@@ -364,7 +364,7 @@ discard block |
||
364 | 364 | * set session data |
365 | 365 | * @access public |
366 | 366 | * @param array $data |
367 | - * @return TRUE on success, FALSE on fail |
|
367 | + * @return boolean on success, FALSE on fail |
|
368 | 368 | */ |
369 | 369 | public function set_session_data( $data ) { |
370 | 370 | |
@@ -392,7 +392,7 @@ discard block |
||
392 | 392 | /** |
393 | 393 | * @initiate session |
394 | 394 | * @access private |
395 | - * @return TRUE on success, FALSE on fail |
|
395 | + * @return boolean on success, FALSE on fail |
|
396 | 396 | * @throws \EE_Error |
397 | 397 | */ |
398 | 398 | private function _espresso_session() { |
@@ -531,7 +531,7 @@ discard block |
||
531 | 531 | * @update session data prior to saving to the db |
532 | 532 | * @access public |
533 | 533 | * @param bool $new_session |
534 | - * @return TRUE on success, FALSE on fail |
|
534 | + * @return boolean on success, FALSE on fail |
|
535 | 535 | */ |
536 | 536 | public function update( $new_session = FALSE ) { |
537 | 537 | $this->_session_data = isset( $this->_session_data ) |
@@ -797,7 +797,7 @@ discard block |
||
797 | 797 | * @access public |
798 | 798 | * @param array $data_to_reset |
799 | 799 | * @param bool $show_all_notices |
800 | - * @return TRUE on success, FALSE on fail |
|
800 | + * @return boolean on success, FALSE on fail |
|
801 | 801 | */ |
802 | 802 | public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
803 | 803 | // if $data_to_reset is not in an array, then put it in one |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\exceptions\InvalidSessionDataException; |
2 | 2 | |
3 | -if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');} |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); } |
|
4 | 4 | /** |
5 | 5 | * |
6 | 6 | * EE_Session class |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * array for defining default session vars |
92 | 92 | * @var array |
93 | 93 | */ |
94 | - private $_default_session_vars = array ( |
|
94 | + private $_default_session_vars = array( |
|
95 | 95 | 'id' => NULL, |
96 | 96 | 'user_id' => NULL, |
97 | 97 | 'ip_address' => NULL, |
@@ -111,12 +111,12 @@ discard block |
||
111 | 111 | * @throws InvalidSessionDataException |
112 | 112 | * @throws \EE_Error |
113 | 113 | */ |
114 | - public static function instance( EE_Encryption $encryption = null ) { |
|
114 | + public static function instance(EE_Encryption $encryption = null) { |
|
115 | 115 | // check if class object is instantiated |
116 | 116 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: |
117 | 117 | // add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
118 | - if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) { |
|
119 | - self::$_instance = new self( $encryption ); |
|
118 | + if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) { |
|
119 | + self::$_instance = new self($encryption); |
|
120 | 120 | } |
121 | 121 | return self::$_instance; |
122 | 122 | } |
@@ -132,15 +132,15 @@ discard block |
||
132 | 132 | * @throws \EE_Error |
133 | 133 | * @throws \EventEspresso\core\exceptions\InvalidSessionDataException |
134 | 134 | */ |
135 | - protected function __construct( EE_Encryption $encryption = null ) { |
|
135 | + protected function __construct(EE_Encryption $encryption = null) { |
|
136 | 136 | |
137 | 137 | // session loading is turned ON by default, but prior to the init hook, can be turned back OFF via: add_filter( 'FHEE_load_EE_Session', '__return_false' ); |
138 | - if ( ! apply_filters( 'FHEE_load_EE_Session', TRUE ) ) { |
|
138 | + if ( ! apply_filters('FHEE_load_EE_Session', TRUE)) { |
|
139 | 139 | return; |
140 | 140 | } |
141 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
142 | - if ( ! defined( 'ESPRESSO_SESSION' ) ) { |
|
143 | - define( 'ESPRESSO_SESSION', true ); |
|
141 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
142 | + if ( ! defined('ESPRESSO_SESSION')) { |
|
143 | + define('ESPRESSO_SESSION', true); |
|
144 | 144 | } |
145 | 145 | // default session lifespan in seconds |
146 | 146 | $this->_lifespan = apply_filters( |
@@ -154,12 +154,12 @@ discard block |
||
154 | 154 | * } |
155 | 155 | */ |
156 | 156 | // retrieve session options from db |
157 | - $session_settings = (array) get_option( 'ee_session_settings', array() ); |
|
158 | - if ( ! empty( $session_settings )) { |
|
157 | + $session_settings = (array) get_option('ee_session_settings', array()); |
|
158 | + if ( ! empty($session_settings)) { |
|
159 | 159 | // cycle though existing session options |
160 | - foreach ( $session_settings as $var_name => $session_setting ) { |
|
160 | + foreach ($session_settings as $var_name => $session_setting) { |
|
161 | 161 | // set values for class properties |
162 | - $var_name = '_' . $var_name; |
|
162 | + $var_name = '_'.$var_name; |
|
163 | 163 | $this->{$var_name} = $session_setting; |
164 | 164 | } |
165 | 165 | } |
@@ -169,16 +169,16 @@ discard block |
||
169 | 169 | // encrypt data via: $this->encryption->encrypt(); |
170 | 170 | $this->encryption = $encryption; |
171 | 171 | // filter hook allows outside functions/classes/plugins to change default empty cart |
172 | - $extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() ); |
|
173 | - array_merge( $this->_default_session_vars, $extra_default_session_vars ); |
|
172 | + $extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array()); |
|
173 | + array_merge($this->_default_session_vars, $extra_default_session_vars); |
|
174 | 174 | // apply default session vars |
175 | 175 | $this->_set_defaults(); |
176 | 176 | add_action('AHEE__EE_System__initialize', array($this, 'open_session')); |
177 | 177 | // check request for 'clear_session' param |
178 | - add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' )); |
|
178 | + add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded')); |
|
179 | 179 | // once everything is all said and done, |
180 | - add_action( 'shutdown', array( $this, 'update' ), 100 ); |
|
181 | - add_action( 'shutdown', array( $this, 'garbage_collection' ), 999 ); |
|
180 | + add_action('shutdown', array($this, 'update'), 100); |
|
181 | + add_action('shutdown', array($this, 'garbage_collection'), 999); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -223,11 +223,11 @@ discard block |
||
223 | 223 | */ |
224 | 224 | private function _set_defaults() { |
225 | 225 | // set some defaults |
226 | - foreach ( $this->_default_session_vars as $key => $default_var ) { |
|
227 | - if ( is_array( $default_var )) { |
|
228 | - $this->_session_data[ $key ] = array(); |
|
226 | + foreach ($this->_default_session_vars as $key => $default_var) { |
|
227 | + if (is_array($default_var)) { |
|
228 | + $this->_session_data[$key] = array(); |
|
229 | 229 | } else { |
230 | - $this->_session_data[ $key ] = ''; |
|
230 | + $this->_session_data[$key] = ''; |
|
231 | 231 | } |
232 | 232 | } |
233 | 233 | } |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | * @param \EE_Cart $cart |
250 | 250 | * @return bool |
251 | 251 | */ |
252 | - public function set_cart( EE_Cart $cart ) { |
|
252 | + public function set_cart(EE_Cart $cart) { |
|
253 | 253 | $this->_session_data['cart'] = $cart; |
254 | 254 | return TRUE; |
255 | 255 | } |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | * @return \EE_Cart |
270 | 270 | */ |
271 | 271 | public function cart() { |
272 | - return isset( $this->_session_data['cart'] ) ? $this->_session_data['cart'] : NULL; |
|
272 | + return isset($this->_session_data['cart']) ? $this->_session_data['cart'] : NULL; |
|
273 | 273 | } |
274 | 274 | |
275 | 275 | |
@@ -278,7 +278,7 @@ discard block |
||
278 | 278 | * @param \EE_Checkout $checkout |
279 | 279 | * @return bool |
280 | 280 | */ |
281 | - public function set_checkout( EE_Checkout $checkout ) { |
|
281 | + public function set_checkout(EE_Checkout $checkout) { |
|
282 | 282 | $this->_session_data['checkout'] = $checkout; |
283 | 283 | return TRUE; |
284 | 284 | } |
@@ -298,7 +298,7 @@ discard block |
||
298 | 298 | * @return \EE_Checkout |
299 | 299 | */ |
300 | 300 | public function checkout() { |
301 | - return isset( $this->_session_data['checkout'] ) ? $this->_session_data['checkout'] : NULL; |
|
301 | + return isset($this->_session_data['checkout']) ? $this->_session_data['checkout'] : NULL; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -308,9 +308,9 @@ discard block |
||
308 | 308 | * @return bool |
309 | 309 | * @throws \EE_Error |
310 | 310 | */ |
311 | - public function set_transaction( EE_Transaction $transaction ) { |
|
311 | + public function set_transaction(EE_Transaction $transaction) { |
|
312 | 312 | // first remove the session from the transaction before we save the transaction in the session |
313 | - $transaction->set_txn_session_data( NULL ); |
|
313 | + $transaction->set_txn_session_data(NULL); |
|
314 | 314 | $this->_session_data['transaction'] = $transaction; |
315 | 315 | return TRUE; |
316 | 316 | } |
@@ -330,7 +330,7 @@ discard block |
||
330 | 330 | * @return \EE_Transaction |
331 | 331 | */ |
332 | 332 | public function transaction() { |
333 | - return isset( $this->_session_data['transaction'] ) ? $this->_session_data['transaction'] : NULL; |
|
333 | + return isset($this->_session_data['transaction']) ? $this->_session_data['transaction'] : NULL; |
|
334 | 334 | } |
335 | 335 | |
336 | 336 | |
@@ -342,15 +342,15 @@ discard block |
||
342 | 342 | * @param bool $reset_cache |
343 | 343 | * @return array |
344 | 344 | */ |
345 | - public function get_session_data( $key = NULL, $reset_cache = FALSE ) { |
|
346 | - if ( $reset_cache ) { |
|
345 | + public function get_session_data($key = NULL, $reset_cache = FALSE) { |
|
346 | + if ($reset_cache) { |
|
347 | 347 | $this->reset_cart(); |
348 | 348 | $this->reset_checkout(); |
349 | 349 | $this->reset_transaction(); |
350 | 350 | } |
351 | - if ( ! empty( $key )) { |
|
352 | - return isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL; |
|
353 | - } else { |
|
351 | + if ( ! empty($key)) { |
|
352 | + return isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL; |
|
353 | + } else { |
|
354 | 354 | return $this->_session_data; |
355 | 355 | } |
356 | 356 | } |
@@ -363,20 +363,20 @@ discard block |
||
363 | 363 | * @param array $data |
364 | 364 | * @return TRUE on success, FALSE on fail |
365 | 365 | */ |
366 | - public function set_session_data( $data ) { |
|
366 | + public function set_session_data($data) { |
|
367 | 367 | |
368 | 368 | // nothing ??? bad data ??? go home! |
369 | - if ( empty( $data ) || ! is_array( $data )) { |
|
370 | - EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
369 | + if (empty($data) || ! is_array($data)) { |
|
370 | + EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
371 | 371 | return FALSE; |
372 | 372 | } |
373 | 373 | |
374 | - foreach ( $data as $key =>$value ) { |
|
375 | - if ( isset( $this->_default_session_vars[ $key ] )) { |
|
376 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ ); |
|
374 | + foreach ($data as $key =>$value) { |
|
375 | + if (isset($this->_default_session_vars[$key])) { |
|
376 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__); |
|
377 | 377 | return FALSE; |
378 | 378 | } else { |
379 | - $this->_session_data[ $key ] = $value; |
|
379 | + $this->_session_data[$key] = $value; |
|
380 | 380 | } |
381 | 381 | } |
382 | 382 | |
@@ -394,9 +394,9 @@ discard block |
||
394 | 394 | * @throws \EE_Error |
395 | 395 | */ |
396 | 396 | private function _espresso_session() { |
397 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
397 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
398 | 398 | // check that session has started |
399 | - if ( session_id() === '' ) { |
|
399 | + if (session_id() === '') { |
|
400 | 400 | //starts a new session if one doesn't already exist, or re-initiates an existing one |
401 | 401 | session_start(); |
402 | 402 | } |
@@ -405,38 +405,38 @@ discard block |
||
405 | 405 | // and the visitors IP |
406 | 406 | $this->_ip_address = $this->_visitor_ip(); |
407 | 407 | // set the "user agent" |
408 | - $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE; |
|
408 | + $this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE; |
|
409 | 409 | // now let's retrieve what's in the db |
410 | 410 | $session_data = $this->_retrieve_session_data(); |
411 | - if (! empty($session_data)) { |
|
411 | + if ( ! empty($session_data)) { |
|
412 | 412 | // get the current time in UTC |
413 | - $this->_time = isset( $this->_time ) ? $this->_time : time(); |
|
413 | + $this->_time = isset($this->_time) ? $this->_time : time(); |
|
414 | 414 | // and reset the session expiration |
415 | - $this->_expiration = isset( $session_data['expiration'] ) |
|
415 | + $this->_expiration = isset($session_data['expiration']) |
|
416 | 416 | ? $session_data['expiration'] |
417 | 417 | : $this->_time + $this->_lifespan; |
418 | 418 | } else { |
419 | 419 | // set initial site access time and the session expiration |
420 | 420 | $this->_set_init_access_and_expiration(); |
421 | 421 | // set referer |
422 | - $this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] ) |
|
423 | - ? esc_attr( $_SERVER['HTTP_REFERER'] ) |
|
422 | + $this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER']) |
|
423 | + ? esc_attr($_SERVER['HTTP_REFERER']) |
|
424 | 424 | : ''; |
425 | 425 | // no previous session = go back and create one (on top of the data above) |
426 | 426 | return FALSE; |
427 | 427 | } |
428 | 428 | // now the user agent |
429 | - if ( $session_data['user_agent'] !== $this->_user_agent ) { |
|
429 | + if ($session_data['user_agent'] !== $this->_user_agent) { |
|
430 | 430 | return FALSE; |
431 | 431 | } |
432 | 432 | // wait a minute... how old are you? |
433 | - if ( $this->_time > $this->_expiration ) { |
|
433 | + if ($this->_time > $this->_expiration) { |
|
434 | 434 | // yer too old fer me! |
435 | 435 | // wipe out everything that isn't a default session datum |
436 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
436 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
437 | 437 | } |
438 | 438 | // make event espresso session data available to plugin |
439 | - $this->_session_data = array_merge( $this->_session_data, $session_data ); |
|
439 | + $this->_session_data = array_merge($this->_session_data, $session_data); |
|
440 | 440 | return TRUE; |
441 | 441 | |
442 | 442 | } |
@@ -452,7 +452,7 @@ discard block |
||
452 | 452 | */ |
453 | 453 | protected function _retrieve_session_data() |
454 | 454 | { |
455 | - $ssn_key = EE_Session::session_id_prefix . $this->_sid; |
|
455 | + $ssn_key = EE_Session::session_id_prefix.$this->_sid; |
|
456 | 456 | try { |
457 | 457 | // we're using WP's Transient API to store session data using the PHP session ID as the option name |
458 | 458 | $session_data = get_transient($ssn_key); |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | return array(); |
461 | 461 | } |
462 | 462 | if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
463 | - $hash_check = get_transient(EE_Session::hash_check_prefix . $this->_sid); |
|
463 | + $hash_check = get_transient(EE_Session::hash_check_prefix.$this->_sid); |
|
464 | 464 | if ($hash_check && $hash_check !== md5($session_data)) { |
465 | 465 | EE_Error::add_error( |
466 | 466 | sprintf( |
467 | 467 | __('The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.', 'event_espresso'), |
468 | - EE_Session::session_id_prefix . $this->_sid |
|
468 | + EE_Session::session_id_prefix.$this->_sid |
|
469 | 469 | ), |
470 | 470 | __FILE__, __FUNCTION__, __LINE__ |
471 | 471 | ); |
@@ -477,17 +477,17 @@ discard block |
||
477 | 477 | $row = $wpdb->get_row( |
478 | 478 | $wpdb->prepare( |
479 | 479 | "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1", |
480 | - '_transient_' . $ssn_key |
|
480 | + '_transient_'.$ssn_key |
|
481 | 481 | ) |
482 | 482 | ); |
483 | 483 | $session_data = is_object($row) ? $row->option_value : null; |
484 | 484 | if ($session_data) { |
485 | 485 | $session_data = preg_replace_callback( |
486 | 486 | '!s:(d+):"(.*?)";!', |
487 | - function ($match) { |
|
487 | + function($match) { |
|
488 | 488 | return $match[1] === strlen($match[2]) |
489 | 489 | ? $match[0] |
490 | - : 's:' . strlen($match[2]) . ':"' . $match[2] . '";'; |
|
490 | + : 's:'.strlen($match[2]).':"'.$match[2].'";'; |
|
491 | 491 | }, |
492 | 492 | $session_data |
493 | 493 | ); |
@@ -508,7 +508,7 @@ discard block |
||
508 | 508 | 'event_espresso' |
509 | 509 | ); |
510 | 510 | $msg .= WP_DEBUG |
511 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
511 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
512 | 512 | : ''; |
513 | 513 | throw new InvalidSessionDataException($msg, 0, $e); |
514 | 514 | } |
@@ -521,11 +521,11 @@ discard block |
||
521 | 521 | 'event_espresso' |
522 | 522 | ); |
523 | 523 | $msg .= WP_DEBUG |
524 | - ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data) |
|
524 | + ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data) |
|
525 | 525 | : ''; |
526 | 526 | throw new InvalidSessionDataException($msg); |
527 | 527 | } |
528 | - if ( isset( $this->_session_data['transaction'] ) && absint( $this->_session_data['transaction'] ) !== 0 ) { |
|
528 | + if (isset($this->_session_data['transaction']) && absint($this->_session_data['transaction']) !== 0) { |
|
529 | 529 | $this->_session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID( |
530 | 530 | $this->_session_data['transaction'] |
531 | 531 | ); |
@@ -546,12 +546,12 @@ discard block |
||
546 | 546 | */ |
547 | 547 | protected function _generate_session_id() { |
548 | 548 | // check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length |
549 | - if ( isset( $_REQUEST[ 'EESID' ] ) ) { |
|
550 | - $session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] ); |
|
549 | + if (isset($_REQUEST['EESID'])) { |
|
550 | + $session_id = sanitize_text_field($_REQUEST['EESID']); |
|
551 | 551 | } else { |
552 | - $session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() ); |
|
552 | + $session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt()); |
|
553 | 553 | } |
554 | - return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id ); |
|
554 | + return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id); |
|
555 | 555 | } |
556 | 556 | |
557 | 557 | |
@@ -563,20 +563,20 @@ discard block |
||
563 | 563 | */ |
564 | 564 | protected function _get_sid_salt() { |
565 | 565 | // was session id salt already saved to db ? |
566 | - if ( empty( $this->_sid_salt ) ) { |
|
566 | + if (empty($this->_sid_salt)) { |
|
567 | 567 | // no? then maybe use WP defined constant |
568 | - if ( defined( 'AUTH_SALT' ) ) { |
|
568 | + if (defined('AUTH_SALT')) { |
|
569 | 569 | $this->_sid_salt = AUTH_SALT; |
570 | 570 | } |
571 | 571 | // if salt doesn't exist or is too short |
572 | - if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) { |
|
572 | + if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) { |
|
573 | 573 | // create a new one |
574 | - $this->_sid_salt = wp_generate_password( 64 ); |
|
574 | + $this->_sid_salt = wp_generate_password(64); |
|
575 | 575 | } |
576 | 576 | // and save it as a permanent session setting |
577 | - $session_settings = get_option( 'ee_session_settings' ); |
|
578 | - $session_settings[ 'sid_salt' ] = $this->_sid_salt; |
|
579 | - update_option( 'ee_session_settings', $session_settings ); |
|
577 | + $session_settings = get_option('ee_session_settings'); |
|
578 | + $session_settings['sid_salt'] = $this->_sid_salt; |
|
579 | + update_option('ee_session_settings', $session_settings); |
|
580 | 580 | } |
581 | 581 | return $this->_sid_salt; |
582 | 582 | } |
@@ -604,19 +604,19 @@ discard block |
||
604 | 604 | * @param bool $new_session |
605 | 605 | * @return TRUE on success, FALSE on fail |
606 | 606 | */ |
607 | - public function update( $new_session = FALSE ) { |
|
608 | - $this->_session_data = isset( $this->_session_data ) |
|
609 | - && is_array( $this->_session_data ) |
|
610 | - && isset( $this->_session_data['id']) |
|
607 | + public function update($new_session = FALSE) { |
|
608 | + $this->_session_data = isset($this->_session_data) |
|
609 | + && is_array($this->_session_data) |
|
610 | + && isset($this->_session_data['id']) |
|
611 | 611 | ? $this->_session_data |
612 | 612 | : array(); |
613 | - if ( empty( $this->_session_data )) { |
|
613 | + if (empty($this->_session_data)) { |
|
614 | 614 | $this->_set_defaults(); |
615 | 615 | } |
616 | 616 | $session_data = array(); |
617 | - foreach ( $this->_session_data as $key => $value ) { |
|
617 | + foreach ($this->_session_data as $key => $value) { |
|
618 | 618 | |
619 | - switch( $key ) { |
|
619 | + switch ($key) { |
|
620 | 620 | |
621 | 621 | case 'id' : |
622 | 622 | // session ID |
@@ -634,7 +634,7 @@ discard block |
||
634 | 634 | break; |
635 | 635 | |
636 | 636 | case 'init_access' : |
637 | - $session_data['init_access'] = absint( $value ); |
|
637 | + $session_data['init_access'] = absint($value); |
|
638 | 638 | break; |
639 | 639 | |
640 | 640 | case 'last_access' : |
@@ -644,7 +644,7 @@ discard block |
||
644 | 644 | |
645 | 645 | case 'expiration' : |
646 | 646 | // when the session expires |
647 | - $session_data['expiration'] = ! empty( $this->_expiration ) |
|
647 | + $session_data['expiration'] = ! empty($this->_expiration) |
|
648 | 648 | ? $this->_expiration |
649 | 649 | : $session_data['init_access'] + $this->_lifespan; |
650 | 650 | break; |
@@ -656,11 +656,11 @@ discard block |
||
656 | 656 | |
657 | 657 | case 'pages_visited' : |
658 | 658 | $page_visit = $this->_get_page_visit(); |
659 | - if ( $page_visit ) { |
|
659 | + if ($page_visit) { |
|
660 | 660 | // set pages visited where the first will be the http referrer |
661 | - $this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit; |
|
661 | + $this->_session_data['pages_visited'][$this->_time] = $page_visit; |
|
662 | 662 | // we'll only save the last 10 page visits. |
663 | - $session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 ); |
|
663 | + $session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10); |
|
664 | 664 | } |
665 | 665 | break; |
666 | 666 | |
@@ -674,9 +674,9 @@ discard block |
||
674 | 674 | |
675 | 675 | $this->_session_data = $session_data; |
676 | 676 | // creating a new session does not require saving to the db just yet |
677 | - if ( ! $new_session ) { |
|
677 | + if ( ! $new_session) { |
|
678 | 678 | // ready? let's save |
679 | - if ( $this->_save_session_to_db() ) { |
|
679 | + if ($this->_save_session_to_db()) { |
|
680 | 680 | return TRUE; |
681 | 681 | } else { |
682 | 682 | return FALSE; |
@@ -695,9 +695,9 @@ discard block |
||
695 | 695 | * @return bool |
696 | 696 | */ |
697 | 697 | private function _create_espresso_session( ) { |
698 | - do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' ); |
|
698 | + do_action('AHEE_log', __CLASS__, __FUNCTION__, ''); |
|
699 | 699 | // use the update function for now with $new_session arg set to TRUE |
700 | - return $this->update( TRUE ) ? TRUE : FALSE; |
|
700 | + return $this->update(TRUE) ? TRUE : FALSE; |
|
701 | 701 | } |
702 | 702 | |
703 | 703 | |
@@ -723,15 +723,15 @@ discard block |
||
723 | 723 | // OR an admin request that is NOT AJAX |
724 | 724 | || ( |
725 | 725 | is_admin() |
726 | - && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) |
|
726 | + && ! (defined('DOING_AJAX') && DOING_AJAX) |
|
727 | 727 | ) |
728 | 728 | ) |
729 | 729 | ) { |
730 | 730 | return false; |
731 | 731 | } |
732 | 732 | $transaction = $this->transaction(); |
733 | - if ( $transaction instanceof EE_Transaction ) { |
|
734 | - if ( ! $transaction->ID() ) { |
|
733 | + if ($transaction instanceof EE_Transaction) { |
|
734 | + if ( ! $transaction->ID()) { |
|
735 | 735 | $transaction->save(); |
736 | 736 | } |
737 | 737 | $this->_session_data['transaction'] = $transaction->ID(); |
@@ -744,17 +744,17 @@ discard block |
||
744 | 744 | //in a different encoding, like ANSI. |
745 | 745 | //we double-check the function exists first because it's labelled "private", so it's possible it will be removed |
746 | 746 | //from WP some day2 |
747 | - if( function_exists( '_wp_json_convert_string' ) ) { |
|
748 | - $session_data = _wp_json_convert_string( $session_data ); |
|
747 | + if (function_exists('_wp_json_convert_string')) { |
|
748 | + $session_data = _wp_json_convert_string($session_data); |
|
749 | 749 | } |
750 | 750 | // do we need to also encode it to avoid corrupted data when saved to the db? |
751 | - $session_data = $this->_use_encryption ? $this->encryption->base64_string_encode( $session_data ) : $session_data; |
|
751 | + $session_data = $this->_use_encryption ? $this->encryption->base64_string_encode($session_data) : $session_data; |
|
752 | 752 | // maybe save hash check |
753 | - if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) { |
|
754 | - set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan ); |
|
753 | + if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) { |
|
754 | + set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan); |
|
755 | 755 | } |
756 | 756 | // we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient( transient ID, data, expiry ) |
757 | - return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan ); |
|
757 | + return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan); |
|
758 | 758 | } |
759 | 759 | |
760 | 760 | |
@@ -780,10 +780,10 @@ discard block |
||
780 | 780 | 'HTTP_FORWARDED', |
781 | 781 | 'REMOTE_ADDR' |
782 | 782 | ); |
783 | - foreach ( $server_keys as $key ){ |
|
784 | - if ( isset( $_SERVER[ $key ] )) { |
|
785 | - foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) { |
|
786 | - if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) { |
|
783 | + foreach ($server_keys as $key) { |
|
784 | + if (isset($_SERVER[$key])) { |
|
785 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
786 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) { |
|
787 | 787 | $visitor_ip = $ip; |
788 | 788 | } |
789 | 789 | } |
@@ -802,32 +802,32 @@ discard block |
||
802 | 802 | * @return string |
803 | 803 | */ |
804 | 804 | public function _get_page_visit() { |
805 | - $page_visit = home_url('/') . 'wp-admin/admin-ajax.php'; |
|
805 | + $page_visit = home_url('/').'wp-admin/admin-ajax.php'; |
|
806 | 806 | // check for request url |
807 | - if ( isset( $_SERVER['REQUEST_URI'] )) { |
|
807 | + if (isset($_SERVER['REQUEST_URI'])) { |
|
808 | 808 | $http_host = ''; |
809 | 809 | $page_id = '?'; |
810 | 810 | $e_reg = ''; |
811 | - $request_uri = esc_url( $_SERVER['REQUEST_URI'] ); |
|
812 | - $ru_bits = explode( '?', $request_uri ); |
|
811 | + $request_uri = esc_url($_SERVER['REQUEST_URI']); |
|
812 | + $ru_bits = explode('?', $request_uri); |
|
813 | 813 | $request_uri = $ru_bits[0]; |
814 | 814 | // check for and grab host as well |
815 | - if ( isset( $_SERVER['HTTP_HOST'] )) { |
|
816 | - $http_host = esc_url( $_SERVER['HTTP_HOST'] ); |
|
815 | + if (isset($_SERVER['HTTP_HOST'])) { |
|
816 | + $http_host = esc_url($_SERVER['HTTP_HOST']); |
|
817 | 817 | } |
818 | 818 | // check for page_id in SERVER REQUEST |
819 | - if ( isset( $_REQUEST['page_id'] )) { |
|
819 | + if (isset($_REQUEST['page_id'])) { |
|
820 | 820 | // rebuild $e_reg without any of the extra parameters |
821 | - $page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&'; |
|
821 | + $page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&'; |
|
822 | 822 | } |
823 | 823 | // check for $e_reg in SERVER REQUEST |
824 | - if ( isset( $_REQUEST['ee'] )) { |
|
824 | + if (isset($_REQUEST['ee'])) { |
|
825 | 825 | // rebuild $e_reg without any of the extra parameters |
826 | - $e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] ); |
|
826 | + $e_reg = 'ee='.esc_attr($_REQUEST['ee']); |
|
827 | 827 | } |
828 | - $page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' ); |
|
828 | + $page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?'); |
|
829 | 829 | } |
830 | - return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : ''; |
|
830 | + return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : ''; |
|
831 | 831 | |
832 | 832 | } |
833 | 833 | |
@@ -856,14 +856,14 @@ discard block |
||
856 | 856 | * @param string $function |
857 | 857 | * @return void |
858 | 858 | */ |
859 | - public function clear_session( $class = '', $function = '' ) { |
|
859 | + public function clear_session($class = '', $function = '') { |
|
860 | 860 | //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>'; |
861 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' . $function . '()' ); |
|
861 | + do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()'); |
|
862 | 862 | $this->reset_cart(); |
863 | 863 | $this->reset_checkout(); |
864 | 864 | $this->reset_transaction(); |
865 | 865 | // wipe out everything that isn't a default session datum |
866 | - $this->reset_data( array_keys( $this->_session_data )); |
|
866 | + $this->reset_data(array_keys($this->_session_data)); |
|
867 | 867 | // reset initial site access time and the session expiration |
868 | 868 | $this->_set_init_access_and_expiration(); |
869 | 869 | $this->_save_session_to_db(); |
@@ -878,42 +878,42 @@ discard block |
||
878 | 878 | * @param bool $show_all_notices |
879 | 879 | * @return TRUE on success, FALSE on fail |
880 | 880 | */ |
881 | - public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) { |
|
881 | + public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) { |
|
882 | 882 | // if $data_to_reset is not in an array, then put it in one |
883 | - if ( ! is_array( $data_to_reset ) ) { |
|
884 | - $data_to_reset = array ( $data_to_reset ); |
|
883 | + if ( ! is_array($data_to_reset)) { |
|
884 | + $data_to_reset = array($data_to_reset); |
|
885 | 885 | } |
886 | 886 | // nothing ??? go home! |
887 | - if ( empty( $data_to_reset )) { |
|
888 | - EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ ); |
|
887 | + if (empty($data_to_reset)) { |
|
888 | + EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
889 | 889 | return FALSE; |
890 | 890 | } |
891 | 891 | $return_value = TRUE; |
892 | 892 | // since $data_to_reset is an array, cycle through the values |
893 | - foreach ( $data_to_reset as $reset ) { |
|
893 | + foreach ($data_to_reset as $reset) { |
|
894 | 894 | |
895 | 895 | // first check to make sure it is a valid session var |
896 | - if ( isset( $this->_session_data[ $reset ] )) { |
|
896 | + if (isset($this->_session_data[$reset])) { |
|
897 | 897 | // then check to make sure it is not a default var |
898 | - if ( ! array_key_exists( $reset, $this->_default_session_vars )) { |
|
898 | + if ( ! array_key_exists($reset, $this->_default_session_vars)) { |
|
899 | 899 | // remove session var |
900 | - unset( $this->_session_data[ $reset ] ); |
|
901 | - if ( $show_all_notices ) { |
|
902 | - EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
900 | + unset($this->_session_data[$reset]); |
|
901 | + if ($show_all_notices) { |
|
902 | + EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
903 | 903 | } |
904 | - $return_value = !isset($return_value) ? TRUE : $return_value; |
|
904 | + $return_value = ! isset($return_value) ? TRUE : $return_value; |
|
905 | 905 | |
906 | 906 | } else { |
907 | 907 | // yeeeeeeeeerrrrrrrrrrr OUT !!!! |
908 | - if ( $show_all_notices ) { |
|
909 | - EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
908 | + if ($show_all_notices) { |
|
909 | + EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
910 | 910 | } |
911 | 911 | $return_value = FALSE; |
912 | 912 | } |
913 | 913 | |
914 | - } else if ( $show_all_notices ) { |
|
914 | + } else if ($show_all_notices) { |
|
915 | 915 | // oops! that session var does not exist! |
916 | - EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ ); |
|
916 | + EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__); |
|
917 | 917 | $return_value = FALSE; |
918 | 918 | } |
919 | 919 | |
@@ -933,8 +933,8 @@ discard block |
||
933 | 933 | * @access public |
934 | 934 | */ |
935 | 935 | public function wp_loaded() { |
936 | - if ( isset( EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) { |
|
937 | - $this->clear_session( __CLASS__, __FUNCTION__ ); |
|
936 | + if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) { |
|
937 | + $this->clear_session(__CLASS__, __FUNCTION__); |
|
938 | 938 | } |
939 | 939 | } |
940 | 940 | |
@@ -959,24 +959,24 @@ discard block |
||
959 | 959 | */ |
960 | 960 | public function garbage_collection() { |
961 | 961 | // only perform during regular requests |
962 | - if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) { |
|
962 | + if ( ! defined('DOING_AJAX') || ! DOING_AJAX) { |
|
963 | 963 | /** @type WPDB $wpdb */ |
964 | 964 | global $wpdb; |
965 | 965 | // since transient expiration timestamps are set in the future, we can compare against NOW |
966 | 966 | $expiration = time(); |
967 | - $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 ); |
|
967 | + $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2); |
|
968 | 968 | // filter the query limit. Set to 0 to turn off garbage collection |
969 | - $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 )); |
|
969 | + $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50)); |
|
970 | 970 | // non-zero LIMIT means take out the trash |
971 | - if ( $expired_session_transient_delete_query_limit ) { |
|
971 | + if ($expired_session_transient_delete_query_limit) { |
|
972 | 972 | //array of transient keys that require garbage collection |
973 | 973 | $session_keys = array( |
974 | 974 | EE_Session::session_id_prefix, |
975 | 975 | EE_Session::hash_check_prefix, |
976 | 976 | ); |
977 | - foreach ( $session_keys as $session_key ) { |
|
978 | - $session_key = str_replace( '_', '\_', $session_key ); |
|
979 | - $session_key = '\_transient\_timeout\_' . $session_key . '%'; |
|
977 | + foreach ($session_keys as $session_key) { |
|
978 | + $session_key = str_replace('_', '\_', $session_key); |
|
979 | + $session_key = '\_transient\_timeout\_'.$session_key.'%'; |
|
980 | 980 | $SQL = " |
981 | 981 | SELECT option_name |
982 | 982 | FROM {$wpdb->options} |
@@ -986,25 +986,25 @@ discard block |
||
986 | 986 | OR option_value > {$too_far_in_the_the_future} ) |
987 | 987 | LIMIT {$expired_session_transient_delete_query_limit} |
988 | 988 | "; |
989 | - $expired_sessions = $wpdb->get_col( $SQL ); |
|
989 | + $expired_sessions = $wpdb->get_col($SQL); |
|
990 | 990 | // valid results? |
991 | - if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) { |
|
991 | + if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) { |
|
992 | 992 | // format array of results into something usable within the actual DELETE query's IN clause |
993 | 993 | $expired = array(); |
994 | - foreach ( $expired_sessions as $expired_session ) { |
|
995 | - $expired[ ] = "'" . $expired_session . "'"; |
|
996 | - $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'"; |
|
994 | + foreach ($expired_sessions as $expired_session) { |
|
995 | + $expired[] = "'".$expired_session."'"; |
|
996 | + $expired[] = "'".str_replace('timeout_', '', $expired_session)."'"; |
|
997 | 997 | } |
998 | - $expired = implode( ', ', $expired ); |
|
998 | + $expired = implode(', ', $expired); |
|
999 | 999 | $SQL = " |
1000 | 1000 | DELETE FROM {$wpdb->options} |
1001 | 1001 | WHERE option_name |
1002 | 1002 | IN ( $expired ); |
1003 | 1003 | "; |
1004 | - $results = $wpdb->query( $SQL ); |
|
1004 | + $results = $wpdb->query($SQL); |
|
1005 | 1005 | // if something went wrong, then notify the admin |
1006 | - if ( $results instanceof WP_Error && is_admin() ) { |
|
1007 | - EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
1006 | + if ($results instanceof WP_Error && is_admin()) { |
|
1007 | + EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
1008 | 1008 | } |
1009 | 1009 | } |
1010 | 1010 | } |
@@ -1025,34 +1025,34 @@ discard block |
||
1025 | 1025 | * @param $data1 |
1026 | 1026 | * @return string |
1027 | 1027 | */ |
1028 | - private function find_serialize_error( $data1 ) { |
|
1028 | + private function find_serialize_error($data1) { |
|
1029 | 1029 | $error = "<pre>"; |
1030 | 1030 | $data2 = preg_replace_callback( |
1031 | 1031 | '!s:(\d+):"(.*?)";!', |
1032 | - function ( $match ) { |
|
1033 | - return ( $match[1] === strlen( $match[2] ) ) |
|
1032 | + function($match) { |
|
1033 | + return ($match[1] === strlen($match[2])) |
|
1034 | 1034 | ? $match[0] |
1035 | 1035 | : 's:' |
1036 | - . strlen( $match[2] ) |
|
1036 | + . strlen($match[2]) |
|
1037 | 1037 | . ':"' |
1038 | 1038 | . $match[2] |
1039 | 1039 | . '";'; |
1040 | 1040 | }, |
1041 | 1041 | $data1 |
1042 | 1042 | ); |
1043 | - $max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 ); |
|
1044 | - $error .= $data1 . PHP_EOL; |
|
1045 | - $error .= $data2 . PHP_EOL; |
|
1046 | - for ( $i = 0; $i < $max; $i++ ) { |
|
1047 | - if ( @$data1[ $i ] !== @$data2[ $i ] ) { |
|
1048 | - $error .= "Difference " . @$data1[ $i ] . " != " . @$data2[ $i ] . PHP_EOL; |
|
1049 | - $error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . " != " . ord( @$data2[ $i ] ) . PHP_EOL; |
|
1050 | - $error .= "\t-> Line Number = $i" . PHP_EOL; |
|
1051 | - $start = ( $i - 20 ); |
|
1052 | - $start = ( $start < 0 ) ? 0 : $start; |
|
1043 | + $max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2); |
|
1044 | + $error .= $data1.PHP_EOL; |
|
1045 | + $error .= $data2.PHP_EOL; |
|
1046 | + for ($i = 0; $i < $max; $i++) { |
|
1047 | + if (@$data1[$i] !== @$data2[$i]) { |
|
1048 | + $error .= "Difference ".@$data1[$i]." != ".@$data2[$i].PHP_EOL; |
|
1049 | + $error .= "\t-> ORD number ".ord(@$data1[$i])." != ".ord(@$data2[$i]).PHP_EOL; |
|
1050 | + $error .= "\t-> Line Number = $i".PHP_EOL; |
|
1051 | + $start = ($i - 20); |
|
1052 | + $start = ($start < 0) ? 0 : $start; |
|
1053 | 1053 | $length = 40; |
1054 | 1054 | $point = $max - $i; |
1055 | - if ( $point < 20 ) { |
|
1055 | + if ($point < 20) { |
|
1056 | 1056 | $rlength = 1; |
1057 | 1057 | $rpoint = -$point; |
1058 | 1058 | } else { |
@@ -1061,16 +1061,16 @@ discard block |
||
1061 | 1061 | } |
1062 | 1062 | $error .= "\t-> Section Data1 = "; |
1063 | 1063 | $error .= substr_replace( |
1064 | - substr( $data1, $start, $length ), |
|
1065 | - "<b style=\"color:green\">{$data1[ $i ]}</b>", |
|
1064 | + substr($data1, $start, $length), |
|
1065 | + "<b style=\"color:green\">{$data1[$i]}</b>", |
|
1066 | 1066 | $rpoint, |
1067 | 1067 | $rlength |
1068 | 1068 | ); |
1069 | 1069 | $error .= PHP_EOL; |
1070 | 1070 | $error .= "\t-> Section Data2 = "; |
1071 | 1071 | $error .= substr_replace( |
1072 | - substr( $data2, $start, $length ), |
|
1073 | - "<b style=\"color:red\">{$data2[ $i ]}</b>", |
|
1072 | + substr($data2, $start, $length), |
|
1073 | + "<b style=\"color:red\">{$data2[$i]}</b>", |
|
1074 | 1074 | $rpoint, |
1075 | 1075 | $rlength |
1076 | 1076 | ); |
@@ -472,13 +472,13 @@ |
||
472 | 472 | |
473 | 473 | function set_must_use_event_types() { |
474 | 474 | $term_details = array( |
475 | - //Attendee's register for the first date-time only |
|
475 | + //Attendee's register for the first date-time only |
|
476 | 476 | 'single-event' => array( __('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days.', 'event_espresso') ), //example: a party or two-day long workshop |
477 | - //Attendee's can register for any of the date-times |
|
477 | + //Attendee's can register for any of the date-times |
|
478 | 478 | 'multi-event' => array( __('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso') ), //example: a three day music festival or week long conference |
479 | - //Attendee's register for the first date-time only |
|
479 | + //Attendee's register for the first date-time only |
|
480 | 480 | 'event-series' => array( __('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: an 8 week introduction to basket weaving course |
481 | - //Attendee's can register for any of the date-times. |
|
481 | + //Attendee's can register for any of the date-times. |
|
482 | 482 | 'recurring-event' => array( __('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: a yoga class |
483 | 483 | |
484 | 484 | 'ongoing' => array( __('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso') ) //example: access to a museum |
@@ -23,37 +23,37 @@ discard block |
||
23 | 23 | * constructor |
24 | 24 | * instantiated at init priority 5 |
25 | 25 | */ |
26 | - function __construct(){ |
|
26 | + function __construct() { |
|
27 | 27 | // register taxonomies |
28 | 28 | $taxonomies = self::get_taxonomies(); |
29 | - foreach ( $taxonomies as $taxonomy => $tax ) { |
|
30 | - $this->register_taxonomy( $taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args'] ); |
|
29 | + foreach ($taxonomies as $taxonomy => $tax) { |
|
30 | + $this->register_taxonomy($taxonomy, $tax['singular_name'], $tax['plural_name'], $tax['args']); |
|
31 | 31 | } |
32 | 32 | // register CPTs |
33 | - $CPTs =self::get_CPTs(); |
|
34 | - foreach ( $CPTs as $CPT_name => $CPT ) { |
|
35 | - $this->register_CPT( $CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], $CPT['singular_slug'], $CPT['plural_slug'] ); |
|
33 | + $CPTs = self::get_CPTs(); |
|
34 | + foreach ($CPTs as $CPT_name => $CPT) { |
|
35 | + $this->register_CPT($CPT_name, $CPT['singular_name'], $CPT['plural_name'], $CPT['args'], $CPT['singular_slug'], $CPT['plural_slug']); |
|
36 | 36 | } |
37 | 37 | // setup default terms in any of our taxonomies (but only if we're in admin). |
38 | 38 | // Why not added via register_activation_hook? |
39 | 39 | // Because it's possible that in future iterations of EE we may add new defaults for specialized taxonomies (think event_types) and register_activation_hook only reliably runs when a user manually activates the plugin. |
40 | 40 | // Keep in mind that this will READ these terms if they are deleted by the user. Hence MUST use terms. |
41 | - if ( is_admin() ) { |
|
41 | + if (is_admin()) { |
|
42 | 42 | $this->set_must_use_event_types(); |
43 | 43 | } |
44 | 44 | //set default terms |
45 | - $this->set_default_term( 'espresso_event_type', 'single-event', array('espresso_events') ); |
|
45 | + $this->set_default_term('espresso_event_type', 'single-event', array('espresso_events')); |
|
46 | 46 | |
47 | 47 | |
48 | - add_action( 'AHEE__EE_System__initialize_last', array( __CLASS__, 'maybe_flush_rewrite_rules' ), 10 ); |
|
48 | + add_action('AHEE__EE_System__initialize_last', array(__CLASS__, 'maybe_flush_rewrite_rules'), 10); |
|
49 | 49 | |
50 | 50 | //hook into save_post so that we can make sure that the default terms get saved on publish of registered cpts IF they don't have a term for that taxonomy set. |
51 | - add_action('save_post', array( $this, 'save_default_term' ), 100, 2 ); |
|
51 | + add_action('save_post', array($this, 'save_default_term'), 100, 2); |
|
52 | 52 | |
53 | 53 | //remove no html restrictions from core wp saving of term descriptions. Note. this will affect only registered EE taxonomies. |
54 | 54 | $this->_allow_html_descriptions_for_ee_taxonomies(); |
55 | 55 | |
56 | - do_action( 'AHEE__EE_Register_CPTs__construct_end', $this ); |
|
56 | + do_action('AHEE__EE_Register_CPTs__construct_end', $this); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
@@ -66,9 +66,9 @@ discard block |
||
66 | 66 | * @return void |
67 | 67 | */ |
68 | 68 | public static function maybe_flush_rewrite_rules() { |
69 | - if ( get_option( 'ee_flush_rewrite_rules', TRUE )) { |
|
69 | + if (get_option('ee_flush_rewrite_rules', TRUE)) { |
|
70 | 70 | flush_rewrite_rules(); |
71 | - update_option( 'ee_flush_rewrite_rules', FALSE ); |
|
71 | + update_option('ee_flush_rewrite_rules', FALSE); |
|
72 | 72 | } |
73 | 73 | } |
74 | 74 | |
@@ -83,7 +83,7 @@ discard block |
||
83 | 83 | protected function _allow_html_descriptions_for_ee_taxonomies() { |
84 | 84 | //first remove default filter for term description but we have to do this earlier before wp sets their own filter |
85 | 85 | //because they just set a global filter on all term descriptions before the custom term description filter. Really sux. |
86 | - add_filter( 'pre_term_description', array( $this, 'ee_filter_ee_term_description_not_wp' ), 1, 2 ); |
|
86 | + add_filter('pre_term_description', array($this, 'ee_filter_ee_term_description_not_wp'), 1, 2); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | |
@@ -93,16 +93,16 @@ discard block |
||
93 | 93 | * @param string $taxonomy The taxonomy name for the taxonomy being filtered. |
94 | 94 | * @return string |
95 | 95 | */ |
96 | - public function ee_filter_ee_term_description_not_wp( $description, $taxonomy ) { |
|
96 | + public function ee_filter_ee_term_description_not_wp($description, $taxonomy) { |
|
97 | 97 | //get a list of EE taxonomies |
98 | - $ee_taxonomies = array_keys( self::get_taxonomies() ); |
|
98 | + $ee_taxonomies = array_keys(self::get_taxonomies()); |
|
99 | 99 | |
100 | 100 | //only do our own thing if the taxonomy listed is an ee taxonomy. |
101 | - if ( in_array( $taxonomy, $ee_taxonomies ) ) { |
|
101 | + if (in_array($taxonomy, $ee_taxonomies)) { |
|
102 | 102 | //remove default wp filter |
103 | - remove_filter( 'pre_term_description', 'wp_filter_kses' ); |
|
103 | + remove_filter('pre_term_description', 'wp_filter_kses'); |
|
104 | 104 | //sanitize THIS content. |
105 | - $description = wp_kses( $description, wp_kses_allowed_html( 'post' ) ); |
|
105 | + $description = wp_kses($description, wp_kses_allowed_html('post')); |
|
106 | 106 | } |
107 | 107 | return $description; |
108 | 108 | } |
@@ -116,9 +116,9 @@ discard block |
||
116 | 116 | * @access public |
117 | 117 | * @return array |
118 | 118 | */ |
119 | - public static function get_taxonomies(){ |
|
119 | + public static function get_taxonomies() { |
|
120 | 120 | // define taxonomies |
121 | - return apply_filters( 'FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
121 | + return apply_filters('FHEE__EE_Register_CPTs__get_taxonomies__taxonomies', array( |
|
122 | 122 | 'espresso_event_categories' => array( |
123 | 123 | 'singular_name' => __("Event Category", "event_espresso"), |
124 | 124 | 'plural_name' => __("Event Categories", "event_espresso"), |
@@ -132,7 +132,7 @@ discard block |
||
132 | 132 | 'delete_terms' => 'ee_delete_event_category', |
133 | 133 | 'assign_terms' => 'ee_assign_event_category' |
134 | 134 | ), |
135 | - 'rewrite' => array( 'slug' => __( 'event-category', 'event_espresso' )) |
|
135 | + 'rewrite' => array('slug' => __('event-category', 'event_espresso')) |
|
136 | 136 | )), |
137 | 137 | 'espresso_venue_categories' => array( |
138 | 138 | 'singular_name' => __("Venue Category", "event_espresso"), |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | 'delete_terms' => 'ee_delete_venue_category', |
148 | 148 | 'assign_terms' => 'ee_assign_venue_category' |
149 | 149 | ), |
150 | - 'rewrite' => array( 'slug' => __( 'venue-category', 'event_espresso' )) |
|
150 | + 'rewrite' => array('slug' => __('venue-category', 'event_espresso')) |
|
151 | 151 | )), |
152 | 152 | 'espresso_event_type' => array( |
153 | 153 | 'singular_name' => __("Event Type", "event_espresso"), |
@@ -162,10 +162,10 @@ discard block |
||
162 | 162 | 'delete_terms' => 'ee_delete_event_type', |
163 | 163 | 'assign_terms' => 'ee_assign_event_type' |
164 | 164 | ), |
165 | - 'rewrite' => array( 'slug' => __( 'event-type', 'event_espresso' )), |
|
165 | + 'rewrite' => array('slug' => __('event-type', 'event_espresso')), |
|
166 | 166 | 'hierarchical'=>true |
167 | 167 | )) |
168 | - ) ); |
|
168 | + )); |
|
169 | 169 | } |
170 | 170 | |
171 | 171 | |
@@ -183,26 +183,26 @@ discard block |
||
183 | 183 | * @return array Empty array if no matching model names for the given slug or an array of model |
184 | 184 | * names indexed by post type slug. |
185 | 185 | */ |
186 | - public static function get_cpt_model_names( $post_type_slug = '' ) { |
|
186 | + public static function get_cpt_model_names($post_type_slug = '') { |
|
187 | 187 | $cpts = self::get_CPTs(); |
188 | 188 | |
189 | 189 | //first if slug passed in... |
190 | - if ( ! empty( $post_type_slug ) ) { |
|
190 | + if ( ! empty($post_type_slug)) { |
|
191 | 191 | //match? |
192 | - if ( ! isset( $cpts[$post_type_slug] ) || ( isset( $cpts[$post_type_slug] ) && empty( $cpts[$post_type_slug]['class_name'] ) ) ) { |
|
192 | + if ( ! isset($cpts[$post_type_slug]) || (isset($cpts[$post_type_slug]) && empty($cpts[$post_type_slug]['class_name']))) { |
|
193 | 193 | return array(); |
194 | 194 | } |
195 | 195 | |
196 | 196 | //k let's get the model name for this cpt. |
197 | - return array( $post_type_slug => str_replace( 'EE', 'EEM', $cpts[$post_type_slug]['class_name'] ) ); |
|
197 | + return array($post_type_slug => str_replace('EE', 'EEM', $cpts[$post_type_slug]['class_name'])); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
201 | 201 | //if we made it here then we're returning an array of cpt model names indexed by post_type_slug. |
202 | 202 | $cpt_models = array(); |
203 | - foreach ( $cpts as $slug => $args ) { |
|
204 | - if ( ! empty( $args['class_name'] ) ) { |
|
205 | - $cpt_models[$slug] = str_replace( 'EE', 'EEM', $args['class_name'] ); |
|
203 | + foreach ($cpts as $slug => $args) { |
|
204 | + if ( ! empty($args['class_name'])) { |
|
205 | + $cpt_models[$slug] = str_replace('EE', 'EEM', $args['class_name']); |
|
206 | 206 | } |
207 | 207 | } |
208 | 208 | return $cpt_models; |
@@ -223,12 +223,12 @@ discard block |
||
223 | 223 | * @return EEM_CPT_Base[] successful instantiation will return an array of successfully instantiated EEM |
224 | 224 | * models indexed by post slug. |
225 | 225 | */ |
226 | - public static function instantiate_cpt_models( $post_type_slug = '' ) { |
|
227 | - $cpt_model_names = self::get_cpt_model_names( $post_type_slug ); |
|
226 | + public static function instantiate_cpt_models($post_type_slug = '') { |
|
227 | + $cpt_model_names = self::get_cpt_model_names($post_type_slug); |
|
228 | 228 | $instantiated = array(); |
229 | - foreach ( $cpt_model_names as $slug => $model_name ) { |
|
230 | - $instance = EE_Registry::instance()->load_model( str_replace( 'EEM_', '', $model_name ) ); |
|
231 | - if ( $instance instanceof EEM_CPT_Base ) { |
|
229 | + foreach ($cpt_model_names as $slug => $model_name) { |
|
230 | + $instance = EE_Registry::instance()->load_model(str_replace('EEM_', '', $model_name)); |
|
231 | + if ($instance instanceof EEM_CPT_Base) { |
|
232 | 232 | $instantiated[$slug] = $instance; |
233 | 233 | } |
234 | 234 | } |
@@ -245,10 +245,10 @@ discard block |
||
245 | 245 | * @access public |
246 | 246 | * @return array |
247 | 247 | */ |
248 | - public static function get_CPTs(){ |
|
248 | + public static function get_CPTs() { |
|
249 | 249 | // define CPTs |
250 | 250 | // NOTE the ['args']['page_templates'] array index is something specific to our CPTs and not part of the WP custom post type api. |
251 | - return apply_filters( 'FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
251 | + return apply_filters('FHEE__EE_Register_CPTs__get_CPTs__cpts', array( |
|
252 | 252 | 'espresso_events' => array( |
253 | 253 | 'singular_name' => __("Event", "event_espresso"), |
254 | 254 | 'plural_name' => __("Events", "event_espresso"), |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | 'publicly_queryable'=> FALSE, |
324 | 324 | 'hierarchical'=> FALSE, |
325 | 325 | 'has_archive' => FALSE, |
326 | - 'taxonomies' => array( 'post_tag' ), |
|
326 | + 'taxonomies' => array('post_tag'), |
|
327 | 327 | 'capability_type' => 'contact', |
328 | 328 | 'capabilities' => array( |
329 | 329 | 'edit_post' => 'ee_edit_contact', |
@@ -340,9 +340,9 @@ discard block |
||
340 | 340 | 'edit_private_posts' => 'ee_edit_contacts', |
341 | 341 | 'edit_published_posts' => 'ee_edit_contacts' |
342 | 342 | ), |
343 | - 'supports' => array( 'editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ), |
|
343 | + 'supports' => array('editor', 'thumbnail', 'excerpt', 'custom-fields', 'comments'), |
|
344 | 344 | )) |
345 | - ) ); |
|
345 | + )); |
|
346 | 346 | } |
347 | 347 | |
348 | 348 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | public static function get_private_CPTs() { |
356 | 356 | $CPTs = self::get_CPTs(); |
357 | 357 | $private_CPTs = array(); |
358 | - foreach ( $CPTs as $CPT => $details ) { |
|
359 | - if ( empty( $details['args']['public'] ) ) |
|
360 | - $private_CPTs[ $CPT ] = $details; |
|
358 | + foreach ($CPTs as $CPT => $details) { |
|
359 | + if (empty($details['args']['public'])) |
|
360 | + $private_CPTs[$CPT] = $details; |
|
361 | 361 | } |
362 | 362 | return $private_CPTs; |
363 | 363 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $plural_name internationalized plural name |
376 | 376 | * @param array $override_args like $args on http://codex.wordpress.org/Function_Reference/register_taxonomy |
377 | 377 | */ |
378 | - function register_taxonomy( $taxonomy_name, $singular_name, $plural_name, $override_args = array() ){ |
|
378 | + function register_taxonomy($taxonomy_name, $singular_name, $plural_name, $override_args = array()) { |
|
379 | 379 | |
380 | 380 | $args = array( |
381 | 381 | 'hierarchical' => true, |
@@ -392,15 +392,15 @@ discard block |
||
392 | 392 | //'rewrite' => array( 'slug' => 'genre' ), |
393 | 393 | ); |
394 | 394 | |
395 | - if($override_args){ |
|
396 | - if(isset($override_args['labels'])){ |
|
397 | - $labels = array_merge($args['labels'],$override_args['labels']); |
|
395 | + if ($override_args) { |
|
396 | + if (isset($override_args['labels'])) { |
|
397 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
398 | 398 | $args['labels'] = $labels; |
399 | 399 | } |
400 | - $args = array_merge($args,$override_args); |
|
400 | + $args = array_merge($args, $override_args); |
|
401 | 401 | |
402 | 402 | } |
403 | - register_taxonomy($taxonomy_name,null, $args); |
|
403 | + register_taxonomy($taxonomy_name, null, $args); |
|
404 | 404 | } |
405 | 405 | |
406 | 406 | |
@@ -414,27 +414,27 @@ discard block |
||
414 | 414 | * The default values set in this function will be overridden by whatever you set in $override_args |
415 | 415 | * @return void, but registers the custom post type |
416 | 416 | */ |
417 | - function register_CPT($post_type, $singular_name,$plural_name,$override_args = array(), $singular_slug = '', $plural_slug = '' ) { |
|
417 | + function register_CPT($post_type, $singular_name, $plural_name, $override_args = array(), $singular_slug = '', $plural_slug = '') { |
|
418 | 418 | |
419 | 419 | $labels = array( |
420 | 420 | 'name' => $plural_name, |
421 | 421 | 'singular_name' => $singular_name, |
422 | - 'add_new' => sprintf(__("Add %s", "event_espresso"),$singular_name), |
|
423 | - 'add_new_item' => sprintf(__("Add New %s", "event_espresso"),$singular_name), |
|
424 | - 'edit_item' => sprintf(__("Edit %s", "event_espresso"),$singular_name), |
|
425 | - 'new_item' => sprintf(__("New %s", "event_espresso"),$singular_name), |
|
426 | - 'all_items' => sprintf(__("All %s", "event_espresso"),$plural_name), |
|
427 | - 'view_item' => sprintf(__("View %s", "event_espresso"),$singular_name), |
|
428 | - 'search_items' => sprintf(__("Search %s", "event_espresso"),$plural_name), |
|
429 | - 'not_found' => sprintf(__("No %s found", "event_espresso"),$plural_name), |
|
430 | - 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"),$plural_name), |
|
422 | + 'add_new' => sprintf(__("Add %s", "event_espresso"), $singular_name), |
|
423 | + 'add_new_item' => sprintf(__("Add New %s", "event_espresso"), $singular_name), |
|
424 | + 'edit_item' => sprintf(__("Edit %s", "event_espresso"), $singular_name), |
|
425 | + 'new_item' => sprintf(__("New %s", "event_espresso"), $singular_name), |
|
426 | + 'all_items' => sprintf(__("All %s", "event_espresso"), $plural_name), |
|
427 | + 'view_item' => sprintf(__("View %s", "event_espresso"), $singular_name), |
|
428 | + 'search_items' => sprintf(__("Search %s", "event_espresso"), $plural_name), |
|
429 | + 'not_found' => sprintf(__("No %s found", "event_espresso"), $plural_name), |
|
430 | + 'not_found_in_trash' => sprintf(__("No %s found in Trash", "event_espresso"), $plural_name), |
|
431 | 431 | 'parent_item_colon' => '', |
432 | - 'menu_name' => sprintf(__("%s", "event_espresso"),$plural_name) |
|
432 | + 'menu_name' => sprintf(__("%s", "event_espresso"), $plural_name) |
|
433 | 433 | ); |
434 | 434 | |
435 | 435 | //verify plural slug and singular slug, if they aren't we'll use $singular_name and $plural_name |
436 | - $singular_slug = ! empty( $singular_slug ) ? $singular_slug : $singular_name; |
|
437 | - $plural_slug = ! empty( $plural_slug ) ? $plural_slug : $plural_name; |
|
436 | + $singular_slug = ! empty($singular_slug) ? $singular_slug : $singular_name; |
|
437 | + $plural_slug = ! empty($plural_slug) ? $plural_slug : $plural_name; |
|
438 | 438 | |
439 | 439 | |
440 | 440 | //note the page_templates arg in the supports index is something specific to EE. WordPress doesn't actually have that in their register_post_type api. |
@@ -447,24 +447,24 @@ discard block |
||
447 | 447 | 'show_in_menu' => false, |
448 | 448 | 'show_in_nav_menus' => false, |
449 | 449 | 'query_var' => true, |
450 | - 'rewrite' => apply_filters( 'FHEE__EE_Register_CPTs__register_CPT__rewrite', array( 'slug' => $plural_slug ), $post_type ), |
|
450 | + 'rewrite' => apply_filters('FHEE__EE_Register_CPTs__register_CPT__rewrite', array('slug' => $plural_slug), $post_type), |
|
451 | 451 | 'capability_type' => 'post', |
452 | 452 | 'map_meta_cap' => true, |
453 | 453 | 'has_archive' => true, |
454 | 454 | 'hierarchical' => true, |
455 | 455 | 'menu_position' => null, |
456 | - 'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments' ) |
|
456 | + 'supports' => array('title', 'editor', 'author', 'thumbnail', 'excerpt', 'custom-fields', 'comments') |
|
457 | 457 | ); |
458 | 458 | |
459 | - if($override_args){ |
|
460 | - if(isset($override_args['labels'])){ |
|
461 | - $labels = array_merge($args['labels'],$override_args['labels']); |
|
459 | + if ($override_args) { |
|
460 | + if (isset($override_args['labels'])) { |
|
461 | + $labels = array_merge($args['labels'], $override_args['labels']); |
|
462 | 462 | } |
463 | - $args = array_merge($args,$override_args); |
|
463 | + $args = array_merge($args, $override_args); |
|
464 | 464 | $args['labels'] = $labels; |
465 | 465 | } |
466 | 466 | |
467 | - register_post_type( $post_type, $args ); |
|
467 | + register_post_type($post_type, $args); |
|
468 | 468 | } |
469 | 469 | |
470 | 470 | |
@@ -473,15 +473,15 @@ discard block |
||
473 | 473 | function set_must_use_event_types() { |
474 | 474 | $term_details = array( |
475 | 475 | //Attendee's register for the first date-time only |
476 | - 'single-event' => array( __('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days.', 'event_espresso') ), //example: a party or two-day long workshop |
|
476 | + 'single-event' => array(__('Single Event', 'event_espresso'), __('A single event that spans one or more consecutive days.', 'event_espresso')), //example: a party or two-day long workshop |
|
477 | 477 | //Attendee's can register for any of the date-times |
478 | - 'multi-event' => array( __('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso') ), //example: a three day music festival or week long conference |
|
478 | + 'multi-event' => array(__('Multi Event', 'event_espresso'), __('Multiple, separate, but related events that occur on consecutive days.', 'event_espresso')), //example: a three day music festival or week long conference |
|
479 | 479 | //Attendee's register for the first date-time only |
480 | - 'event-series' => array( __('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: an 8 week introduction to basket weaving course |
|
480 | + 'event-series' => array(__('Event Series', 'event_espresso'), __(' Multiple events that occur over multiple non-consecutive days.', 'event_espresso')), //example: an 8 week introduction to basket weaving course |
|
481 | 481 | //Attendee's can register for any of the date-times. |
482 | - 'recurring-event' => array( __('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso') ), //example: a yoga class |
|
482 | + 'recurring-event' => array(__('Recurring Event', 'event_espresso'), __('Multiple events that occur over multiple non-consecutive days.', 'event_espresso')), //example: a yoga class |
|
483 | 483 | |
484 | - 'ongoing' => array( __('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso') ) //example: access to a museum |
|
484 | + 'ongoing' => array(__('Ongoing Event', 'event_espresso'), __('An "event" that people can purchase tickets to gain access for anytime for this event regardless of date times on the event', 'event_espresso')) //example: access to a museum |
|
485 | 485 | |
486 | 486 | //'walk-in' => array( __('Walk In', 'event_espresso'), __('Single datetime and single entry recurring events. Attendees register for one or multiple datetimes individually.', 'event_espresso') ), |
487 | 487 | //'reservation' => array( __('Reservation', 'event_espresso'), __('Reservations are created by specifying available datetimes and quantities. Attendees choose from the available datetimes and specify the quantity available (if the maximum is greater than 1)') ), //@TODO to avoid confusion we'll implement this in a later iteration > EE4.1 |
@@ -489,7 +489,7 @@ discard block |
||
489 | 489 | //'appointment' => array( __('Appointments', 'event_espresso'), __('Time slotted events where datetimes are generally in hours or minutes. For example, attendees can register for a single 15 minute or 1 hour time slot and this type of availability frequently reoccurs.', 'event_espresso') ) |
490 | 490 | |
491 | 491 | ); |
492 | - $this->set_must_use_terms( 'espresso_event_type', $term_details ); |
|
492 | + $this->set_must_use_terms('espresso_event_type', $term_details); |
|
493 | 493 | } |
494 | 494 | |
495 | 495 | |
@@ -503,16 +503,16 @@ discard block |
||
503 | 503 | * |
504 | 504 | * @return void |
505 | 505 | */ |
506 | - function set_must_use_terms( $taxonomy, $term_details ) { |
|
506 | + function set_must_use_terms($taxonomy, $term_details) { |
|
507 | 507 | $term_details = (array) $term_details; |
508 | 508 | |
509 | - foreach ( $term_details as $slug => $details ) { |
|
510 | - if ( !term_exists( $slug, $taxonomy ) ) { |
|
509 | + foreach ($term_details as $slug => $details) { |
|
510 | + if ( ! term_exists($slug, $taxonomy)) { |
|
511 | 511 | $insert_arr = array( |
512 | 512 | 'slug' => $slug, |
513 | 513 | 'description' => $details[1] |
514 | 514 | ); |
515 | - wp_insert_term( $details[0], $taxonomy, $insert_arr ); |
|
515 | + wp_insert_term($details[0], $taxonomy, $insert_arr); |
|
516 | 516 | } |
517 | 517 | } |
518 | 518 | } |
@@ -526,8 +526,8 @@ discard block |
||
526 | 526 | * @param string $term_slug The slug of the term that will be the default. |
527 | 527 | * @param array $cpt_slugs An array of custom post types we want the default assigned to |
528 | 528 | */ |
529 | - function set_default_term( $taxonomy, $term_slug, $cpt_slugs = array() ) { |
|
530 | - $this->_default_terms[][$term_slug] = new EE_Default_Term( $taxonomy, $term_slug, $cpt_slugs ); |
|
529 | + function set_default_term($taxonomy, $term_slug, $cpt_slugs = array()) { |
|
530 | + $this->_default_terms[][$term_slug] = new EE_Default_Term($taxonomy, $term_slug, $cpt_slugs); |
|
531 | 531 | } |
532 | 532 | |
533 | 533 | |
@@ -539,20 +539,20 @@ discard block |
||
539 | 539 | * @param object $post Post object |
540 | 540 | * @return void |
541 | 541 | */ |
542 | - function save_default_term( $post_id, $post ) { |
|
543 | - if ( empty( $this->_default_terms ) ) |
|
542 | + function save_default_term($post_id, $post) { |
|
543 | + if (empty($this->_default_terms)) |
|
544 | 544 | return; //no default terms set so lets just exit. |
545 | 545 | |
546 | - foreach ( $this->_default_terms as $defaults ) { |
|
547 | - foreach ( $defaults as $default_obj ) { |
|
548 | - if ( $post->post_status == 'publish' && in_array( $post->post_type, $default_obj->cpt_slugs ) ) { |
|
546 | + foreach ($this->_default_terms as $defaults) { |
|
547 | + foreach ($defaults as $default_obj) { |
|
548 | + if ($post->post_status == 'publish' && in_array($post->post_type, $default_obj->cpt_slugs)) { |
|
549 | 549 | |
550 | 550 | //note some error proofing going on here to save unnecessary db queries |
551 | - $taxonomies = get_object_taxonomies( $post->post_type ); |
|
552 | - foreach ( (array) $taxonomies as $taxonomy ) { |
|
553 | - $terms = wp_get_post_terms( $post_id, $taxonomy); |
|
554 | - if ( empty( $terms ) && $taxonomy == $default_obj->taxonomy ) { |
|
555 | - wp_set_object_terms( $post_id, array( $default_obj->term_slug ), $taxonomy ); |
|
551 | + $taxonomies = get_object_taxonomies($post->post_type); |
|
552 | + foreach ((array) $taxonomies as $taxonomy) { |
|
553 | + $terms = wp_get_post_terms($post_id, $taxonomy); |
|
554 | + if (empty($terms) && $taxonomy == $default_obj->taxonomy) { |
|
555 | + wp_set_object_terms($post_id, array($default_obj->term_slug), $taxonomy); |
|
556 | 556 | } |
557 | 557 | } |
558 | 558 | } |
@@ -584,7 +584,7 @@ discard block |
||
584 | 584 | * @param string $term_slug The slug of the term that will be the default. |
585 | 585 | * @param array $cpt_slugs The custom post type the default term gets saved with |
586 | 586 | */ |
587 | - public function __construct( $taxonomy, $term_slug, $cpt_slugs = array() ) { |
|
587 | + public function __construct($taxonomy, $term_slug, $cpt_slugs = array()) { |
|
588 | 588 | $this->taxonomy = $taxonomy; |
589 | 589 | $this->cpt_slugs = (array) $cpt_slugs; |
590 | 590 | $this->term_slug = $term_slug; |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * |
92 | 92 | * @param array $dir_ref original array of paths |
93 | 93 | * |
94 | - * @return array appended paths |
|
94 | + * @return string[] appended paths |
|
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
@@ -701,7 +701,7 @@ discard block |
||
701 | 701 | * @param EE_Question[] $questions An array of questions indexed by answer id. |
702 | 702 | * @param EE_Answer[] $answers An array of answer objects |
703 | 703 | * @param string $template Template content to be parsed. |
704 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
704 | + * @param string[] $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | 705 | * @param array $extra_data Extra data that might be used when parsing the template. |
706 | 706 | */ |
707 | 707 | protected function _parse_question_list_for_primary_or_recipient_registration( |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | * @since 4.3.2 |
8 | 8 | */ |
9 | 9 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
10 | - exit('No direct script access allowed'); |
|
10 | + exit('No direct script access allowed'); |
|
11 | 11 | } |
12 | 12 | |
13 | 13 | /** |
@@ -22,722 +22,722 @@ discard block |
||
22 | 22 | { |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * constructor. |
|
27 | - */ |
|
28 | - public function __construct() |
|
29 | - { |
|
30 | - $this->_caf_hooks(); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | - * |
|
37 | - * @since 4.3.2 |
|
38 | - * |
|
39 | - * @return void |
|
40 | - */ |
|
41 | - private function _caf_hooks() |
|
42 | - { |
|
43 | - add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | - add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | - 5, 2); |
|
46 | - add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | - 2); |
|
48 | - add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | - 2); |
|
50 | - add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | - 2); |
|
52 | - add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | - add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | - 2); |
|
55 | - add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | - array($this, 'new_default_templates'), 5, 7); |
|
57 | - add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | - 2); |
|
59 | - |
|
60 | - //shortcode parsers |
|
61 | - add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | - add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | - array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | - add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | - array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | - array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | - add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | - array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | - |
|
72 | - /** |
|
73 | - * @since 4.2.0 |
|
74 | - */ |
|
75 | - add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | - add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | - |
|
78 | - /** |
|
79 | - * @since 4.3.0 |
|
80 | - */ |
|
81 | - //eat our own dog food! |
|
82 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | - add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | - do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | - } |
|
86 | - |
|
87 | - |
|
88 | - /** |
|
89 | - * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | - * messages system. |
|
91 | - * |
|
92 | - * @param array $dir_ref original array of paths |
|
93 | - * |
|
94 | - * @return array appended paths |
|
95 | - */ |
|
96 | - public function messages_autoload_paths($dir_ref) |
|
97 | - { |
|
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | - |
|
100 | - return $dir_ref; |
|
101 | - } |
|
102 | - |
|
103 | - |
|
104 | - public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | - { |
|
106 | - $validator_config['attendee_list'] = array( |
|
107 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | - 'required' => array('[ATTENDEE_LIST]') |
|
109 | - ); |
|
110 | - $validator_config['question_list'] = array( |
|
111 | - 'shortcodes' => array('question'), |
|
112 | - 'required' => array('[QUESTION_LIST]') |
|
113 | - ); |
|
114 | - |
|
115 | - return $validator_config; |
|
116 | - } |
|
117 | - |
|
118 | - |
|
119 | - public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | - { |
|
121 | - $validator_config['attendee_list'] = array( |
|
122 | - 'shortcodes' => array('attendee', 'question_list'), |
|
123 | - 'required' => array('[ATTENDEE_LIST]') |
|
124 | - ); |
|
125 | - $validator_config['question_list'] = array( |
|
126 | - 'shortcodes' => array('question'), |
|
127 | - 'required' => array('[QUESTION_LIST]') |
|
128 | - ); |
|
129 | - |
|
130 | - return $validator_config; |
|
131 | - } |
|
132 | - |
|
133 | - |
|
134 | - public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | - { |
|
136 | - $validator_config['attendee_list'] = array( |
|
137 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | - 'required' => array('[ATTENDEE_LIST]') |
|
139 | - ); |
|
140 | - $validator_config['question_list'] = array( |
|
141 | - 'shortcodes' => array('question'), |
|
142 | - 'required' => array('[QUESTION_LIST]') |
|
143 | - ); |
|
144 | - |
|
145 | - return $validator_config; |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | - { |
|
151 | - $template_fields['extra']['content']['question_list'] = array( |
|
152 | - 'input' => 'textarea', |
|
153 | - 'label' => '[QUESTION_LIST]', |
|
154 | - 'type' => 'string', |
|
155 | - 'required' => true, |
|
156 | - 'validation' => true, |
|
157 | - 'format' => '%s', |
|
158 | - 'css_class' => 'large-text', |
|
159 | - 'rows' => '5', |
|
160 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | - ); |
|
162 | - |
|
163 | - return $template_fields; |
|
164 | - } |
|
165 | - |
|
166 | - |
|
167 | - public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | - { |
|
169 | - $template_fields['extra']['content']['question_list'] = array( |
|
170 | - 'input' => 'textarea', |
|
171 | - 'label' => '[QUESTION_LIST]', |
|
172 | - 'type' => 'string', |
|
173 | - 'required' => true, |
|
174 | - 'validation' => true, |
|
175 | - 'format' => '%s', |
|
176 | - 'css_class' => 'large-text', |
|
177 | - 'rows' => '5', |
|
178 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | - ); |
|
180 | - |
|
181 | - return $template_fields; |
|
182 | - } |
|
183 | - |
|
184 | - |
|
185 | - public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | - { |
|
187 | - $template_fields['extra']['content']['question_list'] = array( |
|
188 | - 'input' => 'textarea', |
|
189 | - 'label' => '[QUESTION_LIST]', |
|
190 | - 'type' => 'string', |
|
191 | - 'required' => true, |
|
192 | - 'validation' => true, |
|
193 | - 'format' => '%s', |
|
194 | - 'css_class' => 'large-text', |
|
195 | - 'rows' => '5', |
|
196 | - 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | - ); |
|
198 | - |
|
199 | - return $template_fields; |
|
200 | - } |
|
201 | - |
|
202 | - |
|
203 | - public function new_default_templates( |
|
204 | - $contents, |
|
205 | - $actual_path, |
|
206 | - EE_messenger $messenger, |
|
207 | - EE_message_type $message_type, |
|
208 | - $field, |
|
209 | - $context, |
|
210 | - EE_Messages_Template_Pack $template_pack |
|
211 | - ) { |
|
212 | - |
|
213 | - //we're only modifying templates for the default template pack |
|
214 | - if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | - return $contents; |
|
216 | - } |
|
217 | - |
|
218 | - //the template file name we're replacing contents for. |
|
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | - |
|
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | - |
|
224 | - if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
25 | + /** |
|
26 | + * constructor. |
|
27 | + */ |
|
28 | + public function __construct() |
|
29 | + { |
|
30 | + $this->_caf_hooks(); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Contains all the hooks filters for setting up caffeinated messages functionality. |
|
36 | + * |
|
37 | + * @since 4.3.2 |
|
38 | + * |
|
39 | + * @return void |
|
40 | + */ |
|
41 | + private function _caf_hooks() |
|
42 | + { |
|
43 | + add_filter('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', array($this, 'messages_autoload_paths'), 5); |
|
44 | + add_filter('FHEE__EE_Email_messenger__get_validator_config', array($this, 'email_messenger_validator_config'), |
|
45 | + 5, 2); |
|
46 | + add_filter('FHEE__EE_Email_messenger__get_template_fields', array($this, 'email_messenger_template_fields'), 5, |
|
47 | + 2); |
|
48 | + add_filter('FHEE__EE_Html_messenger__get_template_fields', array($this, 'html_messenger_template_fields'), 5, |
|
49 | + 2); |
|
50 | + add_filter('FHEE__EE_Html_messenger__get_validator_config', array($this, 'html_messenger_validator_config'), 5, |
|
51 | + 2); |
|
52 | + add_filter('FHEE__EE_Pdf_messenger__get_template_fields', array($this, 'pdf_messenger_template_fields'), 5, 2); |
|
53 | + add_filter('FHEE__EE_Pdf_messenger__get_validator_config', array($this, 'pdf_messenger_validator_config'), 5, |
|
54 | + 2); |
|
55 | + add_filter('FHEE__EE_Messages_Template_Pack__get_specific_template__contents', |
|
56 | + array($this, 'new_default_templates'), 5, 7); |
|
57 | + add_filter('FHEE__EE_Messages_Base__get_valid_shortcodes', array($this, 'message_types_valid_shortcodes'), 5, |
|
58 | + 2); |
|
59 | + |
|
60 | + //shortcode parsers |
|
61 | + add_filter('FHEE__EE_Attendee_Shortcodes__shortcodes', array($this, 'additional_attendee_shortcodes'), 5, 2); |
|
62 | + add_filter('FHEE__EE_Attendee_Shortcodes__parser_after', array($this, 'additional_attendee_parser'), 5, 5); |
|
63 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__shortcodes', |
|
64 | + array($this, 'additional_recipient_details_shortcodes'), 5, 2); |
|
65 | + add_filter('FHEE__EE_Recipient_List_Shortcodes__parser_after', |
|
66 | + array($this, 'additional_recipient_details_parser'), 5, 5); |
|
67 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__shortcodes', |
|
68 | + array($this, 'additional_primary_registration_details_shortcodes'), 5, 2); |
|
69 | + add_filter('FHEE__EE_Primary_Registration_List_Shortcodes__parser_after', |
|
70 | + array($this, 'additional_primary_registration_details_parser'), 5, 5); |
|
71 | + |
|
72 | + /** |
|
73 | + * @since 4.2.0 |
|
74 | + */ |
|
75 | + add_filter('FHEE__EE_Datetime_Shortcodes__shortcodes', array($this, 'additional_datetime_shortcodes'), 10, 2); |
|
76 | + add_filter('FHEE__EE_Datetime_Shortcodes__parser_after', array($this, 'additional_datetime_parser'), 10, 5); |
|
77 | + |
|
78 | + /** |
|
79 | + * @since 4.3.0 |
|
80 | + */ |
|
81 | + //eat our own dog food! |
|
82 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_message_types')); |
|
83 | + add_action('EE_Brewing_Regular___messages_caf', array($this, 'register_caf_shortcodes')); |
|
84 | + do_action('EE_Brewing_Regular___messages_caf'); |
|
85 | + } |
|
86 | + |
|
87 | + |
|
88 | + /** |
|
89 | + * This just allows us to add additional paths to the autoloader (EED_Messages::autoload_messages()) for the |
|
90 | + * messages system. |
|
91 | + * |
|
92 | + * @param array $dir_ref original array of paths |
|
93 | + * |
|
94 | + * @return array appended paths |
|
95 | + */ |
|
96 | + public function messages_autoload_paths($dir_ref) |
|
97 | + { |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
99 | + |
|
100 | + return $dir_ref; |
|
101 | + } |
|
102 | + |
|
103 | + |
|
104 | + public function email_messenger_validator_config($validator_config, EE_Email_messenger $messenger) |
|
105 | + { |
|
106 | + $validator_config['attendee_list'] = array( |
|
107 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
108 | + 'required' => array('[ATTENDEE_LIST]') |
|
109 | + ); |
|
110 | + $validator_config['question_list'] = array( |
|
111 | + 'shortcodes' => array('question'), |
|
112 | + 'required' => array('[QUESTION_LIST]') |
|
113 | + ); |
|
114 | + |
|
115 | + return $validator_config; |
|
116 | + } |
|
117 | + |
|
118 | + |
|
119 | + public function html_messenger_validator_config($validator_config, EE_Html_messenger $messenger) |
|
120 | + { |
|
121 | + $validator_config['attendee_list'] = array( |
|
122 | + 'shortcodes' => array('attendee', 'question_list'), |
|
123 | + 'required' => array('[ATTENDEE_LIST]') |
|
124 | + ); |
|
125 | + $validator_config['question_list'] = array( |
|
126 | + 'shortcodes' => array('question'), |
|
127 | + 'required' => array('[QUESTION_LIST]') |
|
128 | + ); |
|
129 | + |
|
130 | + return $validator_config; |
|
131 | + } |
|
132 | + |
|
133 | + |
|
134 | + public function pdf_messenger_validator_config($validator_config, EE_Pdf_messenger $messenger) |
|
135 | + { |
|
136 | + $validator_config['attendee_list'] = array( |
|
137 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list', 'question_list'), |
|
138 | + 'required' => array('[ATTENDEE_LIST]') |
|
139 | + ); |
|
140 | + $validator_config['question_list'] = array( |
|
141 | + 'shortcodes' => array('question'), |
|
142 | + 'required' => array('[QUESTION_LIST]') |
|
143 | + ); |
|
144 | + |
|
145 | + return $validator_config; |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + public function email_messenger_template_fields($template_fields, EE_Email_messenger $messenger) |
|
150 | + { |
|
151 | + $template_fields['extra']['content']['question_list'] = array( |
|
152 | + 'input' => 'textarea', |
|
153 | + 'label' => '[QUESTION_LIST]', |
|
154 | + 'type' => 'string', |
|
155 | + 'required' => true, |
|
156 | + 'validation' => true, |
|
157 | + 'format' => '%s', |
|
158 | + 'css_class' => 'large-text', |
|
159 | + 'rows' => '5', |
|
160 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
161 | + ); |
|
162 | + |
|
163 | + return $template_fields; |
|
164 | + } |
|
165 | + |
|
166 | + |
|
167 | + public function html_messenger_template_fields($template_fields, EE_Html_messenger $messenger) |
|
168 | + { |
|
169 | + $template_fields['extra']['content']['question_list'] = array( |
|
170 | + 'input' => 'textarea', |
|
171 | + 'label' => '[QUESTION_LIST]', |
|
172 | + 'type' => 'string', |
|
173 | + 'required' => true, |
|
174 | + 'validation' => true, |
|
175 | + 'format' => '%s', |
|
176 | + 'css_class' => 'large-text', |
|
177 | + 'rows' => '5', |
|
178 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
179 | + ); |
|
180 | + |
|
181 | + return $template_fields; |
|
182 | + } |
|
183 | + |
|
184 | + |
|
185 | + public function pdf_messenger_template_fields($template_fields, EE_Pdf_messenger $messenger) |
|
186 | + { |
|
187 | + $template_fields['extra']['content']['question_list'] = array( |
|
188 | + 'input' => 'textarea', |
|
189 | + 'label' => '[QUESTION_LIST]', |
|
190 | + 'type' => 'string', |
|
191 | + 'required' => true, |
|
192 | + 'validation' => true, |
|
193 | + 'format' => '%s', |
|
194 | + 'css_class' => 'large-text', |
|
195 | + 'rows' => '5', |
|
196 | + 'shortcodes_required' => array('[QUESTION_LIST]') |
|
197 | + ); |
|
198 | + |
|
199 | + return $template_fields; |
|
200 | + } |
|
201 | + |
|
202 | + |
|
203 | + public function new_default_templates( |
|
204 | + $contents, |
|
205 | + $actual_path, |
|
206 | + EE_messenger $messenger, |
|
207 | + EE_message_type $message_type, |
|
208 | + $field, |
|
209 | + $context, |
|
210 | + EE_Messages_Template_Pack $template_pack |
|
211 | + ) { |
|
212 | + |
|
213 | + //we're only modifying templates for the default template pack |
|
214 | + if ( ! $template_pack instanceof EE_Messages_Template_Pack_Default) { |
|
215 | + return $contents; |
|
216 | + } |
|
217 | + |
|
218 | + //the template file name we're replacing contents for. |
|
219 | + $template_file_prefix = $field . '_' . $context; |
|
220 | + $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
221 | + |
|
222 | + $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
223 | + |
|
224 | + if ($messenger->name == 'email' && $message_type->name == 'registration') { |
|
225 | 225 | |
226 | - switch ($template_file_prefix) { |
|
226 | + switch ($template_file_prefix) { |
|
227 | 227 | |
228 | - case 'question_list_admin' : |
|
229 | - case 'question_list_attendee' : |
|
230 | - case 'question_list_primary_attendee' : |
|
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | - $contents = EEH_Template::display_template($path, array(), true); |
|
233 | - break; |
|
228 | + case 'question_list_admin' : |
|
229 | + case 'question_list_attendee' : |
|
230 | + case 'question_list_primary_attendee' : |
|
231 | + $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
232 | + $contents = EEH_Template::display_template($path, array(), true); |
|
233 | + break; |
|
234 | 234 | |
235 | - case 'attendee_list_primary_attendee' : |
|
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | - $contents = EEH_Template::display_template($path, array(), true); |
|
238 | - break; |
|
235 | + case 'attendee_list_primary_attendee' : |
|
236 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
237 | + $contents = EEH_Template::display_template($path, array(), true); |
|
238 | + break; |
|
239 | 239 | |
240 | - case 'attendee_list_admin' : |
|
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | - $contents = EEH_Template::display_template($path, |
|
243 | - array(), true); |
|
244 | - break; |
|
240 | + case 'attendee_list_admin' : |
|
241 | + $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
242 | + $contents = EEH_Template::display_template($path, |
|
243 | + array(), true); |
|
244 | + break; |
|
245 | 245 | |
246 | - case 'attendee_list_attendee' : |
|
247 | - $contents = ''; |
|
248 | - break; |
|
246 | + case 'attendee_list_attendee' : |
|
247 | + $contents = ''; |
|
248 | + break; |
|
249 | 249 | |
250 | - case 'event_list_attendee' : |
|
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | - $contents = EEH_Template::display_template($path, array(), true); |
|
253 | - break; |
|
254 | - } |
|
255 | - } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | - switch ($template_file_prefix) { |
|
250 | + case 'event_list_attendee' : |
|
251 | + $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
252 | + $contents = EEH_Template::display_template($path, array(), true); |
|
253 | + break; |
|
254 | + } |
|
255 | + } elseif ($messenger->name == 'email' && $message_type->name == 'newsletter') { |
|
256 | + switch ($template_file_prefix) { |
|
257 | 257 | |
258 | - case 'content_attendee' : |
|
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | - $contents = EEH_Template::display_template($path, array(), true); |
|
261 | - break; |
|
258 | + case 'content_attendee' : |
|
259 | + $path = $base_path . $msg_prefix . 'content.template.php'; |
|
260 | + $contents = EEH_Template::display_template($path, array(), true); |
|
261 | + break; |
|
262 | 262 | |
263 | - case 'newsletter_content_attendee' : |
|
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | - $contents = EEH_Template::display_template($path, array(), true); |
|
266 | - break; |
|
263 | + case 'newsletter_content_attendee' : |
|
264 | + $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
265 | + $contents = EEH_Template::display_template($path, array(), true); |
|
266 | + break; |
|
267 | 267 | |
268 | - case 'newsletter_subject_attendee' : |
|
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | - $contents = EEH_Template::display_template($path, array(), true); |
|
271 | - break; |
|
272 | - } |
|
273 | - } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | - switch ($template_file_prefix) { |
|
275 | - case 'attendee_list_purchaser' : |
|
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | - $contents = EEH_Template::display_template($path, array(), true); |
|
278 | - break; |
|
279 | - } |
|
280 | - } |
|
281 | - |
|
282 | - return $contents; |
|
283 | - |
|
284 | - } |
|
285 | - |
|
286 | - |
|
287 | - public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | - { |
|
289 | - //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | - $include_with = array( |
|
291 | - 'registration', |
|
292 | - 'cancelled_registration', |
|
293 | - 'declined_registration', |
|
294 | - 'not_approved_registration', |
|
295 | - 'payment_declined', |
|
296 | - 'payment_failed', |
|
297 | - 'payment_cancelled', |
|
298 | - 'payment', |
|
299 | - 'payment_reminder', |
|
300 | - 'pending_approval', |
|
301 | - 'registration_summary', |
|
302 | - 'invoice', |
|
303 | - 'receipt' |
|
304 | - ); |
|
305 | - if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | - $contexts = array_keys($msg->get_contexts()); |
|
307 | - foreach ($contexts as $context) { |
|
308 | - $valid_shortcodes[$context][] = 'question_list'; |
|
309 | - $valid_shortcodes[$context][] = 'question'; |
|
310 | - } |
|
311 | - } |
|
312 | - |
|
313 | - return $valid_shortcodes; |
|
314 | - } |
|
315 | - |
|
316 | - |
|
317 | - public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | - { |
|
319 | - $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | - 'event_espresso'); |
|
321 | - |
|
322 | - return $shortcodes; |
|
323 | - } |
|
324 | - |
|
325 | - |
|
326 | - public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | - { |
|
328 | - |
|
329 | - if (strpos($shortcode, |
|
330 | - '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | - ) { |
|
332 | - return $parsed; |
|
333 | - } |
|
334 | - |
|
335 | - //let's get the question from the code. |
|
336 | - $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | - $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | - |
|
339 | - $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | - $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | - |
|
342 | - $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | - $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | - |
|
345 | - if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | - return $parsed; |
|
347 | - } |
|
348 | - |
|
349 | - //now let's figure out which question has this text. |
|
350 | - foreach ($aee->questions as $ansid => $question) { |
|
351 | - if ( |
|
352 | - $question instanceof EE_Question |
|
353 | - && trim($question->display_text()) == trim($shortcode) |
|
354 | - && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | - ) { |
|
356 | - return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | - 'no_wpautop'); |
|
358 | - } |
|
359 | - } |
|
360 | - |
|
361 | - //nothing! |
|
362 | - return $parsed; |
|
363 | - } |
|
364 | - |
|
365 | - |
|
366 | - /** |
|
367 | - * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | - * |
|
369 | - * @since 4.2 |
|
370 | - * |
|
371 | - * @param array $shortcodes array of shortcodes and |
|
372 | - * descriptions |
|
373 | - * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | - * |
|
375 | - * @return array array of shortcodes and |
|
376 | - * descriptions |
|
377 | - */ |
|
378 | - public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | - { |
|
380 | - $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | - 'event_espresso'); |
|
382 | - $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | - 'event_espresso'); |
|
384 | - $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | - 'event_espresso'); |
|
386 | - |
|
387 | - return $shortcodes; |
|
388 | - } |
|
389 | - |
|
390 | - |
|
391 | - /** |
|
392 | - * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | - * Datetime shortcodes |
|
394 | - * |
|
395 | - * @since 4.2 |
|
396 | - * |
|
397 | - * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | - * @param string $shortcode The shortcode being parsed. |
|
399 | - * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | - * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | - * Parser. |
|
402 | - * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | - * |
|
404 | - * @return string The new parsed string. |
|
405 | - */ |
|
406 | - public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | - { |
|
408 | - |
|
409 | - if ( ! $data instanceof EE_Datetime) { |
|
410 | - return ''; //get out because we can only parse with the datetime object. |
|
411 | - } |
|
412 | - |
|
413 | - switch ($shortcode) { |
|
414 | - case '[DTT_NAME]' : |
|
415 | - return $data->name(); |
|
416 | - break; |
|
417 | - case '[DTT_DESCRIPTION]' : |
|
418 | - return $data->description(); |
|
419 | - break; |
|
420 | - case '[DTT_NAME_OR_DATES]' : |
|
421 | - return $data->get_dtt_display_name(true); |
|
422 | - break; |
|
423 | - default : |
|
424 | - return $parsed; |
|
425 | - break; |
|
426 | - } |
|
427 | - } |
|
428 | - |
|
429 | - |
|
430 | - public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | - { |
|
432 | - $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | - 'event_espresso'); |
|
434 | - |
|
435 | - return $shortcodes; |
|
436 | - } |
|
437 | - |
|
438 | - |
|
439 | - /** |
|
440 | - * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | - * |
|
442 | - * @param string $parsed The original parsed content for the shortcode |
|
443 | - * @param string $shortcode The shortcode being parsed |
|
444 | - * @param array $data The shortcode parser data array |
|
445 | - * @param array $extra_data The shortcode parser extra data array |
|
446 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | - * |
|
448 | - * @return string |
|
449 | - */ |
|
450 | - public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | - { |
|
452 | - |
|
453 | - if (array($data) && ! isset($data['data'])) { |
|
454 | - return $parsed; |
|
455 | - } |
|
456 | - |
|
457 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | - |
|
460 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | - return $parsed; |
|
462 | - } |
|
463 | - |
|
464 | - switch ($shortcode) { |
|
465 | - case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | - $att = $recipient->att_obj; |
|
467 | - $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | - $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | - $answers = array(); |
|
268 | + case 'newsletter_subject_attendee' : |
|
269 | + $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
270 | + $contents = EEH_Template::display_template($path, array(), true); |
|
271 | + break; |
|
272 | + } |
|
273 | + } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
|
274 | + switch ($template_file_prefix) { |
|
275 | + case 'attendee_list_purchaser' : |
|
276 | + $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
277 | + $contents = EEH_Template::display_template($path, array(), true); |
|
278 | + break; |
|
279 | + } |
|
280 | + } |
|
281 | + |
|
282 | + return $contents; |
|
283 | + |
|
284 | + } |
|
285 | + |
|
286 | + |
|
287 | + public function message_types_valid_shortcodes($valid_shortcodes, EE_Messages_Base $msg) |
|
288 | + { |
|
289 | + //make sure question_list and question are ONLY added for the core message types. Any other message types will have to explicitly set question_list as a valid shortcode. |
|
290 | + $include_with = array( |
|
291 | + 'registration', |
|
292 | + 'cancelled_registration', |
|
293 | + 'declined_registration', |
|
294 | + 'not_approved_registration', |
|
295 | + 'payment_declined', |
|
296 | + 'payment_failed', |
|
297 | + 'payment_cancelled', |
|
298 | + 'payment', |
|
299 | + 'payment_reminder', |
|
300 | + 'pending_approval', |
|
301 | + 'registration_summary', |
|
302 | + 'invoice', |
|
303 | + 'receipt' |
|
304 | + ); |
|
305 | + if ($msg instanceof EE_message_type && in_array($msg->name, $include_with)) { |
|
306 | + $contexts = array_keys($msg->get_contexts()); |
|
307 | + foreach ($contexts as $context) { |
|
308 | + $valid_shortcodes[$context][] = 'question_list'; |
|
309 | + $valid_shortcodes[$context][] = 'question'; |
|
310 | + } |
|
311 | + } |
|
312 | + |
|
313 | + return $valid_shortcodes; |
|
314 | + } |
|
315 | + |
|
316 | + |
|
317 | + public function additional_attendee_shortcodes($shortcodes, $shortcode_parser) |
|
318 | + { |
|
319 | + $shortcodes['[ANSWER_*]'] = __('This is a special dynamic shortcode. Right after the "*", add the exact text of a existing question, and if there is an answer for that question for this registrant, that will take the place of this shortcode.', |
|
320 | + 'event_espresso'); |
|
321 | + |
|
322 | + return $shortcodes; |
|
323 | + } |
|
324 | + |
|
325 | + |
|
326 | + public function additional_attendee_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
327 | + { |
|
328 | + |
|
329 | + if (strpos($shortcode, |
|
330 | + '[ANSWER_*') === false || ! isset($extra_data['data']->questions) || ! isset($extra_data['data']->registrations) |
|
331 | + ) { |
|
332 | + return $parsed; |
|
333 | + } |
|
334 | + |
|
335 | + //let's get the question from the code. |
|
336 | + $shortcode = str_replace('[ANSWER_*', '', $shortcode); |
|
337 | + $shortcode = trim(str_replace(']', '', $shortcode)); |
|
338 | + |
|
339 | + $registration = $data instanceof EE_Registration ? $data : null; |
|
340 | + $registration = ! $registration instanceof EE_Registration && is_array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Registration ? $extra_data['data'] : $registration; |
|
341 | + |
|
342 | + $aee = $data instanceof EE_Messages_Addressee ? $data : null; |
|
343 | + $aee = ! $aee instanceof EE_Messages_Addressee && is_array($extra_data) && isset($extra_data['data']) ? $extra_data['data'] : $aee; |
|
344 | + |
|
345 | + if ( ! $registration instanceof EE_Registration || ! $aee instanceof EE_Messages_Addressee) { |
|
346 | + return $parsed; |
|
347 | + } |
|
348 | + |
|
349 | + //now let's figure out which question has this text. |
|
350 | + foreach ($aee->questions as $ansid => $question) { |
|
351 | + if ( |
|
352 | + $question instanceof EE_Question |
|
353 | + && trim($question->display_text()) == trim($shortcode) |
|
354 | + && isset($aee->registrations[$registration->ID()]['ans_objs'][$ansid]) |
|
355 | + ) { |
|
356 | + return $aee->registrations[$registration->ID()]['ans_objs'][$ansid]->get_pretty('ANS_value', |
|
357 | + 'no_wpautop'); |
|
358 | + } |
|
359 | + } |
|
360 | + |
|
361 | + //nothing! |
|
362 | + return $parsed; |
|
363 | + } |
|
364 | + |
|
365 | + |
|
366 | + /** |
|
367 | + * Callback for additional shortcodes filter for adding additional datetime shortcodes. |
|
368 | + * |
|
369 | + * @since 4.2 |
|
370 | + * |
|
371 | + * @param array $shortcodes array of shortcodes and |
|
372 | + * descriptions |
|
373 | + * @param EE_Datetime_Shortcodes $shortcode_parser EE_Shortcodes object |
|
374 | + * |
|
375 | + * @return array array of shortcodes and |
|
376 | + * descriptions |
|
377 | + */ |
|
378 | + public function additional_datetime_shortcodes($shortcodes, $shortcode_parser) |
|
379 | + { |
|
380 | + $shortcodes['[DTT_NAME]'] = __('This will be parsed to the Title given for a Datetime', |
|
381 | + 'event_espresso'); |
|
382 | + $shortcodes['[DTT_DESCRIPTION]'] = __('This will be parsed to the description for a Datetime', |
|
383 | + 'event_espresso'); |
|
384 | + $shortcodes['[DTT_NAME_OR_DATES]'] = __('When parsed, if the Datetime has a name, it is used, otherwise a formatted string including the start date and end date will be used.', |
|
385 | + 'event_espresso'); |
|
386 | + |
|
387 | + return $shortcodes; |
|
388 | + } |
|
389 | + |
|
390 | + |
|
391 | + /** |
|
392 | + * Callback for additional shortcodes parser filter used for adding parser for new |
|
393 | + * Datetime shortcodes |
|
394 | + * |
|
395 | + * @since 4.2 |
|
396 | + * |
|
397 | + * @param string $parsed The finished parsed string for the given shortcode. |
|
398 | + * @param string $shortcode The shortcode being parsed. |
|
399 | + * @param object $data The incoming data object for the Shortcode Parser. |
|
400 | + * @param object $extra_data The incoming extra date object for the Shortcode |
|
401 | + * Parser. |
|
402 | + * @param EE_Datetime_Shortcodes $shortcode_parser |
|
403 | + * |
|
404 | + * @return string The new parsed string. |
|
405 | + */ |
|
406 | + public function additional_datetime_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
407 | + { |
|
408 | + |
|
409 | + if ( ! $data instanceof EE_Datetime) { |
|
410 | + return ''; //get out because we can only parse with the datetime object. |
|
411 | + } |
|
412 | + |
|
413 | + switch ($shortcode) { |
|
414 | + case '[DTT_NAME]' : |
|
415 | + return $data->name(); |
|
416 | + break; |
|
417 | + case '[DTT_DESCRIPTION]' : |
|
418 | + return $data->description(); |
|
419 | + break; |
|
420 | + case '[DTT_NAME_OR_DATES]' : |
|
421 | + return $data->get_dtt_display_name(true); |
|
422 | + break; |
|
423 | + default : |
|
424 | + return $parsed; |
|
425 | + break; |
|
426 | + } |
|
427 | + } |
|
428 | + |
|
429 | + |
|
430 | + public function additional_recipient_details_shortcodes($shortcodes, $shortcode_parser) |
|
431 | + { |
|
432 | + $shortcodes['[RECIPIENT_QUESTION_LIST]'] = __('This is used to indicate where you want the list of questions and answers to show for the person receiving the message.', |
|
433 | + 'event_espresso'); |
|
434 | + |
|
435 | + return $shortcodes; |
|
436 | + } |
|
437 | + |
|
438 | + |
|
439 | + /** |
|
440 | + * Callback for FHEE__EE_Recipient_List_Shortcodes__parser_after filter (dynamic filter). |
|
441 | + * |
|
442 | + * @param string $parsed The original parsed content for the shortcode |
|
443 | + * @param string $shortcode The shortcode being parsed |
|
444 | + * @param array $data The shortcode parser data array |
|
445 | + * @param array $extra_data The shortcode parser extra data array |
|
446 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
447 | + * |
|
448 | + * @return string |
|
449 | + */ |
|
450 | + public function additional_recipient_details_parser($parsed, $shortcode, $data, $extra_data, $shortcode_parser) |
|
451 | + { |
|
452 | + |
|
453 | + if (array($data) && ! isset($data['data'])) { |
|
454 | + return $parsed; |
|
455 | + } |
|
456 | + |
|
457 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
458 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
459 | + |
|
460 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
461 | + return $parsed; |
|
462 | + } |
|
463 | + |
|
464 | + switch ($shortcode) { |
|
465 | + case '[RECIPIENT_QUESTION_LIST]' : |
|
466 | + $att = $recipient->att_obj; |
|
467 | + $registrations_on_attendee = $att instanceof EE_Attendee ? $recipient->attendees[$att->ID()]['reg_objs'] : array(); |
|
468 | + $registrations_on_attendee = empty($registrations_on_attendee) && $recipient->reg_obj instanceof EE_Registration ? array($recipient->reg_obj) : $registrations_on_attendee; |
|
469 | + $answers = array(); |
|
470 | 470 | |
471 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | - $valid_shortcodes = array('question'); |
|
471 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
472 | + $valid_shortcodes = array('question'); |
|
473 | 473 | |
474 | - //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | - if ($data['data'] instanceof EE_Messages_Addressee) { |
|
474 | + //if the context is main_content then get all answers for all registrations on this attendee |
|
475 | + if ($data['data'] instanceof EE_Messages_Addressee) { |
|
476 | 476 | |
477 | - foreach ($registrations_on_attendee as $reg) { |
|
478 | - if ($reg instanceof EE_Registration) { |
|
479 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | - foreach ($anss as $ans) { |
|
481 | - if ($ans instanceof EE_Answer) { |
|
482 | - $answers[$ans->ID()] = $ans; |
|
483 | - } |
|
484 | - } |
|
485 | - } |
|
486 | - } |
|
487 | - } |
|
477 | + foreach ($registrations_on_attendee as $reg) { |
|
478 | + if ($reg instanceof EE_Registration) { |
|
479 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
480 | + foreach ($anss as $ans) { |
|
481 | + if ($ans instanceof EE_Answer) { |
|
482 | + $answers[$ans->ID()] = $ans; |
|
483 | + } |
|
484 | + } |
|
485 | + } |
|
486 | + } |
|
487 | + } |
|
488 | 488 | |
489 | - //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | - if ($data['data'] instanceof EE_Event) { |
|
491 | - $event = $data['data']; |
|
492 | - foreach ($registrations_on_attendee as $reg) { |
|
493 | - if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | - $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | - foreach ($anss as $ans) { |
|
496 | - if ($ans instanceof EE_Answer) { |
|
497 | - $answers[$ans->ID()] = $ans; |
|
498 | - } |
|
499 | - } |
|
500 | - } |
|
501 | - } |
|
502 | - } |
|
489 | + //if the context is the event list parser, then let's return just the answers for all registrations attached to the recipient for that event. |
|
490 | + if ($data['data'] instanceof EE_Event) { |
|
491 | + $event = $data['data']; |
|
492 | + foreach ($registrations_on_attendee as $reg) { |
|
493 | + if ($reg instanceof EE_Registration && $reg->event_ID() == $event->ID()) { |
|
494 | + $anss = ! empty($recipient->registrations[$reg->ID()]['ans_objs']) ? $recipient->registrations[$reg->ID()]['ans_objs'] : array(); |
|
495 | + foreach ($anss as $ans) { |
|
496 | + if ($ans instanceof EE_Answer) { |
|
497 | + $answers[$ans->ID()] = $ans; |
|
498 | + } |
|
499 | + } |
|
500 | + } |
|
501 | + } |
|
502 | + } |
|
503 | 503 | |
504 | - $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
504 | + $questions = $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
505 | 505 | |
506 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | - //object on it. |
|
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
509 | - $extra_data['data'] = $recipient; |
|
510 | - } |
|
506 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
507 | + //object on it. |
|
508 | + if ( ! isset( $extra_data['data'] ) ) { |
|
509 | + $extra_data['data'] = $recipient; |
|
510 | + } |
|
511 | 511 | |
512 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | - $shortcode_parser, |
|
514 | - $questions, |
|
515 | - $answers, |
|
516 | - $template, |
|
517 | - $valid_shortcodes, |
|
518 | - $extra_data |
|
519 | - ); |
|
520 | - break; |
|
512 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
513 | + $shortcode_parser, |
|
514 | + $questions, |
|
515 | + $answers, |
|
516 | + $template, |
|
517 | + $valid_shortcodes, |
|
518 | + $extra_data |
|
519 | + ); |
|
520 | + break; |
|
521 | 521 | |
522 | - default : |
|
523 | - return $parsed; |
|
524 | - break; |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | - { |
|
531 | - $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | - 'event_espresso'); |
|
533 | - |
|
534 | - return $shortcodes; |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - /** |
|
539 | - * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | - * |
|
541 | - * @param string $parsed The original parsed content for the shortcode |
|
542 | - * @param string $shortcode The shortcode being parsed |
|
543 | - * @param array $data The shortcode parser data array |
|
544 | - * @param array $extra_data The shortcode parser extra data array |
|
545 | - * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | - * |
|
547 | - * @return string |
|
548 | - */ |
|
549 | - public function additional_primary_registration_details_parser( |
|
550 | - $parsed, |
|
551 | - $shortcode, |
|
552 | - $data, |
|
553 | - $extra_data, |
|
554 | - $shortcode_parser |
|
555 | - ) { |
|
556 | - if (array($data) && ! isset($data['data'])) { |
|
557 | - return $parsed; |
|
558 | - } |
|
559 | - |
|
560 | - $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | - $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | - |
|
563 | - if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | - return $parsed; |
|
565 | - } |
|
566 | - |
|
567 | - switch ($shortcode) { |
|
568 | - case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | - if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | - return ''; |
|
571 | - } |
|
572 | - $registration = $recipient->primary_reg_obj; |
|
573 | - $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
574 | - $valid_shortcodes = array('question'); |
|
575 | - $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
576 | - $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
577 | - //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
578 | - //object on it. |
|
579 | - if ( ! isset( $extra_data['data'] ) ){ |
|
580 | - $extra_data['data'] = $recipient; |
|
581 | - } |
|
582 | - return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
583 | - $shortcode_parser, |
|
584 | - $questions, |
|
585 | - $answers, |
|
586 | - $template, |
|
587 | - $valid_shortcodes, |
|
588 | - $extra_data |
|
589 | - ); |
|
590 | - break; |
|
522 | + default : |
|
523 | + return $parsed; |
|
524 | + break; |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + public function additional_primary_registration_details_shortcodes($shortcodes, $shortcode_parser) |
|
530 | + { |
|
531 | + $shortcodes['[PRIMARY_REGISTRANT_QUESTION_LIST]'] = __('This is used to indicate the questions and answers for the primary_registrant. It should be placed in the "[attendee_list]" field', |
|
532 | + 'event_espresso'); |
|
533 | + |
|
534 | + return $shortcodes; |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + /** |
|
539 | + * Callback for FHEE__EE_Primary_Registration_List_Shortcodes__parser_after filter (dynamic filter). |
|
540 | + * |
|
541 | + * @param string $parsed The original parsed content for the shortcode |
|
542 | + * @param string $shortcode The shortcode being parsed |
|
543 | + * @param array $data The shortcode parser data array |
|
544 | + * @param array $extra_data The shortcode parser extra data array |
|
545 | + * @param \EE_Shortcodes $shortcode_parser Shortcode parser. |
|
546 | + * |
|
547 | + * @return string |
|
548 | + */ |
|
549 | + public function additional_primary_registration_details_parser( |
|
550 | + $parsed, |
|
551 | + $shortcode, |
|
552 | + $data, |
|
553 | + $extra_data, |
|
554 | + $shortcode_parser |
|
555 | + ) { |
|
556 | + if (array($data) && ! isset($data['data'])) { |
|
557 | + return $parsed; |
|
558 | + } |
|
559 | + |
|
560 | + $recipient = $data['data'] instanceof EE_Messages_Addressee ? $data['data'] : null; |
|
561 | + $recipient = ! $recipient instanceof EE_Messages_Addressee && array($extra_data) && isset($extra_data['data']) && $extra_data['data'] instanceof EE_Messages_Addressee ? $extra_data['data'] : $recipient; |
|
562 | + |
|
563 | + if ( ! $recipient instanceof EE_Messages_Addressee) { |
|
564 | + return $parsed; |
|
565 | + } |
|
566 | + |
|
567 | + switch ($shortcode) { |
|
568 | + case '[PRIMARY_REGISTRANT_QUESTION_LIST]' : |
|
569 | + if ( ! $recipient->primary_att_obj instanceof EE_Attendee || ! $recipient->primary_reg_obj instanceof EE_Registration) { |
|
570 | + return ''; |
|
571 | + } |
|
572 | + $registration = $recipient->primary_reg_obj; |
|
573 | + $template = is_array($data['template']) && isset($data['template']['question_list']) ? $data['template']['question_list'] : $extra_data['template']['question_list']; |
|
574 | + $valid_shortcodes = array('question'); |
|
575 | + $answers = $recipient->registrations[$registration->ID()]['ans_objs']; |
|
576 | + $questions = isset($recipient->questions) ? $recipient->questions : array(); |
|
577 | + //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
|
578 | + //object on it. |
|
579 | + if ( ! isset( $extra_data['data'] ) ){ |
|
580 | + $extra_data['data'] = $recipient; |
|
581 | + } |
|
582 | + return $this->_parse_question_list_for_primary_or_recipient_registration( |
|
583 | + $shortcode_parser, |
|
584 | + $questions, |
|
585 | + $answers, |
|
586 | + $template, |
|
587 | + $valid_shortcodes, |
|
588 | + $extra_data |
|
589 | + ); |
|
590 | + break; |
|
591 | 591 | |
592 | - default : |
|
593 | - return $parsed; |
|
594 | - break; |
|
595 | - } |
|
596 | - } |
|
597 | - |
|
598 | - |
|
599 | - /** |
|
600 | - * Takes care of registering the message types that are only available in caffeinated EE. |
|
601 | - * |
|
602 | - * @since 4.3.2 |
|
603 | - * |
|
604 | - * @return void |
|
605 | - */ |
|
606 | - public function register_caf_message_types() |
|
607 | - { |
|
608 | - //register newsletter message type |
|
609 | - $setup_args = array( |
|
610 | - 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
611 | - 'autoloadpaths' => array( |
|
612 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
613 | - ), |
|
614 | - 'messengers_to_activate_with' => array('email'), |
|
615 | - 'messengers_to_validate_with' => array('email') |
|
616 | - ); |
|
617 | - EE_Register_Message_Type::register('newsletter', $setup_args); |
|
618 | - |
|
619 | - //register payment reminder message type |
|
620 | - $setup_args = array( |
|
621 | - 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
622 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
623 | - 'messengers_to_activate_with' => array('email'), |
|
624 | - 'messengers_to_validate_with' => array('email') |
|
625 | - ); |
|
626 | - EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
627 | - |
|
628 | - //register payment declined message type |
|
629 | - $setup_args = array( |
|
630 | - 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
631 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
632 | - 'messengers_to_activate_with' => array('email'), |
|
633 | - 'messengers_to_validate_with' => array('email') |
|
634 | - ); |
|
635 | - EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
636 | - |
|
637 | - //register registration declined message type |
|
638 | - $setup_args = array( |
|
639 | - 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
640 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
641 | - 'messengers_to_activate_with' => array('email'), |
|
642 | - 'messengers_to_validate_with' => array('email') |
|
643 | - ); |
|
644 | - EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
645 | - |
|
646 | - //register registration cancelled message type |
|
647 | - $setup_args = array( |
|
648 | - 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
650 | - 'messengers_to_activate_with' => array('email'), |
|
651 | - 'messengers_to_validate_with' => array('email') |
|
652 | - ); |
|
653 | - EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
654 | - |
|
655 | - |
|
656 | - //register payment failed message type |
|
657 | - $setup_args = array( |
|
658 | - 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
660 | - 'messengers_to_activate_with' => array('email'), |
|
661 | - 'messengers_to_validate_with' => array('email') |
|
662 | - ); |
|
663 | - EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
664 | - |
|
665 | - //register payment declined message type |
|
666 | - $setup_args = array( |
|
667 | - 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
668 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
669 | - 'messengers_to_activate_with' => array('email'), |
|
670 | - 'messengers_to_validate_with' => array('email') |
|
671 | - ); |
|
672 | - EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
673 | - } |
|
674 | - |
|
675 | - |
|
676 | - /** |
|
677 | - * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
678 | - * |
|
679 | - * @since 4.3.2 |
|
680 | - * |
|
681 | - * @return void |
|
682 | - */ |
|
683 | - public function register_caf_shortcodes() |
|
684 | - { |
|
685 | - $setup_args = array( |
|
686 | - 'autoloadpaths' => array( |
|
687 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
688 | - ), |
|
689 | - 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
690 | - 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
691 | - 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
692 | - ); |
|
693 | - EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
694 | - } |
|
695 | - |
|
696 | - |
|
697 | - /** |
|
698 | - * Parses a question list shortcode using given data and template |
|
699 | - * |
|
700 | - * @param \EE_Shortcodes $shortcode_parser |
|
701 | - * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
702 | - * @param EE_Answer[] $answers An array of answer objects |
|
703 | - * @param string $template Template content to be parsed. |
|
704 | - * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | - * @param array $extra_data Extra data that might be used when parsing the template. |
|
706 | - */ |
|
707 | - protected function _parse_question_list_for_primary_or_recipient_registration( |
|
708 | - $shortcode_parser, |
|
709 | - $questions, |
|
710 | - $answers, |
|
711 | - $template, |
|
712 | - $valid_shortcodes, |
|
713 | - $extra_data |
|
714 | - ) { |
|
715 | - $question_list = ''; |
|
716 | - /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
717 | - $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
718 | - foreach ($answers as $answer) { |
|
719 | - if ($answer instanceof EE_Answer) { |
|
720 | - //first see if the question is in our $questions array. If not then try to get from answer object. |
|
721 | - $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
722 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
723 | - if ( |
|
724 | - ! $question instanceof EE_Question |
|
725 | - || ( |
|
726 | - $question instanceof EE_Question |
|
727 | - && $question->admin_only() |
|
728 | - ) |
|
729 | - ) { |
|
730 | - continue; |
|
731 | - } |
|
732 | - $question_list .= $shortcode_helper->parse_question_list_template( |
|
733 | - $template, |
|
734 | - $answer, |
|
735 | - $valid_shortcodes, |
|
736 | - $extra_data |
|
737 | - ); |
|
738 | - } |
|
739 | - } |
|
740 | - |
|
741 | - return $question_list; |
|
742 | - } |
|
592 | + default : |
|
593 | + return $parsed; |
|
594 | + break; |
|
595 | + } |
|
596 | + } |
|
597 | + |
|
598 | + |
|
599 | + /** |
|
600 | + * Takes care of registering the message types that are only available in caffeinated EE. |
|
601 | + * |
|
602 | + * @since 4.3.2 |
|
603 | + * |
|
604 | + * @return void |
|
605 | + */ |
|
606 | + public function register_caf_message_types() |
|
607 | + { |
|
608 | + //register newsletter message type |
|
609 | + $setup_args = array( |
|
610 | + 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
|
611 | + 'autoloadpaths' => array( |
|
612 | + EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
613 | + ), |
|
614 | + 'messengers_to_activate_with' => array('email'), |
|
615 | + 'messengers_to_validate_with' => array('email') |
|
616 | + ); |
|
617 | + EE_Register_Message_Type::register('newsletter', $setup_args); |
|
618 | + |
|
619 | + //register payment reminder message type |
|
620 | + $setup_args = array( |
|
621 | + 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
|
622 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
623 | + 'messengers_to_activate_with' => array('email'), |
|
624 | + 'messengers_to_validate_with' => array('email') |
|
625 | + ); |
|
626 | + EE_Register_Message_Type::register('payment_reminder', $setup_args); |
|
627 | + |
|
628 | + //register payment declined message type |
|
629 | + $setup_args = array( |
|
630 | + 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
|
631 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
632 | + 'messengers_to_activate_with' => array('email'), |
|
633 | + 'messengers_to_validate_with' => array('email') |
|
634 | + ); |
|
635 | + EE_Register_Message_Type::register('payment_declined', $setup_args); |
|
636 | + |
|
637 | + //register registration declined message type |
|
638 | + $setup_args = array( |
|
639 | + 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
|
640 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
641 | + 'messengers_to_activate_with' => array('email'), |
|
642 | + 'messengers_to_validate_with' => array('email') |
|
643 | + ); |
|
644 | + EE_Register_Message_Type::register('declined_registration', $setup_args); |
|
645 | + |
|
646 | + //register registration cancelled message type |
|
647 | + $setup_args = array( |
|
648 | + 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
|
649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
650 | + 'messengers_to_activate_with' => array('email'), |
|
651 | + 'messengers_to_validate_with' => array('email') |
|
652 | + ); |
|
653 | + EE_Register_Message_Type::register('cancelled_registration', $setup_args); |
|
654 | + |
|
655 | + |
|
656 | + //register payment failed message type |
|
657 | + $setup_args = array( |
|
658 | + 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
|
659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
660 | + 'messengers_to_activate_with' => array('email'), |
|
661 | + 'messengers_to_validate_with' => array('email') |
|
662 | + ); |
|
663 | + EE_Register_Message_Type::register('payment_failed', $setup_args); |
|
664 | + |
|
665 | + //register payment declined message type |
|
666 | + $setup_args = array( |
|
667 | + 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
|
668 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
669 | + 'messengers_to_activate_with' => array('email'), |
|
670 | + 'messengers_to_validate_with' => array('email') |
|
671 | + ); |
|
672 | + EE_Register_Message_Type::register('payment_cancelled', $setup_args); |
|
673 | + } |
|
674 | + |
|
675 | + |
|
676 | + /** |
|
677 | + * Takes care of registering the shortcode libraries implemented with caffeinated EE and set up related items. |
|
678 | + * |
|
679 | + * @since 4.3.2 |
|
680 | + * |
|
681 | + * @return void |
|
682 | + */ |
|
683 | + public function register_caf_shortcodes() |
|
684 | + { |
|
685 | + $setup_args = array( |
|
686 | + 'autoloadpaths' => array( |
|
687 | + EE_CAF_LIBRARIES . 'shortcodes/' |
|
688 | + ), |
|
689 | + 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
|
690 | + 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
|
691 | + 'list_type_shortcodes' => array('[NEWSLETTER_CONTENT]') |
|
692 | + ); |
|
693 | + EE_Register_Messages_Shortcode_Library::register('newsletter', $setup_args); |
|
694 | + } |
|
695 | + |
|
696 | + |
|
697 | + /** |
|
698 | + * Parses a question list shortcode using given data and template |
|
699 | + * |
|
700 | + * @param \EE_Shortcodes $shortcode_parser |
|
701 | + * @param EE_Question[] $questions An array of questions indexed by answer id. |
|
702 | + * @param EE_Answer[] $answers An array of answer objects |
|
703 | + * @param string $template Template content to be parsed. |
|
704 | + * @param array $valid_shortcodes Valid shortcodes for the template being parsed. |
|
705 | + * @param array $extra_data Extra data that might be used when parsing the template. |
|
706 | + */ |
|
707 | + protected function _parse_question_list_for_primary_or_recipient_registration( |
|
708 | + $shortcode_parser, |
|
709 | + $questions, |
|
710 | + $answers, |
|
711 | + $template, |
|
712 | + $valid_shortcodes, |
|
713 | + $extra_data |
|
714 | + ) { |
|
715 | + $question_list = ''; |
|
716 | + /** @var EEH_Parse_Shortcodes $shortcode_helper */ |
|
717 | + $shortcode_helper = $shortcode_parser->get_shortcode_helper(); |
|
718 | + foreach ($answers as $answer) { |
|
719 | + if ($answer instanceof EE_Answer) { |
|
720 | + //first see if the question is in our $questions array. If not then try to get from answer object. |
|
721 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
722 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
723 | + if ( |
|
724 | + ! $question instanceof EE_Question |
|
725 | + || ( |
|
726 | + $question instanceof EE_Question |
|
727 | + && $question->admin_only() |
|
728 | + ) |
|
729 | + ) { |
|
730 | + continue; |
|
731 | + } |
|
732 | + $question_list .= $shortcode_helper->parse_question_list_template( |
|
733 | + $template, |
|
734 | + $answer, |
|
735 | + $valid_shortcodes, |
|
736 | + $extra_data |
|
737 | + ); |
|
738 | + } |
|
739 | + } |
|
740 | + |
|
741 | + return $question_list; |
|
742 | + } |
|
743 | 743 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function messages_autoload_paths($dir_ref) |
97 | 97 | { |
98 | - $dir_ref[] = EE_CAF_LIBRARIES . 'shortcodes/'; |
|
98 | + $dir_ref[] = EE_CAF_LIBRARIES.'shortcodes/'; |
|
99 | 99 | |
100 | 100 | return $dir_ref; |
101 | 101 | } |
@@ -216,10 +216,10 @@ discard block |
||
216 | 216 | } |
217 | 217 | |
218 | 218 | //the template file name we're replacing contents for. |
219 | - $template_file_prefix = $field . '_' . $context; |
|
220 | - $msg_prefix = $messenger->name . '_' . $message_type->name . '_'; |
|
219 | + $template_file_prefix = $field.'_'.$context; |
|
220 | + $msg_prefix = $messenger->name.'_'.$message_type->name.'_'; |
|
221 | 221 | |
222 | - $base_path = EE_CAF_LIBRARIES . 'messages/defaults/default/'; |
|
222 | + $base_path = EE_CAF_LIBRARIES.'messages/defaults/default/'; |
|
223 | 223 | |
224 | 224 | if ($messenger->name == 'email' && $message_type->name == 'registration') { |
225 | 225 | |
@@ -228,17 +228,17 @@ discard block |
||
228 | 228 | case 'question_list_admin' : |
229 | 229 | case 'question_list_attendee' : |
230 | 230 | case 'question_list_primary_attendee' : |
231 | - $path = $base_path . $msg_prefix . 'question_list.template.php'; |
|
231 | + $path = $base_path.$msg_prefix.'question_list.template.php'; |
|
232 | 232 | $contents = EEH_Template::display_template($path, array(), true); |
233 | 233 | break; |
234 | 234 | |
235 | 235 | case 'attendee_list_primary_attendee' : |
236 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
236 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
237 | 237 | $contents = EEH_Template::display_template($path, array(), true); |
238 | 238 | break; |
239 | 239 | |
240 | 240 | case 'attendee_list_admin' : |
241 | - $path = $base_path . $msg_prefix . 'attendee_list_admin.template.php'; |
|
241 | + $path = $base_path.$msg_prefix.'attendee_list_admin.template.php'; |
|
242 | 242 | $contents = EEH_Template::display_template($path, |
243 | 243 | array(), true); |
244 | 244 | break; |
@@ -248,7 +248,7 @@ discard block |
||
248 | 248 | break; |
249 | 249 | |
250 | 250 | case 'event_list_attendee' : |
251 | - $path = $base_path . $msg_prefix . 'event_list_attendee.template.php'; |
|
251 | + $path = $base_path.$msg_prefix.'event_list_attendee.template.php'; |
|
252 | 252 | $contents = EEH_Template::display_template($path, array(), true); |
253 | 253 | break; |
254 | 254 | } |
@@ -256,24 +256,24 @@ discard block |
||
256 | 256 | switch ($template_file_prefix) { |
257 | 257 | |
258 | 258 | case 'content_attendee' : |
259 | - $path = $base_path . $msg_prefix . 'content.template.php'; |
|
259 | + $path = $base_path.$msg_prefix.'content.template.php'; |
|
260 | 260 | $contents = EEH_Template::display_template($path, array(), true); |
261 | 261 | break; |
262 | 262 | |
263 | 263 | case 'newsletter_content_attendee' : |
264 | - $path = $base_path . $msg_prefix . 'newsletter_content.template.php'; |
|
264 | + $path = $base_path.$msg_prefix.'newsletter_content.template.php'; |
|
265 | 265 | $contents = EEH_Template::display_template($path, array(), true); |
266 | 266 | break; |
267 | 267 | |
268 | 268 | case 'newsletter_subject_attendee' : |
269 | - $path = $base_path . $msg_prefix . 'subject.template.php'; |
|
269 | + $path = $base_path.$msg_prefix.'subject.template.php'; |
|
270 | 270 | $contents = EEH_Template::display_template($path, array(), true); |
271 | 271 | break; |
272 | 272 | } |
273 | 273 | } elseif ($messenger->name == 'html' && $message_type->name == 'receipt') { |
274 | 274 | switch ($template_file_prefix) { |
275 | 275 | case 'attendee_list_purchaser' : |
276 | - $path = $base_path . $msg_prefix . 'attendee_list.template.php'; |
|
276 | + $path = $base_path.$msg_prefix.'attendee_list.template.php'; |
|
277 | 277 | $contents = EEH_Template::display_template($path, array(), true); |
278 | 278 | break; |
279 | 279 | } |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
507 | 507 | //object on it. |
508 | - if ( ! isset( $extra_data['data'] ) ) { |
|
508 | + if ( ! isset($extra_data['data'])) { |
|
509 | 509 | $extra_data['data'] = $recipient; |
510 | 510 | } |
511 | 511 | |
@@ -576,7 +576,7 @@ discard block |
||
576 | 576 | $questions = isset($recipient->questions) ? $recipient->questions : array(); |
577 | 577 | //if $extra_data does not have a 'data' key then let's make sure we add it and set the EE_Messages_Addressee |
578 | 578 | //object on it. |
579 | - if ( ! isset( $extra_data['data'] ) ){ |
|
579 | + if ( ! isset($extra_data['data'])) { |
|
580 | 580 | $extra_data['data'] = $recipient; |
581 | 581 | } |
582 | 582 | return $this->_parse_question_list_for_primary_or_recipient_registration( |
@@ -609,7 +609,7 @@ discard block |
||
609 | 609 | $setup_args = array( |
610 | 610 | 'mtfilename' => 'EE_Newsletter_message_type.class.php', |
611 | 611 | 'autoloadpaths' => array( |
612 | - EE_CAF_LIBRARIES . 'messages/message_type/newsletter/' |
|
612 | + EE_CAF_LIBRARIES.'messages/message_type/newsletter/' |
|
613 | 613 | ), |
614 | 614 | 'messengers_to_activate_with' => array('email'), |
615 | 615 | 'messengers_to_validate_with' => array('email') |
@@ -619,7 +619,7 @@ discard block |
||
619 | 619 | //register payment reminder message type |
620 | 620 | $setup_args = array( |
621 | 621 | 'mtfilename' => 'EE_Payment_Reminder_message_type.class.php', |
622 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_reminder/'), |
|
622 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_reminder/'), |
|
623 | 623 | 'messengers_to_activate_with' => array('email'), |
624 | 624 | 'messengers_to_validate_with' => array('email') |
625 | 625 | ); |
@@ -628,7 +628,7 @@ discard block |
||
628 | 628 | //register payment declined message type |
629 | 629 | $setup_args = array( |
630 | 630 | 'mtfilename' => 'EE_Payment_Declined_message_type.class.php', |
631 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_declined/'), |
|
631 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_declined/'), |
|
632 | 632 | 'messengers_to_activate_with' => array('email'), |
633 | 633 | 'messengers_to_validate_with' => array('email') |
634 | 634 | ); |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | //register registration declined message type |
638 | 638 | $setup_args = array( |
639 | 639 | 'mtfilename' => 'EE_Declined_Registration_message_type.class.php', |
640 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/declined_registration/'), |
|
640 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/declined_registration/'), |
|
641 | 641 | 'messengers_to_activate_with' => array('email'), |
642 | 642 | 'messengers_to_validate_with' => array('email') |
643 | 643 | ); |
@@ -646,7 +646,7 @@ discard block |
||
646 | 646 | //register registration cancelled message type |
647 | 647 | $setup_args = array( |
648 | 648 | 'mtfilename' => 'EE_Cancelled_Registration_message_type.class.php', |
649 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/cancelled_registration/'), |
|
649 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/cancelled_registration/'), |
|
650 | 650 | 'messengers_to_activate_with' => array('email'), |
651 | 651 | 'messengers_to_validate_with' => array('email') |
652 | 652 | ); |
@@ -656,7 +656,7 @@ discard block |
||
656 | 656 | //register payment failed message type |
657 | 657 | $setup_args = array( |
658 | 658 | 'mtfilename' => 'EE_Payment_Failed_message_type.class.php', |
659 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_failed/'), |
|
659 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_failed/'), |
|
660 | 660 | 'messengers_to_activate_with' => array('email'), |
661 | 661 | 'messengers_to_validate_with' => array('email') |
662 | 662 | ); |
@@ -665,7 +665,7 @@ discard block |
||
665 | 665 | //register payment declined message type |
666 | 666 | $setup_args = array( |
667 | 667 | 'mtfilename' => 'EE_Payment_Cancelled_message_type.class.php', |
668 | - 'autoloadpaths' => array(EE_CAF_LIBRARIES . 'messages/message_type/payment_cancelled/'), |
|
668 | + 'autoloadpaths' => array(EE_CAF_LIBRARIES.'messages/message_type/payment_cancelled/'), |
|
669 | 669 | 'messengers_to_activate_with' => array('email'), |
670 | 670 | 'messengers_to_validate_with' => array('email') |
671 | 671 | ); |
@@ -684,7 +684,7 @@ discard block |
||
684 | 684 | { |
685 | 685 | $setup_args = array( |
686 | 686 | 'autoloadpaths' => array( |
687 | - EE_CAF_LIBRARIES . 'shortcodes/' |
|
687 | + EE_CAF_LIBRARIES.'shortcodes/' |
|
688 | 688 | ), |
689 | 689 | 'msgr_validator_callback' => array('EE_Newsletter_Shortcodes', 'messenger_validator_config'), |
690 | 690 | 'msgr_template_fields_callback' => array('EE_Newsletter_Shortcodes', 'messenger_template_fields'), |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | |
3 | 3 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
4 | - exit('NO direct script access allowed'); |
|
4 | + exit('NO direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | |
7 | 7 | /** |
@@ -36,80 +36,80 @@ discard block |
||
36 | 36 | { |
37 | 37 | |
38 | 38 | |
39 | - public function __construct() |
|
40 | - { |
|
41 | - parent::__construct(); |
|
42 | - } |
|
39 | + public function __construct() |
|
40 | + { |
|
41 | + parent::__construct(); |
|
42 | + } |
|
43 | 43 | |
44 | 44 | |
45 | - protected function _init_props() |
|
46 | - { |
|
47 | - $this->label = __('Questions and Answers Shortcodes', 'event_espresso'); |
|
48 | - $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso'); |
|
49 | - $this->_shortcodes = array( |
|
50 | - '[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant. You place this within the "[attendee_list]" field.', |
|
51 | - 'event_espresso') |
|
52 | - ); |
|
53 | - } |
|
45 | + protected function _init_props() |
|
46 | + { |
|
47 | + $this->label = __('Questions and Answers Shortcodes', 'event_espresso'); |
|
48 | + $this->description = __('All shortcodes related to custom questions and answers', 'event_espresso'); |
|
49 | + $this->_shortcodes = array( |
|
50 | + '[QUESTION_LIST]' => __('This is used to indicate where you want the list of questions and answers to show for the registrant. You place this within the "[attendee_list]" field.', |
|
51 | + 'event_espresso') |
|
52 | + ); |
|
53 | + } |
|
54 | 54 | |
55 | 55 | |
56 | - protected function _parser($shortcode) |
|
57 | - { |
|
56 | + protected function _parser($shortcode) |
|
57 | + { |
|
58 | 58 | |
59 | 59 | |
60 | - switch ($shortcode) { |
|
61 | - case '[QUESTION_LIST]' : |
|
62 | - return $this->_get_question_list(); |
|
63 | - break; |
|
64 | - } |
|
60 | + switch ($shortcode) { |
|
61 | + case '[QUESTION_LIST]' : |
|
62 | + return $this->_get_question_list(); |
|
63 | + break; |
|
64 | + } |
|
65 | 65 | |
66 | - return ''; |
|
67 | - } |
|
66 | + return ''; |
|
67 | + } |
|
68 | 68 | |
69 | 69 | |
70 | - protected function _get_question_list() |
|
71 | - { |
|
72 | - $this->_validate_list_requirements(); |
|
70 | + protected function _get_question_list() |
|
71 | + { |
|
72 | + $this->_validate_list_requirements(); |
|
73 | 73 | |
74 | - //for when [QUESTION_LIST] is used in the [attendee_list] field. |
|
75 | - if ($this->_data['data'] instanceof EE_Registration) { |
|
76 | - return $this->_get_question_answer_list_for_attendee(); |
|
77 | - } //for when [QUESTION_LIST] is used in the main content field. |
|
78 | - else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) { |
|
79 | - return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj); |
|
80 | - } else { |
|
81 | - return ''; |
|
82 | - } |
|
83 | - } |
|
74 | + //for when [QUESTION_LIST] is used in the [attendee_list] field. |
|
75 | + if ($this->_data['data'] instanceof EE_Registration) { |
|
76 | + return $this->_get_question_answer_list_for_attendee(); |
|
77 | + } //for when [QUESTION_LIST] is used in the main content field. |
|
78 | + else if ($this->_data['data'] instanceof EE_Messages_Addressee && $this->_data['data']->reg_obj instanceof EE_Registration) { |
|
79 | + return $this->_get_question_answer_list_for_attendee($this->_data['data']->reg_obj); |
|
80 | + } else { |
|
81 | + return ''; |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of |
|
88 | - * answers for that attendee since that is what we really need (we can derive the questions from the answers); |
|
89 | - * @return string parsed template. |
|
90 | - */ |
|
91 | - private function _get_question_answer_list_for_attendee($reg_obj = null) |
|
92 | - { |
|
93 | - $valid_shortcodes = array('question'); |
|
94 | - $reg_obj = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data']; |
|
95 | - $template = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : ''; |
|
96 | - $template = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template; |
|
97 | - $ans_result = ''; |
|
98 | - $answers = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array(); |
|
99 | - $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array(); |
|
100 | - foreach ($answers as $answer) { |
|
101 | - //first see if the question is in our $questions array. If not then try to get from answer object |
|
102 | - $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null; |
|
103 | - $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
104 | - if ($question instanceof EE_Question and $question->admin_only()) { |
|
105 | - continue; |
|
106 | - } |
|
107 | - $ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes, |
|
108 | - $this->_extra_data); |
|
109 | - } |
|
86 | + /** |
|
87 | + * Note when we parse the "[question_list]" shortcode for attendees we're actually going to retrieve the list of |
|
88 | + * answers for that attendee since that is what we really need (we can derive the questions from the answers); |
|
89 | + * @return string parsed template. |
|
90 | + */ |
|
91 | + private function _get_question_answer_list_for_attendee($reg_obj = null) |
|
92 | + { |
|
93 | + $valid_shortcodes = array('question'); |
|
94 | + $reg_obj = $reg_obj instanceof EE_Registration ? $reg_obj : $this->_data['data']; |
|
95 | + $template = is_array($this->_data['template']) && isset($this->_data['template']['question_list']) ? $this->_data['template']['question_list'] : ''; |
|
96 | + $template = empty($template) && isset($this->_extra_data['template']['question_list']) ? $this->_extra_data['template']['question_list'] : $template; |
|
97 | + $ans_result = ''; |
|
98 | + $answers = ! empty($this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs']) ? $this->_extra_data['data']->registrations[$reg_obj->ID()]['ans_objs'] : array(); |
|
99 | + $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array(); |
|
100 | + foreach ($answers as $answer) { |
|
101 | + //first see if the question is in our $questions array. If not then try to get from answer object |
|
102 | + $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null; |
|
103 | + $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
|
104 | + if ($question instanceof EE_Question and $question->admin_only()) { |
|
105 | + continue; |
|
106 | + } |
|
107 | + $ans_result .= $this->_shortcode_helper->parse_question_list_template($template, $answer, $valid_shortcodes, |
|
108 | + $this->_extra_data); |
|
109 | + } |
|
110 | 110 | |
111 | - return $ans_result; |
|
112 | - } |
|
111 | + return $ans_result; |
|
112 | + } |
|
113 | 113 | |
114 | 114 | |
115 | 115 | } //end EE_Question_List_Shortcodes class |
@@ -99,7 +99,7 @@ |
||
99 | 99 | $questions = ! empty($this->_extra_data['data']->questions) ? $this->_extra_data['data']->questions : array(); |
100 | 100 | foreach ($answers as $answer) { |
101 | 101 | //first see if the question is in our $questions array. If not then try to get from answer object |
102 | - $question = isset($questions[ $answer->ID() ]) ? $questions[ $answer->ID() ] : null; |
|
102 | + $question = isset($questions[$answer->ID()]) ? $questions[$answer->ID()] : null; |
|
103 | 103 | $question = ! $question instanceof EE_Question ? $answer->question() : $question; |
104 | 104 | if ($question instanceof EE_Question and $question->admin_only()) { |
105 | 105 | continue; |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | |
5 | 5 | /** |
@@ -22,668 +22,668 @@ discard block |
||
22 | 22 | final class EE_Front_Controller |
23 | 23 | { |
24 | 24 | |
25 | - /** |
|
26 | - * $_template_path |
|
27 | - * @var string $_template_path |
|
28 | - * @access public |
|
29 | - */ |
|
30 | - private $_template_path; |
|
31 | - |
|
32 | - /** |
|
33 | - * $_template |
|
34 | - * @var string $_template |
|
35 | - * @access public |
|
36 | - */ |
|
37 | - private $_template; |
|
38 | - |
|
39 | - /** |
|
40 | - * @type EE_Registry $Registry |
|
41 | - * @access protected |
|
42 | - */ |
|
43 | - protected $Registry; |
|
44 | - |
|
45 | - /** |
|
46 | - * @type EE_Request_Handler $Request_Handler |
|
47 | - * @access protected |
|
48 | - */ |
|
49 | - protected $Request_Handler; |
|
50 | - |
|
51 | - /** |
|
52 | - * @type EE_Module_Request_Router $Module_Request_Router |
|
53 | - * @access protected |
|
54 | - */ |
|
55 | - protected $Module_Request_Router; |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * class constructor |
|
60 | - * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
61 | - * |
|
62 | - * @access public |
|
63 | - * @param \EE_Registry $Registry |
|
64 | - * @param \EE_Request_Handler $Request_Handler |
|
65 | - * @param \EE_Module_Request_Router $Module_Request_Router |
|
66 | - */ |
|
67 | - public function __construct( |
|
68 | - EE_Registry $Registry, |
|
69 | - EE_Request_Handler $Request_Handler, |
|
70 | - EE_Module_Request_Router $Module_Request_Router |
|
71 | - ) { |
|
72 | - $this->Registry = $Registry; |
|
73 | - $this->Request_Handler = $Request_Handler; |
|
74 | - $this->Module_Request_Router = $Module_Request_Router; |
|
75 | - // make sure template tags are loaded immediately so that themes don't break |
|
76 | - add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
|
77 | - // determine how to integrate WP_Query with the EE models |
|
78 | - add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
79 | - // load other resources and begin to actually run shortcodes and modules |
|
80 | - add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
81 | - // analyse the incoming WP request |
|
82 | - add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
83 | - // process any content shortcodes |
|
84 | - add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
|
85 | - // process request with module factory |
|
86 | - add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
87 | - // before headers sent |
|
88 | - add_action('wp', array($this, 'wp'), 5); |
|
89 | - // load css and js |
|
90 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
91 | - // header |
|
92 | - add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
93 | - add_filter('template_include', array($this, 'template_include'), 1); |
|
94 | - // display errors |
|
95 | - add_action('loop_start', array($this, 'display_errors'), 2); |
|
96 | - // the content |
|
97 | - // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
98 | - //exclude our private cpt comments |
|
99 | - add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
100 | - //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
101 | - add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
102 | - // action hook EE |
|
103 | - do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
104 | - // for checking that browser cookies are enabled |
|
105 | - if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
106 | - setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
|
107 | - } |
|
108 | - } |
|
109 | - |
|
110 | - |
|
111 | - /** |
|
112 | - * @return EE_Request_Handler |
|
113 | - */ |
|
114 | - public function Request_Handler() |
|
115 | - { |
|
116 | - return $this->Request_Handler; |
|
117 | - } |
|
118 | - |
|
119 | - |
|
120 | - /** |
|
121 | - * @return EE_Module_Request_Router |
|
122 | - */ |
|
123 | - public function Module_Request_Router() |
|
124 | - { |
|
125 | - return $this->Module_Request_Router; |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - |
|
131 | - |
|
132 | - /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
133 | - |
|
134 | - |
|
135 | - /** |
|
136 | - * load_espresso_template_tags - if current theme is an espresso theme, or uses ee theme template parts, then |
|
137 | - * load it's functions.php file ( if not already loaded ) |
|
138 | - * |
|
139 | - * @return void |
|
140 | - */ |
|
141 | - public function load_espresso_template_tags() |
|
142 | - { |
|
143 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
144 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
145 | - } |
|
146 | - } |
|
147 | - |
|
148 | - |
|
149 | - /** |
|
150 | - * filter_wp_comments |
|
151 | - * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
152 | - * widgets/queries done on frontend |
|
153 | - * |
|
154 | - * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
155 | - * @return array array of comment clauses with modifications. |
|
156 | - */ |
|
157 | - public function filter_wp_comments($clauses) |
|
158 | - { |
|
159 | - global $wpdb; |
|
160 | - if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
161 | - $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
162 | - foreach ($cpts as $cpt => $details) { |
|
163 | - $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
164 | - } |
|
165 | - } |
|
166 | - return $clauses; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * employ_CPT_Strategy |
|
172 | - * |
|
173 | - * @access public |
|
174 | - * @return void |
|
175 | - */ |
|
176 | - public function employ_CPT_Strategy() |
|
177 | - { |
|
178 | - if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
179 | - $this->Registry->load_core('CPT_Strategy'); |
|
180 | - } |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
186 | - * |
|
187 | - * @param string $url incoming url |
|
188 | - * @return string final assembled url |
|
189 | - */ |
|
190 | - public function maybe_force_admin_ajax_ssl($url) |
|
191 | - { |
|
192 | - if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
193 | - $url = str_replace('http://', 'https://', $url); |
|
194 | - } |
|
195 | - return $url; |
|
196 | - } |
|
197 | - |
|
198 | - |
|
199 | - |
|
200 | - |
|
201 | - |
|
202 | - |
|
203 | - /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
204 | - |
|
205 | - |
|
206 | - /** |
|
207 | - * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
208 | - * default priority init phases have run |
|
209 | - * |
|
210 | - * @access public |
|
211 | - * @return void |
|
212 | - */ |
|
213 | - public function wp_loaded() |
|
214 | - { |
|
215 | - } |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - |
|
220 | - |
|
221 | - /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
222 | - /** |
|
223 | - * _get_request |
|
224 | - * |
|
225 | - * @access public |
|
226 | - * @param WP $WP |
|
227 | - * @return void |
|
228 | - */ |
|
229 | - public function get_request(WP $WP) |
|
230 | - { |
|
231 | - do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
232 | - $this->Request_Handler->parse_request($WP); |
|
233 | - do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
234 | - } |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * _initialize_shortcodes - calls init method on shortcodes that have been determined to be in the_content for |
|
239 | - * the currently requested page |
|
240 | - * |
|
241 | - * @access public |
|
242 | - * @param WP $WP |
|
243 | - * @return void |
|
244 | - */ |
|
245 | - public function _initialize_shortcodes(WP $WP) |
|
246 | - { |
|
247 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
|
248 | - $this->Request_Handler->set_request_vars($WP); |
|
249 | - // grab post_name from request |
|
250 | - $current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
251 | - $this->Request_Handler->get('post_name')); |
|
252 | - $show_on_front = get_option('show_on_front'); |
|
253 | - // if it's not set, then check if frontpage is blog |
|
254 | - if (empty($current_post)) { |
|
255 | - // yup.. this is the posts page, prepare to load all shortcode modules |
|
256 | - $current_post = 'posts'; |
|
257 | - // unless.. |
|
258 | - if ($show_on_front === 'page') { |
|
259 | - // some other page is set as the homepage |
|
260 | - $page_on_front = get_option('page_on_front'); |
|
261 | - if ($page_on_front) { |
|
262 | - // k now we need to find the post_name for this page |
|
263 | - global $wpdb; |
|
264 | - $page_on_front = $wpdb->get_var( |
|
265 | - $wpdb->prepare( |
|
266 | - "SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d", |
|
267 | - $page_on_front |
|
268 | - ) |
|
269 | - ); |
|
270 | - // set the current post slug to what it actually is |
|
271 | - $current_post = $page_on_front ? $page_on_front : $current_post; |
|
272 | - } |
|
273 | - } |
|
274 | - } |
|
275 | - // where are posts being displayed ? |
|
276 | - $page_for_posts = EE_Config::get_page_for_posts(); |
|
277 | - // in case $current_post is hierarchical like: /parent-page/current-page |
|
278 | - $current_post = basename($current_post); |
|
279 | - // are we on a category page? |
|
280 | - $term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', |
|
281 | - $WP->query_vars); |
|
282 | - // make sure shortcodes are set |
|
283 | - if (isset($this->Registry->CFG->core->post_shortcodes)) { |
|
284 | - if ( ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts])) { |
|
285 | - $this->Registry->CFG->core->post_shortcodes[$page_for_posts] = array(); |
|
286 | - } |
|
287 | - // cycle thru all posts with shortcodes set |
|
288 | - foreach ($this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
289 | - // filter shortcodes so |
|
290 | - $post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', |
|
291 | - $post_shortcodes); |
|
292 | - // now cycle thru shortcodes |
|
293 | - foreach ($post_shortcodes as $shortcode_class => $post_id) { |
|
294 | - // are we on this page, or on the blog page, or an EE CPT category page ? |
|
295 | - if ($current_post === $post_name || $term_exists) { |
|
296 | - // maybe init the shortcode |
|
297 | - $this->initialize_shortcode_if_active_on_page( |
|
298 | - $shortcode_class, |
|
299 | - $current_post, |
|
300 | - $page_for_posts, |
|
301 | - $post_id, |
|
302 | - $term_exists, |
|
303 | - $WP |
|
304 | - ); |
|
305 | - // if this is NOT the "Posts page" and we have a valid entry |
|
306 | - // for the "Posts page" in our tracked post_shortcodes array |
|
307 | - // but the shortcode is not being tracked for this page |
|
308 | - } else if ( |
|
309 | - $post_name !== $page_for_posts |
|
310 | - && isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts]) |
|
311 | - && ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class]) |
|
312 | - ) { |
|
313 | - // then remove the "fallback" shortcode processor |
|
314 | - remove_shortcode($shortcode_class); |
|
315 | - } |
|
316 | - } |
|
317 | - } |
|
318 | - } |
|
319 | - do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
|
320 | - } |
|
321 | - |
|
322 | - |
|
323 | - /** |
|
324 | - * @param string $shortcode_class |
|
325 | - * @param string $current_post |
|
326 | - * @param string $page_for_posts |
|
327 | - * @param int $post_id |
|
328 | - * @param bool $term_exists |
|
329 | - * @param WP $WP |
|
330 | - */ |
|
331 | - protected function initialize_shortcode_if_active_on_page( |
|
332 | - $shortcode_class, |
|
333 | - $current_post, |
|
334 | - $page_for_posts, |
|
335 | - $post_id, |
|
336 | - $term_exists, |
|
337 | - $WP |
|
338 | - ) { |
|
339 | - // verify shortcode is in list of registered shortcodes |
|
340 | - if ( ! isset($this->Registry->shortcodes->{$shortcode_class})) { |
|
341 | - if ($current_post !== $page_for_posts && current_user_can('edit_post', $post_id)) { |
|
342 | - EE_Error::add_error( |
|
343 | - sprintf( |
|
344 | - __( |
|
345 | - 'The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', |
|
346 | - 'event_espresso' |
|
347 | - ), |
|
348 | - $shortcode_class |
|
349 | - ), |
|
350 | - __FILE__, |
|
351 | - __FUNCTION__, |
|
352 | - __LINE__ |
|
353 | - ); |
|
354 | - add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
355 | - } |
|
356 | - add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
|
357 | - return; |
|
358 | - } |
|
359 | - // is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
|
360 | - if ( |
|
361 | - $term_exists |
|
362 | - || $current_post === $page_for_posts |
|
363 | - || isset($this->Registry->CFG->core->post_shortcodes[$current_post]) |
|
364 | - ) { |
|
365 | - // let's pause to reflect on this... |
|
366 | - $sc_reflector = new ReflectionClass('EES_' . $shortcode_class); |
|
367 | - // ensure that class is actually a shortcode |
|
368 | - if ( |
|
369 | - defined('WP_DEBUG') |
|
370 | - && WP_DEBUG === true |
|
371 | - && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
372 | - ) { |
|
373 | - EE_Error::add_error( |
|
374 | - sprintf( |
|
375 | - __( |
|
376 | - 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
377 | - 'event_espresso' |
|
378 | - ), |
|
379 | - $shortcode_class |
|
380 | - ), |
|
381 | - __FILE__, |
|
382 | - __FUNCTION__, |
|
383 | - __LINE__ |
|
384 | - ); |
|
385 | - add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
386 | - return; |
|
387 | - } |
|
388 | - // and pass the request object to the run method |
|
389 | - $this->Registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
390 | - // fire the shortcode class's run method, so that it can activate resources |
|
391 | - $this->Registry->shortcodes->{$shortcode_class}->run($WP); |
|
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
398 | - * |
|
399 | - * @access public |
|
400 | - * @param WP_Query $WP_Query |
|
401 | - * @return void |
|
402 | - */ |
|
403 | - public function pre_get_posts($WP_Query) |
|
404 | - { |
|
405 | - // only load Module_Request_Router if this is the main query |
|
406 | - if ( |
|
407 | - $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
408 | - && $WP_Query->is_main_query() |
|
409 | - ) { |
|
410 | - // cycle thru module routes |
|
411 | - while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
412 | - // determine module and method for route |
|
413 | - $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
414 | - if ($module instanceof EED_Module) { |
|
415 | - // get registered view for route |
|
416 | - $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
417 | - // grab module name |
|
418 | - $module_name = $module->module_name(); |
|
419 | - // map the module to the module objects |
|
420 | - $this->Registry->modules->{$module_name} = $module; |
|
421 | - } |
|
422 | - } |
|
423 | - } |
|
424 | - } |
|
425 | - |
|
426 | - |
|
427 | - |
|
428 | - |
|
429 | - |
|
430 | - /*********************************************** WP HOOK ***********************************************/ |
|
431 | - |
|
432 | - |
|
433 | - /** |
|
434 | - * wp - basically last chance to do stuff before headers sent |
|
435 | - * |
|
436 | - * @access public |
|
437 | - * @return void |
|
438 | - */ |
|
439 | - public function wp() |
|
440 | - { |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - |
|
445 | - /*********************************************** WP_ENQUEUE_SCRIPTS && WP_HEAD HOOK ***********************************************/ |
|
446 | - |
|
447 | - |
|
448 | - /** |
|
449 | - * wp_enqueue_scripts |
|
450 | - * |
|
451 | - * @access public |
|
452 | - * @return void |
|
453 | - */ |
|
454 | - public function wp_enqueue_scripts() |
|
455 | - { |
|
456 | - |
|
457 | - // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
|
458 | - if (apply_filters('FHEE_load_css', true)) { |
|
459 | - |
|
460 | - $this->Registry->CFG->template_settings->enable_default_style = true; |
|
461 | - //Load the ThemeRoller styles if enabled |
|
462 | - if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
|
463 | - |
|
464 | - //Load custom style sheet if available |
|
465 | - if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
|
466 | - wp_register_style('espresso_custom_css', |
|
467 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
|
468 | - EVENT_ESPRESSO_VERSION); |
|
469 | - wp_enqueue_style('espresso_custom_css'); |
|
470 | - } |
|
471 | - |
|
472 | - if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
|
473 | - wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
|
474 | - array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
475 | - } else { |
|
476 | - wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
477 | - array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
478 | - } |
|
479 | - wp_enqueue_style('espresso_default'); |
|
480 | - |
|
481 | - if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
|
482 | - wp_register_style('espresso_style', |
|
483 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
|
484 | - array('dashicons', 'espresso_default')); |
|
485 | - } else { |
|
486 | - wp_register_style('espresso_style', |
|
487 | - EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
|
488 | - array('dashicons', 'espresso_default')); |
|
489 | - } |
|
490 | - |
|
491 | - } |
|
492 | - |
|
493 | - } |
|
494 | - |
|
495 | - // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
|
496 | - if (apply_filters('FHEE_load_js', true)) { |
|
497 | - |
|
498 | - wp_enqueue_script('jquery'); |
|
499 | - //let's make sure that all required scripts have been setup |
|
500 | - if (function_exists('wp_script_is') && ! wp_script_is('jquery')) { |
|
501 | - $msg = sprintf( |
|
502 | - __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', |
|
503 | - 'event_espresso'), |
|
504 | - '<em><br />', |
|
505 | - '</em>' |
|
506 | - ); |
|
507 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
508 | - } |
|
509 | - // load core js |
|
510 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
|
511 | - EVENT_ESPRESSO_VERSION, true); |
|
512 | - wp_enqueue_script('espresso_core'); |
|
513 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
514 | - |
|
515 | - } |
|
516 | - |
|
517 | - //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
518 | - if (apply_filters('FHEE_load_qtip', false)) { |
|
519 | - EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - //accounting.js library |
|
524 | - // @link http://josscrowcroft.github.io/accounting.js/ |
|
525 | - if (apply_filters('FHEE_load_accounting_js', false)) { |
|
526 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
527 | - wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
528 | - array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
|
529 | - wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
|
530 | - wp_enqueue_script('ee-accounting'); |
|
531 | - |
|
532 | - $currency_config = array( |
|
533 | - 'currency' => array( |
|
534 | - 'symbol' => $this->Registry->CFG->currency->sign, |
|
535 | - 'format' => array( |
|
536 | - 'pos' => $this->Registry->CFG->currency->sign_b4 ? '%s%v' : '%v%s', |
|
537 | - 'neg' => $this->Registry->CFG->currency->sign_b4 ? '- %s%v' : '- %v%s', |
|
538 | - 'zero' => $this->Registry->CFG->currency->sign_b4 ? '%s--' : '--%s', |
|
539 | - ), |
|
540 | - 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
541 | - 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
542 | - 'precision' => $this->Registry->CFG->currency->dec_plc, |
|
543 | - ), |
|
544 | - 'number' => array( |
|
545 | - 'precision' => 0, |
|
546 | - 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
547 | - 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
548 | - ), |
|
549 | - ); |
|
550 | - wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
|
551 | - } |
|
552 | - |
|
553 | - if ( ! function_exists('wp_head')) { |
|
554 | - $msg = sprintf( |
|
555 | - __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
556 | - 'event_espresso'), |
|
557 | - '<em><br />', |
|
558 | - '</em>' |
|
559 | - ); |
|
560 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
561 | - } |
|
562 | - if ( ! function_exists('wp_footer')) { |
|
563 | - $msg = sprintf( |
|
564 | - __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
565 | - 'event_espresso'), |
|
566 | - '<em><br />', |
|
567 | - '</em>' |
|
568 | - ); |
|
569 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
570 | - } |
|
571 | - |
|
572 | - } |
|
573 | - |
|
574 | - |
|
575 | - /** |
|
576 | - * header_meta_tag |
|
577 | - * |
|
578 | - * @access public |
|
579 | - * @return void |
|
580 | - */ |
|
581 | - public function header_meta_tag() |
|
582 | - { |
|
583 | - print( |
|
584 | - apply_filters( |
|
585 | - 'FHEE__EE_Front_Controller__header_meta_tag', |
|
586 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
587 | - ); |
|
588 | - |
|
589 | - //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
590 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
591 | - if ( |
|
592 | - is_tax('espresso_event_type') |
|
593 | - && get_option( 'blog_public' ) !== '0' |
|
594 | - ) { |
|
595 | - print( |
|
596 | - apply_filters( |
|
597 | - 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
598 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
599 | - ) |
|
600 | - ); |
|
601 | - } |
|
602 | - } |
|
603 | - |
|
604 | - |
|
605 | - |
|
606 | - |
|
607 | - /*********************************************** THE_CONTENT FILTER HOOK ***********************************************/ |
|
608 | - /** |
|
609 | - * the_content |
|
610 | - * |
|
611 | - * @access public |
|
612 | - * @param $the_content |
|
613 | - * @return string |
|
614 | - */ |
|
615 | - // public function the_content( $the_content ) { |
|
616 | - // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
617 | - // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
618 | - // } |
|
619 | - // return $the_content; |
|
620 | - // } |
|
621 | - |
|
622 | - |
|
623 | - /*********************************************** WP_FOOTER ***********************************************/ |
|
624 | - |
|
625 | - |
|
626 | - /** |
|
627 | - * display_errors |
|
628 | - * |
|
629 | - * @access public |
|
630 | - * @return string |
|
631 | - */ |
|
632 | - public function display_errors() |
|
633 | - { |
|
634 | - static $shown_already = false; |
|
635 | - do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
636 | - if ( |
|
637 | - ! $shown_already |
|
638 | - && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
639 | - && is_main_query() |
|
640 | - && ! is_feed() |
|
641 | - && in_the_loop() |
|
642 | - && $this->Request_Handler->is_espresso_page() |
|
643 | - ) { |
|
644 | - echo EE_Error::get_notices(); |
|
645 | - $shown_already = true; |
|
646 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
647 | - } |
|
648 | - do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
649 | - } |
|
650 | - |
|
651 | - |
|
652 | - |
|
653 | - |
|
654 | - |
|
655 | - /*********************************************** UTILITIES ***********************************************/ |
|
656 | - /** |
|
657 | - * template_include |
|
658 | - * |
|
659 | - * @access public |
|
660 | - * @param string $template_include_path |
|
661 | - * @return string |
|
662 | - */ |
|
663 | - public function template_include($template_include_path = null) |
|
664 | - { |
|
665 | - if ($this->Request_Handler->is_espresso_page()) { |
|
666 | - $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
667 | - $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
668 | - $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
669 | - $this->_template = basename($this->_template_path); |
|
670 | - return $this->_template_path; |
|
671 | - } |
|
672 | - return $template_include_path; |
|
673 | - } |
|
674 | - |
|
675 | - |
|
676 | - /** |
|
677 | - * get_selected_template |
|
678 | - * |
|
679 | - * @access public |
|
680 | - * @param bool $with_path |
|
681 | - * @return string |
|
682 | - */ |
|
683 | - public function get_selected_template($with_path = false) |
|
684 | - { |
|
685 | - return $with_path ? $this->_template_path : $this->_template; |
|
686 | - } |
|
25 | + /** |
|
26 | + * $_template_path |
|
27 | + * @var string $_template_path |
|
28 | + * @access public |
|
29 | + */ |
|
30 | + private $_template_path; |
|
31 | + |
|
32 | + /** |
|
33 | + * $_template |
|
34 | + * @var string $_template |
|
35 | + * @access public |
|
36 | + */ |
|
37 | + private $_template; |
|
38 | + |
|
39 | + /** |
|
40 | + * @type EE_Registry $Registry |
|
41 | + * @access protected |
|
42 | + */ |
|
43 | + protected $Registry; |
|
44 | + |
|
45 | + /** |
|
46 | + * @type EE_Request_Handler $Request_Handler |
|
47 | + * @access protected |
|
48 | + */ |
|
49 | + protected $Request_Handler; |
|
50 | + |
|
51 | + /** |
|
52 | + * @type EE_Module_Request_Router $Module_Request_Router |
|
53 | + * @access protected |
|
54 | + */ |
|
55 | + protected $Module_Request_Router; |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * class constructor |
|
60 | + * should fire after shortcode, module, addon, or other plugin's default priority init phases have run |
|
61 | + * |
|
62 | + * @access public |
|
63 | + * @param \EE_Registry $Registry |
|
64 | + * @param \EE_Request_Handler $Request_Handler |
|
65 | + * @param \EE_Module_Request_Router $Module_Request_Router |
|
66 | + */ |
|
67 | + public function __construct( |
|
68 | + EE_Registry $Registry, |
|
69 | + EE_Request_Handler $Request_Handler, |
|
70 | + EE_Module_Request_Router $Module_Request_Router |
|
71 | + ) { |
|
72 | + $this->Registry = $Registry; |
|
73 | + $this->Request_Handler = $Request_Handler; |
|
74 | + $this->Module_Request_Router = $Module_Request_Router; |
|
75 | + // make sure template tags are loaded immediately so that themes don't break |
|
76 | + add_action('AHEE__EE_System__core_loaded_and_ready', array($this, 'load_espresso_template_tags'), 10); |
|
77 | + // determine how to integrate WP_Query with the EE models |
|
78 | + add_action('AHEE__EE_System__initialize', array($this, 'employ_CPT_Strategy')); |
|
79 | + // load other resources and begin to actually run shortcodes and modules |
|
80 | + add_action('wp_loaded', array($this, 'wp_loaded'), 5); |
|
81 | + // analyse the incoming WP request |
|
82 | + add_action('parse_request', array($this, 'get_request'), 1, 1); |
|
83 | + // process any content shortcodes |
|
84 | + add_action('parse_request', array($this, '_initialize_shortcodes'), 5); |
|
85 | + // process request with module factory |
|
86 | + add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1); |
|
87 | + // before headers sent |
|
88 | + add_action('wp', array($this, 'wp'), 5); |
|
89 | + // load css and js |
|
90 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 1); |
|
91 | + // header |
|
92 | + add_action('wp_head', array($this, 'header_meta_tag'), 5); |
|
93 | + add_filter('template_include', array($this, 'template_include'), 1); |
|
94 | + // display errors |
|
95 | + add_action('loop_start', array($this, 'display_errors'), 2); |
|
96 | + // the content |
|
97 | + // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 ); |
|
98 | + //exclude our private cpt comments |
|
99 | + add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1); |
|
100 | + //make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://) |
|
101 | + add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1); |
|
102 | + // action hook EE |
|
103 | + do_action('AHEE__EE_Front_Controller__construct__done', $this); |
|
104 | + // for checking that browser cookies are enabled |
|
105 | + if (apply_filters('FHEE__EE_Front_Controller____construct__set_test_cookie', true)) { |
|
106 | + setcookie('ee_cookie_test', uniqid(), time() + 24 * HOUR_IN_SECONDS, '/'); |
|
107 | + } |
|
108 | + } |
|
109 | + |
|
110 | + |
|
111 | + /** |
|
112 | + * @return EE_Request_Handler |
|
113 | + */ |
|
114 | + public function Request_Handler() |
|
115 | + { |
|
116 | + return $this->Request_Handler; |
|
117 | + } |
|
118 | + |
|
119 | + |
|
120 | + /** |
|
121 | + * @return EE_Module_Request_Router |
|
122 | + */ |
|
123 | + public function Module_Request_Router() |
|
124 | + { |
|
125 | + return $this->Module_Request_Router; |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + |
|
131 | + |
|
132 | + /*********************************************** INIT ACTION HOOK ***********************************************/ |
|
133 | + |
|
134 | + |
|
135 | + /** |
|
136 | + * load_espresso_template_tags - if current theme is an espresso theme, or uses ee theme template parts, then |
|
137 | + * load it's functions.php file ( if not already loaded ) |
|
138 | + * |
|
139 | + * @return void |
|
140 | + */ |
|
141 | + public function load_espresso_template_tags() |
|
142 | + { |
|
143 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
144 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
145 | + } |
|
146 | + } |
|
147 | + |
|
148 | + |
|
149 | + /** |
|
150 | + * filter_wp_comments |
|
151 | + * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment |
|
152 | + * widgets/queries done on frontend |
|
153 | + * |
|
154 | + * @param array $clauses array of comment clauses setup by WP_Comment_Query |
|
155 | + * @return array array of comment clauses with modifications. |
|
156 | + */ |
|
157 | + public function filter_wp_comments($clauses) |
|
158 | + { |
|
159 | + global $wpdb; |
|
160 | + if (strpos($clauses['join'], $wpdb->posts) !== false) { |
|
161 | + $cpts = EE_Register_CPTs::get_private_CPTs(); |
|
162 | + foreach ($cpts as $cpt => $details) { |
|
163 | + $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt); |
|
164 | + } |
|
165 | + } |
|
166 | + return $clauses; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * employ_CPT_Strategy |
|
172 | + * |
|
173 | + * @access public |
|
174 | + * @return void |
|
175 | + */ |
|
176 | + public function employ_CPT_Strategy() |
|
177 | + { |
|
178 | + if (apply_filters('FHEE__EE_Front_Controller__employ_CPT_Strategy', true)) { |
|
179 | + $this->Registry->load_core('CPT_Strategy'); |
|
180 | + } |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend |
|
186 | + * |
|
187 | + * @param string $url incoming url |
|
188 | + * @return string final assembled url |
|
189 | + */ |
|
190 | + public function maybe_force_admin_ajax_ssl($url) |
|
191 | + { |
|
192 | + if (is_ssl() && preg_match('/admin-ajax.php/', $url)) { |
|
193 | + $url = str_replace('http://', 'https://', $url); |
|
194 | + } |
|
195 | + return $url; |
|
196 | + } |
|
197 | + |
|
198 | + |
|
199 | + |
|
200 | + |
|
201 | + |
|
202 | + |
|
203 | + /*********************************************** WP_LOADED ACTION HOOK ***********************************************/ |
|
204 | + |
|
205 | + |
|
206 | + /** |
|
207 | + * wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their |
|
208 | + * default priority init phases have run |
|
209 | + * |
|
210 | + * @access public |
|
211 | + * @return void |
|
212 | + */ |
|
213 | + public function wp_loaded() |
|
214 | + { |
|
215 | + } |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + |
|
220 | + |
|
221 | + /*********************************************** PARSE_REQUEST HOOK ***********************************************/ |
|
222 | + /** |
|
223 | + * _get_request |
|
224 | + * |
|
225 | + * @access public |
|
226 | + * @param WP $WP |
|
227 | + * @return void |
|
228 | + */ |
|
229 | + public function get_request(WP $WP) |
|
230 | + { |
|
231 | + do_action('AHEE__EE_Front_Controller__get_request__start'); |
|
232 | + $this->Request_Handler->parse_request($WP); |
|
233 | + do_action('AHEE__EE_Front_Controller__get_request__complete'); |
|
234 | + } |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * _initialize_shortcodes - calls init method on shortcodes that have been determined to be in the_content for |
|
239 | + * the currently requested page |
|
240 | + * |
|
241 | + * @access public |
|
242 | + * @param WP $WP |
|
243 | + * @return void |
|
244 | + */ |
|
245 | + public function _initialize_shortcodes(WP $WP) |
|
246 | + { |
|
247 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__begin', $WP, $this); |
|
248 | + $this->Request_Handler->set_request_vars($WP); |
|
249 | + // grab post_name from request |
|
250 | + $current_post = apply_filters('FHEE__EE_Front_Controller__initialize_shortcodes__current_post_name', |
|
251 | + $this->Request_Handler->get('post_name')); |
|
252 | + $show_on_front = get_option('show_on_front'); |
|
253 | + // if it's not set, then check if frontpage is blog |
|
254 | + if (empty($current_post)) { |
|
255 | + // yup.. this is the posts page, prepare to load all shortcode modules |
|
256 | + $current_post = 'posts'; |
|
257 | + // unless.. |
|
258 | + if ($show_on_front === 'page') { |
|
259 | + // some other page is set as the homepage |
|
260 | + $page_on_front = get_option('page_on_front'); |
|
261 | + if ($page_on_front) { |
|
262 | + // k now we need to find the post_name for this page |
|
263 | + global $wpdb; |
|
264 | + $page_on_front = $wpdb->get_var( |
|
265 | + $wpdb->prepare( |
|
266 | + "SELECT post_name from $wpdb->posts WHERE post_type='page' AND post_status='publish' AND ID=%d", |
|
267 | + $page_on_front |
|
268 | + ) |
|
269 | + ); |
|
270 | + // set the current post slug to what it actually is |
|
271 | + $current_post = $page_on_front ? $page_on_front : $current_post; |
|
272 | + } |
|
273 | + } |
|
274 | + } |
|
275 | + // where are posts being displayed ? |
|
276 | + $page_for_posts = EE_Config::get_page_for_posts(); |
|
277 | + // in case $current_post is hierarchical like: /parent-page/current-page |
|
278 | + $current_post = basename($current_post); |
|
279 | + // are we on a category page? |
|
280 | + $term_exists = is_array(term_exists($current_post, 'category')) || array_key_exists('category_name', |
|
281 | + $WP->query_vars); |
|
282 | + // make sure shortcodes are set |
|
283 | + if (isset($this->Registry->CFG->core->post_shortcodes)) { |
|
284 | + if ( ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts])) { |
|
285 | + $this->Registry->CFG->core->post_shortcodes[$page_for_posts] = array(); |
|
286 | + } |
|
287 | + // cycle thru all posts with shortcodes set |
|
288 | + foreach ($this->Registry->CFG->core->post_shortcodes as $post_name => $post_shortcodes) { |
|
289 | + // filter shortcodes so |
|
290 | + $post_shortcodes = apply_filters('FHEE__Front_Controller__initialize_shortcodes__post_shortcodes', |
|
291 | + $post_shortcodes); |
|
292 | + // now cycle thru shortcodes |
|
293 | + foreach ($post_shortcodes as $shortcode_class => $post_id) { |
|
294 | + // are we on this page, or on the blog page, or an EE CPT category page ? |
|
295 | + if ($current_post === $post_name || $term_exists) { |
|
296 | + // maybe init the shortcode |
|
297 | + $this->initialize_shortcode_if_active_on_page( |
|
298 | + $shortcode_class, |
|
299 | + $current_post, |
|
300 | + $page_for_posts, |
|
301 | + $post_id, |
|
302 | + $term_exists, |
|
303 | + $WP |
|
304 | + ); |
|
305 | + // if this is NOT the "Posts page" and we have a valid entry |
|
306 | + // for the "Posts page" in our tracked post_shortcodes array |
|
307 | + // but the shortcode is not being tracked for this page |
|
308 | + } else if ( |
|
309 | + $post_name !== $page_for_posts |
|
310 | + && isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts]) |
|
311 | + && ! isset($this->Registry->CFG->core->post_shortcodes[$page_for_posts][$shortcode_class]) |
|
312 | + ) { |
|
313 | + // then remove the "fallback" shortcode processor |
|
314 | + remove_shortcode($shortcode_class); |
|
315 | + } |
|
316 | + } |
|
317 | + } |
|
318 | + } |
|
319 | + do_action('AHEE__EE_Front_Controller__initialize_shortcodes__end', $this); |
|
320 | + } |
|
321 | + |
|
322 | + |
|
323 | + /** |
|
324 | + * @param string $shortcode_class |
|
325 | + * @param string $current_post |
|
326 | + * @param string $page_for_posts |
|
327 | + * @param int $post_id |
|
328 | + * @param bool $term_exists |
|
329 | + * @param WP $WP |
|
330 | + */ |
|
331 | + protected function initialize_shortcode_if_active_on_page( |
|
332 | + $shortcode_class, |
|
333 | + $current_post, |
|
334 | + $page_for_posts, |
|
335 | + $post_id, |
|
336 | + $term_exists, |
|
337 | + $WP |
|
338 | + ) { |
|
339 | + // verify shortcode is in list of registered shortcodes |
|
340 | + if ( ! isset($this->Registry->shortcodes->{$shortcode_class})) { |
|
341 | + if ($current_post !== $page_for_posts && current_user_can('edit_post', $post_id)) { |
|
342 | + EE_Error::add_error( |
|
343 | + sprintf( |
|
344 | + __( |
|
345 | + 'The [%s] shortcode has not been properly registered or the corresponding addon/module is not active for some reason. Either fix/remove the shortcode from the post, or activate the addon/module the shortcode is associated with.', |
|
346 | + 'event_espresso' |
|
347 | + ), |
|
348 | + $shortcode_class |
|
349 | + ), |
|
350 | + __FILE__, |
|
351 | + __FUNCTION__, |
|
352 | + __LINE__ |
|
353 | + ); |
|
354 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
355 | + } |
|
356 | + add_shortcode($shortcode_class, array('EES_Shortcode', 'invalid_shortcode_processor')); |
|
357 | + return; |
|
358 | + } |
|
359 | + // is this : a shortcodes set exclusively for this post, or for the home page, or a category, or a taxonomy ? |
|
360 | + if ( |
|
361 | + $term_exists |
|
362 | + || $current_post === $page_for_posts |
|
363 | + || isset($this->Registry->CFG->core->post_shortcodes[$current_post]) |
|
364 | + ) { |
|
365 | + // let's pause to reflect on this... |
|
366 | + $sc_reflector = new ReflectionClass('EES_' . $shortcode_class); |
|
367 | + // ensure that class is actually a shortcode |
|
368 | + if ( |
|
369 | + defined('WP_DEBUG') |
|
370 | + && WP_DEBUG === true |
|
371 | + && ! $sc_reflector->isSubclassOf('EES_Shortcode') |
|
372 | + ) { |
|
373 | + EE_Error::add_error( |
|
374 | + sprintf( |
|
375 | + __( |
|
376 | + 'The requested %s shortcode is not of the class "EES_Shortcode". Please check your files.', |
|
377 | + 'event_espresso' |
|
378 | + ), |
|
379 | + $shortcode_class |
|
380 | + ), |
|
381 | + __FILE__, |
|
382 | + __FUNCTION__, |
|
383 | + __LINE__ |
|
384 | + ); |
|
385 | + add_filter('FHEE_run_EE_the_content', '__return_true'); |
|
386 | + return; |
|
387 | + } |
|
388 | + // and pass the request object to the run method |
|
389 | + $this->Registry->shortcodes->{$shortcode_class} = $sc_reflector->newInstance(); |
|
390 | + // fire the shortcode class's run method, so that it can activate resources |
|
391 | + $this->Registry->shortcodes->{$shortcode_class}->run($WP); |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * pre_get_posts - basically a module factory for instantiating modules and selecting the final view template |
|
398 | + * |
|
399 | + * @access public |
|
400 | + * @param WP_Query $WP_Query |
|
401 | + * @return void |
|
402 | + */ |
|
403 | + public function pre_get_posts($WP_Query) |
|
404 | + { |
|
405 | + // only load Module_Request_Router if this is the main query |
|
406 | + if ( |
|
407 | + $this->Module_Request_Router instanceof EE_Module_Request_Router |
|
408 | + && $WP_Query->is_main_query() |
|
409 | + ) { |
|
410 | + // cycle thru module routes |
|
411 | + while ($route = $this->Module_Request_Router->get_route($WP_Query)) { |
|
412 | + // determine module and method for route |
|
413 | + $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]); |
|
414 | + if ($module instanceof EED_Module) { |
|
415 | + // get registered view for route |
|
416 | + $this->_template_path = $this->Module_Request_Router->get_view($route); |
|
417 | + // grab module name |
|
418 | + $module_name = $module->module_name(); |
|
419 | + // map the module to the module objects |
|
420 | + $this->Registry->modules->{$module_name} = $module; |
|
421 | + } |
|
422 | + } |
|
423 | + } |
|
424 | + } |
|
425 | + |
|
426 | + |
|
427 | + |
|
428 | + |
|
429 | + |
|
430 | + /*********************************************** WP HOOK ***********************************************/ |
|
431 | + |
|
432 | + |
|
433 | + /** |
|
434 | + * wp - basically last chance to do stuff before headers sent |
|
435 | + * |
|
436 | + * @access public |
|
437 | + * @return void |
|
438 | + */ |
|
439 | + public function wp() |
|
440 | + { |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + |
|
445 | + /*********************************************** WP_ENQUEUE_SCRIPTS && WP_HEAD HOOK ***********************************************/ |
|
446 | + |
|
447 | + |
|
448 | + /** |
|
449 | + * wp_enqueue_scripts |
|
450 | + * |
|
451 | + * @access public |
|
452 | + * @return void |
|
453 | + */ |
|
454 | + public function wp_enqueue_scripts() |
|
455 | + { |
|
456 | + |
|
457 | + // css is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_css', '__return_false' ); |
|
458 | + if (apply_filters('FHEE_load_css', true)) { |
|
459 | + |
|
460 | + $this->Registry->CFG->template_settings->enable_default_style = true; |
|
461 | + //Load the ThemeRoller styles if enabled |
|
462 | + if (isset($this->Registry->CFG->template_settings->enable_default_style) && $this->Registry->CFG->template_settings->enable_default_style) { |
|
463 | + |
|
464 | + //Load custom style sheet if available |
|
465 | + if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
|
466 | + wp_register_style('espresso_custom_css', |
|
467 | + EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
|
468 | + EVENT_ESPRESSO_VERSION); |
|
469 | + wp_enqueue_style('espresso_custom_css'); |
|
470 | + } |
|
471 | + |
|
472 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
|
473 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
|
474 | + array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
475 | + } else { |
|
476 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
477 | + array('dashicons'), EVENT_ESPRESSO_VERSION); |
|
478 | + } |
|
479 | + wp_enqueue_style('espresso_default'); |
|
480 | + |
|
481 | + if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
|
482 | + wp_register_style('espresso_style', |
|
483 | + get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
|
484 | + array('dashicons', 'espresso_default')); |
|
485 | + } else { |
|
486 | + wp_register_style('espresso_style', |
|
487 | + EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
|
488 | + array('dashicons', 'espresso_default')); |
|
489 | + } |
|
490 | + |
|
491 | + } |
|
492 | + |
|
493 | + } |
|
494 | + |
|
495 | + // js is turned ON by default, but prior to the wp_enqueue_scripts hook, can be turned OFF via: add_filter( 'FHEE_load_js', '__return_false' ); |
|
496 | + if (apply_filters('FHEE_load_js', true)) { |
|
497 | + |
|
498 | + wp_enqueue_script('jquery'); |
|
499 | + //let's make sure that all required scripts have been setup |
|
500 | + if (function_exists('wp_script_is') && ! wp_script_is('jquery')) { |
|
501 | + $msg = sprintf( |
|
502 | + __('%sJquery is not loaded!%sEvent Espresso is unable to load Jquery due to a conflict with your theme or another plugin.', |
|
503 | + 'event_espresso'), |
|
504 | + '<em><br />', |
|
505 | + '</em>' |
|
506 | + ); |
|
507 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
508 | + } |
|
509 | + // load core js |
|
510 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
|
511 | + EVENT_ESPRESSO_VERSION, true); |
|
512 | + wp_enqueue_script('espresso_core'); |
|
513 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
514 | + |
|
515 | + } |
|
516 | + |
|
517 | + //qtip is turned OFF by default, but prior to the wp_enqueue_scripts hook, can be turned back on again via: add_filter('FHEE_load_qtip', '__return_true' ); |
|
518 | + if (apply_filters('FHEE_load_qtip', false)) { |
|
519 | + EEH_Qtip_Loader::instance()->register_and_enqueue(); |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + //accounting.js library |
|
524 | + // @link http://josscrowcroft.github.io/accounting.js/ |
|
525 | + if (apply_filters('FHEE_load_accounting_js', false)) { |
|
526 | + $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
527 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
528 | + array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
|
529 | + wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
|
530 | + wp_enqueue_script('ee-accounting'); |
|
531 | + |
|
532 | + $currency_config = array( |
|
533 | + 'currency' => array( |
|
534 | + 'symbol' => $this->Registry->CFG->currency->sign, |
|
535 | + 'format' => array( |
|
536 | + 'pos' => $this->Registry->CFG->currency->sign_b4 ? '%s%v' : '%v%s', |
|
537 | + 'neg' => $this->Registry->CFG->currency->sign_b4 ? '- %s%v' : '- %v%s', |
|
538 | + 'zero' => $this->Registry->CFG->currency->sign_b4 ? '%s--' : '--%s', |
|
539 | + ), |
|
540 | + 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
541 | + 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
542 | + 'precision' => $this->Registry->CFG->currency->dec_plc, |
|
543 | + ), |
|
544 | + 'number' => array( |
|
545 | + 'precision' => 0, |
|
546 | + 'thousand' => $this->Registry->CFG->currency->thsnds, |
|
547 | + 'decimal' => $this->Registry->CFG->currency->dec_mrk, |
|
548 | + ), |
|
549 | + ); |
|
550 | + wp_localize_script('ee-accounting', 'EE_ACCOUNTING_CFG', $currency_config); |
|
551 | + } |
|
552 | + |
|
553 | + if ( ! function_exists('wp_head')) { |
|
554 | + $msg = sprintf( |
|
555 | + __('%sMissing wp_head() function.%sThe WordPress function wp_head() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
556 | + 'event_espresso'), |
|
557 | + '<em><br />', |
|
558 | + '</em>' |
|
559 | + ); |
|
560 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
561 | + } |
|
562 | + if ( ! function_exists('wp_footer')) { |
|
563 | + $msg = sprintf( |
|
564 | + __('%sMissing wp_footer() function.%sThe WordPress function wp_footer() seems to be missing in your theme. Please contact the theme developer to make sure this is fixed before using Event Espresso.', |
|
565 | + 'event_espresso'), |
|
566 | + '<em><br />', |
|
567 | + '</em>' |
|
568 | + ); |
|
569 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
570 | + } |
|
571 | + |
|
572 | + } |
|
573 | + |
|
574 | + |
|
575 | + /** |
|
576 | + * header_meta_tag |
|
577 | + * |
|
578 | + * @access public |
|
579 | + * @return void |
|
580 | + */ |
|
581 | + public function header_meta_tag() |
|
582 | + { |
|
583 | + print( |
|
584 | + apply_filters( |
|
585 | + 'FHEE__EE_Front_Controller__header_meta_tag', |
|
586 | + '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
587 | + ); |
|
588 | + |
|
589 | + //let's exclude all event type taxonomy term archive pages from search engine indexing |
|
590 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
|
591 | + if ( |
|
592 | + is_tax('espresso_event_type') |
|
593 | + && get_option( 'blog_public' ) !== '0' |
|
594 | + ) { |
|
595 | + print( |
|
596 | + apply_filters( |
|
597 | + 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
|
598 | + '<meta name="robots" content="noindex,follow" />' . "\n" |
|
599 | + ) |
|
600 | + ); |
|
601 | + } |
|
602 | + } |
|
603 | + |
|
604 | + |
|
605 | + |
|
606 | + |
|
607 | + /*********************************************** THE_CONTENT FILTER HOOK ***********************************************/ |
|
608 | + /** |
|
609 | + * the_content |
|
610 | + * |
|
611 | + * @access public |
|
612 | + * @param $the_content |
|
613 | + * @return string |
|
614 | + */ |
|
615 | + // public function the_content( $the_content ) { |
|
616 | + // // nothing gets loaded at this point unless other systems turn this hookpoint on by using: add_filter( 'FHEE_run_EE_the_content', '__return_true' ); |
|
617 | + // if ( apply_filters( 'FHEE_run_EE_the_content', FALSE ) ) { |
|
618 | + // } |
|
619 | + // return $the_content; |
|
620 | + // } |
|
621 | + |
|
622 | + |
|
623 | + /*********************************************** WP_FOOTER ***********************************************/ |
|
624 | + |
|
625 | + |
|
626 | + /** |
|
627 | + * display_errors |
|
628 | + * |
|
629 | + * @access public |
|
630 | + * @return string |
|
631 | + */ |
|
632 | + public function display_errors() |
|
633 | + { |
|
634 | + static $shown_already = false; |
|
635 | + do_action('AHEE__EE_Front_Controller__display_errors__begin'); |
|
636 | + if ( |
|
637 | + ! $shown_already |
|
638 | + && apply_filters('FHEE__EE_Front_Controller__display_errors', true) |
|
639 | + && is_main_query() |
|
640 | + && ! is_feed() |
|
641 | + && in_the_loop() |
|
642 | + && $this->Request_Handler->is_espresso_page() |
|
643 | + ) { |
|
644 | + echo EE_Error::get_notices(); |
|
645 | + $shown_already = true; |
|
646 | + EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
647 | + } |
|
648 | + do_action('AHEE__EE_Front_Controller__display_errors__end'); |
|
649 | + } |
|
650 | + |
|
651 | + |
|
652 | + |
|
653 | + |
|
654 | + |
|
655 | + /*********************************************** UTILITIES ***********************************************/ |
|
656 | + /** |
|
657 | + * template_include |
|
658 | + * |
|
659 | + * @access public |
|
660 | + * @param string $template_include_path |
|
661 | + * @return string |
|
662 | + */ |
|
663 | + public function template_include($template_include_path = null) |
|
664 | + { |
|
665 | + if ($this->Request_Handler->is_espresso_page()) { |
|
666 | + $this->_template_path = ! empty($this->_template_path) ? basename($this->_template_path) : basename($template_include_path); |
|
667 | + $template_path = EEH_Template::locate_template($this->_template_path, array(), false); |
|
668 | + $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path; |
|
669 | + $this->_template = basename($this->_template_path); |
|
670 | + return $this->_template_path; |
|
671 | + } |
|
672 | + return $template_include_path; |
|
673 | + } |
|
674 | + |
|
675 | + |
|
676 | + /** |
|
677 | + * get_selected_template |
|
678 | + * |
|
679 | + * @access public |
|
680 | + * @param bool $with_path |
|
681 | + * @return string |
|
682 | + */ |
|
683 | + public function get_selected_template($with_path = false) |
|
684 | + { |
|
685 | + return $with_path ? $this->_template_path : $this->_template; |
|
686 | + } |
|
687 | 687 | |
688 | 688 | |
689 | 689 | } |
@@ -140,8 +140,8 @@ discard block |
||
140 | 140 | */ |
141 | 141 | public function load_espresso_template_tags() |
142 | 142 | { |
143 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
144 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
143 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
144 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
145 | 145 | } |
146 | 146 | } |
147 | 147 | |
@@ -363,7 +363,7 @@ discard block |
||
363 | 363 | || isset($this->Registry->CFG->core->post_shortcodes[$current_post]) |
364 | 364 | ) { |
365 | 365 | // let's pause to reflect on this... |
366 | - $sc_reflector = new ReflectionClass('EES_' . $shortcode_class); |
|
366 | + $sc_reflector = new ReflectionClass('EES_'.$shortcode_class); |
|
367 | 367 | // ensure that class is actually a shortcode |
368 | 368 | if ( |
369 | 369 | defined('WP_DEBUG') |
@@ -464,27 +464,27 @@ discard block |
||
464 | 464 | //Load custom style sheet if available |
465 | 465 | if (isset($this->Registry->CFG->template_settings->custom_style_sheet)) { |
466 | 466 | wp_register_style('espresso_custom_css', |
467 | - EVENT_ESPRESSO_UPLOAD_URL . 'css/' . $this->Registry->CFG->template_settings->custom_style_sheet, |
|
467 | + EVENT_ESPRESSO_UPLOAD_URL.'css/'.$this->Registry->CFG->template_settings->custom_style_sheet, |
|
468 | 468 | EVENT_ESPRESSO_VERSION); |
469 | 469 | wp_enqueue_style('espresso_custom_css'); |
470 | 470 | } |
471 | 471 | |
472 | - if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR . 'css/style.css')) { |
|
473 | - wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR . 'css/espresso_default.css', |
|
472 | + if (is_readable(EVENT_ESPRESSO_UPLOAD_DIR.'css/style.css')) { |
|
473 | + wp_register_style('espresso_default', EVENT_ESPRESSO_UPLOAD_DIR.'css/espresso_default.css', |
|
474 | 474 | array('dashicons'), EVENT_ESPRESSO_VERSION); |
475 | 475 | } else { |
476 | - wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL . 'css/espresso_default.css', |
|
476 | + wp_register_style('espresso_default', EE_GLOBAL_ASSETS_URL.'css/espresso_default.css', |
|
477 | 477 | array('dashicons'), EVENT_ESPRESSO_VERSION); |
478 | 478 | } |
479 | 479 | wp_enqueue_style('espresso_default'); |
480 | 480 | |
481 | - if (is_readable(get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'style.css')) { |
|
481 | + if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'style.css')) { |
|
482 | 482 | wp_register_style('espresso_style', |
483 | - get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'style.css', |
|
483 | + get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'style.css', |
|
484 | 484 | array('dashicons', 'espresso_default')); |
485 | 485 | } else { |
486 | 486 | wp_register_style('espresso_style', |
487 | - EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'style.css', |
|
487 | + EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'style.css', |
|
488 | 488 | array('dashicons', 'espresso_default')); |
489 | 489 | } |
490 | 490 | |
@@ -507,7 +507,7 @@ discard block |
||
507 | 507 | EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
508 | 508 | } |
509 | 509 | // load core js |
510 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), |
|
510 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), |
|
511 | 511 | EVENT_ESPRESSO_VERSION, true); |
512 | 512 | wp_enqueue_script('espresso_core'); |
513 | 513 | wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | //accounting.js library |
524 | 524 | // @link http://josscrowcroft.github.io/accounting.js/ |
525 | 525 | if (apply_filters('FHEE_load_accounting_js', false)) { |
526 | - $acct_js = EE_THIRD_PARTY_URL . 'accounting/accounting.js'; |
|
527 | - wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL . 'scripts/ee-accounting-config.js', |
|
526 | + $acct_js = EE_THIRD_PARTY_URL.'accounting/accounting.js'; |
|
527 | + wp_register_script('ee-accounting', EE_GLOBAL_ASSETS_URL.'scripts/ee-accounting-config.js', |
|
528 | 528 | array('ee-accounting-core'), EVENT_ESPRESSO_VERSION, true); |
529 | 529 | wp_register_script('ee-accounting-core', $acct_js, array('underscore'), '0.3.2', true); |
530 | 530 | wp_enqueue_script('ee-accounting'); |
@@ -583,19 +583,19 @@ discard block |
||
583 | 583 | print( |
584 | 584 | apply_filters( |
585 | 585 | 'FHEE__EE_Front_Controller__header_meta_tag', |
586 | - '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n") |
|
586 | + '<meta name="generator" content="Event Espresso Version '.EVENT_ESPRESSO_VERSION."\" />\n") |
|
587 | 587 | ); |
588 | 588 | |
589 | 589 | //let's exclude all event type taxonomy term archive pages from search engine indexing |
590 | 590 | //@see https://events.codebasehq.com/projects/event-espresso/tickets/10249 |
591 | 591 | if ( |
592 | 592 | is_tax('espresso_event_type') |
593 | - && get_option( 'blog_public' ) !== '0' |
|
593 | + && get_option('blog_public') !== '0' |
|
594 | 594 | ) { |
595 | 595 | print( |
596 | 596 | apply_filters( |
597 | 597 | 'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type', |
598 | - '<meta name="robots" content="noindex,follow" />' . "\n" |
|
598 | + '<meta name="robots" content="noindex,follow" />'."\n" |
|
599 | 599 | ) |
600 | 600 | ); |
601 | 601 | } |
@@ -643,7 +643,7 @@ discard block |
||
643 | 643 | ) { |
644 | 644 | echo EE_Error::get_notices(); |
645 | 645 | $shown_already = true; |
646 | - EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php'); |
|
646 | + EEH_Template::display_template(EE_TEMPLATES.'espresso-ajax-notices.template.php'); |
|
647 | 647 | } |
648 | 648 | do_action('AHEE__EE_Front_Controller__display_errors__end'); |
649 | 649 | } |
@@ -473,7 +473,7 @@ discard block |
||
473 | 473 | $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
474 | 474 | $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
475 | 475 | global $ee_menu_slugs; |
476 | - $ee_menu_slugs = (array)$ee_menu_slugs; |
|
476 | + $ee_menu_slugs = (array) $ee_menu_slugs; |
|
477 | 477 | if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) { |
478 | 478 | return false; |
479 | 479 | } |
@@ -488,7 +488,7 @@ discard block |
||
488 | 488 | //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
489 | 489 | $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
490 | 490 | $this->_current_view = $this->_req_action; |
491 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
491 | + $this->_req_nonce = $this->_req_action.'_nonce'; |
|
492 | 492 | $this->_define_page_props(); |
493 | 493 | $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
494 | 494 | //default things |
@@ -509,11 +509,11 @@ discard block |
||
509 | 509 | $this->_extend_page_config_for_cpt(); |
510 | 510 | } |
511 | 511 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
512 | - $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this); |
|
513 | - $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this); |
|
512 | + $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this); |
|
513 | + $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this); |
|
514 | 514 | //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
515 | - if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) { |
|
516 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2); |
|
515 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) { |
|
516 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2); |
|
517 | 517 | } |
518 | 518 | //next route only if routing enabled |
519 | 519 | if ($this->_routing && ! defined('DOING_AJAX')) { |
@@ -523,8 +523,8 @@ discard block |
||
523 | 523 | if ($this->_is_UI_request) { |
524 | 524 | //admin_init stuff - global, all views for this page class, specific view |
525 | 525 | add_action('admin_init', array($this, 'admin_init'), 10); |
526 | - if (method_exists($this, 'admin_init_' . $this->_current_view)) { |
|
527 | - add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15); |
|
526 | + if (method_exists($this, 'admin_init_'.$this->_current_view)) { |
|
527 | + add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15); |
|
528 | 528 | } |
529 | 529 | } else { |
530 | 530 | //hijack regular WP loading and route admin request immediately |
@@ -544,7 +544,7 @@ discard block |
||
544 | 544 | */ |
545 | 545 | private function _do_other_page_hooks() |
546 | 546 | { |
547 | - $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array()); |
|
547 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array()); |
|
548 | 548 | foreach ($registered_pages as $page) { |
549 | 549 | //now let's setup the file name and class that should be present |
550 | 550 | $classname = str_replace('.class.php', '', $page); |
@@ -590,13 +590,13 @@ discard block |
||
590 | 590 | //load admin_notices - global, page class, and view specific |
591 | 591 | add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
592 | 592 | add_action('admin_notices', array($this, 'admin_notices'), 10); |
593 | - if (method_exists($this, 'admin_notices_' . $this->_current_view)) { |
|
594 | - add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15); |
|
593 | + if (method_exists($this, 'admin_notices_'.$this->_current_view)) { |
|
594 | + add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15); |
|
595 | 595 | } |
596 | 596 | //load network admin_notices - global, page class, and view specific |
597 | 597 | add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
598 | - if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) { |
|
599 | - add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view)); |
|
598 | + if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) { |
|
599 | + add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view)); |
|
600 | 600 | } |
601 | 601 | //this will save any per_page screen options if they are present |
602 | 602 | $this->_set_per_page_screen_options(); |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | //add screen options - global, page child class, and view specific |
609 | 609 | $this->_add_global_screen_options(); |
610 | 610 | $this->_add_screen_options(); |
611 | - if (method_exists($this, '_add_screen_options_' . $this->_current_view)) { |
|
612 | - call_user_func(array($this, '_add_screen_options_' . $this->_current_view)); |
|
611 | + if (method_exists($this, '_add_screen_options_'.$this->_current_view)) { |
|
612 | + call_user_func(array($this, '_add_screen_options_'.$this->_current_view)); |
|
613 | 613 | } |
614 | 614 | //add help tab(s) and tours- set via page_config and qtips. |
615 | 615 | $this->_add_help_tour(); |
@@ -618,31 +618,31 @@ discard block |
||
618 | 618 | //add feature_pointers - global, page child class, and view specific |
619 | 619 | $this->_add_feature_pointers(); |
620 | 620 | $this->_add_global_feature_pointers(); |
621 | - if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) { |
|
622 | - call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view)); |
|
621 | + if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) { |
|
622 | + call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view)); |
|
623 | 623 | } |
624 | 624 | //enqueue scripts/styles - global, page class, and view specific |
625 | 625 | add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
626 | 626 | add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
627 | - if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) { |
|
628 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15); |
|
627 | + if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) { |
|
628 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15); |
|
629 | 629 | } |
630 | 630 | add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
631 | 631 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
632 | 632 | add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
633 | 633 | add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
634 | - if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) { |
|
635 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101); |
|
634 | + if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) { |
|
635 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101); |
|
636 | 636 | } |
637 | 637 | //admin footer scripts |
638 | 638 | add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
639 | 639 | add_action('admin_footer', array($this, 'admin_footer'), 100); |
640 | - if (method_exists($this, 'admin_footer_' . $this->_current_view)) { |
|
641 | - add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101); |
|
640 | + if (method_exists($this, 'admin_footer_'.$this->_current_view)) { |
|
641 | + add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101); |
|
642 | 642 | } |
643 | 643 | do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
644 | 644 | //targeted hook |
645 | - do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action); |
|
645 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action); |
|
646 | 646 | } |
647 | 647 | |
648 | 648 | |
@@ -718,7 +718,7 @@ discard block |
||
718 | 718 | // user error msg |
719 | 719 | $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
720 | 720 | // developer error msg |
721 | - $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
721 | + $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
722 | 722 | throw new EE_Error($error_msg); |
723 | 723 | } |
724 | 724 | // and that the requested page route exists |
@@ -729,7 +729,7 @@ discard block |
||
729 | 729 | // user error msg |
730 | 730 | $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
731 | 731 | // developer error msg |
732 | - $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
732 | + $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
733 | 733 | throw new EE_Error($error_msg); |
734 | 734 | } |
735 | 735 | // and that a default route exists |
@@ -737,7 +737,7 @@ discard block |
||
737 | 737 | // user error msg |
738 | 738 | $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
739 | 739 | // developer error msg |
740 | - $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
740 | + $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
741 | 741 | throw new EE_Error($error_msg); |
742 | 742 | } |
743 | 743 | //first lets' catch if the UI request has EVER been set. |
@@ -766,7 +766,7 @@ discard block |
||
766 | 766 | // user error msg |
767 | 767 | $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
768 | 768 | // developer error msg |
769 | - $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
769 | + $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
770 | 770 | throw new EE_Error($error_msg); |
771 | 771 | } |
772 | 772 | } |
@@ -788,7 +788,7 @@ discard block |
||
788 | 788 | // these are not the droids you are looking for !!! |
789 | 789 | $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
790 | 790 | if (WP_DEBUG) { |
791 | - $msg .= "\n " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
791 | + $msg .= "\n ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
792 | 792 | } |
793 | 793 | if ( ! defined('DOING_AJAX')) { |
794 | 794 | wp_die($msg); |
@@ -963,7 +963,7 @@ discard block |
||
963 | 963 | if (strpos($key, 'nonce') !== false) { |
964 | 964 | continue; |
965 | 965 | } |
966 | - $args['wp_referer[' . $key . ']'] = $value; |
|
966 | + $args['wp_referer['.$key.']'] = $value; |
|
967 | 967 | } |
968 | 968 | } |
969 | 969 | return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
@@ -1009,7 +1009,7 @@ discard block |
||
1009 | 1009 | if ($tour instanceof EE_Help_Tour_final_stop) { |
1010 | 1010 | continue; |
1011 | 1011 | } |
1012 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
1012 | + $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>'; |
|
1013 | 1013 | } |
1014 | 1014 | $tour_buttons .= implode('<br />', $tb); |
1015 | 1015 | $tour_buttons .= '</div></div>'; |
@@ -1021,7 +1021,7 @@ discard block |
||
1021 | 1021 | throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', |
1022 | 1022 | 'event_espresso'), $config['help_sidebar'], get_class($this))); |
1023 | 1023 | } |
1024 | - $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
1024 | + $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
1025 | 1025 | $content .= $tour_buttons; //add help tour buttons. |
1026 | 1026 | //do we have any help tours setup? Cause if we do we want to add the buttons |
1027 | 1027 | $this->_current_screen->set_help_sidebar($content); |
@@ -1034,13 +1034,13 @@ discard block |
||
1034 | 1034 | if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
1035 | 1035 | $_ht['id'] = $this->page_slug; |
1036 | 1036 | $_ht['title'] = __('Help Tours', 'event_espresso'); |
1037 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
1037 | + $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>'; |
|
1038 | 1038 | $this->_current_screen->add_help_tab($_ht); |
1039 | 1039 | }/**/ |
1040 | 1040 | if ( ! isset($config['help_tabs'])) { |
1041 | 1041 | return; |
1042 | 1042 | } //no help tabs for this route |
1043 | - foreach ((array)$config['help_tabs'] as $tab_id => $cfg) { |
|
1043 | + foreach ((array) $config['help_tabs'] as $tab_id => $cfg) { |
|
1044 | 1044 | //we're here so there ARE help tabs! |
1045 | 1045 | //make sure we've got what we need |
1046 | 1046 | if ( ! isset($cfg['title'])) { |
@@ -1055,9 +1055,9 @@ discard block |
||
1055 | 1055 | $content = ! empty($cfg['content']) ? $cfg['content'] : null; |
1056 | 1056 | //second priority goes to filename |
1057 | 1057 | } else if ( ! empty($cfg['filename'])) { |
1058 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
1058 | + $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php'; |
|
1059 | 1059 | //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
1060 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
1060 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path; |
|
1061 | 1061 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
1062 | 1062 | if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
1063 | 1063 | EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', |
@@ -1076,7 +1076,7 @@ discard block |
||
1076 | 1076 | return; |
1077 | 1077 | } |
1078 | 1078 | //setup config array for help tab method |
1079 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
1079 | + $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id; |
|
1080 | 1080 | $_ht = array( |
1081 | 1081 | 'id' => $id, |
1082 | 1082 | 'title' => $cfg['title'], |
@@ -1114,9 +1114,9 @@ discard block |
||
1114 | 1114 | } |
1115 | 1115 | if (isset($config['help_tour'])) { |
1116 | 1116 | foreach ($config['help_tour'] as $tour) { |
1117 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
1117 | + $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php'; |
|
1118 | 1118 | //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
1119 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
1119 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path; |
|
1120 | 1120 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
1121 | 1121 | if ( ! is_readable($file_path)) { |
1122 | 1122 | EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), |
@@ -1126,7 +1126,7 @@ discard block |
||
1126 | 1126 | require_once $file_path; |
1127 | 1127 | if ( ! class_exists($tour)) { |
1128 | 1128 | $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
1129 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
1129 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
1130 | 1130 | 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
1131 | 1131 | throw new EE_Error(implode('||', $error_msg)); |
1132 | 1132 | } |
@@ -1158,11 +1158,11 @@ discard block |
||
1158 | 1158 | protected function _add_qtips() |
1159 | 1159 | { |
1160 | 1160 | if (isset($this->_route_config['qtips'])) { |
1161 | - $qtips = (array)$this->_route_config['qtips']; |
|
1161 | + $qtips = (array) $this->_route_config['qtips']; |
|
1162 | 1162 | //load qtip loader |
1163 | 1163 | $path = array( |
1164 | - $this->_get_dir() . '/qtips/', |
|
1165 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/', |
|
1164 | + $this->_get_dir().'/qtips/', |
|
1165 | + EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/', |
|
1166 | 1166 | ); |
1167 | 1167 | EEH_Qtip_Loader::instance()->register($qtips, $path); |
1168 | 1168 | } |
@@ -1192,11 +1192,11 @@ discard block |
||
1192 | 1192 | if ( ! $this->check_user_access($slug, true)) { |
1193 | 1193 | continue; |
1194 | 1194 | } //no nav tab becasue current user does not have access. |
1195 | - $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : ''; |
|
1195 | + $css_class = isset($config['css_class']) ? $config['css_class'].' ' : ''; |
|
1196 | 1196 | $this->_nav_tabs[$slug] = array( |
1197 | 1197 | 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url), |
1198 | 1198 | 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
1199 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
1199 | + 'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class, |
|
1200 | 1200 | 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i, |
1201 | 1201 | ); |
1202 | 1202 | $i++; |
@@ -1259,11 +1259,11 @@ discard block |
||
1259 | 1259 | $capability = empty($capability) ? 'manage_options' : $capability; |
1260 | 1260 | } |
1261 | 1261 | $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
1262 | - if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
1262 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
1263 | 1263 | if ($verify_only) { |
1264 | 1264 | return false; |
1265 | 1265 | } else { |
1266 | - if ( is_user_logged_in() ) { |
|
1266 | + if (is_user_logged_in()) { |
|
1267 | 1267 | wp_die(__('You do not have access to this route.', 'event_espresso')); |
1268 | 1268 | } else { |
1269 | 1269 | return false; |
@@ -1355,7 +1355,7 @@ discard block |
||
1355 | 1355 | public function admin_footer_global() |
1356 | 1356 | { |
1357 | 1357 | //dialog container for dialog helper |
1358 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
1358 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n"; |
|
1359 | 1359 | $d_cont .= '<div class="ee-notices"></div>'; |
1360 | 1360 | $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
1361 | 1361 | $d_cont .= '</div>'; |
@@ -1365,7 +1365,7 @@ discard block |
||
1365 | 1365 | echo implode('<br />', $this->_help_tour[$this->_req_action]); |
1366 | 1366 | } |
1367 | 1367 | //current set timezone for timezone js |
1368 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
1368 | + echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>'; |
|
1369 | 1369 | } |
1370 | 1370 | |
1371 | 1371 | |
@@ -1390,7 +1390,7 @@ discard block |
||
1390 | 1390 | { |
1391 | 1391 | $content = ''; |
1392 | 1392 | $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
1393 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
1393 | + $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php'; |
|
1394 | 1394 | //loop through the array and setup content |
1395 | 1395 | foreach ($help_array as $trigger => $help) { |
1396 | 1396 | //make sure the array is setup properly |
@@ -1424,7 +1424,7 @@ discard block |
||
1424 | 1424 | private function _get_help_content() |
1425 | 1425 | { |
1426 | 1426 | //what is the method we're looking for? |
1427 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
1427 | + $method_name = '_help_popup_content_'.$this->_req_action; |
|
1428 | 1428 | //if method doesn't exist let's get out. |
1429 | 1429 | if ( ! method_exists($this, $method_name)) { |
1430 | 1430 | return array(); |
@@ -1468,8 +1468,8 @@ discard block |
||
1468 | 1468 | $help_content = $this->_set_help_popup_content($help_array, false); |
1469 | 1469 | } |
1470 | 1470 | //let's setup the trigger |
1471 | - $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1472 | - $content = $content . $help_content; |
|
1471 | + $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1472 | + $content = $content.$help_content; |
|
1473 | 1473 | if ($display) { |
1474 | 1474 | echo $content; |
1475 | 1475 | } else { |
@@ -1529,32 +1529,32 @@ discard block |
||
1529 | 1529 | add_action('admin_head', array($this, 'add_xdebug_style')); |
1530 | 1530 | } |
1531 | 1531 | //register all styles |
1532 | - wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1533 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1532 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1533 | + wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1534 | 1534 | //helpers styles |
1535 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
1535 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
1536 | 1536 | //enqueue global styles |
1537 | 1537 | wp_enqueue_style('ee-admin-css'); |
1538 | 1538 | /** SCRIPTS **/ |
1539 | 1539 | //register all scripts |
1540 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1541 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
1542 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1543 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
1540 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1541 | + wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
1542 | + wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1543 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
1544 | 1544 | // register jQuery Validate - see /includes/functions/wp_hooks.php |
1545 | 1545 | add_filter('FHEE_load_jquery_validate', '__return_true'); |
1546 | 1546 | add_filter('FHEE_load_joyride', '__return_true'); |
1547 | 1547 | //script for sorting tables |
1548 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
1548 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
1549 | 1549 | //script for parsing uri's |
1550 | - wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1550 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1551 | 1551 | //and parsing associative serialized form elements |
1552 | - wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1552 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1553 | 1553 | //helpers scripts |
1554 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1555 | - wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1556 | - wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
1557 | - wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
1554 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1555 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1556 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
1557 | + wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
1558 | 1558 | //google charts |
1559 | 1559 | wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
1560 | 1560 | //enqueue global scripts |
@@ -1575,7 +1575,7 @@ discard block |
||
1575 | 1575 | */ |
1576 | 1576 | if ( ! empty($this->_help_tour)) { |
1577 | 1577 | //register the js for kicking things off |
1578 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
1578 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
1579 | 1579 | //setup tours for the js tour object |
1580 | 1580 | foreach ($this->_help_tour['tours'] as $tour) { |
1581 | 1581 | $tours[] = array( |
@@ -1674,17 +1674,17 @@ discard block |
||
1674 | 1674 | return; |
1675 | 1675 | } //not a list_table view so get out. |
1676 | 1676 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
1677 | - if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) { |
|
1677 | + if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) { |
|
1678 | 1678 | //user error msg |
1679 | 1679 | $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
1680 | 1680 | //developer error msg |
1681 | - $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
1682 | - $this->_req_action, '_set_list_table_views_' . $this->_req_action); |
|
1681 | + $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
1682 | + $this->_req_action, '_set_list_table_views_'.$this->_req_action); |
|
1683 | 1683 | throw new EE_Error($error_msg); |
1684 | 1684 | } |
1685 | 1685 | //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
1686 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views); |
|
1687 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views); |
|
1686 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views); |
|
1687 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views); |
|
1688 | 1688 | $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
1689 | 1689 | $this->_set_list_table_view(); |
1690 | 1690 | $this->_set_list_table_object(); |
@@ -1759,7 +1759,7 @@ discard block |
||
1759 | 1759 | // check for current view |
1760 | 1760 | $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
1761 | 1761 | $query_args['action'] = $this->_req_action; |
1762 | - $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
1762 | + $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
1763 | 1763 | $query_args['status'] = $view['slug']; |
1764 | 1764 | //merge any other arguments sent in. |
1765 | 1765 | if (isset($extra_query_args[$view['slug']])) { |
@@ -1797,14 +1797,14 @@ discard block |
||
1797 | 1797 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
1798 | 1798 | foreach ($values as $value) { |
1799 | 1799 | if ($value < $max_entries) { |
1800 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1800 | + $selected = $value == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
1801 | 1801 | $entries_per_page_dropdown .= ' |
1802 | - <option value="' . $value . '"' . $selected . '>' . $value . ' </option>'; |
|
1802 | + <option value="' . $value.'"'.$selected.'>'.$value.' </option>'; |
|
1803 | 1803 | } |
1804 | 1804 | } |
1805 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1805 | + $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
1806 | 1806 | $entries_per_page_dropdown .= ' |
1807 | - <option value="' . $max_entries . '"' . $selected . '>All </option>'; |
|
1807 | + <option value="' . $max_entries.'"'.$selected.'>All </option>'; |
|
1808 | 1808 | $entries_per_page_dropdown .= ' |
1809 | 1809 | </select> |
1810 | 1810 | entries |
@@ -1826,7 +1826,7 @@ discard block |
||
1826 | 1826 | public function _set_search_attributes() |
1827 | 1827 | { |
1828 | 1828 | $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
1829 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
1829 | + $this->_template_args['search']['callback'] = 'search_'.$this->page_slug; |
|
1830 | 1830 | } |
1831 | 1831 | |
1832 | 1832 | /*** END LIST TABLE METHODS **/ |
@@ -1864,7 +1864,7 @@ discard block |
||
1864 | 1864 | // user error msg |
1865 | 1865 | $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
1866 | 1866 | // developer error msg |
1867 | - $error_msg .= '||' . sprintf( |
|
1867 | + $error_msg .= '||'.sprintf( |
|
1868 | 1868 | __( |
1869 | 1869 | 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
1870 | 1870 | 'event_espresso' |
@@ -1894,15 +1894,15 @@ discard block |
||
1894 | 1894 | && is_array($this->_route_config['columns']) |
1895 | 1895 | && count($this->_route_config['columns']) === 2 |
1896 | 1896 | ) { |
1897 | - add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1])); |
|
1897 | + add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1])); |
|
1898 | 1898 | $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
1899 | 1899 | $screen_id = $this->_current_screen->id; |
1900 | - $screen_columns = (int)get_user_option("screen_layout_$screen_id"); |
|
1900 | + $screen_columns = (int) get_user_option("screen_layout_$screen_id"); |
|
1901 | 1901 | $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
1902 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
1902 | + $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns; |
|
1903 | 1903 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
1904 | 1904 | $this->_template_args['screen'] = $this->_current_screen; |
1905 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
1905 | + $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php'; |
|
1906 | 1906 | //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
1907 | 1907 | $this->_route_config['has_metaboxes'] = true; |
1908 | 1908 | } |
@@ -1949,7 +1949,7 @@ discard block |
||
1949 | 1949 | */ |
1950 | 1950 | public function espresso_ratings_request() |
1951 | 1951 | { |
1952 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
1952 | + $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php'; |
|
1953 | 1953 | EEH_Template::display_template($template_path, array()); |
1954 | 1954 | } |
1955 | 1955 | |
@@ -1957,18 +1957,18 @@ discard block |
||
1957 | 1957 | |
1958 | 1958 | public static function cached_rss_display($rss_id, $url) |
1959 | 1959 | { |
1960 | - $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading…') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; |
|
1960 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
1961 | 1961 | $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
1962 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
1963 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
1964 | - $post = '</div>' . "\n"; |
|
1965 | - $cache_key = 'ee_rss_' . md5($rss_id); |
|
1962 | + $pre = '<div class="espresso-rss-display">'."\n\t"; |
|
1963 | + $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>'; |
|
1964 | + $post = '</div>'."\n"; |
|
1965 | + $cache_key = 'ee_rss_'.md5($rss_id); |
|
1966 | 1966 | if (false != ($output = get_transient($cache_key))) { |
1967 | - echo $pre . $output . $post; |
|
1967 | + echo $pre.$output.$post; |
|
1968 | 1968 | return true; |
1969 | 1969 | } |
1970 | 1970 | if ( ! $doing_ajax) { |
1971 | - echo $pre . $loading . $post; |
|
1971 | + echo $pre.$loading.$post; |
|
1972 | 1972 | return false; |
1973 | 1973 | } |
1974 | 1974 | ob_start(); |
@@ -2027,7 +2027,7 @@ discard block |
||
2027 | 2027 | |
2028 | 2028 | public function espresso_sponsors_post_box() |
2029 | 2029 | { |
2030 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2030 | + $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2031 | 2031 | EEH_Template::display_template($templatepath); |
2032 | 2032 | } |
2033 | 2033 | |
@@ -2035,7 +2035,7 @@ discard block |
||
2035 | 2035 | |
2036 | 2036 | private function _publish_post_box() |
2037 | 2037 | { |
2038 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
2038 | + $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview'; |
|
2039 | 2039 | //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
2040 | 2040 | if ( ! empty($this->_labels['publishbox'])) { |
2041 | 2041 | $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
@@ -2052,7 +2052,7 @@ discard block |
||
2052 | 2052 | { |
2053 | 2053 | //if we have extra content set let's add it in if not make sure its empty |
2054 | 2054 | $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
2055 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
2055 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php'; |
|
2056 | 2056 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
2057 | 2057 | } |
2058 | 2058 | |
@@ -2221,7 +2221,7 @@ discard block |
||
2221 | 2221 | //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
2222 | 2222 | $call_back_func = $create_func ? create_function('$post, $metabox', |
2223 | 2223 | 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
2224 | - add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
2224 | + add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
2225 | 2225 | } |
2226 | 2226 | |
2227 | 2227 | |
@@ -2301,10 +2301,10 @@ discard block |
||
2301 | 2301 | ? 'poststuff' |
2302 | 2302 | : 'espresso-default-admin'; |
2303 | 2303 | $template_path = $sidebar |
2304 | - ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' |
|
2305 | - : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
2304 | + ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php' |
|
2305 | + : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php'; |
|
2306 | 2306 | if (defined('DOING_AJAX') && DOING_AJAX) { |
2307 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2307 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2308 | 2308 | } |
2309 | 2309 | $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
2310 | 2310 | $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
@@ -2350,7 +2350,7 @@ discard block |
||
2350 | 2350 | true |
2351 | 2351 | ) |
2352 | 2352 | : $this->_template_args['preview_action_button']; |
2353 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
2353 | + $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php'; |
|
2354 | 2354 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2355 | 2355 | $template_path, |
2356 | 2356 | $this->_template_args, |
@@ -2401,7 +2401,7 @@ discard block |
||
2401 | 2401 | //setup search attributes |
2402 | 2402 | $this->_set_search_attributes(); |
2403 | 2403 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
2404 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
2404 | + $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php'; |
|
2405 | 2405 | $this->_template_args['table_url'] = defined('DOING_AJAX') |
2406 | 2406 | ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
2407 | 2407 | : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
@@ -2411,31 +2411,31 @@ discard block |
||
2411 | 2411 | $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
2412 | 2412 | if ( ! empty($ajax_sorting_callback)) { |
2413 | 2413 | $sortable_list_table_form_fields = wp_nonce_field( |
2414 | - $ajax_sorting_callback . '_nonce', |
|
2415 | - $ajax_sorting_callback . '_nonce', |
|
2414 | + $ajax_sorting_callback.'_nonce', |
|
2415 | + $ajax_sorting_callback.'_nonce', |
|
2416 | 2416 | false, |
2417 | 2417 | false |
2418 | 2418 | ); |
2419 | 2419 | // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
2420 | 2420 | // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
2421 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />'; |
|
2422 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
2421 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />'; |
|
2422 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />'; |
|
2423 | 2423 | } else { |
2424 | 2424 | $sortable_list_table_form_fields = ''; |
2425 | 2425 | } |
2426 | 2426 | $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
2427 | 2427 | $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
2428 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
2429 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">'; |
|
2428 | + $nonce_ref = $this->_req_action.'_nonce'; |
|
2429 | + $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">'; |
|
2430 | 2430 | $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
2431 | 2431 | //display message about search results? |
2432 | 2432 | $this->_template_args['before_list_table'] .= apply_filters( |
2433 | 2433 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
2434 | 2434 | ! empty($this->_req_data['s']) |
2435 | - ? '<p class="ee-search-results">' . sprintf( |
|
2435 | + ? '<p class="ee-search-results">'.sprintf( |
|
2436 | 2436 | __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), |
2437 | 2437 | trim($this->_req_data['s'], '%') |
2438 | - ) . '</p>' |
|
2438 | + ).'</p>' |
|
2439 | 2439 | : '', |
2440 | 2440 | $this->page_slug, |
2441 | 2441 | $this->_req_data, |
@@ -2471,8 +2471,8 @@ discard block |
||
2471 | 2471 | */ |
2472 | 2472 | protected function _display_legend($items) |
2473 | 2473 | { |
2474 | - $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this); |
|
2475 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
2474 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this); |
|
2475 | + $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php'; |
|
2476 | 2476 | return EEH_Template::display_template($legend_template, $this->_template_args, true); |
2477 | 2477 | } |
2478 | 2478 | |
@@ -2567,15 +2567,15 @@ discard block |
||
2567 | 2567 | $this->_nav_tabs = $this->_get_main_nav_tabs(); |
2568 | 2568 | $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
2569 | 2569 | $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
2570 | - $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, |
|
2570 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view, |
|
2571 | 2571 | isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
2572 | - $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, |
|
2572 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view, |
|
2573 | 2573 | isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
2574 | 2574 | $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
2575 | 2575 | // load settings page wrapper template |
2576 | - $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
2576 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php'; |
|
2577 | 2577 | //about page? |
2578 | - $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
2578 | + $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path; |
|
2579 | 2579 | if (defined('DOING_AJAX')) { |
2580 | 2580 | $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
2581 | 2581 | $this->_return_json(); |
@@ -2647,20 +2647,20 @@ discard block |
||
2647 | 2647 | protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null) |
2648 | 2648 | { |
2649 | 2649 | //make sure $text and $actions are in an array |
2650 | - $text = (array)$text; |
|
2651 | - $actions = (array)$actions; |
|
2650 | + $text = (array) $text; |
|
2651 | + $actions = (array) $actions; |
|
2652 | 2652 | $referrer_url = empty($referrer) ? '' : $referrer; |
2653 | - $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />' |
|
2654 | - : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />'; |
|
2653 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />' |
|
2654 | + : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />'; |
|
2655 | 2655 | $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
2656 | 2656 | $default_names = array('save', 'save_and_close'); |
2657 | 2657 | //add in a hidden index for the current page (so save and close redirects properly) |
2658 | 2658 | $this->_template_args['save_buttons'] = $referrer_url; |
2659 | 2659 | foreach ($button_text as $key => $button) { |
2660 | 2660 | $ref = $default_names[$key]; |
2661 | - $id = $this->_current_view . '_' . $ref; |
|
2661 | + $id = $this->_current_view.'_'.$ref; |
|
2662 | 2662 | $name = ! empty($actions) ? $actions[$key] : $ref; |
2663 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
2663 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />'; |
|
2664 | 2664 | if ( ! $both) { |
2665 | 2665 | break; |
2666 | 2666 | } |
@@ -2696,15 +2696,15 @@ discard block |
||
2696 | 2696 | { |
2697 | 2697 | if (empty($route)) { |
2698 | 2698 | $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
2699 | - $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
2700 | - EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
2699 | + $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
2700 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
2701 | 2701 | } |
2702 | 2702 | // open form |
2703 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
2703 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >'; |
|
2704 | 2704 | // add nonce |
2705 | - $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false); |
|
2705 | + $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false); |
|
2706 | 2706 | // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
2707 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
2707 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce; |
|
2708 | 2708 | // add REQUIRED form action |
2709 | 2709 | $hidden_fields = array( |
2710 | 2710 | 'action' => array('type' => 'hidden', 'value' => $route), |
@@ -2714,8 +2714,8 @@ discard block |
||
2714 | 2714 | // generate form fields |
2715 | 2715 | $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
2716 | 2716 | // add fields to form |
2717 | - foreach ((array)$form_fields as $field_name => $form_field) { |
|
2718 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
2717 | + foreach ((array) $form_fields as $field_name => $form_field) { |
|
2718 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field']; |
|
2719 | 2719 | } |
2720 | 2720 | // close form |
2721 | 2721 | $this->_template_args['after_admin_page_content'] = '</form>'; |
@@ -2796,7 +2796,7 @@ discard block |
||
2796 | 2796 | * @param array $query_args The original query_args array coming into the |
2797 | 2797 | * method. |
2798 | 2798 | */ |
2799 | - do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args); |
|
2799 | + do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args); |
|
2800 | 2800 | //calculate where we're going (if we have a "save and close" button pushed) |
2801 | 2801 | if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
2802 | 2802 | // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
@@ -2812,7 +2812,7 @@ discard block |
||
2812 | 2812 | foreach ($this->_default_route_query_args as $query_param => $query_value) { |
2813 | 2813 | //is there a wp_referer array in our _default_route_query_args property? |
2814 | 2814 | if ($query_param == 'wp_referer') { |
2815 | - $query_value = (array)$query_value; |
|
2815 | + $query_value = (array) $query_value; |
|
2816 | 2816 | foreach ($query_value as $reference => $value) { |
2817 | 2817 | if (strpos($reference, 'nonce') !== false) { |
2818 | 2818 | continue; |
@@ -2838,11 +2838,11 @@ discard block |
||
2838 | 2838 | // if redirecting to anything other than the main page, add a nonce |
2839 | 2839 | if (isset($query_args['action'])) { |
2840 | 2840 | // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
2841 | - $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
2841 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
2842 | 2842 | } |
2843 | 2843 | //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
2844 | - do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args); |
|
2845 | - $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
2844 | + do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args); |
|
2845 | + $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
2846 | 2846 | // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
2847 | 2847 | if (defined('DOING_AJAX')) { |
2848 | 2848 | $default_data = array( |
@@ -2972,7 +2972,7 @@ discard block |
||
2972 | 2972 | $args = array( |
2973 | 2973 | 'label' => $this->_admin_page_title, |
2974 | 2974 | 'default' => 10, |
2975 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page', |
|
2975 | + 'option' => $this->_current_page.'_'.$this->_current_view.'_per_page', |
|
2976 | 2976 | ); |
2977 | 2977 | //ONLY add the screen option if the user has access to it. |
2978 | 2978 | if ($this->check_user_access($this->_current_view, true)) { |
@@ -3005,8 +3005,8 @@ discard block |
||
3005 | 3005 | $map_option = $option; |
3006 | 3006 | $option = str_replace('-', '_', $option); |
3007 | 3007 | switch ($map_option) { |
3008 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
3009 | - $value = (int)$value; |
|
3008 | + case $this->_current_page.'_'.$this->_current_view.'_per_page': |
|
3009 | + $value = (int) $value; |
|
3010 | 3010 | if ($value < 1 || $value > 999) { |
3011 | 3011 | return; |
3012 | 3012 | } |
@@ -3033,7 +3033,7 @@ discard block |
||
3033 | 3033 | */ |
3034 | 3034 | public function set_template_args($data) |
3035 | 3035 | { |
3036 | - $this->_template_args = array_merge($this->_template_args, (array)$data); |
|
3036 | + $this->_template_args = array_merge($this->_template_args, (array) $data); |
|
3037 | 3037 | } |
3038 | 3038 | |
3039 | 3039 | |
@@ -3055,12 +3055,12 @@ discard block |
||
3055 | 3055 | $this->_verify_route($route); |
3056 | 3056 | } |
3057 | 3057 | //now let's set the string for what kind of transient we're setting |
3058 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3058 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
3059 | 3059 | $data = $notices ? array('notices' => $data) : $data; |
3060 | 3060 | //is there already a transient for this route? If there is then let's ADD to that transient |
3061 | 3061 | $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
3062 | 3062 | if ($existing) { |
3063 | - $data = array_merge((array)$data, (array)$existing); |
|
3063 | + $data = array_merge((array) $data, (array) $existing); |
|
3064 | 3064 | } |
3065 | 3065 | if (is_multisite() && is_network_admin()) { |
3066 | 3066 | set_site_transient($transient, $data, 8); |
@@ -3081,7 +3081,7 @@ discard block |
||
3081 | 3081 | { |
3082 | 3082 | $user_id = get_current_user_id(); |
3083 | 3083 | $route = ! $route ? $this->_req_action : $route; |
3084 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3084 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
3085 | 3085 | $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
3086 | 3086 | //delete transient after retrieval (just in case it hasn't expired); |
3087 | 3087 | if (is_multisite() && is_network_admin()) { |
@@ -3322,7 +3322,7 @@ discard block |
||
3322 | 3322 | */ |
3323 | 3323 | protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') |
3324 | 3324 | { |
3325 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3325 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
3326 | 3326 | } |
3327 | 3327 | |
3328 | 3328 | |
@@ -3336,7 +3336,7 @@ discard block |
||
3336 | 3336 | */ |
3337 | 3337 | protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') |
3338 | 3338 | { |
3339 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3339 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
3340 | 3340 | } |
3341 | 3341 | |
3342 | 3342 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -28,2116 +28,2116 @@ discard block |
||
28 | 28 | { |
29 | 29 | |
30 | 30 | |
31 | - //set in _init_page_props() |
|
32 | - public $page_slug; |
|
31 | + //set in _init_page_props() |
|
32 | + public $page_slug; |
|
33 | 33 | |
34 | - public $page_label; |
|
34 | + public $page_label; |
|
35 | 35 | |
36 | - public $page_folder; |
|
36 | + public $page_folder; |
|
37 | 37 | |
38 | - //set in define_page_props() |
|
39 | - protected $_admin_base_url; |
|
38 | + //set in define_page_props() |
|
39 | + protected $_admin_base_url; |
|
40 | 40 | |
41 | - protected $_admin_base_path; |
|
41 | + protected $_admin_base_path; |
|
42 | 42 | |
43 | - protected $_admin_page_title; |
|
43 | + protected $_admin_page_title; |
|
44 | 44 | |
45 | - protected $_labels; |
|
45 | + protected $_labels; |
|
46 | 46 | |
47 | 47 | |
48 | - //set early within EE_Admin_Init |
|
49 | - protected $_wp_page_slug; |
|
48 | + //set early within EE_Admin_Init |
|
49 | + protected $_wp_page_slug; |
|
50 | 50 | |
51 | - //navtabs |
|
52 | - protected $_nav_tabs; |
|
51 | + //navtabs |
|
52 | + protected $_nav_tabs; |
|
53 | 53 | |
54 | - protected $_default_nav_tab_name; |
|
54 | + protected $_default_nav_tab_name; |
|
55 | 55 | |
56 | - //helptourstops |
|
57 | - protected $_help_tour = array(); |
|
56 | + //helptourstops |
|
57 | + protected $_help_tour = array(); |
|
58 | 58 | |
59 | 59 | |
60 | - //template variables (used by templates) |
|
61 | - protected $_template_path; |
|
60 | + //template variables (used by templates) |
|
61 | + protected $_template_path; |
|
62 | 62 | |
63 | - protected $_column_template_path; |
|
63 | + protected $_column_template_path; |
|
64 | 64 | |
65 | - /** |
|
66 | - * @var array $_template_args |
|
67 | - */ |
|
68 | - protected $_template_args = array(); |
|
65 | + /** |
|
66 | + * @var array $_template_args |
|
67 | + */ |
|
68 | + protected $_template_args = array(); |
|
69 | 69 | |
70 | - /** |
|
71 | - * this will hold the list table object for a given view. |
|
72 | - * |
|
73 | - * @var EE_Admin_List_Table $_list_table_object |
|
74 | - */ |
|
75 | - protected $_list_table_object; |
|
70 | + /** |
|
71 | + * this will hold the list table object for a given view. |
|
72 | + * |
|
73 | + * @var EE_Admin_List_Table $_list_table_object |
|
74 | + */ |
|
75 | + protected $_list_table_object; |
|
76 | 76 | |
77 | - //bools |
|
78 | - protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states. |
|
77 | + //bools |
|
78 | + protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states. |
|
79 | 79 | |
80 | - protected $_routing; |
|
80 | + protected $_routing; |
|
81 | 81 | |
82 | - //list table args |
|
83 | - protected $_view; |
|
82 | + //list table args |
|
83 | + protected $_view; |
|
84 | 84 | |
85 | - protected $_views; |
|
85 | + protected $_views; |
|
86 | 86 | |
87 | 87 | |
88 | - //action => method pairs used for routing incoming requests |
|
89 | - protected $_page_routes; |
|
88 | + //action => method pairs used for routing incoming requests |
|
89 | + protected $_page_routes; |
|
90 | 90 | |
91 | - protected $_page_config; |
|
91 | + protected $_page_config; |
|
92 | 92 | |
93 | - //the current page route and route config |
|
94 | - protected $_route; |
|
93 | + //the current page route and route config |
|
94 | + protected $_route; |
|
95 | 95 | |
96 | - protected $_route_config; |
|
96 | + protected $_route_config; |
|
97 | 97 | |
98 | - /** |
|
99 | - * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out |
|
100 | - * actions. |
|
101 | - * |
|
102 | - * @since 4.6.x |
|
103 | - * @var array. |
|
104 | - */ |
|
105 | - protected $_default_route_query_args; |
|
98 | + /** |
|
99 | + * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out |
|
100 | + * actions. |
|
101 | + * |
|
102 | + * @since 4.6.x |
|
103 | + * @var array. |
|
104 | + */ |
|
105 | + protected $_default_route_query_args; |
|
106 | 106 | |
107 | - //set via request page and action args. |
|
108 | - protected $_current_page; |
|
107 | + //set via request page and action args. |
|
108 | + protected $_current_page; |
|
109 | 109 | |
110 | - protected $_current_view; |
|
110 | + protected $_current_view; |
|
111 | 111 | |
112 | - protected $_current_page_view_url; |
|
112 | + protected $_current_page_view_url; |
|
113 | 113 | |
114 | - //sanitized request action (and nonce) |
|
115 | - /** |
|
116 | - * @var string $_req_action |
|
117 | - */ |
|
118 | - protected $_req_action; |
|
114 | + //sanitized request action (and nonce) |
|
115 | + /** |
|
116 | + * @var string $_req_action |
|
117 | + */ |
|
118 | + protected $_req_action; |
|
119 | 119 | |
120 | - /** |
|
121 | - * @var string $_req_nonce |
|
122 | - */ |
|
123 | - protected $_req_nonce; |
|
120 | + /** |
|
121 | + * @var string $_req_nonce |
|
122 | + */ |
|
123 | + protected $_req_nonce; |
|
124 | 124 | |
125 | - //search related |
|
126 | - protected $_search_btn_label; |
|
125 | + //search related |
|
126 | + protected $_search_btn_label; |
|
127 | 127 | |
128 | - protected $_search_box_callback; |
|
128 | + protected $_search_box_callback; |
|
129 | 129 | |
130 | - /** |
|
131 | - * WP Current Screen object |
|
132 | - * |
|
133 | - * @var WP_Screen |
|
134 | - */ |
|
135 | - protected $_current_screen; |
|
130 | + /** |
|
131 | + * WP Current Screen object |
|
132 | + * |
|
133 | + * @var WP_Screen |
|
134 | + */ |
|
135 | + protected $_current_screen; |
|
136 | 136 | |
137 | - //for holding EE_Admin_Hooks object when needed (set via set_hook_object()) |
|
138 | - protected $_hook_obj; |
|
137 | + //for holding EE_Admin_Hooks object when needed (set via set_hook_object()) |
|
138 | + protected $_hook_obj; |
|
139 | 139 | |
140 | - //for holding incoming request data |
|
141 | - protected $_req_data; |
|
140 | + //for holding incoming request data |
|
141 | + protected $_req_data; |
|
142 | 142 | |
143 | - // yes / no array for admin form fields |
|
144 | - protected $_yes_no_values = array(); |
|
145 | - |
|
146 | - //some default things shared by all child classes |
|
147 | - protected $_default_espresso_metaboxes; |
|
148 | - |
|
149 | - /** |
|
150 | - * EE_Registry Object |
|
151 | - * |
|
152 | - * @var EE_Registry |
|
153 | - * @access protected |
|
154 | - */ |
|
155 | - protected $EE = null; |
|
156 | - |
|
157 | - |
|
158 | - |
|
159 | - /** |
|
160 | - * This is just a property that flags whether the given route is a caffeinated route or not. |
|
161 | - * |
|
162 | - * @var boolean |
|
163 | - */ |
|
164 | - protected $_is_caf = false; |
|
165 | - |
|
166 | - |
|
167 | - |
|
168 | - /** |
|
169 | - * @Constructor |
|
170 | - * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
171 | - * @access public |
|
172 | - */ |
|
173 | - public function __construct($routing = true) |
|
174 | - { |
|
175 | - if (strpos($this->_get_dir(), 'caffeinated') !== false) { |
|
176 | - $this->_is_caf = true; |
|
177 | - } |
|
178 | - $this->_yes_no_values = array( |
|
179 | - array('id' => true, 'text' => __('Yes', 'event_espresso')), |
|
180 | - array('id' => false, 'text' => __('No', 'event_espresso')), |
|
181 | - ); |
|
182 | - //set the _req_data property. |
|
183 | - $this->_req_data = array_merge($_GET, $_POST); |
|
184 | - //routing enabled? |
|
185 | - $this->_routing = $routing; |
|
186 | - //set initial page props (child method) |
|
187 | - $this->_init_page_props(); |
|
188 | - //set global defaults |
|
189 | - $this->_set_defaults(); |
|
190 | - //set early because incoming requests could be ajax related and we need to register those hooks. |
|
191 | - $this->_global_ajax_hooks(); |
|
192 | - $this->_ajax_hooks(); |
|
193 | - //other_page_hooks have to be early too. |
|
194 | - $this->_do_other_page_hooks(); |
|
195 | - //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
|
196 | - if (method_exists($this, '_before_page_setup')) { |
|
197 | - $this->_before_page_setup(); |
|
198 | - } |
|
199 | - //set up page dependencies |
|
200 | - $this->_page_setup(); |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - |
|
205 | - /** |
|
206 | - * _init_page_props |
|
207 | - * Child classes use to set at least the following properties: |
|
208 | - * $page_slug. |
|
209 | - * $page_label. |
|
210 | - * |
|
211 | - * @abstract |
|
212 | - * @access protected |
|
213 | - * @return void |
|
214 | - */ |
|
215 | - abstract protected function _init_page_props(); |
|
216 | - |
|
217 | - |
|
218 | - |
|
219 | - /** |
|
220 | - * _ajax_hooks |
|
221 | - * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
222 | - * Note: within the ajax callback methods. |
|
223 | - * |
|
224 | - * @abstract |
|
225 | - * @access protected |
|
226 | - * @return void |
|
227 | - */ |
|
228 | - abstract protected function _ajax_hooks(); |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - /** |
|
233 | - * _define_page_props |
|
234 | - * child classes define page properties in here. Must include at least: |
|
235 | - * $_admin_base_url = base_url for all admin pages |
|
236 | - * $_admin_page_title = default admin_page_title for admin pages |
|
237 | - * $_labels = array of default labels for various automatically generated elements: |
|
238 | - * array( |
|
239 | - * 'buttons' => array( |
|
240 | - * 'add' => __('label for add new button'), |
|
241 | - * 'edit' => __('label for edit button'), |
|
242 | - * 'delete' => __('label for delete button') |
|
243 | - * ) |
|
244 | - * ) |
|
245 | - * |
|
246 | - * @abstract |
|
247 | - * @access protected |
|
248 | - * @return void |
|
249 | - */ |
|
250 | - abstract protected function _define_page_props(); |
|
251 | - |
|
252 | - |
|
253 | - |
|
254 | - /** |
|
255 | - * _set_page_routes |
|
256 | - * child classes use this to define the page routes for all subpages handled by the class. Page routes are assigned to a action => method pairs in an array and to the $_page_routes property. Each page route must also have a 'default' |
|
257 | - * route. Here's the format |
|
258 | - * $this->_page_routes = array( |
|
259 | - * 'default' => array( |
|
260 | - * 'func' => '_default_method_handling_route', |
|
261 | - * 'args' => array('array','of','args'), |
|
262 | - * 'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing) |
|
263 | - * 'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after. The string you enter here should match the defined route reference for a headers sent route. |
|
264 | - * 'capability' => 'route_capability', //indicate a string for minimum capability required to access this route. |
|
265 | - * 'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks). |
|
266 | - * ), |
|
267 | - * 'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method. |
|
268 | - * ) |
|
269 | - * ) |
|
270 | - * |
|
271 | - * @abstract |
|
272 | - * @access protected |
|
273 | - * @return void |
|
274 | - */ |
|
275 | - abstract protected function _set_page_routes(); |
|
276 | - |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * _set_page_config |
|
281 | - * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page. |
|
282 | - * Format: |
|
283 | - * $this->_page_config = array( |
|
284 | - * 'default' => array( |
|
285 | - * 'labels' => array( |
|
286 | - * 'buttons' => array( |
|
287 | - * 'add' => __('label for adding item'), |
|
288 | - * 'edit' => __('label for editing item'), |
|
289 | - * 'delete' => __('label for deleting item') |
|
290 | - * ), |
|
291 | - * 'publishbox' => __('Localized Title for Publish metabox', 'event_espresso') |
|
292 | - * ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method |
|
293 | - * 'nav' => array( |
|
294 | - * 'label' => __('Label for Tab', 'event_espresso'). |
|
295 | - * 'url' => 'http://someurl', //automatically generated UNLESS you define |
|
296 | - * 'css_class' => 'css-class', //automatically generated UNLESS you define |
|
297 | - * 'order' => 10, //required to indicate tab position. |
|
298 | - * 'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter. |
|
299 | - * 'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page. |
|
300 | - * 'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages. |
|
301 | - * 'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes. Typically this is used if the 'metaboxes' index is not used because metaboxes are added later. We just use |
|
302 | - * this flag to make sure the necessary js gets enqueued on page load. |
|
303 | - * 'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued. |
|
304 | - * 'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes). The array indicates the max number of columns (4) and the default number of columns on page load (2). There is an option |
|
305 | - * in the "screen_options" dropdown that is setup so users can pick what columns they want to display. |
|
306 | - * 'help_tabs' => array( //this is used for adding help tabs to a page |
|
307 | - * 'tab_id' => array( |
|
308 | - * 'title' => 'tab_title', |
|
309 | - * 'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content. The fallback if it isn't present is to try a the callback. Filename should match a file in the admin |
|
310 | - * folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php) |
|
311 | - * 'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class |
|
312 | - * ), |
|
313 | - * 'tab2_id' => array( |
|
314 | - * 'title' => 'tab2 title', |
|
315 | - * 'filename' => 'file_name_2' |
|
316 | - * 'callback' => 'callback_method_for_content', |
|
317 | - * ), |
|
318 | - * 'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/ |
|
319 | - * 'help_tour' => array( |
|
320 | - * 'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here |
|
321 | - * (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class) |
|
322 | - * ), |
|
323 | - * 'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present). To remove the requirement for a nonce check when this route is visited just set |
|
324 | - * 'require_nonce' to FALSE |
|
325 | - * ) |
|
326 | - * ) |
|
327 | - * |
|
328 | - * @abstract |
|
329 | - * @access protected |
|
330 | - * @return void |
|
331 | - */ |
|
332 | - abstract protected function _set_page_config(); |
|
333 | - |
|
334 | - |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** end sample help_tour methods **/ |
|
339 | - /** |
|
340 | - * _add_screen_options |
|
341 | - * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
342 | - * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view. |
|
343 | - * |
|
344 | - * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
345 | - * see also WP_Screen object documents... |
|
346 | - * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
347 | - * @abstract |
|
348 | - * @access protected |
|
349 | - * @return void |
|
350 | - */ |
|
351 | - abstract protected function _add_screen_options(); |
|
352 | - |
|
353 | - |
|
354 | - |
|
355 | - /** |
|
356 | - * _add_feature_pointers |
|
357 | - * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js). |
|
358 | - * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view. |
|
359 | - * Note: this is just a placeholder for now. Implementation will come down the road |
|
360 | - * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
361 | - * |
|
362 | - * @link http://eamann.com/tech/wordpress-portland/ |
|
363 | - * @abstract |
|
364 | - * @access protected |
|
365 | - * @return void |
|
366 | - */ |
|
367 | - abstract protected function _add_feature_pointers(); |
|
368 | - |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * load_scripts_styles |
|
373 | - * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages. Note this is for all pages/subpages of the system. You can also load only specific scripts/styles |
|
374 | - * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg) |
|
375 | - * |
|
376 | - * @abstract |
|
377 | - * @access public |
|
378 | - * @return void |
|
379 | - */ |
|
380 | - abstract public function load_scripts_styles(); |
|
381 | - |
|
382 | - |
|
383 | - |
|
384 | - /** |
|
385 | - * admin_init |
|
386 | - * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here. This will apply to all pages/views loaded by child class. |
|
387 | - * |
|
388 | - * @abstract |
|
389 | - * @access public |
|
390 | - * @return void |
|
391 | - */ |
|
392 | - abstract public function admin_init(); |
|
393 | - |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * admin_notices |
|
398 | - * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
399 | - * |
|
400 | - * @abstract |
|
401 | - * @access public |
|
402 | - * @return void |
|
403 | - */ |
|
404 | - abstract public function admin_notices(); |
|
405 | - |
|
406 | - |
|
407 | - |
|
408 | - /** |
|
409 | - * admin_footer_scripts |
|
410 | - * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
411 | - * |
|
412 | - * @access public |
|
413 | - * @return void |
|
414 | - */ |
|
415 | - abstract public function admin_footer_scripts(); |
|
416 | - |
|
417 | - |
|
418 | - |
|
419 | - /** |
|
420 | - * admin_footer |
|
421 | - * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class. |
|
422 | - * |
|
423 | - * @access public |
|
424 | - * @return void |
|
425 | - */ |
|
426 | - public function admin_footer() |
|
427 | - { |
|
428 | - } |
|
429 | - |
|
430 | - |
|
431 | - |
|
432 | - /** |
|
433 | - * _global_ajax_hooks |
|
434 | - * all global add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
435 | - * Note: within the ajax callback methods. |
|
436 | - * |
|
437 | - * @abstract |
|
438 | - * @access protected |
|
439 | - * @return void |
|
440 | - */ |
|
441 | - protected function _global_ajax_hooks() |
|
442 | - { |
|
443 | - //for lazy loading of metabox content |
|
444 | - add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
445 | - } |
|
446 | - |
|
447 | - |
|
448 | - |
|
449 | - public function ajax_metabox_content() |
|
450 | - { |
|
451 | - $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
452 | - $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
453 | - self::cached_rss_display($contentid, $url); |
|
454 | - wp_die(); |
|
455 | - } |
|
456 | - |
|
457 | - |
|
458 | - |
|
459 | - /** |
|
460 | - * _page_setup |
|
461 | - * Makes sure any things that need to be loaded early get handled. We also escape early here if the page requested doesn't match the object. |
|
462 | - * |
|
463 | - * @final |
|
464 | - * @access protected |
|
465 | - * @return void |
|
466 | - */ |
|
467 | - final protected function _page_setup() |
|
468 | - { |
|
469 | - //requires? |
|
470 | - //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
|
471 | - add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
472 | - //next verify if we need to load anything... |
|
473 | - $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
|
474 | - $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
475 | - global $ee_menu_slugs; |
|
476 | - $ee_menu_slugs = (array)$ee_menu_slugs; |
|
477 | - if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) { |
|
478 | - return false; |
|
479 | - } |
|
480 | - // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
|
481 | - if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
482 | - $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
483 | - } |
|
484 | - // then set blank or -1 action values to 'default' |
|
485 | - $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
486 | - //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
|
487 | - $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
488 | - //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
|
489 | - $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
490 | - $this->_current_view = $this->_req_action; |
|
491 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
492 | - $this->_define_page_props(); |
|
493 | - $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
494 | - //default things |
|
495 | - $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
496 | - //set page configs |
|
497 | - $this->_set_page_routes(); |
|
498 | - $this->_set_page_config(); |
|
499 | - //let's include any referrer data in our default_query_args for this route for "stickiness". |
|
500 | - if (isset($this->_req_data['wp_referer'])) { |
|
501 | - $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
|
502 | - } |
|
503 | - //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
|
504 | - if (method_exists($this, '_extend_page_config')) { |
|
505 | - $this->_extend_page_config(); |
|
506 | - } |
|
507 | - //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
|
508 | - if (method_exists($this, '_extend_page_config_for_cpt')) { |
|
509 | - $this->_extend_page_config_for_cpt(); |
|
510 | - } |
|
511 | - //filter routes and page_config so addons can add their stuff. Filtering done per class |
|
512 | - $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this); |
|
513 | - $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this); |
|
514 | - //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
|
515 | - if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) { |
|
516 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2); |
|
517 | - } |
|
518 | - //next route only if routing enabled |
|
519 | - if ($this->_routing && ! defined('DOING_AJAX')) { |
|
520 | - $this->_verify_routes(); |
|
521 | - //next let's just check user_access and kill if no access |
|
522 | - $this->check_user_access(); |
|
523 | - if ($this->_is_UI_request) { |
|
524 | - //admin_init stuff - global, all views for this page class, specific view |
|
525 | - add_action('admin_init', array($this, 'admin_init'), 10); |
|
526 | - if (method_exists($this, 'admin_init_' . $this->_current_view)) { |
|
527 | - add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15); |
|
528 | - } |
|
529 | - } else { |
|
530 | - //hijack regular WP loading and route admin request immediately |
|
531 | - @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
532 | - $this->route_admin_request(); |
|
533 | - } |
|
534 | - } |
|
535 | - } |
|
536 | - |
|
537 | - |
|
538 | - |
|
539 | - /** |
|
540 | - * Provides a way for related child admin pages to load stuff on the loaded admin page. |
|
541 | - * |
|
542 | - * @access private |
|
543 | - * @return void |
|
544 | - */ |
|
545 | - private function _do_other_page_hooks() |
|
546 | - { |
|
547 | - $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array()); |
|
548 | - foreach ($registered_pages as $page) { |
|
549 | - //now let's setup the file name and class that should be present |
|
550 | - $classname = str_replace('.class.php', '', $page); |
|
551 | - //autoloaders should take care of loading file |
|
552 | - if ( ! class_exists($classname)) { |
|
553 | - $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
554 | - $error_msg[] = $error_msg[0] |
|
555 | - . "\r\n" |
|
556 | - . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
557 | - 'event_espresso'), $page, '<br />', $classname); |
|
558 | - throw new EE_Error(implode('||', $error_msg)); |
|
559 | - } |
|
560 | - $a = new ReflectionClass($classname); |
|
561 | - //notice we are passing the instance of this class to the hook object. |
|
562 | - $hookobj[] = $a->newInstance($this); |
|
563 | - } |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - |
|
568 | - public function load_page_dependencies() |
|
569 | - { |
|
570 | - try { |
|
571 | - $this->_load_page_dependencies(); |
|
572 | - } catch (EE_Error $e) { |
|
573 | - $e->get_error(); |
|
574 | - } |
|
575 | - } |
|
576 | - |
|
577 | - |
|
578 | - |
|
579 | - /** |
|
580 | - * load_page_dependencies |
|
581 | - * loads things specific to this page class when its loaded. Really helps with efficiency. |
|
582 | - * |
|
583 | - * @access public |
|
584 | - * @return void |
|
585 | - */ |
|
586 | - protected function _load_page_dependencies() |
|
587 | - { |
|
588 | - //let's set the current_screen and screen options to override what WP set |
|
589 | - $this->_current_screen = get_current_screen(); |
|
590 | - //load admin_notices - global, page class, and view specific |
|
591 | - add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
592 | - add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
593 | - if (method_exists($this, 'admin_notices_' . $this->_current_view)) { |
|
594 | - add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15); |
|
595 | - } |
|
596 | - //load network admin_notices - global, page class, and view specific |
|
597 | - add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
598 | - if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) { |
|
599 | - add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view)); |
|
600 | - } |
|
601 | - //this will save any per_page screen options if they are present |
|
602 | - $this->_set_per_page_screen_options(); |
|
603 | - //setup list table properties |
|
604 | - $this->_set_list_table(); |
|
605 | - // child classes can "register" a metabox to be automatically handled via the _page_config array property. However in some cases the metaboxes will need to be added within a route handling callback. |
|
606 | - $this->_add_registered_meta_boxes(); |
|
607 | - $this->_add_screen_columns(); |
|
608 | - //add screen options - global, page child class, and view specific |
|
609 | - $this->_add_global_screen_options(); |
|
610 | - $this->_add_screen_options(); |
|
611 | - if (method_exists($this, '_add_screen_options_' . $this->_current_view)) { |
|
612 | - call_user_func(array($this, '_add_screen_options_' . $this->_current_view)); |
|
613 | - } |
|
614 | - //add help tab(s) and tours- set via page_config and qtips. |
|
615 | - $this->_add_help_tour(); |
|
616 | - $this->_add_help_tabs(); |
|
617 | - $this->_add_qtips(); |
|
618 | - //add feature_pointers - global, page child class, and view specific |
|
619 | - $this->_add_feature_pointers(); |
|
620 | - $this->_add_global_feature_pointers(); |
|
621 | - if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) { |
|
622 | - call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view)); |
|
623 | - } |
|
624 | - //enqueue scripts/styles - global, page class, and view specific |
|
625 | - add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
626 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
627 | - if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) { |
|
628 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15); |
|
629 | - } |
|
630 | - add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
631 | - //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
|
632 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
633 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
634 | - if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) { |
|
635 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101); |
|
636 | - } |
|
637 | - //admin footer scripts |
|
638 | - add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
639 | - add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
640 | - if (method_exists($this, 'admin_footer_' . $this->_current_view)) { |
|
641 | - add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101); |
|
642 | - } |
|
643 | - do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
644 | - //targeted hook |
|
645 | - do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action); |
|
646 | - } |
|
647 | - |
|
648 | - |
|
649 | - |
|
650 | - /** |
|
651 | - * _set_defaults |
|
652 | - * This sets some global defaults for class properties. |
|
653 | - */ |
|
654 | - private function _set_defaults() |
|
655 | - { |
|
656 | - $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null; |
|
657 | - $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
658 | - $this->default_nav_tab_name = 'overview'; |
|
659 | - //init template args |
|
660 | - $this->_template_args = array( |
|
661 | - 'admin_page_header' => '', |
|
662 | - 'admin_page_content' => '', |
|
663 | - 'post_body_content' => '', |
|
664 | - 'before_list_table' => '', |
|
665 | - 'after_list_table' => '', |
|
666 | - ); |
|
667 | - } |
|
668 | - |
|
669 | - |
|
670 | - |
|
671 | - /** |
|
672 | - * route_admin_request |
|
673 | - * |
|
674 | - * @see _route_admin_request() |
|
675 | - * @access public |
|
676 | - * @return void|exception error |
|
677 | - */ |
|
678 | - public function route_admin_request() |
|
679 | - { |
|
680 | - try { |
|
681 | - $this->_route_admin_request(); |
|
682 | - } catch (EE_Error $e) { |
|
683 | - $e->get_error(); |
|
684 | - } |
|
685 | - } |
|
686 | - |
|
687 | - |
|
688 | - |
|
689 | - public function set_wp_page_slug($wp_page_slug) |
|
690 | - { |
|
691 | - $this->_wp_page_slug = $wp_page_slug; |
|
692 | - //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
|
693 | - if (is_network_admin()) { |
|
694 | - $this->_wp_page_slug .= '-network'; |
|
695 | - } |
|
696 | - } |
|
697 | - |
|
698 | - |
|
699 | - |
|
700 | - /** |
|
701 | - * _verify_routes |
|
702 | - * All this method does is verify the incoming request and make sure that routes exist for it. We do this early so we know if we need to drop out. |
|
703 | - * |
|
704 | - * @access protected |
|
705 | - * @return void |
|
706 | - */ |
|
707 | - protected function _verify_routes() |
|
708 | - { |
|
709 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
710 | - if ( ! $this->_current_page && ! defined('DOING_AJAX')) { |
|
711 | - return false; |
|
712 | - } |
|
713 | - $this->_route = false; |
|
714 | - $func = false; |
|
715 | - $args = array(); |
|
716 | - // check that the page_routes array is not empty |
|
717 | - if (empty($this->_page_routes)) { |
|
718 | - // user error msg |
|
719 | - $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
720 | - // developer error msg |
|
721 | - $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
722 | - throw new EE_Error($error_msg); |
|
723 | - } |
|
724 | - // and that the requested page route exists |
|
725 | - if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
726 | - $this->_route = $this->_page_routes[$this->_req_action]; |
|
727 | - $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
|
728 | - } else { |
|
729 | - // user error msg |
|
730 | - $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
731 | - // developer error msg |
|
732 | - $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
733 | - throw new EE_Error($error_msg); |
|
734 | - } |
|
735 | - // and that a default route exists |
|
736 | - if ( ! array_key_exists('default', $this->_page_routes)) { |
|
737 | - // user error msg |
|
738 | - $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
739 | - // developer error msg |
|
740 | - $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
741 | - throw new EE_Error($error_msg); |
|
742 | - } |
|
743 | - //first lets' catch if the UI request has EVER been set. |
|
744 | - if ($this->_is_UI_request === null) { |
|
745 | - //lets set if this is a UI request or not. |
|
746 | - $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false; |
|
747 | - //wait a minute... we might have a noheader in the route array |
|
748 | - $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request; |
|
749 | - } |
|
750 | - $this->_set_current_labels(); |
|
751 | - } |
|
752 | - |
|
753 | - |
|
754 | - |
|
755 | - /** |
|
756 | - * this method simply verifies a given route and makes sure its an actual route available for the loaded page |
|
757 | - * |
|
758 | - * @param string $route the route name we're verifying |
|
759 | - * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
|
760 | - */ |
|
761 | - protected function _verify_route($route) |
|
762 | - { |
|
763 | - if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
764 | - return true; |
|
765 | - } else { |
|
766 | - // user error msg |
|
767 | - $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
768 | - // developer error msg |
|
769 | - $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
770 | - throw new EE_Error($error_msg); |
|
771 | - } |
|
772 | - } |
|
773 | - |
|
774 | - |
|
775 | - |
|
776 | - /** |
|
777 | - * perform nonce verification |
|
778 | - * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!) |
|
779 | - * |
|
780 | - * @param string $nonce The nonce sent |
|
781 | - * @param string $nonce_ref The nonce reference string (name0) |
|
782 | - * @return mixed (bool|die) |
|
783 | - */ |
|
784 | - protected function _verify_nonce($nonce, $nonce_ref) |
|
785 | - { |
|
786 | - // verify nonce against expected value |
|
787 | - if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
788 | - // these are not the droids you are looking for !!! |
|
789 | - $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
790 | - if (WP_DEBUG) { |
|
791 | - $msg .= "\n " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
792 | - } |
|
793 | - if ( ! defined('DOING_AJAX')) { |
|
794 | - wp_die($msg); |
|
795 | - } else { |
|
796 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
797 | - $this->_return_json(); |
|
798 | - } |
|
799 | - } |
|
800 | - } |
|
801 | - |
|
802 | - |
|
803 | - |
|
804 | - /** |
|
805 | - * _route_admin_request() |
|
806 | - * Meat and potatoes of the class. Basically, this dude checks out what's being requested and sees if theres are |
|
807 | - * some doodads to work the magic and handle the flingjangy. Translation: Checks if the requested action is listed |
|
808 | - * in the page routes and then will try to load the corresponding method. |
|
809 | - * |
|
810 | - * @access protected |
|
811 | - * @return void |
|
812 | - * @throws \EE_Error |
|
813 | - */ |
|
814 | - protected function _route_admin_request() |
|
815 | - { |
|
816 | - if ( ! $this->_is_UI_request) { |
|
817 | - $this->_verify_routes(); |
|
818 | - } |
|
819 | - $nonce_check = isset($this->_route_config['require_nonce']) |
|
820 | - ? $this->_route_config['require_nonce'] |
|
821 | - : true; |
|
822 | - if ($this->_req_action !== 'default' && $nonce_check) { |
|
823 | - // set nonce from post data |
|
824 | - $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
825 | - ? sanitize_text_field($this->_req_data[$this->_req_nonce]) |
|
826 | - : ''; |
|
827 | - $this->_verify_nonce($nonce, $this->_req_nonce); |
|
828 | - } |
|
829 | - //set the nav_tabs array but ONLY if this is UI_request |
|
830 | - if ($this->_is_UI_request) { |
|
831 | - $this->_set_nav_tabs(); |
|
832 | - } |
|
833 | - // grab callback function |
|
834 | - $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
835 | - // check if callback has args |
|
836 | - $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
837 | - $error_msg = ''; |
|
838 | - // action right before calling route |
|
839 | - // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
|
840 | - if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
841 | - do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
842 | - } |
|
843 | - // right before calling the route, let's remove _wp_http_referer from the |
|
844 | - // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
|
845 | - $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
846 | - if ( ! empty($func)) { |
|
847 | - if (is_array($func)) { |
|
848 | - list($class, $method) = $func; |
|
849 | - } else if (strpos($func, '::') !== false) { |
|
850 | - list($class, $method) = explode('::', $func); |
|
851 | - } else { |
|
852 | - $class = $this; |
|
853 | - $method = $func; |
|
854 | - } |
|
855 | - if ( ! (is_object($class) && $class === $this)) { |
|
856 | - // send along this admin page object for access by addons. |
|
857 | - $args['admin_page_object'] = $this; |
|
858 | - } |
|
859 | - if ( |
|
860 | - //is it a method on a class that doesn't work? |
|
861 | - ( |
|
862 | - method_exists($class, $method) |
|
863 | - && call_user_func_array(array($class, $method), $args) === false |
|
864 | - ) |
|
865 | - || ( |
|
866 | - //is it a standalone function that doesn't work? |
|
867 | - function_exists($method) |
|
868 | - && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false |
|
869 | - ) |
|
870 | - || ( |
|
871 | - //is it neither a class method NOR a standalone function? |
|
872 | - ! method_exists($class, $method) |
|
873 | - && ! function_exists($method) |
|
874 | - ) |
|
875 | - ) { |
|
876 | - // user error msg |
|
877 | - $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
878 | - // developer error msg |
|
879 | - $error_msg .= '||'; |
|
880 | - $error_msg .= sprintf( |
|
881 | - __( |
|
882 | - 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', |
|
883 | - 'event_espresso' |
|
884 | - ), |
|
885 | - $method |
|
886 | - ); |
|
887 | - } |
|
888 | - if ( ! empty($error_msg)) { |
|
889 | - throw new EE_Error($error_msg); |
|
890 | - } |
|
891 | - } |
|
892 | - //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
|
893 | - //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
|
894 | - if ($this->_is_UI_request === false |
|
895 | - && is_array($this->_route) |
|
896 | - && ! empty($this->_route['headers_sent_route']) |
|
897 | - ) { |
|
898 | - $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
899 | - } |
|
900 | - } |
|
901 | - |
|
902 | - |
|
903 | - |
|
904 | - /** |
|
905 | - * This method just allows the resetting of page properties in the case where a no headers |
|
906 | - * route redirects to a headers route in its route config. |
|
907 | - * |
|
908 | - * @since 4.3.0 |
|
909 | - * @param string $new_route New (non header) route to redirect to. |
|
910 | - * @return void |
|
911 | - */ |
|
912 | - protected function _reset_routing_properties($new_route) |
|
913 | - { |
|
914 | - $this->_is_UI_request = true; |
|
915 | - //now we set the current route to whatever the headers_sent_route is set at |
|
916 | - $this->_req_data['action'] = $new_route; |
|
917 | - //rerun page setup |
|
918 | - $this->_page_setup(); |
|
919 | - } |
|
920 | - |
|
921 | - |
|
922 | - |
|
923 | - /** |
|
924 | - * _add_query_arg |
|
925 | - * adds nonce to array of arguments then calls WP add_query_arg function |
|
926 | - *(internally just uses EEH_URL's function with the same name) |
|
927 | - * |
|
928 | - * @access public |
|
929 | - * @param array $args |
|
930 | - * @param string $url |
|
931 | - * @param bool $sticky if true, then the existing Request params will be appended to the generated |
|
932 | - * url in an associative array indexed by the key 'wp_referer'; |
|
933 | - * Example usage: |
|
934 | - * If the current page is: |
|
935 | - * http://mydomain.com/wp-admin/admin.php?page=espresso_registrations |
|
936 | - * &action=default&event_id=20&month_range=March%202015 |
|
937 | - * &_wpnonce=5467821 |
|
938 | - * and you call: |
|
939 | - * EE_Admin_Page::add_query_args_and_nonce( |
|
940 | - * array( |
|
941 | - * 'action' => 'resend_something', |
|
942 | - * 'page=>espresso_registrations' |
|
943 | - * ), |
|
944 | - * $some_url, |
|
945 | - * true |
|
946 | - * ); |
|
947 | - * It will produce a url in this structure: |
|
948 | - * http://{$some_url}/?page=espresso_registrations&action=resend_something |
|
949 | - * &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[ |
|
950 | - * month_range]=March%202015 |
|
951 | - * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
|
952 | - * @return string |
|
953 | - */ |
|
954 | - public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) |
|
955 | - { |
|
956 | - //if there is a _wp_http_referer include the values from the request but only if sticky = true |
|
957 | - if ($sticky) { |
|
958 | - $request = $_REQUEST; |
|
959 | - unset($request['_wp_http_referer']); |
|
960 | - unset($request['wp_referer']); |
|
961 | - foreach ($request as $key => $value) { |
|
962 | - //do not add nonces |
|
963 | - if (strpos($key, 'nonce') !== false) { |
|
964 | - continue; |
|
965 | - } |
|
966 | - $args['wp_referer[' . $key . ']'] = $value; |
|
967 | - } |
|
968 | - } |
|
969 | - return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
970 | - } |
|
971 | - |
|
972 | - |
|
973 | - |
|
974 | - /** |
|
975 | - * This returns a generated link that will load the related help tab. |
|
976 | - * |
|
977 | - * @param string $help_tab_id the id for the connected help tab |
|
978 | - * @param string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
979 | - * @param string $help_text (optional) send help text you want to use for the link if default not to be used |
|
980 | - * @uses EEH_Template::get_help_tab_link() |
|
981 | - * @return string generated link |
|
982 | - */ |
|
983 | - protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false) |
|
984 | - { |
|
985 | - return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
986 | - } |
|
987 | - |
|
988 | - |
|
989 | - |
|
990 | - /** |
|
991 | - * _add_help_tabs |
|
992 | - * Note child classes define their help tabs within the page_config array. |
|
993 | - * |
|
994 | - * @link http://codex.wordpress.org/Function_Reference/add_help_tab |
|
995 | - * @access protected |
|
996 | - * @return void |
|
997 | - */ |
|
998 | - protected function _add_help_tabs() |
|
999 | - { |
|
1000 | - $tour_buttons = ''; |
|
1001 | - if (isset($this->_page_config[$this->_req_action])) { |
|
1002 | - $config = $this->_page_config[$this->_req_action]; |
|
1003 | - //is there a help tour for the current route? if there is let's setup the tour buttons |
|
1004 | - if (isset($this->_help_tour[$this->_req_action])) { |
|
1005 | - $tb = array(); |
|
1006 | - $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
|
1007 | - foreach ($this->_help_tour['tours'] as $tour) { |
|
1008 | - //if this is the end tour then we don't need to setup a button |
|
1009 | - if ($tour instanceof EE_Help_Tour_final_stop) { |
|
1010 | - continue; |
|
1011 | - } |
|
1012 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
1013 | - } |
|
1014 | - $tour_buttons .= implode('<br />', $tb); |
|
1015 | - $tour_buttons .= '</div></div>'; |
|
1016 | - } |
|
1017 | - // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
|
1018 | - if (is_array($config) && isset($config['help_sidebar'])) { |
|
1019 | - //check that the callback given is valid |
|
1020 | - if ( ! method_exists($this, $config['help_sidebar'])) { |
|
1021 | - throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', |
|
1022 | - 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
1023 | - } |
|
1024 | - $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
1025 | - $content .= $tour_buttons; //add help tour buttons. |
|
1026 | - //do we have any help tours setup? Cause if we do we want to add the buttons |
|
1027 | - $this->_current_screen->set_help_sidebar($content); |
|
1028 | - } |
|
1029 | - //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
|
1030 | - if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
1031 | - $this->_current_screen->set_help_sidebar($tour_buttons); |
|
1032 | - } |
|
1033 | - //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
|
1034 | - if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
1035 | - $_ht['id'] = $this->page_slug; |
|
1036 | - $_ht['title'] = __('Help Tours', 'event_espresso'); |
|
1037 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
1038 | - $this->_current_screen->add_help_tab($_ht); |
|
1039 | - }/**/ |
|
1040 | - if ( ! isset($config['help_tabs'])) { |
|
1041 | - return; |
|
1042 | - } //no help tabs for this route |
|
1043 | - foreach ((array)$config['help_tabs'] as $tab_id => $cfg) { |
|
1044 | - //we're here so there ARE help tabs! |
|
1045 | - //make sure we've got what we need |
|
1046 | - if ( ! isset($cfg['title'])) { |
|
1047 | - throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
1048 | - } |
|
1049 | - if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) { |
|
1050 | - throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', |
|
1051 | - 'event_espresso')); |
|
1052 | - } |
|
1053 | - //first priority goes to content. |
|
1054 | - if ( ! empty($cfg['content'])) { |
|
1055 | - $content = ! empty($cfg['content']) ? $cfg['content'] : null; |
|
1056 | - //second priority goes to filename |
|
1057 | - } else if ( ! empty($cfg['filename'])) { |
|
1058 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
1059 | - //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
|
1060 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
1061 | - //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
1062 | - if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
1063 | - EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', |
|
1064 | - 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
1065 | - return; |
|
1066 | - } |
|
1067 | - $template_args['admin_page_obj'] = $this; |
|
1068 | - $content = EEH_Template::display_template($file_path, $template_args, true); |
|
1069 | - } else { |
|
1070 | - $content = ''; |
|
1071 | - } |
|
1072 | - //check if callback is valid |
|
1073 | - if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
1074 | - EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', |
|
1075 | - 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
1076 | - return; |
|
1077 | - } |
|
1078 | - //setup config array for help tab method |
|
1079 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
1080 | - $_ht = array( |
|
1081 | - 'id' => $id, |
|
1082 | - 'title' => $cfg['title'], |
|
1083 | - 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null, |
|
1084 | - 'content' => $content, |
|
1085 | - ); |
|
1086 | - $this->_current_screen->add_help_tab($_ht); |
|
1087 | - } |
|
1088 | - } |
|
1089 | - } |
|
1090 | - |
|
1091 | - |
|
1092 | - |
|
1093 | - /** |
|
1094 | - * This basically checks loaded $_page_config property to see if there are any help_tours defined. "help_tours" is an array with properties for setting up usage of the joyride plugin |
|
1095 | - * |
|
1096 | - * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
1097 | - * @see instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments |
|
1098 | - * @access protected |
|
1099 | - * @return void |
|
1100 | - */ |
|
1101 | - protected function _add_help_tour() |
|
1102 | - { |
|
1103 | - $tours = array(); |
|
1104 | - $this->_help_tour = array(); |
|
1105 | - //exit early if help tours are turned off globally |
|
1106 | - if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) { |
|
1107 | - return; |
|
1108 | - } |
|
1109 | - //loop through _page_config to find any help_tour defined |
|
1110 | - foreach ($this->_page_config as $route => $config) { |
|
1111 | - //we're only going to set things up for this route |
|
1112 | - if ($route !== $this->_req_action) { |
|
1113 | - continue; |
|
1114 | - } |
|
1115 | - if (isset($config['help_tour'])) { |
|
1116 | - foreach ($config['help_tour'] as $tour) { |
|
1117 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
1118 | - //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
|
1119 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
1120 | - //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
1121 | - if ( ! is_readable($file_path)) { |
|
1122 | - EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), |
|
1123 | - $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
1124 | - return; |
|
1125 | - } |
|
1126 | - require_once $file_path; |
|
1127 | - if ( ! class_exists($tour)) { |
|
1128 | - $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
1129 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
1130 | - 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
1131 | - throw new EE_Error(implode('||', $error_msg)); |
|
1132 | - } |
|
1133 | - $a = new ReflectionClass($tour); |
|
1134 | - $tour_obj = $a->newInstance($this->_is_caf); |
|
1135 | - $tours[] = $tour_obj; |
|
1136 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
1137 | - } |
|
1138 | - //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
|
1139 | - $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
|
1140 | - $tours[] = $end_stop_tour; |
|
1141 | - $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
1142 | - } |
|
1143 | - } |
|
1144 | - if ( ! empty($tours)) { |
|
1145 | - $this->_help_tour['tours'] = $tours; |
|
1146 | - } |
|
1147 | - //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
|
1148 | - } |
|
1149 | - |
|
1150 | - |
|
1151 | - |
|
1152 | - /** |
|
1153 | - * This simply sets up any qtips that have been defined in the page config |
|
1154 | - * |
|
1155 | - * @access protected |
|
1156 | - * @return void |
|
1157 | - */ |
|
1158 | - protected function _add_qtips() |
|
1159 | - { |
|
1160 | - if (isset($this->_route_config['qtips'])) { |
|
1161 | - $qtips = (array)$this->_route_config['qtips']; |
|
1162 | - //load qtip loader |
|
1163 | - $path = array( |
|
1164 | - $this->_get_dir() . '/qtips/', |
|
1165 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/', |
|
1166 | - ); |
|
1167 | - EEH_Qtip_Loader::instance()->register($qtips, $path); |
|
1168 | - } |
|
1169 | - } |
|
1170 | - |
|
1171 | - |
|
1172 | - |
|
1173 | - /** |
|
1174 | - * _set_nav_tabs |
|
1175 | - * This sets up the nav tabs from the page_routes array. This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly. |
|
1176 | - * |
|
1177 | - * @access protected |
|
1178 | - * @return void |
|
1179 | - */ |
|
1180 | - protected function _set_nav_tabs() |
|
1181 | - { |
|
1182 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1183 | - $i = 0; |
|
1184 | - foreach ($this->_page_config as $slug => $config) { |
|
1185 | - if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) { |
|
1186 | - continue; |
|
1187 | - } //no nav tab for this config |
|
1188 | - //check for persistent flag |
|
1189 | - if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) { |
|
1190 | - continue; |
|
1191 | - } //nav tab is only to appear when route requested. |
|
1192 | - if ( ! $this->check_user_access($slug, true)) { |
|
1193 | - continue; |
|
1194 | - } //no nav tab becasue current user does not have access. |
|
1195 | - $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : ''; |
|
1196 | - $this->_nav_tabs[$slug] = array( |
|
1197 | - 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url), |
|
1198 | - 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
1199 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
1200 | - 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i, |
|
1201 | - ); |
|
1202 | - $i++; |
|
1203 | - } |
|
1204 | - //if $this->_nav_tabs is empty then lets set the default |
|
1205 | - if (empty($this->_nav_tabs)) { |
|
1206 | - $this->_nav_tabs[$this->default_nav_tab_name] = array( |
|
1207 | - 'url' => $this->admin_base_url, |
|
1208 | - 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
1209 | - 'css_class' => 'nav-tab-active', |
|
1210 | - 'order' => 10, |
|
1211 | - ); |
|
1212 | - } |
|
1213 | - //now let's sort the tabs according to order |
|
1214 | - usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
1215 | - } |
|
1216 | - |
|
1217 | - |
|
1218 | - |
|
1219 | - /** |
|
1220 | - * _set_current_labels |
|
1221 | - * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array |
|
1222 | - * |
|
1223 | - * @access private |
|
1224 | - * @return void |
|
1225 | - */ |
|
1226 | - private function _set_current_labels() |
|
1227 | - { |
|
1228 | - if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
1229 | - foreach ($this->_route_config['labels'] as $label => $text) { |
|
1230 | - if (is_array($text)) { |
|
1231 | - foreach ($text as $sublabel => $subtext) { |
|
1232 | - $this->_labels[$label][$sublabel] = $subtext; |
|
1233 | - } |
|
1234 | - } else { |
|
1235 | - $this->_labels[$label] = $text; |
|
1236 | - } |
|
1237 | - } |
|
1238 | - } |
|
1239 | - } |
|
1240 | - |
|
1241 | - |
|
1242 | - |
|
1243 | - /** |
|
1244 | - * verifies user access for this admin page |
|
1245 | - * |
|
1246 | - * @param string $route_to_check if present then the capability for the route matching this string is checked. |
|
1247 | - * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
|
1248 | - * @return BOOL|wp_die() |
|
1249 | - */ |
|
1250 | - public function check_user_access($route_to_check = '', $verify_only = false) |
|
1251 | - { |
|
1252 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1253 | - $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
1254 | - $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) |
|
1255 | - ? $this->_page_routes[$route_to_check]['capability'] : null; |
|
1256 | - if (empty($capability) && empty($route_to_check)) { |
|
1257 | - $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
1258 | - } else { |
|
1259 | - $capability = empty($capability) ? 'manage_options' : $capability; |
|
1260 | - } |
|
1261 | - $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
1262 | - if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
1263 | - if ($verify_only) { |
|
1264 | - return false; |
|
1265 | - } else { |
|
1266 | - if ( is_user_logged_in() ) { |
|
1267 | - wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
1268 | - } else { |
|
1269 | - return false; |
|
1270 | - } |
|
1271 | - } |
|
1272 | - } |
|
1273 | - return true; |
|
1274 | - } |
|
1275 | - |
|
1276 | - |
|
1277 | - |
|
1278 | - /** |
|
1279 | - * admin_init_global |
|
1280 | - * This runs all the code that we want executed within the WP admin_init hook. |
|
1281 | - * This method executes for ALL EE Admin pages. |
|
1282 | - * |
|
1283 | - * @access public |
|
1284 | - * @return void |
|
1285 | - */ |
|
1286 | - public function admin_init_global() |
|
1287 | - { |
|
1288 | - } |
|
1289 | - |
|
1290 | - |
|
1291 | - |
|
1292 | - /** |
|
1293 | - * wp_loaded_global |
|
1294 | - * This runs all the code that we want executed within the WP wp_loaded hook. This method is optional for an EE_Admin page and will execute on every EE Admin Page load |
|
1295 | - * |
|
1296 | - * @access public |
|
1297 | - * @return void |
|
1298 | - */ |
|
1299 | - public function wp_loaded() |
|
1300 | - { |
|
1301 | - } |
|
1302 | - |
|
1303 | - |
|
1304 | - |
|
1305 | - /** |
|
1306 | - * admin_notices |
|
1307 | - * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
1308 | - * |
|
1309 | - * @access public |
|
1310 | - * @return void |
|
1311 | - */ |
|
1312 | - public function admin_notices_global() |
|
1313 | - { |
|
1314 | - $this->_display_no_javascript_warning(); |
|
1315 | - $this->_display_espresso_notices(); |
|
1316 | - } |
|
1317 | - |
|
1318 | - |
|
1319 | - |
|
1320 | - public function network_admin_notices_global() |
|
1321 | - { |
|
1322 | - $this->_display_no_javascript_warning(); |
|
1323 | - $this->_display_espresso_notices(); |
|
1324 | - } |
|
1325 | - |
|
1326 | - |
|
1327 | - |
|
1328 | - /** |
|
1329 | - * admin_footer_scripts_global |
|
1330 | - * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
1331 | - * |
|
1332 | - * @access public |
|
1333 | - * @return void |
|
1334 | - */ |
|
1335 | - public function admin_footer_scripts_global() |
|
1336 | - { |
|
1337 | - $this->_add_admin_page_ajax_loading_img(); |
|
1338 | - $this->_add_admin_page_overlay(); |
|
1339 | - //if metaboxes are present we need to add the nonce field |
|
1340 | - if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
1341 | - wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
1342 | - wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
1343 | - } |
|
1344 | - } |
|
1345 | - |
|
1346 | - |
|
1347 | - |
|
1348 | - /** |
|
1349 | - * admin_footer_global |
|
1350 | - * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages. |
|
1351 | - * |
|
1352 | - * @access public |
|
1353 | - * @return void |
|
1354 | - */ |
|
1355 | - public function admin_footer_global() |
|
1356 | - { |
|
1357 | - //dialog container for dialog helper |
|
1358 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
1359 | - $d_cont .= '<div class="ee-notices"></div>'; |
|
1360 | - $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
|
1361 | - $d_cont .= '</div>'; |
|
1362 | - echo $d_cont; |
|
1363 | - //help tour stuff? |
|
1364 | - if (isset($this->_help_tour[$this->_req_action])) { |
|
1365 | - echo implode('<br />', $this->_help_tour[$this->_req_action]); |
|
1366 | - } |
|
1367 | - //current set timezone for timezone js |
|
1368 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
1369 | - } |
|
1370 | - |
|
1371 | - |
|
1372 | - |
|
1373 | - /** |
|
1374 | - * This function sees if there is a method for help popup content existing for the given route. If there is then we'll use the retrieved array to output the content using the template. |
|
1375 | - * For child classes: |
|
1376 | - * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for |
|
1377 | - * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()" So if you are setting help content for the |
|
1378 | - * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method. You must prepare and return an array in the following format array( |
|
1379 | - * 'help_trigger_id' => array( |
|
1380 | - * 'title' => __('localized title for popup', 'event_espresso'), |
|
1381 | - * 'content' => __('localized content for popup', 'event_espresso') |
|
1382 | - * ) |
|
1383 | - * ); |
|
1384 | - * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route. |
|
1385 | - * |
|
1386 | - * @access protected |
|
1387 | - * @return string content |
|
1388 | - */ |
|
1389 | - protected function _set_help_popup_content($help_array = array(), $display = false) |
|
1390 | - { |
|
1391 | - $content = ''; |
|
1392 | - $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
1393 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
1394 | - //loop through the array and setup content |
|
1395 | - foreach ($help_array as $trigger => $help) { |
|
1396 | - //make sure the array is setup properly |
|
1397 | - if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
1398 | - throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', |
|
1399 | - 'event_espresso')); |
|
1400 | - } |
|
1401 | - //we're good so let'd setup the template vars and then assign parsed template content to our content. |
|
1402 | - $template_args = array( |
|
1403 | - 'help_popup_id' => $trigger, |
|
1404 | - 'help_popup_title' => $help['title'], |
|
1405 | - 'help_popup_content' => $help['content'], |
|
1406 | - ); |
|
1407 | - $content .= EEH_Template::display_template($template_path, $template_args, true); |
|
1408 | - } |
|
1409 | - if ($display) { |
|
1410 | - echo $content; |
|
1411 | - } else { |
|
1412 | - return $content; |
|
1413 | - } |
|
1414 | - } |
|
1415 | - |
|
1416 | - |
|
1417 | - |
|
1418 | - /** |
|
1419 | - * All this does is retrive the help content array if set by the EE_Admin_Page child |
|
1420 | - * |
|
1421 | - * @access private |
|
1422 | - * @return array properly formatted array for help popup content |
|
1423 | - */ |
|
1424 | - private function _get_help_content() |
|
1425 | - { |
|
1426 | - //what is the method we're looking for? |
|
1427 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
1428 | - //if method doesn't exist let's get out. |
|
1429 | - if ( ! method_exists($this, $method_name)) { |
|
1430 | - return array(); |
|
1431 | - } |
|
1432 | - //k we're good to go let's retrieve the help array |
|
1433 | - $help_array = call_user_func(array($this, $method_name)); |
|
1434 | - //make sure we've got an array! |
|
1435 | - if ( ! is_array($help_array)) { |
|
1436 | - throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
1437 | - } |
|
1438 | - return $help_array; |
|
1439 | - } |
|
1440 | - |
|
1441 | - |
|
1442 | - |
|
1443 | - /** |
|
1444 | - * EE Admin Pages can use this to set a properly formatted trigger for a help popup. |
|
1445 | - * By default the trigger html is printed. Otherwise it can be returned if the $display flag is set "false" |
|
1446 | - * See comments made on the _set_help_content method for understanding other parts to the help popup tool. |
|
1447 | - * |
|
1448 | - * @access protected |
|
1449 | - * @param string $trigger_id reference for retrieving the trigger content for the popup |
|
1450 | - * @param boolean $display if false then we return the trigger string |
|
1451 | - * @param array $dimensions an array of dimensions for the box (array(h,w)) |
|
1452 | - * @return string |
|
1453 | - */ |
|
1454 | - protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640')) |
|
1455 | - { |
|
1456 | - if (defined('DOING_AJAX')) { |
|
1457 | - return; |
|
1458 | - } |
|
1459 | - //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
|
1460 | - $help_array = $this->_get_help_content(); |
|
1461 | - $help_content = ''; |
|
1462 | - if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
1463 | - $help_array[$trigger_id] = array( |
|
1464 | - 'title' => __('Missing Content', 'event_espresso'), |
|
1465 | - 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', |
|
1466 | - 'event_espresso'), |
|
1467 | - ); |
|
1468 | - $help_content = $this->_set_help_popup_content($help_array, false); |
|
1469 | - } |
|
1470 | - //let's setup the trigger |
|
1471 | - $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1472 | - $content = $content . $help_content; |
|
1473 | - if ($display) { |
|
1474 | - echo $content; |
|
1475 | - } else { |
|
1476 | - return $content; |
|
1477 | - } |
|
1478 | - } |
|
1479 | - |
|
1480 | - |
|
1481 | - |
|
1482 | - /** |
|
1483 | - * _add_global_screen_options |
|
1484 | - * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
1485 | - * This particular method will add_screen_options on ALL EE_Admin Pages |
|
1486 | - * |
|
1487 | - * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
1488 | - * see also WP_Screen object documents... |
|
1489 | - * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
1490 | - * @abstract |
|
1491 | - * @access private |
|
1492 | - * @return void |
|
1493 | - */ |
|
1494 | - private function _add_global_screen_options() |
|
1495 | - { |
|
1496 | - } |
|
1497 | - |
|
1498 | - |
|
1499 | - |
|
1500 | - /** |
|
1501 | - * _add_global_feature_pointers |
|
1502 | - * This method is used for implementing any "feature pointers" (using built-in WP styling js). |
|
1503 | - * This particular method will implement feature pointers for ALL EE_Admin pages. |
|
1504 | - * Note: this is just a placeholder for now. Implementation will come down the road |
|
1505 | - * |
|
1506 | - * @see WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
1507 | - * @link http://eamann.com/tech/wordpress-portland/ |
|
1508 | - * @abstract |
|
1509 | - * @access protected |
|
1510 | - * @return void |
|
1511 | - */ |
|
1512 | - private function _add_global_feature_pointers() |
|
1513 | - { |
|
1514 | - } |
|
1515 | - |
|
1516 | - |
|
1517 | - |
|
1518 | - /** |
|
1519 | - * load_global_scripts_styles |
|
1520 | - * The scripts and styles enqueued in here will be loaded on every EE Admin page |
|
1521 | - * |
|
1522 | - * @return void |
|
1523 | - */ |
|
1524 | - public function load_global_scripts_styles() |
|
1525 | - { |
|
1526 | - /** STYLES **/ |
|
1527 | - // add debugging styles |
|
1528 | - if (WP_DEBUG) { |
|
1529 | - add_action('admin_head', array($this, 'add_xdebug_style')); |
|
1530 | - } |
|
1531 | - //register all styles |
|
1532 | - wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1533 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1534 | - //helpers styles |
|
1535 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
1536 | - //enqueue global styles |
|
1537 | - wp_enqueue_style('ee-admin-css'); |
|
1538 | - /** SCRIPTS **/ |
|
1539 | - //register all scripts |
|
1540 | - wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1541 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
1542 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1543 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
1544 | - // register jQuery Validate - see /includes/functions/wp_hooks.php |
|
1545 | - add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
1546 | - add_filter('FHEE_load_joyride', '__return_true'); |
|
1547 | - //script for sorting tables |
|
1548 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
1549 | - //script for parsing uri's |
|
1550 | - wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1551 | - //and parsing associative serialized form elements |
|
1552 | - wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1553 | - //helpers scripts |
|
1554 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1555 | - wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1556 | - wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
1557 | - wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
1558 | - //google charts |
|
1559 | - wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
|
1560 | - //enqueue global scripts |
|
1561 | - //taking care of metaboxes |
|
1562 | - if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
1563 | - wp_enqueue_script('dashboard'); |
|
1564 | - } |
|
1565 | - //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
|
1566 | - if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
1567 | - wp_enqueue_script('ee_admin_js'); |
|
1568 | - wp_enqueue_style('ee-admin-css'); |
|
1569 | - } |
|
1570 | - //localize script for ajax lazy loading |
|
1571 | - $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
1572 | - wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
1573 | - /** |
|
1574 | - * help tour stuff |
|
1575 | - */ |
|
1576 | - if ( ! empty($this->_help_tour)) { |
|
1577 | - //register the js for kicking things off |
|
1578 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
1579 | - //setup tours for the js tour object |
|
1580 | - foreach ($this->_help_tour['tours'] as $tour) { |
|
1581 | - $tours[] = array( |
|
1582 | - 'id' => $tour->get_slug(), |
|
1583 | - 'options' => $tour->get_options(), |
|
1584 | - ); |
|
1585 | - } |
|
1586 | - wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
1587 | - //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
|
1588 | - } |
|
1589 | - } |
|
1590 | - |
|
1591 | - |
|
1592 | - |
|
1593 | - /** |
|
1594 | - * admin_footer_scripts_eei18n_js_strings |
|
1595 | - * |
|
1596 | - * @access public |
|
1597 | - * @return void |
|
1598 | - */ |
|
1599 | - public function admin_footer_scripts_eei18n_js_strings() |
|
1600 | - { |
|
1601 | - EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
|
1602 | - EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
1603 | - EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
1604 | - EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
1605 | - EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
1606 | - EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
1607 | - EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1608 | - EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
1609 | - EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
1610 | - EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
1611 | - EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
1612 | - EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
1613 | - EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
1614 | - EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
1615 | - EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
1616 | - EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
1617 | - EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
1618 | - EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
1619 | - EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1620 | - EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
1621 | - EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
1622 | - EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
1623 | - EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
1624 | - EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
1625 | - EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
1626 | - EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
1627 | - EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
1628 | - EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
1629 | - EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
1630 | - EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
1631 | - EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
1632 | - EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
1633 | - EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
1634 | - EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
1635 | - EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
1636 | - EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
1637 | - EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
1638 | - EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
1639 | - EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
1640 | - EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
1641 | - //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
|
1642 | - //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
|
1643 | - //espresso_core is listed as a dependency of ee_admin_js. |
|
1644 | - wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
1645 | - } |
|
1646 | - |
|
1647 | - |
|
1648 | - |
|
1649 | - /** |
|
1650 | - * load enhanced xdebug styles for ppl with failing eyesight |
|
1651 | - * |
|
1652 | - * @access public |
|
1653 | - * @return void |
|
1654 | - */ |
|
1655 | - public function add_xdebug_style() |
|
1656 | - { |
|
1657 | - echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
|
1658 | - } |
|
1659 | - |
|
1660 | - |
|
1661 | - /************************/ |
|
1662 | - /** LIST TABLE METHODS **/ |
|
1663 | - /************************/ |
|
1664 | - /** |
|
1665 | - * this sets up the list table if the current view requires it. |
|
1666 | - * |
|
1667 | - * @access protected |
|
1668 | - * @return void |
|
1669 | - */ |
|
1670 | - protected function _set_list_table() |
|
1671 | - { |
|
1672 | - //first is this a list_table view? |
|
1673 | - if ( ! isset($this->_route_config['list_table'])) { |
|
1674 | - return; |
|
1675 | - } //not a list_table view so get out. |
|
1676 | - //list table functions are per view specific (because some admin pages might have more than one listtable!) |
|
1677 | - if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) { |
|
1678 | - //user error msg |
|
1679 | - $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
1680 | - //developer error msg |
|
1681 | - $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
1682 | - $this->_req_action, '_set_list_table_views_' . $this->_req_action); |
|
1683 | - throw new EE_Error($error_msg); |
|
1684 | - } |
|
1685 | - //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
|
1686 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views); |
|
1687 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views); |
|
1688 | - $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
1689 | - $this->_set_list_table_view(); |
|
1690 | - $this->_set_list_table_object(); |
|
1691 | - } |
|
1692 | - |
|
1693 | - |
|
1694 | - |
|
1695 | - /** |
|
1696 | - * set current view for List Table |
|
1697 | - * |
|
1698 | - * @access public |
|
1699 | - * @return array |
|
1700 | - */ |
|
1701 | - protected function _set_list_table_view() |
|
1702 | - { |
|
1703 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1704 | - // looking at active items or dumpster diving ? |
|
1705 | - if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
1706 | - $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
1707 | - } else { |
|
1708 | - $this->_view = sanitize_key($this->_req_data['status']); |
|
1709 | - } |
|
1710 | - } |
|
1711 | - |
|
1712 | - |
|
1713 | - |
|
1714 | - /** |
|
1715 | - * _set_list_table_object |
|
1716 | - * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of. |
|
1717 | - * |
|
1718 | - * @throws \EE_Error |
|
1719 | - */ |
|
1720 | - protected function _set_list_table_object() |
|
1721 | - { |
|
1722 | - if (isset($this->_route_config['list_table'])) { |
|
1723 | - if ( ! class_exists($this->_route_config['list_table'])) { |
|
1724 | - throw new EE_Error( |
|
1725 | - sprintf( |
|
1726 | - __( |
|
1727 | - 'The %s class defined for the list table does not exist. Please check the spelling of the class ref in the $_page_config property on %s.', |
|
1728 | - 'event_espresso' |
|
1729 | - ), |
|
1730 | - $this->_route_config['list_table'], |
|
1731 | - get_class($this) |
|
1732 | - ) |
|
1733 | - ); |
|
1734 | - } |
|
1735 | - $list_table = $this->_route_config['list_table']; |
|
1736 | - $this->_list_table_object = new $list_table($this); |
|
1737 | - } |
|
1738 | - } |
|
1739 | - |
|
1740 | - |
|
1741 | - |
|
1742 | - /** |
|
1743 | - * get_list_table_view_RLs - get it? View RL ?? VU-RL??? URL ?? |
|
1744 | - * |
|
1745 | - * @param array $extra_query_args Optional. An array of extra query args to add to the generated |
|
1746 | - * urls. The array should be indexed by the view it is being |
|
1747 | - * added to. |
|
1748 | - * @return array |
|
1749 | - */ |
|
1750 | - public function get_list_table_view_RLs($extra_query_args = array()) |
|
1751 | - { |
|
1752 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1753 | - if (empty($this->_views)) { |
|
1754 | - $this->_views = array(); |
|
1755 | - } |
|
1756 | - // cycle thru views |
|
1757 | - foreach ($this->_views as $key => $view) { |
|
1758 | - $query_args = array(); |
|
1759 | - // check for current view |
|
1760 | - $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
1761 | - $query_args['action'] = $this->_req_action; |
|
1762 | - $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
1763 | - $query_args['status'] = $view['slug']; |
|
1764 | - //merge any other arguments sent in. |
|
1765 | - if (isset($extra_query_args[$view['slug']])) { |
|
1766 | - $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
1767 | - } |
|
1768 | - $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1769 | - } |
|
1770 | - return $this->_views; |
|
1771 | - } |
|
1772 | - |
|
1773 | - |
|
1774 | - |
|
1775 | - /** |
|
1776 | - * _entries_per_page_dropdown |
|
1777 | - * generates a drop down box for selecting the number of visiable rows in an admin page list table |
|
1778 | - * |
|
1779 | - * @todo : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it. |
|
1780 | - * @access protected |
|
1781 | - * @param int $max_entries total number of rows in the table |
|
1782 | - * @return string |
|
1783 | - */ |
|
1784 | - protected function _entries_per_page_dropdown($max_entries = false) |
|
1785 | - { |
|
1786 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1787 | - $values = array(10, 25, 50, 100); |
|
1788 | - $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
1789 | - if ($max_entries) { |
|
1790 | - $values[] = $max_entries; |
|
1791 | - sort($values); |
|
1792 | - } |
|
1793 | - $entries_per_page_dropdown = ' |
|
143 | + // yes / no array for admin form fields |
|
144 | + protected $_yes_no_values = array(); |
|
145 | + |
|
146 | + //some default things shared by all child classes |
|
147 | + protected $_default_espresso_metaboxes; |
|
148 | + |
|
149 | + /** |
|
150 | + * EE_Registry Object |
|
151 | + * |
|
152 | + * @var EE_Registry |
|
153 | + * @access protected |
|
154 | + */ |
|
155 | + protected $EE = null; |
|
156 | + |
|
157 | + |
|
158 | + |
|
159 | + /** |
|
160 | + * This is just a property that flags whether the given route is a caffeinated route or not. |
|
161 | + * |
|
162 | + * @var boolean |
|
163 | + */ |
|
164 | + protected $_is_caf = false; |
|
165 | + |
|
166 | + |
|
167 | + |
|
168 | + /** |
|
169 | + * @Constructor |
|
170 | + * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object. |
|
171 | + * @access public |
|
172 | + */ |
|
173 | + public function __construct($routing = true) |
|
174 | + { |
|
175 | + if (strpos($this->_get_dir(), 'caffeinated') !== false) { |
|
176 | + $this->_is_caf = true; |
|
177 | + } |
|
178 | + $this->_yes_no_values = array( |
|
179 | + array('id' => true, 'text' => __('Yes', 'event_espresso')), |
|
180 | + array('id' => false, 'text' => __('No', 'event_espresso')), |
|
181 | + ); |
|
182 | + //set the _req_data property. |
|
183 | + $this->_req_data = array_merge($_GET, $_POST); |
|
184 | + //routing enabled? |
|
185 | + $this->_routing = $routing; |
|
186 | + //set initial page props (child method) |
|
187 | + $this->_init_page_props(); |
|
188 | + //set global defaults |
|
189 | + $this->_set_defaults(); |
|
190 | + //set early because incoming requests could be ajax related and we need to register those hooks. |
|
191 | + $this->_global_ajax_hooks(); |
|
192 | + $this->_ajax_hooks(); |
|
193 | + //other_page_hooks have to be early too. |
|
194 | + $this->_do_other_page_hooks(); |
|
195 | + //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup. |
|
196 | + if (method_exists($this, '_before_page_setup')) { |
|
197 | + $this->_before_page_setup(); |
|
198 | + } |
|
199 | + //set up page dependencies |
|
200 | + $this->_page_setup(); |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + |
|
205 | + /** |
|
206 | + * _init_page_props |
|
207 | + * Child classes use to set at least the following properties: |
|
208 | + * $page_slug. |
|
209 | + * $page_label. |
|
210 | + * |
|
211 | + * @abstract |
|
212 | + * @access protected |
|
213 | + * @return void |
|
214 | + */ |
|
215 | + abstract protected function _init_page_props(); |
|
216 | + |
|
217 | + |
|
218 | + |
|
219 | + /** |
|
220 | + * _ajax_hooks |
|
221 | + * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
222 | + * Note: within the ajax callback methods. |
|
223 | + * |
|
224 | + * @abstract |
|
225 | + * @access protected |
|
226 | + * @return void |
|
227 | + */ |
|
228 | + abstract protected function _ajax_hooks(); |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + /** |
|
233 | + * _define_page_props |
|
234 | + * child classes define page properties in here. Must include at least: |
|
235 | + * $_admin_base_url = base_url for all admin pages |
|
236 | + * $_admin_page_title = default admin_page_title for admin pages |
|
237 | + * $_labels = array of default labels for various automatically generated elements: |
|
238 | + * array( |
|
239 | + * 'buttons' => array( |
|
240 | + * 'add' => __('label for add new button'), |
|
241 | + * 'edit' => __('label for edit button'), |
|
242 | + * 'delete' => __('label for delete button') |
|
243 | + * ) |
|
244 | + * ) |
|
245 | + * |
|
246 | + * @abstract |
|
247 | + * @access protected |
|
248 | + * @return void |
|
249 | + */ |
|
250 | + abstract protected function _define_page_props(); |
|
251 | + |
|
252 | + |
|
253 | + |
|
254 | + /** |
|
255 | + * _set_page_routes |
|
256 | + * child classes use this to define the page routes for all subpages handled by the class. Page routes are assigned to a action => method pairs in an array and to the $_page_routes property. Each page route must also have a 'default' |
|
257 | + * route. Here's the format |
|
258 | + * $this->_page_routes = array( |
|
259 | + * 'default' => array( |
|
260 | + * 'func' => '_default_method_handling_route', |
|
261 | + * 'args' => array('array','of','args'), |
|
262 | + * 'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing) |
|
263 | + * 'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after. The string you enter here should match the defined route reference for a headers sent route. |
|
264 | + * 'capability' => 'route_capability', //indicate a string for minimum capability required to access this route. |
|
265 | + * 'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks). |
|
266 | + * ), |
|
267 | + * 'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method. |
|
268 | + * ) |
|
269 | + * ) |
|
270 | + * |
|
271 | + * @abstract |
|
272 | + * @access protected |
|
273 | + * @return void |
|
274 | + */ |
|
275 | + abstract protected function _set_page_routes(); |
|
276 | + |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * _set_page_config |
|
281 | + * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page. |
|
282 | + * Format: |
|
283 | + * $this->_page_config = array( |
|
284 | + * 'default' => array( |
|
285 | + * 'labels' => array( |
|
286 | + * 'buttons' => array( |
|
287 | + * 'add' => __('label for adding item'), |
|
288 | + * 'edit' => __('label for editing item'), |
|
289 | + * 'delete' => __('label for deleting item') |
|
290 | + * ), |
|
291 | + * 'publishbox' => __('Localized Title for Publish metabox', 'event_espresso') |
|
292 | + * ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method |
|
293 | + * 'nav' => array( |
|
294 | + * 'label' => __('Label for Tab', 'event_espresso'). |
|
295 | + * 'url' => 'http://someurl', //automatically generated UNLESS you define |
|
296 | + * 'css_class' => 'css-class', //automatically generated UNLESS you define |
|
297 | + * 'order' => 10, //required to indicate tab position. |
|
298 | + * 'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter. |
|
299 | + * 'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page. |
|
300 | + * 'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages. |
|
301 | + * 'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes. Typically this is used if the 'metaboxes' index is not used because metaboxes are added later. We just use |
|
302 | + * this flag to make sure the necessary js gets enqueued on page load. |
|
303 | + * 'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued. |
|
304 | + * 'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes). The array indicates the max number of columns (4) and the default number of columns on page load (2). There is an option |
|
305 | + * in the "screen_options" dropdown that is setup so users can pick what columns they want to display. |
|
306 | + * 'help_tabs' => array( //this is used for adding help tabs to a page |
|
307 | + * 'tab_id' => array( |
|
308 | + * 'title' => 'tab_title', |
|
309 | + * 'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content. The fallback if it isn't present is to try a the callback. Filename should match a file in the admin |
|
310 | + * folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php) |
|
311 | + * 'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class |
|
312 | + * ), |
|
313 | + * 'tab2_id' => array( |
|
314 | + * 'title' => 'tab2 title', |
|
315 | + * 'filename' => 'file_name_2' |
|
316 | + * 'callback' => 'callback_method_for_content', |
|
317 | + * ), |
|
318 | + * 'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/ |
|
319 | + * 'help_tour' => array( |
|
320 | + * 'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here |
|
321 | + * (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class) |
|
322 | + * ), |
|
323 | + * 'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present). To remove the requirement for a nonce check when this route is visited just set |
|
324 | + * 'require_nonce' to FALSE |
|
325 | + * ) |
|
326 | + * ) |
|
327 | + * |
|
328 | + * @abstract |
|
329 | + * @access protected |
|
330 | + * @return void |
|
331 | + */ |
|
332 | + abstract protected function _set_page_config(); |
|
333 | + |
|
334 | + |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** end sample help_tour methods **/ |
|
339 | + /** |
|
340 | + * _add_screen_options |
|
341 | + * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
342 | + * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view. |
|
343 | + * |
|
344 | + * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
345 | + * see also WP_Screen object documents... |
|
346 | + * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
347 | + * @abstract |
|
348 | + * @access protected |
|
349 | + * @return void |
|
350 | + */ |
|
351 | + abstract protected function _add_screen_options(); |
|
352 | + |
|
353 | + |
|
354 | + |
|
355 | + /** |
|
356 | + * _add_feature_pointers |
|
357 | + * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js). |
|
358 | + * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view. |
|
359 | + * Note: this is just a placeholder for now. Implementation will come down the road |
|
360 | + * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
361 | + * |
|
362 | + * @link http://eamann.com/tech/wordpress-portland/ |
|
363 | + * @abstract |
|
364 | + * @access protected |
|
365 | + * @return void |
|
366 | + */ |
|
367 | + abstract protected function _add_feature_pointers(); |
|
368 | + |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * load_scripts_styles |
|
373 | + * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages. Note this is for all pages/subpages of the system. You can also load only specific scripts/styles |
|
374 | + * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg) |
|
375 | + * |
|
376 | + * @abstract |
|
377 | + * @access public |
|
378 | + * @return void |
|
379 | + */ |
|
380 | + abstract public function load_scripts_styles(); |
|
381 | + |
|
382 | + |
|
383 | + |
|
384 | + /** |
|
385 | + * admin_init |
|
386 | + * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here. This will apply to all pages/views loaded by child class. |
|
387 | + * |
|
388 | + * @abstract |
|
389 | + * @access public |
|
390 | + * @return void |
|
391 | + */ |
|
392 | + abstract public function admin_init(); |
|
393 | + |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * admin_notices |
|
398 | + * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
399 | + * |
|
400 | + * @abstract |
|
401 | + * @access public |
|
402 | + * @return void |
|
403 | + */ |
|
404 | + abstract public function admin_notices(); |
|
405 | + |
|
406 | + |
|
407 | + |
|
408 | + /** |
|
409 | + * admin_footer_scripts |
|
410 | + * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class. |
|
411 | + * |
|
412 | + * @access public |
|
413 | + * @return void |
|
414 | + */ |
|
415 | + abstract public function admin_footer_scripts(); |
|
416 | + |
|
417 | + |
|
418 | + |
|
419 | + /** |
|
420 | + * admin_footer |
|
421 | + * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class. |
|
422 | + * |
|
423 | + * @access public |
|
424 | + * @return void |
|
425 | + */ |
|
426 | + public function admin_footer() |
|
427 | + { |
|
428 | + } |
|
429 | + |
|
430 | + |
|
431 | + |
|
432 | + /** |
|
433 | + * _global_ajax_hooks |
|
434 | + * all global add_action('wp_ajax_{name_of_hook}') hooks in here. |
|
435 | + * Note: within the ajax callback methods. |
|
436 | + * |
|
437 | + * @abstract |
|
438 | + * @access protected |
|
439 | + * @return void |
|
440 | + */ |
|
441 | + protected function _global_ajax_hooks() |
|
442 | + { |
|
443 | + //for lazy loading of metabox content |
|
444 | + add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10); |
|
445 | + } |
|
446 | + |
|
447 | + |
|
448 | + |
|
449 | + public function ajax_metabox_content() |
|
450 | + { |
|
451 | + $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : ''; |
|
452 | + $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : ''; |
|
453 | + self::cached_rss_display($contentid, $url); |
|
454 | + wp_die(); |
|
455 | + } |
|
456 | + |
|
457 | + |
|
458 | + |
|
459 | + /** |
|
460 | + * _page_setup |
|
461 | + * Makes sure any things that need to be loaded early get handled. We also escape early here if the page requested doesn't match the object. |
|
462 | + * |
|
463 | + * @final |
|
464 | + * @access protected |
|
465 | + * @return void |
|
466 | + */ |
|
467 | + final protected function _page_setup() |
|
468 | + { |
|
469 | + //requires? |
|
470 | + //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can. But keep in mind, not everything is available from the EE_Admin Page object at this point. |
|
471 | + add_action('admin_init', array($this, 'admin_init_global'), 5); |
|
472 | + //next verify if we need to load anything... |
|
473 | + $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
|
474 | + $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
|
475 | + global $ee_menu_slugs; |
|
476 | + $ee_menu_slugs = (array)$ee_menu_slugs; |
|
477 | + if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) { |
|
478 | + return false; |
|
479 | + } |
|
480 | + // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first |
|
481 | + if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) { |
|
482 | + $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action']; |
|
483 | + } |
|
484 | + // then set blank or -1 action values to 'default' |
|
485 | + $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default'; |
|
486 | + //if action is 'default' after the above BUT we have 'route' var set, then let's use the route as the action. This covers cases where we're coming in from a list table that isn't on the default route. |
|
487 | + $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
488 | + //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
|
489 | + $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
|
490 | + $this->_current_view = $this->_req_action; |
|
491 | + $this->_req_nonce = $this->_req_action . '_nonce'; |
|
492 | + $this->_define_page_props(); |
|
493 | + $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
|
494 | + //default things |
|
495 | + $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box'); |
|
496 | + //set page configs |
|
497 | + $this->_set_page_routes(); |
|
498 | + $this->_set_page_config(); |
|
499 | + //let's include any referrer data in our default_query_args for this route for "stickiness". |
|
500 | + if (isset($this->_req_data['wp_referer'])) { |
|
501 | + $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer']; |
|
502 | + } |
|
503 | + //for caffeinated and other extended functionality. If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays |
|
504 | + if (method_exists($this, '_extend_page_config')) { |
|
505 | + $this->_extend_page_config(); |
|
506 | + } |
|
507 | + //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays. |
|
508 | + if (method_exists($this, '_extend_page_config_for_cpt')) { |
|
509 | + $this->_extend_page_config_for_cpt(); |
|
510 | + } |
|
511 | + //filter routes and page_config so addons can add their stuff. Filtering done per class |
|
512 | + $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this); |
|
513 | + $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this); |
|
514 | + //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
|
515 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) { |
|
516 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2); |
|
517 | + } |
|
518 | + //next route only if routing enabled |
|
519 | + if ($this->_routing && ! defined('DOING_AJAX')) { |
|
520 | + $this->_verify_routes(); |
|
521 | + //next let's just check user_access and kill if no access |
|
522 | + $this->check_user_access(); |
|
523 | + if ($this->_is_UI_request) { |
|
524 | + //admin_init stuff - global, all views for this page class, specific view |
|
525 | + add_action('admin_init', array($this, 'admin_init'), 10); |
|
526 | + if (method_exists($this, 'admin_init_' . $this->_current_view)) { |
|
527 | + add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15); |
|
528 | + } |
|
529 | + } else { |
|
530 | + //hijack regular WP loading and route admin request immediately |
|
531 | + @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT)); |
|
532 | + $this->route_admin_request(); |
|
533 | + } |
|
534 | + } |
|
535 | + } |
|
536 | + |
|
537 | + |
|
538 | + |
|
539 | + /** |
|
540 | + * Provides a way for related child admin pages to load stuff on the loaded admin page. |
|
541 | + * |
|
542 | + * @access private |
|
543 | + * @return void |
|
544 | + */ |
|
545 | + private function _do_other_page_hooks() |
|
546 | + { |
|
547 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array()); |
|
548 | + foreach ($registered_pages as $page) { |
|
549 | + //now let's setup the file name and class that should be present |
|
550 | + $classname = str_replace('.class.php', '', $page); |
|
551 | + //autoloaders should take care of loading file |
|
552 | + if ( ! class_exists($classname)) { |
|
553 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
554 | + $error_msg[] = $error_msg[0] |
|
555 | + . "\r\n" |
|
556 | + . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
557 | + 'event_espresso'), $page, '<br />', $classname); |
|
558 | + throw new EE_Error(implode('||', $error_msg)); |
|
559 | + } |
|
560 | + $a = new ReflectionClass($classname); |
|
561 | + //notice we are passing the instance of this class to the hook object. |
|
562 | + $hookobj[] = $a->newInstance($this); |
|
563 | + } |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + |
|
568 | + public function load_page_dependencies() |
|
569 | + { |
|
570 | + try { |
|
571 | + $this->_load_page_dependencies(); |
|
572 | + } catch (EE_Error $e) { |
|
573 | + $e->get_error(); |
|
574 | + } |
|
575 | + } |
|
576 | + |
|
577 | + |
|
578 | + |
|
579 | + /** |
|
580 | + * load_page_dependencies |
|
581 | + * loads things specific to this page class when its loaded. Really helps with efficiency. |
|
582 | + * |
|
583 | + * @access public |
|
584 | + * @return void |
|
585 | + */ |
|
586 | + protected function _load_page_dependencies() |
|
587 | + { |
|
588 | + //let's set the current_screen and screen options to override what WP set |
|
589 | + $this->_current_screen = get_current_screen(); |
|
590 | + //load admin_notices - global, page class, and view specific |
|
591 | + add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
|
592 | + add_action('admin_notices', array($this, 'admin_notices'), 10); |
|
593 | + if (method_exists($this, 'admin_notices_' . $this->_current_view)) { |
|
594 | + add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15); |
|
595 | + } |
|
596 | + //load network admin_notices - global, page class, and view specific |
|
597 | + add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
|
598 | + if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) { |
|
599 | + add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view)); |
|
600 | + } |
|
601 | + //this will save any per_page screen options if they are present |
|
602 | + $this->_set_per_page_screen_options(); |
|
603 | + //setup list table properties |
|
604 | + $this->_set_list_table(); |
|
605 | + // child classes can "register" a metabox to be automatically handled via the _page_config array property. However in some cases the metaboxes will need to be added within a route handling callback. |
|
606 | + $this->_add_registered_meta_boxes(); |
|
607 | + $this->_add_screen_columns(); |
|
608 | + //add screen options - global, page child class, and view specific |
|
609 | + $this->_add_global_screen_options(); |
|
610 | + $this->_add_screen_options(); |
|
611 | + if (method_exists($this, '_add_screen_options_' . $this->_current_view)) { |
|
612 | + call_user_func(array($this, '_add_screen_options_' . $this->_current_view)); |
|
613 | + } |
|
614 | + //add help tab(s) and tours- set via page_config and qtips. |
|
615 | + $this->_add_help_tour(); |
|
616 | + $this->_add_help_tabs(); |
|
617 | + $this->_add_qtips(); |
|
618 | + //add feature_pointers - global, page child class, and view specific |
|
619 | + $this->_add_feature_pointers(); |
|
620 | + $this->_add_global_feature_pointers(); |
|
621 | + if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) { |
|
622 | + call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view)); |
|
623 | + } |
|
624 | + //enqueue scripts/styles - global, page class, and view specific |
|
625 | + add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
|
626 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
|
627 | + if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) { |
|
628 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15); |
|
629 | + } |
|
630 | + add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
|
631 | + //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
|
632 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
|
633 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
|
634 | + if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) { |
|
635 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101); |
|
636 | + } |
|
637 | + //admin footer scripts |
|
638 | + add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
|
639 | + add_action('admin_footer', array($this, 'admin_footer'), 100); |
|
640 | + if (method_exists($this, 'admin_footer_' . $this->_current_view)) { |
|
641 | + add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101); |
|
642 | + } |
|
643 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
|
644 | + //targeted hook |
|
645 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action); |
|
646 | + } |
|
647 | + |
|
648 | + |
|
649 | + |
|
650 | + /** |
|
651 | + * _set_defaults |
|
652 | + * This sets some global defaults for class properties. |
|
653 | + */ |
|
654 | + private function _set_defaults() |
|
655 | + { |
|
656 | + $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null; |
|
657 | + $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array(); |
|
658 | + $this->default_nav_tab_name = 'overview'; |
|
659 | + //init template args |
|
660 | + $this->_template_args = array( |
|
661 | + 'admin_page_header' => '', |
|
662 | + 'admin_page_content' => '', |
|
663 | + 'post_body_content' => '', |
|
664 | + 'before_list_table' => '', |
|
665 | + 'after_list_table' => '', |
|
666 | + ); |
|
667 | + } |
|
668 | + |
|
669 | + |
|
670 | + |
|
671 | + /** |
|
672 | + * route_admin_request |
|
673 | + * |
|
674 | + * @see _route_admin_request() |
|
675 | + * @access public |
|
676 | + * @return void|exception error |
|
677 | + */ |
|
678 | + public function route_admin_request() |
|
679 | + { |
|
680 | + try { |
|
681 | + $this->_route_admin_request(); |
|
682 | + } catch (EE_Error $e) { |
|
683 | + $e->get_error(); |
|
684 | + } |
|
685 | + } |
|
686 | + |
|
687 | + |
|
688 | + |
|
689 | + public function set_wp_page_slug($wp_page_slug) |
|
690 | + { |
|
691 | + $this->_wp_page_slug = $wp_page_slug; |
|
692 | + //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls... |
|
693 | + if (is_network_admin()) { |
|
694 | + $this->_wp_page_slug .= '-network'; |
|
695 | + } |
|
696 | + } |
|
697 | + |
|
698 | + |
|
699 | + |
|
700 | + /** |
|
701 | + * _verify_routes |
|
702 | + * All this method does is verify the incoming request and make sure that routes exist for it. We do this early so we know if we need to drop out. |
|
703 | + * |
|
704 | + * @access protected |
|
705 | + * @return void |
|
706 | + */ |
|
707 | + protected function _verify_routes() |
|
708 | + { |
|
709 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
710 | + if ( ! $this->_current_page && ! defined('DOING_AJAX')) { |
|
711 | + return false; |
|
712 | + } |
|
713 | + $this->_route = false; |
|
714 | + $func = false; |
|
715 | + $args = array(); |
|
716 | + // check that the page_routes array is not empty |
|
717 | + if (empty($this->_page_routes)) { |
|
718 | + // user error msg |
|
719 | + $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
720 | + // developer error msg |
|
721 | + $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
722 | + throw new EE_Error($error_msg); |
|
723 | + } |
|
724 | + // and that the requested page route exists |
|
725 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
726 | + $this->_route = $this->_page_routes[$this->_req_action]; |
|
727 | + $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array(); |
|
728 | + } else { |
|
729 | + // user error msg |
|
730 | + $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
731 | + // developer error msg |
|
732 | + $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
733 | + throw new EE_Error($error_msg); |
|
734 | + } |
|
735 | + // and that a default route exists |
|
736 | + if ( ! array_key_exists('default', $this->_page_routes)) { |
|
737 | + // user error msg |
|
738 | + $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
|
739 | + // developer error msg |
|
740 | + $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
741 | + throw new EE_Error($error_msg); |
|
742 | + } |
|
743 | + //first lets' catch if the UI request has EVER been set. |
|
744 | + if ($this->_is_UI_request === null) { |
|
745 | + //lets set if this is a UI request or not. |
|
746 | + $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false; |
|
747 | + //wait a minute... we might have a noheader in the route array |
|
748 | + $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request; |
|
749 | + } |
|
750 | + $this->_set_current_labels(); |
|
751 | + } |
|
752 | + |
|
753 | + |
|
754 | + |
|
755 | + /** |
|
756 | + * this method simply verifies a given route and makes sure its an actual route available for the loaded page |
|
757 | + * |
|
758 | + * @param string $route the route name we're verifying |
|
759 | + * @return mixed (bool|Exception) we'll throw an exception if this isn't a valid route. |
|
760 | + */ |
|
761 | + protected function _verify_route($route) |
|
762 | + { |
|
763 | + if (array_key_exists($this->_req_action, $this->_page_routes)) { |
|
764 | + return true; |
|
765 | + } else { |
|
766 | + // user error msg |
|
767 | + $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
|
768 | + // developer error msg |
|
769 | + $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
770 | + throw new EE_Error($error_msg); |
|
771 | + } |
|
772 | + } |
|
773 | + |
|
774 | + |
|
775 | + |
|
776 | + /** |
|
777 | + * perform nonce verification |
|
778 | + * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!) |
|
779 | + * |
|
780 | + * @param string $nonce The nonce sent |
|
781 | + * @param string $nonce_ref The nonce reference string (name0) |
|
782 | + * @return mixed (bool|die) |
|
783 | + */ |
|
784 | + protected function _verify_nonce($nonce, $nonce_ref) |
|
785 | + { |
|
786 | + // verify nonce against expected value |
|
787 | + if ( ! wp_verify_nonce($nonce, $nonce_ref)) { |
|
788 | + // these are not the droids you are looking for !!! |
|
789 | + $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
|
790 | + if (WP_DEBUG) { |
|
791 | + $msg .= "\n " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
792 | + } |
|
793 | + if ( ! defined('DOING_AJAX')) { |
|
794 | + wp_die($msg); |
|
795 | + } else { |
|
796 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
797 | + $this->_return_json(); |
|
798 | + } |
|
799 | + } |
|
800 | + } |
|
801 | + |
|
802 | + |
|
803 | + |
|
804 | + /** |
|
805 | + * _route_admin_request() |
|
806 | + * Meat and potatoes of the class. Basically, this dude checks out what's being requested and sees if theres are |
|
807 | + * some doodads to work the magic and handle the flingjangy. Translation: Checks if the requested action is listed |
|
808 | + * in the page routes and then will try to load the corresponding method. |
|
809 | + * |
|
810 | + * @access protected |
|
811 | + * @return void |
|
812 | + * @throws \EE_Error |
|
813 | + */ |
|
814 | + protected function _route_admin_request() |
|
815 | + { |
|
816 | + if ( ! $this->_is_UI_request) { |
|
817 | + $this->_verify_routes(); |
|
818 | + } |
|
819 | + $nonce_check = isset($this->_route_config['require_nonce']) |
|
820 | + ? $this->_route_config['require_nonce'] |
|
821 | + : true; |
|
822 | + if ($this->_req_action !== 'default' && $nonce_check) { |
|
823 | + // set nonce from post data |
|
824 | + $nonce = isset($this->_req_data[$this->_req_nonce]) |
|
825 | + ? sanitize_text_field($this->_req_data[$this->_req_nonce]) |
|
826 | + : ''; |
|
827 | + $this->_verify_nonce($nonce, $this->_req_nonce); |
|
828 | + } |
|
829 | + //set the nav_tabs array but ONLY if this is UI_request |
|
830 | + if ($this->_is_UI_request) { |
|
831 | + $this->_set_nav_tabs(); |
|
832 | + } |
|
833 | + // grab callback function |
|
834 | + $func = is_array($this->_route) ? $this->_route['func'] : $this->_route; |
|
835 | + // check if callback has args |
|
836 | + $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array(); |
|
837 | + $error_msg = ''; |
|
838 | + // action right before calling route |
|
839 | + // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request') |
|
840 | + if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) { |
|
841 | + do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this); |
|
842 | + } |
|
843 | + // right before calling the route, let's remove _wp_http_referer from the |
|
844 | + // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing). |
|
845 | + $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI'])); |
|
846 | + if ( ! empty($func)) { |
|
847 | + if (is_array($func)) { |
|
848 | + list($class, $method) = $func; |
|
849 | + } else if (strpos($func, '::') !== false) { |
|
850 | + list($class, $method) = explode('::', $func); |
|
851 | + } else { |
|
852 | + $class = $this; |
|
853 | + $method = $func; |
|
854 | + } |
|
855 | + if ( ! (is_object($class) && $class === $this)) { |
|
856 | + // send along this admin page object for access by addons. |
|
857 | + $args['admin_page_object'] = $this; |
|
858 | + } |
|
859 | + if ( |
|
860 | + //is it a method on a class that doesn't work? |
|
861 | + ( |
|
862 | + method_exists($class, $method) |
|
863 | + && call_user_func_array(array($class, $method), $args) === false |
|
864 | + ) |
|
865 | + || ( |
|
866 | + //is it a standalone function that doesn't work? |
|
867 | + function_exists($method) |
|
868 | + && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false |
|
869 | + ) |
|
870 | + || ( |
|
871 | + //is it neither a class method NOR a standalone function? |
|
872 | + ! method_exists($class, $method) |
|
873 | + && ! function_exists($method) |
|
874 | + ) |
|
875 | + ) { |
|
876 | + // user error msg |
|
877 | + $error_msg = __('An error occurred. The requested page route could not be found.', 'event_espresso'); |
|
878 | + // developer error msg |
|
879 | + $error_msg .= '||'; |
|
880 | + $error_msg .= sprintf( |
|
881 | + __( |
|
882 | + 'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.', |
|
883 | + 'event_espresso' |
|
884 | + ), |
|
885 | + $method |
|
886 | + ); |
|
887 | + } |
|
888 | + if ( ! empty($error_msg)) { |
|
889 | + throw new EE_Error($error_msg); |
|
890 | + } |
|
891 | + } |
|
892 | + //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route. |
|
893 | + //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent. |
|
894 | + if ($this->_is_UI_request === false |
|
895 | + && is_array($this->_route) |
|
896 | + && ! empty($this->_route['headers_sent_route']) |
|
897 | + ) { |
|
898 | + $this->_reset_routing_properties($this->_route['headers_sent_route']); |
|
899 | + } |
|
900 | + } |
|
901 | + |
|
902 | + |
|
903 | + |
|
904 | + /** |
|
905 | + * This method just allows the resetting of page properties in the case where a no headers |
|
906 | + * route redirects to a headers route in its route config. |
|
907 | + * |
|
908 | + * @since 4.3.0 |
|
909 | + * @param string $new_route New (non header) route to redirect to. |
|
910 | + * @return void |
|
911 | + */ |
|
912 | + protected function _reset_routing_properties($new_route) |
|
913 | + { |
|
914 | + $this->_is_UI_request = true; |
|
915 | + //now we set the current route to whatever the headers_sent_route is set at |
|
916 | + $this->_req_data['action'] = $new_route; |
|
917 | + //rerun page setup |
|
918 | + $this->_page_setup(); |
|
919 | + } |
|
920 | + |
|
921 | + |
|
922 | + |
|
923 | + /** |
|
924 | + * _add_query_arg |
|
925 | + * adds nonce to array of arguments then calls WP add_query_arg function |
|
926 | + *(internally just uses EEH_URL's function with the same name) |
|
927 | + * |
|
928 | + * @access public |
|
929 | + * @param array $args |
|
930 | + * @param string $url |
|
931 | + * @param bool $sticky if true, then the existing Request params will be appended to the generated |
|
932 | + * url in an associative array indexed by the key 'wp_referer'; |
|
933 | + * Example usage: |
|
934 | + * If the current page is: |
|
935 | + * http://mydomain.com/wp-admin/admin.php?page=espresso_registrations |
|
936 | + * &action=default&event_id=20&month_range=March%202015 |
|
937 | + * &_wpnonce=5467821 |
|
938 | + * and you call: |
|
939 | + * EE_Admin_Page::add_query_args_and_nonce( |
|
940 | + * array( |
|
941 | + * 'action' => 'resend_something', |
|
942 | + * 'page=>espresso_registrations' |
|
943 | + * ), |
|
944 | + * $some_url, |
|
945 | + * true |
|
946 | + * ); |
|
947 | + * It will produce a url in this structure: |
|
948 | + * http://{$some_url}/?page=espresso_registrations&action=resend_something |
|
949 | + * &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[ |
|
950 | + * month_range]=March%202015 |
|
951 | + * @param bool $exclude_nonce If true, the the nonce will be excluded from the generated nonce. |
|
952 | + * @return string |
|
953 | + */ |
|
954 | + public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false) |
|
955 | + { |
|
956 | + //if there is a _wp_http_referer include the values from the request but only if sticky = true |
|
957 | + if ($sticky) { |
|
958 | + $request = $_REQUEST; |
|
959 | + unset($request['_wp_http_referer']); |
|
960 | + unset($request['wp_referer']); |
|
961 | + foreach ($request as $key => $value) { |
|
962 | + //do not add nonces |
|
963 | + if (strpos($key, 'nonce') !== false) { |
|
964 | + continue; |
|
965 | + } |
|
966 | + $args['wp_referer[' . $key . ']'] = $value; |
|
967 | + } |
|
968 | + } |
|
969 | + return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
|
970 | + } |
|
971 | + |
|
972 | + |
|
973 | + |
|
974 | + /** |
|
975 | + * This returns a generated link that will load the related help tab. |
|
976 | + * |
|
977 | + * @param string $help_tab_id the id for the connected help tab |
|
978 | + * @param string $icon_style (optional) include css class for the style you want to use for the help icon. |
|
979 | + * @param string $help_text (optional) send help text you want to use for the link if default not to be used |
|
980 | + * @uses EEH_Template::get_help_tab_link() |
|
981 | + * @return string generated link |
|
982 | + */ |
|
983 | + protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false) |
|
984 | + { |
|
985 | + return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text); |
|
986 | + } |
|
987 | + |
|
988 | + |
|
989 | + |
|
990 | + /** |
|
991 | + * _add_help_tabs |
|
992 | + * Note child classes define their help tabs within the page_config array. |
|
993 | + * |
|
994 | + * @link http://codex.wordpress.org/Function_Reference/add_help_tab |
|
995 | + * @access protected |
|
996 | + * @return void |
|
997 | + */ |
|
998 | + protected function _add_help_tabs() |
|
999 | + { |
|
1000 | + $tour_buttons = ''; |
|
1001 | + if (isset($this->_page_config[$this->_req_action])) { |
|
1002 | + $config = $this->_page_config[$this->_req_action]; |
|
1003 | + //is there a help tour for the current route? if there is let's setup the tour buttons |
|
1004 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
1005 | + $tb = array(); |
|
1006 | + $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">'; |
|
1007 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
1008 | + //if this is the end tour then we don't need to setup a button |
|
1009 | + if ($tour instanceof EE_Help_Tour_final_stop) { |
|
1010 | + continue; |
|
1011 | + } |
|
1012 | + $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
1013 | + } |
|
1014 | + $tour_buttons .= implode('<br />', $tb); |
|
1015 | + $tour_buttons .= '</div></div>'; |
|
1016 | + } |
|
1017 | + // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well. |
|
1018 | + if (is_array($config) && isset($config['help_sidebar'])) { |
|
1019 | + //check that the callback given is valid |
|
1020 | + if ( ! method_exists($this, $config['help_sidebar'])) { |
|
1021 | + throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', |
|
1022 | + 'event_espresso'), $config['help_sidebar'], get_class($this))); |
|
1023 | + } |
|
1024 | + $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
1025 | + $content .= $tour_buttons; //add help tour buttons. |
|
1026 | + //do we have any help tours setup? Cause if we do we want to add the buttons |
|
1027 | + $this->_current_screen->set_help_sidebar($content); |
|
1028 | + } |
|
1029 | + //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar. |
|
1030 | + if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) { |
|
1031 | + $this->_current_screen->set_help_sidebar($tour_buttons); |
|
1032 | + } |
|
1033 | + //handle if no help_tabs are set so the sidebar will still show for the help tour buttons |
|
1034 | + if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
|
1035 | + $_ht['id'] = $this->page_slug; |
|
1036 | + $_ht['title'] = __('Help Tours', 'event_espresso'); |
|
1037 | + $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
1038 | + $this->_current_screen->add_help_tab($_ht); |
|
1039 | + }/**/ |
|
1040 | + if ( ! isset($config['help_tabs'])) { |
|
1041 | + return; |
|
1042 | + } //no help tabs for this route |
|
1043 | + foreach ((array)$config['help_tabs'] as $tab_id => $cfg) { |
|
1044 | + //we're here so there ARE help tabs! |
|
1045 | + //make sure we've got what we need |
|
1046 | + if ( ! isset($cfg['title'])) { |
|
1047 | + throw new EE_Error(__('The _page_config array is not set up properly for help tabs. It is missing a title', 'event_espresso')); |
|
1048 | + } |
|
1049 | + if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) { |
|
1050 | + throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab', |
|
1051 | + 'event_espresso')); |
|
1052 | + } |
|
1053 | + //first priority goes to content. |
|
1054 | + if ( ! empty($cfg['content'])) { |
|
1055 | + $content = ! empty($cfg['content']) ? $cfg['content'] : null; |
|
1056 | + //second priority goes to filename |
|
1057 | + } else if ( ! empty($cfg['filename'])) { |
|
1058 | + $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
1059 | + //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
|
1060 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
1061 | + //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
1062 | + if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
|
1063 | + EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', |
|
1064 | + 'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__); |
|
1065 | + return; |
|
1066 | + } |
|
1067 | + $template_args['admin_page_obj'] = $this; |
|
1068 | + $content = EEH_Template::display_template($file_path, $template_args, true); |
|
1069 | + } else { |
|
1070 | + $content = ''; |
|
1071 | + } |
|
1072 | + //check if callback is valid |
|
1073 | + if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) { |
|
1074 | + EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content. Check the spelling or make sure the method is present.', |
|
1075 | + 'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__); |
|
1076 | + return; |
|
1077 | + } |
|
1078 | + //setup config array for help tab method |
|
1079 | + $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
1080 | + $_ht = array( |
|
1081 | + 'id' => $id, |
|
1082 | + 'title' => $cfg['title'], |
|
1083 | + 'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null, |
|
1084 | + 'content' => $content, |
|
1085 | + ); |
|
1086 | + $this->_current_screen->add_help_tab($_ht); |
|
1087 | + } |
|
1088 | + } |
|
1089 | + } |
|
1090 | + |
|
1091 | + |
|
1092 | + |
|
1093 | + /** |
|
1094 | + * This basically checks loaded $_page_config property to see if there are any help_tours defined. "help_tours" is an array with properties for setting up usage of the joyride plugin |
|
1095 | + * |
|
1096 | + * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin |
|
1097 | + * @see instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments |
|
1098 | + * @access protected |
|
1099 | + * @return void |
|
1100 | + */ |
|
1101 | + protected function _add_help_tour() |
|
1102 | + { |
|
1103 | + $tours = array(); |
|
1104 | + $this->_help_tour = array(); |
|
1105 | + //exit early if help tours are turned off globally |
|
1106 | + if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) { |
|
1107 | + return; |
|
1108 | + } |
|
1109 | + //loop through _page_config to find any help_tour defined |
|
1110 | + foreach ($this->_page_config as $route => $config) { |
|
1111 | + //we're only going to set things up for this route |
|
1112 | + if ($route !== $this->_req_action) { |
|
1113 | + continue; |
|
1114 | + } |
|
1115 | + if (isset($config['help_tour'])) { |
|
1116 | + foreach ($config['help_tour'] as $tour) { |
|
1117 | + $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
1118 | + //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
|
1119 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
1120 | + //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
|
1121 | + if ( ! is_readable($file_path)) { |
|
1122 | + EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), |
|
1123 | + $file_path, $tour), __FILE__, __FUNCTION__, __LINE__); |
|
1124 | + return; |
|
1125 | + } |
|
1126 | + require_once $file_path; |
|
1127 | + if ( ! class_exists($tour)) { |
|
1128 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
|
1129 | + $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
1130 | + 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
|
1131 | + throw new EE_Error(implode('||', $error_msg)); |
|
1132 | + } |
|
1133 | + $a = new ReflectionClass($tour); |
|
1134 | + $tour_obj = $a->newInstance($this->_is_caf); |
|
1135 | + $tours[] = $tour_obj; |
|
1136 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj); |
|
1137 | + } |
|
1138 | + //let's inject the end tour stop element common to all pages... this will only get seen once per machine. |
|
1139 | + $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf); |
|
1140 | + $tours[] = $end_stop_tour; |
|
1141 | + $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour); |
|
1142 | + } |
|
1143 | + } |
|
1144 | + if ( ! empty($tours)) { |
|
1145 | + $this->_help_tour['tours'] = $tours; |
|
1146 | + } |
|
1147 | + //thats it! Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically. |
|
1148 | + } |
|
1149 | + |
|
1150 | + |
|
1151 | + |
|
1152 | + /** |
|
1153 | + * This simply sets up any qtips that have been defined in the page config |
|
1154 | + * |
|
1155 | + * @access protected |
|
1156 | + * @return void |
|
1157 | + */ |
|
1158 | + protected function _add_qtips() |
|
1159 | + { |
|
1160 | + if (isset($this->_route_config['qtips'])) { |
|
1161 | + $qtips = (array)$this->_route_config['qtips']; |
|
1162 | + //load qtip loader |
|
1163 | + $path = array( |
|
1164 | + $this->_get_dir() . '/qtips/', |
|
1165 | + EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/', |
|
1166 | + ); |
|
1167 | + EEH_Qtip_Loader::instance()->register($qtips, $path); |
|
1168 | + } |
|
1169 | + } |
|
1170 | + |
|
1171 | + |
|
1172 | + |
|
1173 | + /** |
|
1174 | + * _set_nav_tabs |
|
1175 | + * This sets up the nav tabs from the page_routes array. This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly. |
|
1176 | + * |
|
1177 | + * @access protected |
|
1178 | + * @return void |
|
1179 | + */ |
|
1180 | + protected function _set_nav_tabs() |
|
1181 | + { |
|
1182 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1183 | + $i = 0; |
|
1184 | + foreach ($this->_page_config as $slug => $config) { |
|
1185 | + if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) { |
|
1186 | + continue; |
|
1187 | + } //no nav tab for this config |
|
1188 | + //check for persistent flag |
|
1189 | + if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) { |
|
1190 | + continue; |
|
1191 | + } //nav tab is only to appear when route requested. |
|
1192 | + if ( ! $this->check_user_access($slug, true)) { |
|
1193 | + continue; |
|
1194 | + } //no nav tab becasue current user does not have access. |
|
1195 | + $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : ''; |
|
1196 | + $this->_nav_tabs[$slug] = array( |
|
1197 | + 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url), |
|
1198 | + 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
|
1199 | + 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
1200 | + 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i, |
|
1201 | + ); |
|
1202 | + $i++; |
|
1203 | + } |
|
1204 | + //if $this->_nav_tabs is empty then lets set the default |
|
1205 | + if (empty($this->_nav_tabs)) { |
|
1206 | + $this->_nav_tabs[$this->default_nav_tab_name] = array( |
|
1207 | + 'url' => $this->admin_base_url, |
|
1208 | + 'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)), |
|
1209 | + 'css_class' => 'nav-tab-active', |
|
1210 | + 'order' => 10, |
|
1211 | + ); |
|
1212 | + } |
|
1213 | + //now let's sort the tabs according to order |
|
1214 | + usort($this->_nav_tabs, array($this, '_sort_nav_tabs')); |
|
1215 | + } |
|
1216 | + |
|
1217 | + |
|
1218 | + |
|
1219 | + /** |
|
1220 | + * _set_current_labels |
|
1221 | + * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array |
|
1222 | + * |
|
1223 | + * @access private |
|
1224 | + * @return void |
|
1225 | + */ |
|
1226 | + private function _set_current_labels() |
|
1227 | + { |
|
1228 | + if (is_array($this->_route_config) && isset($this->_route_config['labels'])) { |
|
1229 | + foreach ($this->_route_config['labels'] as $label => $text) { |
|
1230 | + if (is_array($text)) { |
|
1231 | + foreach ($text as $sublabel => $subtext) { |
|
1232 | + $this->_labels[$label][$sublabel] = $subtext; |
|
1233 | + } |
|
1234 | + } else { |
|
1235 | + $this->_labels[$label] = $text; |
|
1236 | + } |
|
1237 | + } |
|
1238 | + } |
|
1239 | + } |
|
1240 | + |
|
1241 | + |
|
1242 | + |
|
1243 | + /** |
|
1244 | + * verifies user access for this admin page |
|
1245 | + * |
|
1246 | + * @param string $route_to_check if present then the capability for the route matching this string is checked. |
|
1247 | + * @param bool $verify_only Default is FALSE which means if user check fails then wp_die(). Otherwise just return false if verify fail. |
|
1248 | + * @return BOOL|wp_die() |
|
1249 | + */ |
|
1250 | + public function check_user_access($route_to_check = '', $verify_only = false) |
|
1251 | + { |
|
1252 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1253 | + $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check; |
|
1254 | + $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability']) |
|
1255 | + ? $this->_page_routes[$route_to_check]['capability'] : null; |
|
1256 | + if (empty($capability) && empty($route_to_check)) { |
|
1257 | + $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability']; |
|
1258 | + } else { |
|
1259 | + $capability = empty($capability) ? 'manage_options' : $capability; |
|
1260 | + } |
|
1261 | + $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
|
1262 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
1263 | + if ($verify_only) { |
|
1264 | + return false; |
|
1265 | + } else { |
|
1266 | + if ( is_user_logged_in() ) { |
|
1267 | + wp_die(__('You do not have access to this route.', 'event_espresso')); |
|
1268 | + } else { |
|
1269 | + return false; |
|
1270 | + } |
|
1271 | + } |
|
1272 | + } |
|
1273 | + return true; |
|
1274 | + } |
|
1275 | + |
|
1276 | + |
|
1277 | + |
|
1278 | + /** |
|
1279 | + * admin_init_global |
|
1280 | + * This runs all the code that we want executed within the WP admin_init hook. |
|
1281 | + * This method executes for ALL EE Admin pages. |
|
1282 | + * |
|
1283 | + * @access public |
|
1284 | + * @return void |
|
1285 | + */ |
|
1286 | + public function admin_init_global() |
|
1287 | + { |
|
1288 | + } |
|
1289 | + |
|
1290 | + |
|
1291 | + |
|
1292 | + /** |
|
1293 | + * wp_loaded_global |
|
1294 | + * This runs all the code that we want executed within the WP wp_loaded hook. This method is optional for an EE_Admin page and will execute on every EE Admin Page load |
|
1295 | + * |
|
1296 | + * @access public |
|
1297 | + * @return void |
|
1298 | + */ |
|
1299 | + public function wp_loaded() |
|
1300 | + { |
|
1301 | + } |
|
1302 | + |
|
1303 | + |
|
1304 | + |
|
1305 | + /** |
|
1306 | + * admin_notices |
|
1307 | + * Anything triggered by the 'admin_notices' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
1308 | + * |
|
1309 | + * @access public |
|
1310 | + * @return void |
|
1311 | + */ |
|
1312 | + public function admin_notices_global() |
|
1313 | + { |
|
1314 | + $this->_display_no_javascript_warning(); |
|
1315 | + $this->_display_espresso_notices(); |
|
1316 | + } |
|
1317 | + |
|
1318 | + |
|
1319 | + |
|
1320 | + public function network_admin_notices_global() |
|
1321 | + { |
|
1322 | + $this->_display_no_javascript_warning(); |
|
1323 | + $this->_display_espresso_notices(); |
|
1324 | + } |
|
1325 | + |
|
1326 | + |
|
1327 | + |
|
1328 | + /** |
|
1329 | + * admin_footer_scripts_global |
|
1330 | + * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages. |
|
1331 | + * |
|
1332 | + * @access public |
|
1333 | + * @return void |
|
1334 | + */ |
|
1335 | + public function admin_footer_scripts_global() |
|
1336 | + { |
|
1337 | + $this->_add_admin_page_ajax_loading_img(); |
|
1338 | + $this->_add_admin_page_overlay(); |
|
1339 | + //if metaboxes are present we need to add the nonce field |
|
1340 | + if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) { |
|
1341 | + wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false); |
|
1342 | + wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false); |
|
1343 | + } |
|
1344 | + } |
|
1345 | + |
|
1346 | + |
|
1347 | + |
|
1348 | + /** |
|
1349 | + * admin_footer_global |
|
1350 | + * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages. |
|
1351 | + * |
|
1352 | + * @access public |
|
1353 | + * @return void |
|
1354 | + */ |
|
1355 | + public function admin_footer_global() |
|
1356 | + { |
|
1357 | + //dialog container for dialog helper |
|
1358 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
1359 | + $d_cont .= '<div class="ee-notices"></div>'; |
|
1360 | + $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
|
1361 | + $d_cont .= '</div>'; |
|
1362 | + echo $d_cont; |
|
1363 | + //help tour stuff? |
|
1364 | + if (isset($this->_help_tour[$this->_req_action])) { |
|
1365 | + echo implode('<br />', $this->_help_tour[$this->_req_action]); |
|
1366 | + } |
|
1367 | + //current set timezone for timezone js |
|
1368 | + echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
1369 | + } |
|
1370 | + |
|
1371 | + |
|
1372 | + |
|
1373 | + /** |
|
1374 | + * This function sees if there is a method for help popup content existing for the given route. If there is then we'll use the retrieved array to output the content using the template. |
|
1375 | + * For child classes: |
|
1376 | + * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for |
|
1377 | + * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()" So if you are setting help content for the |
|
1378 | + * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method. You must prepare and return an array in the following format array( |
|
1379 | + * 'help_trigger_id' => array( |
|
1380 | + * 'title' => __('localized title for popup', 'event_espresso'), |
|
1381 | + * 'content' => __('localized content for popup', 'event_espresso') |
|
1382 | + * ) |
|
1383 | + * ); |
|
1384 | + * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route. |
|
1385 | + * |
|
1386 | + * @access protected |
|
1387 | + * @return string content |
|
1388 | + */ |
|
1389 | + protected function _set_help_popup_content($help_array = array(), $display = false) |
|
1390 | + { |
|
1391 | + $content = ''; |
|
1392 | + $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
|
1393 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
1394 | + //loop through the array and setup content |
|
1395 | + foreach ($help_array as $trigger => $help) { |
|
1396 | + //make sure the array is setup properly |
|
1397 | + if ( ! isset($help['title']) || ! isset($help['content'])) { |
|
1398 | + throw new EE_Error(__('Does not look like the popup content array has been setup correctly. Might want to double check that. Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class', |
|
1399 | + 'event_espresso')); |
|
1400 | + } |
|
1401 | + //we're good so let'd setup the template vars and then assign parsed template content to our content. |
|
1402 | + $template_args = array( |
|
1403 | + 'help_popup_id' => $trigger, |
|
1404 | + 'help_popup_title' => $help['title'], |
|
1405 | + 'help_popup_content' => $help['content'], |
|
1406 | + ); |
|
1407 | + $content .= EEH_Template::display_template($template_path, $template_args, true); |
|
1408 | + } |
|
1409 | + if ($display) { |
|
1410 | + echo $content; |
|
1411 | + } else { |
|
1412 | + return $content; |
|
1413 | + } |
|
1414 | + } |
|
1415 | + |
|
1416 | + |
|
1417 | + |
|
1418 | + /** |
|
1419 | + * All this does is retrive the help content array if set by the EE_Admin_Page child |
|
1420 | + * |
|
1421 | + * @access private |
|
1422 | + * @return array properly formatted array for help popup content |
|
1423 | + */ |
|
1424 | + private function _get_help_content() |
|
1425 | + { |
|
1426 | + //what is the method we're looking for? |
|
1427 | + $method_name = '_help_popup_content_' . $this->_req_action; |
|
1428 | + //if method doesn't exist let's get out. |
|
1429 | + if ( ! method_exists($this, $method_name)) { |
|
1430 | + return array(); |
|
1431 | + } |
|
1432 | + //k we're good to go let's retrieve the help array |
|
1433 | + $help_array = call_user_func(array($this, $method_name)); |
|
1434 | + //make sure we've got an array! |
|
1435 | + if ( ! is_array($help_array)) { |
|
1436 | + throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso')); |
|
1437 | + } |
|
1438 | + return $help_array; |
|
1439 | + } |
|
1440 | + |
|
1441 | + |
|
1442 | + |
|
1443 | + /** |
|
1444 | + * EE Admin Pages can use this to set a properly formatted trigger for a help popup. |
|
1445 | + * By default the trigger html is printed. Otherwise it can be returned if the $display flag is set "false" |
|
1446 | + * See comments made on the _set_help_content method for understanding other parts to the help popup tool. |
|
1447 | + * |
|
1448 | + * @access protected |
|
1449 | + * @param string $trigger_id reference for retrieving the trigger content for the popup |
|
1450 | + * @param boolean $display if false then we return the trigger string |
|
1451 | + * @param array $dimensions an array of dimensions for the box (array(h,w)) |
|
1452 | + * @return string |
|
1453 | + */ |
|
1454 | + protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640')) |
|
1455 | + { |
|
1456 | + if (defined('DOING_AJAX')) { |
|
1457 | + return; |
|
1458 | + } |
|
1459 | + //let's check and see if there is any content set for this popup. If there isn't then we'll include a default title and content so that developers know something needs to be corrected |
|
1460 | + $help_array = $this->_get_help_content(); |
|
1461 | + $help_content = ''; |
|
1462 | + if (empty($help_array) || ! isset($help_array[$trigger_id])) { |
|
1463 | + $help_array[$trigger_id] = array( |
|
1464 | + 'title' => __('Missing Content', 'event_espresso'), |
|
1465 | + 'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)', |
|
1466 | + 'event_espresso'), |
|
1467 | + ); |
|
1468 | + $help_content = $this->_set_help_popup_content($help_array, false); |
|
1469 | + } |
|
1470 | + //let's setup the trigger |
|
1471 | + $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
1472 | + $content = $content . $help_content; |
|
1473 | + if ($display) { |
|
1474 | + echo $content; |
|
1475 | + } else { |
|
1476 | + return $content; |
|
1477 | + } |
|
1478 | + } |
|
1479 | + |
|
1480 | + |
|
1481 | + |
|
1482 | + /** |
|
1483 | + * _add_global_screen_options |
|
1484 | + * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so. |
|
1485 | + * This particular method will add_screen_options on ALL EE_Admin Pages |
|
1486 | + * |
|
1487 | + * @link http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/ |
|
1488 | + * see also WP_Screen object documents... |
|
1489 | + * @link http://codex.wordpress.org/Class_Reference/WP_Screen |
|
1490 | + * @abstract |
|
1491 | + * @access private |
|
1492 | + * @return void |
|
1493 | + */ |
|
1494 | + private function _add_global_screen_options() |
|
1495 | + { |
|
1496 | + } |
|
1497 | + |
|
1498 | + |
|
1499 | + |
|
1500 | + /** |
|
1501 | + * _add_global_feature_pointers |
|
1502 | + * This method is used for implementing any "feature pointers" (using built-in WP styling js). |
|
1503 | + * This particular method will implement feature pointers for ALL EE_Admin pages. |
|
1504 | + * Note: this is just a placeholder for now. Implementation will come down the road |
|
1505 | + * |
|
1506 | + * @see WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see: |
|
1507 | + * @link http://eamann.com/tech/wordpress-portland/ |
|
1508 | + * @abstract |
|
1509 | + * @access protected |
|
1510 | + * @return void |
|
1511 | + */ |
|
1512 | + private function _add_global_feature_pointers() |
|
1513 | + { |
|
1514 | + } |
|
1515 | + |
|
1516 | + |
|
1517 | + |
|
1518 | + /** |
|
1519 | + * load_global_scripts_styles |
|
1520 | + * The scripts and styles enqueued in here will be loaded on every EE Admin page |
|
1521 | + * |
|
1522 | + * @return void |
|
1523 | + */ |
|
1524 | + public function load_global_scripts_styles() |
|
1525 | + { |
|
1526 | + /** STYLES **/ |
|
1527 | + // add debugging styles |
|
1528 | + if (WP_DEBUG) { |
|
1529 | + add_action('admin_head', array($this, 'add_xdebug_style')); |
|
1530 | + } |
|
1531 | + //register all styles |
|
1532 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
1533 | + wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
1534 | + //helpers styles |
|
1535 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
1536 | + //enqueue global styles |
|
1537 | + wp_enqueue_style('ee-admin-css'); |
|
1538 | + /** SCRIPTS **/ |
|
1539 | + //register all scripts |
|
1540 | + wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1541 | + wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
1542 | + wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
1543 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
1544 | + // register jQuery Validate - see /includes/functions/wp_hooks.php |
|
1545 | + add_filter('FHEE_load_jquery_validate', '__return_true'); |
|
1546 | + add_filter('FHEE_load_joyride', '__return_true'); |
|
1547 | + //script for sorting tables |
|
1548 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
1549 | + //script for parsing uri's |
|
1550 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1551 | + //and parsing associative serialized form elements |
|
1552 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1553 | + //helpers scripts |
|
1554 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
1555 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
1556 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
1557 | + wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
1558 | + //google charts |
|
1559 | + wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
|
1560 | + //enqueue global scripts |
|
1561 | + //taking care of metaboxes |
|
1562 | + if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) { |
|
1563 | + wp_enqueue_script('dashboard'); |
|
1564 | + } |
|
1565 | + //enqueue thickbox for ee help popups. default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups |
|
1566 | + if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) { |
|
1567 | + wp_enqueue_script('ee_admin_js'); |
|
1568 | + wp_enqueue_style('ee-admin-css'); |
|
1569 | + } |
|
1570 | + //localize script for ajax lazy loading |
|
1571 | + $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content')); |
|
1572 | + wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids); |
|
1573 | + /** |
|
1574 | + * help tour stuff |
|
1575 | + */ |
|
1576 | + if ( ! empty($this->_help_tour)) { |
|
1577 | + //register the js for kicking things off |
|
1578 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
1579 | + //setup tours for the js tour object |
|
1580 | + foreach ($this->_help_tour['tours'] as $tour) { |
|
1581 | + $tours[] = array( |
|
1582 | + 'id' => $tour->get_slug(), |
|
1583 | + 'options' => $tour->get_options(), |
|
1584 | + ); |
|
1585 | + } |
|
1586 | + wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours)); |
|
1587 | + //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour |
|
1588 | + } |
|
1589 | + } |
|
1590 | + |
|
1591 | + |
|
1592 | + |
|
1593 | + /** |
|
1594 | + * admin_footer_scripts_eei18n_js_strings |
|
1595 | + * |
|
1596 | + * @access public |
|
1597 | + * @return void |
|
1598 | + */ |
|
1599 | + public function admin_footer_scripts_eei18n_js_strings() |
|
1600 | + { |
|
1601 | + EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL; |
|
1602 | + EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso'); |
|
1603 | + EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso'); |
|
1604 | + EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso'); |
|
1605 | + EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso'); |
|
1606 | + EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso'); |
|
1607 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1608 | + EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso'); |
|
1609 | + EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso'); |
|
1610 | + EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso'); |
|
1611 | + EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso'); |
|
1612 | + EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso'); |
|
1613 | + EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso'); |
|
1614 | + EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso'); |
|
1615 | + EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso'); |
|
1616 | + EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso'); |
|
1617 | + EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso'); |
|
1618 | + EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso'); |
|
1619 | + EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso'); |
|
1620 | + EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso'); |
|
1621 | + EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso'); |
|
1622 | + EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso'); |
|
1623 | + EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso'); |
|
1624 | + EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso'); |
|
1625 | + EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso'); |
|
1626 | + EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso'); |
|
1627 | + EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso'); |
|
1628 | + EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso'); |
|
1629 | + EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso'); |
|
1630 | + EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso'); |
|
1631 | + EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso'); |
|
1632 | + EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso'); |
|
1633 | + EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso'); |
|
1634 | + EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso'); |
|
1635 | + EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso'); |
|
1636 | + EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso'); |
|
1637 | + EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso'); |
|
1638 | + EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso'); |
|
1639 | + EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso'); |
|
1640 | + EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso'); |
|
1641 | + //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance |
|
1642 | + //admin page when in maintenance mode and ee_admin_js is not loaded then. This works everywhere else because |
|
1643 | + //espresso_core is listed as a dependency of ee_admin_js. |
|
1644 | + wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings); |
|
1645 | + } |
|
1646 | + |
|
1647 | + |
|
1648 | + |
|
1649 | + /** |
|
1650 | + * load enhanced xdebug styles for ppl with failing eyesight |
|
1651 | + * |
|
1652 | + * @access public |
|
1653 | + * @return void |
|
1654 | + */ |
|
1655 | + public function add_xdebug_style() |
|
1656 | + { |
|
1657 | + echo '<style>.xdebug-error { font-size:1.5em; }</style>'; |
|
1658 | + } |
|
1659 | + |
|
1660 | + |
|
1661 | + /************************/ |
|
1662 | + /** LIST TABLE METHODS **/ |
|
1663 | + /************************/ |
|
1664 | + /** |
|
1665 | + * this sets up the list table if the current view requires it. |
|
1666 | + * |
|
1667 | + * @access protected |
|
1668 | + * @return void |
|
1669 | + */ |
|
1670 | + protected function _set_list_table() |
|
1671 | + { |
|
1672 | + //first is this a list_table view? |
|
1673 | + if ( ! isset($this->_route_config['list_table'])) { |
|
1674 | + return; |
|
1675 | + } //not a list_table view so get out. |
|
1676 | + //list table functions are per view specific (because some admin pages might have more than one listtable!) |
|
1677 | + if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) { |
|
1678 | + //user error msg |
|
1679 | + $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
|
1680 | + //developer error msg |
|
1681 | + $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
1682 | + $this->_req_action, '_set_list_table_views_' . $this->_req_action); |
|
1683 | + throw new EE_Error($error_msg); |
|
1684 | + } |
|
1685 | + //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
|
1686 | + $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views); |
|
1687 | + $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views); |
|
1688 | + $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
|
1689 | + $this->_set_list_table_view(); |
|
1690 | + $this->_set_list_table_object(); |
|
1691 | + } |
|
1692 | + |
|
1693 | + |
|
1694 | + |
|
1695 | + /** |
|
1696 | + * set current view for List Table |
|
1697 | + * |
|
1698 | + * @access public |
|
1699 | + * @return array |
|
1700 | + */ |
|
1701 | + protected function _set_list_table_view() |
|
1702 | + { |
|
1703 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1704 | + // looking at active items or dumpster diving ? |
|
1705 | + if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) { |
|
1706 | + $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all'; |
|
1707 | + } else { |
|
1708 | + $this->_view = sanitize_key($this->_req_data['status']); |
|
1709 | + } |
|
1710 | + } |
|
1711 | + |
|
1712 | + |
|
1713 | + |
|
1714 | + /** |
|
1715 | + * _set_list_table_object |
|
1716 | + * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of. |
|
1717 | + * |
|
1718 | + * @throws \EE_Error |
|
1719 | + */ |
|
1720 | + protected function _set_list_table_object() |
|
1721 | + { |
|
1722 | + if (isset($this->_route_config['list_table'])) { |
|
1723 | + if ( ! class_exists($this->_route_config['list_table'])) { |
|
1724 | + throw new EE_Error( |
|
1725 | + sprintf( |
|
1726 | + __( |
|
1727 | + 'The %s class defined for the list table does not exist. Please check the spelling of the class ref in the $_page_config property on %s.', |
|
1728 | + 'event_espresso' |
|
1729 | + ), |
|
1730 | + $this->_route_config['list_table'], |
|
1731 | + get_class($this) |
|
1732 | + ) |
|
1733 | + ); |
|
1734 | + } |
|
1735 | + $list_table = $this->_route_config['list_table']; |
|
1736 | + $this->_list_table_object = new $list_table($this); |
|
1737 | + } |
|
1738 | + } |
|
1739 | + |
|
1740 | + |
|
1741 | + |
|
1742 | + /** |
|
1743 | + * get_list_table_view_RLs - get it? View RL ?? VU-RL??? URL ?? |
|
1744 | + * |
|
1745 | + * @param array $extra_query_args Optional. An array of extra query args to add to the generated |
|
1746 | + * urls. The array should be indexed by the view it is being |
|
1747 | + * added to. |
|
1748 | + * @return array |
|
1749 | + */ |
|
1750 | + public function get_list_table_view_RLs($extra_query_args = array()) |
|
1751 | + { |
|
1752 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1753 | + if (empty($this->_views)) { |
|
1754 | + $this->_views = array(); |
|
1755 | + } |
|
1756 | + // cycle thru views |
|
1757 | + foreach ($this->_views as $key => $view) { |
|
1758 | + $query_args = array(); |
|
1759 | + // check for current view |
|
1760 | + $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
|
1761 | + $query_args['action'] = $this->_req_action; |
|
1762 | + $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
1763 | + $query_args['status'] = $view['slug']; |
|
1764 | + //merge any other arguments sent in. |
|
1765 | + if (isset($extra_query_args[$view['slug']])) { |
|
1766 | + $query_args = array_merge($query_args, $extra_query_args[$view['slug']]); |
|
1767 | + } |
|
1768 | + $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
|
1769 | + } |
|
1770 | + return $this->_views; |
|
1771 | + } |
|
1772 | + |
|
1773 | + |
|
1774 | + |
|
1775 | + /** |
|
1776 | + * _entries_per_page_dropdown |
|
1777 | + * generates a drop down box for selecting the number of visiable rows in an admin page list table |
|
1778 | + * |
|
1779 | + * @todo : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it. |
|
1780 | + * @access protected |
|
1781 | + * @param int $max_entries total number of rows in the table |
|
1782 | + * @return string |
|
1783 | + */ |
|
1784 | + protected function _entries_per_page_dropdown($max_entries = false) |
|
1785 | + { |
|
1786 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1787 | + $values = array(10, 25, 50, 100); |
|
1788 | + $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10; |
|
1789 | + if ($max_entries) { |
|
1790 | + $values[] = $max_entries; |
|
1791 | + sort($values); |
|
1792 | + } |
|
1793 | + $entries_per_page_dropdown = ' |
|
1794 | 1794 | <div id="entries-per-page-dv" class="alignleft actions"> |
1795 | 1795 | <label class="hide-if-no-js"> |
1796 | 1796 | Show |
1797 | 1797 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
1798 | - foreach ($values as $value) { |
|
1799 | - if ($value < $max_entries) { |
|
1800 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1801 | - $entries_per_page_dropdown .= ' |
|
1798 | + foreach ($values as $value) { |
|
1799 | + if ($value < $max_entries) { |
|
1800 | + $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1801 | + $entries_per_page_dropdown .= ' |
|
1802 | 1802 | <option value="' . $value . '"' . $selected . '>' . $value . ' </option>'; |
1803 | - } |
|
1804 | - } |
|
1805 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1806 | - $entries_per_page_dropdown .= ' |
|
1803 | + } |
|
1804 | + } |
|
1805 | + $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
1806 | + $entries_per_page_dropdown .= ' |
|
1807 | 1807 | <option value="' . $max_entries . '"' . $selected . '>All </option>'; |
1808 | - $entries_per_page_dropdown .= ' |
|
1808 | + $entries_per_page_dropdown .= ' |
|
1809 | 1809 | </select> |
1810 | 1810 | entries |
1811 | 1811 | </label> |
1812 | 1812 | <input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" > |
1813 | 1813 | </div> |
1814 | 1814 | '; |
1815 | - return $entries_per_page_dropdown; |
|
1816 | - } |
|
1817 | - |
|
1818 | - |
|
1819 | - |
|
1820 | - /** |
|
1821 | - * _set_search_attributes |
|
1822 | - * |
|
1823 | - * @access protected |
|
1824 | - * @return void |
|
1825 | - */ |
|
1826 | - public function _set_search_attributes() |
|
1827 | - { |
|
1828 | - $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
1829 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
1830 | - } |
|
1831 | - |
|
1832 | - /*** END LIST TABLE METHODS **/ |
|
1833 | - /*****************************/ |
|
1834 | - /** |
|
1835 | - * _add_registered_metaboxes |
|
1836 | - * this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array. |
|
1837 | - * |
|
1838 | - * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
|
1839 | - * @access private |
|
1840 | - * @return void |
|
1841 | - */ |
|
1842 | - private function _add_registered_meta_boxes() |
|
1843 | - { |
|
1844 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1845 | - //we only add meta boxes if the page_route calls for it |
|
1846 | - if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) |
|
1847 | - && is_array( |
|
1848 | - $this->_route_config['metaboxes'] |
|
1849 | - ) |
|
1850 | - ) { |
|
1851 | - // this simply loops through the callbacks provided |
|
1852 | - // and checks if there is a corresponding callback registered by the child |
|
1853 | - // if there is then we go ahead and process the metabox loader. |
|
1854 | - foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
1855 | - // first check for Closures |
|
1856 | - if ($metabox_callback instanceof Closure) { |
|
1857 | - $result = $metabox_callback(); |
|
1858 | - } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) { |
|
1859 | - $result = call_user_func(array($metabox_callback[0], $metabox_callback[1])); |
|
1860 | - } else { |
|
1861 | - $result = call_user_func(array($this, &$metabox_callback)); |
|
1862 | - } |
|
1863 | - if ($result === false) { |
|
1864 | - // user error msg |
|
1865 | - $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
1866 | - // developer error msg |
|
1867 | - $error_msg .= '||' . sprintf( |
|
1868 | - __( |
|
1869 | - 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
|
1870 | - 'event_espresso' |
|
1871 | - ), |
|
1872 | - $metabox_callback |
|
1873 | - ); |
|
1874 | - throw new EE_Error($error_msg); |
|
1875 | - } |
|
1876 | - } |
|
1877 | - } |
|
1878 | - } |
|
1879 | - |
|
1880 | - |
|
1881 | - |
|
1882 | - /** |
|
1883 | - * _add_screen_columns |
|
1884 | - * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page. |
|
1885 | - * |
|
1886 | - * @access private |
|
1887 | - * @return void |
|
1888 | - */ |
|
1889 | - private function _add_screen_columns() |
|
1890 | - { |
|
1891 | - if ( |
|
1892 | - is_array($this->_route_config) |
|
1893 | - && isset($this->_route_config['columns']) |
|
1894 | - && is_array($this->_route_config['columns']) |
|
1895 | - && count($this->_route_config['columns']) === 2 |
|
1896 | - ) { |
|
1897 | - add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1])); |
|
1898 | - $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
|
1899 | - $screen_id = $this->_current_screen->id; |
|
1900 | - $screen_columns = (int)get_user_option("screen_layout_$screen_id"); |
|
1901 | - $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
1902 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
1903 | - $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
1904 | - $this->_template_args['screen'] = $this->_current_screen; |
|
1905 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
1906 | - //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
|
1907 | - $this->_route_config['has_metaboxes'] = true; |
|
1908 | - } |
|
1909 | - } |
|
1910 | - |
|
1911 | - |
|
1912 | - |
|
1913 | - /**********************************/ |
|
1914 | - /** GLOBALLY AVAILABLE METABOXES **/ |
|
1915 | - /** |
|
1916 | - * In this section we put any globally available EE metaboxes for all EE Admin pages. They are called by simply referencing the callback in the _page_config array property. This way you can be very specific about what pages these get |
|
1917 | - * loaded on. |
|
1918 | - */ |
|
1919 | - private function _espresso_news_post_box() |
|
1920 | - { |
|
1921 | - $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
1922 | - add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
1923 | - $this, |
|
1924 | - 'espresso_news_post_box', |
|
1925 | - ), $this->_wp_page_slug, 'side'); |
|
1926 | - } |
|
1927 | - |
|
1928 | - |
|
1929 | - |
|
1930 | - /** |
|
1931 | - * Code for setting up espresso ratings request metabox. |
|
1932 | - */ |
|
1933 | - protected function _espresso_ratings_request() |
|
1934 | - { |
|
1935 | - if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
1936 | - return ''; |
|
1937 | - } |
|
1938 | - $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
1939 | - add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
1940 | - $this, |
|
1941 | - 'espresso_ratings_request', |
|
1942 | - ), $this->_wp_page_slug, 'side'); |
|
1943 | - } |
|
1944 | - |
|
1945 | - |
|
1946 | - |
|
1947 | - /** |
|
1948 | - * Code for setting up espresso ratings request metabox content. |
|
1949 | - */ |
|
1950 | - public function espresso_ratings_request() |
|
1951 | - { |
|
1952 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
1953 | - EEH_Template::display_template($template_path, array()); |
|
1954 | - } |
|
1955 | - |
|
1956 | - |
|
1957 | - |
|
1958 | - public static function cached_rss_display($rss_id, $url) |
|
1959 | - { |
|
1960 | - $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading…') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; |
|
1961 | - $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
1962 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
1963 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
1964 | - $post = '</div>' . "\n"; |
|
1965 | - $cache_key = 'ee_rss_' . md5($rss_id); |
|
1966 | - if (false != ($output = get_transient($cache_key))) { |
|
1967 | - echo $pre . $output . $post; |
|
1968 | - return true; |
|
1969 | - } |
|
1970 | - if ( ! $doing_ajax) { |
|
1971 | - echo $pre . $loading . $post; |
|
1972 | - return false; |
|
1973 | - } |
|
1974 | - ob_start(); |
|
1975 | - wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
1976 | - set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
1977 | - return true; |
|
1978 | - } |
|
1979 | - |
|
1980 | - |
|
1981 | - |
|
1982 | - public function espresso_news_post_box() |
|
1983 | - { |
|
1984 | - ?> |
|
1815 | + return $entries_per_page_dropdown; |
|
1816 | + } |
|
1817 | + |
|
1818 | + |
|
1819 | + |
|
1820 | + /** |
|
1821 | + * _set_search_attributes |
|
1822 | + * |
|
1823 | + * @access protected |
|
1824 | + * @return void |
|
1825 | + */ |
|
1826 | + public function _set_search_attributes() |
|
1827 | + { |
|
1828 | + $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
|
1829 | + $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
1830 | + } |
|
1831 | + |
|
1832 | + /*** END LIST TABLE METHODS **/ |
|
1833 | + /*****************************/ |
|
1834 | + /** |
|
1835 | + * _add_registered_metaboxes |
|
1836 | + * this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array. |
|
1837 | + * |
|
1838 | + * @link http://codex.wordpress.org/Function_Reference/add_meta_box |
|
1839 | + * @access private |
|
1840 | + * @return void |
|
1841 | + */ |
|
1842 | + private function _add_registered_meta_boxes() |
|
1843 | + { |
|
1844 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1845 | + //we only add meta boxes if the page_route calls for it |
|
1846 | + if (is_array($this->_route_config) && isset($this->_route_config['metaboxes']) |
|
1847 | + && is_array( |
|
1848 | + $this->_route_config['metaboxes'] |
|
1849 | + ) |
|
1850 | + ) { |
|
1851 | + // this simply loops through the callbacks provided |
|
1852 | + // and checks if there is a corresponding callback registered by the child |
|
1853 | + // if there is then we go ahead and process the metabox loader. |
|
1854 | + foreach ($this->_route_config['metaboxes'] as $metabox_callback) { |
|
1855 | + // first check for Closures |
|
1856 | + if ($metabox_callback instanceof Closure) { |
|
1857 | + $result = $metabox_callback(); |
|
1858 | + } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) { |
|
1859 | + $result = call_user_func(array($metabox_callback[0], $metabox_callback[1])); |
|
1860 | + } else { |
|
1861 | + $result = call_user_func(array($this, &$metabox_callback)); |
|
1862 | + } |
|
1863 | + if ($result === false) { |
|
1864 | + // user error msg |
|
1865 | + $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
|
1866 | + // developer error msg |
|
1867 | + $error_msg .= '||' . sprintf( |
|
1868 | + __( |
|
1869 | + 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
|
1870 | + 'event_espresso' |
|
1871 | + ), |
|
1872 | + $metabox_callback |
|
1873 | + ); |
|
1874 | + throw new EE_Error($error_msg); |
|
1875 | + } |
|
1876 | + } |
|
1877 | + } |
|
1878 | + } |
|
1879 | + |
|
1880 | + |
|
1881 | + |
|
1882 | + /** |
|
1883 | + * _add_screen_columns |
|
1884 | + * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page. |
|
1885 | + * |
|
1886 | + * @access private |
|
1887 | + * @return void |
|
1888 | + */ |
|
1889 | + private function _add_screen_columns() |
|
1890 | + { |
|
1891 | + if ( |
|
1892 | + is_array($this->_route_config) |
|
1893 | + && isset($this->_route_config['columns']) |
|
1894 | + && is_array($this->_route_config['columns']) |
|
1895 | + && count($this->_route_config['columns']) === 2 |
|
1896 | + ) { |
|
1897 | + add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1])); |
|
1898 | + $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
|
1899 | + $screen_id = $this->_current_screen->id; |
|
1900 | + $screen_columns = (int)get_user_option("screen_layout_$screen_id"); |
|
1901 | + $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
|
1902 | + $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
1903 | + $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
1904 | + $this->_template_args['screen'] = $this->_current_screen; |
|
1905 | + $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
1906 | + //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
|
1907 | + $this->_route_config['has_metaboxes'] = true; |
|
1908 | + } |
|
1909 | + } |
|
1910 | + |
|
1911 | + |
|
1912 | + |
|
1913 | + /**********************************/ |
|
1914 | + /** GLOBALLY AVAILABLE METABOXES **/ |
|
1915 | + /** |
|
1916 | + * In this section we put any globally available EE metaboxes for all EE Admin pages. They are called by simply referencing the callback in the _page_config array property. This way you can be very specific about what pages these get |
|
1917 | + * loaded on. |
|
1918 | + */ |
|
1919 | + private function _espresso_news_post_box() |
|
1920 | + { |
|
1921 | + $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso')); |
|
1922 | + add_meta_box('espresso_news_post_box', $news_box_title, array( |
|
1923 | + $this, |
|
1924 | + 'espresso_news_post_box', |
|
1925 | + ), $this->_wp_page_slug, 'side'); |
|
1926 | + } |
|
1927 | + |
|
1928 | + |
|
1929 | + |
|
1930 | + /** |
|
1931 | + * Code for setting up espresso ratings request metabox. |
|
1932 | + */ |
|
1933 | + protected function _espresso_ratings_request() |
|
1934 | + { |
|
1935 | + if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) { |
|
1936 | + return ''; |
|
1937 | + } |
|
1938 | + $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso')); |
|
1939 | + add_meta_box('espresso_ratings_request', $ratings_box_title, array( |
|
1940 | + $this, |
|
1941 | + 'espresso_ratings_request', |
|
1942 | + ), $this->_wp_page_slug, 'side'); |
|
1943 | + } |
|
1944 | + |
|
1945 | + |
|
1946 | + |
|
1947 | + /** |
|
1948 | + * Code for setting up espresso ratings request metabox content. |
|
1949 | + */ |
|
1950 | + public function espresso_ratings_request() |
|
1951 | + { |
|
1952 | + $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
1953 | + EEH_Template::display_template($template_path, array()); |
|
1954 | + } |
|
1955 | + |
|
1956 | + |
|
1957 | + |
|
1958 | + public static function cached_rss_display($rss_id, $url) |
|
1959 | + { |
|
1960 | + $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading…') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; |
|
1961 | + $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
|
1962 | + $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
1963 | + $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
1964 | + $post = '</div>' . "\n"; |
|
1965 | + $cache_key = 'ee_rss_' . md5($rss_id); |
|
1966 | + if (false != ($output = get_transient($cache_key))) { |
|
1967 | + echo $pre . $output . $post; |
|
1968 | + return true; |
|
1969 | + } |
|
1970 | + if ( ! $doing_ajax) { |
|
1971 | + echo $pre . $loading . $post; |
|
1972 | + return false; |
|
1973 | + } |
|
1974 | + ob_start(); |
|
1975 | + wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5)); |
|
1976 | + set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS); |
|
1977 | + return true; |
|
1978 | + } |
|
1979 | + |
|
1980 | + |
|
1981 | + |
|
1982 | + public function espresso_news_post_box() |
|
1983 | + { |
|
1984 | + ?> |
|
1985 | 1985 | <div class="padding"> |
1986 | 1986 | <div id="espresso_news_post_box_content" class="infolinks"> |
1987 | 1987 | <?php |
1988 | - // Get RSS Feed(s) |
|
1989 | - $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
1990 | - $url = urlencode($feed_url); |
|
1991 | - self::cached_rss_display('espresso_news_post_box_content', $url); |
|
1992 | - ?> |
|
1988 | + // Get RSS Feed(s) |
|
1989 | + $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/'); |
|
1990 | + $url = urlencode($feed_url); |
|
1991 | + self::cached_rss_display('espresso_news_post_box_content', $url); |
|
1992 | + ?> |
|
1993 | 1993 | </div> |
1994 | 1994 | <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?> |
1995 | 1995 | </div> |
1996 | 1996 | <?php |
1997 | - } |
|
1998 | - |
|
1999 | - |
|
2000 | - |
|
2001 | - private function _espresso_links_post_box() |
|
2002 | - { |
|
2003 | - //Hiding until we actually have content to put in here... |
|
2004 | - //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side'); |
|
2005 | - } |
|
2006 | - |
|
2007 | - |
|
2008 | - |
|
2009 | - public function espresso_links_post_box() |
|
2010 | - { |
|
2011 | - //Hiding until we actually have content to put in here... |
|
2012 | - //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'; |
|
2013 | - //EEH_Template::display_template( $templatepath ); |
|
2014 | - } |
|
2015 | - |
|
2016 | - |
|
2017 | - |
|
2018 | - protected function _espresso_sponsors_post_box() |
|
2019 | - { |
|
2020 | - $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true); |
|
2021 | - if ($show_sponsors) { |
|
2022 | - add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2023 | - } |
|
2024 | - } |
|
2025 | - |
|
2026 | - |
|
2027 | - |
|
2028 | - public function espresso_sponsors_post_box() |
|
2029 | - { |
|
2030 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2031 | - EEH_Template::display_template($templatepath); |
|
2032 | - } |
|
2033 | - |
|
2034 | - |
|
2035 | - |
|
2036 | - private function _publish_post_box() |
|
2037 | - { |
|
2038 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
2039 | - //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
|
2040 | - if ( ! empty($this->_labels['publishbox'])) { |
|
2041 | - $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
2042 | - } else { |
|
2043 | - $box_label = __('Publish', 'event_espresso'); |
|
2044 | - } |
|
2045 | - $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
2046 | - add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
2047 | - } |
|
2048 | - |
|
2049 | - |
|
2050 | - |
|
2051 | - public function editor_overview() |
|
2052 | - { |
|
2053 | - //if we have extra content set let's add it in if not make sure its empty |
|
2054 | - $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2055 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
2056 | - echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2057 | - } |
|
2058 | - |
|
2059 | - |
|
2060 | - /** end of globally available metaboxes section **/ |
|
2061 | - /*************************************************/ |
|
2062 | - /** |
|
2063 | - * Public wrapper for the protected method. Allows plugins/addons to externally call the |
|
2064 | - * protected method. |
|
2065 | - * |
|
2066 | - * @see $this->_set_publish_post_box_vars for param details |
|
2067 | - * @since 4.6.0 |
|
2068 | - */ |
|
2069 | - public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) |
|
2070 | - { |
|
2071 | - $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
2072 | - } |
|
2073 | - |
|
2074 | - |
|
2075 | - |
|
2076 | - /** |
|
2077 | - * Sets the _template_args arguments used by the _publish_post_box shortcut |
|
2078 | - * Note: currently there is no validation for this. However if you want the delete button, the |
|
2079 | - * save, and save and close buttons to work properly, then you will want to include a |
|
2080 | - * values for the name and id arguments. |
|
2081 | - * |
|
2082 | - * @todo Add in validation for name/id arguments. |
|
2083 | - * @param string $name key used for the action ID (i.e. event_id) |
|
2084 | - * @param int $id id attached to the item published |
|
2085 | - * @param string $delete page route callback for the delete action |
|
2086 | - * @param string $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed |
|
2087 | - * @param boolean $both_btns whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button |
|
2088 | - * @throws \EE_Error |
|
2089 | - */ |
|
2090 | - protected function _set_publish_post_box_vars( |
|
2091 | - $name = '', |
|
2092 | - $id = 0, |
|
2093 | - $delete = '', |
|
2094 | - $save_close_redirect_URL = '', |
|
2095 | - $both_btns = true |
|
2096 | - ) { |
|
2097 | - // if Save & Close, use a custom redirect URL or default to the main page? |
|
2098 | - $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
2099 | - // create the Save & Close and Save buttons |
|
2100 | - $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
2101 | - //if we have extra content set let's add it in if not make sure its empty |
|
2102 | - $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2103 | - if ($delete && ! empty($id)) { |
|
2104 | - //make sure we have a default if just true is sent. |
|
2105 | - $delete = ! empty($delete) ? $delete : 'delete'; |
|
2106 | - $delete_link_args = array($name => $id); |
|
2107 | - $delete = $this->get_action_link_or_button( |
|
2108 | - $delete, |
|
2109 | - $delete, |
|
2110 | - $delete_link_args, |
|
2111 | - 'submitdelete deletion', |
|
2112 | - '', |
|
2113 | - false |
|
2114 | - ); |
|
2115 | - } |
|
2116 | - $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
2117 | - if ( ! empty($name) && ! empty($id)) { |
|
2118 | - $hidden_field_arr[$name] = array( |
|
2119 | - 'type' => 'hidden', |
|
2120 | - 'value' => $id, |
|
2121 | - ); |
|
2122 | - $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array'); |
|
2123 | - } else { |
|
2124 | - $hf = ''; |
|
2125 | - } |
|
2126 | - // add hidden field |
|
2127 | - $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
2128 | - } |
|
2129 | - |
|
2130 | - |
|
2131 | - |
|
2132 | - /** |
|
2133 | - * displays an error message to ppl who have javascript disabled |
|
2134 | - * |
|
2135 | - * @access private |
|
2136 | - * @return string |
|
2137 | - */ |
|
2138 | - private function _display_no_javascript_warning() |
|
2139 | - { |
|
2140 | - ?> |
|
1997 | + } |
|
1998 | + |
|
1999 | + |
|
2000 | + |
|
2001 | + private function _espresso_links_post_box() |
|
2002 | + { |
|
2003 | + //Hiding until we actually have content to put in here... |
|
2004 | + //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side'); |
|
2005 | + } |
|
2006 | + |
|
2007 | + |
|
2008 | + |
|
2009 | + public function espresso_links_post_box() |
|
2010 | + { |
|
2011 | + //Hiding until we actually have content to put in here... |
|
2012 | + //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'; |
|
2013 | + //EEH_Template::display_template( $templatepath ); |
|
2014 | + } |
|
2015 | + |
|
2016 | + |
|
2017 | + |
|
2018 | + protected function _espresso_sponsors_post_box() |
|
2019 | + { |
|
2020 | + $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true); |
|
2021 | + if ($show_sponsors) { |
|
2022 | + add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side'); |
|
2023 | + } |
|
2024 | + } |
|
2025 | + |
|
2026 | + |
|
2027 | + |
|
2028 | + public function espresso_sponsors_post_box() |
|
2029 | + { |
|
2030 | + $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
2031 | + EEH_Template::display_template($templatepath); |
|
2032 | + } |
|
2033 | + |
|
2034 | + |
|
2035 | + |
|
2036 | + private function _publish_post_box() |
|
2037 | + { |
|
2038 | + $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
2039 | + //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
|
2040 | + if ( ! empty($this->_labels['publishbox'])) { |
|
2041 | + $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
|
2042 | + } else { |
|
2043 | + $box_label = __('Publish', 'event_espresso'); |
|
2044 | + } |
|
2045 | + $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this); |
|
2046 | + add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high'); |
|
2047 | + } |
|
2048 | + |
|
2049 | + |
|
2050 | + |
|
2051 | + public function editor_overview() |
|
2052 | + { |
|
2053 | + //if we have extra content set let's add it in if not make sure its empty |
|
2054 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2055 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
2056 | + echo EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2057 | + } |
|
2058 | + |
|
2059 | + |
|
2060 | + /** end of globally available metaboxes section **/ |
|
2061 | + /*************************************************/ |
|
2062 | + /** |
|
2063 | + * Public wrapper for the protected method. Allows plugins/addons to externally call the |
|
2064 | + * protected method. |
|
2065 | + * |
|
2066 | + * @see $this->_set_publish_post_box_vars for param details |
|
2067 | + * @since 4.6.0 |
|
2068 | + */ |
|
2069 | + public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true) |
|
2070 | + { |
|
2071 | + $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns); |
|
2072 | + } |
|
2073 | + |
|
2074 | + |
|
2075 | + |
|
2076 | + /** |
|
2077 | + * Sets the _template_args arguments used by the _publish_post_box shortcut |
|
2078 | + * Note: currently there is no validation for this. However if you want the delete button, the |
|
2079 | + * save, and save and close buttons to work properly, then you will want to include a |
|
2080 | + * values for the name and id arguments. |
|
2081 | + * |
|
2082 | + * @todo Add in validation for name/id arguments. |
|
2083 | + * @param string $name key used for the action ID (i.e. event_id) |
|
2084 | + * @param int $id id attached to the item published |
|
2085 | + * @param string $delete page route callback for the delete action |
|
2086 | + * @param string $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed |
|
2087 | + * @param boolean $both_btns whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button |
|
2088 | + * @throws \EE_Error |
|
2089 | + */ |
|
2090 | + protected function _set_publish_post_box_vars( |
|
2091 | + $name = '', |
|
2092 | + $id = 0, |
|
2093 | + $delete = '', |
|
2094 | + $save_close_redirect_URL = '', |
|
2095 | + $both_btns = true |
|
2096 | + ) { |
|
2097 | + // if Save & Close, use a custom redirect URL or default to the main page? |
|
2098 | + $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url; |
|
2099 | + // create the Save & Close and Save buttons |
|
2100 | + $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL); |
|
2101 | + //if we have extra content set let's add it in if not make sure its empty |
|
2102 | + $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
|
2103 | + if ($delete && ! empty($id)) { |
|
2104 | + //make sure we have a default if just true is sent. |
|
2105 | + $delete = ! empty($delete) ? $delete : 'delete'; |
|
2106 | + $delete_link_args = array($name => $id); |
|
2107 | + $delete = $this->get_action_link_or_button( |
|
2108 | + $delete, |
|
2109 | + $delete, |
|
2110 | + $delete_link_args, |
|
2111 | + 'submitdelete deletion', |
|
2112 | + '', |
|
2113 | + false |
|
2114 | + ); |
|
2115 | + } |
|
2116 | + $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : ''; |
|
2117 | + if ( ! empty($name) && ! empty($id)) { |
|
2118 | + $hidden_field_arr[$name] = array( |
|
2119 | + 'type' => 'hidden', |
|
2120 | + 'value' => $id, |
|
2121 | + ); |
|
2122 | + $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array'); |
|
2123 | + } else { |
|
2124 | + $hf = ''; |
|
2125 | + } |
|
2126 | + // add hidden field |
|
2127 | + $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf; |
|
2128 | + } |
|
2129 | + |
|
2130 | + |
|
2131 | + |
|
2132 | + /** |
|
2133 | + * displays an error message to ppl who have javascript disabled |
|
2134 | + * |
|
2135 | + * @access private |
|
2136 | + * @return string |
|
2137 | + */ |
|
2138 | + private function _display_no_javascript_warning() |
|
2139 | + { |
|
2140 | + ?> |
|
2141 | 2141 | <noscript> |
2142 | 2142 | <div id="no-js-message" class="error"> |
2143 | 2143 | <p style="font-size:1.3em;"> |
@@ -2147,1231 +2147,1231 @@ discard block |
||
2147 | 2147 | </div> |
2148 | 2148 | </noscript> |
2149 | 2149 | <?php |
2150 | - } |
|
2150 | + } |
|
2151 | 2151 | |
2152 | 2152 | |
2153 | 2153 | |
2154 | - /** |
|
2155 | - * displays espresso success and/or error notices |
|
2156 | - * |
|
2157 | - * @access private |
|
2158 | - * @return string |
|
2159 | - */ |
|
2160 | - private function _display_espresso_notices() |
|
2161 | - { |
|
2162 | - $notices = $this->_get_transient(true); |
|
2163 | - echo stripslashes($notices); |
|
2164 | - } |
|
2154 | + /** |
|
2155 | + * displays espresso success and/or error notices |
|
2156 | + * |
|
2157 | + * @access private |
|
2158 | + * @return string |
|
2159 | + */ |
|
2160 | + private function _display_espresso_notices() |
|
2161 | + { |
|
2162 | + $notices = $this->_get_transient(true); |
|
2163 | + echo stripslashes($notices); |
|
2164 | + } |
|
2165 | 2165 | |
2166 | 2166 | |
2167 | 2167 | |
2168 | - /** |
|
2169 | - * spinny things pacify the masses |
|
2170 | - * |
|
2171 | - * @access private |
|
2172 | - * @return string |
|
2173 | - */ |
|
2174 | - protected function _add_admin_page_ajax_loading_img() |
|
2175 | - { |
|
2176 | - ?> |
|
2168 | + /** |
|
2169 | + * spinny things pacify the masses |
|
2170 | + * |
|
2171 | + * @access private |
|
2172 | + * @return string |
|
2173 | + */ |
|
2174 | + protected function _add_admin_page_ajax_loading_img() |
|
2175 | + { |
|
2176 | + ?> |
|
2177 | 2177 | <div id="espresso-ajax-loading" class="ajax-loading-grey"> |
2178 | 2178 | <span class="ee-spinner ee-spin"></span><span class="hidden"><?php _e('loading...', 'event_espresso'); ?></span> |
2179 | 2179 | </div> |
2180 | 2180 | <?php |
2181 | - } |
|
2181 | + } |
|
2182 | 2182 | |
2183 | 2183 | |
2184 | 2184 | |
2185 | - /** |
|
2186 | - * add admin page overlay for modal boxes |
|
2187 | - * |
|
2188 | - * @access private |
|
2189 | - * @return string |
|
2190 | - */ |
|
2191 | - protected function _add_admin_page_overlay() |
|
2192 | - { |
|
2193 | - ?> |
|
2185 | + /** |
|
2186 | + * add admin page overlay for modal boxes |
|
2187 | + * |
|
2188 | + * @access private |
|
2189 | + * @return string |
|
2190 | + */ |
|
2191 | + protected function _add_admin_page_overlay() |
|
2192 | + { |
|
2193 | + ?> |
|
2194 | 2194 | <div id="espresso-admin-page-overlay-dv" class=""></div> |
2195 | 2195 | <?php |
2196 | - } |
|
2197 | - |
|
2198 | - |
|
2199 | - |
|
2200 | - /** |
|
2201 | - * facade for add_meta_box |
|
2202 | - * |
|
2203 | - * @param string $action where the metabox get's displayed |
|
2204 | - * @param string $title Title of Metabox (output in metabox header) |
|
2205 | - * @param string $callback If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here. |
|
2206 | - * @param array $callback_args an array of args supplied for the metabox |
|
2207 | - * @param string $column what metabox column |
|
2208 | - * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
|
2209 | - * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
|
2210 | - */ |
|
2211 | - public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) |
|
2212 | - { |
|
2213 | - do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
2214 | - //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
|
2215 | - if (empty($callback_args) && $create_func) { |
|
2216 | - $callback_args = array( |
|
2217 | - 'template_path' => $this->_template_path, |
|
2218 | - 'template_args' => $this->_template_args, |
|
2219 | - ); |
|
2220 | - } |
|
2221 | - //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
|
2222 | - $call_back_func = $create_func ? create_function('$post, $metabox', |
|
2223 | - 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
|
2224 | - add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
2225 | - } |
|
2226 | - |
|
2227 | - |
|
2228 | - |
|
2229 | - /** |
|
2230 | - * generates HTML wrapper for and admin details page that contains metaboxes in columns |
|
2231 | - * |
|
2232 | - * @return [type] [description] |
|
2233 | - */ |
|
2234 | - public function display_admin_page_with_metabox_columns() |
|
2235 | - { |
|
2236 | - $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
|
2237 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true); |
|
2238 | - //the final wrapper |
|
2239 | - $this->admin_page_wrapper(); |
|
2240 | - } |
|
2241 | - |
|
2242 | - |
|
2243 | - |
|
2244 | - /** |
|
2245 | - * generates HTML wrapper for an admin details page |
|
2246 | - * |
|
2247 | - * @access public |
|
2248 | - * @return void |
|
2249 | - */ |
|
2250 | - public function display_admin_page_with_sidebar() |
|
2251 | - { |
|
2252 | - $this->_display_admin_page(true); |
|
2253 | - } |
|
2254 | - |
|
2255 | - |
|
2256 | - |
|
2257 | - /** |
|
2258 | - * generates HTML wrapper for an admin details page (except no sidebar) |
|
2259 | - * |
|
2260 | - * @access public |
|
2261 | - * @return void |
|
2262 | - */ |
|
2263 | - public function display_admin_page_with_no_sidebar() |
|
2264 | - { |
|
2265 | - $this->_display_admin_page(); |
|
2266 | - } |
|
2267 | - |
|
2268 | - |
|
2269 | - |
|
2270 | - /** |
|
2271 | - * generates HTML wrapper for an EE about admin page (no sidebar) |
|
2272 | - * |
|
2273 | - * @access public |
|
2274 | - * @return void |
|
2275 | - */ |
|
2276 | - public function display_about_admin_page() |
|
2277 | - { |
|
2278 | - $this->_display_admin_page(false, true); |
|
2279 | - } |
|
2280 | - |
|
2281 | - |
|
2282 | - |
|
2283 | - /** |
|
2284 | - * display_admin_page |
|
2285 | - * contains the code for actually displaying an admin page |
|
2286 | - * |
|
2287 | - * @access private |
|
2288 | - * @param boolean $sidebar true with sidebar, false without |
|
2289 | - * @param boolean $about use the about admin wrapper instead of the default. |
|
2290 | - * @return void |
|
2291 | - */ |
|
2292 | - private function _display_admin_page($sidebar = false, $about = false) |
|
2293 | - { |
|
2294 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2295 | - //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
|
2296 | - do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
2297 | - // set current wp page slug - looks like: event-espresso_page_event_categories |
|
2298 | - // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
|
2299 | - $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
2300 | - $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route |
|
2301 | - ? 'poststuff' |
|
2302 | - : 'espresso-default-admin'; |
|
2303 | - $template_path = $sidebar |
|
2304 | - ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' |
|
2305 | - : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
2306 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2307 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2308 | - } |
|
2309 | - $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
2310 | - $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
2311 | - $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
|
2312 | - $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
|
2313 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2314 | - // the final template wrapper |
|
2315 | - $this->admin_page_wrapper($about); |
|
2316 | - } |
|
2317 | - |
|
2318 | - |
|
2319 | - |
|
2320 | - /** |
|
2321 | - * This is used to display caf preview pages. |
|
2322 | - * |
|
2323 | - * @since 4.3.2 |
|
2324 | - * @param string $utm_campaign_source what is the key used for google analytics link |
|
2325 | - * @param bool $display_sidebar whether to use the sidebar template or the full template for the page. TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar. |
|
2326 | - * @return void |
|
2327 | - * @throws \EE_Error |
|
2328 | - */ |
|
2329 | - public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true) |
|
2330 | - { |
|
2331 | - //let's generate a default preview action button if there isn't one already present. |
|
2332 | - $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso'); |
|
2333 | - $buy_now_url = add_query_arg( |
|
2334 | - array( |
|
2335 | - 'ee_ver' => 'ee4', |
|
2336 | - 'utm_source' => 'ee4_plugin_admin', |
|
2337 | - 'utm_medium' => 'link', |
|
2338 | - 'utm_campaign' => $utm_campaign_source, |
|
2339 | - 'utm_content' => 'buy_now_button', |
|
2340 | - ), |
|
2341 | - 'http://eventespresso.com/pricing/' |
|
2342 | - ); |
|
2343 | - $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) |
|
2344 | - ? $this->get_action_link_or_button( |
|
2345 | - '', |
|
2346 | - 'buy_now', |
|
2347 | - array(), |
|
2348 | - 'button-primary button-large', |
|
2349 | - $buy_now_url, |
|
2350 | - true |
|
2351 | - ) |
|
2352 | - : $this->_template_args['preview_action_button']; |
|
2353 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
2354 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2355 | - $template_path, |
|
2356 | - $this->_template_args, |
|
2357 | - true |
|
2358 | - ); |
|
2359 | - $this->_display_admin_page($display_sidebar); |
|
2360 | - } |
|
2361 | - |
|
2362 | - |
|
2363 | - |
|
2364 | - /** |
|
2365 | - * display_admin_list_table_page_with_sidebar |
|
2366 | - * generates HTML wrapper for an admin_page with list_table |
|
2367 | - * |
|
2368 | - * @access public |
|
2369 | - * @return void |
|
2370 | - */ |
|
2371 | - public function display_admin_list_table_page_with_sidebar() |
|
2372 | - { |
|
2373 | - $this->_display_admin_list_table_page(true); |
|
2374 | - } |
|
2375 | - |
|
2376 | - |
|
2377 | - |
|
2378 | - /** |
|
2379 | - * display_admin_list_table_page_with_no_sidebar |
|
2380 | - * generates HTML wrapper for an admin_page with list_table (but with no sidebar) |
|
2381 | - * |
|
2382 | - * @access public |
|
2383 | - * @return void |
|
2384 | - */ |
|
2385 | - public function display_admin_list_table_page_with_no_sidebar() |
|
2386 | - { |
|
2387 | - $this->_display_admin_list_table_page(); |
|
2388 | - } |
|
2389 | - |
|
2390 | - |
|
2391 | - |
|
2392 | - /** |
|
2393 | - * generates html wrapper for an admin_list_table page |
|
2394 | - * |
|
2395 | - * @access private |
|
2396 | - * @param boolean $sidebar whether to display with sidebar or not. |
|
2397 | - * @return void |
|
2398 | - */ |
|
2399 | - private function _display_admin_list_table_page($sidebar = false) |
|
2400 | - { |
|
2401 | - //setup search attributes |
|
2402 | - $this->_set_search_attributes(); |
|
2403 | - $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
2404 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
2405 | - $this->_template_args['table_url'] = defined('DOING_AJAX') |
|
2406 | - ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
|
2407 | - : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
2408 | - $this->_template_args['list_table'] = $this->_list_table_object; |
|
2409 | - $this->_template_args['current_route'] = $this->_req_action; |
|
2410 | - $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
2411 | - $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
|
2412 | - if ( ! empty($ajax_sorting_callback)) { |
|
2413 | - $sortable_list_table_form_fields = wp_nonce_field( |
|
2414 | - $ajax_sorting_callback . '_nonce', |
|
2415 | - $ajax_sorting_callback . '_nonce', |
|
2416 | - false, |
|
2417 | - false |
|
2418 | - ); |
|
2419 | - // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
|
2420 | - // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
|
2421 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />'; |
|
2422 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
2423 | - } else { |
|
2424 | - $sortable_list_table_form_fields = ''; |
|
2425 | - } |
|
2426 | - $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
|
2427 | - $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
2428 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
2429 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">'; |
|
2430 | - $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
|
2431 | - //display message about search results? |
|
2432 | - $this->_template_args['before_list_table'] .= apply_filters( |
|
2433 | - 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
|
2434 | - ! empty($this->_req_data['s']) |
|
2435 | - ? '<p class="ee-search-results">' . sprintf( |
|
2436 | - __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), |
|
2437 | - trim($this->_req_data['s'], '%') |
|
2438 | - ) . '</p>' |
|
2439 | - : '', |
|
2440 | - $this->page_slug, |
|
2441 | - $this->_req_data, |
|
2442 | - $this->_req_action |
|
2443 | - ); |
|
2444 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2445 | - $template_path, |
|
2446 | - $this->_template_args, |
|
2447 | - true |
|
2448 | - ); |
|
2449 | - // the final template wrapper |
|
2450 | - if ($sidebar) { |
|
2451 | - $this->display_admin_page_with_sidebar(); |
|
2452 | - } else { |
|
2453 | - $this->display_admin_page_with_no_sidebar(); |
|
2454 | - } |
|
2455 | - } |
|
2456 | - |
|
2457 | - |
|
2458 | - |
|
2459 | - /** |
|
2460 | - * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend. |
|
2461 | - * $items are expected in an array in the following format: |
|
2462 | - * $legend_items = array( |
|
2463 | - * 'item_id' => array( |
|
2464 | - * 'icon' => 'http://url_to_icon_being_described.png', |
|
2465 | - * 'desc' => __('localized description of item'); |
|
2466 | - * ) |
|
2467 | - * ); |
|
2468 | - * |
|
2469 | - * @param array $items see above for format of array |
|
2470 | - * @return string html string of legend |
|
2471 | - */ |
|
2472 | - protected function _display_legend($items) |
|
2473 | - { |
|
2474 | - $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this); |
|
2475 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
2476 | - return EEH_Template::display_template($legend_template, $this->_template_args, true); |
|
2477 | - } |
|
2478 | - |
|
2479 | - |
|
2480 | - |
|
2481 | - /** |
|
2482 | - * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect |
|
2483 | - * |
|
2484 | - * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed. |
|
2485 | - * The returned json object is created from an array in the following format: |
|
2486 | - * array( |
|
2487 | - * 'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early), |
|
2488 | - * 'success' => FALSE, //(default FALSE) - contains any special success message. |
|
2489 | - * 'notices' => '', // - contains any EE_Error formatted notices |
|
2490 | - * 'content' => 'string can be html', //this is a string of formatted content (can be html) |
|
2491 | - * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any |
|
2492 | - * specific template args that might be included in here) |
|
2493 | - * ) |
|
2494 | - * The json object is populated by whatever is set in the $_template_args property. |
|
2495 | - * @return void |
|
2496 | - */ |
|
2497 | - protected function _return_json($sticky_notices = false) |
|
2498 | - { |
|
2499 | - //make sure any EE_Error notices have been handled. |
|
2500 | - $this->_process_notices(array(), true, $sticky_notices); |
|
2501 | - $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
2502 | - unset($this->_template_args['data']); |
|
2503 | - $json = array( |
|
2504 | - 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : false, |
|
2505 | - 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : false, |
|
2506 | - 'errors' => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false, |
|
2507 | - 'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false, |
|
2508 | - 'notices' => EE_Error::get_notices(), |
|
2509 | - 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
2510 | - 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
2511 | - 'isEEajax' => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
2512 | - ); |
|
2513 | - // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
2514 | - if (null === error_get_last() || ! headers_sent()) { |
|
2515 | - header('Content-Type: application/json; charset=UTF-8'); |
|
2516 | - } |
|
2517 | - echo wp_json_encode($json); |
|
2518 | - |
|
2519 | - exit(); |
|
2520 | - } |
|
2521 | - |
|
2522 | - |
|
2523 | - |
|
2524 | - /** |
|
2525 | - * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax) |
|
2526 | - * |
|
2527 | - * @return void |
|
2528 | - * @throws EE_Error |
|
2529 | - */ |
|
2530 | - public function return_json() |
|
2531 | - { |
|
2532 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2533 | - $this->_return_json(); |
|
2534 | - } else { |
|
2535 | - throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
2536 | - } |
|
2537 | - } |
|
2538 | - |
|
2539 | - |
|
2540 | - |
|
2541 | - /** |
|
2542 | - * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property. |
|
2543 | - * |
|
2544 | - * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child |
|
2545 | - * @access public |
|
2546 | - */ |
|
2547 | - public function set_hook_object(EE_Admin_Hooks $hook_obj) |
|
2548 | - { |
|
2549 | - $this->_hook_obj = $hook_obj; |
|
2550 | - } |
|
2551 | - |
|
2552 | - |
|
2553 | - |
|
2554 | - /** |
|
2555 | - * generates HTML wrapper with Tabbed nav for an admin page |
|
2556 | - * |
|
2557 | - * @access public |
|
2558 | - * @param boolean $about whether to use the special about page wrapper or default. |
|
2559 | - * @return void |
|
2560 | - */ |
|
2561 | - public function admin_page_wrapper($about = false) |
|
2562 | - { |
|
2563 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2564 | - $this->_nav_tabs = $this->_get_main_nav_tabs(); |
|
2565 | - $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
|
2566 | - $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
|
2567 | - $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, |
|
2568 | - isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
2569 | - $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, |
|
2570 | - isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
2571 | - $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
|
2572 | - // load settings page wrapper template |
|
2573 | - $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
2574 | - //about page? |
|
2575 | - $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
2576 | - if (defined('DOING_AJAX')) { |
|
2577 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2578 | - $this->_return_json(); |
|
2579 | - } else { |
|
2580 | - EEH_Template::display_template($template_path, $this->_template_args); |
|
2581 | - } |
|
2582 | - } |
|
2583 | - |
|
2584 | - |
|
2585 | - |
|
2586 | - /** |
|
2587 | - * This returns the admin_nav tabs html using the configuration in the _nav_tabs property |
|
2588 | - * |
|
2589 | - * @return string html |
|
2590 | - */ |
|
2591 | - protected function _get_main_nav_tabs() |
|
2592 | - { |
|
2593 | - //let's generate the html using the EEH_Tabbed_Content helper. We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array) |
|
2594 | - return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs); |
|
2595 | - } |
|
2596 | - |
|
2597 | - |
|
2598 | - |
|
2599 | - /** |
|
2600 | - * sort nav tabs |
|
2601 | - * |
|
2602 | - * @access public |
|
2603 | - * @param $a |
|
2604 | - * @param $b |
|
2605 | - * @return int |
|
2606 | - */ |
|
2607 | - private function _sort_nav_tabs($a, $b) |
|
2608 | - { |
|
2609 | - if ($a['order'] == $b['order']) { |
|
2610 | - return 0; |
|
2611 | - } |
|
2612 | - return ($a['order'] < $b['order']) ? -1 : 1; |
|
2613 | - } |
|
2614 | - |
|
2615 | - |
|
2616 | - |
|
2617 | - /** |
|
2618 | - * generates HTML for the forms used on admin pages |
|
2619 | - * |
|
2620 | - * @access protected |
|
2621 | - * @param array $input_vars - array of input field details |
|
2622 | - * @param string $generator (options are 'string' or 'array', basically use this to indicate which generator to use) |
|
2623 | - * @return string |
|
2624 | - * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
|
2625 | - * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
|
2626 | - */ |
|
2627 | - protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false) |
|
2628 | - { |
|
2629 | - $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
|
2630 | - return $content; |
|
2631 | - } |
|
2632 | - |
|
2633 | - |
|
2634 | - |
|
2635 | - /** |
|
2636 | - * generates the "Save" and "Save & Close" buttons for edit forms |
|
2637 | - * |
|
2638 | - * @access protected |
|
2639 | - * @param bool $both if true then both buttons will be generated. If false then just the "Save & Close" button. |
|
2640 | - * @param array $text if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close') |
|
2641 | - * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
|
2642 | - * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
|
2643 | - */ |
|
2644 | - protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null) |
|
2645 | - { |
|
2646 | - //make sure $text and $actions are in an array |
|
2647 | - $text = (array)$text; |
|
2648 | - $actions = (array)$actions; |
|
2649 | - $referrer_url = empty($referrer) ? '' : $referrer; |
|
2650 | - $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />' |
|
2651 | - : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />'; |
|
2652 | - $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
2653 | - $default_names = array('save', 'save_and_close'); |
|
2654 | - //add in a hidden index for the current page (so save and close redirects properly) |
|
2655 | - $this->_template_args['save_buttons'] = $referrer_url; |
|
2656 | - foreach ($button_text as $key => $button) { |
|
2657 | - $ref = $default_names[$key]; |
|
2658 | - $id = $this->_current_view . '_' . $ref; |
|
2659 | - $name = ! empty($actions) ? $actions[$key] : $ref; |
|
2660 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
2661 | - if ( ! $both) { |
|
2662 | - break; |
|
2663 | - } |
|
2664 | - } |
|
2665 | - } |
|
2666 | - |
|
2667 | - |
|
2668 | - |
|
2669 | - /** |
|
2670 | - * Wrapper for the protected function. Allows plugins/addons to call this to set the form tags. |
|
2671 | - * |
|
2672 | - * @see $this->_set_add_edit_form_tags() for details on params |
|
2673 | - * @since 4.6.0 |
|
2674 | - * @param string $route |
|
2675 | - * @param array $additional_hidden_fields |
|
2676 | - */ |
|
2677 | - public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
2678 | - { |
|
2679 | - $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
2680 | - } |
|
2681 | - |
|
2682 | - |
|
2683 | - |
|
2684 | - /** |
|
2685 | - * set form open and close tags on add/edit pages. |
|
2686 | - * |
|
2687 | - * @access protected |
|
2688 | - * @param string $route the route you want the form to direct to |
|
2689 | - * @param array $additional_hidden_fields any additional hidden fields required in the form header |
|
2690 | - * @return void |
|
2691 | - */ |
|
2692 | - protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
2693 | - { |
|
2694 | - if (empty($route)) { |
|
2695 | - $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
|
2696 | - $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
2697 | - EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
2698 | - } |
|
2699 | - // open form |
|
2700 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
2701 | - // add nonce |
|
2702 | - $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false); |
|
2703 | - // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
|
2704 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
2705 | - // add REQUIRED form action |
|
2706 | - $hidden_fields = array( |
|
2707 | - 'action' => array('type' => 'hidden', 'value' => $route), |
|
2708 | - ); |
|
2709 | - // merge arrays |
|
2710 | - $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
2711 | - // generate form fields |
|
2712 | - $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
2713 | - // add fields to form |
|
2714 | - foreach ((array)$form_fields as $field_name => $form_field) { |
|
2715 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
2716 | - } |
|
2717 | - // close form |
|
2718 | - $this->_template_args['after_admin_page_content'] = '</form>'; |
|
2719 | - } |
|
2720 | - |
|
2721 | - |
|
2722 | - |
|
2723 | - /** |
|
2724 | - * Public Wrapper for _redirect_after_action() method since its |
|
2725 | - * discovered it would be useful for external code to have access. |
|
2726 | - * |
|
2727 | - * @see EE_Admin_Page::_redirect_after_action() for params. |
|
2728 | - * @since 4.5.0 |
|
2729 | - */ |
|
2730 | - public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
2731 | - { |
|
2732 | - $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
2733 | - } |
|
2734 | - |
|
2735 | - |
|
2736 | - |
|
2737 | - /** |
|
2738 | - * _redirect_after_action |
|
2739 | - * |
|
2740 | - * @param int $success - whether success was for two or more records, or just one, or none |
|
2741 | - * @param string $what - what the action was performed on |
|
2742 | - * @param string $action_desc - what was done ie: updated, deleted, etc |
|
2743 | - * @param array $query_args - an array of query_args to be added to the URL to redirect to after the admin action is completed |
|
2744 | - * @param BOOL $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show. |
|
2745 | - * @access protected |
|
2746 | - * @return void |
|
2747 | - */ |
|
2748 | - protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
2749 | - { |
|
2750 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2751 | - //class name for actions/filters. |
|
2752 | - $classname = get_class($this); |
|
2753 | - //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
|
2754 | - $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
2755 | - $notices = EE_Error::get_notices(false); |
|
2756 | - // overwrite default success messages //BUT ONLY if overwrite not overridden |
|
2757 | - if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
2758 | - EE_Error::overwrite_success(); |
|
2759 | - } |
|
2760 | - if ( ! empty($what) && ! empty($action_desc)) { |
|
2761 | - // how many records affected ? more than one record ? or just one ? |
|
2762 | - if ($success > 1 && empty($notices['errors'])) { |
|
2763 | - // set plural msg |
|
2764 | - EE_Error::add_success( |
|
2765 | - sprintf( |
|
2766 | - __('The "%s" have been successfully %s.', 'event_espresso'), |
|
2767 | - $what, |
|
2768 | - $action_desc |
|
2769 | - ), |
|
2770 | - __FILE__, __FUNCTION__, __LINE__ |
|
2771 | - ); |
|
2772 | - } else if ($success == 1 && empty($notices['errors'])) { |
|
2773 | - // set singular msg |
|
2774 | - EE_Error::add_success( |
|
2775 | - sprintf( |
|
2776 | - __('The "%s" has been successfully %s.', 'event_espresso'), |
|
2777 | - $what, |
|
2778 | - $action_desc |
|
2779 | - ), |
|
2780 | - __FILE__, __FUNCTION__, __LINE__ |
|
2781 | - ); |
|
2782 | - } |
|
2783 | - } |
|
2784 | - // check that $query_args isn't something crazy |
|
2785 | - if ( ! is_array($query_args)) { |
|
2786 | - $query_args = array(); |
|
2787 | - } |
|
2788 | - /** |
|
2789 | - * Allow injecting actions before the query_args are modified for possible different |
|
2790 | - * redirections on save and close actions |
|
2791 | - * |
|
2792 | - * @since 4.2.0 |
|
2793 | - * @param array $query_args The original query_args array coming into the |
|
2794 | - * method. |
|
2795 | - */ |
|
2796 | - do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args); |
|
2797 | - //calculate where we're going (if we have a "save and close" button pushed) |
|
2798 | - if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
2799 | - // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
|
2800 | - $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
2801 | - // regenerate query args array from referrer URL |
|
2802 | - parse_str($parsed_url['query'], $query_args); |
|
2803 | - // correct page and action will be in the query args now |
|
2804 | - $redirect_url = admin_url('admin.php'); |
|
2805 | - } |
|
2806 | - //merge any default query_args set in _default_route_query_args property |
|
2807 | - if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
2808 | - $args_to_merge = array(); |
|
2809 | - foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
2810 | - //is there a wp_referer array in our _default_route_query_args property? |
|
2811 | - if ($query_param == 'wp_referer') { |
|
2812 | - $query_value = (array)$query_value; |
|
2813 | - foreach ($query_value as $reference => $value) { |
|
2814 | - if (strpos($reference, 'nonce') !== false) { |
|
2815 | - continue; |
|
2816 | - } |
|
2817 | - //finally we will override any arguments in the referer with |
|
2818 | - //what might be set on the _default_route_query_args array. |
|
2819 | - if (isset($this->_default_route_query_args[$reference])) { |
|
2820 | - $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
2821 | - } else { |
|
2822 | - $args_to_merge[$reference] = urlencode($value); |
|
2823 | - } |
|
2824 | - } |
|
2825 | - continue; |
|
2826 | - } |
|
2827 | - $args_to_merge[$query_param] = $query_value; |
|
2828 | - } |
|
2829 | - //now let's merge these arguments but override with what was specifically sent in to the |
|
2830 | - //redirect. |
|
2831 | - $query_args = array_merge($args_to_merge, $query_args); |
|
2832 | - } |
|
2833 | - $this->_process_notices($query_args); |
|
2834 | - // generate redirect url |
|
2835 | - // if redirecting to anything other than the main page, add a nonce |
|
2836 | - if (isset($query_args['action'])) { |
|
2837 | - // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
|
2838 | - $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
2839 | - } |
|
2840 | - //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
|
2841 | - do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args); |
|
2842 | - $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
2843 | - // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
|
2844 | - if (defined('DOING_AJAX')) { |
|
2845 | - $default_data = array( |
|
2846 | - 'close' => true, |
|
2847 | - 'redirect_url' => $redirect_url, |
|
2848 | - 'where' => 'main', |
|
2849 | - 'what' => 'append', |
|
2850 | - ); |
|
2851 | - $this->_template_args['success'] = $success; |
|
2852 | - $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
2853 | - $this->_return_json(); |
|
2854 | - } |
|
2855 | - wp_safe_redirect($redirect_url); |
|
2856 | - exit(); |
|
2857 | - } |
|
2858 | - |
|
2859 | - |
|
2860 | - |
|
2861 | - /** |
|
2862 | - * process any notices before redirecting (or returning ajax request) |
|
2863 | - * This method sets the $this->_template_args['notices'] attribute; |
|
2864 | - * |
|
2865 | - * @param array $query_args any query args that need to be used for notice transient ('action') |
|
2866 | - * @param bool $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet. |
|
2867 | - * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
|
2868 | - * @return void |
|
2869 | - */ |
|
2870 | - protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true) |
|
2871 | - { |
|
2872 | - //first let's set individual error properties if doing_ajax and the properties aren't already set. |
|
2873 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2874 | - $notices = EE_Error::get_notices(false); |
|
2875 | - if (empty($this->_template_args['success'])) { |
|
2876 | - $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false; |
|
2877 | - } |
|
2878 | - if (empty($this->_template_args['errors'])) { |
|
2879 | - $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false; |
|
2880 | - } |
|
2881 | - if (empty($this->_template_args['attention'])) { |
|
2882 | - $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false; |
|
2883 | - } |
|
2884 | - } |
|
2885 | - $this->_template_args['notices'] = EE_Error::get_notices(); |
|
2886 | - //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
|
2887 | - if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
2888 | - $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
2889 | - $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify); |
|
2890 | - } |
|
2891 | - } |
|
2892 | - |
|
2893 | - |
|
2894 | - |
|
2895 | - /** |
|
2896 | - * get_action_link_or_button |
|
2897 | - * returns the button html for adding, editing, or deleting an item (depending on given type) |
|
2898 | - * |
|
2899 | - * @param string $action use this to indicate which action the url is generated with. |
|
2900 | - * @param string $type accepted strings must be defined in the $_labels['button'] array(as the key) property. |
|
2901 | - * @param array $extra_request if the button requires extra params you can include them in $key=>$value pairs. |
|
2902 | - * @param string $class Use this to give the class for the button. Defaults to 'button-primary' |
|
2903 | - * @param string $base_url If this is not provided |
|
2904 | - * the _admin_base_url will be used as the default for the button base_url. |
|
2905 | - * Otherwise this value will be used. |
|
2906 | - * @param bool $exclude_nonce If true then no nonce will be in the generated button link. |
|
2907 | - * @return string |
|
2908 | - * @throws \EE_Error |
|
2909 | - */ |
|
2910 | - public function get_action_link_or_button( |
|
2911 | - $action, |
|
2912 | - $type = 'add', |
|
2913 | - $extra_request = array(), |
|
2914 | - $class = 'button-primary', |
|
2915 | - $base_url = '', |
|
2916 | - $exclude_nonce = false |
|
2917 | - ) { |
|
2918 | - //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
|
2919 | - if (empty($base_url) && ! isset($this->_page_routes[$action])) { |
|
2920 | - throw new EE_Error( |
|
2921 | - sprintf( |
|
2922 | - __( |
|
2923 | - 'There is no page route for given action for the button. This action was given: %s', |
|
2924 | - 'event_espresso' |
|
2925 | - ), |
|
2926 | - $action |
|
2927 | - ) |
|
2928 | - ); |
|
2929 | - } |
|
2930 | - if ( ! isset($this->_labels['buttons'][$type])) { |
|
2931 | - throw new EE_Error( |
|
2932 | - sprintf( |
|
2933 | - __( |
|
2934 | - 'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', |
|
2935 | - 'event_espresso' |
|
2936 | - ), |
|
2937 | - $type |
|
2938 | - ) |
|
2939 | - ); |
|
2940 | - } |
|
2941 | - //finally check user access for this button. |
|
2942 | - $has_access = $this->check_user_access($action, true); |
|
2943 | - if ( ! $has_access) { |
|
2944 | - return ''; |
|
2945 | - } |
|
2946 | - $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
|
2947 | - $query_args = array( |
|
2948 | - 'action' => $action, |
|
2949 | - ); |
|
2950 | - //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
|
2951 | - if ( ! empty($extra_request)) { |
|
2952 | - $query_args = array_merge($extra_request, $query_args); |
|
2953 | - } |
|
2954 | - $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
2955 | - return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
2956 | - } |
|
2957 | - |
|
2958 | - |
|
2959 | - |
|
2960 | - /** |
|
2961 | - * _per_page_screen_option |
|
2962 | - * Utility function for adding in a per_page_option in the screen_options_dropdown. |
|
2963 | - * |
|
2964 | - * @return void |
|
2965 | - */ |
|
2966 | - protected function _per_page_screen_option() |
|
2967 | - { |
|
2968 | - $option = 'per_page'; |
|
2969 | - $args = array( |
|
2970 | - 'label' => $this->_admin_page_title, |
|
2971 | - 'default' => 10, |
|
2972 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page', |
|
2973 | - ); |
|
2974 | - //ONLY add the screen option if the user has access to it. |
|
2975 | - if ($this->check_user_access($this->_current_view, true)) { |
|
2976 | - add_screen_option($option, $args); |
|
2977 | - } |
|
2978 | - } |
|
2979 | - |
|
2980 | - |
|
2981 | - |
|
2982 | - /** |
|
2983 | - * set_per_page_screen_option |
|
2984 | - * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page. |
|
2985 | - * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu. |
|
2986 | - * |
|
2987 | - * @access private |
|
2988 | - * @return void |
|
2989 | - */ |
|
2990 | - private function _set_per_page_screen_options() |
|
2991 | - { |
|
2992 | - if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
2993 | - check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
2994 | - if ( ! $user = wp_get_current_user()) { |
|
2995 | - return; |
|
2996 | - } |
|
2997 | - $option = $_POST['wp_screen_options']['option']; |
|
2998 | - $value = $_POST['wp_screen_options']['value']; |
|
2999 | - if ($option != sanitize_key($option)) { |
|
3000 | - return; |
|
3001 | - } |
|
3002 | - $map_option = $option; |
|
3003 | - $option = str_replace('-', '_', $option); |
|
3004 | - switch ($map_option) { |
|
3005 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
3006 | - $value = (int)$value; |
|
3007 | - if ($value < 1 || $value > 999) { |
|
3008 | - return; |
|
3009 | - } |
|
3010 | - break; |
|
3011 | - default: |
|
3012 | - $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
3013 | - if (false === $value) { |
|
3014 | - return; |
|
3015 | - } |
|
3016 | - break; |
|
3017 | - } |
|
3018 | - update_user_meta($user->ID, $option, $value); |
|
3019 | - wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
3020 | - exit; |
|
3021 | - } |
|
3022 | - } |
|
3023 | - |
|
3024 | - |
|
3025 | - |
|
3026 | - /** |
|
3027 | - * This just allows for setting the $_template_args property if it needs to be set outside the object |
|
3028 | - * |
|
3029 | - * @param array $data array that will be assigned to template args. |
|
3030 | - */ |
|
3031 | - public function set_template_args($data) |
|
3032 | - { |
|
3033 | - $this->_template_args = array_merge($this->_template_args, (array)$data); |
|
3034 | - } |
|
3035 | - |
|
3036 | - |
|
3037 | - |
|
3038 | - /** |
|
3039 | - * This makes available the WP transient system for temporarily moving data between routes |
|
3040 | - * |
|
3041 | - * @access protected |
|
3042 | - * @param string $route the route that should receive the transient |
|
3043 | - * @param array $data the data that gets sent |
|
3044 | - * @param bool $notices If this is for notices then we use this to indicate so, otherwise its just a normal route transient. |
|
3045 | - * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
|
3046 | - * @return void |
|
3047 | - */ |
|
3048 | - protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false) |
|
3049 | - { |
|
3050 | - $user_id = get_current_user_id(); |
|
3051 | - if ( ! $skip_route_verify) { |
|
3052 | - $this->_verify_route($route); |
|
3053 | - } |
|
3054 | - //now let's set the string for what kind of transient we're setting |
|
3055 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3056 | - $data = $notices ? array('notices' => $data) : $data; |
|
3057 | - //is there already a transient for this route? If there is then let's ADD to that transient |
|
3058 | - $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3059 | - if ($existing) { |
|
3060 | - $data = array_merge((array)$data, (array)$existing); |
|
3061 | - } |
|
3062 | - if (is_multisite() && is_network_admin()) { |
|
3063 | - set_site_transient($transient, $data, 8); |
|
3064 | - } else { |
|
3065 | - set_transient($transient, $data, 8); |
|
3066 | - } |
|
3067 | - } |
|
3068 | - |
|
3069 | - |
|
3070 | - |
|
3071 | - /** |
|
3072 | - * this retrieves the temporary transient that has been set for moving data between routes. |
|
3073 | - * |
|
3074 | - * @param bool $notices true we get notices transient. False we just return normal route transient |
|
3075 | - * @return mixed data |
|
3076 | - */ |
|
3077 | - protected function _get_transient($notices = false, $route = false) |
|
3078 | - { |
|
3079 | - $user_id = get_current_user_id(); |
|
3080 | - $route = ! $route ? $this->_req_action : $route; |
|
3081 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3082 | - $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3083 | - //delete transient after retrieval (just in case it hasn't expired); |
|
3084 | - if (is_multisite() && is_network_admin()) { |
|
3085 | - delete_site_transient($transient); |
|
3086 | - } else { |
|
3087 | - delete_transient($transient); |
|
3088 | - } |
|
3089 | - return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
3090 | - } |
|
3091 | - |
|
3092 | - |
|
3093 | - |
|
3094 | - /** |
|
3095 | - * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later. |
|
3096 | - * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.) |
|
3097 | - * |
|
3098 | - * @return void |
|
3099 | - */ |
|
3100 | - protected function _transient_garbage_collection() |
|
3101 | - { |
|
3102 | - global $wpdb; |
|
3103 | - //retrieve all existing transients |
|
3104 | - $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
|
3105 | - if ($results = $wpdb->get_results($query)) { |
|
3106 | - foreach ($results as $result) { |
|
3107 | - $transient = str_replace('_transient_', '', $result->option_name); |
|
3108 | - get_transient($transient); |
|
3109 | - if (is_multisite() && is_network_admin()) { |
|
3110 | - get_site_transient($transient); |
|
3111 | - } |
|
3112 | - } |
|
3113 | - } |
|
3114 | - } |
|
3115 | - |
|
3116 | - |
|
3117 | - |
|
3118 | - /** |
|
3119 | - * get_view |
|
3120 | - * |
|
3121 | - * @access public |
|
3122 | - * @return string content of _view property |
|
3123 | - */ |
|
3124 | - public function get_view() |
|
3125 | - { |
|
3126 | - return $this->_view; |
|
3127 | - } |
|
3128 | - |
|
3129 | - |
|
3130 | - |
|
3131 | - /** |
|
3132 | - * getter for the protected $_views property |
|
3133 | - * |
|
3134 | - * @return array |
|
3135 | - */ |
|
3136 | - public function get_views() |
|
3137 | - { |
|
3138 | - return $this->_views; |
|
3139 | - } |
|
3140 | - |
|
3141 | - |
|
3142 | - |
|
3143 | - /** |
|
3144 | - * get_current_page |
|
3145 | - * |
|
3146 | - * @access public |
|
3147 | - * @return string _current_page property value |
|
3148 | - */ |
|
3149 | - public function get_current_page() |
|
3150 | - { |
|
3151 | - return $this->_current_page; |
|
3152 | - } |
|
3153 | - |
|
3154 | - |
|
3155 | - |
|
3156 | - /** |
|
3157 | - * get_current_view |
|
3158 | - * |
|
3159 | - * @access public |
|
3160 | - * @return string _current_view property value |
|
3161 | - */ |
|
3162 | - public function get_current_view() |
|
3163 | - { |
|
3164 | - return $this->_current_view; |
|
3165 | - } |
|
3166 | - |
|
3167 | - |
|
3168 | - |
|
3169 | - /** |
|
3170 | - * get_current_screen |
|
3171 | - * |
|
3172 | - * @access public |
|
3173 | - * @return object The current WP_Screen object |
|
3174 | - */ |
|
3175 | - public function get_current_screen() |
|
3176 | - { |
|
3177 | - return $this->_current_screen; |
|
3178 | - } |
|
3179 | - |
|
3180 | - |
|
3181 | - |
|
3182 | - /** |
|
3183 | - * get_current_page_view_url |
|
3184 | - * |
|
3185 | - * @access public |
|
3186 | - * @return string This returns the url for the current_page_view. |
|
3187 | - */ |
|
3188 | - public function get_current_page_view_url() |
|
3189 | - { |
|
3190 | - return $this->_current_page_view_url; |
|
3191 | - } |
|
3192 | - |
|
3193 | - |
|
3194 | - |
|
3195 | - /** |
|
3196 | - * just returns the _req_data property |
|
3197 | - * |
|
3198 | - * @return array |
|
3199 | - */ |
|
3200 | - public function get_request_data() |
|
3201 | - { |
|
3202 | - return $this->_req_data; |
|
3203 | - } |
|
3204 | - |
|
3205 | - |
|
3206 | - |
|
3207 | - /** |
|
3208 | - * returns the _req_data protected property |
|
3209 | - * |
|
3210 | - * @return string |
|
3211 | - */ |
|
3212 | - public function get_req_action() |
|
3213 | - { |
|
3214 | - return $this->_req_action; |
|
3215 | - } |
|
3216 | - |
|
3217 | - |
|
3218 | - |
|
3219 | - /** |
|
3220 | - * @return bool value of $_is_caf property |
|
3221 | - */ |
|
3222 | - public function is_caf() |
|
3223 | - { |
|
3224 | - return $this->_is_caf; |
|
3225 | - } |
|
3226 | - |
|
3227 | - |
|
3228 | - |
|
3229 | - /** |
|
3230 | - * @return mixed |
|
3231 | - */ |
|
3232 | - public function default_espresso_metaboxes() |
|
3233 | - { |
|
3234 | - return $this->_default_espresso_metaboxes; |
|
3235 | - } |
|
3236 | - |
|
3237 | - |
|
3238 | - |
|
3239 | - /** |
|
3240 | - * @return mixed |
|
3241 | - */ |
|
3242 | - public function admin_base_url() |
|
3243 | - { |
|
3244 | - return $this->_admin_base_url; |
|
3245 | - } |
|
3246 | - |
|
3247 | - |
|
3248 | - |
|
3249 | - /** |
|
3250 | - * @return mixed |
|
3251 | - */ |
|
3252 | - public function wp_page_slug() |
|
3253 | - { |
|
3254 | - return $this->_wp_page_slug; |
|
3255 | - } |
|
3256 | - |
|
3257 | - |
|
3258 | - |
|
3259 | - /** |
|
3260 | - * updates espresso configuration settings |
|
3261 | - * |
|
3262 | - * @access protected |
|
3263 | - * @param string $tab |
|
3264 | - * @param EE_Config_Base|EE_Config $config |
|
3265 | - * @param string $file file where error occurred |
|
3266 | - * @param string $func function where error occurred |
|
3267 | - * @param string $line line no where error occurred |
|
3268 | - * @return boolean |
|
3269 | - */ |
|
3270 | - protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') |
|
3271 | - { |
|
3272 | - //remove any options that are NOT going to be saved with the config settings. |
|
3273 | - if (isset($config->core->ee_ueip_optin)) { |
|
3274 | - $config->core->ee_ueip_has_notified = true; |
|
3275 | - // TODO: remove the following two lines and make sure values are migrated from 3.1 |
|
3276 | - update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
3277 | - update_option('ee_ueip_has_notified', true); |
|
3278 | - } |
|
3279 | - // and save it (note we're also doing the network save here) |
|
3280 | - $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true; |
|
3281 | - $config_saved = EE_Config::instance()->update_espresso_config(false, false); |
|
3282 | - if ($config_saved && $net_saved) { |
|
3283 | - EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
3284 | - return true; |
|
3285 | - } else { |
|
3286 | - EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
3287 | - return false; |
|
3288 | - } |
|
3289 | - } |
|
3290 | - |
|
3291 | - |
|
3292 | - |
|
3293 | - /** |
|
3294 | - * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
|
3295 | - * |
|
3296 | - * @return array |
|
3297 | - */ |
|
3298 | - public function get_yes_no_values() |
|
3299 | - { |
|
3300 | - return $this->_yes_no_values; |
|
3301 | - } |
|
3302 | - |
|
3303 | - |
|
3304 | - |
|
3305 | - protected function _get_dir() |
|
3306 | - { |
|
3307 | - $reflector = new ReflectionClass(get_class($this)); |
|
3308 | - return dirname($reflector->getFileName()); |
|
3309 | - } |
|
3310 | - |
|
3311 | - |
|
3312 | - |
|
3313 | - /** |
|
3314 | - * A helper for getting a "next link". |
|
3315 | - * |
|
3316 | - * @param string $url The url to link to |
|
3317 | - * @param string $class The class to use. |
|
3318 | - * @return string |
|
3319 | - */ |
|
3320 | - protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') |
|
3321 | - { |
|
3322 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3323 | - } |
|
3324 | - |
|
3325 | - |
|
3326 | - |
|
3327 | - /** |
|
3328 | - * A helper for getting a "previous link". |
|
3329 | - * |
|
3330 | - * @param string $url The url to link to |
|
3331 | - * @param string $class The class to use. |
|
3332 | - * @return string |
|
3333 | - */ |
|
3334 | - protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') |
|
3335 | - { |
|
3336 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3337 | - } |
|
3338 | - |
|
3339 | - |
|
3340 | - |
|
3341 | - |
|
3342 | - |
|
3343 | - |
|
3344 | - |
|
3345 | - //below are some messages related methods that should be available across the EE_Admin system. Note, these methods are NOT page specific |
|
3346 | - /** |
|
3347 | - * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data |
|
3348 | - * array. |
|
3349 | - * |
|
3350 | - * @return bool success/fail |
|
3351 | - */ |
|
3352 | - protected function _process_resend_registration() |
|
3353 | - { |
|
3354 | - $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
3355 | - do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
3356 | - return $this->_template_args['success']; |
|
3357 | - } |
|
3358 | - |
|
3359 | - |
|
3360 | - |
|
3361 | - /** |
|
3362 | - * This automatically processes any payment message notifications when manual payment has been applied. |
|
3363 | - * |
|
3364 | - * @access protected |
|
3365 | - * @param \EE_Payment $payment |
|
3366 | - * @return bool success/fail |
|
3367 | - */ |
|
3368 | - protected function _process_payment_notification(EE_Payment $payment) |
|
3369 | - { |
|
3370 | - add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
3371 | - do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
3372 | - $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
3373 | - return $this->_template_args['success']; |
|
3374 | - } |
|
2196 | + } |
|
2197 | + |
|
2198 | + |
|
2199 | + |
|
2200 | + /** |
|
2201 | + * facade for add_meta_box |
|
2202 | + * |
|
2203 | + * @param string $action where the metabox get's displayed |
|
2204 | + * @param string $title Title of Metabox (output in metabox header) |
|
2205 | + * @param string $callback If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here. |
|
2206 | + * @param array $callback_args an array of args supplied for the metabox |
|
2207 | + * @param string $column what metabox column |
|
2208 | + * @param string $priority give this metabox a priority (using accepted priorities for wp meta boxes) |
|
2209 | + * @param boolean $create_func default is true. Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box. |
|
2210 | + */ |
|
2211 | + public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true) |
|
2212 | + { |
|
2213 | + do_action('AHEE_log', __FILE__, __FUNCTION__, $callback); |
|
2214 | + //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated. |
|
2215 | + if (empty($callback_args) && $create_func) { |
|
2216 | + $callback_args = array( |
|
2217 | + 'template_path' => $this->_template_path, |
|
2218 | + 'template_args' => $this->_template_args, |
|
2219 | + ); |
|
2220 | + } |
|
2221 | + //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
|
2222 | + $call_back_func = $create_func ? create_function('$post, $metabox', |
|
2223 | + 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
|
2224 | + add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
2225 | + } |
|
2226 | + |
|
2227 | + |
|
2228 | + |
|
2229 | + /** |
|
2230 | + * generates HTML wrapper for and admin details page that contains metaboxes in columns |
|
2231 | + * |
|
2232 | + * @return [type] [description] |
|
2233 | + */ |
|
2234 | + public function display_admin_page_with_metabox_columns() |
|
2235 | + { |
|
2236 | + $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content']; |
|
2237 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true); |
|
2238 | + //the final wrapper |
|
2239 | + $this->admin_page_wrapper(); |
|
2240 | + } |
|
2241 | + |
|
2242 | + |
|
2243 | + |
|
2244 | + /** |
|
2245 | + * generates HTML wrapper for an admin details page |
|
2246 | + * |
|
2247 | + * @access public |
|
2248 | + * @return void |
|
2249 | + */ |
|
2250 | + public function display_admin_page_with_sidebar() |
|
2251 | + { |
|
2252 | + $this->_display_admin_page(true); |
|
2253 | + } |
|
2254 | + |
|
2255 | + |
|
2256 | + |
|
2257 | + /** |
|
2258 | + * generates HTML wrapper for an admin details page (except no sidebar) |
|
2259 | + * |
|
2260 | + * @access public |
|
2261 | + * @return void |
|
2262 | + */ |
|
2263 | + public function display_admin_page_with_no_sidebar() |
|
2264 | + { |
|
2265 | + $this->_display_admin_page(); |
|
2266 | + } |
|
2267 | + |
|
2268 | + |
|
2269 | + |
|
2270 | + /** |
|
2271 | + * generates HTML wrapper for an EE about admin page (no sidebar) |
|
2272 | + * |
|
2273 | + * @access public |
|
2274 | + * @return void |
|
2275 | + */ |
|
2276 | + public function display_about_admin_page() |
|
2277 | + { |
|
2278 | + $this->_display_admin_page(false, true); |
|
2279 | + } |
|
2280 | + |
|
2281 | + |
|
2282 | + |
|
2283 | + /** |
|
2284 | + * display_admin_page |
|
2285 | + * contains the code for actually displaying an admin page |
|
2286 | + * |
|
2287 | + * @access private |
|
2288 | + * @param boolean $sidebar true with sidebar, false without |
|
2289 | + * @param boolean $about use the about admin wrapper instead of the default. |
|
2290 | + * @return void |
|
2291 | + */ |
|
2292 | + private function _display_admin_page($sidebar = false, $about = false) |
|
2293 | + { |
|
2294 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2295 | + //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages. |
|
2296 | + do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes'); |
|
2297 | + // set current wp page slug - looks like: event-espresso_page_event_categories |
|
2298 | + // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated. |
|
2299 | + $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
2300 | + $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route |
|
2301 | + ? 'poststuff' |
|
2302 | + : 'espresso-default-admin'; |
|
2303 | + $template_path = $sidebar |
|
2304 | + ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' |
|
2305 | + : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
2306 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2307 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
2308 | + } |
|
2309 | + $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
|
2310 | + $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
|
2311 | + $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''; |
|
2312 | + $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''; |
|
2313 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2314 | + // the final template wrapper |
|
2315 | + $this->admin_page_wrapper($about); |
|
2316 | + } |
|
2317 | + |
|
2318 | + |
|
2319 | + |
|
2320 | + /** |
|
2321 | + * This is used to display caf preview pages. |
|
2322 | + * |
|
2323 | + * @since 4.3.2 |
|
2324 | + * @param string $utm_campaign_source what is the key used for google analytics link |
|
2325 | + * @param bool $display_sidebar whether to use the sidebar template or the full template for the page. TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar. |
|
2326 | + * @return void |
|
2327 | + * @throws \EE_Error |
|
2328 | + */ |
|
2329 | + public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true) |
|
2330 | + { |
|
2331 | + //let's generate a default preview action button if there isn't one already present. |
|
2332 | + $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso'); |
|
2333 | + $buy_now_url = add_query_arg( |
|
2334 | + array( |
|
2335 | + 'ee_ver' => 'ee4', |
|
2336 | + 'utm_source' => 'ee4_plugin_admin', |
|
2337 | + 'utm_medium' => 'link', |
|
2338 | + 'utm_campaign' => $utm_campaign_source, |
|
2339 | + 'utm_content' => 'buy_now_button', |
|
2340 | + ), |
|
2341 | + 'http://eventespresso.com/pricing/' |
|
2342 | + ); |
|
2343 | + $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button']) |
|
2344 | + ? $this->get_action_link_or_button( |
|
2345 | + '', |
|
2346 | + 'buy_now', |
|
2347 | + array(), |
|
2348 | + 'button-primary button-large', |
|
2349 | + $buy_now_url, |
|
2350 | + true |
|
2351 | + ) |
|
2352 | + : $this->_template_args['preview_action_button']; |
|
2353 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
2354 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2355 | + $template_path, |
|
2356 | + $this->_template_args, |
|
2357 | + true |
|
2358 | + ); |
|
2359 | + $this->_display_admin_page($display_sidebar); |
|
2360 | + } |
|
2361 | + |
|
2362 | + |
|
2363 | + |
|
2364 | + /** |
|
2365 | + * display_admin_list_table_page_with_sidebar |
|
2366 | + * generates HTML wrapper for an admin_page with list_table |
|
2367 | + * |
|
2368 | + * @access public |
|
2369 | + * @return void |
|
2370 | + */ |
|
2371 | + public function display_admin_list_table_page_with_sidebar() |
|
2372 | + { |
|
2373 | + $this->_display_admin_list_table_page(true); |
|
2374 | + } |
|
2375 | + |
|
2376 | + |
|
2377 | + |
|
2378 | + /** |
|
2379 | + * display_admin_list_table_page_with_no_sidebar |
|
2380 | + * generates HTML wrapper for an admin_page with list_table (but with no sidebar) |
|
2381 | + * |
|
2382 | + * @access public |
|
2383 | + * @return void |
|
2384 | + */ |
|
2385 | + public function display_admin_list_table_page_with_no_sidebar() |
|
2386 | + { |
|
2387 | + $this->_display_admin_list_table_page(); |
|
2388 | + } |
|
2389 | + |
|
2390 | + |
|
2391 | + |
|
2392 | + /** |
|
2393 | + * generates html wrapper for an admin_list_table page |
|
2394 | + * |
|
2395 | + * @access private |
|
2396 | + * @param boolean $sidebar whether to display with sidebar or not. |
|
2397 | + * @return void |
|
2398 | + */ |
|
2399 | + private function _display_admin_list_table_page($sidebar = false) |
|
2400 | + { |
|
2401 | + //setup search attributes |
|
2402 | + $this->_set_search_attributes(); |
|
2403 | + $this->_template_args['current_page'] = $this->_wp_page_slug; |
|
2404 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
2405 | + $this->_template_args['table_url'] = defined('DOING_AJAX') |
|
2406 | + ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
|
2407 | + : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
|
2408 | + $this->_template_args['list_table'] = $this->_list_table_object; |
|
2409 | + $this->_template_args['current_route'] = $this->_req_action; |
|
2410 | + $this->_template_args['list_table_class'] = get_class($this->_list_table_object); |
|
2411 | + $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
|
2412 | + if ( ! empty($ajax_sorting_callback)) { |
|
2413 | + $sortable_list_table_form_fields = wp_nonce_field( |
|
2414 | + $ajax_sorting_callback . '_nonce', |
|
2415 | + $ajax_sorting_callback . '_nonce', |
|
2416 | + false, |
|
2417 | + false |
|
2418 | + ); |
|
2419 | + // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
|
2420 | + // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
|
2421 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />'; |
|
2422 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
2423 | + } else { |
|
2424 | + $sortable_list_table_form_fields = ''; |
|
2425 | + } |
|
2426 | + $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
|
2427 | + $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
|
2428 | + $nonce_ref = $this->_req_action . '_nonce'; |
|
2429 | + $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">'; |
|
2430 | + $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
|
2431 | + //display message about search results? |
|
2432 | + $this->_template_args['before_list_table'] .= apply_filters( |
|
2433 | + 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg', |
|
2434 | + ! empty($this->_req_data['s']) |
|
2435 | + ? '<p class="ee-search-results">' . sprintf( |
|
2436 | + __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'), |
|
2437 | + trim($this->_req_data['s'], '%') |
|
2438 | + ) . '</p>' |
|
2439 | + : '', |
|
2440 | + $this->page_slug, |
|
2441 | + $this->_req_data, |
|
2442 | + $this->_req_action |
|
2443 | + ); |
|
2444 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2445 | + $template_path, |
|
2446 | + $this->_template_args, |
|
2447 | + true |
|
2448 | + ); |
|
2449 | + // the final template wrapper |
|
2450 | + if ($sidebar) { |
|
2451 | + $this->display_admin_page_with_sidebar(); |
|
2452 | + } else { |
|
2453 | + $this->display_admin_page_with_no_sidebar(); |
|
2454 | + } |
|
2455 | + } |
|
2456 | + |
|
2457 | + |
|
2458 | + |
|
2459 | + /** |
|
2460 | + * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend. |
|
2461 | + * $items are expected in an array in the following format: |
|
2462 | + * $legend_items = array( |
|
2463 | + * 'item_id' => array( |
|
2464 | + * 'icon' => 'http://url_to_icon_being_described.png', |
|
2465 | + * 'desc' => __('localized description of item'); |
|
2466 | + * ) |
|
2467 | + * ); |
|
2468 | + * |
|
2469 | + * @param array $items see above for format of array |
|
2470 | + * @return string html string of legend |
|
2471 | + */ |
|
2472 | + protected function _display_legend($items) |
|
2473 | + { |
|
2474 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this); |
|
2475 | + $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
2476 | + return EEH_Template::display_template($legend_template, $this->_template_args, true); |
|
2477 | + } |
|
2478 | + |
|
2479 | + |
|
2480 | + |
|
2481 | + /** |
|
2482 | + * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect |
|
2483 | + * |
|
2484 | + * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed. |
|
2485 | + * The returned json object is created from an array in the following format: |
|
2486 | + * array( |
|
2487 | + * 'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early), |
|
2488 | + * 'success' => FALSE, //(default FALSE) - contains any special success message. |
|
2489 | + * 'notices' => '', // - contains any EE_Error formatted notices |
|
2490 | + * 'content' => 'string can be html', //this is a string of formatted content (can be html) |
|
2491 | + * 'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any |
|
2492 | + * specific template args that might be included in here) |
|
2493 | + * ) |
|
2494 | + * The json object is populated by whatever is set in the $_template_args property. |
|
2495 | + * @return void |
|
2496 | + */ |
|
2497 | + protected function _return_json($sticky_notices = false) |
|
2498 | + { |
|
2499 | + //make sure any EE_Error notices have been handled. |
|
2500 | + $this->_process_notices(array(), true, $sticky_notices); |
|
2501 | + $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array(); |
|
2502 | + unset($this->_template_args['data']); |
|
2503 | + $json = array( |
|
2504 | + 'error' => isset($this->_template_args['error']) ? $this->_template_args['error'] : false, |
|
2505 | + 'success' => isset($this->_template_args['success']) ? $this->_template_args['success'] : false, |
|
2506 | + 'errors' => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false, |
|
2507 | + 'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false, |
|
2508 | + 'notices' => EE_Error::get_notices(), |
|
2509 | + 'content' => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '', |
|
2510 | + 'data' => array_merge($data, array('template_args' => $this->_template_args)), |
|
2511 | + 'isEEajax' => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package. |
|
2512 | + ); |
|
2513 | + // make sure there are no php errors or headers_sent. Then we can set correct json header. |
|
2514 | + if (null === error_get_last() || ! headers_sent()) { |
|
2515 | + header('Content-Type: application/json; charset=UTF-8'); |
|
2516 | + } |
|
2517 | + echo wp_json_encode($json); |
|
2518 | + |
|
2519 | + exit(); |
|
2520 | + } |
|
2521 | + |
|
2522 | + |
|
2523 | + |
|
2524 | + /** |
|
2525 | + * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax) |
|
2526 | + * |
|
2527 | + * @return void |
|
2528 | + * @throws EE_Error |
|
2529 | + */ |
|
2530 | + public function return_json() |
|
2531 | + { |
|
2532 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2533 | + $this->_return_json(); |
|
2534 | + } else { |
|
2535 | + throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__)); |
|
2536 | + } |
|
2537 | + } |
|
2538 | + |
|
2539 | + |
|
2540 | + |
|
2541 | + /** |
|
2542 | + * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property. |
|
2543 | + * |
|
2544 | + * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child |
|
2545 | + * @access public |
|
2546 | + */ |
|
2547 | + public function set_hook_object(EE_Admin_Hooks $hook_obj) |
|
2548 | + { |
|
2549 | + $this->_hook_obj = $hook_obj; |
|
2550 | + } |
|
2551 | + |
|
2552 | + |
|
2553 | + |
|
2554 | + /** |
|
2555 | + * generates HTML wrapper with Tabbed nav for an admin page |
|
2556 | + * |
|
2557 | + * @access public |
|
2558 | + * @param boolean $about whether to use the special about page wrapper or default. |
|
2559 | + * @return void |
|
2560 | + */ |
|
2561 | + public function admin_page_wrapper($about = false) |
|
2562 | + { |
|
2563 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2564 | + $this->_nav_tabs = $this->_get_main_nav_tabs(); |
|
2565 | + $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
|
2566 | + $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
|
2567 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, |
|
2568 | + isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
|
2569 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, |
|
2570 | + isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
|
2571 | + $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
|
2572 | + // load settings page wrapper template |
|
2573 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
2574 | + //about page? |
|
2575 | + $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
|
2576 | + if (defined('DOING_AJAX')) { |
|
2577 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true); |
|
2578 | + $this->_return_json(); |
|
2579 | + } else { |
|
2580 | + EEH_Template::display_template($template_path, $this->_template_args); |
|
2581 | + } |
|
2582 | + } |
|
2583 | + |
|
2584 | + |
|
2585 | + |
|
2586 | + /** |
|
2587 | + * This returns the admin_nav tabs html using the configuration in the _nav_tabs property |
|
2588 | + * |
|
2589 | + * @return string html |
|
2590 | + */ |
|
2591 | + protected function _get_main_nav_tabs() |
|
2592 | + { |
|
2593 | + //let's generate the html using the EEH_Tabbed_Content helper. We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array) |
|
2594 | + return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs); |
|
2595 | + } |
|
2596 | + |
|
2597 | + |
|
2598 | + |
|
2599 | + /** |
|
2600 | + * sort nav tabs |
|
2601 | + * |
|
2602 | + * @access public |
|
2603 | + * @param $a |
|
2604 | + * @param $b |
|
2605 | + * @return int |
|
2606 | + */ |
|
2607 | + private function _sort_nav_tabs($a, $b) |
|
2608 | + { |
|
2609 | + if ($a['order'] == $b['order']) { |
|
2610 | + return 0; |
|
2611 | + } |
|
2612 | + return ($a['order'] < $b['order']) ? -1 : 1; |
|
2613 | + } |
|
2614 | + |
|
2615 | + |
|
2616 | + |
|
2617 | + /** |
|
2618 | + * generates HTML for the forms used on admin pages |
|
2619 | + * |
|
2620 | + * @access protected |
|
2621 | + * @param array $input_vars - array of input field details |
|
2622 | + * @param string $generator (options are 'string' or 'array', basically use this to indicate which generator to use) |
|
2623 | + * @return string |
|
2624 | + * @uses EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php) |
|
2625 | + * @uses EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php) |
|
2626 | + */ |
|
2627 | + protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false) |
|
2628 | + { |
|
2629 | + $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars); |
|
2630 | + return $content; |
|
2631 | + } |
|
2632 | + |
|
2633 | + |
|
2634 | + |
|
2635 | + /** |
|
2636 | + * generates the "Save" and "Save & Close" buttons for edit forms |
|
2637 | + * |
|
2638 | + * @access protected |
|
2639 | + * @param bool $both if true then both buttons will be generated. If false then just the "Save & Close" button. |
|
2640 | + * @param array $text if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close') |
|
2641 | + * @param array $actions if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button). We can also use this to just dump default actions by submitting some other value. |
|
2642 | + * @param bool|string|null $referrer if false then we just do the default action on save and close. Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling). |
|
2643 | + */ |
|
2644 | + protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null) |
|
2645 | + { |
|
2646 | + //make sure $text and $actions are in an array |
|
2647 | + $text = (array)$text; |
|
2648 | + $actions = (array)$actions; |
|
2649 | + $referrer_url = empty($referrer) ? '' : $referrer; |
|
2650 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />' |
|
2651 | + : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />'; |
|
2652 | + $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
|
2653 | + $default_names = array('save', 'save_and_close'); |
|
2654 | + //add in a hidden index for the current page (so save and close redirects properly) |
|
2655 | + $this->_template_args['save_buttons'] = $referrer_url; |
|
2656 | + foreach ($button_text as $key => $button) { |
|
2657 | + $ref = $default_names[$key]; |
|
2658 | + $id = $this->_current_view . '_' . $ref; |
|
2659 | + $name = ! empty($actions) ? $actions[$key] : $ref; |
|
2660 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
2661 | + if ( ! $both) { |
|
2662 | + break; |
|
2663 | + } |
|
2664 | + } |
|
2665 | + } |
|
2666 | + |
|
2667 | + |
|
2668 | + |
|
2669 | + /** |
|
2670 | + * Wrapper for the protected function. Allows plugins/addons to call this to set the form tags. |
|
2671 | + * |
|
2672 | + * @see $this->_set_add_edit_form_tags() for details on params |
|
2673 | + * @since 4.6.0 |
|
2674 | + * @param string $route |
|
2675 | + * @param array $additional_hidden_fields |
|
2676 | + */ |
|
2677 | + public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
2678 | + { |
|
2679 | + $this->_set_add_edit_form_tags($route, $additional_hidden_fields); |
|
2680 | + } |
|
2681 | + |
|
2682 | + |
|
2683 | + |
|
2684 | + /** |
|
2685 | + * set form open and close tags on add/edit pages. |
|
2686 | + * |
|
2687 | + * @access protected |
|
2688 | + * @param string $route the route you want the form to direct to |
|
2689 | + * @param array $additional_hidden_fields any additional hidden fields required in the form header |
|
2690 | + * @return void |
|
2691 | + */ |
|
2692 | + protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array()) |
|
2693 | + { |
|
2694 | + if (empty($route)) { |
|
2695 | + $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
|
2696 | + $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
2697 | + EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
2698 | + } |
|
2699 | + // open form |
|
2700 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
2701 | + // add nonce |
|
2702 | + $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false); |
|
2703 | + // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
|
2704 | + $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
2705 | + // add REQUIRED form action |
|
2706 | + $hidden_fields = array( |
|
2707 | + 'action' => array('type' => 'hidden', 'value' => $route), |
|
2708 | + ); |
|
2709 | + // merge arrays |
|
2710 | + $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields; |
|
2711 | + // generate form fields |
|
2712 | + $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
|
2713 | + // add fields to form |
|
2714 | + foreach ((array)$form_fields as $field_name => $form_field) { |
|
2715 | + $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
2716 | + } |
|
2717 | + // close form |
|
2718 | + $this->_template_args['after_admin_page_content'] = '</form>'; |
|
2719 | + } |
|
2720 | + |
|
2721 | + |
|
2722 | + |
|
2723 | + /** |
|
2724 | + * Public Wrapper for _redirect_after_action() method since its |
|
2725 | + * discovered it would be useful for external code to have access. |
|
2726 | + * |
|
2727 | + * @see EE_Admin_Page::_redirect_after_action() for params. |
|
2728 | + * @since 4.5.0 |
|
2729 | + */ |
|
2730 | + public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
2731 | + { |
|
2732 | + $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite); |
|
2733 | + } |
|
2734 | + |
|
2735 | + |
|
2736 | + |
|
2737 | + /** |
|
2738 | + * _redirect_after_action |
|
2739 | + * |
|
2740 | + * @param int $success - whether success was for two or more records, or just one, or none |
|
2741 | + * @param string $what - what the action was performed on |
|
2742 | + * @param string $action_desc - what was done ie: updated, deleted, etc |
|
2743 | + * @param array $query_args - an array of query_args to be added to the URL to redirect to after the admin action is completed |
|
2744 | + * @param BOOL $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show. |
|
2745 | + * @access protected |
|
2746 | + * @return void |
|
2747 | + */ |
|
2748 | + protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false) |
|
2749 | + { |
|
2750 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2751 | + //class name for actions/filters. |
|
2752 | + $classname = get_class($this); |
|
2753 | + //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url |
|
2754 | + $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url; |
|
2755 | + $notices = EE_Error::get_notices(false); |
|
2756 | + // overwrite default success messages //BUT ONLY if overwrite not overridden |
|
2757 | + if ( ! $override_overwrite || ! empty($notices['errors'])) { |
|
2758 | + EE_Error::overwrite_success(); |
|
2759 | + } |
|
2760 | + if ( ! empty($what) && ! empty($action_desc)) { |
|
2761 | + // how many records affected ? more than one record ? or just one ? |
|
2762 | + if ($success > 1 && empty($notices['errors'])) { |
|
2763 | + // set plural msg |
|
2764 | + EE_Error::add_success( |
|
2765 | + sprintf( |
|
2766 | + __('The "%s" have been successfully %s.', 'event_espresso'), |
|
2767 | + $what, |
|
2768 | + $action_desc |
|
2769 | + ), |
|
2770 | + __FILE__, __FUNCTION__, __LINE__ |
|
2771 | + ); |
|
2772 | + } else if ($success == 1 && empty($notices['errors'])) { |
|
2773 | + // set singular msg |
|
2774 | + EE_Error::add_success( |
|
2775 | + sprintf( |
|
2776 | + __('The "%s" has been successfully %s.', 'event_espresso'), |
|
2777 | + $what, |
|
2778 | + $action_desc |
|
2779 | + ), |
|
2780 | + __FILE__, __FUNCTION__, __LINE__ |
|
2781 | + ); |
|
2782 | + } |
|
2783 | + } |
|
2784 | + // check that $query_args isn't something crazy |
|
2785 | + if ( ! is_array($query_args)) { |
|
2786 | + $query_args = array(); |
|
2787 | + } |
|
2788 | + /** |
|
2789 | + * Allow injecting actions before the query_args are modified for possible different |
|
2790 | + * redirections on save and close actions |
|
2791 | + * |
|
2792 | + * @since 4.2.0 |
|
2793 | + * @param array $query_args The original query_args array coming into the |
|
2794 | + * method. |
|
2795 | + */ |
|
2796 | + do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args); |
|
2797 | + //calculate where we're going (if we have a "save and close" button pushed) |
|
2798 | + if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
|
2799 | + // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
|
2800 | + $parsed_url = parse_url($this->_req_data['save_and_close_referrer']); |
|
2801 | + // regenerate query args array from referrer URL |
|
2802 | + parse_str($parsed_url['query'], $query_args); |
|
2803 | + // correct page and action will be in the query args now |
|
2804 | + $redirect_url = admin_url('admin.php'); |
|
2805 | + } |
|
2806 | + //merge any default query_args set in _default_route_query_args property |
|
2807 | + if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) { |
|
2808 | + $args_to_merge = array(); |
|
2809 | + foreach ($this->_default_route_query_args as $query_param => $query_value) { |
|
2810 | + //is there a wp_referer array in our _default_route_query_args property? |
|
2811 | + if ($query_param == 'wp_referer') { |
|
2812 | + $query_value = (array)$query_value; |
|
2813 | + foreach ($query_value as $reference => $value) { |
|
2814 | + if (strpos($reference, 'nonce') !== false) { |
|
2815 | + continue; |
|
2816 | + } |
|
2817 | + //finally we will override any arguments in the referer with |
|
2818 | + //what might be set on the _default_route_query_args array. |
|
2819 | + if (isset($this->_default_route_query_args[$reference])) { |
|
2820 | + $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]); |
|
2821 | + } else { |
|
2822 | + $args_to_merge[$reference] = urlencode($value); |
|
2823 | + } |
|
2824 | + } |
|
2825 | + continue; |
|
2826 | + } |
|
2827 | + $args_to_merge[$query_param] = $query_value; |
|
2828 | + } |
|
2829 | + //now let's merge these arguments but override with what was specifically sent in to the |
|
2830 | + //redirect. |
|
2831 | + $query_args = array_merge($args_to_merge, $query_args); |
|
2832 | + } |
|
2833 | + $this->_process_notices($query_args); |
|
2834 | + // generate redirect url |
|
2835 | + // if redirecting to anything other than the main page, add a nonce |
|
2836 | + if (isset($query_args['action'])) { |
|
2837 | + // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
|
2838 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
2839 | + } |
|
2840 | + //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
|
2841 | + do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args); |
|
2842 | + $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
2843 | + // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
|
2844 | + if (defined('DOING_AJAX')) { |
|
2845 | + $default_data = array( |
|
2846 | + 'close' => true, |
|
2847 | + 'redirect_url' => $redirect_url, |
|
2848 | + 'where' => 'main', |
|
2849 | + 'what' => 'append', |
|
2850 | + ); |
|
2851 | + $this->_template_args['success'] = $success; |
|
2852 | + $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data; |
|
2853 | + $this->_return_json(); |
|
2854 | + } |
|
2855 | + wp_safe_redirect($redirect_url); |
|
2856 | + exit(); |
|
2857 | + } |
|
2858 | + |
|
2859 | + |
|
2860 | + |
|
2861 | + /** |
|
2862 | + * process any notices before redirecting (or returning ajax request) |
|
2863 | + * This method sets the $this->_template_args['notices'] attribute; |
|
2864 | + * |
|
2865 | + * @param array $query_args any query args that need to be used for notice transient ('action') |
|
2866 | + * @param bool $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet. |
|
2867 | + * @param bool $sticky_notices This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice. |
|
2868 | + * @return void |
|
2869 | + */ |
|
2870 | + protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true) |
|
2871 | + { |
|
2872 | + //first let's set individual error properties if doing_ajax and the properties aren't already set. |
|
2873 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
2874 | + $notices = EE_Error::get_notices(false); |
|
2875 | + if (empty($this->_template_args['success'])) { |
|
2876 | + $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false; |
|
2877 | + } |
|
2878 | + if (empty($this->_template_args['errors'])) { |
|
2879 | + $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false; |
|
2880 | + } |
|
2881 | + if (empty($this->_template_args['attention'])) { |
|
2882 | + $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false; |
|
2883 | + } |
|
2884 | + } |
|
2885 | + $this->_template_args['notices'] = EE_Error::get_notices(); |
|
2886 | + //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true) |
|
2887 | + if ( ! defined('DOING_AJAX') || $sticky_notices) { |
|
2888 | + $route = isset($query_args['action']) ? $query_args['action'] : 'default'; |
|
2889 | + $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify); |
|
2890 | + } |
|
2891 | + } |
|
2892 | + |
|
2893 | + |
|
2894 | + |
|
2895 | + /** |
|
2896 | + * get_action_link_or_button |
|
2897 | + * returns the button html for adding, editing, or deleting an item (depending on given type) |
|
2898 | + * |
|
2899 | + * @param string $action use this to indicate which action the url is generated with. |
|
2900 | + * @param string $type accepted strings must be defined in the $_labels['button'] array(as the key) property. |
|
2901 | + * @param array $extra_request if the button requires extra params you can include them in $key=>$value pairs. |
|
2902 | + * @param string $class Use this to give the class for the button. Defaults to 'button-primary' |
|
2903 | + * @param string $base_url If this is not provided |
|
2904 | + * the _admin_base_url will be used as the default for the button base_url. |
|
2905 | + * Otherwise this value will be used. |
|
2906 | + * @param bool $exclude_nonce If true then no nonce will be in the generated button link. |
|
2907 | + * @return string |
|
2908 | + * @throws \EE_Error |
|
2909 | + */ |
|
2910 | + public function get_action_link_or_button( |
|
2911 | + $action, |
|
2912 | + $type = 'add', |
|
2913 | + $extra_request = array(), |
|
2914 | + $class = 'button-primary', |
|
2915 | + $base_url = '', |
|
2916 | + $exclude_nonce = false |
|
2917 | + ) { |
|
2918 | + //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along) |
|
2919 | + if (empty($base_url) && ! isset($this->_page_routes[$action])) { |
|
2920 | + throw new EE_Error( |
|
2921 | + sprintf( |
|
2922 | + __( |
|
2923 | + 'There is no page route for given action for the button. This action was given: %s', |
|
2924 | + 'event_espresso' |
|
2925 | + ), |
|
2926 | + $action |
|
2927 | + ) |
|
2928 | + ); |
|
2929 | + } |
|
2930 | + if ( ! isset($this->_labels['buttons'][$type])) { |
|
2931 | + throw new EE_Error( |
|
2932 | + sprintf( |
|
2933 | + __( |
|
2934 | + 'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.', |
|
2935 | + 'event_espresso' |
|
2936 | + ), |
|
2937 | + $type |
|
2938 | + ) |
|
2939 | + ); |
|
2940 | + } |
|
2941 | + //finally check user access for this button. |
|
2942 | + $has_access = $this->check_user_access($action, true); |
|
2943 | + if ( ! $has_access) { |
|
2944 | + return ''; |
|
2945 | + } |
|
2946 | + $_base_url = ! $base_url ? $this->_admin_base_url : $base_url; |
|
2947 | + $query_args = array( |
|
2948 | + 'action' => $action, |
|
2949 | + ); |
|
2950 | + //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten. |
|
2951 | + if ( ! empty($extra_request)) { |
|
2952 | + $query_args = array_merge($extra_request, $query_args); |
|
2953 | + } |
|
2954 | + $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce); |
|
2955 | + return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class); |
|
2956 | + } |
|
2957 | + |
|
2958 | + |
|
2959 | + |
|
2960 | + /** |
|
2961 | + * _per_page_screen_option |
|
2962 | + * Utility function for adding in a per_page_option in the screen_options_dropdown. |
|
2963 | + * |
|
2964 | + * @return void |
|
2965 | + */ |
|
2966 | + protected function _per_page_screen_option() |
|
2967 | + { |
|
2968 | + $option = 'per_page'; |
|
2969 | + $args = array( |
|
2970 | + 'label' => $this->_admin_page_title, |
|
2971 | + 'default' => 10, |
|
2972 | + 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page', |
|
2973 | + ); |
|
2974 | + //ONLY add the screen option if the user has access to it. |
|
2975 | + if ($this->check_user_access($this->_current_view, true)) { |
|
2976 | + add_screen_option($option, $args); |
|
2977 | + } |
|
2978 | + } |
|
2979 | + |
|
2980 | + |
|
2981 | + |
|
2982 | + /** |
|
2983 | + * set_per_page_screen_option |
|
2984 | + * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page. |
|
2985 | + * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu. |
|
2986 | + * |
|
2987 | + * @access private |
|
2988 | + * @return void |
|
2989 | + */ |
|
2990 | + private function _set_per_page_screen_options() |
|
2991 | + { |
|
2992 | + if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) { |
|
2993 | + check_admin_referer('screen-options-nonce', 'screenoptionnonce'); |
|
2994 | + if ( ! $user = wp_get_current_user()) { |
|
2995 | + return; |
|
2996 | + } |
|
2997 | + $option = $_POST['wp_screen_options']['option']; |
|
2998 | + $value = $_POST['wp_screen_options']['value']; |
|
2999 | + if ($option != sanitize_key($option)) { |
|
3000 | + return; |
|
3001 | + } |
|
3002 | + $map_option = $option; |
|
3003 | + $option = str_replace('-', '_', $option); |
|
3004 | + switch ($map_option) { |
|
3005 | + case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
3006 | + $value = (int)$value; |
|
3007 | + if ($value < 1 || $value > 999) { |
|
3008 | + return; |
|
3009 | + } |
|
3010 | + break; |
|
3011 | + default: |
|
3012 | + $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value); |
|
3013 | + if (false === $value) { |
|
3014 | + return; |
|
3015 | + } |
|
3016 | + break; |
|
3017 | + } |
|
3018 | + update_user_meta($user->ID, $option, $value); |
|
3019 | + wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer())); |
|
3020 | + exit; |
|
3021 | + } |
|
3022 | + } |
|
3023 | + |
|
3024 | + |
|
3025 | + |
|
3026 | + /** |
|
3027 | + * This just allows for setting the $_template_args property if it needs to be set outside the object |
|
3028 | + * |
|
3029 | + * @param array $data array that will be assigned to template args. |
|
3030 | + */ |
|
3031 | + public function set_template_args($data) |
|
3032 | + { |
|
3033 | + $this->_template_args = array_merge($this->_template_args, (array)$data); |
|
3034 | + } |
|
3035 | + |
|
3036 | + |
|
3037 | + |
|
3038 | + /** |
|
3039 | + * This makes available the WP transient system for temporarily moving data between routes |
|
3040 | + * |
|
3041 | + * @access protected |
|
3042 | + * @param string $route the route that should receive the transient |
|
3043 | + * @param array $data the data that gets sent |
|
3044 | + * @param bool $notices If this is for notices then we use this to indicate so, otherwise its just a normal route transient. |
|
3045 | + * @param bool $skip_route_verify Used to indicate we want to skip route verification. This is usually ONLY used when we are adding a transient before page_routes have been defined. |
|
3046 | + * @return void |
|
3047 | + */ |
|
3048 | + protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false) |
|
3049 | + { |
|
3050 | + $user_id = get_current_user_id(); |
|
3051 | + if ( ! $skip_route_verify) { |
|
3052 | + $this->_verify_route($route); |
|
3053 | + } |
|
3054 | + //now let's set the string for what kind of transient we're setting |
|
3055 | + $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3056 | + $data = $notices ? array('notices' => $data) : $data; |
|
3057 | + //is there already a transient for this route? If there is then let's ADD to that transient |
|
3058 | + $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3059 | + if ($existing) { |
|
3060 | + $data = array_merge((array)$data, (array)$existing); |
|
3061 | + } |
|
3062 | + if (is_multisite() && is_network_admin()) { |
|
3063 | + set_site_transient($transient, $data, 8); |
|
3064 | + } else { |
|
3065 | + set_transient($transient, $data, 8); |
|
3066 | + } |
|
3067 | + } |
|
3068 | + |
|
3069 | + |
|
3070 | + |
|
3071 | + /** |
|
3072 | + * this retrieves the temporary transient that has been set for moving data between routes. |
|
3073 | + * |
|
3074 | + * @param bool $notices true we get notices transient. False we just return normal route transient |
|
3075 | + * @return mixed data |
|
3076 | + */ |
|
3077 | + protected function _get_transient($notices = false, $route = false) |
|
3078 | + { |
|
3079 | + $user_id = get_current_user_id(); |
|
3080 | + $route = ! $route ? $this->_req_action : $route; |
|
3081 | + $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
3082 | + $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
|
3083 | + //delete transient after retrieval (just in case it hasn't expired); |
|
3084 | + if (is_multisite() && is_network_admin()) { |
|
3085 | + delete_site_transient($transient); |
|
3086 | + } else { |
|
3087 | + delete_transient($transient); |
|
3088 | + } |
|
3089 | + return $notices && isset($data['notices']) ? $data['notices'] : $data; |
|
3090 | + } |
|
3091 | + |
|
3092 | + |
|
3093 | + |
|
3094 | + /** |
|
3095 | + * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later. |
|
3096 | + * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.) |
|
3097 | + * |
|
3098 | + * @return void |
|
3099 | + */ |
|
3100 | + protected function _transient_garbage_collection() |
|
3101 | + { |
|
3102 | + global $wpdb; |
|
3103 | + //retrieve all existing transients |
|
3104 | + $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'"; |
|
3105 | + if ($results = $wpdb->get_results($query)) { |
|
3106 | + foreach ($results as $result) { |
|
3107 | + $transient = str_replace('_transient_', '', $result->option_name); |
|
3108 | + get_transient($transient); |
|
3109 | + if (is_multisite() && is_network_admin()) { |
|
3110 | + get_site_transient($transient); |
|
3111 | + } |
|
3112 | + } |
|
3113 | + } |
|
3114 | + } |
|
3115 | + |
|
3116 | + |
|
3117 | + |
|
3118 | + /** |
|
3119 | + * get_view |
|
3120 | + * |
|
3121 | + * @access public |
|
3122 | + * @return string content of _view property |
|
3123 | + */ |
|
3124 | + public function get_view() |
|
3125 | + { |
|
3126 | + return $this->_view; |
|
3127 | + } |
|
3128 | + |
|
3129 | + |
|
3130 | + |
|
3131 | + /** |
|
3132 | + * getter for the protected $_views property |
|
3133 | + * |
|
3134 | + * @return array |
|
3135 | + */ |
|
3136 | + public function get_views() |
|
3137 | + { |
|
3138 | + return $this->_views; |
|
3139 | + } |
|
3140 | + |
|
3141 | + |
|
3142 | + |
|
3143 | + /** |
|
3144 | + * get_current_page |
|
3145 | + * |
|
3146 | + * @access public |
|
3147 | + * @return string _current_page property value |
|
3148 | + */ |
|
3149 | + public function get_current_page() |
|
3150 | + { |
|
3151 | + return $this->_current_page; |
|
3152 | + } |
|
3153 | + |
|
3154 | + |
|
3155 | + |
|
3156 | + /** |
|
3157 | + * get_current_view |
|
3158 | + * |
|
3159 | + * @access public |
|
3160 | + * @return string _current_view property value |
|
3161 | + */ |
|
3162 | + public function get_current_view() |
|
3163 | + { |
|
3164 | + return $this->_current_view; |
|
3165 | + } |
|
3166 | + |
|
3167 | + |
|
3168 | + |
|
3169 | + /** |
|
3170 | + * get_current_screen |
|
3171 | + * |
|
3172 | + * @access public |
|
3173 | + * @return object The current WP_Screen object |
|
3174 | + */ |
|
3175 | + public function get_current_screen() |
|
3176 | + { |
|
3177 | + return $this->_current_screen; |
|
3178 | + } |
|
3179 | + |
|
3180 | + |
|
3181 | + |
|
3182 | + /** |
|
3183 | + * get_current_page_view_url |
|
3184 | + * |
|
3185 | + * @access public |
|
3186 | + * @return string This returns the url for the current_page_view. |
|
3187 | + */ |
|
3188 | + public function get_current_page_view_url() |
|
3189 | + { |
|
3190 | + return $this->_current_page_view_url; |
|
3191 | + } |
|
3192 | + |
|
3193 | + |
|
3194 | + |
|
3195 | + /** |
|
3196 | + * just returns the _req_data property |
|
3197 | + * |
|
3198 | + * @return array |
|
3199 | + */ |
|
3200 | + public function get_request_data() |
|
3201 | + { |
|
3202 | + return $this->_req_data; |
|
3203 | + } |
|
3204 | + |
|
3205 | + |
|
3206 | + |
|
3207 | + /** |
|
3208 | + * returns the _req_data protected property |
|
3209 | + * |
|
3210 | + * @return string |
|
3211 | + */ |
|
3212 | + public function get_req_action() |
|
3213 | + { |
|
3214 | + return $this->_req_action; |
|
3215 | + } |
|
3216 | + |
|
3217 | + |
|
3218 | + |
|
3219 | + /** |
|
3220 | + * @return bool value of $_is_caf property |
|
3221 | + */ |
|
3222 | + public function is_caf() |
|
3223 | + { |
|
3224 | + return $this->_is_caf; |
|
3225 | + } |
|
3226 | + |
|
3227 | + |
|
3228 | + |
|
3229 | + /** |
|
3230 | + * @return mixed |
|
3231 | + */ |
|
3232 | + public function default_espresso_metaboxes() |
|
3233 | + { |
|
3234 | + return $this->_default_espresso_metaboxes; |
|
3235 | + } |
|
3236 | + |
|
3237 | + |
|
3238 | + |
|
3239 | + /** |
|
3240 | + * @return mixed |
|
3241 | + */ |
|
3242 | + public function admin_base_url() |
|
3243 | + { |
|
3244 | + return $this->_admin_base_url; |
|
3245 | + } |
|
3246 | + |
|
3247 | + |
|
3248 | + |
|
3249 | + /** |
|
3250 | + * @return mixed |
|
3251 | + */ |
|
3252 | + public function wp_page_slug() |
|
3253 | + { |
|
3254 | + return $this->_wp_page_slug; |
|
3255 | + } |
|
3256 | + |
|
3257 | + |
|
3258 | + |
|
3259 | + /** |
|
3260 | + * updates espresso configuration settings |
|
3261 | + * |
|
3262 | + * @access protected |
|
3263 | + * @param string $tab |
|
3264 | + * @param EE_Config_Base|EE_Config $config |
|
3265 | + * @param string $file file where error occurred |
|
3266 | + * @param string $func function where error occurred |
|
3267 | + * @param string $line line no where error occurred |
|
3268 | + * @return boolean |
|
3269 | + */ |
|
3270 | + protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '') |
|
3271 | + { |
|
3272 | + //remove any options that are NOT going to be saved with the config settings. |
|
3273 | + if (isset($config->core->ee_ueip_optin)) { |
|
3274 | + $config->core->ee_ueip_has_notified = true; |
|
3275 | + // TODO: remove the following two lines and make sure values are migrated from 3.1 |
|
3276 | + update_option('ee_ueip_optin', $config->core->ee_ueip_optin); |
|
3277 | + update_option('ee_ueip_has_notified', true); |
|
3278 | + } |
|
3279 | + // and save it (note we're also doing the network save here) |
|
3280 | + $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true; |
|
3281 | + $config_saved = EE_Config::instance()->update_espresso_config(false, false); |
|
3282 | + if ($config_saved && $net_saved) { |
|
3283 | + EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab)); |
|
3284 | + return true; |
|
3285 | + } else { |
|
3286 | + EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line); |
|
3287 | + return false; |
|
3288 | + } |
|
3289 | + } |
|
3290 | + |
|
3291 | + |
|
3292 | + |
|
3293 | + /** |
|
3294 | + * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument. |
|
3295 | + * |
|
3296 | + * @return array |
|
3297 | + */ |
|
3298 | + public function get_yes_no_values() |
|
3299 | + { |
|
3300 | + return $this->_yes_no_values; |
|
3301 | + } |
|
3302 | + |
|
3303 | + |
|
3304 | + |
|
3305 | + protected function _get_dir() |
|
3306 | + { |
|
3307 | + $reflector = new ReflectionClass(get_class($this)); |
|
3308 | + return dirname($reflector->getFileName()); |
|
3309 | + } |
|
3310 | + |
|
3311 | + |
|
3312 | + |
|
3313 | + /** |
|
3314 | + * A helper for getting a "next link". |
|
3315 | + * |
|
3316 | + * @param string $url The url to link to |
|
3317 | + * @param string $class The class to use. |
|
3318 | + * @return string |
|
3319 | + */ |
|
3320 | + protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') |
|
3321 | + { |
|
3322 | + return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3323 | + } |
|
3324 | + |
|
3325 | + |
|
3326 | + |
|
3327 | + /** |
|
3328 | + * A helper for getting a "previous link". |
|
3329 | + * |
|
3330 | + * @param string $url The url to link to |
|
3331 | + * @param string $class The class to use. |
|
3332 | + * @return string |
|
3333 | + */ |
|
3334 | + protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') |
|
3335 | + { |
|
3336 | + return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
3337 | + } |
|
3338 | + |
|
3339 | + |
|
3340 | + |
|
3341 | + |
|
3342 | + |
|
3343 | + |
|
3344 | + |
|
3345 | + //below are some messages related methods that should be available across the EE_Admin system. Note, these methods are NOT page specific |
|
3346 | + /** |
|
3347 | + * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data |
|
3348 | + * array. |
|
3349 | + * |
|
3350 | + * @return bool success/fail |
|
3351 | + */ |
|
3352 | + protected function _process_resend_registration() |
|
3353 | + { |
|
3354 | + $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data); |
|
3355 | + do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data); |
|
3356 | + return $this->_template_args['success']; |
|
3357 | + } |
|
3358 | + |
|
3359 | + |
|
3360 | + |
|
3361 | + /** |
|
3362 | + * This automatically processes any payment message notifications when manual payment has been applied. |
|
3363 | + * |
|
3364 | + * @access protected |
|
3365 | + * @param \EE_Payment $payment |
|
3366 | + * @return bool success/fail |
|
3367 | + */ |
|
3368 | + protected function _process_payment_notification(EE_Payment $payment) |
|
3369 | + { |
|
3370 | + add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true'); |
|
3371 | + do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment); |
|
3372 | + $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment); |
|
3373 | + return $this->_template_args['success']; |
|
3374 | + } |
|
3375 | 3375 | |
3376 | 3376 | |
3377 | 3377 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,239 +40,239 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.22.rc.029'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.22.rc.029'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - /** |
|
197 | - * espresso_plugin_activation |
|
198 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
199 | - */ |
|
200 | - function espresso_plugin_activation() |
|
201 | - { |
|
202 | - update_option('ee_espresso_activation', true); |
|
203 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + /** |
|
197 | + * espresso_plugin_activation |
|
198 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
199 | + */ |
|
200 | + function espresso_plugin_activation() |
|
201 | + { |
|
202 | + update_option('ee_espresso_activation', true); |
|
203 | + } |
|
204 | 204 | |
205 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
206 | - /** |
|
207 | - * espresso_load_error_handling |
|
208 | - * this function loads EE's class for handling exceptions and errors |
|
209 | - */ |
|
210 | - function espresso_load_error_handling() |
|
211 | - { |
|
212 | - // load debugging tools |
|
213 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
214 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
215 | - EEH_Debug_Tools::instance(); |
|
216 | - } |
|
217 | - // load error handling |
|
218 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
219 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
220 | - } else { |
|
221 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
222 | - } |
|
223 | - } |
|
205 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
206 | + /** |
|
207 | + * espresso_load_error_handling |
|
208 | + * this function loads EE's class for handling exceptions and errors |
|
209 | + */ |
|
210 | + function espresso_load_error_handling() |
|
211 | + { |
|
212 | + // load debugging tools |
|
213 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
214 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
215 | + EEH_Debug_Tools::instance(); |
|
216 | + } |
|
217 | + // load error handling |
|
218 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
219 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
220 | + } else { |
|
221 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
222 | + } |
|
223 | + } |
|
224 | 224 | |
225 | - /** |
|
226 | - * espresso_load_required |
|
227 | - * given a class name and path, this function will load that file or throw an exception |
|
228 | - * |
|
229 | - * @param string $classname |
|
230 | - * @param string $full_path_to_file |
|
231 | - * @throws EE_Error |
|
232 | - */ |
|
233 | - function espresso_load_required($classname, $full_path_to_file) |
|
234 | - { |
|
235 | - static $error_handling_loaded = false; |
|
236 | - if ( ! $error_handling_loaded) { |
|
237 | - espresso_load_error_handling(); |
|
238 | - $error_handling_loaded = true; |
|
239 | - } |
|
240 | - if (is_readable($full_path_to_file)) { |
|
241 | - require_once($full_path_to_file); |
|
242 | - } else { |
|
243 | - throw new EE_Error ( |
|
244 | - sprintf( |
|
245 | - esc_html__( |
|
246 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
247 | - 'event_espresso' |
|
248 | - ), |
|
249 | - $classname |
|
250 | - ) |
|
251 | - ); |
|
252 | - } |
|
253 | - } |
|
225 | + /** |
|
226 | + * espresso_load_required |
|
227 | + * given a class name and path, this function will load that file or throw an exception |
|
228 | + * |
|
229 | + * @param string $classname |
|
230 | + * @param string $full_path_to_file |
|
231 | + * @throws EE_Error |
|
232 | + */ |
|
233 | + function espresso_load_required($classname, $full_path_to_file) |
|
234 | + { |
|
235 | + static $error_handling_loaded = false; |
|
236 | + if ( ! $error_handling_loaded) { |
|
237 | + espresso_load_error_handling(); |
|
238 | + $error_handling_loaded = true; |
|
239 | + } |
|
240 | + if (is_readable($full_path_to_file)) { |
|
241 | + require_once($full_path_to_file); |
|
242 | + } else { |
|
243 | + throw new EE_Error ( |
|
244 | + sprintf( |
|
245 | + esc_html__( |
|
246 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
247 | + 'event_espresso' |
|
248 | + ), |
|
249 | + $classname |
|
250 | + ) |
|
251 | + ); |
|
252 | + } |
|
253 | + } |
|
254 | 254 | |
255 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
256 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
257 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
258 | - new EE_Bootstrap(); |
|
259 | - } |
|
255 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
256 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
257 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
258 | + new EE_Bootstrap(); |
|
259 | + } |
|
260 | 260 | } |
261 | 261 | if ( ! function_exists('espresso_deactivate_plugin')) { |
262 | - /** |
|
263 | - * deactivate_plugin |
|
264 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
265 | - * |
|
266 | - * @access public |
|
267 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
268 | - * @return void |
|
269 | - */ |
|
270 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
271 | - { |
|
272 | - if ( ! function_exists('deactivate_plugins')) { |
|
273 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
274 | - } |
|
275 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
276 | - deactivate_plugins($plugin_basename); |
|
277 | - } |
|
262 | + /** |
|
263 | + * deactivate_plugin |
|
264 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
265 | + * |
|
266 | + * @access public |
|
267 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
268 | + * @return void |
|
269 | + */ |
|
270 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
271 | + { |
|
272 | + if ( ! function_exists('deactivate_plugins')) { |
|
273 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
274 | + } |
|
275 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
276 | + deactivate_plugins($plugin_basename); |
|
277 | + } |
|
278 | 278 | } |