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 |
||
25 | final class EE_System implements ResettableInterface |
||
26 | { |
||
27 | |||
28 | /** |
||
29 | * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
||
30 | * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
||
31 | */ |
||
32 | const req_type_normal = 0; |
||
33 | |||
34 | /** |
||
35 | * Indicates this is a brand new installation of EE so we should install |
||
36 | * tables and default data etc |
||
37 | */ |
||
38 | const req_type_new_activation = 1; |
||
39 | |||
40 | /** |
||
41 | * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
||
42 | * and we just exited maintenance mode). We MUST check the database is setup properly |
||
43 | * and that default data is setup too |
||
44 | */ |
||
45 | const req_type_reactivation = 2; |
||
46 | |||
47 | /** |
||
48 | * indicates that EE has been upgraded since its previous request. |
||
49 | * We may have data migration scripts to call and will want to trigger maintenance mode |
||
50 | */ |
||
51 | const req_type_upgrade = 3; |
||
52 | |||
53 | /** |
||
54 | * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
||
55 | */ |
||
56 | const req_type_downgrade = 4; |
||
57 | |||
58 | /** |
||
59 | * @deprecated since version 4.6.0.dev.006 |
||
60 | * Now whenever a new_activation is detected the request type is still just |
||
61 | * new_activation (same for reactivation, upgrade, downgrade etc), but if we're in maintenance mode |
||
62 | * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
||
63 | * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
||
64 | * (Specifically, when the migration manager indicates migrations are finished |
||
65 | * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
||
66 | */ |
||
67 | const req_type_activation_but_not_installed = 5; |
||
68 | |||
69 | /** |
||
70 | * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
||
71 | */ |
||
72 | const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
||
73 | |||
74 | /** |
||
75 | * @var AddonManager $addon_manager |
||
76 | */ |
||
77 | private $addon_manager; |
||
78 | |||
79 | /** |
||
80 | * @var EE_System $_instance |
||
81 | */ |
||
82 | private static $_instance; |
||
83 | |||
84 | /** |
||
85 | * @var EE_Registry $registry |
||
86 | */ |
||
87 | private $registry; |
||
88 | |||
89 | /** |
||
90 | * @var LoaderInterface $loader |
||
91 | */ |
||
92 | private $loader; |
||
93 | |||
94 | /** |
||
95 | * @var EE_Capabilities $capabilities |
||
96 | */ |
||
97 | private $capabilities; |
||
98 | |||
99 | /** |
||
100 | * @var EE_Maintenance_Mode $maintenance_mode |
||
101 | */ |
||
102 | private $maintenance_mode; |
||
103 | |||
104 | /** |
||
105 | * @var RequestInterface $request |
||
106 | */ |
||
107 | private $request; |
||
108 | |||
109 | /** |
||
110 | * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
||
111 | * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
||
112 | * |
||
113 | * @var int $_req_type |
||
114 | */ |
||
115 | private $_req_type; |
||
116 | |||
117 | /** |
||
118 | * Whether or not there was a non-micro version change in EE core version during this request |
||
119 | * |
||
120 | * @var boolean $_major_version_change |
||
121 | */ |
||
122 | private $_major_version_change = false; |
||
123 | |||
124 | /** |
||
125 | * @var Router $router |
||
126 | */ |
||
127 | private $router; |
||
128 | |||
129 | |||
130 | /** |
||
131 | * @singleton method used to instantiate class object |
||
132 | * @param LoaderInterface|null $loader |
||
133 | * @param EE_Maintenance_Mode|null $maintenance_mode |
||
134 | * @param EE_Registry|null $registry |
||
135 | * @param RequestInterface|null $request |
||
136 | * @param Router|null $router |
||
137 | * @return EE_System |
||
138 | */ |
||
139 | public static function instance( |
||
140 | LoaderInterface $loader = null, |
||
141 | EE_Maintenance_Mode $maintenance_mode = null, |
||
142 | EE_Registry $registry = null, |
||
143 | RequestInterface $request = null, |
||
144 | Router $router = null |
||
145 | ): EE_System { |
||
146 | // check if class object is instantiated |
||
147 | if (! self::$_instance instanceof EE_System) { |
||
148 | self::$_instance = new self($loader, $maintenance_mode, $registry, $request, $router); |
||
149 | } |
||
150 | return self::$_instance; |
||
151 | } |
||
152 | |||
153 | |||
154 | /** |
||
155 | * resets the instance and returns it |
||
156 | * |
||
157 | * @return EE_System |
||
158 | */ |
||
159 | public static function reset(): EE_System |
||
160 | { |
||
161 | self::$_instance->_req_type = null; |
||
162 | // make sure none of the old hooks are left hanging around |
||
163 | remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
||
164 | // we need to reset the migration manager in order for it to detect DMSs properly |
||
165 | EE_Data_Migration_Manager::reset(); |
||
166 | self::instance()->detect_activations_or_upgrades(); |
||
167 | self::instance()->perform_activations_upgrades_and_migrations(); |
||
168 | return self::instance(); |
||
169 | } |
||
170 | |||
171 | |||
172 | /** |
||
173 | * sets hooks for running rest of system |
||
174 | * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
||
175 | * starting EE Addons from any other point may lead to problems |
||
176 | * |
||
177 | * @param LoaderInterface $loader |
||
178 | * @param EE_Maintenance_Mode $maintenance_mode |
||
179 | * @param EE_Registry $registry |
||
180 | * @param RequestInterface $request |
||
181 | * @param Router $router |
||
182 | */ |
||
183 | private function __construct( |
||
184 | LoaderInterface $loader, |
||
185 | EE_Maintenance_Mode $maintenance_mode, |
||
186 | EE_Registry $registry, |
||
187 | RequestInterface $request, |
||
188 | Router $router |
||
189 | ) { |
||
190 | $this->registry = $registry; |
||
191 | $this->loader = $loader; |
||
192 | $this->request = $request; |
||
193 | $this->router = $router; |
||
194 | $this->maintenance_mode = $maintenance_mode; |
||
195 | do_action('AHEE__EE_System__construct__begin', $this); |
||
196 | add_action( |
||
197 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
198 | [$this, 'loadCapabilities'], |
||
199 | 5 |
||
200 | ); |
||
201 | add_action( |
||
202 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
203 | [$this, 'loadCommandBus'], |
||
204 | 7 |
||
205 | ); |
||
206 | add_action( |
||
207 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
208 | [$this, 'loadPluginApi'], |
||
209 | 9 |
||
210 | ); |
||
211 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
||
212 | add_action( |
||
213 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
214 | [$this, 'load_espresso_addons'] |
||
215 | ); |
||
216 | // when an ee addon is activated, we want to call the core hook(s) again |
||
217 | // because the newly-activated addon didn't get a chance to run at all |
||
218 | add_action('activate_plugin', [$this, 'load_espresso_addons'], 1); |
||
219 | // detect whether install or upgrade |
||
220 | add_action( |
||
221 | 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
||
222 | [$this, 'detect_activations_or_upgrades'], |
||
223 | 3 |
||
224 | ); |
||
225 | // load EE_Config, EE_Textdomain, etc |
||
226 | add_action( |
||
227 | 'AHEE__EE_Bootstrap__load_core_configuration', |
||
228 | [$this, 'load_core_configuration'], |
||
229 | 5 |
||
230 | ); |
||
231 | // load specifications for matching routes to current request |
||
232 | add_action( |
||
233 | 'AHEE__EE_Bootstrap__load_core_configuration', |
||
234 | [$this, 'loadRouteMatchSpecifications'] |
||
235 | ); |
||
236 | // load EE_Config, EE_Textdomain, etc |
||
237 | add_action( |
||
238 | 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
||
239 | [$this, 'register_shortcodes_modules_and_widgets'], |
||
240 | 7 |
||
241 | ); |
||
242 | // you wanna get going? I wanna get going... let's get going! |
||
243 | add_action( |
||
244 | 'AHEE__EE_Bootstrap__brew_espresso', |
||
245 | [$this, 'brew_espresso'], |
||
246 | 9 |
||
247 | ); |
||
248 | // other housekeeping |
||
249 | // exclude EE critical pages from wp_list_pages |
||
250 | add_filter( |
||
251 | 'wp_list_pages_excludes', |
||
252 | [$this, 'remove_pages_from_wp_list_pages'], |
||
253 | 10 |
||
254 | ); |
||
255 | // ALL EE Addons should use the following hook point to attach their initial setup too |
||
256 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
||
257 | do_action('AHEE__EE_System__construct__complete', $this); |
||
258 | } |
||
259 | |||
260 | |||
261 | /** |
||
262 | * load and setup EE_Capabilities |
||
263 | * |
||
264 | * @return void |
||
265 | */ |
||
266 | public function loadCapabilities() |
||
267 | { |
||
268 | $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
||
269 | add_action( |
||
270 | 'AHEE__EE_Capabilities__init_caps__before_initialization', |
||
271 | function () { |
||
272 | LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
||
273 | } |
||
274 | ); |
||
275 | } |
||
276 | |||
277 | |||
278 | /** |
||
279 | * create and cache the CommandBus, and also add middleware |
||
280 | * The CapChecker middleware requires the use of EE_Capabilities |
||
281 | * which is why we need to load the CommandBus after Caps are set up |
||
282 | * |
||
283 | * @return void |
||
284 | */ |
||
285 | public function loadCommandBus() |
||
301 | |||
302 | |||
303 | /** |
||
304 | * @return void |
||
305 | * @throws Exception |
||
306 | */ |
||
307 | public function loadPluginApi() |
||
313 | |||
314 | |||
315 | /** |
||
316 | * load_espresso_addons |
||
317 | * allow addons to load first so that they can set hooks for running DMS's, etc |
||
318 | * this is hooked into both: |
||
319 | * 'AHEE__EE_Bootstrap__load_core_configuration' |
||
320 | * which runs during the WP 'plugins_loaded' action at priority 5 |
||
321 | * and the WP 'activate_plugin' hook point |
||
322 | * |
||
323 | * @return void |
||
324 | * @throws Exception |
||
325 | */ |
||
326 | public function load_espresso_addons() |
||
331 | |||
332 | |||
333 | /** |
||
334 | * detect_activations_or_upgrades |
||
335 | * Checks for activation or upgrade of core first; |
||
336 | * then also checks if any registered addons have been activated or upgraded |
||
337 | * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
||
338 | * which runs during the WP 'plugins_loaded' action at priority 3 |
||
339 | * |
||
340 | * @access public |
||
341 | * @return void |
||
342 | */ |
||
343 | public function detect_activations_or_upgrades() |
||
354 | |||
355 | |||
356 | /** |
||
357 | * detect_if_activation_or_upgrade |
||
358 | * Takes care of detecting whether this is a brand new install or code upgrade, |
||
359 | * and either setting up the DB or setting up maintenance mode etc. |
||
360 | * |
||
361 | * @access public |
||
362 | * @return void |
||
363 | */ |
||
364 | public function detect_if_activation_or_upgrade() |
||
398 | |||
399 | |||
400 | /** |
||
401 | * Updates the list of installed versions and sets hooks for |
||
402 | * initializing the database later during the request |
||
403 | * |
||
404 | * @param array $espresso_db_update |
||
405 | */ |
||
406 | private function _handle_core_version_change(array $espresso_db_update) |
||
415 | |||
416 | |||
417 | /** |
||
418 | * standardizes the wp option 'espresso_db_upgrade' which actually stores |
||
419 | * information about what versions of EE have been installed and activated, |
||
420 | * NOT necessarily the state of the database |
||
421 | * |
||
422 | * @param mixed $espresso_db_update the value of the WordPress option. |
||
423 | * If not supplied, fetches it from the options table |
||
424 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
||
425 | */ |
||
426 | private function fix_espresso_db_upgrade_option($espresso_db_update = null): array |
||
465 | |||
466 | |||
467 | /** |
||
468 | * Does the traditional work of setting up the plugin's database and adding default data. |
||
469 | * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
||
470 | * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
||
471 | * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
||
472 | * so that it will be done when migrations are finished |
||
473 | * |
||
474 | * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
||
475 | * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
||
476 | * This is a resource-intensive job |
||
477 | * so we prefer to only do it when necessary |
||
478 | * @return void |
||
479 | * @throws EE_Error |
||
480 | */ |
||
481 | public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
||
512 | |||
513 | |||
514 | /** |
||
515 | * Initializes the db for all registered addons |
||
516 | * |
||
517 | * @throws EE_Error |
||
518 | */ |
||
519 | public function initialize_addons() |
||
528 | |||
529 | |||
530 | /** |
||
531 | * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
||
532 | * |
||
533 | * @param array $version_history |
||
534 | * @param string $current_version_to_add version to be added to the version history |
||
535 | * @return boolean success as to whether or not this option was changed |
||
536 | */ |
||
537 | public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null): bool |
||
549 | |||
550 | |||
551 | /** |
||
552 | * Detects if the current version indicated in the has existed in the list of |
||
553 | * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
||
554 | * |
||
555 | * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
||
556 | * If not supplied, fetches it from the options table. |
||
557 | * Also, caches its result so later parts of the code can also know whether |
||
558 | * there's been an update or not. This way we can add the current version to |
||
559 | * espresso_db_update, but still know if this is a new install or not |
||
560 | * @return int one of the constants on EE_System::req_type_ |
||
561 | */ |
||
562 | public function detect_req_type($espresso_db_update = null): int |
||
578 | |||
579 | |||
580 | /** |
||
581 | * Returns whether or not there was a non-micro version change (ie, change in either |
||
582 | * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
||
583 | * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
||
584 | * |
||
585 | * @param $activation_history |
||
586 | * @return bool |
||
587 | */ |
||
588 | private function _detect_major_version_change($activation_history): bool |
||
603 | |||
604 | |||
605 | /** |
||
606 | * Returns true if either the major or minor version of EE changed during this request. |
||
607 | * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
||
608 | * |
||
609 | * @return bool |
||
610 | */ |
||
611 | public function is_major_version_change(): bool |
||
615 | |||
616 | |||
617 | /** |
||
618 | * Determines the request type for any ee addon, given three piece of info: the current array of activation |
||
619 | * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
||
620 | * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
||
621 | * just activated to (for core that will always be espresso_version()) |
||
622 | * |
||
623 | * @param array|null $activation_history the option's value which stores the activation history for |
||
624 | * this |
||
625 | * ee plugin. for core that's 'espresso_db_update' |
||
626 | * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
||
627 | * indicate that this plugin was just activated |
||
628 | * @param string $current_version the version that was just upgraded to (for core that will be |
||
629 | * espresso_version()) |
||
630 | * @return int one of the constants on EE_System::req_type_ |
||
631 | */ |
||
632 | public static function detect_req_type_given_activation_history( |
||
646 | |||
647 | |||
648 | /** |
||
649 | * @param array $activation_history |
||
650 | * @param int $version_change |
||
651 | * @param bool $is_activation |
||
652 | * @return int |
||
653 | * @since $VID:$ |
||
654 | */ |
||
655 | private static function getRequestType(array $activation_history, int $version_change, bool $is_activation): int |
||
675 | |||
676 | |||
677 | /** |
||
678 | * Detects if the $version_to_upgrade_to is higher than the most recent version in |
||
679 | * the $activation_history_for_addon |
||
680 | * |
||
681 | * @param array $activation_history array where keys are versions, |
||
682 | * values are arrays of times activated (sometimes 'unknown-date') |
||
683 | * @param string $current_version |
||
684 | * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
||
685 | * -1 if $version_to_upgrade_to is LOWER (downgrade); |
||
686 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
||
687 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
||
688 | */ |
||
689 | private static function compareVersionWithPrevious(array $activation_history, string $current_version): int |
||
695 | |||
696 | |||
697 | /** |
||
698 | * Gets the most recently active version listed in the activation history, |
||
699 | * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
||
700 | * |
||
701 | * @param array $activation_history (keys are versions, values are arrays of times activated, |
||
702 | * sometimes containing 'unknown-date' |
||
703 | * @return string |
||
704 | */ |
||
705 | private static function getMostRecentlyActiveVersion(array $activation_history): string |
||
727 | |||
728 | |||
729 | /** |
||
730 | * This redirects to the about EE page after activation |
||
731 | * |
||
732 | * @return void |
||
733 | */ |
||
734 | public function redirect_to_about_ee() |
||
756 | |||
757 | |||
758 | /** |
||
759 | * load_core_configuration |
||
760 | * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
||
761 | * which runs during the WP 'plugins_loaded' action at priority 5 |
||
762 | * |
||
763 | * @return void |
||
764 | * @throws ReflectionException |
||
765 | * @throws Exception |
||
766 | */ |
||
767 | public function load_core_configuration() |
||
796 | |||
797 | |||
798 | /** |
||
799 | * cycles through all of the models/*.model.php files, and assembles an array of model names |
||
800 | * |
||
801 | * @return void |
||
802 | * @throws ReflectionException |
||
803 | */ |
||
804 | private function _parse_model_names() |
||
826 | |||
827 | |||
828 | /** |
||
829 | * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
||
830 | * that need to be setup before our EE_System launches. |
||
831 | * |
||
832 | * @return void |
||
833 | * @throws DomainException |
||
834 | * @throws InvalidArgumentException |
||
835 | * @throws InvalidDataTypeException |
||
836 | * @throws InvalidInterfaceException |
||
837 | * @throws InvalidClassException |
||
838 | * @throws InvalidFilePathException |
||
839 | */ |
||
840 | private function _maybe_brew_regular() |
||
848 | |||
849 | |||
850 | /** |
||
851 | * @throws Exception |
||
852 | * @since 4.9.71.p |
||
853 | */ |
||
854 | public function loadRouteMatchSpecifications() |
||
865 | |||
866 | |||
867 | /** |
||
868 | * register_shortcodes_modules_and_widgets |
||
869 | * generate lists of shortcodes and modules, then verify paths and classes |
||
870 | * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
||
871 | * which runs during the WP 'plugins_loaded' action at priority 7 |
||
872 | * |
||
873 | * @access public |
||
874 | * @return void |
||
875 | * @throws Exception |
||
876 | */ |
||
877 | public function register_shortcodes_modules_and_widgets() |
||
886 | |||
887 | |||
888 | /** |
||
889 | * _incompatible_addon_error |
||
890 | * |
||
891 | * @access public |
||
892 | * @return void |
||
893 | */ |
||
894 | private function _incompatible_addon_error() |
||
926 | |||
927 | |||
928 | /** |
||
929 | * brew_espresso |
||
930 | * begins the process of setting hooks for initializing EE in the correct order |
||
931 | * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
||
932 | * which runs during the WP 'plugins_loaded' action at priority 9 |
||
933 | * |
||
934 | * @return void |
||
935 | * @throws Exception |
||
936 | */ |
||
937 | public function brew_espresso() |
||
951 | |||
952 | |||
953 | /** |
||
954 | * set_hooks_for_core |
||
955 | * |
||
956 | * @access public |
||
957 | * @return void |
||
958 | * @throws EE_Error |
||
959 | */ |
||
960 | public function set_hooks_for_core() |
||
969 | |||
970 | |||
971 | /** |
||
972 | * Using the information gathered in EE_System::_incompatible_addon_error, |
||
973 | * deactivates any addons considered incompatible with the current version of EE |
||
974 | */ |
||
975 | private function _deactivate_incompatible_addons() |
||
990 | |||
991 | |||
992 | /** |
||
993 | * perform_activations_upgrades_and_migrations |
||
994 | * |
||
995 | * @access public |
||
996 | * @return void |
||
997 | */ |
||
998 | public function perform_activations_upgrades_and_migrations() |
||
1002 | |||
1003 | |||
1004 | /** |
||
1005 | * @return void |
||
1006 | * @throws DomainException |
||
1007 | */ |
||
1008 | public function load_CPTs_and_session() |
||
1030 | |||
1031 | |||
1032 | /** |
||
1033 | * load_controllers |
||
1034 | * this is the best place to load any additional controllers that needs access to EE core. |
||
1035 | * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
||
1036 | * time |
||
1037 | * |
||
1038 | * @access public |
||
1039 | * @return void |
||
1040 | * @throws Exception |
||
1041 | */ |
||
1042 | public function load_controllers() |
||
1048 | |||
1049 | |||
1050 | /** |
||
1051 | * core_loaded_and_ready |
||
1052 | * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
||
1053 | * |
||
1054 | * @access public |
||
1055 | * @return void |
||
1056 | * @throws Exception |
||
1057 | */ |
||
1058 | public function core_loaded_and_ready() |
||
1069 | |||
1070 | |||
1071 | /** |
||
1072 | * initialize |
||
1073 | * this is the best place to begin initializing client code |
||
1074 | * |
||
1075 | * @access public |
||
1076 | * @return void |
||
1077 | */ |
||
1078 | public function initialize() |
||
1082 | |||
1083 | |||
1084 | /** |
||
1085 | * initialize_last |
||
1086 | * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
||
1087 | * initialize has done so |
||
1088 | * |
||
1089 | * @access public |
||
1090 | * @return void |
||
1091 | * @throws Exception |
||
1092 | */ |
||
1093 | public function initialize_last() |
||
1104 | |||
1105 | |||
1106 | /** |
||
1107 | * @return void |
||
1108 | */ |
||
1109 | public function addEspressoToolbar() |
||
1116 | |||
1117 | |||
1118 | /** |
||
1119 | * do_not_cache |
||
1120 | * sets no cache headers and defines no cache constants for WP plugins |
||
1121 | * |
||
1122 | * @access public |
||
1123 | * @return void |
||
1124 | */ |
||
1125 | public static function do_not_cache() |
||
1144 | |||
1145 | |||
1146 | /** |
||
1147 | * extra_nocache_headers |
||
1148 | * |
||
1149 | * @access public |
||
1150 | * @param $headers |
||
1151 | * @return array |
||
1152 | */ |
||
1153 | public static function extra_nocache_headers($headers): array |
||
1161 | |||
1162 | |||
1163 | /** |
||
1164 | * nocache_headers |
||
1165 | * |
||
1166 | * @access public |
||
1167 | * @return void |
||
1168 | */ |
||
1169 | public static function nocache_headers() |
||
1173 | |||
1174 | |||
1175 | /** |
||
1176 | * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
||
1177 | * never returned with the function. |
||
1178 | * |
||
1179 | * @param array $exclude_array any existing pages being excluded are in this array. |
||
1180 | * @return array |
||
1181 | */ |
||
1182 | public function remove_pages_from_wp_list_pages(array $exclude_array): array |
||
1186 | } |
||
1187 |
It seems like you allow that null is being passed for a parameter, however the function which is called does not seem to accept null.
We recommend to add an additional type check (or disallow null for the parameter):