@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Class EE_Object_Repository |
@@ -38,9 +38,9 @@ discard block |
||
38 | 38 | * @param array $arguments arrays of arguments that will be passed to the object's callback method |
39 | 39 | * @return bool | int |
40 | 40 | */ |
41 | - protected function _call_user_func_array_on_current( $callback = '', $arguments = array() ) { |
|
42 | - if ( $callback !== '' && method_exists( $this->current(), $callback ) ) { |
|
43 | - return call_user_func_array( array( $this->current(), $callback ), $arguments ); |
|
41 | + protected function _call_user_func_array_on_current($callback = '', $arguments = array()) { |
|
42 | + if ($callback !== '' && method_exists($this->current(), $callback)) { |
|
43 | + return call_user_func_array(array($this->current(), $callback), $arguments); |
|
44 | 44 | } |
45 | 45 | return false; |
46 | 46 | } |
@@ -56,13 +56,13 @@ discard block |
||
56 | 56 | * @param string $callback name of method found on repository objects to be called |
57 | 57 | * @return bool | int |
58 | 58 | */ |
59 | - protected function _call_user_func_on_all( $callback = '' ) { |
|
59 | + protected function _call_user_func_on_all($callback = '') { |
|
60 | 60 | $success = true; |
61 | - if ( $this->valid() ) { |
|
61 | + if ($this->valid()) { |
|
62 | 62 | $this->rewind(); |
63 | - while ( $this->valid() ) { |
|
63 | + while ($this->valid()) { |
|
64 | 64 | // any negative result will toggle success to false |
65 | - $success = $this->_call_user_func_array_on_current( $callback ) ? $success : false; |
|
65 | + $success = $this->_call_user_func_array_on_current($callback) ? $success : false; |
|
66 | 66 | $this->next(); |
67 | 67 | } |
68 | 68 | $this->rewind(); |
@@ -86,9 +86,9 @@ discard block |
||
86 | 86 | * @param array $persistence_arguments arrays of arguments that will be passed to the object's persistence method |
87 | 87 | * @return bool | int |
88 | 88 | */ |
89 | - public function persist( $persistence_callback = '', $persistence_arguments = array() ) { |
|
90 | - $persistence_callback = ! empty( $persistence_callback ) ? $persistence_callback : $this->persist_method; |
|
91 | - return $this->_call_user_func_array_on_current( $persistence_callback, $persistence_arguments ); |
|
89 | + public function persist($persistence_callback = '', $persistence_arguments = array()) { |
|
90 | + $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
91 | + return $this->_call_user_func_array_on_current($persistence_callback, $persistence_arguments); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -102,9 +102,9 @@ discard block |
||
102 | 102 | * @param string $persistence_callback name of method found on object that can be used for persisting the object |
103 | 103 | * @return bool | int |
104 | 104 | */ |
105 | - public function persist_all( $persistence_callback = '' ) { |
|
106 | - $persistence_callback = ! empty( $persistence_callback ) ? $persistence_callback : $this->persist_method; |
|
107 | - return $this->_call_user_func_on_all( $persistence_callback ); |
|
105 | + public function persist_all($persistence_callback = '') { |
|
106 | + $persistence_callback = ! empty($persistence_callback) ? $persistence_callback : $this->persist_method; |
|
107 | + return $this->_call_user_func_on_all($persistence_callback); |
|
108 | 108 | } |
109 | 109 | |
110 | 110 |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -217,12 +218,15 @@ discard block |
||
217 | 218 | $this->_set_hooks_properties(); |
218 | 219 | |
219 | 220 | //first let's verify we're on the right page |
220 | - if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) |
|
221 | - return; //get out nothing more to be done here. |
|
221 | + if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) { |
|
222 | + return; |
|
223 | + } |
|
224 | + //get out nothing more to be done here. |
|
222 | 225 | |
223 | 226 | //allow for extends to modify properties |
224 | - if ( method_exists( $this, '_extend_properties' ) ) |
|
225 | - $this->_extend_properties(); |
|
227 | + if ( method_exists( $this, '_extend_properties' ) ) { |
|
228 | + $this->_extend_properties(); |
|
229 | + } |
|
226 | 230 | |
227 | 231 | $this->_set_page_object(); |
228 | 232 | $this->_init_hooks(); |
@@ -305,8 +309,10 @@ discard block |
||
305 | 309 | } |
306 | 310 | |
307 | 311 | //k now lets do the enqueues |
308 | - if( !isset( $this->_scripts_styles['enqueues'] ) ) |
|
309 | - return; //not sure if we should throw an error here or not. |
|
312 | + if( !isset( $this->_scripts_styles['enqueues'] ) ) { |
|
313 | + return; |
|
314 | + } |
|
315 | + //not sure if we should throw an error here or not. |
|
310 | 316 | foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) { |
311 | 317 | //make sure $routes is an array |
312 | 318 | $routes = (array) $routes; |
@@ -323,8 +329,9 @@ discard block |
||
323 | 329 | } |
324 | 330 | |
325 | 331 | //let's do the deregisters |
326 | - if ( !isset( $this->_scripts_styles['deregisters'] ) ) |
|
327 | - return; |
|
332 | + if ( !isset( $this->_scripts_styles['deregisters'] ) ) { |
|
333 | + return; |
|
334 | + } |
|
328 | 335 | foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) { |
329 | 336 | $defaults = array( |
330 | 337 | 'type' => 'js' |
@@ -376,8 +383,9 @@ discard block |
||
376 | 383 | |
377 | 384 | //first default file (if exists) |
378 | 385 | $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php'; |
379 | - if ( is_readable( $decaf_file ) ) |
|
380 | - require_once( $decaf_file ); |
|
386 | + if ( is_readable( $decaf_file ) ) { |
|
387 | + require_once( $decaf_file ); |
|
388 | + } |
|
381 | 389 | |
382 | 390 | //now we have to do require for extended file (if needed) |
383 | 391 | if ( $this->_extend ) { |
@@ -486,12 +494,14 @@ discard block |
||
486 | 494 | |
487 | 495 | foreach ( $hook_filter_array as $hook => $args ) { |
488 | 496 | if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) { |
489 | - if ( isset( $this->_wp_action_filters_priority[$hook] ) ) |
|
490 | - $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
491 | - if ( $args['type'] == 'action' ) |
|
492 | - add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
493 | - else |
|
494 | - add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
497 | + if ( isset( $this->_wp_action_filters_priority[$hook] ) ) { |
|
498 | + $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
|
499 | + } |
|
500 | + if ( $args['type'] == 'action' ) { |
|
501 | + add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
502 | + } else { |
|
503 | + add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
504 | + } |
|
495 | 505 | } |
496 | 506 | } |
497 | 507 | |
@@ -504,8 +514,10 @@ discard block |
||
504 | 514 | */ |
505 | 515 | private function _ajax_hooks() { |
506 | 516 | |
507 | - if ( empty( $this->_ajax_func) ) |
|
508 | - return; //get out there's nothing to take care of. |
|
517 | + if ( empty( $this->_ajax_func) ) { |
|
518 | + return; |
|
519 | + } |
|
520 | + //get out there's nothing to take care of. |
|
509 | 521 | |
510 | 522 | foreach ( $this->_ajax_func as $action => $method ) { |
511 | 523 | //make sure method exists |
@@ -528,8 +540,10 @@ discard block |
||
528 | 540 | * @return void |
529 | 541 | */ |
530 | 542 | protected function _init_hooks() { |
531 | - if ( empty( $this->_init_func) ) |
|
532 | - return; //get out there's nothing to take care of. |
|
543 | + if ( empty( $this->_init_func) ) { |
|
544 | + return; |
|
545 | + } |
|
546 | + //get out there's nothing to take care of. |
|
533 | 547 | |
534 | 548 | //We need to determine what page_route we are on! |
535 | 549 | $current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
@@ -541,8 +555,9 @@ discard block |
||
541 | 555 | $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
542 | 556 | throw new EE_Error( implode('||', $msg ) ); |
543 | 557 | } |
544 | - if ( $route == $this->_current_route ) |
|
545 | - add_action('admin_init', array( $this, $method ) ); |
|
558 | + if ( $route == $this->_current_route ) { |
|
559 | + add_action('admin_init', array( $this, $method ) ); |
|
560 | + } |
|
546 | 561 | } |
547 | 562 | |
548 | 563 | } |
@@ -557,8 +572,10 @@ discard block |
||
557 | 572 | * @return void |
558 | 573 | */ |
559 | 574 | public function add_metaboxes() { |
560 | - if ( empty( $this->_metaboxes ) ) |
|
561 | - return; //get out we don't have any metaboxes to set for this connection |
|
575 | + if ( empty( $this->_metaboxes ) ) { |
|
576 | + return; |
|
577 | + } |
|
578 | + //get out we don't have any metaboxes to set for this connection |
|
562 | 579 | |
563 | 580 | $this->_handle_metabox_array( $this->_metaboxes ); |
564 | 581 | |
@@ -569,19 +586,24 @@ discard block |
||
569 | 586 | private function _handle_metabox_array( $boxes, $add = TRUE ) { |
570 | 587 | |
571 | 588 | foreach ( $boxes as $box ) { |
572 | - if ( !isset($box['page_route']) ) |
|
573 | - continue; //we dont' have a valid array |
|
589 | + if ( !isset($box['page_route']) ) { |
|
590 | + continue; |
|
591 | + } |
|
592 | + //we dont' have a valid array |
|
574 | 593 | |
575 | 594 | //let's make sure $box['page_route'] is an array so the "foreach" will work. |
576 | 595 | $box['page_route'] = (array) $box['page_route']; |
577 | 596 | |
578 | 597 | foreach ( $box['page_route'] as $route ) { |
579 | - if ( $route != $this->_current_route ) |
|
580 | - continue; //get out we only add metaboxes for set route. |
|
581 | - if ( $add ) |
|
582 | - $this->_add_metabox($box); |
|
583 | - else |
|
584 | - $this->_remove_metabox($box); |
|
598 | + if ( $route != $this->_current_route ) { |
|
599 | + continue; |
|
600 | + } |
|
601 | + //get out we only add metaboxes for set route. |
|
602 | + if ( $add ) { |
|
603 | + $this->_add_metabox($box); |
|
604 | + } else { |
|
605 | + $this->_remove_metabox($box); |
|
606 | + } |
|
585 | 607 | } |
586 | 608 | } |
587 | 609 | } |
@@ -596,8 +618,10 @@ discard block |
||
596 | 618 | */ |
597 | 619 | public function remove_metaboxes() { |
598 | 620 | |
599 | - if ( empty( $this->_remove_metaboxes ) ) |
|
600 | - return; //get out there are no metaboxes to remove |
|
621 | + if ( empty( $this->_remove_metaboxes ) ) { |
|
622 | + return; |
|
623 | + } |
|
624 | + //get out there are no metaboxes to remove |
|
601 | 625 | |
602 | 626 | $this->_handle_metabox_array( $this->_remove_metaboxes, FALSE ); |
603 | 627 | } |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * constructor |
210 | 210 | * @param EE_Admin_Page $admin_page the calling admin_page_object |
211 | 211 | */ |
212 | - public function __construct( EE_Admin_Page $adminpage ) { |
|
212 | + public function __construct(EE_Admin_Page $adminpage) { |
|
213 | 213 | |
214 | 214 | $this->_adminpage_obj = $adminpage; |
215 | 215 | $this->_req_data = array_merge($_GET, $_POST); |
@@ -217,11 +217,11 @@ discard block |
||
217 | 217 | $this->_set_hooks_properties(); |
218 | 218 | |
219 | 219 | //first let's verify we're on the right page |
220 | - if ( !isset( $this->_req_data['page'] ) || ( isset( $this->_req_data['page'] ) && $this->_adminpage_obj->page_slug != $this->_req_data['page'] ) ) |
|
220 | + if ( ! isset($this->_req_data['page']) || (isset($this->_req_data['page']) && $this->_adminpage_obj->page_slug != $this->_req_data['page'])) |
|
221 | 221 | return; //get out nothing more to be done here. |
222 | 222 | |
223 | 223 | //allow for extends to modify properties |
224 | - if ( method_exists( $this, '_extend_properties' ) ) |
|
224 | + if (method_exists($this, '_extend_properties')) |
|
225 | 225 | $this->_extend_properties(); |
226 | 226 | |
227 | 227 | $this->_set_page_object(); |
@@ -229,9 +229,9 @@ discard block |
||
229 | 229 | $this->_load_custom_methods(); |
230 | 230 | $this->_load_routed_hooks(); |
231 | 231 | |
232 | - add_action( 'admin_enqueue_scripts', array($this, 'enqueue_scripts_styles' ) ); |
|
233 | - add_action( 'admin_enqueue_scripts', array($this, 'add_metaboxes'), 20 ); |
|
234 | - add_action( 'admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15 ); |
|
232 | + add_action('admin_enqueue_scripts', array($this, 'enqueue_scripts_styles')); |
|
233 | + add_action('admin_enqueue_scripts', array($this, 'add_metaboxes'), 20); |
|
234 | + add_action('admin_enqueue_scripts', array($this, 'remove_metaboxes'), 15); |
|
235 | 235 | |
236 | 236 | $this->_ajax_hooks(); |
237 | 237 | |
@@ -272,15 +272,15 @@ discard block |
||
272 | 272 | */ |
273 | 273 | public function enqueue_scripts_styles() { |
274 | 274 | |
275 | - if ( !empty( $this->_scripts_styles ) ) { |
|
275 | + if ( ! empty($this->_scripts_styles)) { |
|
276 | 276 | //first let's do all the registrations |
277 | - if ( !isset($this->_scripts_styles['registers'] ) ) { |
|
277 | + if ( ! isset($this->_scripts_styles['registers'])) { |
|
278 | 278 | $msg[] = __('There is no "registers" index in the <code>$this->_scripts_styles</code> property.', 'event_espresso'); |
279 | - $msg[] = sprintf ( __('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>' . $this->caller . '</strong>' ); |
|
280 | - throw new EE_Error( implode( '||', $msg ) ); |
|
279 | + $msg[] = sprintf(__('Make sure you read the phpdoc comments above the definition of the $_scripts_styles property in the <code>EE_Admin_Hooks</code> class and modify according in the %s child', 'event_espresso'), '<strong>'.$this->caller.'</strong>'); |
|
280 | + throw new EE_Error(implode('||', $msg)); |
|
281 | 281 | } |
282 | 282 | |
283 | - foreach( $this->_scripts_styles['registers'] as $ref => $details ) { |
|
283 | + foreach ($this->_scripts_styles['registers'] as $ref => $details) { |
|
284 | 284 | $defaults = array( |
285 | 285 | 'type' => 'js', |
286 | 286 | 'url' => '', |
@@ -289,48 +289,48 @@ discard block |
||
289 | 289 | 'footer' => TRUE |
290 | 290 | ); |
291 | 291 | $details = wp_parse_args($details, $defaults); |
292 | - extract( $details ); |
|
292 | + extract($details); |
|
293 | 293 | |
294 | 294 | //let's make sure that we set the 'registers' type if it's not set! We need it later to determine whhich enqueu we do |
295 | 295 | $this->_scripts_styles['registers'][$ref]['type'] = $type; |
296 | 296 | |
297 | 297 | //let's make sure we're not missing any REQUIRED parameters |
298 | - if ( empty($url) ) { |
|
299 | - $msg[] = sprintf( __('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet' ); |
|
300 | - $msg[] = sprintf( __('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>' . $this->caller . '</strong>', $ref ); |
|
301 | - throw new EE_Error( implode( '||', $msg ) ); |
|
298 | + if (empty($url)) { |
|
299 | + $msg[] = sprintf(__('Missing the url for the requested %s', 'event_espresso'), $type == 'js' ? 'script' : 'stylesheet'); |
|
300 | + $msg[] = sprintf(__('Doublecheck your <code>$this->_scripts_styles</code> array in %s and make sure that there is a "url" set for the %s ref', 'event_espresso'), '<strong>'.$this->caller.'</strong>', $ref); |
|
301 | + throw new EE_Error(implode('||', $msg)); |
|
302 | 302 | } |
303 | 303 | //made it here so let's do the appropriate registration |
304 | - $type == 'js' ? wp_register_script( $ref, $url, $depends, $version, $footer ) : wp_register_style( $ref, $url, $depends, $version ); |
|
304 | + $type == 'js' ? wp_register_script($ref, $url, $depends, $version, $footer) : wp_register_style($ref, $url, $depends, $version); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | //k now lets do the enqueues |
308 | - if( !isset( $this->_scripts_styles['enqueues'] ) ) |
|
309 | - return; //not sure if we should throw an error here or not. |
|
310 | - foreach( $this->_scripts_styles['enqueues'] as $ref => $routes ) { |
|
308 | + if ( ! isset($this->_scripts_styles['enqueues'])) |
|
309 | + return; //not sure if we should throw an error here or not. |
|
310 | + foreach ($this->_scripts_styles['enqueues'] as $ref => $routes) { |
|
311 | 311 | //make sure $routes is an array |
312 | 312 | $routes = (array) $routes; |
313 | 313 | |
314 | - if ( in_array($this->_current_route, $routes ) ) { |
|
314 | + if (in_array($this->_current_route, $routes)) { |
|
315 | 315 | $this->_scripts_styles['registers'][$ref]['type'] == 'js' ? wp_enqueue_script($ref) : wp_enqueue_style($ref); |
316 | 316 | //if we have a localization for the script let's do that too. |
317 | - if ( isset( $this->_scripts_styles['localize'][$ref] ) ) { |
|
318 | - foreach ( $this->_scripts_styles['localize'][$ref] as $object_name => $indexes ) { |
|
319 | - wp_localize_script($ref, $object_name , $this->_scripts_styles['localize'][$ref][$object_name] ); |
|
317 | + if (isset($this->_scripts_styles['localize'][$ref])) { |
|
318 | + foreach ($this->_scripts_styles['localize'][$ref] as $object_name => $indexes) { |
|
319 | + wp_localize_script($ref, $object_name, $this->_scripts_styles['localize'][$ref][$object_name]); |
|
320 | 320 | } |
321 | 321 | } |
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | 325 | //let's do the deregisters |
326 | - if ( !isset( $this->_scripts_styles['deregisters'] ) ) |
|
326 | + if ( ! isset($this->_scripts_styles['deregisters'])) |
|
327 | 327 | return; |
328 | - foreach ( $this->_scripts_styles['deregisters'] as $ref => $details ) { |
|
328 | + foreach ($this->_scripts_styles['deregisters'] as $ref => $details) { |
|
329 | 329 | $defaults = array( |
330 | 330 | 'type' => 'js' |
331 | 331 | ); |
332 | - $details = wp_parse_args( $details, $defaults ); |
|
333 | - extract( $details ); |
|
332 | + $details = wp_parse_args($details, $defaults); |
|
333 | + extract($details); |
|
334 | 334 | |
335 | 335 | $type == 'js' ? wp_deregister_script($ref) : wp_deregister_style($ref); |
336 | 336 | |
@@ -349,7 +349,7 @@ discard block |
||
349 | 349 | */ |
350 | 350 | private function _set_defaults() { |
351 | 351 | $this->_ajax_func = $this->_init_func = $this->_metaboxes = $this->_scripts = $this->_styles = $this->_wp_action_filters_priority = array(); |
352 | - $this->_current_route = isset( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
|
352 | + $this->_current_route = isset($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
353 | 353 | $this->caller = get_class($this); |
354 | 354 | $this->_extend = stripos($this->caller, 'Extend') ? TRUE : FALSE; |
355 | 355 | } |
@@ -364,34 +364,34 @@ discard block |
||
364 | 364 | */ |
365 | 365 | protected function _set_page_object() { |
366 | 366 | //first make sure $this->_name is set |
367 | - if ( empty( $this->_name ) ) { |
|
367 | + if (empty($this->_name)) { |
|
368 | 368 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
369 | - $msg[] = sprintf( __("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller ); |
|
370 | - throw new EE_Error( implode( '||', $msg ) ); |
|
369 | + $msg[] = sprintf(__("This is because the %s child class has not set the '_name' property", 'event_espresso'), $this->caller); |
|
370 | + throw new EE_Error(implode('||', $msg)); |
|
371 | 371 | } |
372 | 372 | |
373 | - $ref = str_replace('_' , ' ', $this->_name); //take the_message -> the message |
|
374 | - $ref = str_replace(' ', '_', ucwords($ref) ) . '_Admin_Page'; //take the message -> The_Message |
|
373 | + $ref = str_replace('_', ' ', $this->_name); //take the_message -> the message |
|
374 | + $ref = str_replace(' ', '_', ucwords($ref)).'_Admin_Page'; //take the message -> The_Message |
|
375 | 375 | |
376 | 376 | //first default file (if exists) |
377 | - $decaf_file = EE_ADMIN_PAGES . $this->_name . DS . $ref . '.core.php'; |
|
378 | - if ( is_readable( $decaf_file ) ) |
|
379 | - require_once( $decaf_file ); |
|
377 | + $decaf_file = EE_ADMIN_PAGES.$this->_name.DS.$ref.'.core.php'; |
|
378 | + if (is_readable($decaf_file)) |
|
379 | + require_once($decaf_file); |
|
380 | 380 | |
381 | 381 | //now we have to do require for extended file (if needed) |
382 | - if ( $this->_extend ) { |
|
383 | - require_once( EE_CORE_CAF_ADMIN_EXTEND . $this->_name . DS . 'Extend_' . $ref . '.core.php' ); |
|
382 | + if ($this->_extend) { |
|
383 | + require_once(EE_CORE_CAF_ADMIN_EXTEND.$this->_name.DS.'Extend_'.$ref.'.core.php'); |
|
384 | 384 | } |
385 | 385 | |
386 | 386 | |
387 | 387 | //if we've got an extended class we use that! |
388 | - $ref = $this->_extend ? 'Extend_' . $ref : $ref; |
|
388 | + $ref = $this->_extend ? 'Extend_'.$ref : $ref; |
|
389 | 389 | |
390 | 390 | //let's make sure the class exists |
391 | - if ( !class_exists( $ref ) ) { |
|
391 | + if ( ! class_exists($ref)) { |
|
392 | 392 | $msg[] = __('We can\'t load the page object', 'event_espresso'); |
393 | - $msg[] = sprintf( __('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref ); |
|
394 | - throw new EE_Error( implode( '||', $msg ) ); |
|
393 | + $msg[] = sprintf(__('The class name that was given is %s. Check the spelling and make sure its correct, also there needs to be an autoloader setup for the class', 'event_espresso'), $ref); |
|
394 | + throw new EE_Error(implode('||', $msg)); |
|
395 | 395 | } |
396 | 396 | |
397 | 397 | $a = new ReflectionClass($ref); |
@@ -416,27 +416,27 @@ discard block |
||
416 | 416 | $method_callback = $this->_current_route == 'default' ? 'default_callback' : $this->_current_route; |
417 | 417 | |
418 | 418 | //these run before the Admin_Page route executes. |
419 | - if ( method_exists( $this, $method_callback ) ) { |
|
420 | - call_user_func( array( $this, $method_callback) ); |
|
419 | + if (method_exists($this, $method_callback)) { |
|
420 | + call_user_func(array($this, $method_callback)); |
|
421 | 421 | } |
422 | 422 | |
423 | 423 | |
424 | 424 | //these run via the _redirect_after_action method in EE_Admin_Page which usually happens after non_UI methods in EE_Admin_Page classes. There are two redirect actions, the first fires before $query_args might be manipulated by "save and close" actions and the seond fires right before the actual redirect happens. |
425 | 425 | //first the actions |
426 | 426 | //note that these action hooks will have the $query_args value available. |
427 | - $admin_class_name = get_class( $this->_adminpage_obj ); |
|
427 | + $admin_class_name = get_class($this->_adminpage_obj); |
|
428 | 428 | |
429 | - if ( method_exists( $this, '_redirect_action_early_' . $this->_current_route ) ) { |
|
430 | - add_action( 'AHEE__' . $admin_class_name . '___redirect_after_action__before_redirect_modification_' . $this->_current_route, array( $this, '_redirect_action_early_' . $this->_current_route ), 10 ); |
|
429 | + if (method_exists($this, '_redirect_action_early_'.$this->_current_route)) { |
|
430 | + add_action('AHEE__'.$admin_class_name.'___redirect_after_action__before_redirect_modification_'.$this->_current_route, array($this, '_redirect_action_early_'.$this->_current_route), 10); |
|
431 | 431 | } |
432 | 432 | |
433 | - if ( method_exists( $this, '_redirect_action_' . $this->_current_route ) ) { |
|
434 | - add_action( 'AHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_action_' . $this->_current_route ), 10 ); |
|
433 | + if (method_exists($this, '_redirect_action_'.$this->_current_route)) { |
|
434 | + add_action('AHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_action_'.$this->_current_route), 10); |
|
435 | 435 | } |
436 | 436 | |
437 | 437 | //let's hook into the _redirect itself and allow for changing where the user goes after redirect. This will have $query_args and $redirect_url available. |
438 | - if ( method_exists( $this, '_redirect_filter_' . $this->_current_route ) ) { |
|
439 | - add_filter( 'FHEE_redirect_' . $admin_class_name . $this->_current_route, array( $this, '_redirect_filter_' . $this->_current_route ), 10, 2 ); |
|
438 | + if (method_exists($this, '_redirect_filter_'.$this->_current_route)) { |
|
439 | + add_filter('FHEE_redirect_'.$admin_class_name.$this->_current_route, array($this, '_redirect_filter_'.$this->_current_route), 10, 2); |
|
440 | 440 | } |
441 | 441 | |
442 | 442 | } |
@@ -459,12 +459,12 @@ discard block |
||
459 | 459 | 'argnum' => 1, |
460 | 460 | 'priority' => 10 |
461 | 461 | ), |
462 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug . '_' . $this->_current_route => array( |
|
462 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug.'_'.$this->_current_route => array( |
|
463 | 463 | 'type' => 'filter', |
464 | 464 | 'argnum' => 1, |
465 | 465 | 'priority' => 10 |
466 | 466 | ), |
467 | - 'FHEE_list_table_views_' . $this->_adminpage_obj->page_slug => array( |
|
467 | + 'FHEE_list_table_views_'.$this->_adminpage_obj->page_slug => array( |
|
468 | 468 | 'type' => 'filter', |
469 | 469 | 'argnum' => 1, |
470 | 470 | 'priority' => 10 |
@@ -483,14 +483,14 @@ discard block |
||
483 | 483 | |
484 | 484 | |
485 | 485 | |
486 | - foreach ( $hook_filter_array as $hook => $args ) { |
|
487 | - if ( method_exists( $this, $this->_current_route . '_' . $hook ) ) { |
|
488 | - if ( isset( $this->_wp_action_filters_priority[$hook] ) ) |
|
486 | + foreach ($hook_filter_array as $hook => $args) { |
|
487 | + if (method_exists($this, $this->_current_route.'_'.$hook)) { |
|
488 | + if (isset($this->_wp_action_filters_priority[$hook])) |
|
489 | 489 | $args['priority'] = $this->_wp_action_filters_priority[$hook]; |
490 | - if ( $args['type'] == 'action' ) |
|
491 | - add_action( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
490 | + if ($args['type'] == 'action') |
|
491 | + add_action($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']); |
|
492 | 492 | else |
493 | - add_filter( $hook, array( $this, $this->_current_route . '_' . $hook ), $args['priority'], $args['argnum'] ); |
|
493 | + add_filter($hook, array($this, $this->_current_route.'_'.$hook), $args['priority'], $args['argnum']); |
|
494 | 494 | } |
495 | 495 | } |
496 | 496 | |
@@ -503,18 +503,18 @@ discard block |
||
503 | 503 | */ |
504 | 504 | private function _ajax_hooks() { |
505 | 505 | |
506 | - if ( empty( $this->_ajax_func) ) |
|
506 | + if (empty($this->_ajax_func)) |
|
507 | 507 | return; //get out there's nothing to take care of. |
508 | 508 | |
509 | - foreach ( $this->_ajax_func as $action => $method ) { |
|
509 | + foreach ($this->_ajax_func as $action => $method) { |
|
510 | 510 | //make sure method exists |
511 | - if ( !method_exists($this, $method) ) { |
|
512 | - $msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso') . '<br />'; |
|
513 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
|
514 | - throw new EE_Error( implode('||', $msg ) ); |
|
511 | + if ( ! method_exists($this, $method)) { |
|
512 | + $msg[] = __('There is no corresponding method for the hook labeled in the _ajax_func array', 'event_espresso').'<br />'; |
|
513 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller); |
|
514 | + throw new EE_Error(implode('||', $msg)); |
|
515 | 515 | } |
516 | 516 | |
517 | - add_action('wp_ajax_' . $action, array( $this, $method ) ); |
|
517 | + add_action('wp_ajax_'.$action, array($this, $method)); |
|
518 | 518 | } |
519 | 519 | |
520 | 520 | } |
@@ -527,21 +527,21 @@ discard block |
||
527 | 527 | * @return void |
528 | 528 | */ |
529 | 529 | protected function _init_hooks() { |
530 | - if ( empty( $this->_init_func) ) |
|
530 | + if (empty($this->_init_func)) |
|
531 | 531 | return; //get out there's nothing to take care of. |
532 | 532 | |
533 | 533 | //We need to determine what page_route we are on! |
534 | - $current_route = isset ( $_REQUEST['action'] ) ? $_REQUEST['action'] : 'default'; |
|
534 | + $current_route = isset ($_REQUEST['action']) ? $_REQUEST['action'] : 'default'; |
|
535 | 535 | |
536 | - foreach ( $this->_init_func as $route => $method ) { |
|
536 | + foreach ($this->_init_func as $route => $method) { |
|
537 | 537 | //make sure method exists |
538 | - if ( !method_exists($this, $method) ) { |
|
539 | - $msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso') . '<br />'; |
|
540 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $method, $this->caller ); |
|
541 | - throw new EE_Error( implode('||', $msg ) ); |
|
538 | + if ( ! method_exists($this, $method)) { |
|
539 | + $msg[] = __('There is no corresponding method for the hook labeled in the _init_func array', 'event_espresso').'<br />'; |
|
540 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $method, $this->caller); |
|
541 | + throw new EE_Error(implode('||', $msg)); |
|
542 | 542 | } |
543 | - if ( $route == $this->_current_route ) |
|
544 | - add_action('admin_init', array( $this, $method ) ); |
|
543 | + if ($route == $this->_current_route) |
|
544 | + add_action('admin_init', array($this, $method)); |
|
545 | 545 | } |
546 | 546 | |
547 | 547 | } |
@@ -556,28 +556,28 @@ discard block |
||
556 | 556 | * @return void |
557 | 557 | */ |
558 | 558 | public function add_metaboxes() { |
559 | - if ( empty( $this->_metaboxes ) ) |
|
559 | + if (empty($this->_metaboxes)) |
|
560 | 560 | return; //get out we don't have any metaboxes to set for this connection |
561 | 561 | |
562 | - $this->_handle_metabox_array( $this->_metaboxes ); |
|
562 | + $this->_handle_metabox_array($this->_metaboxes); |
|
563 | 563 | |
564 | 564 | } |
565 | 565 | |
566 | 566 | |
567 | 567 | |
568 | - private function _handle_metabox_array( $boxes, $add = TRUE ) { |
|
568 | + private function _handle_metabox_array($boxes, $add = TRUE) { |
|
569 | 569 | |
570 | - foreach ( $boxes as $box ) { |
|
571 | - if ( !isset($box['page_route']) ) |
|
570 | + foreach ($boxes as $box) { |
|
571 | + if ( ! isset($box['page_route'])) |
|
572 | 572 | continue; //we dont' have a valid array |
573 | 573 | |
574 | 574 | //let's make sure $box['page_route'] is an array so the "foreach" will work. |
575 | 575 | $box['page_route'] = (array) $box['page_route']; |
576 | 576 | |
577 | - foreach ( $box['page_route'] as $route ) { |
|
578 | - if ( $route != $this->_current_route ) |
|
577 | + foreach ($box['page_route'] as $route) { |
|
578 | + if ($route != $this->_current_route) |
|
579 | 579 | continue; //get out we only add metaboxes for set route. |
580 | - if ( $add ) |
|
580 | + if ($add) |
|
581 | 581 | $this->_add_metabox($box); |
582 | 582 | else |
583 | 583 | $this->_remove_metabox($box); |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | */ |
596 | 596 | public function remove_metaboxes() { |
597 | 597 | |
598 | - if ( empty( $this->_remove_metaboxes ) ) |
|
598 | + if (empty($this->_remove_metaboxes)) |
|
599 | 599 | return; //get out there are no metaboxes to remove |
600 | 600 | |
601 | - $this->_handle_metabox_array( $this->_remove_metaboxes, FALSE ); |
|
601 | + $this->_handle_metabox_array($this->_remove_metaboxes, FALSE); |
|
602 | 602 | } |
603 | 603 | |
604 | 604 | |
@@ -608,53 +608,53 @@ discard block |
||
608 | 608 | * @access private |
609 | 609 | * @param array $args an array of args that have been set for this metabox by the child class |
610 | 610 | */ |
611 | - private function _add_metabox( $args ) { |
|
611 | + private function _add_metabox($args) { |
|
612 | 612 | $current_screen = get_current_screen(); |
613 | - $screen_id = is_object( $current_screen ) ? $current_screen->id : NULL; |
|
614 | - $func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback'; |
|
613 | + $screen_id = is_object($current_screen) ? $current_screen->id : NULL; |
|
614 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
615 | 615 | |
616 | 616 | //set defaults |
617 | 617 | $defaults = array( |
618 | 618 | 'func' => $func, |
619 | - 'id' => $this->caller . '_' . $func . '_metabox', |
|
619 | + 'id' => $this->caller.'_'.$func.'_metabox', |
|
620 | 620 | 'priority' => 'default', |
621 | 621 | 'label' => $this->caller, |
622 | 622 | 'context' => 'advanced', |
623 | 623 | 'callback_args' => array(), |
624 | - 'page' => isset( $args['page'] ) ? $args['page'] : $screen_id |
|
624 | + 'page' => isset($args['page']) ? $args['page'] : $screen_id |
|
625 | 625 | ); |
626 | 626 | |
627 | - $args = wp_parse_args( $args, $defaults ); |
|
627 | + $args = wp_parse_args($args, $defaults); |
|
628 | 628 | extract($args); |
629 | 629 | |
630 | 630 | |
631 | 631 | //make sure method exists |
632 | - if ( !method_exists($this, $func) ) { |
|
633 | - $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso') . '<br />'; |
|
634 | - $msg[] = sprintf( __('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso' ), $func, $this->caller ); |
|
635 | - throw new EE_Error( implode('||', $msg ) ); |
|
632 | + if ( ! method_exists($this, $func)) { |
|
633 | + $msg[] = __('There is no corresponding method to display the metabox content', 'event_espresso').'<br />'; |
|
634 | + $msg[] = sprintf(__('The method name given in the array is %s, check the spelling and make sure it exists in the %s class', 'event_espresso'), $func, $this->caller); |
|
635 | + throw new EE_Error(implode('||', $msg)); |
|
636 | 636 | } |
637 | 637 | |
638 | 638 | //everything checks out so lets add the metabox |
639 | - add_meta_box( $id, $label, array( $this, $func ), $page, $context, $priority, $callback_args); |
|
639 | + add_meta_box($id, $label, array($this, $func), $page, $context, $priority, $callback_args); |
|
640 | 640 | } |
641 | 641 | |
642 | 642 | |
643 | 643 | |
644 | - private function _remove_metabox( $args ) { |
|
644 | + private function _remove_metabox($args) { |
|
645 | 645 | $current_screen = get_current_screen(); |
646 | - $screen_id = is_object( $current_screen ) ? $current_screen->id : NULL; |
|
647 | - $func = isset( $args['func'] ) ? $args['func'] : 'some_invalid_callback'; |
|
646 | + $screen_id = is_object($current_screen) ? $current_screen->id : NULL; |
|
647 | + $func = isset($args['func']) ? $args['func'] : 'some_invalid_callback'; |
|
648 | 648 | |
649 | 649 | //set defaults |
650 | 650 | $defaults = array( |
651 | - 'id' => isset( $args['id'] ) ? $args['id'] : $this->_current_route . '_' . $this->caller . '_' . $func . '_metabox', |
|
651 | + 'id' => isset($args['id']) ? $args['id'] : $this->_current_route.'_'.$this->caller.'_'.$func.'_metabox', |
|
652 | 652 | 'context' => 'default', |
653 | - 'screen' => isset( $args['screen'] ) ? $args['screen'] : $screen_id |
|
653 | + 'screen' => isset($args['screen']) ? $args['screen'] : $screen_id |
|
654 | 654 | ); |
655 | 655 | |
656 | - $args = wp_parse_args( $args, $defaults ); |
|
657 | - extract( $args ); |
|
656 | + $args = wp_parse_args($args, $defaults); |
|
657 | + extract($args); |
|
658 | 658 | |
659 | 659 | //everything checks out so lets remove the box! |
660 | 660 | remove_meta_box($id, $screen, $context); |
@@ -32,7 +32,7 @@ discard block |
||
32 | 32 | public function do_initial_loads() { |
33 | 33 | //we want to use the corresponding admin page object (but not route it!). To do this we just set _routing to false. That way this page object is being loaded on all pages to make sure we hook into admin properly. But note... we are ONLY doing this if the given page is NOT pages we WANT to load ;) |
34 | 34 | //This is important because we have hooks that help redirect custom post type saves |
35 | - if ( !isset( $_REQUEST['page'] ) || ( isset( $_REQUEST['page'] ) && $_REQUEST['page'] != $this->_menu_map->menu_slug ) ) { |
|
35 | + if ( ! isset($_REQUEST['page']) || (isset($_REQUEST['page']) && $_REQUEST['page'] != $this->_menu_map->menu_slug)) { |
|
36 | 36 | $this->_routing = FALSE; |
37 | 37 | $this->_initialize_admin_page(); |
38 | 38 | } else { |
@@ -40,17 +40,17 @@ discard block |
||
40 | 40 | $this->_initialize_admin_page(); |
41 | 41 | //added for 4.1 to completely disable autosave for our pages. This can be removed once we fully enable autosave functionality |
42 | 42 | remove_filter('wp_print_scripts', 'wp_just_in_time_script_localization'); |
43 | - add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100 ); |
|
43 | + add_filter('wp_print_scripts', array($this, 'wp_just_in_time_script_localization'), 100); |
|
44 | 44 | //end removal of autosave functionality. |
45 | 45 | } |
46 | 46 | } |
47 | 47 | |
48 | 48 | public function wp_just_in_time_script_localization() { |
49 | - wp_localize_script( 'autosave', 'autosaveL10n', array( |
|
49 | + wp_localize_script('autosave', 'autosaveL10n', array( |
|
50 | 50 | 'autosaveInterval' => 172800, |
51 | 51 | 'savingText' => __('Saving Draft…'), |
52 | 52 | 'saveAlert' => __('The changes you made will be lost if you navigate away from this page.') |
53 | - ) ); |
|
53 | + )); |
|
54 | 54 | } |
55 | 55 | |
56 | 56 |
@@ -1,4 +1,6 @@ |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -1,4 +1,6 @@ discard block |
||
1 | -<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | +} |
|
2 | 4 | /** |
3 | 5 | * Event Espresso |
4 | 6 | * |
@@ -220,7 +222,9 @@ discard block |
||
220 | 222 | public function initialize_admin_page() { |
221 | 223 | //let's check user access first |
222 | 224 | $this->_check_user_access(); |
223 | - if ( !is_object( $this->_loaded_page_object) ) return; |
|
225 | + if ( !is_object( $this->_loaded_page_object) ) { |
|
226 | + return; |
|
227 | + } |
|
224 | 228 | $this->_loaded_page_object->route_admin_request(); |
225 | 229 | return; |
226 | 230 | } |
@@ -232,7 +236,9 @@ discard block |
||
232 | 236 | |
233 | 237 | |
234 | 238 | public function set_page_dependencies($wp_page_slug) { |
235 | - if ( !$this->_load_page ) return; |
|
239 | + if ( !$this->_load_page ) { |
|
240 | + return; |
|
241 | + } |
|
236 | 242 | |
237 | 243 | if ( !is_object($this->_loaded_page_object) ) { |
238 | 244 | $msg[] = __('We can\'t load the page because we\'re missing a valid page object that tells us what to load', 'event_espresso'); |
@@ -249,8 +255,9 @@ discard block |
||
249 | 255 | $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
250 | 256 | $page_hook = 'load-' . $wp_page_slug; |
251 | 257 | //hook into page load hook so all page specific stuff get's loaded. |
252 | - if ( !empty($wp_page_slug) ) |
|
253 | - add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') ); |
|
258 | + if ( !empty($wp_page_slug) ) { |
|
259 | + add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') ); |
|
260 | + } |
|
254 | 261 | } |
255 | 262 | |
256 | 263 | |
@@ -283,7 +290,9 @@ discard block |
||
283 | 290 | if ( isset( $values['class'] ) && $values['class'] == $class ) { |
284 | 291 | $file_index = $index - 1; |
285 | 292 | $this->_folder_name = basename(dirname($bt[$file_index]['file']) ); |
286 | - if ( !empty( $this->_folder_name ) ) break; |
|
293 | + if ( !empty( $this->_folder_name ) ) { |
|
294 | + break; |
|
295 | + } |
|
287 | 296 | } |
288 | 297 | } |
289 | 298 | |
@@ -337,8 +346,9 @@ discard block |
||
337 | 346 | $hook_paths[] = $file; |
338 | 347 | |
339 | 348 | //make sure we haven't already got a hook setup for this page path |
340 | - if ( in_array( $rel_admin, $this->_files_hooked ) ) |
|
341 | - continue; |
|
349 | + if ( in_array( $rel_admin, $this->_files_hooked ) ) { |
|
350 | + continue; |
|
351 | + } |
|
342 | 352 | |
343 | 353 | $this->hook_file = $hook_file; |
344 | 354 | $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
@@ -367,8 +377,10 @@ discard block |
||
367 | 377 | protected function _initialize_admin_page() { |
368 | 378 | |
369 | 379 | //JUST CHECK WE'RE ON RIGHT PAGE. |
370 | - if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) |
|
371 | - return; //not on the right page so let's get out. |
|
380 | + if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) { |
|
381 | + return; |
|
382 | + } |
|
383 | + //not on the right page so let's get out. |
|
372 | 384 | $this->_load_page = TRUE; |
373 | 385 | |
374 | 386 | //let's set page specific autoloaders. Note that this just sets autoloaders for THIS set of admin pages. |
@@ -153,18 +153,18 @@ |
||
153 | 153 | |
154 | 154 | |
155 | 155 | /** |
156 | - * This loads scripts and styles for the EE_Admin system |
|
157 | - * that must be available on ALL WP admin pages (i.e. EE_menu items) |
|
158 | - * |
|
156 | + * This loads scripts and styles for the EE_Admin system |
|
157 | + * that must be available on ALL WP admin pages (i.e. EE_menu items) |
|
158 | + * |
|
159 | 159 | * @return void |
160 | 160 | */ |
161 | 161 | public function load_wp_global_scripts_styles() { |
162 | 162 | wp_register_style( |
163 | - 'espresso_menu', |
|
164 | - EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
165 | - array('dashicons'), |
|
166 | - EVENT_ESPRESSO_VERSION |
|
167 | - ); |
|
163 | + 'espresso_menu', |
|
164 | + EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
165 | + array('dashicons'), |
|
166 | + EVENT_ESPRESSO_VERSION |
|
167 | + ); |
|
168 | 168 | wp_enqueue_style('espresso_menu'); |
169 | 169 | } |
170 | 170 |
@@ -88,16 +88,16 @@ discard block |
||
88 | 88 | $this->_set_init_properties(); |
89 | 89 | |
90 | 90 | //global styles/scripts across all wp admin pages |
91 | - add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5 ); |
|
91 | + add_action('admin_enqueue_scripts', array($this, 'load_wp_global_scripts_styles'), 5); |
|
92 | 92 | |
93 | 93 | //load initial stuff. |
94 | 94 | $this->_set_file_and_folder_name(); |
95 | 95 | |
96 | 96 | $this->_set_menu_map(); |
97 | 97 | |
98 | - if ( empty( $this->_menu_map ) || is_array( $this->_menu_map ) ) |
|
98 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) |
|
99 | 99 | { |
100 | - EE_Error::doing_it_wrong( get_class( $this ) . '::$_menu_map', sprintf( __('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso' ), get_class( $this ) ), '4.4.0' ); |
|
100 | + EE_Error::doing_it_wrong(get_class($this).'::$_menu_map', sprintf(__('The EE4 addon with the class %s is setting up the _menu_map property incorrectly for this version of EE core. Please see Admin_Page_Init class examples in core for the new way of setting this property up.', 'event_espresso'), get_class($this)), '4.4.0'); |
|
101 | 101 | return; |
102 | 102 | } |
103 | 103 | |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | public function load_wp_global_scripts_styles() { |
162 | 162 | wp_register_style( |
163 | 163 | 'espresso_menu', |
164 | - EE_ADMIN_URL . 'assets/admin-menu-styles.css', |
|
164 | + EE_ADMIN_URL.'assets/admin-menu-styles.css', |
|
165 | 165 | array('dashicons'), |
166 | 166 | EVENT_ESPRESSO_VERSION |
167 | 167 | ); |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | |
194 | 194 | |
195 | 195 | protected function _set_capability() { |
196 | - $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
197 | - $this->capability = apply_filters( 'FHEE_' . $this->_menu_map->menu_slug . '_capability', $capability ); |
|
196 | + $capability = empty($this->capability) ? $this->_menu_map->capability : $this->capability; |
|
197 | + $this->capability = apply_filters('FHEE_'.$this->_menu_map->menu_slug.'_capability', $capability); |
|
198 | 198 | } |
199 | 199 | |
200 | 200 | |
@@ -212,7 +212,7 @@ discard block |
||
212 | 212 | public function initialize_admin_page() { |
213 | 213 | //let's check user access first |
214 | 214 | $this->_check_user_access(); |
215 | - if ( !is_object( $this->_loaded_page_object) ) return; |
|
215 | + if ( ! is_object($this->_loaded_page_object)) return; |
|
216 | 216 | $this->_loaded_page_object->route_admin_request(); |
217 | 217 | return; |
218 | 218 | } |
@@ -224,25 +224,25 @@ discard block |
||
224 | 224 | |
225 | 225 | |
226 | 226 | public function set_page_dependencies($wp_page_slug) { |
227 | - if ( !$this->_load_page ) return; |
|
227 | + if ( ! $this->_load_page) return; |
|
228 | 228 | |
229 | - if ( !is_object($this->_loaded_page_object) ) { |
|
229 | + if ( ! is_object($this->_loaded_page_object)) { |
|
230 | 230 | $msg[] = __('We can\'t load the page because we\'re missing a valid page object that tells us what to load', 'event_espresso'); |
231 | - $msg[] = $msg[0] . "\r\n" . sprintf( |
|
231 | + $msg[] = $msg[0]."\r\n".sprintf( |
|
232 | 232 | __('The custom slug you have set for this page is %s. This means we\'re looking for the class %s_Admin_Page (found in %s_Admin_Page.core.php) within your %s directory', 'event_espresso'), |
233 | 233 | $this->_file_name, |
234 | 234 | $this->_file_name, |
235 | - $this->_folder_path . $this->_file_name, |
|
235 | + $this->_folder_path.$this->_file_name, |
|
236 | 236 | $this->_menu_map->menu_slug |
237 | 237 | ); |
238 | - throw new EE_Error( implode( '||', $msg) ); |
|
238 | + throw new EE_Error(implode('||', $msg)); |
|
239 | 239 | } |
240 | 240 | |
241 | 241 | $this->_loaded_page_object->set_wp_page_slug($wp_page_slug); |
242 | - $page_hook = 'load-' . $wp_page_slug; |
|
242 | + $page_hook = 'load-'.$wp_page_slug; |
|
243 | 243 | //hook into page load hook so all page specific stuff get's loaded. |
244 | - if ( !empty($wp_page_slug) ) |
|
245 | - add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies') ); |
|
244 | + if ( ! empty($wp_page_slug)) |
|
245 | + add_action($page_hook, array($this->_loaded_page_object, 'load_page_dependencies')); |
|
246 | 246 | } |
247 | 247 | |
248 | 248 | |
@@ -253,7 +253,7 @@ discard block |
||
253 | 253 | */ |
254 | 254 | public function do_initial_loads() { |
255 | 255 | //no loading or initializing if menu map is setup incorrectly. |
256 | - if ( empty( $this->_menu_map ) || is_array( $this->_menu_map ) ) { |
|
256 | + if (empty($this->_menu_map) || is_array($this->_menu_map)) { |
|
257 | 257 | return; |
258 | 258 | } |
259 | 259 | $this->_initialize_admin_page(); |
@@ -270,19 +270,19 @@ discard block |
||
270 | 270 | $bt = debug_backtrace(); |
271 | 271 | //for more reliable determination of folder name |
272 | 272 | //we're using this to get the actual folder name of the CALLING class (i.e. the child class that extends this). Why? Because $this->menu_slug may be different than the folder name (to avoid conflicts with other plugins) |
273 | - $class = get_class( $this ); |
|
274 | - foreach ( $bt as $index => $values ) { |
|
275 | - if ( isset( $values['class'] ) && $values['class'] == $class ) { |
|
273 | + $class = get_class($this); |
|
274 | + foreach ($bt as $index => $values) { |
|
275 | + if (isset($values['class']) && $values['class'] == $class) { |
|
276 | 276 | $file_index = $index - 1; |
277 | - $this->_folder_name = basename(dirname($bt[$file_index]['file']) ); |
|
278 | - if ( !empty( $this->_folder_name ) ) break; |
|
277 | + $this->_folder_name = basename(dirname($bt[$file_index]['file'])); |
|
278 | + if ( ! empty($this->_folder_name)) break; |
|
279 | 279 | } |
280 | 280 | } |
281 | 281 | |
282 | - $this->_folder_path = EE_ADMIN_PAGES . $this->_folder_name . DS; |
|
282 | + $this->_folder_path = EE_ADMIN_PAGES.$this->_folder_name.DS; |
|
283 | 283 | |
284 | - $this->_file_name = preg_replace( '/^ee/' , 'EE', $this->_folder_name ); |
|
285 | - $this->_file_name = ucwords( str_replace('_', ' ', $this->_file_name) ); |
|
284 | + $this->_file_name = preg_replace('/^ee/', 'EE', $this->_folder_name); |
|
285 | + $this->_file_name = ucwords(str_replace('_', ' ', $this->_file_name)); |
|
286 | 286 | $this->_file_name = str_replace(' ', '_', $this->_file_name); |
287 | 287 | } |
288 | 288 | |
@@ -294,19 +294,19 @@ discard block |
||
294 | 294 | * @param bool $extend This indicates whether we're checking the extend directory for any register_hooks files/classes |
295 | 295 | * @return array |
296 | 296 | */ |
297 | - public function register_hooks( $extend = FALSE ) { |
|
297 | + public function register_hooks($extend = FALSE) { |
|
298 | 298 | |
299 | 299 | //get a list of files in the directory that have the "Hook" in their name an |
300 | 300 | |
301 | 301 | //if this is an extended check (i.e. caf is active) then we will scan the caffeinated/extend directory first and any hook files that are found will be have their reference added to the $_files_hook array property. Then, we make sure that when we loop through the core decaf directories to find hook files that we skip over any hooks files that have already been set by caf. |
302 | - if ( $extend ) { |
|
303 | - $hook_files_glob_path = apply_filters( 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . DS . '*' . $this->_file_name . '_Hooks_Extend.class.php' ); |
|
304 | - $this->_hook_paths = $this->_register_hook_files( $hook_files_glob_path, $extend ); |
|
302 | + if ($extend) { |
|
303 | + $hook_files_glob_path = apply_filters('FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path__extend', EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.DS.'*'.$this->_file_name.'_Hooks_Extend.class.php'); |
|
304 | + $this->_hook_paths = $this->_register_hook_files($hook_files_glob_path, $extend); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | //loop through decaf folders |
308 | - $hook_files_glob_path = apply_filters( 'FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', $this->_folder_path . '*' . $this->_file_name . '_Hooks.class.php' ); |
|
309 | - $this->_hook_paths = array_merge( $this->_register_hook_files( $hook_files_glob_path ), $this->_hook_paths ); //making sure any extended hook paths are later in the array than the core hook paths! |
|
308 | + $hook_files_glob_path = apply_filters('FHEE__EE_Admin_Page_Init__register_hooks__hook_files_glob_path', $this->_folder_path.'*'.$this->_file_name.'_Hooks.class.php'); |
|
309 | + $this->_hook_paths = array_merge($this->_register_hook_files($hook_files_glob_path), $this->_hook_paths); //making sure any extended hook paths are later in the array than the core hook paths! |
|
310 | 310 | |
311 | 311 | return $this->_hook_paths; |
312 | 312 | |
@@ -314,27 +314,27 @@ discard block |
||
314 | 314 | |
315 | 315 | |
316 | 316 | |
317 | - protected function _register_hook_files( $hook_files_glob_path, $extend = FALSE ) { |
|
317 | + protected function _register_hook_files($hook_files_glob_path, $extend = FALSE) { |
|
318 | 318 | $hook_paths = array(); |
319 | - if ( $hook_files = glob( $hook_files_glob_path ) ) { |
|
320 | - if ( empty( $hook_files ) ) { |
|
319 | + if ($hook_files = glob($hook_files_glob_path)) { |
|
320 | + if (empty($hook_files)) { |
|
321 | 321 | return array(); |
322 | 322 | } |
323 | - foreach ( $hook_files as $file ) { |
|
323 | + foreach ($hook_files as $file) { |
|
324 | 324 | //lets get the linked admin. |
325 | - $hook_file = $extend ? str_replace( EE_CORE_CAF_ADMIN_EXTEND . $this->_folder_name . DS, '', $file ) : str_replace($this->_folder_path, '', $file ); |
|
326 | - $replace = $extend ? '_' . $this->_file_name . '_Hooks_Extend.class.php' : '_' . $this->_file_name . '_Hooks.class.php'; |
|
327 | - $rel_admin = str_replace( $replace, '', $hook_file); |
|
325 | + $hook_file = $extend ? str_replace(EE_CORE_CAF_ADMIN_EXTEND.$this->_folder_name.DS, '', $file) : str_replace($this->_folder_path, '', $file); |
|
326 | + $replace = $extend ? '_'.$this->_file_name.'_Hooks_Extend.class.php' : '_'.$this->_file_name.'_Hooks.class.php'; |
|
327 | + $rel_admin = str_replace($replace, '', $hook_file); |
|
328 | 328 | $rel_admin = strtolower($rel_admin); |
329 | 329 | $hook_paths[] = $file; |
330 | 330 | |
331 | 331 | //make sure we haven't already got a hook setup for this page path |
332 | - if ( in_array( $rel_admin, $this->_files_hooked ) ) |
|
332 | + if (in_array($rel_admin, $this->_files_hooked)) |
|
333 | 333 | continue; |
334 | 334 | |
335 | 335 | $this->hook_file = $hook_file; |
336 | - $rel_admin_hook = 'FHEE_do_other_page_hooks_' . $rel_admin; |
|
337 | - $filter = add_filter( $rel_admin_hook, array($this, 'load_admin_hook') ); |
|
336 | + $rel_admin_hook = 'FHEE_do_other_page_hooks_'.$rel_admin; |
|
337 | + $filter = add_filter($rel_admin_hook, array($this, 'load_admin_hook')); |
|
338 | 338 | $this->_files_hooked[] = $rel_admin; |
339 | 339 | } |
340 | 340 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | protected function _initialize_admin_page() { |
360 | 360 | |
361 | 361 | //JUST CHECK WE'RE ON RIGHT PAGE. |
362 | - if ( (!isset( $_REQUEST['page'] ) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing ) |
|
362 | + if (( ! isset($_REQUEST['page']) || $_REQUEST['page'] != $this->_menu_map->menu_slug) && $this->_routing) |
|
363 | 363 | return; //not on the right page so let's get out. |
364 | 364 | $this->_load_page = TRUE; |
365 | 365 | |
@@ -367,30 +367,30 @@ discard block |
||
367 | 367 | // spl_autoload_register(array( $this, 'set_autoloaders') ); |
368 | 368 | |
369 | 369 | //we don't need to do a page_request check here because it's only called via WP menu system. |
370 | - $admin_page = $this->_file_name . '_Admin_Page'; |
|
371 | - $hook_suffix = $this->_menu_map->menu_slug . '_' . $admin_page; |
|
370 | + $admin_page = $this->_file_name.'_Admin_Page'; |
|
371 | + $hook_suffix = $this->_menu_map->menu_slug.'_'.$admin_page; |
|
372 | 372 | $admin_page = apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__{$hook_suffix}", $admin_page); |
373 | 373 | |
374 | 374 | // define requested admin page class name then load the file and instantiate |
375 | - $path_to_file = str_replace( array( '\\', '/' ), DS, $this->_folder_path . $admin_page . '.core.php' ); |
|
376 | - $path_to_file=apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}",$path_to_file );//so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
375 | + $path_to_file = str_replace(array('\\', '/'), DS, $this->_folder_path.$admin_page.'.core.php'); |
|
376 | + $path_to_file = apply_filters("FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__{$hook_suffix}", $path_to_file); //so if the file would be in EE_ADMIN/attendees/Attendee_Admin_Page.core.php, the filter would be FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__attendees_Attendee_Admin_Page |
|
377 | 377 | |
378 | - if ( is_readable( $path_to_file )) { |
|
378 | + if (is_readable($path_to_file)) { |
|
379 | 379 | // This is a place where EE plugins can hook in to make sure their own files are required in the appropriate place |
380 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization' ); |
|
381 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_' . $this->_menu_map->menu_slug ); |
|
382 | - require_once( $path_to_file ); |
|
383 | - $a = new ReflectionClass( $admin_page ); |
|
384 | - $this->_loaded_page_object = $a->newInstance( $this->_routing ); |
|
380 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization'); |
|
381 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__before_initialization_'.$this->_menu_map->menu_slug); |
|
382 | + require_once($path_to_file); |
|
383 | + $a = new ReflectionClass($admin_page); |
|
384 | + $this->_loaded_page_object = $a->newInstance($this->_routing); |
|
385 | 385 | } |
386 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__after_initialization' ); |
|
387 | - do_action( 'AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_' . $this->_menu_map->menu_slug ); |
|
386 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization'); |
|
387 | + do_action('AHEE__EE_Admin_Page___initialize_admin_page__after_initialization_'.$this->_menu_map->menu_slug); |
|
388 | 388 | } |
389 | 389 | |
390 | 390 | |
391 | 391 | |
392 | 392 | public function get_admin_page_name() { |
393 | - return $this->_file_name . '_Admin_Page'; |
|
393 | + return $this->_file_name.'_Admin_Page'; |
|
394 | 394 | } |
395 | 395 | |
396 | 396 | |
@@ -422,8 +422,8 @@ discard block |
||
422 | 422 | * @return bool|die true if pass (or admin) wp_die if fail |
423 | 423 | */ |
424 | 424 | private function _check_user_access() { |
425 | - if ( ! EE_Registry::instance()->CAP->current_user_can( $this->_menu_map->capability, $this->_menu_map->menu_slug ) ) { |
|
426 | - wp_die( __('You don\'t have access to this page.'), '', array( 'back_link' => true ) ); |
|
425 | + if ( ! EE_Registry::instance()->CAP->current_user_can($this->_menu_map->capability, $this->_menu_map->menu_slug)) { |
|
426 | + wp_die(__('You don\'t have access to this page.'), '', array('back_link' => true)); |
|
427 | 427 | } |
428 | 428 | return true; |
429 | 429 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -237,8 +238,9 @@ discard block |
||
237 | 238 | //first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects ) |
238 | 239 | usort( $this->_admin_menu_groups, array( $this, '_sort_menu_maps' ) ); |
239 | 240 | foreach ( $this->_admin_menu_groups as $group ) { |
240 | - if ( ! $group instanceof EE_Admin_Page_Menu_Group ) |
|
241 | - throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups. All values in this array are required to be a EE_Admin_Page_Menu_Group object. Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) ); |
|
241 | + if ( ! $group instanceof EE_Admin_Page_Menu_Group ) { |
|
242 | + throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups. All values in this array are required to be a EE_Admin_Page_Menu_Group object. Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) ); |
|
243 | + } |
|
242 | 244 | $groups[$group->menu_slug] = $group; |
243 | 245 | } |
244 | 246 | return $groups; |
@@ -494,8 +496,9 @@ discard block |
||
494 | 496 | //let's sort the groups, make sure it's a valid group, add header (if to show). |
495 | 497 | foreach ( $pages_array as $group => $menu_maps ) { |
496 | 498 | //valid_group? |
497 | - if ( ! array_key_exists( $group, $menu_groups ) ) |
|
498 | - continue; |
|
499 | + if ( ! array_key_exists( $group, $menu_groups ) ) { |
|
500 | + continue; |
|
501 | + } |
|
499 | 502 | |
500 | 503 | //sort pages. |
501 | 504 | usort( $menu_maps, array( $this, '_sort_menu_maps' ) ); |
@@ -510,8 +513,9 @@ discard block |
||
510 | 513 | |
511 | 514 | //now let's setup the _prepped_menu_maps property |
512 | 515 | foreach ( $menu_groups as $group => $group_objs ) { |
513 | - if ( isset( $pages_array[$group] ) ) |
|
514 | - $this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] ); |
|
516 | + if ( isset( $pages_array[$group] ) ) { |
|
517 | + $this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] ); |
|
518 | + } |
|
515 | 519 | }/**/ |
516 | 520 | |
517 | 521 | } |
@@ -656,8 +660,9 @@ discard block |
||
656 | 660 | * @return int sort order |
657 | 661 | */ |
658 | 662 | private function _sort_menu_maps( EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b ) { |
659 | - if ( $a->menu_order == $b->menu_order ) |
|
660 | - return 0; |
|
663 | + if ( $a->menu_order == $b->menu_order ) { |
|
664 | + return 0; |
|
665 | + } |
|
661 | 666 | return ($a->menu_order < $b->menu_order) ? -1 : 1; |
662 | 667 | } |
663 | 668 |
@@ -402,21 +402,21 @@ |
||
402 | 402 | $class_name = $this->_get_classname_for_admin_init_page( $page ); |
403 | 403 | EE_Registry::instance()->load_file( $path, $class_name, 'core' ); |
404 | 404 | if ( ! class_exists( $class_name )) { |
405 | - $inner_error_msg = '<br />' . sprintf( |
|
406 | - esc_html__( |
|
407 | - 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
408 | - 'event_espresso' |
|
409 | - ), |
|
410 | - '<strong>' . $class_name . '</strong>' |
|
411 | - ); |
|
405 | + $inner_error_msg = '<br />' . sprintf( |
|
406 | + esc_html__( |
|
407 | + 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
408 | + 'event_espresso' |
|
409 | + ), |
|
410 | + '<strong>' . $class_name . '</strong>' |
|
411 | + ); |
|
412 | 412 | $error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page); |
413 | 413 | $error_msg[] = $error_msg[0] |
414 | - . "\r\n" |
|
415 | - . sprintf( |
|
416 | - esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
417 | - $page |
|
418 | - ) |
|
419 | - . $inner_error_msg; |
|
414 | + . "\r\n" |
|
415 | + . sprintf( |
|
416 | + esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
417 | + $page |
|
418 | + ) |
|
419 | + . $inner_error_msg; |
|
420 | 420 | throw new EE_Error( implode( '||', $error_msg )); |
421 | 421 | } |
422 | 422 | $a = new ReflectionClass($class_name); |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -119,8 +119,8 @@ discard block |
||
119 | 119 | //let's do a scan and see what installed pages we have |
120 | 120 | $this->_get_installed_pages(); |
121 | 121 | //set menus (has to be done on every load - we're not actually loading the page just setting the menus and where they point to). |
122 | - add_action('admin_menu', array( $this, 'set_menus' )); |
|
123 | - add_action( 'network_admin_menu', array( $this, 'set_network_menus' ) ); |
|
122 | + add_action('admin_menu', array($this, 'set_menus')); |
|
123 | + add_action('network_admin_menu', array($this, 'set_network_menus')); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | |
@@ -133,13 +133,13 @@ discard block |
||
133 | 133 | * @return void |
134 | 134 | */ |
135 | 135 | private function _define_caffeinated_constants() { |
136 | - if ( ! defined( 'EE_CORE_CAF_ADMIN' ) ) { |
|
137 | - define( 'EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH . 'caffeinated/admin/'); |
|
138 | - define( 'EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL . 'caffeinated/admin/'); |
|
139 | - define( 'EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN . 'new/'); |
|
140 | - define( 'EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN . 'extend/'); |
|
141 | - define( 'EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL . 'extend/'); |
|
142 | - define( 'EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN . 'hooks/'); |
|
136 | + if ( ! defined('EE_CORE_CAF_ADMIN')) { |
|
137 | + define('EE_CORE_CAF_ADMIN', EE_PLUGIN_DIR_PATH.'caffeinated/admin/'); |
|
138 | + define('EE_CORE_CAF_ADMIN_URL', EE_PLUGIN_DIR_URL.'caffeinated/admin/'); |
|
139 | + define('EE_CORE_CAF_ADMIN_NEW', EE_CORE_CAF_ADMIN.'new/'); |
|
140 | + define('EE_CORE_CAF_ADMIN_EXTEND', EE_CORE_CAF_ADMIN.'extend/'); |
|
141 | + define('EE_CORE_CAF_ADMIN_EXTEND_URL', EE_CORE_CAF_ADMIN_URL.'extend/'); |
|
142 | + define('EE_CORE_CAF_ADMIN_HOOKS', EE_CORE_CAF_ADMIN.'hooks/'); |
|
143 | 143 | } |
144 | 144 | } |
145 | 145 | |
@@ -158,7 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | //set array of EE_Admin_Page_Menu_Group objects |
160 | 160 | $groups = array( |
161 | - 'main' => new EE_Admin_Page_Menu_Group( array( |
|
161 | + 'main' => new EE_Admin_Page_Menu_Group(array( |
|
162 | 162 | 'menu_label' => __('Main', 'event_espresso'), |
163 | 163 | 'show_on_menu' => EE_Admin_Page_Menu_Map::NONE, |
164 | 164 | 'menu_slug' => 'main', |
@@ -166,7 +166,7 @@ discard block |
||
166 | 166 | 'menu_order' => 0, |
167 | 167 | 'parent_slug' => 'espresso_events', |
168 | 168 | )), |
169 | - 'management' => new EE_Admin_Page_Menu_Group( array( |
|
169 | + 'management' => new EE_Admin_Page_Menu_Group(array( |
|
170 | 170 | 'menu_label' => __('Management', 'event_espresso'), |
171 | 171 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
172 | 172 | 'menu_slug' => 'management', |
@@ -174,7 +174,7 @@ discard block |
||
174 | 174 | 'menu_order' => 10, |
175 | 175 | 'parent_slug' => 'espresso_events' |
176 | 176 | )), |
177 | - 'settings' => new EE_Admin_Page_Menu_Group( array( |
|
177 | + 'settings' => new EE_Admin_Page_Menu_Group(array( |
|
178 | 178 | 'menu_label' => __('Settings', 'event_espresso'), |
179 | 179 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
180 | 180 | 'menu_slug' => 'settings', |
@@ -182,7 +182,7 @@ discard block |
||
182 | 182 | 'menu_order' => 30, |
183 | 183 | 'parent_slug' => 'espresso_events' |
184 | 184 | )), |
185 | - 'templates' => new EE_Admin_Page_Menu_Group( array( |
|
185 | + 'templates' => new EE_Admin_Page_Menu_Group(array( |
|
186 | 186 | 'menu_label' => __('Templates', 'event_espresso'), |
187 | 187 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
188 | 188 | 'menu_slug' => 'templates', |
@@ -190,7 +190,7 @@ discard block |
||
190 | 190 | 'menu_order' => 40, |
191 | 191 | 'parent_slug' => 'espresso_events' |
192 | 192 | )), |
193 | - 'extras' => new EE_Admin_Page_Menu_Group( array( |
|
193 | + 'extras' => new EE_Admin_Page_Menu_Group(array( |
|
194 | 194 | 'menu_label' => __('Extras', 'event_espresso'), |
195 | 195 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN, |
196 | 196 | 'menu_slug' => 'extras', |
@@ -199,7 +199,7 @@ discard block |
||
199 | 199 | 'parent_slug' => 'espresso_events', |
200 | 200 | 'maintenance_mode_parent' => 'espresso_maintenance_settings' |
201 | 201 | )), |
202 | - 'tools' => new EE_Admin_Page_Menu_Group( array( |
|
202 | + 'tools' => new EE_Admin_Page_Menu_Group(array( |
|
203 | 203 | 'menu_label' => __("Tools", "event_espresso"), |
204 | 204 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY, |
205 | 205 | 'menu_slug' => 'tools', |
@@ -207,7 +207,7 @@ discard block |
||
207 | 207 | 'menu_order' => 60, |
208 | 208 | 'parent_slug' => 'espresso_events' |
209 | 209 | )), |
210 | - 'addons' => new EE_Admin_Page_Menu_Group( array( |
|
210 | + 'addons' => new EE_Admin_Page_Menu_Group(array( |
|
211 | 211 | 'show_on_menu' => EE_Admin_Page_Menu_Map::BLOG_AND_NETWORK_ADMIN, |
212 | 212 | 'menu_label' => __('Add-ons', 'event_espresso'), |
213 | 213 | 'menu_slug' => 'addons', |
@@ -217,7 +217,7 @@ discard block |
||
217 | 217 | )) |
218 | 218 | ); |
219 | 219 | |
220 | - $this->_admin_menu_groups = apply_filters( 'FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups ); |
|
220 | + $this->_admin_menu_groups = apply_filters('FHEE__EE_Admin_Page_Loader___set_menu_groups__admin_menu_groups', $groups); |
|
221 | 221 | } |
222 | 222 | |
223 | 223 | |
@@ -235,10 +235,10 @@ discard block |
||
235 | 235 | private function _rearrange_menu_groups() { |
236 | 236 | $groups = array(); |
237 | 237 | //first let's order the menu groups by their internal menu order (note usort type hinting to ensure the incoming array is EE_Admin_Page_Menu_Map objects ) |
238 | - usort( $this->_admin_menu_groups, array( $this, '_sort_menu_maps' ) ); |
|
239 | - foreach ( $this->_admin_menu_groups as $group ) { |
|
240 | - if ( ! $group instanceof EE_Admin_Page_Menu_Group ) |
|
241 | - throw new EE_Error( sprintf( __('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups. All values in this array are required to be a EE_Admin_Page_Menu_Group object. Instead there was: %s', 'event_espresso'), print_r($group, TRUE) ) ); |
|
238 | + usort($this->_admin_menu_groups, array($this, '_sort_menu_maps')); |
|
239 | + foreach ($this->_admin_menu_groups as $group) { |
|
240 | + if ( ! $group instanceof EE_Admin_Page_Menu_Group) |
|
241 | + throw new EE_Error(sprintf(__('Unable to continue sorting the menu groups array because there is an invalid value for the menu groups. All values in this array are required to be a EE_Admin_Page_Menu_Group object. Instead there was: %s', 'event_espresso'), print_r($group, TRUE))); |
|
242 | 242 | $groups[$group->menu_slug] = $group; |
243 | 243 | } |
244 | 244 | return $groups; |
@@ -256,48 +256,48 @@ discard block |
||
256 | 256 | */ |
257 | 257 | private function _get_installed_pages() { |
258 | 258 | $installed_refs = array(); |
259 | - $exclude = array( 'assets', 'templates' ); |
|
259 | + $exclude = array('assets', 'templates'); |
|
260 | 260 | // grab everything in the admin core directory |
261 | - $admin_screens = glob( EE_ADMIN_PAGES . '*', GLOB_ONLYDIR ); |
|
262 | - if ( $admin_screens ) { |
|
263 | - foreach( $admin_screens as $admin_screen ) { |
|
261 | + $admin_screens = glob(EE_ADMIN_PAGES.'*', GLOB_ONLYDIR); |
|
262 | + if ($admin_screens) { |
|
263 | + foreach ($admin_screens as $admin_screen) { |
|
264 | 264 | // files and anything in the exclude array need not apply |
265 | - if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) { |
|
265 | + if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) { |
|
266 | 266 | // these folders represent the different EE admin pages |
267 | - $installed_refs[ basename( $admin_screen ) ] = $admin_screen; |
|
267 | + $installed_refs[basename($admin_screen)] = $admin_screen; |
|
268 | 268 | } |
269 | 269 | } |
270 | 270 | } |
271 | 271 | |
272 | - if ( empty( $installed_refs ) ) { |
|
272 | + if (empty($installed_refs)) { |
|
273 | 273 | $error_msg[] = __('There are no EE_Admin pages detected, it looks like EE did not install properly', 'event_espresso'); |
274 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf( __('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES ); |
|
275 | - throw new EE_Error( implode( '||', $error_msg )); |
|
274 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('Check that the %s folder exists and is writable. Maybe try deactivating, then reactivating Event Espresso again.', 'event_espresso'), EE_ADMIN_PAGES); |
|
275 | + throw new EE_Error(implode('||', $error_msg)); |
|
276 | 276 | } |
277 | 277 | |
278 | 278 | //this just checks the caffeinated folder and takes care of setting up any caffeinated stuff. |
279 | 279 | $installed_refs = $this->_set_caffeinated($installed_refs); |
280 | 280 | //allow plugins to add in their own pages (note at this point they will need to have an autoloader defined for their class) OR hook into EEH_Autoloader::load_admin_page() to add their path.; |
281 | - $installed_refs = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs ); |
|
282 | - $this->_caffeinated_extends = apply_filters( 'FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends ); |
|
281 | + $installed_refs = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs', $installed_refs); |
|
282 | + $this->_caffeinated_extends = apply_filters('FHEE__EE_Admin_Page_Loader___get_installed_pages__caffeinated_extends', $this->_caffeinated_extends); |
|
283 | 283 | |
284 | 284 | //loop through admin pages and setup the $_installed_pages array. |
285 | 285 | $hooks_ref = array(); |
286 | - foreach ( $installed_refs as $page => $path ) { |
|
286 | + foreach ($installed_refs as $page => $path) { |
|
287 | 287 | // set autoloaders for our admin page classes based on included path information |
288 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $path ); |
|
288 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($path); |
|
289 | 289 | // build list of installed pages |
290 | - $this->_installed_pages[$page] = $this->_load_admin_page( $page, $path ); |
|
290 | + $this->_installed_pages[$page] = $this->_load_admin_page($page, $path); |
|
291 | 291 | // verify returned object |
292 | - if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) { |
|
293 | - if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map ) { |
|
292 | + if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) { |
|
293 | + if ( ! $this->_installed_pages[$page]->get_menu_map() instanceof EE_Admin_Page_Menu_Map) { |
|
294 | 294 | continue; |
295 | 295 | } |
296 | 296 | |
297 | 297 | //skip if in full maintenance mode and maintenance_mode_parent is set |
298 | 298 | $maintenance_mode_parent = $this->_installed_pages[$page]->get_menu_map()->maintenance_mode_parent; |
299 | - if ( empty( $maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
300 | - unset( $installed_refs[$page] ); |
|
299 | + if (empty($maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
300 | + unset($installed_refs[$page]); |
|
301 | 301 | continue; |
302 | 302 | } |
303 | 303 | |
@@ -305,45 +305,45 @@ discard block |
||
305 | 305 | //flag for register hooks on extended pages b/c extended pages use the default INIT. |
306 | 306 | $extend = FALSE; |
307 | 307 | //now that we've got the admin_init objects... lets see if there are any caffeinated pages extending the originals. If there are then let's hook into the init admin filter and load our extend instead. |
308 | - if ( isset( $this->_caffeinated_extends[$page] ) ) { |
|
308 | + if (isset($this->_caffeinated_extends[$page])) { |
|
309 | 309 | $this->_current_caf_extend_slug = $page; |
310 | - $path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name(); |
|
311 | - $path_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"] . '";'; |
|
312 | - $page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__' . $this->_installed_pages[$page]->get_menu_map()->menu_slug . '_' . $this->_installed_pages[$page]->get_admin_page_name(); |
|
313 | - $page_runtime = 'return "' . $this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"] . '";'; |
|
310 | + $path_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__path_to_file__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name(); |
|
311 | + $path_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["path"].'";'; |
|
312 | + $page_hook = 'FHEE__EE_Admin_Page_Init___initialize_admin_page__admin_page__'.$this->_installed_pages[$page]->get_menu_map()->menu_slug.'_'.$this->_installed_pages[$page]->get_admin_page_name(); |
|
313 | + $page_runtime = 'return "'.$this->_caffeinated_extends[$this->_current_caf_extend_slug]["admin_page"].'";'; |
|
314 | 314 | |
315 | - $hook_function_path = create_function( '$path_to_file', $path_runtime); |
|
316 | - $hook_function_page = create_function( '$admin_page', $page_runtime ); |
|
315 | + $hook_function_path = create_function('$path_to_file', $path_runtime); |
|
316 | + $hook_function_page = create_function('$admin_page', $page_runtime); |
|
317 | 317 | |
318 | - add_filter( $path_hook, $hook_function_path ); |
|
319 | - add_filter( $page_hook, $hook_function_page ); |
|
318 | + add_filter($path_hook, $hook_function_path); |
|
319 | + add_filter($page_hook, $hook_function_page); |
|
320 | 320 | $extend = TRUE; |
321 | 321 | } |
322 | 322 | //let's do the registered hooks |
323 | - $extended_hooks = $this->_installed_pages[$page]->register_hooks( $extend ); |
|
323 | + $extended_hooks = $this->_installed_pages[$page]->register_hooks($extend); |
|
324 | 324 | $hooks_ref = array_merge($hooks_ref, $extended_hooks); |
325 | 325 | } |
326 | 326 | } |
327 | 327 | |
328 | 328 | //the hooks_ref is all the pages where we have $extended _Hooks files that will extend a class in a different folder. So we want to make sure we load the file for the parent. |
329 | 329 | //first make sure we've got unique values |
330 | - $hooks_ref = array_unique( $hooks_ref ); |
|
330 | + $hooks_ref = array_unique($hooks_ref); |
|
331 | 331 | //now let's loop and require! |
332 | - foreach ( $hooks_ref as $path ) { |
|
333 | - require_once( $path ); |
|
332 | + foreach ($hooks_ref as $path) { |
|
333 | + require_once($path); |
|
334 | 334 | } |
335 | 335 | //make sure we have menu slugs global setup. Used in EE_Admin_Page->page_setup() to ensure we don't do a full class load for an admin page that isn't requested. |
336 | 336 | global $ee_menu_slugs; |
337 | 337 | $ee_menu_slugs = $this->_menu_slugs; |
338 | 338 | |
339 | 339 | //we need to loop again to run any early code |
340 | - foreach ( $installed_refs as $page => $path ) { |
|
341 | - if ( $this->_installed_pages[$page] instanceof EE_Admin_Page_Init ) { |
|
340 | + foreach ($installed_refs as $page => $path) { |
|
341 | + if ($this->_installed_pages[$page] instanceof EE_Admin_Page_Init) { |
|
342 | 342 | $this->_installed_pages[$page]->do_initial_loads(); |
343 | 343 | } |
344 | 344 | } |
345 | 345 | |
346 | - do_action( 'AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages ); |
|
346 | + do_action('AHEE__EE_Admin_Page_Loader___get_installed_pages_loaded', $this->_installed_pages); |
|
347 | 347 | |
348 | 348 | } |
349 | 349 | |
@@ -355,9 +355,9 @@ discard block |
||
355 | 355 | * @param string $page_slug |
356 | 356 | * @return EE_Admin_Page |
357 | 357 | */ |
358 | - public function get_admin_page_object( $page_slug = '' ) { |
|
359 | - if ( isset( $this->_installed_pages[ $page_slug ] )) { |
|
360 | - return $this->_installed_pages[ $page_slug ]->loaded_page_object(); |
|
358 | + public function get_admin_page_object($page_slug = '') { |
|
359 | + if (isset($this->_installed_pages[$page_slug])) { |
|
360 | + return $this->_installed_pages[$page_slug]->loaded_page_object(); |
|
361 | 361 | } |
362 | 362 | return NULL; |
363 | 363 | } |
@@ -370,9 +370,9 @@ discard block |
||
370 | 370 | * @param $dir_name |
371 | 371 | * @return string |
372 | 372 | */ |
373 | - private function _get_classname_for_admin_page( $dir_name = '' ) { |
|
374 | - $class_name = str_replace( '_', ' ', strtolower( $dir_name )); |
|
375 | - return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page'; |
|
373 | + private function _get_classname_for_admin_page($dir_name = '') { |
|
374 | + $class_name = str_replace('_', ' ', strtolower($dir_name)); |
|
375 | + return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page'; |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | |
@@ -383,9 +383,9 @@ discard block |
||
383 | 383 | * @param $dir_name |
384 | 384 | * @return string |
385 | 385 | */ |
386 | - private function _get_classname_for_admin_init_page( $dir_name = '' ) { |
|
387 | - $class_name = str_replace( '_', ' ', strtolower( $dir_name )); |
|
388 | - return str_replace( ' ', '_', ucwords( $class_name )) . '_Admin_Page_Init'; |
|
386 | + private function _get_classname_for_admin_init_page($dir_name = '') { |
|
387 | + $class_name = str_replace('_', ' ', strtolower($dir_name)); |
|
388 | + return str_replace(' ', '_', ucwords($class_name)).'_Admin_Page_Init'; |
|
389 | 389 | } |
390 | 390 | |
391 | 391 | |
@@ -398,26 +398,26 @@ discard block |
||
398 | 398 | * @throws EE_Error |
399 | 399 | * @return object|bool return page object if valid, bool false if not. |
400 | 400 | */ |
401 | - private function _load_admin_page( $page = '', $path = '' ) { |
|
402 | - $class_name = $this->_get_classname_for_admin_init_page( $page ); |
|
403 | - EE_Registry::instance()->load_file( $path, $class_name, 'core' ); |
|
404 | - if ( ! class_exists( $class_name )) { |
|
405 | - $inner_error_msg = '<br />' . sprintf( |
|
401 | + private function _load_admin_page($page = '', $path = '') { |
|
402 | + $class_name = $this->_get_classname_for_admin_init_page($page); |
|
403 | + EE_Registry::instance()->load_file($path, $class_name, 'core'); |
|
404 | + if ( ! class_exists($class_name)) { |
|
405 | + $inner_error_msg = '<br />'.sprintf( |
|
406 | 406 | esc_html__( |
407 | 407 | 'Make sure you have %1$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
408 | 408 | 'event_espresso' |
409 | 409 | ), |
410 | - '<strong>' . $class_name . '</strong>' |
|
410 | + '<strong>'.$class_name.'</strong>' |
|
411 | 411 | ); |
412 | - $error_msg[] = sprintf( __('Something went wrong with loading the %s admin page.', 'event_espresso' ), $page); |
|
412 | + $error_msg[] = sprintf(__('Something went wrong with loading the %s admin page.', 'event_espresso'), $page); |
|
413 | 413 | $error_msg[] = $error_msg[0] |
414 | 414 | . "\r\n" |
415 | 415 | . sprintf( |
416 | - esc_html__( 'There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
416 | + esc_html__('There is no Init class in place for the %s admin page.', 'event_espresso'), |
|
417 | 417 | $page |
418 | 418 | ) |
419 | 419 | . $inner_error_msg; |
420 | - throw new EE_Error( implode( '||', $error_msg )); |
|
420 | + throw new EE_Error(implode('||', $error_msg)); |
|
421 | 421 | } |
422 | 422 | $a = new ReflectionClass($class_name); |
423 | 423 | return $a->newInstance(); |
@@ -436,9 +436,9 @@ discard block |
||
436 | 436 | public function set_menus() { |
437 | 437 | //prep the menu pages (sort, group.) |
438 | 438 | $this->_prep_pages(); |
439 | - foreach( $this->_prepped_menu_maps as $menu_map ) { |
|
440 | - if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) { |
|
441 | - $menu_map->add_menu_page( FALSE ); |
|
439 | + foreach ($this->_prepped_menu_maps as $menu_map) { |
|
440 | + if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) { |
|
441 | + $menu_map->add_menu_page(FALSE); |
|
442 | 442 | } |
443 | 443 | } |
444 | 444 | } |
@@ -451,11 +451,11 @@ discard block |
||
451 | 451 | * |
452 | 452 | * @return void |
453 | 453 | */ |
454 | - public function set_network_menus(){ |
|
454 | + public function set_network_menus() { |
|
455 | 455 | $this->_prep_pages(); |
456 | - foreach( $this->_prepped_menu_maps as $menu_map ) { |
|
457 | - if ( EE_Registry::instance()->CAP->current_user_can( $menu_map->capability, $menu_map->menu_slug ) ) { |
|
458 | - $menu_map->add_menu_page( TRUE ); |
|
456 | + foreach ($this->_prepped_menu_maps as $menu_map) { |
|
457 | + if (EE_Registry::instance()->CAP->current_user_can($menu_map->capability, $menu_map->menu_slug)) { |
|
458 | + $menu_map->add_menu_page(TRUE); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
@@ -476,22 +476,22 @@ discard block |
||
476 | 476 | //rearrange _admin_menu_groups to be indexed by group slug. |
477 | 477 | $menu_groups = $this->_rearrange_menu_groups(); |
478 | 478 | |
479 | - foreach( $this->_installed_pages as $page ) { |
|
480 | - if ( $page instanceof EE_Admin_page_Init ) { |
|
479 | + foreach ($this->_installed_pages as $page) { |
|
480 | + if ($page instanceof EE_Admin_page_Init) { |
|
481 | 481 | $page_map = $page->get_menu_map(); |
482 | 482 | //if we've got an array then the menu map is in the old format so let's throw a persistent notice that the admin system isn't setup correctly for this item. |
483 | - if ( is_array( $page_map ) || empty( $page_map ) ) { |
|
484 | - EE_Error::add_persistent_admin_notice( 'menu_map_warning_' . str_replace(' ', '_', $page->label) . '_' . EVENT_ESPRESSO_VERSION, sprintf( __('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core. This means that full functionality for this component is not available. This error message usually appears with an Add-on that is out of date. Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso' ), $page->label ) ); |
|
483 | + if (is_array($page_map) || empty($page_map)) { |
|
484 | + EE_Error::add_persistent_admin_notice('menu_map_warning_'.str_replace(' ', '_', $page->label).'_'.EVENT_ESPRESSO_VERSION, sprintf(__('The admin page for %s was not correctly setup because it is using an older method for integrating with Event Espresso Core. This means that full functionality for this component is not available. This error message usually appears with an Add-on that is out of date. Make sure you update all your Event Espresso 4 add-ons to the latest version to ensure they have necessary compatibility updates in place.', 'event_espresso'), $page->label)); |
|
485 | 485 | continue; |
486 | 486 | } |
487 | 487 | |
488 | 488 | //if page map is NOT a EE_Admin_Page_Menu_Map object then throw error. |
489 | - if ( ! $page_map instanceof EE_Admin_Page_Menu_Map ) { |
|
490 | - throw new EE_Error( sprintf( __('The menu map for %s must be an EE_Admin_Page_Menu_Map object. Instead it is %s. Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map ) ); |
|
489 | + if ( ! $page_map instanceof EE_Admin_Page_Menu_Map) { |
|
490 | + throw new EE_Error(sprintf(__('The menu map for %s must be an EE_Admin_Page_Menu_Map object. Instead it is %s. Please double check that the menu map has been configured correctly.', 'event_espresso'), $page->label, $page_map)); |
|
491 | 491 | } |
492 | 492 | |
493 | 493 | //use the maintenance_mode_parent property and maintenance mode status to determine if this page even gets added to array. |
494 | - if ( empty( $page_map->maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
494 | + if (empty($page_map->maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
495 | 495 | continue; |
496 | 496 | } |
497 | 497 | |
@@ -500,21 +500,21 @@ discard block |
||
500 | 500 | } |
501 | 501 | } |
502 | 502 | |
503 | - if ( empty( $pages_array )) { |
|
504 | - throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso') ); |
|
503 | + if (empty($pages_array)) { |
|
504 | + throw new EE_Error(__('Something went wrong when prepping the admin pages', 'event_espresso')); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | //let's sort the groups, make sure it's a valid group, add header (if to show). |
508 | - foreach ( $pages_array as $group => $menu_maps ) { |
|
508 | + foreach ($pages_array as $group => $menu_maps) { |
|
509 | 509 | //valid_group? |
510 | - if ( ! array_key_exists( $group, $menu_groups ) ) |
|
510 | + if ( ! array_key_exists($group, $menu_groups)) |
|
511 | 511 | continue; |
512 | 512 | |
513 | 513 | //sort pages. |
514 | - usort( $menu_maps, array( $this, '_sort_menu_maps' ) ); |
|
514 | + usort($menu_maps, array($this, '_sort_menu_maps')); |
|
515 | 515 | |
516 | 516 | //prepend header |
517 | - array_unshift( $menu_maps, $menu_groups[$group] ); |
|
517 | + array_unshift($menu_maps, $menu_groups[$group]); |
|
518 | 518 | |
519 | 519 | //reset $pages_array with prepped data |
520 | 520 | $pages_array[$group] = $menu_maps; |
@@ -522,9 +522,9 @@ discard block |
||
522 | 522 | |
523 | 523 | |
524 | 524 | //now let's setup the _prepped_menu_maps property |
525 | - foreach ( $menu_groups as $group => $group_objs ) { |
|
526 | - if ( isset( $pages_array[$group] ) ) |
|
527 | - $this->_prepped_menu_maps = array_merge( $this->_prepped_menu_maps, $pages_array[$group] ); |
|
525 | + foreach ($menu_groups as $group => $group_objs) { |
|
526 | + if (isset($pages_array[$group])) |
|
527 | + $this->_prepped_menu_maps = array_merge($this->_prepped_menu_maps, $pages_array[$group]); |
|
528 | 528 | }/**/ |
529 | 529 | |
530 | 530 | } |
@@ -544,10 +544,10 @@ discard block |
||
544 | 544 | * @param array $installed_refs the original installed_refs array that may contain our NEW EE_Admin_Pages to be loaded. |
545 | 545 | * @return array |
546 | 546 | */ |
547 | - private function _set_caffeinated( $installed_refs ) { |
|
547 | + private function _set_caffeinated($installed_refs) { |
|
548 | 548 | |
549 | 549 | //first let's check if there IS a caffeinated folder. If there is not then lets get out. |
550 | - if ( ! is_dir( EE_PLUGIN_DIR_PATH . 'caffeinated' . DS . 'admin' ) || ( defined( 'EE_DECAF' ) && EE_DECAF )) { |
|
550 | + if ( ! is_dir(EE_PLUGIN_DIR_PATH.'caffeinated'.DS.'admin') || (defined('EE_DECAF') && EE_DECAF)) { |
|
551 | 551 | return $installed_refs; |
552 | 552 | } |
553 | 553 | |
@@ -556,15 +556,15 @@ discard block |
||
556 | 556 | $exclude = array('tickets'); |
557 | 557 | |
558 | 558 | //okay let's setup an "New" pages first (we'll return installed refs later) |
559 | - $new_admin_screens = glob( EE_CORE_CAF_ADMIN . 'new/*', GLOB_ONLYDIR ); |
|
560 | - if ( $new_admin_screens ) { |
|
561 | - foreach( $new_admin_screens as $admin_screen ) { |
|
559 | + $new_admin_screens = glob(EE_CORE_CAF_ADMIN.'new/*', GLOB_ONLYDIR); |
|
560 | + if ($new_admin_screens) { |
|
561 | + foreach ($new_admin_screens as $admin_screen) { |
|
562 | 562 | // files and anything in the exclude array need not apply |
563 | - if ( is_dir( $admin_screen ) && ! in_array( basename( $admin_screen ), $exclude )) { |
|
563 | + if (is_dir($admin_screen) && ! in_array(basename($admin_screen), $exclude)) { |
|
564 | 564 | // these folders represent the different NEW EE admin pages |
565 | - $installed_refs[ basename( $admin_screen ) ] = $admin_screen; |
|
565 | + $installed_refs[basename($admin_screen)] = $admin_screen; |
|
566 | 566 | // set autoloaders for our admin page classes based on included path information |
567 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $admin_screen ); |
|
567 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($admin_screen); |
|
568 | 568 | // $this->_caf_autoloader[] = array( |
569 | 569 | // 'dir' => 'new', |
570 | 570 | // 'folder' => basename( $admin_screen ) |
@@ -574,18 +574,18 @@ discard block |
||
574 | 574 | } |
575 | 575 | |
576 | 576 | //let's see if there are any EXTENDS to setup in the $_caffeinated_extends array (that will be used later for hooking into the _initialize_admin_age in the related core_init admin page) |
577 | - $extends = glob( EE_CORE_CAF_ADMIN . 'extend/*', GLOB_ONLYDIR ); |
|
578 | - if ( $extends ) { |
|
579 | - foreach( $extends as $extend ) { |
|
580 | - if ( is_dir( $extend ) ) { |
|
581 | - $extend_ref = basename( $extend ); |
|
577 | + $extends = glob(EE_CORE_CAF_ADMIN.'extend/*', GLOB_ONLYDIR); |
|
578 | + if ($extends) { |
|
579 | + foreach ($extends as $extend) { |
|
580 | + if (is_dir($extend)) { |
|
581 | + $extend_ref = basename($extend); |
|
582 | 582 | //now let's make sure there is a file that matches the expected format |
583 | - $filename = str_replace(' ', '_', ucwords( str_replace('_', ' ', $extend_ref ) ) ); |
|
584 | - $filename = 'Extend_' . $filename . '_Admin_Page'; |
|
585 | - $this->_caffeinated_extends[$extend_ref]['path'] = str_replace( array( '\\', '/' ), DS, EE_CORE_CAF_ADMIN . 'extend' . DS . $extend_ref . DS . $filename . '.core.php' ); |
|
583 | + $filename = str_replace(' ', '_', ucwords(str_replace('_', ' ', $extend_ref))); |
|
584 | + $filename = 'Extend_'.$filename.'_Admin_Page'; |
|
585 | + $this->_caffeinated_extends[$extend_ref]['path'] = str_replace(array('\\', '/'), DS, EE_CORE_CAF_ADMIN.'extend'.DS.$extend_ref.DS.$filename.'.core.php'); |
|
586 | 586 | $this->_caffeinated_extends[$extend_ref]['admin_page'] = $filename; |
587 | 587 | // set autoloaders for our admin page classes based on included path information |
588 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder( $extend ); |
|
588 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder($extend); |
|
589 | 589 | // $this->_caf_autoloader[] = array( |
590 | 590 | // 'dir' => 'extend', |
591 | 591 | // 'folder' => $extend_ref |
@@ -596,22 +596,22 @@ discard block |
||
596 | 596 | |
597 | 597 | //let's see if there are any HOOK files and instantiate them if there are (so that hooks are loaded early!). |
598 | 598 | $ee_admin_hooks = array(); |
599 | - $hooks = glob( EE_CORE_CAF_ADMIN . 'hooks/*.class.php' ); |
|
600 | - if ( $hooks ) { |
|
601 | - foreach ( $hooks as $hook ) { |
|
602 | - if ( is_readable( $hook ) ) { |
|
599 | + $hooks = glob(EE_CORE_CAF_ADMIN.'hooks/*.class.php'); |
|
600 | + if ($hooks) { |
|
601 | + foreach ($hooks as $hook) { |
|
602 | + if (is_readable($hook)) { |
|
603 | 603 | require_once $hook; |
604 | - $classname = str_replace( EE_CORE_CAF_ADMIN . 'hooks/', '', $hook ); |
|
604 | + $classname = str_replace(EE_CORE_CAF_ADMIN.'hooks/', '', $hook); |
|
605 | 605 | $classname = str_replace('.class.php', '', $classname); |
606 | - if ( class_exists( $classname ) ) { |
|
607 | - $a = new ReflectionClass( $classname ); |
|
606 | + if (class_exists($classname)) { |
|
607 | + $a = new ReflectionClass($classname); |
|
608 | 608 | $ee_admin_hooks[] = $a->newInstance(); |
609 | 609 | } |
610 | 610 | } |
611 | 611 | } |
612 | 612 | }/**/ |
613 | 613 | |
614 | - $ee_admin_hooks = apply_filters( 'FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks ); |
|
614 | + $ee_admin_hooks = apply_filters('FHEE__EE_Admin_Page_Loader__set_caffeinated__ee_admin_hooks', $ee_admin_hooks); |
|
615 | 615 | |
616 | 616 | return $installed_refs; |
617 | 617 | |
@@ -666,8 +666,8 @@ discard block |
||
666 | 666 | * @param EE_Admin_Page_Menu_Map $b being compared to |
667 | 667 | * @return int sort order |
668 | 668 | */ |
669 | - private function _sort_menu_maps( EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b ) { |
|
670 | - if ( $a->menu_order == $b->menu_order ) |
|
669 | + private function _sort_menu_maps(EE_Admin_Page_Menu_Map $a, EE_Admin_Page_Menu_Map $b) { |
|
670 | + if ($a->menu_order == $b->menu_order) |
|
671 | 671 | return 0; |
672 | 672 | return ($a->menu_order < $b->menu_order) ? -1 : 1; |
673 | 673 | } |
@@ -15,7 +15,7 @@ discard block |
||
15 | 15 | * @package Event Espresso |
16 | 16 | * @subpackage admin |
17 | 17 | */ |
18 | -abstract class EE_Admin_Page_Menu_Map { |
|
18 | +abstract class EE_Admin_Page_Menu_Map { |
|
19 | 19 | |
20 | 20 | |
21 | 21 | /** |
@@ -155,28 +155,28 @@ discard block |
||
155 | 155 | * are present. |
156 | 156 | * @return void |
157 | 157 | */ |
158 | - public function __construct( $menu_args, $required ) { |
|
158 | + public function __construct($menu_args, $required) { |
|
159 | 159 | //filter all args before processing so plugins can manipulate various settings for menus. |
160 | - $menu_args = apply_filters( 'FHEE__EE_Admin_Page_Menu_Map__construct__menu_args', $menu_args, $required, get_class( $this ) ); |
|
160 | + $menu_args = apply_filters('FHEE__EE_Admin_Page_Menu_Map__construct__menu_args', $menu_args, $required, get_class($this)); |
|
161 | 161 | |
162 | 162 | |
163 | 163 | //verify that required keys are present in the incoming array. |
164 | - $missing = array_diff( (array) $required, array_keys( (array) $menu_args ) ); |
|
164 | + $missing = array_diff((array) $required, array_keys((array) $menu_args)); |
|
165 | 165 | |
166 | - if ( !empty( $missing ) ) { |
|
167 | - throw new EE_Error( sprintf( __('%s is missing some expected keys in the argument array. The following keys are missing: %s', 'event_espresso'), get_class( $this ), implode(', ', $missing ) ) ); |
|
166 | + if ( ! empty($missing)) { |
|
167 | + throw new EE_Error(sprintf(__('%s is missing some expected keys in the argument array. The following keys are missing: %s', 'event_espresso'), get_class($this), implode(', ', $missing))); |
|
168 | 168 | } |
169 | 169 | |
170 | 170 | //made it here okay, so let's set the properties! |
171 | - foreach ( $menu_args as $prop => $value ) { |
|
171 | + foreach ($menu_args as $prop => $value) { |
|
172 | 172 | |
173 | - switch ( $prop ) { |
|
173 | + switch ($prop) { |
|
174 | 174 | case 'show_on_menu' : |
175 | 175 | $value = (int) $value; |
176 | 176 | break; |
177 | 177 | case 'admin_init_page' : |
178 | - if ( in_array( 'admin_init_page', $required ) && ! $value instanceof EE_Admin_Page_Init ) { |
|
179 | - throw new EE_Error( sprintf( __('The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object. Instead %s was given as the value.', 'event_espresso'), print_r($value, TRUE) ) ); |
|
178 | + if (in_array('admin_init_page', $required) && ! $value instanceof EE_Admin_Page_Init) { |
|
179 | + throw new EE_Error(sprintf(__('The value for the "admin_init_page" argument must be an instance of an EE_Admin_Page_Init object. Instead %s was given as the value.', 'event_espresso'), print_r($value, TRUE))); |
|
180 | 180 | } |
181 | 181 | break; |
182 | 182 | case 'menu_callback' : |
@@ -187,24 +187,24 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | } |
190 | - if ( ! EEH_Class_Tools::has_property( $this, $prop ) ) |
|
191 | - throw new EE_Error( sprintf( __('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class( $this ), $prop ) ); |
|
190 | + if ( ! EEH_Class_Tools::has_property($this, $prop)) |
|
191 | + throw new EE_Error(sprintf(__('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class($this), $prop)); |
|
192 | 192 | $this->{$prop} = $value; |
193 | 193 | |
194 | 194 | } |
195 | 195 | |
196 | 196 | //filter capabilities (both static and dynamic) |
197 | - $this->capability = apply_filters( 'FHEE_management_capability', $this->capability, NULL ); |
|
198 | - $this->capability = apply_filters( 'FHEE_' . $this->menu_slug . '_capability', $this->capability, NULL ); |
|
197 | + $this->capability = apply_filters('FHEE_management_capability', $this->capability, NULL); |
|
198 | + $this->capability = apply_filters('FHEE_'.$this->menu_slug.'_capability', $this->capability, NULL); |
|
199 | 199 | |
200 | 200 | //Might need to change parent slug depending on maintenance mode. |
201 | - if ( ! empty( $this->maintenance_mode_parent ) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance ) { |
|
201 | + if ( ! empty($this->maintenance_mode_parent) && EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
202 | 202 | $this->parent_slug = $this->maintenance_mode_parent; |
203 | 203 | } |
204 | 204 | |
205 | 205 | //if empty menu_callback let's set default (but only if we have admin page init object) |
206 | - if ( empty( $this->menu_callback ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) |
|
207 | - $this->menu_callback = array( $this->admin_init_page, 'initialize_admin_page' ); |
|
206 | + if (empty($this->menu_callback) && $this->admin_init_page instanceof EE_Admin_Page_Init) |
|
207 | + $this->menu_callback = array($this->admin_init_page, 'initialize_admin_page'); |
|
208 | 208 | |
209 | 209 | } |
210 | 210 | |
@@ -226,21 +226,21 @@ discard block |
||
226 | 226 | * @param boolean $network_admin whether this is being added to the network admin page or not |
227 | 227 | * @since 4.4.0 |
228 | 228 | */ |
229 | - public function add_menu_page( $network_admin = FALSE ) { |
|
229 | + public function add_menu_page($network_admin = FALSE) { |
|
230 | 230 | |
231 | 231 | $show_on_menu_int = (int) $this->show_on_menu; |
232 | - if( ( $network_admin && in_array( $show_on_menu_int, array( self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY ), TRUE ) ) |
|
232 | + if (($network_admin && in_array($show_on_menu_int, array(self::BLOG_AND_NETWORK_ADMIN, self::NETWORK_ADMIN_ONLY), TRUE)) |
|
233 | 233 | || |
234 | - ( ! $network_admin && in_array( $show_on_menu_int, array( self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY ), TRUE )) ){ |
|
234 | + ( ! $network_admin && in_array($show_on_menu_int, array(self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY), TRUE))) { |
|
235 | 235 | $wp_page_slug = $this->_add_menu_page(); |
236 | - }else{ |
|
236 | + } else { |
|
237 | 237 | $wp_page_slug = ''; |
238 | 238 | } |
239 | 239 | |
240 | - if ( !empty( $wp_page_slug ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) { |
|
240 | + if ( ! empty($wp_page_slug) && $this->admin_init_page instanceof EE_Admin_Page_Init) { |
|
241 | 241 | try { |
242 | - $this->admin_init_page->set_page_dependencies( $wp_page_slug ); |
|
243 | - } catch( EE_Error $e ) { |
|
242 | + $this->admin_init_page->set_page_dependencies($wp_page_slug); |
|
243 | + } catch (EE_Error $e) { |
|
244 | 244 | $e->get_error(); |
245 | 245 | } |
246 | 246 | } |
@@ -293,12 +293,12 @@ discard block |
||
293 | 293 | public $position; |
294 | 294 | |
295 | 295 | |
296 | - public function __construct( $menu_args ) { |
|
297 | - $required = array( 'menu_label', 'parent_slug', 'menu_slug', 'menu_group', 'menu_order', 'admin_init_page'); |
|
296 | + public function __construct($menu_args) { |
|
297 | + $required = array('menu_label', 'parent_slug', 'menu_slug', 'menu_group', 'menu_order', 'admin_init_page'); |
|
298 | 298 | |
299 | - parent::__construct( $menu_args, $required ); |
|
299 | + parent::__construct($menu_args, $required); |
|
300 | 300 | |
301 | - $this->position = ! empty( $this->position ) ? (int) $this->position : $this->position; |
|
301 | + $this->position = ! empty($this->position) ? (int) $this->position : $this->position; |
|
302 | 302 | } |
303 | 303 | |
304 | 304 | |
@@ -306,9 +306,9 @@ discard block |
||
306 | 306 | * Uses the proper WP utility for registering a menu page for the main WP pages. |
307 | 307 | */ |
308 | 308 | protected function _add_menu_page() { |
309 | - $main = add_menu_page( $this->title, $this->menu_label, $this->capability, $this->parent_slug, $this->menu_callback, $this->icon_url, $this->position ); |
|
310 | - if ( ! empty( $this->subtitle ) ) { |
|
311 | - add_submenu_page( $this->parent_slug, $this->subtitle, $this->subtitle, $this->capability, $this->menu_slug, $this->menu_callback ); |
|
309 | + $main = add_menu_page($this->title, $this->menu_label, $this->capability, $this->parent_slug, $this->menu_callback, $this->icon_url, $this->position); |
|
310 | + if ( ! empty($this->subtitle)) { |
|
311 | + add_submenu_page($this->parent_slug, $this->subtitle, $this->subtitle, $this->capability, $this->menu_slug, $this->menu_callback); |
|
312 | 312 | } |
313 | 313 | return $main; |
314 | 314 | } |
@@ -325,13 +325,13 @@ discard block |
||
325 | 325 | */ |
326 | 326 | class EE_Admin_Page_Sub_Menu extends EE_Admin_Page_Main_Menu { |
327 | 327 | |
328 | - public function __construct( $menu_args ) { |
|
329 | - parent::__construct( $menu_args ); |
|
328 | + public function __construct($menu_args) { |
|
329 | + parent::__construct($menu_args); |
|
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | 333 | protected function _add_menu_page() { |
334 | - return add_submenu_page( $this->parent_slug, $this->title, $this->menu_label, $this->capability, $this->menu_slug, $this->menu_callback ); |
|
334 | + return add_submenu_page($this->parent_slug, $this->title, $this->menu_label, $this->capability, $this->menu_slug, $this->menu_callback); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | } //end class EE_Admin_Page_Menu_Map |
@@ -352,18 +352,18 @@ discard block |
||
352 | 352 | |
353 | 353 | |
354 | 354 | |
355 | - public function __construct( $menu_args = array() ) { |
|
356 | - $required = array( 'menu_label', 'menu_slug', 'menu_order', 'parent_slug' ); |
|
357 | - parent::__construct( $menu_args, $required ); |
|
355 | + public function __construct($menu_args = array()) { |
|
356 | + $required = array('menu_label', 'menu_slug', 'menu_order', 'parent_slug'); |
|
357 | + parent::__construct($menu_args, $required); |
|
358 | 358 | } |
359 | 359 | |
360 | 360 | |
361 | 361 | protected function _add_menu_page() { |
362 | - return add_submenu_page( $this->parent_slug, $this->menu_label, $this->_group_link(), $this->capability, $this->menu_slug, '__return_false' ); |
|
362 | + return add_submenu_page($this->parent_slug, $this->menu_label, $this->_group_link(), $this->capability, $this->menu_slug, '__return_false'); |
|
363 | 363 | } |
364 | 364 | |
365 | 365 | |
366 | 366 | private function _group_link() { |
367 | - return '<span class="ee_menu_group" onclick="return false;">' . $this->menu_label . '</span>'; |
|
367 | + return '<span class="ee_menu_group" onclick="return false;">'.$this->menu_label.'</span>'; |
|
368 | 368 | } |
369 | 369 | } //end EE_Admin_Page_Menu_Group |
@@ -187,8 +187,9 @@ discard block |
||
187 | 187 | break; |
188 | 188 | |
189 | 189 | } |
190 | - if ( ! EEH_Class_Tools::has_property( $this, $prop ) ) |
|
191 | - throw new EE_Error( sprintf( __('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class( $this ), $prop ) ); |
|
190 | + if ( ! EEH_Class_Tools::has_property( $this, $prop ) ) { |
|
191 | + throw new EE_Error( sprintf( __('The $menu_args coming into %s has a index key (%s) representing a property that is not defined by the class. Perhaps there is a typo?', 'event_espresso'), get_class( $this ), $prop ) ); |
|
192 | + } |
|
192 | 193 | $this->{$prop} = $value; |
193 | 194 | |
194 | 195 | } |
@@ -203,8 +204,9 @@ discard block |
||
203 | 204 | } |
204 | 205 | |
205 | 206 | //if empty menu_callback let's set default (but only if we have admin page init object) |
206 | - if ( empty( $this->menu_callback ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) |
|
207 | - $this->menu_callback = array( $this->admin_init_page, 'initialize_admin_page' ); |
|
207 | + if ( empty( $this->menu_callback ) && $this->admin_init_page instanceof EE_Admin_Page_Init ) { |
|
208 | + $this->menu_callback = array( $this->admin_init_page, 'initialize_admin_page' ); |
|
209 | + } |
|
208 | 210 | |
209 | 211 | } |
210 | 212 | |
@@ -233,7 +235,7 @@ discard block |
||
233 | 235 | || |
234 | 236 | ( ! $network_admin && in_array( $show_on_menu_int, array( self::BLOG_AND_NETWORK_ADMIN, self::BLOG_ADMIN_ONLY ), TRUE )) ){ |
235 | 237 | $wp_page_slug = $this->_add_menu_page(); |
236 | - }else{ |
|
238 | + } else{ |
|
237 | 239 | $wp_page_slug = ''; |
238 | 240 | } |
239 | 241 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -115,7 +115,7 @@ discard block |
||
115 | 115 | */ |
116 | 116 | public function __construct($caf = FALSE) { |
117 | 117 | $this->_is_caf = $caf; |
118 | - $this->_req_data = array_merge( $_GET, $_POST ); |
|
118 | + $this->_req_data = array_merge($_GET, $_POST); |
|
119 | 119 | $this->_set_tour_properties(); |
120 | 120 | $this->_set_tour_stops(); |
121 | 121 | $this->_set_tour_options(); |
@@ -158,36 +158,36 @@ discard block |
||
158 | 158 | * @access protected |
159 | 159 | * @return void |
160 | 160 | */ |
161 | - protected function _set_tour_options( $options = array() ) { |
|
161 | + protected function _set_tour_options($options = array()) { |
|
162 | 162 | $defaults = array( |
163 | - 'tipLocation' => 'bottom', // 'top', 'bottom', 'right', 'left' in relation to parent |
|
164 | - 'nubPosition' => 'auto', // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left" |
|
165 | - 'tipAdjustmentY' => 0, //allow for adjustment of tip |
|
166 | - 'tipAdjustmentX' => 0, //allow for adjustment of tip |
|
163 | + 'tipLocation' => 'bottom', // 'top', 'bottom', 'right', 'left' in relation to parent |
|
164 | + 'nubPosition' => 'auto', // override on a per tooltip bases. can be "auto", "right", "top", "bottom", "left" |
|
165 | + 'tipAdjustmentY' => 0, //allow for adjustment of tip |
|
166 | + 'tipAdjustmentX' => 0, //allow for adjustment of tip |
|
167 | 167 | 'scroll' => true, //whether to scrollTo the next step or not |
168 | - 'scrollSpeed' => 300, // Page scrolling speed in ms |
|
169 | - 'timer' => 0, // 0 = off, all other numbers = time(ms) |
|
170 | - 'autoStart' => true, // true or false - false tour starts when restart called |
|
171 | - 'startTimerOnClick' => true, // true/false to start timer on first click |
|
172 | - 'nextButton' => true, // true/false for next button visibility |
|
168 | + 'scrollSpeed' => 300, // Page scrolling speed in ms |
|
169 | + 'timer' => 0, // 0 = off, all other numbers = time(ms) |
|
170 | + 'autoStart' => true, // true or false - false tour starts when restart called |
|
171 | + 'startTimerOnClick' => true, // true/false to start timer on first click |
|
172 | + 'nextButton' => true, // true/false for next button visibility |
|
173 | 173 | 'button_text' => __('Next', 'event_espresso'), |
174 | - 'tipAnimation' => 'fade', // 'pop' or 'fade' in each tip |
|
175 | - 'pauseAfter' => array(), // array of indexes where to pause the tour after |
|
176 | - 'tipAnimationFadeSpeed' => 300, // if 'fade'- speed in ms of transition |
|
177 | - 'cookieMonster' => true, // true/false for whether cookies are used |
|
178 | - 'cookieName' => $this->get_slug(), // choose your own cookie name (setup will add the prefix for the specific page joyride) |
|
179 | - 'cookieDomain' => false, // set to false or yoursite.com |
|
174 | + 'tipAnimation' => 'fade', // 'pop' or 'fade' in each tip |
|
175 | + 'pauseAfter' => array(), // array of indexes where to pause the tour after |
|
176 | + 'tipAnimationFadeSpeed' => 300, // if 'fade'- speed in ms of transition |
|
177 | + 'cookieMonster' => true, // true/false for whether cookies are used |
|
178 | + 'cookieName' => $this->get_slug(), // choose your own cookie name (setup will add the prefix for the specific page joyride) |
|
179 | + 'cookieDomain' => false, // set to false or yoursite.com |
|
180 | 180 | //'tipContainer' => 'body', // Where the tip be attached if not inline |
181 | - 'modal' => false, // Whether to cover page with modal during the tour |
|
182 | - 'expose' => false, // Whether to expose the elements at each step in the tour (requires modal:true), |
|
183 | - 'postExposeCallback' => 'EEHelpTour.postExposeCallback', // A method to call after an element has been exposed |
|
184 | - 'preRideCallback' => 'EEHelpTour_preRideCallback', // A method to call before the tour starts (passed index, tip, and cloned exposed element) |
|
185 | - 'postRideCallback' => 'EEHelpTour_postRideCallback', // a method to call once the tour closes. This will correspond to the name of a js method that will have to be defined in loaded js. |
|
186 | - 'preStepCallback' => 'EEHelpTour_preStepCallback', // A method to call before each step |
|
187 | - 'postStepCallback' => 'EEHelpTour_postStepCallback', // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/ |
|
181 | + 'modal' => false, // Whether to cover page with modal during the tour |
|
182 | + 'expose' => false, // Whether to expose the elements at each step in the tour (requires modal:true), |
|
183 | + 'postExposeCallback' => 'EEHelpTour.postExposeCallback', // A method to call after an element has been exposed |
|
184 | + 'preRideCallback' => 'EEHelpTour_preRideCallback', // A method to call before the tour starts (passed index, tip, and cloned exposed element) |
|
185 | + 'postRideCallback' => 'EEHelpTour_postRideCallback', // a method to call once the tour closes. This will correspond to the name of a js method that will have to be defined in loaded js. |
|
186 | + 'preStepCallback' => 'EEHelpTour_preStepCallback', // A method to call before each step |
|
187 | + 'postStepCallback' => 'EEHelpTour_postStepCallback', // A method to call after each step (remember this will correspond with a js method that you will have to define in a js file BEFORE ee-help-tour.js loads, if the default methods do not exist, then ee-help-tour.js just substitues empty functions $.noop)/**/ |
|
188 | 188 | ); |
189 | 189 | |
190 | - $options = !empty( $options ) && is_array($options) ? array_merge( $defaults, $options ) : $defaults; |
|
190 | + $options = ! empty($options) && is_array($options) ? array_merge($defaults, $options) : $defaults; |
|
191 | 191 | $this->_options = $options; |
192 | 192 | } |
193 | 193 | |
@@ -202,8 +202,8 @@ discard block |
||
202 | 202 | * @return string slug for the tour |
203 | 203 | */ |
204 | 204 | public function get_slug() { |
205 | - if ( empty( $this->_slug ) ) |
|
206 | - throw new EE_Error( sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
205 | + if (empty($this->_slug)) |
|
206 | + throw new EE_Error(sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this))); |
|
207 | 207 | return $this->_slug; |
208 | 208 | } |
209 | 209 | |
@@ -215,8 +215,8 @@ discard block |
||
215 | 215 | * @return string |
216 | 216 | */ |
217 | 217 | public function get_label() { |
218 | - if ( empty( $this->_label ) ) |
|
219 | - throw new EE_Error( sprintf( __('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
218 | + if (empty($this->_label)) |
|
219 | + throw new EE_Error(sprintf(__('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this))); |
|
220 | 220 | return $this->_label; |
221 | 221 | } |
222 | 222 | |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | * @return array |
228 | 228 | */ |
229 | 229 | public function get_stops() { |
230 | - foreach( $this->_stops as $ind => $stop ) { |
|
231 | - if ( ! isset( $stop['button_text'] ) ) { |
|
230 | + foreach ($this->_stops as $ind => $stop) { |
|
231 | + if ( ! isset($stop['button_text'])) { |
|
232 | 232 | $this->_stops[$ind]['button_text'] = $this->_options['button_text']; |
233 | 233 | } |
234 | 234 | } |
@@ -243,12 +243,12 @@ discard block |
||
243 | 243 | */ |
244 | 244 | public function get_options() { |
245 | 245 | //let's make sure there are not pauses set |
246 | - foreach ( $this->_stops as $ind => $stop ) { |
|
247 | - if ( isset( $stop['pause_after'] ) && $stop['pause_after'] ) { |
|
246 | + foreach ($this->_stops as $ind => $stop) { |
|
247 | + if (isset($stop['pause_after']) && $stop['pause_after']) { |
|
248 | 248 | $this->_options['pauseAfter'][] = $ind; |
249 | 249 | } |
250 | 250 | } |
251 | - return apply_filters( 'FHEE__' . get_class($this) . '__get_options', $this->_options, $this ); |
|
251 | + return apply_filters('FHEE__'.get_class($this).'__get_options', $this->_options, $this); |
|
252 | 252 | } |
253 | 253 | |
254 | 254 | } |
@@ -1,6 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION')) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -202,8 +203,9 @@ discard block |
||
202 | 203 | * @return string slug for the tour |
203 | 204 | */ |
204 | 205 | public function get_slug() { |
205 | - if ( empty( $this->_slug ) ) |
|
206 | - throw new EE_Error( sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
206 | + if ( empty( $this->_slug ) ) { |
|
207 | + throw new EE_Error( sprintf(__('There is no slug set for the help tour class (%s). Make sure that the $_slug property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
208 | + } |
|
207 | 209 | return $this->_slug; |
208 | 210 | } |
209 | 211 | |
@@ -215,8 +217,9 @@ discard block |
||
215 | 217 | * @return string |
216 | 218 | */ |
217 | 219 | public function get_label() { |
218 | - if ( empty( $this->_label ) ) |
|
219 | - throw new EE_Error( sprintf( __('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
220 | + if ( empty( $this->_label ) ) { |
|
221 | + throw new EE_Error( sprintf( __('There is no label set for the help tour class (%s). Make sure that the $_label property is set in the class constructor', 'event_espresso'), get_class($this) ) ); |
|
222 | + } |
|
220 | 223 | return $this->_label; |
221 | 224 | } |
222 | 225 |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | 4 | |
5 | 5 | /** |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | 'action' => 'admin_option_settings', |
61 | 61 | 'page' => 'espresso_general_settings' |
62 | 62 | ); |
63 | - return '<p>' . sprintf( __('That\'s it for the tour! At any time you can restart a tour by clicking on this help dropdown and then clicking one of the Tour buttons. There are help tours available on all Event Espresso Admin pages. If you want to turn off help tours for all pages, %sgo here%s. All the best with your events!', 'event_espresso'), '<a href="' . EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php') ) . '">', '</a>' ) . '</p>'; |
|
63 | + return '<p>'.sprintf(__('That\'s it for the tour! At any time you can restart a tour by clicking on this help dropdown and then clicking one of the Tour buttons. There are help tours available on all Event Espresso Admin pages. If you want to turn off help tours for all pages, %sgo here%s. All the best with your events!', 'event_espresso'), '<a href="'.EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php')).'">', '</a>').'</p>'; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | } |
67 | 67 | \ No newline at end of file |
@@ -1,6 +1,7 @@ |
||
1 | 1 | <?php |
2 | -if (!defined('EVENT_ESPRESSO_VERSION') ) |
|
2 | +if (!defined('EVENT_ESPRESSO_VERSION') ) { |
|
3 | 3 | exit('NO direct script access allowed'); |
4 | +} |
|
4 | 5 | |
5 | 6 | /** |
6 | 7 | * Event Espresso |
@@ -1,16 +1,16 @@ |
||
1 | 1 | <div class="wrap espresso-admin about-wrap"> |
2 | 2 | |
3 | 3 | <h1><?php echo $admin_page_title; ?></h1> |
4 | - <div class="about-text"><?php echo !empty($admin_page_subtitle) ? $admin_page_subtitle : ''; ?></div> |
|
5 | - <div class="ee-badge"><img class="" src=" <?php echo EE_GLOBAL_ASSETS_URL; ?>images/event-espresso-cup-90x90.png" width="90" height="90" alt="<?php printf( esc_attr__( '%s Logo', 'event_espresso' ), 'Event Espresso' ); ?>"/><br /><?php printf( __('Version %s', 'event_espresso' ), EVENT_ESPRESSO_VERSION ); ?></div> |
|
4 | + <div class="about-text"><?php echo ! empty($admin_page_subtitle) ? $admin_page_subtitle : ''; ?></div> |
|
5 | + <div class="ee-badge"><img class="" src=" <?php echo EE_GLOBAL_ASSETS_URL; ?>images/event-espresso-cup-90x90.png" width="90" height="90" alt="<?php printf(esc_attr__('%s Logo', 'event_espresso'), 'Event Espresso'); ?>"/><br /><?php printf(__('Version %s', 'event_espresso'), EVENT_ESPRESSO_VERSION); ?></div> |
|
6 | 6 | |
7 | 7 | <?php echo $nav_tabs; ?> |
8 | 8 | |
9 | 9 | |
10 | 10 | <?php |
11 | - do_action( 'AHEE__admin_wrapper__template__before_about_admin_page_content' ); |
|
11 | + do_action('AHEE__admin_wrapper__template__before_about_admin_page_content'); |
|
12 | 12 | echo $about_admin_page_content; |
13 | - do_action( 'AHEE__admin_wrapper__template__after_about_admin_page_content' ); |
|
13 | + do_action('AHEE__admin_wrapper__template__after_about_admin_page_content'); |
|
14 | 14 | ?> |
15 | 15 | |
16 | 16 | </div> |