@@ -22,119 +22,119 @@ |
||
| 22 | 22 | class CachingLoader extends LoaderDecorator |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @var CollectionInterface $cache |
|
| 27 | - */ |
|
| 28 | - protected $cache; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * @var string $identifier |
|
| 32 | - */ |
|
| 33 | - protected $identifier; |
|
| 34 | - |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * CachingLoader constructor. |
|
| 39 | - * |
|
| 40 | - * @param LoaderDecoratorInterface $loader |
|
| 41 | - * @param CollectionInterface $cache |
|
| 42 | - * @param string $identifier |
|
| 43 | - * @throws InvalidDataTypeException |
|
| 44 | - */ |
|
| 45 | - public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '') |
|
| 46 | - { |
|
| 47 | - parent::__construct($loader); |
|
| 48 | - $this->cache = $cache; |
|
| 49 | - $this->setIdentifier($identifier); |
|
| 50 | - if ($this->identifier !== '') { |
|
| 51 | - // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
| 52 | - // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER'); |
|
| 53 | - // where "IDENTIFIER" = the string that was set during construction |
|
| 54 | - add_action( |
|
| 55 | - "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}", |
|
| 56 | - array($this, 'reset') |
|
| 57 | - ); |
|
| 58 | - } |
|
| 59 | - // to clear ALL caches, simply do the following: |
|
| 60 | - // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache'); |
|
| 61 | - add_action( |
|
| 62 | - 'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache', |
|
| 63 | - array($this, 'reset') |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @return string |
|
| 71 | - */ |
|
| 72 | - public function identifier() |
|
| 73 | - { |
|
| 74 | - return $this->identifier; |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @param string $identifier |
|
| 81 | - * @throws InvalidDataTypeException |
|
| 82 | - */ |
|
| 83 | - private function setIdentifier($identifier) |
|
| 84 | - { |
|
| 85 | - if ( ! is_string($identifier)) { |
|
| 86 | - throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
| 87 | - } |
|
| 88 | - $this->identifier = $identifier; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @param string $fqcn |
|
| 95 | - * @param array $arguments |
|
| 96 | - * @param bool $shared |
|
| 97 | - * @return mixed |
|
| 98 | - * @throws InvalidEntityException |
|
| 99 | - * @throws ServiceNotFoundException |
|
| 100 | - */ |
|
| 101 | - public function load($fqcn, $arguments = array(), $shared = true) |
|
| 102 | - { |
|
| 103 | - $fqcn = ltrim($fqcn, '\\'); |
|
| 104 | - // caching can be turned off via the following code: |
|
| 105 | - // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
|
| 106 | - if( |
|
| 107 | - apply_filters( |
|
| 108 | - 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
|
| 109 | - false, |
|
| 110 | - $this |
|
| 111 | - ) |
|
| 112 | - ){ |
|
| 113 | - // even though $shared might be true, caching should be bypassed for whatever reason, |
|
| 114 | - // so we don't want the core loader to cache anything, therefore caching is turned off |
|
| 115 | - return $this->loader->load($fqcn, $arguments, false); |
|
| 116 | - } |
|
| 117 | - $identifier = md5($fqcn . serialize($arguments)); |
|
| 118 | - if($this->cache->has($identifier)){ |
|
| 119 | - return $this->cache->get($identifier); |
|
| 120 | - } |
|
| 121 | - $object = $this->loader->load($fqcn, $arguments, $shared); |
|
| 122 | - if($object instanceof $fqcn) { |
|
| 123 | - $this->cache->add($object, $identifier); |
|
| 124 | - } |
|
| 125 | - return $object; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - /** |
|
| 131 | - * empties cache and calls reset() on loader if method exists |
|
| 132 | - */ |
|
| 133 | - public function reset() |
|
| 134 | - { |
|
| 135 | - $this->cache->detachAll(); |
|
| 136 | - $this->loader->reset(); |
|
| 137 | - } |
|
| 25 | + /** |
|
| 26 | + * @var CollectionInterface $cache |
|
| 27 | + */ |
|
| 28 | + protected $cache; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * @var string $identifier |
|
| 32 | + */ |
|
| 33 | + protected $identifier; |
|
| 34 | + |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * CachingLoader constructor. |
|
| 39 | + * |
|
| 40 | + * @param LoaderDecoratorInterface $loader |
|
| 41 | + * @param CollectionInterface $cache |
|
| 42 | + * @param string $identifier |
|
| 43 | + * @throws InvalidDataTypeException |
|
| 44 | + */ |
|
| 45 | + public function __construct(LoaderDecoratorInterface $loader, CollectionInterface $cache, $identifier = '') |
|
| 46 | + { |
|
| 47 | + parent::__construct($loader); |
|
| 48 | + $this->cache = $cache; |
|
| 49 | + $this->setIdentifier($identifier); |
|
| 50 | + if ($this->identifier !== '') { |
|
| 51 | + // to only clear this cache, and assuming an identifier has been set, simply do the following: |
|
| 52 | + // do_action('AHEE__EventEspresso\core\services\loaders\CachingLoader__resetCache__IDENTIFIER'); |
|
| 53 | + // where "IDENTIFIER" = the string that was set during construction |
|
| 54 | + add_action( |
|
| 55 | + "AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache__{$identifier}", |
|
| 56 | + array($this, 'reset') |
|
| 57 | + ); |
|
| 58 | + } |
|
| 59 | + // to clear ALL caches, simply do the following: |
|
| 60 | + // do_action('AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache'); |
|
| 61 | + add_action( |
|
| 62 | + 'AHEE__EventEspresso_core_services_loaders_CachingLoader__resetCache', |
|
| 63 | + array($this, 'reset') |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @return string |
|
| 71 | + */ |
|
| 72 | + public function identifier() |
|
| 73 | + { |
|
| 74 | + return $this->identifier; |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @param string $identifier |
|
| 81 | + * @throws InvalidDataTypeException |
|
| 82 | + */ |
|
| 83 | + private function setIdentifier($identifier) |
|
| 84 | + { |
|
| 85 | + if ( ! is_string($identifier)) { |
|
| 86 | + throw new InvalidDataTypeException('$identifier', $identifier, 'string'); |
|
| 87 | + } |
|
| 88 | + $this->identifier = $identifier; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @param string $fqcn |
|
| 95 | + * @param array $arguments |
|
| 96 | + * @param bool $shared |
|
| 97 | + * @return mixed |
|
| 98 | + * @throws InvalidEntityException |
|
| 99 | + * @throws ServiceNotFoundException |
|
| 100 | + */ |
|
| 101 | + public function load($fqcn, $arguments = array(), $shared = true) |
|
| 102 | + { |
|
| 103 | + $fqcn = ltrim($fqcn, '\\'); |
|
| 104 | + // caching can be turned off via the following code: |
|
| 105 | + // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
|
| 106 | + if( |
|
| 107 | + apply_filters( |
|
| 108 | + 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
|
| 109 | + false, |
|
| 110 | + $this |
|
| 111 | + ) |
|
| 112 | + ){ |
|
| 113 | + // even though $shared might be true, caching should be bypassed for whatever reason, |
|
| 114 | + // so we don't want the core loader to cache anything, therefore caching is turned off |
|
| 115 | + return $this->loader->load($fqcn, $arguments, false); |
|
| 116 | + } |
|
| 117 | + $identifier = md5($fqcn . serialize($arguments)); |
|
| 118 | + if($this->cache->has($identifier)){ |
|
| 119 | + return $this->cache->get($identifier); |
|
| 120 | + } |
|
| 121 | + $object = $this->loader->load($fqcn, $arguments, $shared); |
|
| 122 | + if($object instanceof $fqcn) { |
|
| 123 | + $this->cache->add($object, $identifier); |
|
| 124 | + } |
|
| 125 | + return $object; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + /** |
|
| 131 | + * empties cache and calls reset() on loader if method exists |
|
| 132 | + */ |
|
| 133 | + public function reset() |
|
| 134 | + { |
|
| 135 | + $this->cache->detachAll(); |
|
| 136 | + $this->loader->reset(); |
|
| 137 | + } |
|
| 138 | 138 | |
| 139 | 139 | |
| 140 | 140 | } |
@@ -103,23 +103,23 @@ |
||
| 103 | 103 | $fqcn = ltrim($fqcn, '\\'); |
| 104 | 104 | // caching can be turned off via the following code: |
| 105 | 105 | // add_filter('FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', '__return_true'); |
| 106 | - if( |
|
| 106 | + if ( |
|
| 107 | 107 | apply_filters( |
| 108 | 108 | 'FHEE__EventEspresso_core_services_loaders_CachingLoader__load__bypass_cache', |
| 109 | 109 | false, |
| 110 | 110 | $this |
| 111 | 111 | ) |
| 112 | - ){ |
|
| 112 | + ) { |
|
| 113 | 113 | // even though $shared might be true, caching should be bypassed for whatever reason, |
| 114 | 114 | // so we don't want the core loader to cache anything, therefore caching is turned off |
| 115 | 115 | return $this->loader->load($fqcn, $arguments, false); |
| 116 | 116 | } |
| 117 | - $identifier = md5($fqcn . serialize($arguments)); |
|
| 118 | - if($this->cache->has($identifier)){ |
|
| 117 | + $identifier = md5($fqcn.serialize($arguments)); |
|
| 118 | + if ($this->cache->has($identifier)) { |
|
| 119 | 119 | return $this->cache->get($identifier); |
| 120 | 120 | } |
| 121 | 121 | $object = $this->loader->load($fqcn, $arguments, $shared); |
| 122 | - if($object instanceof $fqcn) { |
|
| 122 | + if ($object instanceof $fqcn) { |
|
| 123 | 123 | $this->cache->add($object, $identifier); |
| 124 | 124 | } |
| 125 | 125 | return $object; |
@@ -31,899 +31,899 @@ |
||
| 31 | 31 | { |
| 32 | 32 | |
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @deprecated 4.9.40 |
|
| 36 | - * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 37 | - */ |
|
| 38 | - const req_type_normal = 0; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * @deprecated 4.9.40 |
|
| 42 | - * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 43 | - */ |
|
| 44 | - const req_type_new_activation = 1; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @deprecated 4.9.40 |
|
| 48 | - * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 49 | - */ |
|
| 50 | - const req_type_reactivation = 2; |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @deprecated 4.9.40 |
|
| 54 | - * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 55 | - */ |
|
| 56 | - const req_type_upgrade = 3; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @deprecated 4.9.40 |
|
| 60 | - * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 61 | - */ |
|
| 62 | - const req_type_downgrade = 4; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @deprecated since version 4.6.0.dev.006 |
|
| 66 | - * Now whenever a new_activation is detected the request type is still just |
|
| 67 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
| 68 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
| 69 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
| 70 | - * (Specifically, when the migration manager indicates migrations are finished |
|
| 71 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
| 72 | - */ |
|
| 73 | - const req_type_activation_but_not_installed = 5; |
|
| 74 | - |
|
| 75 | - /** |
|
| 76 | - * @deprecated 4.9.40 |
|
| 77 | - * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 78 | - */ |
|
| 79 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * @var EE_System $_instance |
|
| 84 | - */ |
|
| 85 | - private static $_instance; |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @var EE_Registry $registry |
|
| 89 | - */ |
|
| 90 | - private $registry; |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @var LoaderInterface $loader |
|
| 94 | - */ |
|
| 95 | - private $loader; |
|
| 96 | - |
|
| 97 | - /** |
|
| 98 | - * @var EE_Capabilities $capabilities |
|
| 99 | - */ |
|
| 100 | - private $capabilities; |
|
| 101 | - |
|
| 102 | - /** |
|
| 103 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
| 104 | - */ |
|
| 105 | - private $maintenance_mode; |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @var ActivationsAndUpgradesManager $activations_and_upgrades_manager |
|
| 109 | - */ |
|
| 110 | - private $activations_and_upgrades_manager; |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * @var ActivationHistory $activation_history |
|
| 114 | - */ |
|
| 115 | - private $activation_history; |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @var \EventEspresso\core\services\activation\RequestType $request_type |
|
| 119 | - */ |
|
| 120 | - private $request_type; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @var bool $activation_detected |
|
| 124 | - */ |
|
| 125 | - private $activation_detected = false; |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @singleton method used to instantiate class object |
|
| 131 | - * @param EE_Registry|null $registry |
|
| 132 | - * @param LoaderInterface|null $loader |
|
| 133 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
| 134 | - * @return EE_System |
|
| 135 | - */ |
|
| 136 | - public static function instance( |
|
| 137 | - EE_Registry $registry = null, |
|
| 138 | - LoaderInterface $loader = null, |
|
| 139 | - EE_Maintenance_Mode $maintenance_mode = null |
|
| 140 | - ) { |
|
| 141 | - // check if class object is instantiated |
|
| 142 | - if (! self::$_instance instanceof EE_System) { |
|
| 143 | - self::$_instance = new self( |
|
| 144 | - $registry, |
|
| 145 | - $loader, |
|
| 146 | - $maintenance_mode |
|
| 147 | - ); |
|
| 148 | - } |
|
| 149 | - return self::$_instance; |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * resets the instance and returns it |
|
| 156 | - * |
|
| 157 | - * @return EE_System |
|
| 158 | - * @throws InvalidInterfaceException |
|
| 159 | - * @throws InvalidDataTypeException |
|
| 160 | - * @throws DomainException |
|
| 161 | - * @throws InvalidArgumentException |
|
| 162 | - * @throws InvalidEntityException |
|
| 163 | - */ |
|
| 164 | - public static function reset() |
|
| 165 | - { |
|
| 166 | - //make sure none of the old hooks are left hanging around |
|
| 167 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 168 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
| 169 | - EE_Data_Migration_Manager::reset(); |
|
| 170 | - self::instance()->detect_activations_or_upgrades(); |
|
| 171 | - self::instance()->activations_and_upgrades_manager->performActivationsAndUpgrades(); |
|
| 172 | - return self::instance(); |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * sets hooks for running rest of system |
|
| 179 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 180 | - * starting EE Addons from any other point may lead to problems |
|
| 181 | - * |
|
| 182 | - * @param EE_Registry $registry |
|
| 183 | - * @param LoaderInterface $loader |
|
| 184 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
| 185 | - */ |
|
| 186 | - private function __construct( |
|
| 187 | - EE_Registry $registry, |
|
| 188 | - LoaderInterface $loader, |
|
| 189 | - EE_Maintenance_Mode $maintenance_mode |
|
| 190 | - ) { |
|
| 191 | - $this->registry = $registry; |
|
| 192 | - $this->loader = $loader; |
|
| 193 | - $this->maintenance_mode = $maintenance_mode; |
|
| 194 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
| 195 | - add_action( |
|
| 196 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 197 | - array($this, 'loadCapabilities'), |
|
| 198 | - 5 |
|
| 199 | - ); |
|
| 200 | - add_action( |
|
| 201 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 202 | - array($this, 'loadCommandBus'), |
|
| 203 | - 7 |
|
| 204 | - ); |
|
| 205 | - add_action( |
|
| 206 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 207 | - array($this, 'loadPluginApi'), |
|
| 208 | - 9 |
|
| 209 | - ); |
|
| 210 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
| 211 | - add_action( |
|
| 212 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 213 | - array($this, 'load_espresso_addons') |
|
| 214 | - ); |
|
| 215 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
| 216 | - // because the newly-activated addon didn't get a chance to run at all |
|
| 217 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
| 218 | - // detect whether install or upgrade |
|
| 219 | - add_action( |
|
| 220 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
| 221 | - array($this, 'detect_activations_or_upgrades'), |
|
| 222 | - 3 |
|
| 223 | - ); |
|
| 224 | - // load EE_Config, EE_Textdomain, etc |
|
| 225 | - add_action( |
|
| 226 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 227 | - array($this, 'load_core_configuration'), |
|
| 228 | - 5 |
|
| 229 | - ); |
|
| 230 | - // load EE_Config, EE_Textdomain, etc |
|
| 231 | - add_action( |
|
| 232 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
| 233 | - array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 234 | - 7 |
|
| 235 | - ); |
|
| 236 | - // you wanna get going? I wanna get going... let's get going! |
|
| 237 | - add_action( |
|
| 238 | - 'AHEE__EE_Bootstrap__brew_espresso', |
|
| 239 | - array($this, 'brew_espresso'), |
|
| 240 | - 9 |
|
| 241 | - ); |
|
| 242 | - //other housekeeping |
|
| 243 | - //exclude EE critical pages from wp_list_pages |
|
| 244 | - add_filter( |
|
| 245 | - 'wp_list_pages_excludes', |
|
| 246 | - array($this, 'remove_pages_from_wp_list_pages'), |
|
| 247 | - 10 |
|
| 248 | - ); |
|
| 249 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
| 250 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
| 251 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
| 252 | - } |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * load and setup EE_Capabilities |
|
| 258 | - * |
|
| 259 | - * @return void |
|
| 260 | - * @throws InvalidArgumentException |
|
| 261 | - * @throws InvalidInterfaceException |
|
| 262 | - * @throws InvalidDataTypeException |
|
| 263 | - * @throws EE_Error |
|
| 264 | - */ |
|
| 265 | - public function loadCapabilities() |
|
| 266 | - { |
|
| 267 | - $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
| 268 | - add_action( |
|
| 269 | - 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
| 270 | - function() { |
|
| 271 | - LoaderFactory::getLoader()->getShared('Payment_Method_Manager'); |
|
| 272 | - } |
|
| 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 | - * @throws EE_Error |
|
| 285 | - */ |
|
| 286 | - public function loadCommandBus() |
|
| 287 | - { |
|
| 288 | - $this->loader->getShared( |
|
| 289 | - 'CommandBusInterface', |
|
| 290 | - array( |
|
| 291 | - null, |
|
| 292 | - apply_filters( |
|
| 293 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 294 | - array( |
|
| 295 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
| 296 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
| 297 | - ) |
|
| 298 | - ), |
|
| 299 | - ) |
|
| 300 | - ); |
|
| 301 | - } |
|
| 302 | - |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * @return void |
|
| 307 | - * @throws EE_Error |
|
| 308 | - */ |
|
| 309 | - public function loadPluginApi() |
|
| 310 | - { |
|
| 311 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
| 312 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
| 313 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 314 | - } |
|
| 315 | - |
|
| 316 | - |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * Gets the ActivationHistory object for this addon |
|
| 320 | - * |
|
| 321 | - * @return ActivationHistory |
|
| 322 | - */ |
|
| 323 | - public function getActivationHistory() |
|
| 324 | - { |
|
| 325 | - return $this->activation_history; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * @param ActivationHistory $activation_history |
|
| 332 | - */ |
|
| 333 | - public function setActivationHistory(ActivationHistory $activation_history) |
|
| 334 | - { |
|
| 335 | - $this->activation_history = $activation_history; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @return RequestType |
|
| 342 | - */ |
|
| 343 | - public function getRequestType() |
|
| 344 | - { |
|
| 345 | - return $this->request_type; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - |
|
| 350 | - /** |
|
| 351 | - * @param RequestType $request_type |
|
| 352 | - */ |
|
| 353 | - public function setRequestType(RequestType $request_type) |
|
| 354 | - { |
|
| 355 | - $this->request_type = $request_type; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * load_espresso_addons |
|
| 360 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
| 361 | - * this is hooked into both: |
|
| 362 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 363 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 364 | - * and the WP 'activate_plugin' hook point |
|
| 365 | - * |
|
| 366 | - * @return void |
|
| 367 | - * @throws EE_Error |
|
| 368 | - */ |
|
| 369 | - public function load_espresso_addons() |
|
| 370 | - { |
|
| 371 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 372 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
| 373 | - //We want it for mobile apps. Just include the entire plugin |
|
| 374 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
| 375 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
| 376 | - //and causes a fatal error |
|
| 377 | - if ( |
|
| 378 | - ! ( |
|
| 379 | - isset($_GET['activate']) |
|
| 380 | - && $_GET['activate'] === 'true' |
|
| 381 | - ) |
|
| 382 | - && ! function_exists('json_basic_auth_handler') |
|
| 383 | - && ! function_exists('json_basic_auth_error') |
|
| 384 | - && ! ( |
|
| 385 | - isset($_GET['action']) |
|
| 386 | - && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
|
| 387 | - ) |
|
| 388 | - ) { |
|
| 389 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
| 390 | - } |
|
| 391 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
| 392 | - } |
|
| 393 | - |
|
| 394 | - |
|
| 395 | - |
|
| 396 | - /** |
|
| 397 | - * detect_activations_or_upgrades |
|
| 398 | - * Checks for activation or upgrade of core first; |
|
| 399 | - * then also checks if any registered addons have been activated or upgraded |
|
| 400 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
| 401 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
| 402 | - * |
|
| 403 | - * @return void |
|
| 404 | - * @throws DomainException |
|
| 405 | - * @throws InvalidArgumentException |
|
| 406 | - * @throws InvalidEntityException |
|
| 407 | - * @throws InvalidInterfaceException |
|
| 408 | - * @throws InvalidDataTypeException |
|
| 409 | - */ |
|
| 410 | - public function detect_activations_or_upgrades() |
|
| 411 | - { |
|
| 412 | - if( |
|
| 413 | - (defined('DOING_AJAX') && DOING_AJAX) |
|
| 414 | - || (defined('REST_REQUEST') && REST_REQUEST) |
|
| 415 | - ) { |
|
| 416 | - return; |
|
| 417 | - } |
|
| 418 | - $this->activations_and_upgrades_manager = ActivationsFactory::getActivationsAndUpgradesManager(); |
|
| 419 | - $this->activation_detected = $this->activations_and_upgrades_manager->detectActivationsAndVersionChanges( |
|
| 420 | - array_merge( |
|
| 421 | - array($this), |
|
| 422 | - get_object_vars($this->registry->addons) |
|
| 423 | - ) |
|
| 424 | - ); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - |
|
| 429 | - /** |
|
| 430 | - * load_core_configuration |
|
| 431 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 432 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 433 | - * |
|
| 434 | - * @return void |
|
| 435 | - * @throws ReflectionException |
|
| 436 | - */ |
|
| 437 | - public function load_core_configuration() |
|
| 438 | - { |
|
| 439 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 440 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
| 441 | - //load textdomain |
|
| 442 | - EE_Load_Textdomain::load_textdomain(); |
|
| 443 | - // load and setup EE_Config and EE_Network_Config |
|
| 444 | - $config = $this->loader->getShared('EE_Config'); |
|
| 445 | - $this->loader->getShared('EE_Network_Config'); |
|
| 446 | - // setup autoloaders |
|
| 447 | - // enable logging? |
|
| 448 | - if ($config->admin->use_full_logging) { |
|
| 449 | - $this->loader->getShared('EE_Log'); |
|
| 450 | - } |
|
| 451 | - // check for activation errors |
|
| 452 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
| 453 | - if ($activation_errors) { |
|
| 454 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 455 | - update_option('ee_plugin_activation_errors', false); |
|
| 456 | - } |
|
| 457 | - // get model names |
|
| 458 | - $this->_parse_model_names(); |
|
| 459 | - //load caf stuff a chance to play during the activation process too. |
|
| 460 | - $this->_maybe_brew_regular(); |
|
| 461 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 462 | - } |
|
| 463 | - |
|
| 464 | - |
|
| 465 | - |
|
| 466 | - /** |
|
| 467 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
| 468 | - * |
|
| 469 | - * @return void |
|
| 470 | - * @throws ReflectionException |
|
| 471 | - */ |
|
| 472 | - private function _parse_model_names() |
|
| 473 | - { |
|
| 474 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
| 475 | - $models = glob(EE_MODELS . '*.model.php'); |
|
| 476 | - $model_names = array(); |
|
| 477 | - $non_abstract_db_models = array(); |
|
| 478 | - foreach ($models as $model) { |
|
| 479 | - // get model classname |
|
| 480 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 481 | - $short_name = str_replace('EEM_', '', $classname); |
|
| 482 | - $reflectionClass = new ReflectionClass($classname); |
|
| 483 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 484 | - $non_abstract_db_models[$short_name] = $classname; |
|
| 485 | - } |
|
| 486 | - $model_names[$short_name] = $classname; |
|
| 487 | - } |
|
| 488 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 489 | - $this->registry->non_abstract_db_models = apply_filters( |
|
| 490 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
| 491 | - $non_abstract_db_models |
|
| 492 | - ); |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - |
|
| 496 | - |
|
| 497 | - /** |
|
| 498 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
| 499 | - * that need to be setup before our EE_System launches. |
|
| 500 | - * |
|
| 501 | - * @return void |
|
| 502 | - */ |
|
| 503 | - private function _maybe_brew_regular() |
|
| 504 | - { |
|
| 505 | - if ( |
|
| 506 | - ! $this->activation_detected |
|
| 507 | - && (! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 508 | - && is_readable(EE_CAFF_PATH . 'brewing_regular.php') |
|
| 509 | - ) { |
|
| 510 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - |
|
| 515 | - |
|
| 516 | - /** |
|
| 517 | - * register_shortcodes_modules_and_widgets |
|
| 518 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
| 519 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
| 520 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
| 521 | - * |
|
| 522 | - * @access public |
|
| 523 | - * @return void |
|
| 524 | - * @throws Exception |
|
| 525 | - */ |
|
| 526 | - public function register_shortcodes_modules_and_widgets() |
|
| 527 | - { |
|
| 528 | - if ($this->activation_detected) { |
|
| 529 | - return; |
|
| 530 | - } |
|
| 531 | - // check for addons using old hook point |
|
| 532 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 533 | - $this->_incompatible_addon_error(); |
|
| 534 | - } |
|
| 535 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 536 | - try { |
|
| 537 | - // load, register, and add shortcodes the new way |
|
| 538 | - new ShortcodesManager( |
|
| 539 | - // and the old way, but we'll put it under control of the new system |
|
| 540 | - EE_Config::getLegacyShortcodesManager() |
|
| 541 | - ); |
|
| 542 | - } catch (Exception $exception) { |
|
| 543 | - new ExceptionStackTraceDisplay($exception); |
|
| 544 | - } |
|
| 545 | - } |
|
| 546 | - |
|
| 547 | - |
|
| 548 | - |
|
| 549 | - /** |
|
| 550 | - * _incompatible_addon_error |
|
| 551 | - * |
|
| 552 | - * @access public |
|
| 553 | - * @return void |
|
| 554 | - */ |
|
| 555 | - private function _incompatible_addon_error() |
|
| 556 | - { |
|
| 557 | - // get array of classes hooking into here |
|
| 558 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
| 559 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
| 560 | - ); |
|
| 561 | - if (! empty($class_names)) { |
|
| 562 | - $msg = __( |
|
| 563 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
| 564 | - 'event_espresso' |
|
| 565 | - ); |
|
| 566 | - $msg .= '<ul>'; |
|
| 567 | - foreach ($class_names as $class_name) { |
|
| 568 | - $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
| 569 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
| 570 | - $class_name |
|
| 571 | - ) . '</b></li>'; |
|
| 572 | - } |
|
| 573 | - $msg .= '</ul>'; |
|
| 574 | - $msg .= __( |
|
| 575 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
| 576 | - 'event_espresso' |
|
| 577 | - ); |
|
| 578 | - // save list of incompatible addons to wp-options for later use |
|
| 579 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 580 | - if (is_admin()) { |
|
| 581 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 582 | - } |
|
| 583 | - } |
|
| 584 | - } |
|
| 585 | - |
|
| 586 | - |
|
| 587 | - |
|
| 588 | - /** |
|
| 589 | - * brew_espresso |
|
| 590 | - * begins the process of setting hooks for initializing EE in the correct order |
|
| 591 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
| 592 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
| 593 | - * |
|
| 594 | - * @return void |
|
| 595 | - */ |
|
| 596 | - public function brew_espresso() |
|
| 597 | - { |
|
| 598 | - if ($this->activation_detected) { |
|
| 599 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
| 600 | - return; |
|
| 601 | - } |
|
| 602 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 603 | - // load some final core systems |
|
| 604 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 605 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 606 | - add_action('init', array($this, 'load_controllers'), 7); |
|
| 607 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 608 | - add_action('init', array($this, 'initialize'), 10); |
|
| 609 | - add_action('init', array($this, 'initialize_last'), 100); |
|
| 610 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 611 | - // pew pew pew |
|
| 612 | - $this->loader->getShared('EE_PUE'); |
|
| 613 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 614 | - } |
|
| 615 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 616 | - } |
|
| 617 | - |
|
| 618 | - |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * set_hooks_for_core |
|
| 622 | - * |
|
| 623 | - * @access public |
|
| 624 | - * @return void |
|
| 625 | - * @throws EE_Error |
|
| 626 | - */ |
|
| 627 | - public function set_hooks_for_core() |
|
| 628 | - { |
|
| 629 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 630 | - //caps need to be initialized on every request so that capability maps are set. |
|
| 631 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
| 632 | - $this->capabilities->init_caps(); |
|
| 633 | - } |
|
| 634 | - |
|
| 635 | - |
|
| 636 | - |
|
| 637 | - /** |
|
| 638 | - * perform_activations_upgrades_and_migrations |
|
| 639 | - * |
|
| 640 | - * @access public |
|
| 641 | - * @return void |
|
| 642 | - */ |
|
| 643 | - public function perform_activations_upgrades_and_migrations() |
|
| 644 | - { |
|
| 645 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - |
|
| 649 | - |
|
| 650 | - /** |
|
| 651 | - * load_CPTs_and_session |
|
| 652 | - * |
|
| 653 | - * @access public |
|
| 654 | - * @return void |
|
| 655 | - */ |
|
| 656 | - public function load_CPTs_and_session() |
|
| 657 | - { |
|
| 658 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 659 | - // register Custom Post Types |
|
| 660 | - $this->loader->getShared('EE_Register_CPTs'); |
|
| 661 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - |
|
| 665 | - |
|
| 666 | - /** |
|
| 667 | - * load_controllers |
|
| 668 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
| 669 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
| 670 | - * time |
|
| 671 | - * |
|
| 672 | - * @access public |
|
| 673 | - * @return void |
|
| 674 | - */ |
|
| 675 | - public function load_controllers() |
|
| 676 | - { |
|
| 677 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
| 678 | - // let's get it started |
|
| 679 | - if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
| 680 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 681 | - $this->loader->getShared('EE_Front_Controller'); |
|
| 682 | - } else if (! EE_FRONT_AJAX) { |
|
| 683 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 684 | - $this->loader->getShared('EE_Admin'); |
|
| 685 | - } |
|
| 686 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * core_loaded_and_ready |
|
| 693 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
| 694 | - * |
|
| 695 | - * @access public |
|
| 696 | - * @return void |
|
| 697 | - */ |
|
| 698 | - public function core_loaded_and_ready() |
|
| 699 | - { |
|
| 700 | - $this->loader->getShared('EE_Session'); |
|
| 701 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 702 | - // load_espresso_template_tags |
|
| 703 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
| 704 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
| 705 | - } |
|
| 706 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 707 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 708 | - } |
|
| 709 | - |
|
| 710 | - |
|
| 711 | - |
|
| 712 | - /** |
|
| 713 | - * initialize |
|
| 714 | - * this is the best place to begin initializing client code |
|
| 715 | - * |
|
| 716 | - * @access public |
|
| 717 | - * @return void |
|
| 718 | - */ |
|
| 719 | - public function initialize() |
|
| 720 | - { |
|
| 721 | - do_action('AHEE__EE_System__initialize'); |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * initialize_last |
|
| 728 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
| 729 | - * initialize has done so |
|
| 730 | - * |
|
| 731 | - * @access public |
|
| 732 | - * @return void |
|
| 733 | - */ |
|
| 734 | - public function initialize_last() |
|
| 735 | - { |
|
| 736 | - do_action('AHEE__EE_System__initialize_last'); |
|
| 737 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
| 738 | - } |
|
| 739 | - |
|
| 740 | - |
|
| 741 | - |
|
| 742 | - /** |
|
| 743 | - * @return void |
|
| 744 | - * @throws EE_Error |
|
| 745 | - */ |
|
| 746 | - public function addEspressoToolbar() |
|
| 747 | - { |
|
| 748 | - $this->loader->getShared( |
|
| 749 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
| 750 | - array($this->capabilities) |
|
| 751 | - ); |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - |
|
| 755 | - |
|
| 756 | - /** |
|
| 757 | - * do_not_cache |
|
| 758 | - * sets no cache headers and defines no cache constants for WP plugins |
|
| 759 | - * |
|
| 760 | - * @access public |
|
| 761 | - * @return void |
|
| 762 | - */ |
|
| 763 | - public static function do_not_cache() |
|
| 764 | - { |
|
| 765 | - // set no cache constants |
|
| 766 | - if (! defined('DONOTCACHEPAGE')) { |
|
| 767 | - define('DONOTCACHEPAGE', true); |
|
| 768 | - } |
|
| 769 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
| 770 | - define('DONOTCACHCEOBJECT', true); |
|
| 771 | - } |
|
| 772 | - if (! defined('DONOTCACHEDB')) { |
|
| 773 | - define('DONOTCACHEDB', true); |
|
| 774 | - } |
|
| 775 | - // add no cache headers |
|
| 776 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 777 | - // plus a little extra for nginx and Google Chrome |
|
| 778 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 779 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
| 780 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 781 | - } |
|
| 782 | - |
|
| 783 | - |
|
| 784 | - |
|
| 785 | - /** |
|
| 786 | - * extra_nocache_headers |
|
| 787 | - * |
|
| 788 | - * @access public |
|
| 789 | - * @param $headers |
|
| 790 | - * @return array |
|
| 791 | - */ |
|
| 792 | - public static function extra_nocache_headers($headers) |
|
| 793 | - { |
|
| 794 | - // for NGINX |
|
| 795 | - $headers['X-Accel-Expires'] = 0; |
|
| 796 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
| 797 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
| 798 | - return $headers; |
|
| 799 | - } |
|
| 800 | - |
|
| 801 | - |
|
| 802 | - |
|
| 803 | - /** |
|
| 804 | - * nocache_headers |
|
| 805 | - * |
|
| 806 | - * @access public |
|
| 807 | - * @return void |
|
| 808 | - */ |
|
| 809 | - public static function nocache_headers() |
|
| 810 | - { |
|
| 811 | - nocache_headers(); |
|
| 812 | - } |
|
| 813 | - |
|
| 814 | - |
|
| 815 | - |
|
| 816 | - |
|
| 817 | - /** |
|
| 818 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
| 819 | - * never returned with the function. |
|
| 820 | - * |
|
| 821 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
| 822 | - * @return array |
|
| 823 | - */ |
|
| 824 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
| 825 | - { |
|
| 826 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 827 | - } |
|
| 828 | - |
|
| 829 | - |
|
| 830 | - |
|
| 831 | - /******************************** DEPRECATED ***************************************/ |
|
| 832 | - |
|
| 833 | - |
|
| 834 | - |
|
| 835 | - /** |
|
| 836 | - * @deprecated 4.9.40 |
|
| 837 | - * @return void |
|
| 838 | - */ |
|
| 839 | - public function detect_if_activation_or_upgrade() |
|
| 840 | - { |
|
| 841 | - } |
|
| 842 | - |
|
| 843 | - |
|
| 844 | - |
|
| 845 | - /** |
|
| 846 | - * @deprecated 4.9.40 |
|
| 847 | - * @param null $version_history |
|
| 848 | - * @param null $current_version_to_add |
|
| 849 | - * @return void |
|
| 850 | - */ |
|
| 851 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 852 | - { |
|
| 853 | - } |
|
| 854 | - |
|
| 855 | - |
|
| 856 | - |
|
| 857 | - /** |
|
| 858 | - * @deprecated 4.9.40 |
|
| 859 | - * @param null $espresso_db_update |
|
| 860 | - * @return int one of the constants on EE_System::req_type_ |
|
| 861 | - */ |
|
| 862 | - public function detect_req_type($espresso_db_update = null) |
|
| 863 | - { |
|
| 864 | - return $this->getRequestType()->getRequestType(); |
|
| 865 | - } |
|
| 866 | - |
|
| 867 | - |
|
| 868 | - |
|
| 869 | - /** |
|
| 870 | - * @deprecated 4.9.40 |
|
| 871 | - * @return bool |
|
| 872 | - */ |
|
| 873 | - public function is_major_version_change() |
|
| 874 | - { |
|
| 875 | - return $this->getRequestType()->isMajorVersionChange(); |
|
| 876 | - } |
|
| 34 | + /** |
|
| 35 | + * @deprecated 4.9.40 |
|
| 36 | + * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 37 | + */ |
|
| 38 | + const req_type_normal = 0; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * @deprecated 4.9.40 |
|
| 42 | + * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 43 | + */ |
|
| 44 | + const req_type_new_activation = 1; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @deprecated 4.9.40 |
|
| 48 | + * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 49 | + */ |
|
| 50 | + const req_type_reactivation = 2; |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @deprecated 4.9.40 |
|
| 54 | + * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 55 | + */ |
|
| 56 | + const req_type_upgrade = 3; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @deprecated 4.9.40 |
|
| 60 | + * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 61 | + */ |
|
| 62 | + const req_type_downgrade = 4; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @deprecated since version 4.6.0.dev.006 |
|
| 66 | + * Now whenever a new_activation is detected the request type is still just |
|
| 67 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
| 68 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
| 69 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
| 70 | + * (Specifically, when the migration manager indicates migrations are finished |
|
| 71 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
| 72 | + */ |
|
| 73 | + const req_type_activation_but_not_installed = 5; |
|
| 74 | + |
|
| 75 | + /** |
|
| 76 | + * @deprecated 4.9.40 |
|
| 77 | + * @see \EventEspresso\core\services\activation\RequestTypeDetector |
|
| 78 | + */ |
|
| 79 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * @var EE_System $_instance |
|
| 84 | + */ |
|
| 85 | + private static $_instance; |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @var EE_Registry $registry |
|
| 89 | + */ |
|
| 90 | + private $registry; |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @var LoaderInterface $loader |
|
| 94 | + */ |
|
| 95 | + private $loader; |
|
| 96 | + |
|
| 97 | + /** |
|
| 98 | + * @var EE_Capabilities $capabilities |
|
| 99 | + */ |
|
| 100 | + private $capabilities; |
|
| 101 | + |
|
| 102 | + /** |
|
| 103 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
| 104 | + */ |
|
| 105 | + private $maintenance_mode; |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @var ActivationsAndUpgradesManager $activations_and_upgrades_manager |
|
| 109 | + */ |
|
| 110 | + private $activations_and_upgrades_manager; |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * @var ActivationHistory $activation_history |
|
| 114 | + */ |
|
| 115 | + private $activation_history; |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @var \EventEspresso\core\services\activation\RequestType $request_type |
|
| 119 | + */ |
|
| 120 | + private $request_type; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @var bool $activation_detected |
|
| 124 | + */ |
|
| 125 | + private $activation_detected = false; |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @singleton method used to instantiate class object |
|
| 131 | + * @param EE_Registry|null $registry |
|
| 132 | + * @param LoaderInterface|null $loader |
|
| 133 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
| 134 | + * @return EE_System |
|
| 135 | + */ |
|
| 136 | + public static function instance( |
|
| 137 | + EE_Registry $registry = null, |
|
| 138 | + LoaderInterface $loader = null, |
|
| 139 | + EE_Maintenance_Mode $maintenance_mode = null |
|
| 140 | + ) { |
|
| 141 | + // check if class object is instantiated |
|
| 142 | + if (! self::$_instance instanceof EE_System) { |
|
| 143 | + self::$_instance = new self( |
|
| 144 | + $registry, |
|
| 145 | + $loader, |
|
| 146 | + $maintenance_mode |
|
| 147 | + ); |
|
| 148 | + } |
|
| 149 | + return self::$_instance; |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * resets the instance and returns it |
|
| 156 | + * |
|
| 157 | + * @return EE_System |
|
| 158 | + * @throws InvalidInterfaceException |
|
| 159 | + * @throws InvalidDataTypeException |
|
| 160 | + * @throws DomainException |
|
| 161 | + * @throws InvalidArgumentException |
|
| 162 | + * @throws InvalidEntityException |
|
| 163 | + */ |
|
| 164 | + public static function reset() |
|
| 165 | + { |
|
| 166 | + //make sure none of the old hooks are left hanging around |
|
| 167 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 168 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
| 169 | + EE_Data_Migration_Manager::reset(); |
|
| 170 | + self::instance()->detect_activations_or_upgrades(); |
|
| 171 | + self::instance()->activations_and_upgrades_manager->performActivationsAndUpgrades(); |
|
| 172 | + return self::instance(); |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * sets hooks for running rest of system |
|
| 179 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 180 | + * starting EE Addons from any other point may lead to problems |
|
| 181 | + * |
|
| 182 | + * @param EE_Registry $registry |
|
| 183 | + * @param LoaderInterface $loader |
|
| 184 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
| 185 | + */ |
|
| 186 | + private function __construct( |
|
| 187 | + EE_Registry $registry, |
|
| 188 | + LoaderInterface $loader, |
|
| 189 | + EE_Maintenance_Mode $maintenance_mode |
|
| 190 | + ) { |
|
| 191 | + $this->registry = $registry; |
|
| 192 | + $this->loader = $loader; |
|
| 193 | + $this->maintenance_mode = $maintenance_mode; |
|
| 194 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
| 195 | + add_action( |
|
| 196 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 197 | + array($this, 'loadCapabilities'), |
|
| 198 | + 5 |
|
| 199 | + ); |
|
| 200 | + add_action( |
|
| 201 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 202 | + array($this, 'loadCommandBus'), |
|
| 203 | + 7 |
|
| 204 | + ); |
|
| 205 | + add_action( |
|
| 206 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 207 | + array($this, 'loadPluginApi'), |
|
| 208 | + 9 |
|
| 209 | + ); |
|
| 210 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
| 211 | + add_action( |
|
| 212 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 213 | + array($this, 'load_espresso_addons') |
|
| 214 | + ); |
|
| 215 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
| 216 | + // because the newly-activated addon didn't get a chance to run at all |
|
| 217 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
| 218 | + // detect whether install or upgrade |
|
| 219 | + add_action( |
|
| 220 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
| 221 | + array($this, 'detect_activations_or_upgrades'), |
|
| 222 | + 3 |
|
| 223 | + ); |
|
| 224 | + // load EE_Config, EE_Textdomain, etc |
|
| 225 | + add_action( |
|
| 226 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 227 | + array($this, 'load_core_configuration'), |
|
| 228 | + 5 |
|
| 229 | + ); |
|
| 230 | + // load EE_Config, EE_Textdomain, etc |
|
| 231 | + add_action( |
|
| 232 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
| 233 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 234 | + 7 |
|
| 235 | + ); |
|
| 236 | + // you wanna get going? I wanna get going... let's get going! |
|
| 237 | + add_action( |
|
| 238 | + 'AHEE__EE_Bootstrap__brew_espresso', |
|
| 239 | + array($this, 'brew_espresso'), |
|
| 240 | + 9 |
|
| 241 | + ); |
|
| 242 | + //other housekeeping |
|
| 243 | + //exclude EE critical pages from wp_list_pages |
|
| 244 | + add_filter( |
|
| 245 | + 'wp_list_pages_excludes', |
|
| 246 | + array($this, 'remove_pages_from_wp_list_pages'), |
|
| 247 | + 10 |
|
| 248 | + ); |
|
| 249 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
| 250 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
| 251 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
| 252 | + } |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * load and setup EE_Capabilities |
|
| 258 | + * |
|
| 259 | + * @return void |
|
| 260 | + * @throws InvalidArgumentException |
|
| 261 | + * @throws InvalidInterfaceException |
|
| 262 | + * @throws InvalidDataTypeException |
|
| 263 | + * @throws EE_Error |
|
| 264 | + */ |
|
| 265 | + public function loadCapabilities() |
|
| 266 | + { |
|
| 267 | + $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
| 268 | + add_action( |
|
| 269 | + 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
| 270 | + function() { |
|
| 271 | + LoaderFactory::getLoader()->getShared('Payment_Method_Manager'); |
|
| 272 | + } |
|
| 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 | + * @throws EE_Error |
|
| 285 | + */ |
|
| 286 | + public function loadCommandBus() |
|
| 287 | + { |
|
| 288 | + $this->loader->getShared( |
|
| 289 | + 'CommandBusInterface', |
|
| 290 | + array( |
|
| 291 | + null, |
|
| 292 | + apply_filters( |
|
| 293 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 294 | + array( |
|
| 295 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
| 296 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
| 297 | + ) |
|
| 298 | + ), |
|
| 299 | + ) |
|
| 300 | + ); |
|
| 301 | + } |
|
| 302 | + |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * @return void |
|
| 307 | + * @throws EE_Error |
|
| 308 | + */ |
|
| 309 | + public function loadPluginApi() |
|
| 310 | + { |
|
| 311 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
| 312 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
| 313 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 314 | + } |
|
| 315 | + |
|
| 316 | + |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * Gets the ActivationHistory object for this addon |
|
| 320 | + * |
|
| 321 | + * @return ActivationHistory |
|
| 322 | + */ |
|
| 323 | + public function getActivationHistory() |
|
| 324 | + { |
|
| 325 | + return $this->activation_history; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * @param ActivationHistory $activation_history |
|
| 332 | + */ |
|
| 333 | + public function setActivationHistory(ActivationHistory $activation_history) |
|
| 334 | + { |
|
| 335 | + $this->activation_history = $activation_history; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @return RequestType |
|
| 342 | + */ |
|
| 343 | + public function getRequestType() |
|
| 344 | + { |
|
| 345 | + return $this->request_type; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + |
|
| 350 | + /** |
|
| 351 | + * @param RequestType $request_type |
|
| 352 | + */ |
|
| 353 | + public function setRequestType(RequestType $request_type) |
|
| 354 | + { |
|
| 355 | + $this->request_type = $request_type; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * load_espresso_addons |
|
| 360 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
| 361 | + * this is hooked into both: |
|
| 362 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 363 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 364 | + * and the WP 'activate_plugin' hook point |
|
| 365 | + * |
|
| 366 | + * @return void |
|
| 367 | + * @throws EE_Error |
|
| 368 | + */ |
|
| 369 | + public function load_espresso_addons() |
|
| 370 | + { |
|
| 371 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 372 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
| 373 | + //We want it for mobile apps. Just include the entire plugin |
|
| 374 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
| 375 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
| 376 | + //and causes a fatal error |
|
| 377 | + if ( |
|
| 378 | + ! ( |
|
| 379 | + isset($_GET['activate']) |
|
| 380 | + && $_GET['activate'] === 'true' |
|
| 381 | + ) |
|
| 382 | + && ! function_exists('json_basic_auth_handler') |
|
| 383 | + && ! function_exists('json_basic_auth_error') |
|
| 384 | + && ! ( |
|
| 385 | + isset($_GET['action']) |
|
| 386 | + && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
|
| 387 | + ) |
|
| 388 | + ) { |
|
| 389 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
| 390 | + } |
|
| 391 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
| 392 | + } |
|
| 393 | + |
|
| 394 | + |
|
| 395 | + |
|
| 396 | + /** |
|
| 397 | + * detect_activations_or_upgrades |
|
| 398 | + * Checks for activation or upgrade of core first; |
|
| 399 | + * then also checks if any registered addons have been activated or upgraded |
|
| 400 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
| 401 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
| 402 | + * |
|
| 403 | + * @return void |
|
| 404 | + * @throws DomainException |
|
| 405 | + * @throws InvalidArgumentException |
|
| 406 | + * @throws InvalidEntityException |
|
| 407 | + * @throws InvalidInterfaceException |
|
| 408 | + * @throws InvalidDataTypeException |
|
| 409 | + */ |
|
| 410 | + public function detect_activations_or_upgrades() |
|
| 411 | + { |
|
| 412 | + if( |
|
| 413 | + (defined('DOING_AJAX') && DOING_AJAX) |
|
| 414 | + || (defined('REST_REQUEST') && REST_REQUEST) |
|
| 415 | + ) { |
|
| 416 | + return; |
|
| 417 | + } |
|
| 418 | + $this->activations_and_upgrades_manager = ActivationsFactory::getActivationsAndUpgradesManager(); |
|
| 419 | + $this->activation_detected = $this->activations_and_upgrades_manager->detectActivationsAndVersionChanges( |
|
| 420 | + array_merge( |
|
| 421 | + array($this), |
|
| 422 | + get_object_vars($this->registry->addons) |
|
| 423 | + ) |
|
| 424 | + ); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + |
|
| 429 | + /** |
|
| 430 | + * load_core_configuration |
|
| 431 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 432 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 433 | + * |
|
| 434 | + * @return void |
|
| 435 | + * @throws ReflectionException |
|
| 436 | + */ |
|
| 437 | + public function load_core_configuration() |
|
| 438 | + { |
|
| 439 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 440 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
| 441 | + //load textdomain |
|
| 442 | + EE_Load_Textdomain::load_textdomain(); |
|
| 443 | + // load and setup EE_Config and EE_Network_Config |
|
| 444 | + $config = $this->loader->getShared('EE_Config'); |
|
| 445 | + $this->loader->getShared('EE_Network_Config'); |
|
| 446 | + // setup autoloaders |
|
| 447 | + // enable logging? |
|
| 448 | + if ($config->admin->use_full_logging) { |
|
| 449 | + $this->loader->getShared('EE_Log'); |
|
| 450 | + } |
|
| 451 | + // check for activation errors |
|
| 452 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
| 453 | + if ($activation_errors) { |
|
| 454 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 455 | + update_option('ee_plugin_activation_errors', false); |
|
| 456 | + } |
|
| 457 | + // get model names |
|
| 458 | + $this->_parse_model_names(); |
|
| 459 | + //load caf stuff a chance to play during the activation process too. |
|
| 460 | + $this->_maybe_brew_regular(); |
|
| 461 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 462 | + } |
|
| 463 | + |
|
| 464 | + |
|
| 465 | + |
|
| 466 | + /** |
|
| 467 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
| 468 | + * |
|
| 469 | + * @return void |
|
| 470 | + * @throws ReflectionException |
|
| 471 | + */ |
|
| 472 | + private function _parse_model_names() |
|
| 473 | + { |
|
| 474 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
| 475 | + $models = glob(EE_MODELS . '*.model.php'); |
|
| 476 | + $model_names = array(); |
|
| 477 | + $non_abstract_db_models = array(); |
|
| 478 | + foreach ($models as $model) { |
|
| 479 | + // get model classname |
|
| 480 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 481 | + $short_name = str_replace('EEM_', '', $classname); |
|
| 482 | + $reflectionClass = new ReflectionClass($classname); |
|
| 483 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 484 | + $non_abstract_db_models[$short_name] = $classname; |
|
| 485 | + } |
|
| 486 | + $model_names[$short_name] = $classname; |
|
| 487 | + } |
|
| 488 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 489 | + $this->registry->non_abstract_db_models = apply_filters( |
|
| 490 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
| 491 | + $non_abstract_db_models |
|
| 492 | + ); |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + |
|
| 496 | + |
|
| 497 | + /** |
|
| 498 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
| 499 | + * that need to be setup before our EE_System launches. |
|
| 500 | + * |
|
| 501 | + * @return void |
|
| 502 | + */ |
|
| 503 | + private function _maybe_brew_regular() |
|
| 504 | + { |
|
| 505 | + if ( |
|
| 506 | + ! $this->activation_detected |
|
| 507 | + && (! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 508 | + && is_readable(EE_CAFF_PATH . 'brewing_regular.php') |
|
| 509 | + ) { |
|
| 510 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + |
|
| 515 | + |
|
| 516 | + /** |
|
| 517 | + * register_shortcodes_modules_and_widgets |
|
| 518 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
| 519 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
| 520 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
| 521 | + * |
|
| 522 | + * @access public |
|
| 523 | + * @return void |
|
| 524 | + * @throws Exception |
|
| 525 | + */ |
|
| 526 | + public function register_shortcodes_modules_and_widgets() |
|
| 527 | + { |
|
| 528 | + if ($this->activation_detected) { |
|
| 529 | + return; |
|
| 530 | + } |
|
| 531 | + // check for addons using old hook point |
|
| 532 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 533 | + $this->_incompatible_addon_error(); |
|
| 534 | + } |
|
| 535 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 536 | + try { |
|
| 537 | + // load, register, and add shortcodes the new way |
|
| 538 | + new ShortcodesManager( |
|
| 539 | + // and the old way, but we'll put it under control of the new system |
|
| 540 | + EE_Config::getLegacyShortcodesManager() |
|
| 541 | + ); |
|
| 542 | + } catch (Exception $exception) { |
|
| 543 | + new ExceptionStackTraceDisplay($exception); |
|
| 544 | + } |
|
| 545 | + } |
|
| 546 | + |
|
| 547 | + |
|
| 548 | + |
|
| 549 | + /** |
|
| 550 | + * _incompatible_addon_error |
|
| 551 | + * |
|
| 552 | + * @access public |
|
| 553 | + * @return void |
|
| 554 | + */ |
|
| 555 | + private function _incompatible_addon_error() |
|
| 556 | + { |
|
| 557 | + // get array of classes hooking into here |
|
| 558 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
| 559 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
| 560 | + ); |
|
| 561 | + if (! empty($class_names)) { |
|
| 562 | + $msg = __( |
|
| 563 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
| 564 | + 'event_espresso' |
|
| 565 | + ); |
|
| 566 | + $msg .= '<ul>'; |
|
| 567 | + foreach ($class_names as $class_name) { |
|
| 568 | + $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
| 569 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
| 570 | + $class_name |
|
| 571 | + ) . '</b></li>'; |
|
| 572 | + } |
|
| 573 | + $msg .= '</ul>'; |
|
| 574 | + $msg .= __( |
|
| 575 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
| 576 | + 'event_espresso' |
|
| 577 | + ); |
|
| 578 | + // save list of incompatible addons to wp-options for later use |
|
| 579 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 580 | + if (is_admin()) { |
|
| 581 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 582 | + } |
|
| 583 | + } |
|
| 584 | + } |
|
| 585 | + |
|
| 586 | + |
|
| 587 | + |
|
| 588 | + /** |
|
| 589 | + * brew_espresso |
|
| 590 | + * begins the process of setting hooks for initializing EE in the correct order |
|
| 591 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
| 592 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
| 593 | + * |
|
| 594 | + * @return void |
|
| 595 | + */ |
|
| 596 | + public function brew_espresso() |
|
| 597 | + { |
|
| 598 | + if ($this->activation_detected) { |
|
| 599 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
| 600 | + return; |
|
| 601 | + } |
|
| 602 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 603 | + // load some final core systems |
|
| 604 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 605 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 606 | + add_action('init', array($this, 'load_controllers'), 7); |
|
| 607 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 608 | + add_action('init', array($this, 'initialize'), 10); |
|
| 609 | + add_action('init', array($this, 'initialize_last'), 100); |
|
| 610 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 611 | + // pew pew pew |
|
| 612 | + $this->loader->getShared('EE_PUE'); |
|
| 613 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 614 | + } |
|
| 615 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 616 | + } |
|
| 617 | + |
|
| 618 | + |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * set_hooks_for_core |
|
| 622 | + * |
|
| 623 | + * @access public |
|
| 624 | + * @return void |
|
| 625 | + * @throws EE_Error |
|
| 626 | + */ |
|
| 627 | + public function set_hooks_for_core() |
|
| 628 | + { |
|
| 629 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 630 | + //caps need to be initialized on every request so that capability maps are set. |
|
| 631 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
| 632 | + $this->capabilities->init_caps(); |
|
| 633 | + } |
|
| 634 | + |
|
| 635 | + |
|
| 636 | + |
|
| 637 | + /** |
|
| 638 | + * perform_activations_upgrades_and_migrations |
|
| 639 | + * |
|
| 640 | + * @access public |
|
| 641 | + * @return void |
|
| 642 | + */ |
|
| 643 | + public function perform_activations_upgrades_and_migrations() |
|
| 644 | + { |
|
| 645 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + |
|
| 649 | + |
|
| 650 | + /** |
|
| 651 | + * load_CPTs_and_session |
|
| 652 | + * |
|
| 653 | + * @access public |
|
| 654 | + * @return void |
|
| 655 | + */ |
|
| 656 | + public function load_CPTs_and_session() |
|
| 657 | + { |
|
| 658 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 659 | + // register Custom Post Types |
|
| 660 | + $this->loader->getShared('EE_Register_CPTs'); |
|
| 661 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + |
|
| 665 | + |
|
| 666 | + /** |
|
| 667 | + * load_controllers |
|
| 668 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
| 669 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
| 670 | + * time |
|
| 671 | + * |
|
| 672 | + * @access public |
|
| 673 | + * @return void |
|
| 674 | + */ |
|
| 675 | + public function load_controllers() |
|
| 676 | + { |
|
| 677 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
| 678 | + // let's get it started |
|
| 679 | + if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
| 680 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 681 | + $this->loader->getShared('EE_Front_Controller'); |
|
| 682 | + } else if (! EE_FRONT_AJAX) { |
|
| 683 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 684 | + $this->loader->getShared('EE_Admin'); |
|
| 685 | + } |
|
| 686 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + |
|
| 690 | + |
|
| 691 | + /** |
|
| 692 | + * core_loaded_and_ready |
|
| 693 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
| 694 | + * |
|
| 695 | + * @access public |
|
| 696 | + * @return void |
|
| 697 | + */ |
|
| 698 | + public function core_loaded_and_ready() |
|
| 699 | + { |
|
| 700 | + $this->loader->getShared('EE_Session'); |
|
| 701 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 702 | + // load_espresso_template_tags |
|
| 703 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
| 704 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
| 705 | + } |
|
| 706 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 707 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 708 | + } |
|
| 709 | + |
|
| 710 | + |
|
| 711 | + |
|
| 712 | + /** |
|
| 713 | + * initialize |
|
| 714 | + * this is the best place to begin initializing client code |
|
| 715 | + * |
|
| 716 | + * @access public |
|
| 717 | + * @return void |
|
| 718 | + */ |
|
| 719 | + public function initialize() |
|
| 720 | + { |
|
| 721 | + do_action('AHEE__EE_System__initialize'); |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * initialize_last |
|
| 728 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
| 729 | + * initialize has done so |
|
| 730 | + * |
|
| 731 | + * @access public |
|
| 732 | + * @return void |
|
| 733 | + */ |
|
| 734 | + public function initialize_last() |
|
| 735 | + { |
|
| 736 | + do_action('AHEE__EE_System__initialize_last'); |
|
| 737 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
| 738 | + } |
|
| 739 | + |
|
| 740 | + |
|
| 741 | + |
|
| 742 | + /** |
|
| 743 | + * @return void |
|
| 744 | + * @throws EE_Error |
|
| 745 | + */ |
|
| 746 | + public function addEspressoToolbar() |
|
| 747 | + { |
|
| 748 | + $this->loader->getShared( |
|
| 749 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
| 750 | + array($this->capabilities) |
|
| 751 | + ); |
|
| 752 | + } |
|
| 753 | + |
|
| 754 | + |
|
| 755 | + |
|
| 756 | + /** |
|
| 757 | + * do_not_cache |
|
| 758 | + * sets no cache headers and defines no cache constants for WP plugins |
|
| 759 | + * |
|
| 760 | + * @access public |
|
| 761 | + * @return void |
|
| 762 | + */ |
|
| 763 | + public static function do_not_cache() |
|
| 764 | + { |
|
| 765 | + // set no cache constants |
|
| 766 | + if (! defined('DONOTCACHEPAGE')) { |
|
| 767 | + define('DONOTCACHEPAGE', true); |
|
| 768 | + } |
|
| 769 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
| 770 | + define('DONOTCACHCEOBJECT', true); |
|
| 771 | + } |
|
| 772 | + if (! defined('DONOTCACHEDB')) { |
|
| 773 | + define('DONOTCACHEDB', true); |
|
| 774 | + } |
|
| 775 | + // add no cache headers |
|
| 776 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 777 | + // plus a little extra for nginx and Google Chrome |
|
| 778 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 779 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
| 780 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 781 | + } |
|
| 782 | + |
|
| 783 | + |
|
| 784 | + |
|
| 785 | + /** |
|
| 786 | + * extra_nocache_headers |
|
| 787 | + * |
|
| 788 | + * @access public |
|
| 789 | + * @param $headers |
|
| 790 | + * @return array |
|
| 791 | + */ |
|
| 792 | + public static function extra_nocache_headers($headers) |
|
| 793 | + { |
|
| 794 | + // for NGINX |
|
| 795 | + $headers['X-Accel-Expires'] = 0; |
|
| 796 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
| 797 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
| 798 | + return $headers; |
|
| 799 | + } |
|
| 800 | + |
|
| 801 | + |
|
| 802 | + |
|
| 803 | + /** |
|
| 804 | + * nocache_headers |
|
| 805 | + * |
|
| 806 | + * @access public |
|
| 807 | + * @return void |
|
| 808 | + */ |
|
| 809 | + public static function nocache_headers() |
|
| 810 | + { |
|
| 811 | + nocache_headers(); |
|
| 812 | + } |
|
| 813 | + |
|
| 814 | + |
|
| 815 | + |
|
| 816 | + |
|
| 817 | + /** |
|
| 818 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
| 819 | + * never returned with the function. |
|
| 820 | + * |
|
| 821 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
| 822 | + * @return array |
|
| 823 | + */ |
|
| 824 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
| 825 | + { |
|
| 826 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 827 | + } |
|
| 828 | + |
|
| 829 | + |
|
| 830 | + |
|
| 831 | + /******************************** DEPRECATED ***************************************/ |
|
| 832 | + |
|
| 833 | + |
|
| 834 | + |
|
| 835 | + /** |
|
| 836 | + * @deprecated 4.9.40 |
|
| 837 | + * @return void |
|
| 838 | + */ |
|
| 839 | + public function detect_if_activation_or_upgrade() |
|
| 840 | + { |
|
| 841 | + } |
|
| 842 | + |
|
| 843 | + |
|
| 844 | + |
|
| 845 | + /** |
|
| 846 | + * @deprecated 4.9.40 |
|
| 847 | + * @param null $version_history |
|
| 848 | + * @param null $current_version_to_add |
|
| 849 | + * @return void |
|
| 850 | + */ |
|
| 851 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 852 | + { |
|
| 853 | + } |
|
| 854 | + |
|
| 855 | + |
|
| 856 | + |
|
| 857 | + /** |
|
| 858 | + * @deprecated 4.9.40 |
|
| 859 | + * @param null $espresso_db_update |
|
| 860 | + * @return int one of the constants on EE_System::req_type_ |
|
| 861 | + */ |
|
| 862 | + public function detect_req_type($espresso_db_update = null) |
|
| 863 | + { |
|
| 864 | + return $this->getRequestType()->getRequestType(); |
|
| 865 | + } |
|
| 866 | + |
|
| 867 | + |
|
| 868 | + |
|
| 869 | + /** |
|
| 870 | + * @deprecated 4.9.40 |
|
| 871 | + * @return bool |
|
| 872 | + */ |
|
| 873 | + public function is_major_version_change() |
|
| 874 | + { |
|
| 875 | + return $this->getRequestType()->isMajorVersionChange(); |
|
| 876 | + } |
|
| 877 | 877 | |
| 878 | 878 | |
| 879 | 879 | |
| 880 | - /** |
|
| 881 | - * @deprecated 4.9.40 |
|
| 882 | - * @param array $activation_history_for_addon |
|
| 883 | - * @param string $activation_indicator_option_name |
|
| 884 | - * @param string $version_to_upgrade_to |
|
| 885 | - * @return int one of the constants on EE_System::req_type_* |
|
| 886 | - */ |
|
| 887 | - public static function detect_req_type_given_activation_history( |
|
| 888 | - $activation_history_for_addon, |
|
| 889 | - $activation_indicator_option_name, |
|
| 890 | - $version_to_upgrade_to |
|
| 891 | - ) { |
|
| 892 | - return EE_System::instance()->getRequestType()->getRequestType(); |
|
| 893 | - } |
|
| 880 | + /** |
|
| 881 | + * @deprecated 4.9.40 |
|
| 882 | + * @param array $activation_history_for_addon |
|
| 883 | + * @param string $activation_indicator_option_name |
|
| 884 | + * @param string $version_to_upgrade_to |
|
| 885 | + * @return int one of the constants on EE_System::req_type_* |
|
| 886 | + */ |
|
| 887 | + public static function detect_req_type_given_activation_history( |
|
| 888 | + $activation_history_for_addon, |
|
| 889 | + $activation_indicator_option_name, |
|
| 890 | + $version_to_upgrade_to |
|
| 891 | + ) { |
|
| 892 | + return EE_System::instance()->getRequestType()->getRequestType(); |
|
| 893 | + } |
|
| 894 | 894 | |
| 895 | 895 | |
| 896 | 896 | |
| 897 | - /** |
|
| 898 | - * @deprecated 4.9.40 |
|
| 899 | - * @param boolean $initialize_addons_too |
|
| 900 | - * @param boolean $verify_schema |
|
| 901 | - * @return void |
|
| 902 | - * @throws EE_Error |
|
| 903 | - */ |
|
| 904 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
| 905 | - { |
|
| 906 | - } |
|
| 897 | + /** |
|
| 898 | + * @deprecated 4.9.40 |
|
| 899 | + * @param boolean $initialize_addons_too |
|
| 900 | + * @param boolean $verify_schema |
|
| 901 | + * @return void |
|
| 902 | + * @throws EE_Error |
|
| 903 | + */ |
|
| 904 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
| 905 | + { |
|
| 906 | + } |
|
| 907 | 907 | |
| 908 | 908 | |
| 909 | 909 | |
| 910 | - /** |
|
| 911 | - * @deprecated 4.9.40 |
|
| 912 | - * @throws EE_Error |
|
| 913 | - */ |
|
| 914 | - public function initialize_addons() |
|
| 915 | - { |
|
| 916 | - } |
|
| 910 | + /** |
|
| 911 | + * @deprecated 4.9.40 |
|
| 912 | + * @throws EE_Error |
|
| 913 | + */ |
|
| 914 | + public function initialize_addons() |
|
| 915 | + { |
|
| 916 | + } |
|
| 917 | 917 | |
| 918 | 918 | |
| 919 | 919 | |
| 920 | - /** |
|
| 921 | - * @deprecated 4.9.40 |
|
| 922 | - * @return void |
|
| 923 | - */ |
|
| 924 | - public function redirect_to_about_ee() |
|
| 925 | - { |
|
| 926 | - } |
|
| 920 | + /** |
|
| 921 | + * @deprecated 4.9.40 |
|
| 922 | + * @return void |
|
| 923 | + */ |
|
| 924 | + public function redirect_to_about_ee() |
|
| 925 | + { |
|
| 926 | + } |
|
| 927 | 927 | |
| 928 | 928 | |
| 929 | 929 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | EE_Maintenance_Mode $maintenance_mode = null |
| 140 | 140 | ) { |
| 141 | 141 | // check if class object is instantiated |
| 142 | - if (! self::$_instance instanceof EE_System) { |
|
| 142 | + if ( ! self::$_instance instanceof EE_System) { |
|
| 143 | 143 | self::$_instance = new self( |
| 144 | 144 | $registry, |
| 145 | 145 | $loader, |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | { |
| 311 | 311 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
| 312 | 312 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
| 313 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 313 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
| 314 | 314 | } |
| 315 | 315 | |
| 316 | 316 | |
@@ -386,7 +386,7 @@ discard block |
||
| 386 | 386 | && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
| 387 | 387 | ) |
| 388 | 388 | ) { |
| 389 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
| 389 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php'; |
|
| 390 | 390 | } |
| 391 | 391 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
| 392 | 392 | } |
@@ -409,7 +409,7 @@ discard block |
||
| 409 | 409 | */ |
| 410 | 410 | public function detect_activations_or_upgrades() |
| 411 | 411 | { |
| 412 | - if( |
|
| 412 | + if ( |
|
| 413 | 413 | (defined('DOING_AJAX') && DOING_AJAX) |
| 414 | 414 | || (defined('REST_REQUEST') && REST_REQUEST) |
| 415 | 415 | ) { |
@@ -472,7 +472,7 @@ discard block |
||
| 472 | 472 | private function _parse_model_names() |
| 473 | 473 | { |
| 474 | 474 | //get all the files in the EE_MODELS folder that end in .model.php |
| 475 | - $models = glob(EE_MODELS . '*.model.php'); |
|
| 475 | + $models = glob(EE_MODELS.'*.model.php'); |
|
| 476 | 476 | $model_names = array(); |
| 477 | 477 | $non_abstract_db_models = array(); |
| 478 | 478 | foreach ($models as $model) { |
@@ -504,10 +504,10 @@ discard block |
||
| 504 | 504 | { |
| 505 | 505 | if ( |
| 506 | 506 | ! $this->activation_detected |
| 507 | - && (! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 508 | - && is_readable(EE_CAFF_PATH . 'brewing_regular.php') |
|
| 507 | + && ( ! defined('EE_DECAF') || EE_DECAF !== true) |
|
| 508 | + && is_readable(EE_CAFF_PATH.'brewing_regular.php') |
|
| 509 | 509 | ) { |
| 510 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 510 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
| 511 | 511 | } |
| 512 | 512 | } |
| 513 | 513 | |
@@ -558,17 +558,17 @@ discard block |
||
| 558 | 558 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
| 559 | 559 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
| 560 | 560 | ); |
| 561 | - if (! empty($class_names)) { |
|
| 561 | + if ( ! empty($class_names)) { |
|
| 562 | 562 | $msg = __( |
| 563 | 563 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
| 564 | 564 | 'event_espresso' |
| 565 | 565 | ); |
| 566 | 566 | $msg .= '<ul>'; |
| 567 | 567 | foreach ($class_names as $class_name) { |
| 568 | - $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
| 568 | + $msg .= '<li><b>Event Espresso - '.str_replace( |
|
| 569 | 569 | array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
| 570 | 570 | $class_name |
| 571 | - ) . '</b></li>'; |
|
| 571 | + ).'</b></li>'; |
|
| 572 | 572 | } |
| 573 | 573 | $msg .= '</ul>'; |
| 574 | 574 | $msg .= __( |
@@ -676,10 +676,10 @@ discard block |
||
| 676 | 676 | { |
| 677 | 677 | do_action('AHEE__EE_System__load_controllers__start'); |
| 678 | 678 | // let's get it started |
| 679 | - if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
| 679 | + if ( ! is_admin() && ! $this->maintenance_mode->level()) { |
|
| 680 | 680 | do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
| 681 | 681 | $this->loader->getShared('EE_Front_Controller'); |
| 682 | - } else if (! EE_FRONT_AJAX) { |
|
| 682 | + } else if ( ! EE_FRONT_AJAX) { |
|
| 683 | 683 | do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
| 684 | 684 | $this->loader->getShared('EE_Admin'); |
| 685 | 685 | } |
@@ -700,8 +700,8 @@ discard block |
||
| 700 | 700 | $this->loader->getShared('EE_Session'); |
| 701 | 701 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
| 702 | 702 | // load_espresso_template_tags |
| 703 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
| 704 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
| 703 | + if (is_readable(EE_PUBLIC.'template_tags.php')) { |
|
| 704 | + require_once(EE_PUBLIC.'template_tags.php'); |
|
| 705 | 705 | } |
| 706 | 706 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
| 707 | 707 | $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
@@ -763,13 +763,13 @@ discard block |
||
| 763 | 763 | public static function do_not_cache() |
| 764 | 764 | { |
| 765 | 765 | // set no cache constants |
| 766 | - if (! defined('DONOTCACHEPAGE')) { |
|
| 766 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
| 767 | 767 | define('DONOTCACHEPAGE', true); |
| 768 | 768 | } |
| 769 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
| 769 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
| 770 | 770 | define('DONOTCACHCEOBJECT', true); |
| 771 | 771 | } |
| 772 | - if (! defined('DONOTCACHEDB')) { |
|
| 772 | + if ( ! defined('DONOTCACHEDB')) { |
|
| 773 | 773 | define('DONOTCACHEDB', true); |
| 774 | 774 | } |
| 775 | 775 | // add no cache headers |
@@ -16,288 +16,288 @@ |
||
| 16 | 16 | class EE_Request implements InterminableInterface |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - /** |
|
| 20 | - * $_GET parameters |
|
| 21 | - * |
|
| 22 | - * @var array $_get |
|
| 23 | - */ |
|
| 24 | - private $_get; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * $_POST parameters |
|
| 28 | - * |
|
| 29 | - * @var array $_post |
|
| 30 | - */ |
|
| 31 | - private $_post; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * $_COOKIE parameters |
|
| 35 | - * |
|
| 36 | - * @var array $_cookie |
|
| 37 | - */ |
|
| 38 | - private $_cookie; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * $_REQUEST parameters |
|
| 42 | - * |
|
| 43 | - * @var array $_params |
|
| 44 | - */ |
|
| 45 | - private $_params; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * whether current request is via AJAX |
|
| 49 | - * |
|
| 50 | - * @var boolean $ajax |
|
| 51 | - */ |
|
| 52 | - public $ajax; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * whether current request is via AJAX from the frontend of the site |
|
| 56 | - * |
|
| 57 | - * @var boolean $front_ajax |
|
| 58 | - */ |
|
| 59 | - public $front_ajax; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * IP address for request |
|
| 63 | - * |
|
| 64 | - * @var string $_ip_address |
|
| 65 | - */ |
|
| 66 | - private $_ip_address; |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * class constructor |
|
| 71 | - * |
|
| 72 | - * @access public |
|
| 73 | - * @param array $get |
|
| 74 | - * @param array $post |
|
| 75 | - * @param array $cookie |
|
| 76 | - */ |
|
| 77 | - public function __construct(array $get, array $post, array $cookie) |
|
| 78 | - { |
|
| 79 | - // grab request vars |
|
| 80 | - $this->_get = (array)$get; |
|
| 81 | - $this->_post = (array)$post; |
|
| 82 | - $this->_cookie = (array)$cookie; |
|
| 83 | - $this->_params = array_merge($this->_get, $this->_post); |
|
| 84 | - // AJAX ??? |
|
| 85 | - $this->ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 86 | - $this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1; |
|
| 87 | - // grab user IP |
|
| 88 | - $this->_ip_address = $this->_visitor_ip(); |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @return array |
|
| 95 | - */ |
|
| 96 | - public function get_params() |
|
| 97 | - { |
|
| 98 | - return $this->_get; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @return array |
|
| 105 | - */ |
|
| 106 | - public function post_params() |
|
| 107 | - { |
|
| 108 | - return $this->_post; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return array |
|
| 115 | - */ |
|
| 116 | - public function cookie_params() |
|
| 117 | - { |
|
| 118 | - return $this->_cookie; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * returns contents of $_REQUEST |
|
| 125 | - * |
|
| 126 | - * @return array |
|
| 127 | - */ |
|
| 128 | - public function params() |
|
| 129 | - { |
|
| 130 | - return $this->_params; |
|
| 131 | - } |
|
| 132 | - |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @param $key |
|
| 137 | - * @param $value |
|
| 138 | - * @param bool $override_ee |
|
| 139 | - * @return void |
|
| 140 | - */ |
|
| 141 | - public function set($key, $value, $override_ee = false) |
|
| 142 | - { |
|
| 143 | - // don't allow "ee" to be overwritten unless explicitly instructed to do so |
|
| 144 | - if ( |
|
| 145 | - $key !== 'ee' |
|
| 146 | - || ($key === 'ee' && empty($this->_params['ee'])) |
|
| 147 | - || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
| 148 | - ) { |
|
| 149 | - $this->_params[$key] = $value; |
|
| 150 | - } |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * returns the value for a request param if the given key exists |
|
| 157 | - * |
|
| 158 | - * @param $key |
|
| 159 | - * @param null $default |
|
| 160 | - * @return mixed |
|
| 161 | - */ |
|
| 162 | - public function get($key, $default = null) |
|
| 163 | - { |
|
| 164 | - return $this->request_parameter_drill_down($key, $default, 'get'); |
|
| 165 | - } |
|
| 166 | - |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * check if param exists |
|
| 171 | - * @param $key |
|
| 172 | - * @return bool |
|
| 173 | - */ |
|
| 174 | - public function is_set($key) |
|
| 175 | - { |
|
| 176 | - return $this->request_parameter_drill_down($key); |
|
| 177 | - } |
|
| 178 | - |
|
| 179 | - |
|
| 180 | - |
|
| 181 | - /** |
|
| 182 | - * the supplied key can be a simple string to represent a "top-level" request parameter |
|
| 183 | - * or represent a key for a request parameter that is nested deeper within the request parameter array, |
|
| 184 | - * by using square brackets to surround keys for deeper array elements. |
|
| 185 | - * For example : |
|
| 186 | - * if the supplied $key was: "first[second][third]" |
|
| 187 | - * then this will attempt to drill down into the request parameter array to find a value. |
|
| 188 | - * Given the following request parameters: |
|
| 189 | - * array( |
|
| 190 | - * 'first' => array( |
|
| 191 | - * 'second' => array( |
|
| 192 | - * 'third' => 'has a value' |
|
| 193 | - * ) |
|
| 194 | - * ) |
|
| 195 | - * ) |
|
| 196 | - * would return true |
|
| 197 | - * |
|
| 198 | - * @param string $is_set_or_get |
|
| 199 | - * @param $key |
|
| 200 | - * @param null $default |
|
| 201 | - * @param array $request_params |
|
| 202 | - * @return bool|mixed|null |
|
| 203 | - */ |
|
| 204 | - private function request_parameter_drill_down( |
|
| 205 | - $key, |
|
| 206 | - $default = null, |
|
| 207 | - $is_set_or_get = 'is_set', |
|
| 208 | - array $request_params = array() |
|
| 209 | - ) { |
|
| 210 | - $request_params = ! empty($request_params) |
|
| 211 | - ? $request_params |
|
| 212 | - : $this->_params; |
|
| 213 | - // does incoming key represent an array like 'first[second][third]' ? |
|
| 214 | - if (strpos($key, '[') !== false) { |
|
| 215 | - // turn it into an actual array |
|
| 216 | - $key = str_replace(']', '', $key); |
|
| 217 | - $keys = explode('[', $key); |
|
| 218 | - $key = array_shift($keys); |
|
| 219 | - // check if top level key exists |
|
| 220 | - if (isset($request_params[$key])) { |
|
| 221 | - // build a new key to pass along like: 'second[third]' |
|
| 222 | - // or just 'second' depending on depth of keys |
|
| 223 | - $key_string = array_shift($keys); |
|
| 224 | - if (! empty($keys)) { |
|
| 225 | - $key_string .= '[' . implode('][', $keys) . ']'; |
|
| 226 | - } |
|
| 227 | - return $this->request_parameter_drill_down( |
|
| 228 | - $key_string, |
|
| 229 | - $default, |
|
| 230 | - $is_set_or_get, |
|
| 231 | - $request_params[$key] |
|
| 232 | - ); |
|
| 233 | - } |
|
| 234 | - } |
|
| 235 | - if ($is_set_or_get === 'is_set') { |
|
| 236 | - return isset($request_params[$key]); |
|
| 237 | - } |
|
| 238 | - return isset($request_params[$key]) |
|
| 239 | - ? $request_params[$key] |
|
| 240 | - : $default; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * remove param |
|
| 247 | - * @param $key |
|
| 248 | - * @param bool $unset_from_global_too |
|
| 249 | - */ |
|
| 250 | - public function un_set($key, $unset_from_global_too = false) |
|
| 251 | - { |
|
| 252 | - unset($this->_params[$key]); |
|
| 253 | - if ($unset_from_global_too) { |
|
| 254 | - unset($_REQUEST[$key]); |
|
| 255 | - } |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - |
|
| 259 | - |
|
| 260 | - /** |
|
| 261 | - * @return string |
|
| 262 | - */ |
|
| 263 | - public function ip_address() |
|
| 264 | - { |
|
| 265 | - return $this->_ip_address; |
|
| 266 | - } |
|
| 267 | - |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * _visitor_ip |
|
| 272 | - * attempt to get IP address of current visitor from server |
|
| 273 | - * plz see: http://stackoverflow.com/a/2031935/1475279 |
|
| 274 | - * |
|
| 275 | - * @access public |
|
| 276 | - * @return string |
|
| 277 | - */ |
|
| 278 | - private function _visitor_ip() |
|
| 279 | - { |
|
| 280 | - $visitor_ip = '0.0.0.0'; |
|
| 281 | - $server_keys = array( |
|
| 282 | - 'HTTP_CLIENT_IP', |
|
| 283 | - 'HTTP_X_FORWARDED_FOR', |
|
| 284 | - 'HTTP_X_FORWARDED', |
|
| 285 | - 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 286 | - 'HTTP_FORWARDED_FOR', |
|
| 287 | - 'HTTP_FORWARDED', |
|
| 288 | - 'REMOTE_ADDR', |
|
| 289 | - ); |
|
| 290 | - foreach ($server_keys as $key) { |
|
| 291 | - if (isset($_SERVER[$key])) { |
|
| 292 | - foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
| 293 | - if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
| 294 | - $visitor_ip = $ip; |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - return $visitor_ip; |
|
| 300 | - } |
|
| 19 | + /** |
|
| 20 | + * $_GET parameters |
|
| 21 | + * |
|
| 22 | + * @var array $_get |
|
| 23 | + */ |
|
| 24 | + private $_get; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * $_POST parameters |
|
| 28 | + * |
|
| 29 | + * @var array $_post |
|
| 30 | + */ |
|
| 31 | + private $_post; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * $_COOKIE parameters |
|
| 35 | + * |
|
| 36 | + * @var array $_cookie |
|
| 37 | + */ |
|
| 38 | + private $_cookie; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * $_REQUEST parameters |
|
| 42 | + * |
|
| 43 | + * @var array $_params |
|
| 44 | + */ |
|
| 45 | + private $_params; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * whether current request is via AJAX |
|
| 49 | + * |
|
| 50 | + * @var boolean $ajax |
|
| 51 | + */ |
|
| 52 | + public $ajax; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * whether current request is via AJAX from the frontend of the site |
|
| 56 | + * |
|
| 57 | + * @var boolean $front_ajax |
|
| 58 | + */ |
|
| 59 | + public $front_ajax; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * IP address for request |
|
| 63 | + * |
|
| 64 | + * @var string $_ip_address |
|
| 65 | + */ |
|
| 66 | + private $_ip_address; |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * class constructor |
|
| 71 | + * |
|
| 72 | + * @access public |
|
| 73 | + * @param array $get |
|
| 74 | + * @param array $post |
|
| 75 | + * @param array $cookie |
|
| 76 | + */ |
|
| 77 | + public function __construct(array $get, array $post, array $cookie) |
|
| 78 | + { |
|
| 79 | + // grab request vars |
|
| 80 | + $this->_get = (array)$get; |
|
| 81 | + $this->_post = (array)$post; |
|
| 82 | + $this->_cookie = (array)$cookie; |
|
| 83 | + $this->_params = array_merge($this->_get, $this->_post); |
|
| 84 | + // AJAX ??? |
|
| 85 | + $this->ajax = defined('DOING_AJAX') && DOING_AJAX; |
|
| 86 | + $this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1; |
|
| 87 | + // grab user IP |
|
| 88 | + $this->_ip_address = $this->_visitor_ip(); |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @return array |
|
| 95 | + */ |
|
| 96 | + public function get_params() |
|
| 97 | + { |
|
| 98 | + return $this->_get; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @return array |
|
| 105 | + */ |
|
| 106 | + public function post_params() |
|
| 107 | + { |
|
| 108 | + return $this->_post; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return array |
|
| 115 | + */ |
|
| 116 | + public function cookie_params() |
|
| 117 | + { |
|
| 118 | + return $this->_cookie; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * returns contents of $_REQUEST |
|
| 125 | + * |
|
| 126 | + * @return array |
|
| 127 | + */ |
|
| 128 | + public function params() |
|
| 129 | + { |
|
| 130 | + return $this->_params; |
|
| 131 | + } |
|
| 132 | + |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @param $key |
|
| 137 | + * @param $value |
|
| 138 | + * @param bool $override_ee |
|
| 139 | + * @return void |
|
| 140 | + */ |
|
| 141 | + public function set($key, $value, $override_ee = false) |
|
| 142 | + { |
|
| 143 | + // don't allow "ee" to be overwritten unless explicitly instructed to do so |
|
| 144 | + if ( |
|
| 145 | + $key !== 'ee' |
|
| 146 | + || ($key === 'ee' && empty($this->_params['ee'])) |
|
| 147 | + || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee) |
|
| 148 | + ) { |
|
| 149 | + $this->_params[$key] = $value; |
|
| 150 | + } |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * returns the value for a request param if the given key exists |
|
| 157 | + * |
|
| 158 | + * @param $key |
|
| 159 | + * @param null $default |
|
| 160 | + * @return mixed |
|
| 161 | + */ |
|
| 162 | + public function get($key, $default = null) |
|
| 163 | + { |
|
| 164 | + return $this->request_parameter_drill_down($key, $default, 'get'); |
|
| 165 | + } |
|
| 166 | + |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * check if param exists |
|
| 171 | + * @param $key |
|
| 172 | + * @return bool |
|
| 173 | + */ |
|
| 174 | + public function is_set($key) |
|
| 175 | + { |
|
| 176 | + return $this->request_parameter_drill_down($key); |
|
| 177 | + } |
|
| 178 | + |
|
| 179 | + |
|
| 180 | + |
|
| 181 | + /** |
|
| 182 | + * the supplied key can be a simple string to represent a "top-level" request parameter |
|
| 183 | + * or represent a key for a request parameter that is nested deeper within the request parameter array, |
|
| 184 | + * by using square brackets to surround keys for deeper array elements. |
|
| 185 | + * For example : |
|
| 186 | + * if the supplied $key was: "first[second][third]" |
|
| 187 | + * then this will attempt to drill down into the request parameter array to find a value. |
|
| 188 | + * Given the following request parameters: |
|
| 189 | + * array( |
|
| 190 | + * 'first' => array( |
|
| 191 | + * 'second' => array( |
|
| 192 | + * 'third' => 'has a value' |
|
| 193 | + * ) |
|
| 194 | + * ) |
|
| 195 | + * ) |
|
| 196 | + * would return true |
|
| 197 | + * |
|
| 198 | + * @param string $is_set_or_get |
|
| 199 | + * @param $key |
|
| 200 | + * @param null $default |
|
| 201 | + * @param array $request_params |
|
| 202 | + * @return bool|mixed|null |
|
| 203 | + */ |
|
| 204 | + private function request_parameter_drill_down( |
|
| 205 | + $key, |
|
| 206 | + $default = null, |
|
| 207 | + $is_set_or_get = 'is_set', |
|
| 208 | + array $request_params = array() |
|
| 209 | + ) { |
|
| 210 | + $request_params = ! empty($request_params) |
|
| 211 | + ? $request_params |
|
| 212 | + : $this->_params; |
|
| 213 | + // does incoming key represent an array like 'first[second][third]' ? |
|
| 214 | + if (strpos($key, '[') !== false) { |
|
| 215 | + // turn it into an actual array |
|
| 216 | + $key = str_replace(']', '', $key); |
|
| 217 | + $keys = explode('[', $key); |
|
| 218 | + $key = array_shift($keys); |
|
| 219 | + // check if top level key exists |
|
| 220 | + if (isset($request_params[$key])) { |
|
| 221 | + // build a new key to pass along like: 'second[third]' |
|
| 222 | + // or just 'second' depending on depth of keys |
|
| 223 | + $key_string = array_shift($keys); |
|
| 224 | + if (! empty($keys)) { |
|
| 225 | + $key_string .= '[' . implode('][', $keys) . ']'; |
|
| 226 | + } |
|
| 227 | + return $this->request_parameter_drill_down( |
|
| 228 | + $key_string, |
|
| 229 | + $default, |
|
| 230 | + $is_set_or_get, |
|
| 231 | + $request_params[$key] |
|
| 232 | + ); |
|
| 233 | + } |
|
| 234 | + } |
|
| 235 | + if ($is_set_or_get === 'is_set') { |
|
| 236 | + return isset($request_params[$key]); |
|
| 237 | + } |
|
| 238 | + return isset($request_params[$key]) |
|
| 239 | + ? $request_params[$key] |
|
| 240 | + : $default; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * remove param |
|
| 247 | + * @param $key |
|
| 248 | + * @param bool $unset_from_global_too |
|
| 249 | + */ |
|
| 250 | + public function un_set($key, $unset_from_global_too = false) |
|
| 251 | + { |
|
| 252 | + unset($this->_params[$key]); |
|
| 253 | + if ($unset_from_global_too) { |
|
| 254 | + unset($_REQUEST[$key]); |
|
| 255 | + } |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + |
|
| 259 | + |
|
| 260 | + /** |
|
| 261 | + * @return string |
|
| 262 | + */ |
|
| 263 | + public function ip_address() |
|
| 264 | + { |
|
| 265 | + return $this->_ip_address; |
|
| 266 | + } |
|
| 267 | + |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * _visitor_ip |
|
| 272 | + * attempt to get IP address of current visitor from server |
|
| 273 | + * plz see: http://stackoverflow.com/a/2031935/1475279 |
|
| 274 | + * |
|
| 275 | + * @access public |
|
| 276 | + * @return string |
|
| 277 | + */ |
|
| 278 | + private function _visitor_ip() |
|
| 279 | + { |
|
| 280 | + $visitor_ip = '0.0.0.0'; |
|
| 281 | + $server_keys = array( |
|
| 282 | + 'HTTP_CLIENT_IP', |
|
| 283 | + 'HTTP_X_FORWARDED_FOR', |
|
| 284 | + 'HTTP_X_FORWARDED', |
|
| 285 | + 'HTTP_X_CLUSTER_CLIENT_IP', |
|
| 286 | + 'HTTP_FORWARDED_FOR', |
|
| 287 | + 'HTTP_FORWARDED', |
|
| 288 | + 'REMOTE_ADDR', |
|
| 289 | + ); |
|
| 290 | + foreach ($server_keys as $key) { |
|
| 291 | + if (isset($_SERVER[$key])) { |
|
| 292 | + foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) { |
|
| 293 | + if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) { |
|
| 294 | + $visitor_ip = $ip; |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + return $visitor_ip; |
|
| 300 | + } |
|
| 301 | 301 | |
| 302 | 302 | |
| 303 | 303 | |
@@ -77,13 +77,13 @@ discard block |
||
| 77 | 77 | public function __construct(array $get, array $post, array $cookie) |
| 78 | 78 | { |
| 79 | 79 | // grab request vars |
| 80 | - $this->_get = (array)$get; |
|
| 81 | - $this->_post = (array)$post; |
|
| 82 | - $this->_cookie = (array)$cookie; |
|
| 80 | + $this->_get = (array) $get; |
|
| 81 | + $this->_post = (array) $post; |
|
| 82 | + $this->_cookie = (array) $cookie; |
|
| 83 | 83 | $this->_params = array_merge($this->_get, $this->_post); |
| 84 | 84 | // AJAX ??? |
| 85 | 85 | $this->ajax = defined('DOING_AJAX') && DOING_AJAX; |
| 86 | - $this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1; |
|
| 86 | + $this->front_ajax = $this->is_set('ee_front_ajax') && (int) $this->get('ee_front_ajax') === 1; |
|
| 87 | 87 | // grab user IP |
| 88 | 88 | $this->_ip_address = $this->_visitor_ip(); |
| 89 | 89 | } |
@@ -221,8 +221,8 @@ discard block |
||
| 221 | 221 | // build a new key to pass along like: 'second[third]' |
| 222 | 222 | // or just 'second' depending on depth of keys |
| 223 | 223 | $key_string = array_shift($keys); |
| 224 | - if (! empty($keys)) { |
|
| 225 | - $key_string .= '[' . implode('][', $keys) . ']'; |
|
| 224 | + if ( ! empty($keys)) { |
|
| 225 | + $key_string .= '['.implode('][', $keys).']'; |
|
| 226 | 226 | } |
| 227 | 227 | return $this->request_parameter_drill_down( |
| 228 | 228 | $key_string, |