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 |
||
| 23 | final class EE_System implements ResettableInterface |
||
| 24 | { |
||
| 25 | |||
| 26 | |||
| 27 | /** |
||
| 28 | * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
||
| 29 | * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
||
| 30 | */ |
||
| 31 | const req_type_normal = 0; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * Indicates this is a brand new installation of EE so we should install |
||
| 35 | * tables and default data etc |
||
| 36 | */ |
||
| 37 | const req_type_new_activation = 1; |
||
| 38 | |||
| 39 | /** |
||
| 40 | * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
||
| 41 | * and we just exited maintenance mode). We MUST check the database is setup properly |
||
| 42 | * and that default data is setup too |
||
| 43 | */ |
||
| 44 | const req_type_reactivation = 2; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * indicates that EE has been upgraded since its previous request. |
||
| 48 | * We may have data migration scripts to call and will want to trigger maintenance mode |
||
| 49 | */ |
||
| 50 | const req_type_upgrade = 3; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
||
| 54 | */ |
||
| 55 | const req_type_downgrade = 4; |
||
| 56 | |||
| 57 | /** |
||
| 58 | * @deprecated since version 4.6.0.dev.006 |
||
| 59 | * Now whenever a new_activation is detected the request type is still just |
||
| 60 | * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
||
| 61 | * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
||
| 62 | * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
||
| 63 | * (Specifically, when the migration manager indicates migrations are finished |
||
| 64 | * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
||
| 65 | */ |
||
| 66 | const req_type_activation_but_not_installed = 5; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
||
| 70 | */ |
||
| 71 | const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
||
| 72 | |||
| 73 | |||
| 74 | /** |
||
| 75 | * @var EE_System $_instance |
||
| 76 | */ |
||
| 77 | private static $_instance; |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @var EE_Registry $registry |
||
| 81 | */ |
||
| 82 | protected $registry; |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
||
| 86 | * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
||
| 87 | * |
||
| 88 | * @var int $_req_type |
||
| 89 | */ |
||
| 90 | private $_req_type; |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Whether or not there was a non-micro version change in EE core version during this request |
||
| 94 | * |
||
| 95 | * @var boolean $_major_version_change |
||
| 96 | */ |
||
| 97 | private $_major_version_change = false; |
||
| 98 | |||
| 99 | |||
| 100 | |||
| 101 | /** |
||
| 102 | * @singleton method used to instantiate class object |
||
| 103 | * @access public |
||
| 104 | * @param EE_Registry $Registry |
||
| 105 | * @return EE_System |
||
| 106 | */ |
||
| 107 | public static function instance(EE_Registry $Registry = null) |
||
| 115 | |||
| 116 | |||
| 117 | |||
| 118 | /** |
||
| 119 | * resets the instance and returns it |
||
| 120 | * |
||
| 121 | * @return EE_System |
||
| 122 | */ |
||
| 123 | public static function reset() |
||
| 134 | |||
| 135 | |||
| 136 | |||
| 137 | /** |
||
| 138 | * sets hooks for running rest of system |
||
| 139 | * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
||
| 140 | * starting EE Addons from any other point may lead to problems |
||
| 141 | * |
||
| 142 | * @access private |
||
| 143 | * @param EE_Registry $Registry |
||
| 144 | */ |
||
| 145 | private function __construct(EE_Registry $Registry) |
||
| 146 | { |
||
| 147 | $this->registry = $Registry; |
||
| 148 | do_action('AHEE__EE_System__construct__begin', $this); |
||
| 149 | add_action( |
||
| 150 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
| 151 | array($this, 'loadCapabilities'), |
||
| 152 | 5 |
||
| 153 | ); |
||
| 154 | add_action( |
||
| 155 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
| 156 | array($this, 'loadCommandBus'), |
||
| 157 | 7 |
||
| 158 | ); |
||
| 159 | add_action( |
||
| 160 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
| 161 | array($this, 'loadPluginApi'), |
||
| 162 | 9 |
||
| 163 | ); |
||
| 164 | // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
||
| 165 | add_action( |
||
| 166 | 'AHEE__EE_Bootstrap__load_espresso_addons', |
||
| 167 | array($this, 'load_espresso_addons') |
||
| 168 | ); |
||
| 169 | // when an ee addon is activated, we want to call the core hook(s) again |
||
| 170 | // because the newly-activated addon didn't get a chance to run at all |
||
| 171 | add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
||
| 172 | // detect whether install or upgrade |
||
| 173 | add_action( |
||
| 174 | 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
||
| 175 | array($this, 'detect_activations_or_upgrades'), |
||
| 176 | 3 |
||
| 177 | ); |
||
| 178 | // load EE_Config, EE_Textdomain, etc |
||
| 179 | add_action( |
||
| 180 | 'AHEE__EE_Bootstrap__load_core_configuration', |
||
| 181 | array($this, 'load_core_configuration'), |
||
| 182 | 5 |
||
| 183 | ); |
||
| 184 | // load EE_Config, EE_Textdomain, etc |
||
| 185 | add_action( |
||
| 186 | 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
||
| 187 | array($this, 'register_shortcodes_modules_and_widgets'), |
||
| 188 | 7 |
||
| 189 | ); |
||
| 190 | // you wanna get going? I wanna get going... let's get going! |
||
| 191 | add_action( |
||
| 192 | 'AHEE__EE_Bootstrap__brew_espresso', |
||
| 193 | array($this, 'brew_espresso'), |
||
| 194 | 9 |
||
| 195 | ); |
||
| 196 | //other housekeeping |
||
| 197 | //exclude EE critical pages from wp_list_pages |
||
| 198 | add_filter( |
||
| 199 | 'wp_list_pages_excludes', |
||
| 200 | array($this, 'remove_pages_from_wp_list_pages'), |
||
| 201 | 10 |
||
| 202 | ); |
||
| 203 | // ALL EE Addons should use the following hook point to attach their initial setup too |
||
| 204 | // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
||
| 205 | do_action('AHEE__EE_System__construct__complete', $this); |
||
| 206 | } |
||
| 207 | |||
| 208 | |||
| 209 | |||
| 210 | /** |
||
| 211 | * load and setup EE_Capabilities |
||
| 212 | * |
||
| 213 | * @return void |
||
| 214 | * @throws EE_Error |
||
| 215 | */ |
||
| 216 | public function loadCapabilities() |
||
| 217 | { |
||
| 218 | $this->registry->load_core('EE_Capabilities'); |
||
| 219 | add_action( |
||
| 220 | 'AHEE__EE_Capabilities__init_caps__before_initialization', |
||
| 221 | function() { |
||
| 222 | EE_Registry::instance()->load_lib('Payment_Method_Manager'); |
||
| 223 | } |
||
| 224 | ); |
||
| 225 | } |
||
| 226 | |||
| 227 | |||
| 228 | |||
| 229 | /** |
||
| 230 | * create and cache the CommandBus, and also add middleware |
||
| 231 | * The CapChecker middleware requires the use of EE_Capabilities |
||
| 232 | * which is why we need to load the CommandBus after Caps are set up |
||
| 233 | * |
||
| 234 | * @return void |
||
| 235 | * @throws EE_Error |
||
| 236 | */ |
||
| 237 | public function loadCommandBus() |
||
| 238 | { |
||
| 239 | $this->registry->create( |
||
| 240 | 'CommandBusInterface', |
||
| 241 | array( |
||
| 242 | null, |
||
| 243 | apply_filters( |
||
| 244 | 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
||
| 245 | array( |
||
| 246 | $this->registry->create('CapChecker'), |
||
| 247 | $this->registry->create('AddActionHook'), |
||
| 248 | ) |
||
| 249 | ), |
||
| 250 | ), |
||
| 251 | true |
||
| 252 | ); |
||
| 253 | } |
||
| 254 | |||
| 255 | |||
| 256 | |||
| 257 | /** |
||
| 258 | * @return void |
||
| 259 | * @throws EE_Error |
||
| 260 | */ |
||
| 261 | public function loadPluginApi() |
||
| 262 | { |
||
| 263 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
||
| 264 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
||
| 265 | EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
||
| 266 | } |
||
| 267 | |||
| 268 | |||
| 269 | |||
| 270 | /** |
||
| 271 | * load_espresso_addons |
||
| 272 | * allow addons to load first so that they can set hooks for running DMS's, etc |
||
| 273 | * this is hooked into both: |
||
| 274 | * 'AHEE__EE_Bootstrap__load_core_configuration' |
||
| 275 | * which runs during the WP 'plugins_loaded' action at priority 5 |
||
| 276 | * and the WP 'activate_plugin' hook point |
||
| 277 | * |
||
| 278 | * @access public |
||
| 279 | * @return void |
||
| 280 | * @throws EE_Error |
||
| 281 | */ |
||
| 282 | public function load_espresso_addons() |
||
| 283 | { |
||
| 284 | do_action('AHEE__EE_System__load_espresso_addons'); |
||
| 285 | //if the WP API basic auth plugin isn't already loaded, load it now. |
||
| 286 | //We want it for mobile apps. Just include the entire plugin |
||
| 287 | //also, don't load the basic auth when a plugin is getting activated, because |
||
| 288 | //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
||
| 289 | //and causes a fatal error |
||
| 290 | if ( |
||
| 291 | ! (isset($_GET['activate']) && $_GET['activate'] === 'true') |
||
| 292 | && ! function_exists('json_basic_auth_handler') |
||
| 293 | && ! function_exists('json_basic_auth_error') |
||
| 294 | && ! ( |
||
| 295 | isset($_GET['action']) |
||
| 296 | && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
||
| 297 | ) |
||
| 298 | ) { |
||
| 299 | include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
||
| 300 | } |
||
| 301 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
||
| 302 | } |
||
| 303 | |||
| 304 | |||
| 305 | |||
| 306 | /** |
||
| 307 | * detect_activations_or_upgrades |
||
| 308 | * Checks for activation or upgrade of core first; |
||
| 309 | * then also checks if any registered addons have been activated or upgraded |
||
| 310 | * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
||
| 311 | * which runs during the WP 'plugins_loaded' action at priority 3 |
||
| 312 | * |
||
| 313 | * @access public |
||
| 314 | * @return void |
||
| 315 | */ |
||
| 316 | public function detect_activations_or_upgrades() |
||
| 325 | |||
| 326 | |||
| 327 | |||
| 328 | /** |
||
| 329 | * detect_if_activation_or_upgrade |
||
| 330 | * Takes care of detecting whether this is a brand new install or code upgrade, |
||
| 331 | * and either setting up the DB or setting up maintenance mode etc. |
||
| 332 | * |
||
| 333 | * @access public |
||
| 334 | * @return void |
||
| 335 | */ |
||
| 336 | public function detect_if_activation_or_upgrade() |
||
| 374 | |||
| 375 | |||
| 376 | |||
| 377 | /** |
||
| 378 | * Updates the list of installed versions and sets hooks for |
||
| 379 | * initializing the database later during the request |
||
| 380 | * |
||
| 381 | * @param array $espresso_db_update |
||
| 382 | */ |
||
| 383 | protected function _handle_core_version_change($espresso_db_update) |
||
| 390 | |||
| 391 | |||
| 392 | |||
| 393 | /** |
||
| 394 | * standardizes the wp option 'espresso_db_upgrade' which actually stores |
||
| 395 | * information about what versions of EE have been installed and activated, |
||
| 396 | * NOT necessarily the state of the database |
||
| 397 | * |
||
| 398 | * @param mixed $espresso_db_update the value of the WordPress option. |
||
| 399 | * If not supplied, fetches it from the options table |
||
| 400 | * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
||
| 401 | */ |
||
| 402 | private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
||
| 403 | { |
||
| 404 | do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
||
| 405 | if ( ! $espresso_db_update) { |
||
| 406 | $espresso_db_update = get_option('espresso_db_update'); |
||
| 407 | } |
||
| 408 | // check that option is an array |
||
| 409 | if ( ! is_array($espresso_db_update)) { |
||
| 410 | // if option is FALSE, then it never existed |
||
| 411 | if ($espresso_db_update === false) { |
||
| 412 | // make $espresso_db_update an array and save option with autoload OFF |
||
| 413 | $espresso_db_update = array(); |
||
| 414 | add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
||
| 415 | } else { |
||
| 416 | // option is NOT FALSE but also is NOT an array, so make it an array and save it |
||
| 417 | $espresso_db_update = array($espresso_db_update => array()); |
||
| 418 | update_option('espresso_db_update', $espresso_db_update); |
||
| 419 | } |
||
| 420 | } else { |
||
| 421 | $corrected_db_update = array(); |
||
| 422 | //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
||
| 423 | foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
||
| 424 | if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
||
| 425 | //the key is an int, and the value IS NOT an array |
||
| 426 | //so it must be numerically-indexed, where values are versions installed... |
||
| 427 | //fix it! |
||
| 428 | $version_string = $should_be_array; |
||
| 429 | $corrected_db_update[$version_string] = array('unknown-date'); |
||
| 430 | } else { |
||
| 431 | //ok it checks out |
||
| 432 | $corrected_db_update[$should_be_version_string] = $should_be_array; |
||
| 433 | } |
||
| 434 | } |
||
| 435 | $espresso_db_update = $corrected_db_update; |
||
| 436 | update_option('espresso_db_update', $espresso_db_update); |
||
| 437 | } |
||
| 438 | do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
||
| 439 | return $espresso_db_update; |
||
| 440 | } |
||
| 441 | |||
| 442 | |||
| 443 | |||
| 444 | /** |
||
| 445 | * Does the traditional work of setting up the plugin's database and adding default data. |
||
| 446 | * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
||
| 447 | * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
||
| 448 | * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
||
| 449 | * so that it will be done when migrations are finished |
||
| 450 | * |
||
| 451 | * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
||
| 452 | * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
||
| 453 | * This is a resource-intensive job |
||
| 454 | * so we prefer to only do it when necessary |
||
| 455 | * @return void |
||
| 456 | * @throws EE_Error |
||
| 457 | */ |
||
| 458 | public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
||
| 485 | |||
| 486 | |||
| 487 | |||
| 488 | /** |
||
| 489 | * Initializes the db for all registered addons |
||
| 490 | * |
||
| 491 | * @throws EE_Error |
||
| 492 | */ |
||
| 493 | public function initialize_addons() |
||
| 500 | |||
| 501 | |||
| 502 | |||
| 503 | /** |
||
| 504 | * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
||
| 505 | * |
||
| 506 | * @param array $version_history |
||
| 507 | * @param string $current_version_to_add version to be added to the version history |
||
| 508 | * @return boolean success as to whether or not this option was changed |
||
| 509 | */ |
||
| 510 | public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
||
| 522 | |||
| 523 | |||
| 524 | |||
| 525 | /** |
||
| 526 | * Detects if the current version indicated in the has existed in the list of |
||
| 527 | * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
||
| 528 | * |
||
| 529 | * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
||
| 530 | * If not supplied, fetches it from the options table. |
||
| 531 | * Also, caches its result so later parts of the code can also know whether |
||
| 532 | * there's been an update or not. This way we can add the current version to |
||
| 533 | * espresso_db_update, but still know if this is a new install or not |
||
| 534 | * @return int one of the constants on EE_System::req_type_ |
||
| 535 | */ |
||
| 536 | public function detect_req_type($espresso_db_update = null) |
||
| 547 | |||
| 548 | |||
| 549 | |||
| 550 | /** |
||
| 551 | * Returns whether or not there was a non-micro version change (ie, change in either |
||
| 552 | * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
||
| 553 | * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
||
| 554 | * |
||
| 555 | * @param $activation_history |
||
| 556 | * @return bool |
||
| 557 | */ |
||
| 558 | protected function _detect_major_version_change($activation_history) |
||
| 568 | |||
| 569 | |||
| 570 | |||
| 571 | /** |
||
| 572 | * Returns true if either the major or minor version of EE changed during this request. |
||
| 573 | * 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 |
||
| 574 | * |
||
| 575 | * @return bool |
||
| 576 | */ |
||
| 577 | public function is_major_version_change() |
||
| 581 | |||
| 582 | |||
| 583 | |||
| 584 | /** |
||
| 585 | * Determines the request type for any ee addon, given three piece of info: the current array of activation |
||
| 586 | * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
||
| 587 | * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
||
| 588 | * just activated to (for core that will always be espresso_version()) |
||
| 589 | * |
||
| 590 | * @param array $activation_history_for_addon the option's value which stores the activation history for this |
||
| 591 | * ee plugin. for core that's 'espresso_db_update' |
||
| 592 | * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
||
| 593 | * indicate that this plugin was just activated |
||
| 594 | * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
||
| 595 | * espresso_version()) |
||
| 596 | * @return int one of the constants on EE_System::req_type_* |
||
| 597 | */ |
||
| 598 | public static function detect_req_type_given_activation_history( |
||
| 646 | |||
| 647 | |||
| 648 | |||
| 649 | /** |
||
| 650 | * Detects if the $version_to_upgrade_to is higher than the most recent version in |
||
| 651 | * the $activation_history_for_addon |
||
| 652 | * |
||
| 653 | * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
||
| 654 | * sometimes containing 'unknown-date' |
||
| 655 | * @param string $version_to_upgrade_to (current version) |
||
| 656 | * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
||
| 657 | * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
||
| 658 | * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
||
| 659 | * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
||
| 660 | */ |
||
| 661 | protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
||
| 667 | |||
| 668 | |||
| 669 | |||
| 670 | /** |
||
| 671 | * Gets the most recently active version listed in the activation history, |
||
| 672 | * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
||
| 673 | * |
||
| 674 | * @param array $activation_history (keys are versions, values are arrays of times activated, |
||
| 675 | * sometimes containing 'unknown-date' |
||
| 676 | * @return string |
||
| 677 | */ |
||
| 678 | protected static function _get_most_recently_active_version_from_activation_history($activation_history) |
||
| 703 | |||
| 704 | |||
| 705 | |||
| 706 | /** |
||
| 707 | * This redirects to the about EE page after activation |
||
| 708 | * |
||
| 709 | * @return void |
||
| 710 | */ |
||
| 711 | public function redirect_to_about_ee() |
||
| 736 | |||
| 737 | |||
| 738 | |||
| 739 | /** |
||
| 740 | * load_core_configuration |
||
| 741 | * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
||
| 742 | * which runs during the WP 'plugins_loaded' action at priority 5 |
||
| 743 | * |
||
| 744 | * @return void |
||
| 745 | * @throws \ReflectionException |
||
| 746 | */ |
||
| 747 | public function load_core_configuration() |
||
| 773 | |||
| 774 | |||
| 775 | |||
| 776 | /** |
||
| 777 | * cycles through all of the models/*.model.php files, and assembles an array of model names |
||
| 778 | * |
||
| 779 | * @return void |
||
| 780 | * @throws ReflectionException |
||
| 781 | */ |
||
| 782 | private function _parse_model_names() |
||
| 802 | |||
| 803 | |||
| 804 | |||
| 805 | /** |
||
| 806 | * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
||
| 807 | * that need to be setup before our EE_System launches. |
||
| 808 | * |
||
| 809 | * @return void |
||
| 810 | */ |
||
| 811 | private function _maybe_brew_regular() |
||
| 817 | |||
| 818 | |||
| 819 | |||
| 820 | /** |
||
| 821 | * register_shortcodes_modules_and_widgets |
||
| 822 | * generate lists of shortcodes and modules, then verify paths and classes |
||
| 823 | * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
||
| 824 | * which runs during the WP 'plugins_loaded' action at priority 7 |
||
| 825 | * |
||
| 826 | * @access public |
||
| 827 | * @return void |
||
| 828 | */ |
||
| 829 | public function register_shortcodes_modules_and_widgets() |
||
| 849 | |||
| 850 | |||
| 851 | |||
| 852 | /** |
||
| 853 | * _incompatible_addon_error |
||
| 854 | * |
||
| 855 | * @access public |
||
| 856 | * @return void |
||
| 857 | */ |
||
| 858 | private function _incompatible_addon_error() |
||
| 880 | |||
| 881 | |||
| 882 | |||
| 883 | /** |
||
| 884 | * brew_espresso |
||
| 885 | * begins the process of setting hooks for initializing EE in the correct order |
||
| 886 | * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
||
| 887 | * which runs during the WP 'plugins_loaded' action at priority 9 |
||
| 888 | * |
||
| 889 | * @return void |
||
| 890 | */ |
||
| 891 | public function brew_espresso() |
||
| 910 | |||
| 911 | |||
| 912 | |||
| 913 | /** |
||
| 914 | * set_hooks_for_core |
||
| 915 | * |
||
| 916 | * @access public |
||
| 917 | * @return void |
||
| 918 | * @throws EE_Error |
||
| 919 | */ |
||
| 920 | public function set_hooks_for_core() |
||
| 928 | |||
| 929 | |||
| 930 | |||
| 931 | /** |
||
| 932 | * Using the information gathered in EE_System::_incompatible_addon_error, |
||
| 933 | * deactivates any addons considered incompatible with the current version of EE |
||
| 934 | */ |
||
| 935 | private function _deactivate_incompatible_addons() |
||
| 950 | |||
| 951 | |||
| 952 | |||
| 953 | /** |
||
| 954 | * perform_activations_upgrades_and_migrations |
||
| 955 | * |
||
| 956 | * @access public |
||
| 957 | * @return void |
||
| 958 | */ |
||
| 959 | public function perform_activations_upgrades_and_migrations() |
||
| 967 | |||
| 968 | |||
| 969 | |||
| 970 | /** |
||
| 971 | * load_CPTs_and_session |
||
| 972 | * |
||
| 973 | * @access public |
||
| 974 | * @return void |
||
| 975 | */ |
||
| 976 | public function load_CPTs_and_session() |
||
| 983 | |||
| 984 | |||
| 985 | |||
| 986 | /** |
||
| 987 | * load_controllers |
||
| 988 | * this is the best place to load any additional controllers that needs access to EE core. |
||
| 989 | * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
||
| 990 | * time |
||
| 991 | * |
||
| 992 | * @access public |
||
| 993 | * @return void |
||
| 994 | */ |
||
| 995 | public function load_controllers() |
||
| 1008 | |||
| 1009 | |||
| 1010 | |||
| 1011 | /** |
||
| 1012 | * core_loaded_and_ready |
||
| 1013 | * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
||
| 1014 | * |
||
| 1015 | * @access public |
||
| 1016 | * @return void |
||
| 1017 | */ |
||
| 1018 | public function core_loaded_and_ready() |
||
| 1029 | |||
| 1030 | |||
| 1031 | |||
| 1032 | /** |
||
| 1033 | * initialize |
||
| 1034 | * this is the best place to begin initializing client code |
||
| 1035 | * |
||
| 1036 | * @access public |
||
| 1037 | * @return void |
||
| 1038 | */ |
||
| 1039 | public function initialize() |
||
| 1043 | |||
| 1044 | |||
| 1045 | |||
| 1046 | /** |
||
| 1047 | * initialize_last |
||
| 1048 | * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
||
| 1049 | * initialize has done so |
||
| 1050 | * |
||
| 1051 | * @access public |
||
| 1052 | * @return void |
||
| 1053 | */ |
||
| 1054 | public function initialize_last() |
||
| 1058 | |||
| 1059 | |||
| 1060 | |||
| 1061 | /** |
||
| 1062 | * set_hooks_for_shortcodes_modules_and_addons |
||
| 1063 | * this is the best place for other systems to set callbacks for hooking into other parts of EE |
||
| 1064 | * this happens at the very beginning of the wp_loaded hook point |
||
| 1065 | * |
||
| 1066 | * @access public |
||
| 1067 | * @return void |
||
| 1068 | */ |
||
| 1069 | public function set_hooks_for_shortcodes_modules_and_addons() |
||
| 1073 | |||
| 1074 | |||
| 1075 | |||
| 1076 | /** |
||
| 1077 | * do_not_cache |
||
| 1078 | * sets no cache headers and defines no cache constants for WP plugins |
||
| 1079 | * |
||
| 1080 | * @access public |
||
| 1081 | * @return void |
||
| 1082 | */ |
||
| 1083 | public static function do_not_cache() |
||
| 1102 | |||
| 1103 | |||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * extra_nocache_headers |
||
| 1107 | * |
||
| 1108 | * @access public |
||
| 1109 | * @param $headers |
||
| 1110 | * @return array |
||
| 1111 | */ |
||
| 1112 | public static function extra_nocache_headers($headers) |
||
| 1120 | |||
| 1121 | |||
| 1122 | |||
| 1123 | /** |
||
| 1124 | * nocache_headers |
||
| 1125 | * |
||
| 1126 | * @access public |
||
| 1127 | * @return void |
||
| 1128 | */ |
||
| 1129 | public static function nocache_headers() |
||
| 1133 | |||
| 1134 | |||
| 1135 | |||
| 1136 | /** |
||
| 1137 | * espresso_toolbar_items |
||
| 1138 | * |
||
| 1139 | * @access public |
||
| 1140 | * @param WP_Admin_Bar $admin_bar |
||
| 1141 | * @return void |
||
| 1142 | */ |
||
| 1143 | public function espresso_toolbar_items(WP_Admin_Bar $admin_bar) |
||
| 1513 | |||
| 1514 | |||
| 1515 | |||
| 1516 | /** |
||
| 1517 | * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
||
| 1518 | * never returned with the function. |
||
| 1519 | * |
||
| 1520 | * @param array $exclude_array any existing pages being excluded are in this array. |
||
| 1521 | * @return array |
||
| 1522 | */ |
||
| 1523 | public function remove_pages_from_wp_list_pages($exclude_array) |
||
| 1527 | |||
| 1528 | |||
| 1529 | |||
| 1530 | |||
| 1531 | } |
||
| 1532 | // End of file EE_System.core.php |
||
| 1534 |
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):