Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like EE_System often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use EE_System, and based on these observations, apply Extract Interface, too.
1 | <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
||
24 | final class EE_System { |
||
25 | |||
26 | |||
27 | /** |
||
28 | * instance of the EE_System object |
||
29 | * |
||
30 | * @var $_instance |
||
31 | * @access private |
||
32 | */ |
||
33 | private static $_instance = null; |
||
34 | |||
35 | /** |
||
36 | * @access protected |
||
37 | * @type $config EE_Registry |
||
38 | */ |
||
39 | protected $registry; |
||
40 | |||
41 | /** |
||
42 | * @access protected |
||
43 | * @type $config EE_Config |
||
44 | */ |
||
45 | protected $config; |
||
46 | |||
47 | /** |
||
48 | * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
||
49 | * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
||
50 | */ |
||
51 | const req_type_normal = 0; |
||
52 | /** |
||
53 | * Indicates this is a brand new installation of EE so we should install |
||
54 | * tables and default data etc |
||
55 | */ |
||
56 | const req_type_new_activation = 1; |
||
57 | /** |
||
58 | * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
||
59 | * and we just exited maintenance mode). We MUST check the database is setup properly |
||
60 | * and that default data is setup too |
||
61 | */ |
||
62 | const req_type_reactivation = 2; |
||
63 | /** |
||
64 | * indicates that EE has been upgraded since its previous request. |
||
65 | * We may have data migration scripts to call and will want to trigger maintenance mode |
||
66 | */ |
||
67 | const req_type_upgrade = 3; |
||
68 | /** |
||
69 | * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
||
70 | */ |
||
71 | const req_type_downgrade = 4; |
||
72 | |||
73 | /** |
||
74 | * @deprecated since version 4.6.0.dev.006 |
||
75 | * Now whenever a new_activation is detected the request type is still just |
||
76 | * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
||
77 | * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
||
78 | * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
||
79 | * (Specifically, when the migration manager indicates migrations are finished |
||
80 | * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
||
81 | */ |
||
82 | const req_type_activation_but_not_installed = 5; |
||
83 | |||
84 | /** |
||
85 | * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
||
86 | */ |
||
87 | const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
||
88 | |||
89 | /** |
||
90 | * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
||
91 | * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
||
92 | * @var int |
||
93 | */ |
||
94 | private $_req_type; |
||
95 | |||
96 | |||
97 | |||
98 | /** |
||
99 | * @singleton method used to instantiate class object |
||
100 | * @access public |
||
101 | * @return EE_System |
||
102 | */ |
||
103 | public static function instance() { |
||
110 | |||
111 | |||
112 | /** |
||
113 | * resets the instance and returns it |
||
114 | * @return EE_System |
||
115 | */ |
||
116 | public static function reset(){ |
||
126 | |||
127 | |||
128 | |||
129 | /** |
||
130 | * sets hooks for running rest of system |
||
131 | * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
||
132 | * starting EE Addons from any other point may lead to problems |
||
133 | * |
||
134 | * @access private |
||
135 | */ |
||
136 | private function __construct() { |
||
158 | |||
159 | |||
160 | |||
161 | /** |
||
162 | * load_espresso_addons |
||
163 | * |
||
164 | * allow addons to load first so that they can set hooks for running DMS's, etc |
||
165 | * this is hooked into both: |
||
166 | * 'AHEE__EE_Bootstrap__load_core_configuration' |
||
167 | * which runs during the WP 'plugins_loaded' action at priority 5 |
||
168 | * and the WP 'activate_plugin' hookpoint |
||
169 | * |
||
170 | * @access public |
||
171 | * @return void |
||
172 | */ |
||
173 | public function load_espresso_addons() { |
||
181 | |||
182 | |||
183 | /** |
||
184 | * detect_activations_or_upgrades |
||
185 | * |
||
186 | * Checks for activation or upgrade of core first; |
||
187 | * then also checks if any registered addons have been activated or upgraded |
||
188 | * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
||
189 | * which runs during the WP 'plugins_loaded' action at priority 3 |
||
190 | * |
||
191 | * @access public |
||
192 | * @return void |
||
193 | */ |
||
194 | public function detect_activations_or_upgrades(){ |
||
202 | |||
203 | |||
204 | |||
205 | /** |
||
206 | * detect_if_activation_or_upgrade |
||
207 | * |
||
208 | * Takes care of detecting whether this is a brand new install or code upgrade, |
||
209 | * and either setting up the DB or setting up maintenance mode etc. |
||
210 | * |
||
211 | * @access public |
||
212 | * @return void |
||
213 | */ |
||
214 | public function detect_if_activation_or_upgrade() { |
||
257 | |||
258 | /** |
||
259 | * Updates the list of installed versions and sets hooks for |
||
260 | * initializing the database later during the request |
||
261 | * @param array $espresso_db_update |
||
262 | */ |
||
263 | protected function _handle_core_version_change( $espresso_db_update ){ |
||
268 | |||
269 | |||
270 | |||
271 | |||
272 | /** |
||
273 | * standardizes the wp option 'espresso_db_upgrade' which actually stores |
||
274 | * information about what versions of EE have been installed and activated, |
||
275 | * NOT necessarily the state of the database |
||
276 | * |
||
277 | * @param null $espresso_db_update |
||
278 | * @internal param array $espresso_db_update_value the value of the WordPress option. If not supplied, fetches it from the options table |
||
279 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
||
280 | */ |
||
281 | private function fix_espresso_db_upgrade_option($espresso_db_update = null){ |
||
321 | |||
322 | |||
323 | |||
324 | |||
325 | /** |
||
326 | * Does the traditional work of setting up the plugin's database and adding default data. |
||
327 | * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
||
328 | * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
||
329 | * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
||
330 | * so that it will be done when migrations are finished |
||
331 | * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
||
332 | * however, |
||
333 | * @param boolean $verify_db_schema if true will re-check the database tables have the correct schema. This is a resource-intensive job |
||
|
|||
334 | * so we prefer to only do it when necessary |
||
335 | * @return void |
||
336 | */ |
||
337 | public function initialize_db_if_no_migrations_required( $initialize_addons_too = FALSE, $verify_schema = true ){ |
||
357 | |||
358 | /** |
||
359 | * Initializes the db for all registered addons |
||
360 | */ |
||
361 | public function initialize_addons(){ |
||
367 | |||
368 | |||
369 | /** |
||
370 | * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
||
371 | * @param array $version_history |
||
372 | * @param string $current_version_to_add version to be added to the version history |
||
373 | * @return boolean success as to whether or not this option was changed |
||
374 | */ |
||
375 | public function update_list_of_installed_versions($version_history = NULL,$current_version_to_add = NULL) { |
||
386 | |||
387 | |||
388 | |||
389 | |||
390 | /** |
||
391 | * Detects if the current version indicated in the has existed in the list of |
||
392 | * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
||
393 | * |
||
394 | * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
||
395 | * If not supplied, fetches it from the options table. |
||
396 | * Also, caches its result so later parts of the code can also know whether there's been an |
||
397 | * update or not. This way we can add the current version to espresso_db_update, |
||
398 | * but still know if this is a new install or not |
||
399 | * @return int one of the constants on EE_System::req_type_ |
||
400 | */ |
||
401 | public function detect_req_type( $espresso_db_update = NULL ){ |
||
408 | |||
409 | |||
410 | |||
411 | /** |
||
412 | * Determines the request type for any ee addon, given three piece of info: the current array of activation histories (for core that' 'espresso_db_update' wp option); the name of the wordpress option which is temporarily set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin |
||
413 | * was just activated to (for core that will always be espresso_version()) |
||
414 | * @param array $activation_history_for_addon the option's value which stores the activation history for this ee plugin. |
||
415 | * for core that's 'espresso_db_update' |
||
416 | * @param string $activation_indicator_option_name the name of the wordpress option that is temporarily set to indicate that this plugin was just activated |
||
417 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be espresso_version()) |
||
418 | * @return int one of the constants on EE_System::req_type_* |
||
419 | */ |
||
420 | public static function detect_req_type_given_activation_history( $activation_history_for_addon, $activation_indicator_option_name, $version_to_upgrade_to ){ |
||
464 | |||
465 | |||
466 | |||
467 | /** |
||
468 | * Detects if the $version_to_upgrade_to is higher than the most recent version in |
||
469 | * the $activation_history_for_addon |
||
470 | * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
||
471 | * sometimes containing 'unknown-date' |
||
472 | * @param string $version_to_upgrade_to (current version) |
||
473 | * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
||
474 | * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
||
475 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
||
476 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
||
477 | */ |
||
478 | protected static function _new_version_is_higher( $activation_history_for_addon, $version_to_upgrade_to ){ |
||
503 | |||
504 | |||
505 | |||
506 | /** |
||
507 | * This redirects to the about EE page after activation |
||
508 | * @return void |
||
509 | */ |
||
510 | public function redirect_to_about_ee() { |
||
528 | |||
529 | |||
530 | /** |
||
531 | * load_core_configuration |
||
532 | * |
||
533 | * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
||
534 | * which runs during the WP 'plugins_loaded' action at priority 5 |
||
535 | * |
||
536 | * @return void |
||
537 | */ |
||
538 | public function load_core_configuration(){ |
||
564 | |||
565 | |||
566 | /** |
||
567 | * cycles through all of the models/*.model.php files, and assembles an array of model names |
||
568 | * |
||
569 | * @return void |
||
570 | */ |
||
571 | private function _parse_model_names(){ |
||
589 | |||
590 | |||
591 | |||
592 | /** |
||
593 | * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks that need to be setup before our EE_System launches. |
||
594 | * @return void |
||
595 | */ |
||
596 | private function _maybe_brew_regular() { |
||
601 | |||
602 | |||
603 | |||
604 | /** |
||
605 | * register_shortcodes_modules_and_widgets |
||
606 | * |
||
607 | * generate lists of shortcodes and modules, then verify paths and classes |
||
608 | * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
||
609 | * which runs during the WP 'plugins_loaded' action at priority 7 |
||
610 | * |
||
611 | * @access public |
||
612 | * @return void |
||
613 | */ |
||
614 | public function register_shortcodes_modules_and_widgets() { |
||
621 | |||
622 | |||
623 | /** |
||
624 | * _incompatible_addon_error |
||
625 | * |
||
626 | * @access public |
||
627 | * @return void |
||
628 | */ |
||
629 | private function _incompatible_addon_error() { |
||
647 | |||
648 | |||
649 | |||
650 | |||
651 | /** |
||
652 | * brew_espresso |
||
653 | * |
||
654 | * begins the process of setting hooks for initializing EE in the correct order |
||
655 | * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hookpoint |
||
656 | * which runs during the WP 'plugins_loaded' action at priority 9 |
||
657 | * |
||
658 | * @return void |
||
659 | */ |
||
660 | public function brew_espresso(){ |
||
680 | |||
681 | |||
682 | |||
683 | |||
684 | /** |
||
685 | * set_hooks_for_core |
||
686 | * |
||
687 | * @access public |
||
688 | * @return void |
||
689 | */ |
||
690 | public function set_hooks_for_core() { |
||
694 | |||
695 | |||
696 | |||
697 | /** |
||
698 | * Using the information gathered in EE_System::_incompatible_addon_error, |
||
699 | * deactivates any addons considered incompatible with the current version of EE |
||
700 | */ |
||
701 | private function _deactivate_incompatible_addons(){ |
||
715 | |||
716 | |||
717 | |||
718 | /** |
||
719 | * perform_activations_upgrades_and_migrations |
||
720 | * |
||
721 | * @access public |
||
722 | * @return void |
||
723 | */ |
||
724 | public function perform_activations_upgrades_and_migrations() { |
||
731 | |||
732 | |||
733 | |||
734 | /** |
||
735 | * load_CPTs_and_session |
||
736 | * |
||
737 | * @access public |
||
738 | * @return void |
||
739 | */ |
||
740 | public function load_CPTs_and_session() { |
||
746 | |||
747 | |||
748 | |||
749 | /** |
||
750 | * load_controllers |
||
751 | * |
||
752 | * this is the best place to load any additional controllers that needs access to EE core. |
||
753 | * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this time |
||
754 | * |
||
755 | * @access public |
||
756 | * @return void |
||
757 | */ |
||
758 | public function load_controllers() { |
||
770 | |||
771 | |||
772 | |||
773 | /** |
||
774 | * core_loaded_and_ready |
||
775 | * |
||
776 | * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
||
777 | * |
||
778 | * @access public |
||
779 | * @return void |
||
780 | */ |
||
781 | public function core_loaded_and_ready() { |
||
787 | |||
788 | |||
789 | |||
790 | /** |
||
791 | * initialize |
||
792 | * |
||
793 | * this is the best place to begin initializing client code |
||
794 | * |
||
795 | * @access public |
||
796 | * @return void |
||
797 | */ |
||
798 | public function initialize() { |
||
801 | |||
802 | |||
803 | |||
804 | /** |
||
805 | * initialize_last |
||
806 | * |
||
807 | * this is run really late during the WP init hookpoint, and ensures that mostly everything else that needs to initialize has done so |
||
808 | * |
||
809 | * @access public |
||
810 | * @return void |
||
811 | */ |
||
812 | public function initialize_last() { |
||
815 | |||
816 | |||
817 | |||
818 | |||
819 | /** |
||
820 | * set_hooks_for_shortcodes_modules_and_addons |
||
821 | * |
||
822 | * this is the best place for other systems to set callbacks for hooking into other parts of EE |
||
823 | * this happens at the very beginning of the wp_loaded hookpoint |
||
824 | * |
||
825 | * @access public |
||
826 | * @return void |
||
827 | */ |
||
828 | public function set_hooks_for_shortcodes_modules_and_addons() { |
||
831 | |||
832 | |||
833 | |||
834 | |||
835 | /** |
||
836 | * do_not_cache |
||
837 | * |
||
838 | * sets no cache headers and defines no cache constants for WP plugins |
||
839 | * |
||
840 | * @access public |
||
841 | * @return void |
||
842 | */ |
||
843 | public static function do_not_cache() { |
||
861 | |||
862 | |||
863 | |||
864 | /** |
||
865 | * nocache_headers_nginx |
||
866 | * |
||
867 | * @access public |
||
868 | * @param $headers |
||
869 | * @return array |
||
870 | */ |
||
871 | public static function nocache_headers_nginx ( $headers ) { |
||
875 | |||
876 | |||
877 | |||
878 | /** |
||
879 | * nocache_headers |
||
880 | * |
||
881 | * @access public |
||
882 | * @return void |
||
883 | */ |
||
884 | public static function nocache_headers() { |
||
887 | |||
888 | |||
889 | |||
890 | /** |
||
891 | * espresso_toolbar_items |
||
892 | * |
||
893 | * @access public |
||
894 | * @param $admin_bar |
||
895 | * @return void |
||
896 | */ |
||
897 | public function espresso_toolbar_items( $admin_bar ) { |
||
898 | |||
899 | // if in full M-Mode, or its an AJAX request, or user is NOT an admin |
||
900 | if ( EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance || defined( 'DOING_AJAX' ) || ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_top_level' )) { |
||
901 | return; |
||
902 | } |
||
903 | |||
904 | do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
||
905 | EE_Registry::instance()->load_helper( 'URL' ); |
||
906 | $menu_class = 'espresso_menu_item_class'; |
||
907 | //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
||
908 | //because they're only defined in each of their respective constructors |
||
909 | //and this might be a frontend request, in which case they aren't available |
||
910 | $events_admin_url = admin_url("admin.php?page=espresso_events"); |
||
911 | $reg_admin_url = admin_url("admin.php?page=espresso_registrations"); |
||
912 | $extensions_admin_url = admin_url("admin.php?page=espresso_packages"); |
||
913 | |||
914 | //Top Level |
||
915 | $admin_bar->add_menu(array( |
||
916 | 'id' => 'espresso-toolbar', |
||
917 | 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' . _x('Event Espresso', 'admin bar menu group label', 'event_espresso') . '</span>', |
||
918 | 'href' => $events_admin_url, |
||
919 | 'meta' => array( |
||
920 | 'title' => __('Event Espresso', 'event_espresso'), |
||
921 | 'class' => $menu_class . 'first' |
||
922 | ), |
||
923 | )); |
||
924 | |||
925 | //Events |
||
926 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events' ) ) { |
|
927 | $admin_bar->add_menu(array( |
||
928 | 'id' => 'espresso-toolbar-events', |
||
929 | 'parent' => 'espresso-toolbar', |
||
930 | 'title' => __( 'Events', 'event_espresso' ), |
||
931 | 'href' => $events_admin_url, |
||
932 | 'meta' => array( |
||
933 | 'title' => __('Events', 'event_espresso'), |
||
934 | 'target' => '', |
||
935 | 'class' => $menu_class |
||
936 | ), |
||
937 | )); |
||
938 | } |
||
939 | |||
940 | |||
941 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new' ) ) { |
|
942 | //Events Add New |
||
943 | $admin_bar->add_menu(array( |
||
944 | 'id' => 'espresso-toolbar-events-new', |
||
945 | 'parent' => 'espresso-toolbar-events', |
||
946 | 'title' => __('Add New', 'event_espresso'), |
||
947 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'create_new' ), $events_admin_url ), |
||
948 | 'meta' => array( |
||
949 | 'title' => __('Add New', 'event_espresso'), |
||
950 | 'target' => '', |
||
951 | 'class' => $menu_class |
||
952 | ), |
||
953 | )); |
||
954 | } |
||
955 | |||
956 | if ( is_single() && ( get_post_type() == 'espresso_events' ) ) { |
||
957 | |||
958 | //Current post |
||
959 | global $post; |
||
960 | |||
961 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_event', 'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID ) ) { |
|
962 | //Events Edit Current Event |
||
963 | $admin_bar->add_menu(array( |
||
964 | 'id' => 'espresso-toolbar-events-edit', |
||
965 | 'parent' => 'espresso-toolbar-events', |
||
966 | 'title' => __('Edit Event', 'event_espresso'), |
||
967 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$post->ID ), $events_admin_url ), |
||
968 | 'meta' => array( |
||
969 | 'title' => __('Edit Event', 'event_espresso'), |
||
970 | 'target' => '', |
||
971 | 'class' => $menu_class |
||
972 | ), |
||
973 | )); |
||
974 | } |
||
975 | |||
976 | } |
||
977 | |||
978 | //Events View |
||
979 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-view' ) ) { |
|
980 | $admin_bar->add_menu(array( |
||
981 | 'id' => 'espresso-toolbar-events-view', |
||
982 | 'parent' => 'espresso-toolbar-events', |
||
983 | 'title' => __( 'View', 'event_espresso' ), |
||
984 | 'href' => $events_admin_url, |
||
985 | 'meta' => array( |
||
986 | 'title' => __('View', 'event_espresso'), |
||
987 | 'target' => '', |
||
988 | 'class' => $menu_class |
||
989 | ), |
||
990 | )); |
||
991 | } |
||
992 | |||
993 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all' ) ) { |
|
994 | //Events View All |
||
995 | $admin_bar->add_menu(array( |
||
996 | 'id' => 'espresso-toolbar-events-all', |
||
997 | 'parent' => 'espresso-toolbar-events-view', |
||
998 | 'title' => __( 'All', 'event_espresso' ), |
||
999 | 'href' => $events_admin_url, |
||
1000 | 'meta' => array( |
||
1001 | 'title' => __('All', 'event_espresso'), |
||
1002 | 'target' => '', |
||
1003 | 'class' => $menu_class |
||
1004 | ), |
||
1005 | )); |
||
1006 | } |
||
1007 | |||
1008 | |||
1009 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-today' ) ) { |
|
1010 | //Events View Today |
||
1011 | $admin_bar->add_menu(array( |
||
1012 | 'id' => 'espresso-toolbar-events-today', |
||
1013 | 'parent' => 'espresso-toolbar-events-view', |
||
1014 | 'title' => __('Today', 'event_espresso'), |
||
1015 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $events_admin_url ), |
||
1016 | 'meta' => array( |
||
1017 | 'title' => __('Today', 'event_espresso'), |
||
1018 | 'target' => '', |
||
1019 | 'class' => $menu_class |
||
1020 | ), |
||
1021 | )); |
||
1022 | } |
||
1023 | |||
1024 | |||
1025 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-month' ) ) { |
|
1026 | //Events View This Month |
||
1027 | $admin_bar->add_menu(array( |
||
1028 | 'id' => 'espresso-toolbar-events-month', |
||
1029 | 'parent' => 'espresso-toolbar-events-view', |
||
1030 | 'title' => __( 'This Month', 'event_espresso'), |
||
1031 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $events_admin_url ), |
||
1032 | 'meta' => array( |
||
1033 | 'title' => __('This Month', 'event_espresso'), |
||
1034 | 'target' => '', |
||
1035 | 'class' => $menu_class |
||
1036 | ), |
||
1037 | )); |
||
1038 | } |
||
1039 | |||
1040 | //Registration Overview |
||
1041 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations' ) ) { |
|
1042 | $admin_bar->add_menu(array( |
||
1043 | 'id' => 'espresso-toolbar-registrations', |
||
1044 | 'parent' => 'espresso-toolbar', |
||
1045 | 'title' => __( 'Registrations', 'event_espresso' ), |
||
1046 | 'href' => $reg_admin_url, |
||
1047 | 'meta' => array( |
||
1048 | 'title' => __('Registrations', 'event_espresso'), |
||
1049 | 'target' => '', |
||
1050 | 'class' => $menu_class |
||
1051 | ), |
||
1052 | )); |
||
1053 | } |
||
1054 | |||
1055 | //Registration Overview Today |
||
1056 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today' ) ) { |
|
1057 | $admin_bar->add_menu(array( |
||
1058 | 'id' => 'espresso-toolbar-registrations-today', |
||
1059 | 'parent' => 'espresso-toolbar-registrations', |
||
1060 | 'title' => __( 'Today', 'event_espresso'), |
||
1061 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today' ), $reg_admin_url ), |
||
1062 | 'meta' => array( |
||
1063 | 'title' => __('Today', 'event_espresso'), |
||
1064 | 'target' => '', |
||
1065 | 'class' => $menu_class |
||
1066 | ), |
||
1067 | )); |
||
1068 | } |
||
1069 | |||
1070 | //Registration Overview Today Completed |
||
1071 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' ) ) { |
|
1072 | $admin_bar->add_menu(array( |
||
1073 | 'id' => 'espresso-toolbar-registrations-today-approved', |
||
1074 | 'parent' => 'espresso-toolbar-registrations-today', |
||
1075 | 'title' => __( 'Approved', 'event_espresso' ), |
||
1076 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
||
1077 | 'meta' => array( |
||
1078 | 'title' => __('Approved', 'event_espresso' ), |
||
1079 | 'target' => '', |
||
1080 | 'class' => $menu_class |
||
1081 | ), |
||
1082 | )); |
||
1083 | } |
||
1084 | |||
1085 | //Registration Overview Today Pending\ |
||
1086 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' ) ) { |
|
1087 | $admin_bar->add_menu(array( |
||
1088 | 'id' => 'espresso-toolbar-registrations-today-pending', |
||
1089 | 'parent' => 'espresso-toolbar-registrations-today', |
||
1090 | 'title' => __( 'Pending', 'event_espresso' ), |
||
1091 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', 'reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
||
1092 | 'meta' => array( |
||
1093 | 'title' => __('Pending Payment', 'event_espresso' ), |
||
1094 | 'target' => '', |
||
1095 | 'class' => $menu_class |
||
1096 | ), |
||
1097 | )); |
||
1098 | } |
||
1099 | |||
1100 | //Registration Overview Today Incomplete |
||
1101 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' ) ) { |
|
1102 | $admin_bar->add_menu(array( |
||
1103 | 'id' => 'espresso-toolbar-registrations-today-not-approved', |
||
1104 | 'parent' => 'espresso-toolbar-registrations-today', |
||
1105 | 'title' => __( 'Not Approved', 'event_espresso' ), |
||
1106 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
||
1107 | 'meta' => array( |
||
1108 | 'title' => __('Not Approved', 'event_espresso' ), |
||
1109 | 'target' => '', |
||
1110 | 'class' => $menu_class |
||
1111 | ), |
||
1112 | )); |
||
1113 | } |
||
1114 | |||
1115 | //Registration Overview Today Incomplete |
||
1116 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' ) ) { |
|
1117 | $admin_bar->add_menu(array( |
||
1118 | 'id' => 'espresso-toolbar-registrations-today-cancelled', |
||
1119 | 'parent' => 'espresso-toolbar-registrations-today', |
||
1120 | 'title' => __( 'Cancelled', 'event_espresso'), |
||
1121 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'today', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
||
1122 | 'meta' => array( |
||
1123 | 'title' => __('Cancelled', 'event_espresso'), |
||
1124 | 'target' => '', |
||
1125 | 'class' => $menu_class |
||
1126 | ), |
||
1127 | )); |
||
1128 | } |
||
1129 | |||
1130 | //Registration Overview This Month |
||
1131 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month' ) ) { |
|
1132 | $admin_bar->add_menu(array( |
||
1133 | 'id' => 'espresso-toolbar-registrations-month', |
||
1134 | 'parent' => 'espresso-toolbar-registrations', |
||
1135 | 'title' => __( 'This Month', 'event_espresso' ), |
||
1136 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month' ), $reg_admin_url ), |
||
1137 | 'meta' => array( |
||
1138 | 'title' => __('This Month', 'event_espresso'), |
||
1139 | 'target' => '', |
||
1140 | 'class' => $menu_class |
||
1141 | ), |
||
1142 | )); |
||
1143 | } |
||
1144 | |||
1145 | //Registration Overview This Month Approved |
||
1146 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' ) ) { |
|
1147 | $admin_bar->add_menu(array( |
||
1148 | 'id' => 'espresso-toolbar-registrations-month-approved', |
||
1149 | 'parent' => 'espresso-toolbar-registrations-month', |
||
1150 | 'title' => __( 'Approved', 'event_espresso' ), |
||
1151 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_approved ), $reg_admin_url ), |
||
1152 | 'meta' => array( |
||
1153 | 'title' => __('Approved', 'event_espresso'), |
||
1154 | 'target' => '', |
||
1155 | 'class' => $menu_class |
||
1156 | ), |
||
1157 | )); |
||
1158 | } |
||
1159 | |||
1160 | //Registration Overview This Month Pending |
||
1161 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' ) ) { |
|
1162 | $admin_bar->add_menu(array( |
||
1163 | 'id' => 'espresso-toolbar-registrations-month-pending', |
||
1164 | 'parent' => 'espresso-toolbar-registrations-month', |
||
1165 | 'title' => __( 'Pending', 'event_espresso'), |
||
1166 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_pending_payment ), $reg_admin_url ), |
||
1167 | 'meta' => array( |
||
1168 | 'title' => __('Pending', 'event_espresso'), |
||
1169 | 'target' => '', |
||
1170 | 'class' => $menu_class |
||
1171 | ), |
||
1172 | )); |
||
1173 | } |
||
1174 | |||
1175 | //Registration Overview This Month Not Approved |
||
1176 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' ) ) { |
|
1177 | $admin_bar->add_menu(array( |
||
1178 | 'id' => 'espresso-toolbar-registrations-month-not-approved', |
||
1179 | 'parent' => 'espresso-toolbar-registrations-month', |
||
1180 | 'title' => __( 'Not Approved', 'event_espresso'), |
||
1181 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_not_approved ), $reg_admin_url ), |
||
1182 | 'meta' => array( |
||
1183 | 'title' => __('Not Approved', 'event_espresso' ), |
||
1184 | 'target' => '', |
||
1185 | 'class' => $menu_class |
||
1186 | ), |
||
1187 | )); |
||
1188 | } |
||
1189 | |||
1190 | |||
1191 | //Registration Overview This Month Cancelled |
||
1192 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' ) ) { |
|
1193 | $admin_bar->add_menu(array( |
||
1194 | 'id' => 'espresso-toolbar-registrations-month-cancelled', |
||
1195 | 'parent' => 'espresso-toolbar-registrations-month', |
||
1196 | 'title' => __('Cancelled', 'event_espresso'), |
||
1197 | 'href' => EEH_URL::add_query_args_and_nonce( array( 'action'=>'default', 'status'=>'month', '_reg_status'=>EEM_Registration::status_id_cancelled ), $reg_admin_url ), |
||
1198 | 'meta' => array( |
||
1199 | 'title' => __('Cancelled', 'event_espresso'), |
||
1200 | 'target' => '', |
||
1201 | 'class' => $menu_class |
||
1202 | ), |
||
1203 | )); |
||
1204 | } |
||
1205 | |||
1206 | //Extensions & Services |
||
1207 | View Code Duplication | if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' ) ) { |
|
1208 | $admin_bar->add_menu(array( |
||
1209 | 'id' => 'espresso-toolbar-extensions-and-services', |
||
1210 | 'parent' => 'espresso-toolbar', |
||
1211 | 'title' => __( 'Extensions & Services', 'event_espresso' ), |
||
1212 | 'href' => $extensions_admin_url, |
||
1213 | 'meta' => array( |
||
1214 | 'title' => __('Extensions & Services', 'event_espresso'), |
||
1215 | 'target' => '', |
||
1216 | 'class' => $menu_class |
||
1217 | ), |
||
1218 | )); |
||
1219 | } |
||
1220 | } |
||
1221 | |||
1222 | |||
1223 | |||
1224 | |||
1225 | |||
1226 | /** |
||
1227 | * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are never returned with the function. |
||
1228 | * |
||
1229 | * |
||
1230 | * @param array $exclude_array any existing pages being excluded are in this array. |
||
1231 | * @return array |
||
1232 | */ |
||
1233 | public function remove_pages_from_wp_list_pages( $exclude_array ) { |
||
1236 | |||
1237 | |||
1238 | |||
1239 | |||
1240 | |||
1241 | |||
1242 | /*********************************************** WP_ENQUEUE_SCRIPTS HOOK ***********************************************/ |
||
1243 | |||
1244 | |||
1245 | |||
1246 | /** |
||
1247 | * wp_enqueue_scripts |
||
1248 | * |
||
1249 | * @access public |
||
1250 | * @return void |
||
1251 | */ |
||
1252 | public function wp_enqueue_scripts() { |
||
1262 | |||
1263 | |||
1264 | |||
1265 | } |
||
1266 | // End of file EE_System.core.php |
||
1268 |
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italy
is not defined by the methodfinale(...)
.The most likely cause is that the parameter was removed, but the annotation was not.