@@ -20,42 +20,42 @@ |
||
| 20 | 20 | class FilePath |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * @var string file_path |
|
| 25 | - */ |
|
| 26 | - private $file_path; |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * FilePath constructor. |
|
| 31 | - * |
|
| 32 | - * @param string $file_path |
|
| 33 | - * @throws InvalidDataTypeException |
|
| 34 | - * @throws InvalidFilePathException |
|
| 35 | - */ |
|
| 36 | - public function __construct($file_path) |
|
| 37 | - { |
|
| 38 | - if (! is_string($file_path)) { |
|
| 39 | - throw new InvalidDataTypeException( |
|
| 40 | - '$file_path', |
|
| 41 | - $file_path, |
|
| 42 | - 'string' |
|
| 43 | - ); |
|
| 44 | - } |
|
| 45 | - if (! is_readable($file_path)) { |
|
| 46 | - throw new InvalidFilePathException($file_path); |
|
| 47 | - } |
|
| 48 | - $this->file_path = $file_path; |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - public function __toString() |
|
| 56 | - { |
|
| 57 | - return $this->file_path; |
|
| 58 | - } |
|
| 23 | + /** |
|
| 24 | + * @var string file_path |
|
| 25 | + */ |
|
| 26 | + private $file_path; |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * FilePath constructor. |
|
| 31 | + * |
|
| 32 | + * @param string $file_path |
|
| 33 | + * @throws InvalidDataTypeException |
|
| 34 | + * @throws InvalidFilePathException |
|
| 35 | + */ |
|
| 36 | + public function __construct($file_path) |
|
| 37 | + { |
|
| 38 | + if (! is_string($file_path)) { |
|
| 39 | + throw new InvalidDataTypeException( |
|
| 40 | + '$file_path', |
|
| 41 | + $file_path, |
|
| 42 | + 'string' |
|
| 43 | + ); |
|
| 44 | + } |
|
| 45 | + if (! is_readable($file_path)) { |
|
| 46 | + throw new InvalidFilePathException($file_path); |
|
| 47 | + } |
|
| 48 | + $this->file_path = $file_path; |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + public function __toString() |
|
| 56 | + { |
|
| 57 | + return $this->file_path; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | 60 | |
| 61 | 61 | } |
@@ -35,14 +35,14 @@ |
||
| 35 | 35 | */ |
| 36 | 36 | public function __construct($file_path) |
| 37 | 37 | { |
| 38 | - if (! is_string($file_path)) { |
|
| 38 | + if ( ! is_string($file_path)) { |
|
| 39 | 39 | throw new InvalidDataTypeException( |
| 40 | 40 | '$file_path', |
| 41 | 41 | $file_path, |
| 42 | 42 | 'string' |
| 43 | 43 | ); |
| 44 | 44 | } |
| 45 | - if (! is_readable($file_path)) { |
|
| 45 | + if ( ! is_readable($file_path)) { |
|
| 46 | 46 | throw new InvalidFilePathException($file_path); |
| 47 | 47 | } |
| 48 | 48 | $this->file_path = $file_path; |
@@ -21,45 +21,45 @@ |
||
| 21 | 21 | class FullyQualifiedName |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var string $fully_qualified_name |
|
| 26 | - */ |
|
| 27 | - private $fully_qualified_name; |
|
| 24 | + /** |
|
| 25 | + * @var string $fully_qualified_name |
|
| 26 | + */ |
|
| 27 | + private $fully_qualified_name; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * FullyQualifiedName constructor. |
|
| 32 | - * |
|
| 33 | - * @param string $fully_qualified_name |
|
| 34 | - * @throws InvalidClassException |
|
| 35 | - * @throws InvalidInterfaceException |
|
| 36 | - * @throws InvalidDataTypeException |
|
| 37 | - */ |
|
| 38 | - public function __construct($fully_qualified_name) |
|
| 39 | - { |
|
| 40 | - if (! is_string($fully_qualified_name)) { |
|
| 41 | - throw new InvalidDataTypeException( |
|
| 42 | - '$fully_qualified_name', |
|
| 43 | - $fully_qualified_name, |
|
| 44 | - 'string' |
|
| 45 | - ); |
|
| 46 | - } |
|
| 47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
| 48 | - if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
| 49 | - throw new InvalidInterfaceException($fully_qualified_name); |
|
| 50 | - } |
|
| 51 | - throw new InvalidClassException($fully_qualified_name); |
|
| 52 | - } |
|
| 53 | - $this->fully_qualified_name = $fully_qualified_name; |
|
| 54 | - } |
|
| 30 | + /** |
|
| 31 | + * FullyQualifiedName constructor. |
|
| 32 | + * |
|
| 33 | + * @param string $fully_qualified_name |
|
| 34 | + * @throws InvalidClassException |
|
| 35 | + * @throws InvalidInterfaceException |
|
| 36 | + * @throws InvalidDataTypeException |
|
| 37 | + */ |
|
| 38 | + public function __construct($fully_qualified_name) |
|
| 39 | + { |
|
| 40 | + if (! is_string($fully_qualified_name)) { |
|
| 41 | + throw new InvalidDataTypeException( |
|
| 42 | + '$fully_qualified_name', |
|
| 43 | + $fully_qualified_name, |
|
| 44 | + 'string' |
|
| 45 | + ); |
|
| 46 | + } |
|
| 47 | + if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
| 48 | + if (strpos($fully_qualified_name, 'Interface') !== false) { |
|
| 49 | + throw new InvalidInterfaceException($fully_qualified_name); |
|
| 50 | + } |
|
| 51 | + throw new InvalidClassException($fully_qualified_name); |
|
| 52 | + } |
|
| 53 | + $this->fully_qualified_name = $fully_qualified_name; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | 56 | |
| 57 | - /** |
|
| 58 | - * @return string |
|
| 59 | - */ |
|
| 60 | - public function __toString() |
|
| 61 | - { |
|
| 62 | - return $this->fully_qualified_name; |
|
| 63 | - } |
|
| 57 | + /** |
|
| 58 | + * @return string |
|
| 59 | + */ |
|
| 60 | + public function __toString() |
|
| 61 | + { |
|
| 62 | + return $this->fully_qualified_name; |
|
| 63 | + } |
|
| 64 | 64 | |
| 65 | 65 | } |
@@ -37,14 +37,14 @@ |
||
| 37 | 37 | */ |
| 38 | 38 | public function __construct($fully_qualified_name) |
| 39 | 39 | { |
| 40 | - if (! is_string($fully_qualified_name)) { |
|
| 40 | + if ( ! is_string($fully_qualified_name)) { |
|
| 41 | 41 | throw new InvalidDataTypeException( |
| 42 | 42 | '$fully_qualified_name', |
| 43 | 43 | $fully_qualified_name, |
| 44 | 44 | 'string' |
| 45 | 45 | ); |
| 46 | 46 | } |
| 47 | - if (! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
| 47 | + if ( ! class_exists($fully_qualified_name) && ! interface_exists($fully_qualified_name)) { |
|
| 48 | 48 | if (strpos($fully_qualified_name, 'Interface') !== false) { |
| 49 | 49 | throw new InvalidInterfaceException($fully_qualified_name); |
| 50 | 50 | } |
@@ -28,219 +28,219 @@ |
||
| 28 | 28 | class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var EE_Request $request |
|
| 33 | - */ |
|
| 34 | - protected $request; |
|
| 31 | + /** |
|
| 32 | + * @var EE_Request $request |
|
| 33 | + */ |
|
| 34 | + protected $request; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var EE_Response $response |
|
| 38 | - */ |
|
| 39 | - protected $response; |
|
| 36 | + /** |
|
| 37 | + * @var EE_Response $response |
|
| 38 | + */ |
|
| 39 | + protected $response; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var EE_Dependency_Map $dependency_map |
|
| 43 | - */ |
|
| 44 | - protected $dependency_map; |
|
| 41 | + /** |
|
| 42 | + * @var EE_Dependency_Map $dependency_map |
|
| 43 | + */ |
|
| 44 | + protected $dependency_map; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var EE_Registry $registry |
|
| 48 | - */ |
|
| 49 | - protected $registry; |
|
| 46 | + /** |
|
| 47 | + * @var EE_Registry $registry |
|
| 48 | + */ |
|
| 49 | + protected $registry; |
|
| 50 | 50 | |
| 51 | 51 | |
| 52 | 52 | |
| 53 | - /** |
|
| 54 | - * EE_Load_Espresso_Core constructor |
|
| 55 | - */ |
|
| 53 | + /** |
|
| 54 | + * EE_Load_Espresso_Core constructor |
|
| 55 | + */ |
|
| 56 | 56 | public function __construct() { |
| 57 | - // deprecated functions |
|
| 58 | - espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
| 59 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * handle |
|
| 66 | - * sets hooks for running rest of system |
|
| 67 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 68 | - * starting EE Addons from any other point may lead to problems |
|
| 69 | - * |
|
| 70 | - * @param EE_Request $request |
|
| 71 | - * @param EE_Response $response |
|
| 72 | - * @return EE_Response |
|
| 73 | - * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
| 74 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 75 | - * @throws EE_Error |
|
| 76 | - * @throws InvalidDataTypeException |
|
| 77 | - * @throws InvalidInterfaceException |
|
| 78 | - * @throws InvalidArgumentException |
|
| 79 | - */ |
|
| 80 | - public function handle_request(EE_Request $request, EE_Response $response) |
|
| 81 | - { |
|
| 82 | - $this->request = $request; |
|
| 83 | - $this->response = $response; |
|
| 84 | - // info about how to load classes required by other classes |
|
| 85 | - $this->dependency_map = $this->_load_dependency_map(); |
|
| 86 | - // central repository for classes |
|
| 87 | - $this->registry = $this->_load_registry(); |
|
| 88 | - do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 89 | - $loader = LoaderFactory::getLoader($this->registry); |
|
| 90 | - $this->dependency_map->setLoader($loader); |
|
| 91 | - // instantiate core Domain class |
|
| 92 | - DomainFactory::getShared( |
|
| 93 | - new FullyQualifiedName( |
|
| 94 | - 'EventEspresso\core\domain\Domain' |
|
| 95 | - ), |
|
| 96 | - array( |
|
| 97 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
| 98 | - Version::fromString(espresso_version()) |
|
| 99 | - ) |
|
| 100 | - ); |
|
| 101 | - // build DI container |
|
| 102 | - // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 103 | - // $OpenCoffeeShop->addRecipes(); |
|
| 104 | - // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 105 | - // workarounds for PHP < 5.3 |
|
| 106 | - $this->_load_class_tools(); |
|
| 107 | - // deprecated functions |
|
| 108 | - espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 109 | - // WP cron jobs |
|
| 110 | - $loader->getShared('EE_Cron_Tasks'); |
|
| 111 | - $loader->getShared('EE_Request_Handler'); |
|
| 112 | - $loader->getShared('EE_System'); |
|
| 113 | - return $this->response; |
|
| 114 | - } |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @return EE_Request |
|
| 120 | - */ |
|
| 121 | - public function request() |
|
| 122 | - { |
|
| 123 | - return $this->request; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - |
|
| 128 | - /** |
|
| 129 | - * @return EE_Response |
|
| 130 | - */ |
|
| 131 | - public function response() |
|
| 132 | - { |
|
| 133 | - return $this->response; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @return EE_Dependency_Map |
|
| 140 | - * @throws EE_Error |
|
| 141 | - */ |
|
| 142 | - public function dependency_map() |
|
| 143 | - { |
|
| 144 | - if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 145 | - throw new EE_Error( |
|
| 146 | - sprintf( |
|
| 147 | - __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 148 | - print_r($this->dependency_map, true) |
|
| 149 | - ) |
|
| 150 | - ); |
|
| 151 | - } |
|
| 152 | - return $this->dependency_map; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @return EE_Registry |
|
| 159 | - * @throws EE_Error |
|
| 160 | - */ |
|
| 161 | - public function registry() |
|
| 162 | - { |
|
| 163 | - if (! $this->registry instanceof EE_Registry) { |
|
| 164 | - throw new EE_Error( |
|
| 165 | - sprintf( |
|
| 166 | - __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 167 | - print_r($this->registry, true) |
|
| 168 | - ) |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - return $this->registry; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - /** |
|
| 177 | - * @return EE_Dependency_Map |
|
| 178 | - */ |
|
| 179 | - private function _load_dependency_map() |
|
| 180 | - { |
|
| 181 | - if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
| 182 | - EE_Error::add_error( |
|
| 183 | - __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 184 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 185 | - ); |
|
| 186 | - wp_die(EE_Error::get_notices()); |
|
| 187 | - } |
|
| 188 | - require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
| 189 | - return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 190 | - } |
|
| 191 | - |
|
| 192 | - |
|
| 193 | - |
|
| 194 | - /** |
|
| 195 | - * @return EE_Registry |
|
| 196 | - * @throws \InvalidArgumentException |
|
| 197 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 198 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 199 | - */ |
|
| 200 | - private function _load_registry() |
|
| 201 | - { |
|
| 202 | - if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
| 203 | - EE_Error::add_error( |
|
| 204 | - __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 205 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 206 | - ); |
|
| 207 | - wp_die(EE_Error::get_notices()); |
|
| 208 | - } |
|
| 209 | - require_once(EE_CORE . 'EE_Registry.core.php'); |
|
| 210 | - return EE_Registry::instance($this->dependency_map); |
|
| 211 | - } |
|
| 212 | - |
|
| 213 | - |
|
| 214 | - |
|
| 215 | - /** |
|
| 216 | - * @return void |
|
| 217 | - */ |
|
| 218 | - private function _load_class_tools() |
|
| 219 | - { |
|
| 220 | - if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
| 221 | - EE_Error::add_error( |
|
| 222 | - __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 223 | - __FILE__, __FUNCTION__, __LINE__ |
|
| 224 | - ); |
|
| 225 | - } |
|
| 226 | - require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
| 227 | - } |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - |
|
| 231 | - /** |
|
| 232 | - * called after the request stack has been fully processed |
|
| 233 | - * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
| 234 | - * |
|
| 235 | - * @param EE_Request $request |
|
| 236 | - * @param EE_Response $response |
|
| 237 | - */ |
|
| 238 | - public function handle_response(EE_Request $request, EE_Response $response) |
|
| 239 | - { |
|
| 240 | - if ($response->plugin_deactivated()) { |
|
| 241 | - espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 242 | - } |
|
| 243 | - } |
|
| 57 | + // deprecated functions |
|
| 58 | + espresso_load_required('EE_Base', EE_CORE . 'EE_Base.core.php'); |
|
| 59 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * handle |
|
| 66 | + * sets hooks for running rest of system |
|
| 67 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 68 | + * starting EE Addons from any other point may lead to problems |
|
| 69 | + * |
|
| 70 | + * @param EE_Request $request |
|
| 71 | + * @param EE_Response $response |
|
| 72 | + * @return EE_Response |
|
| 73 | + * @throws \EventEspresso\core\exceptions\InvalidFilePathException |
|
| 74 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 75 | + * @throws EE_Error |
|
| 76 | + * @throws InvalidDataTypeException |
|
| 77 | + * @throws InvalidInterfaceException |
|
| 78 | + * @throws InvalidArgumentException |
|
| 79 | + */ |
|
| 80 | + public function handle_request(EE_Request $request, EE_Response $response) |
|
| 81 | + { |
|
| 82 | + $this->request = $request; |
|
| 83 | + $this->response = $response; |
|
| 84 | + // info about how to load classes required by other classes |
|
| 85 | + $this->dependency_map = $this->_load_dependency_map(); |
|
| 86 | + // central repository for classes |
|
| 87 | + $this->registry = $this->_load_registry(); |
|
| 88 | + do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading'); |
|
| 89 | + $loader = LoaderFactory::getLoader($this->registry); |
|
| 90 | + $this->dependency_map->setLoader($loader); |
|
| 91 | + // instantiate core Domain class |
|
| 92 | + DomainFactory::getShared( |
|
| 93 | + new FullyQualifiedName( |
|
| 94 | + 'EventEspresso\core\domain\Domain' |
|
| 95 | + ), |
|
| 96 | + array( |
|
| 97 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
| 98 | + Version::fromString(espresso_version()) |
|
| 99 | + ) |
|
| 100 | + ); |
|
| 101 | + // build DI container |
|
| 102 | + // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop(); |
|
| 103 | + // $OpenCoffeeShop->addRecipes(); |
|
| 104 | + // $CoffeeShop = $OpenCoffeeShop->CoffeeShop(); |
|
| 105 | + // workarounds for PHP < 5.3 |
|
| 106 | + $this->_load_class_tools(); |
|
| 107 | + // deprecated functions |
|
| 108 | + espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php'); |
|
| 109 | + // WP cron jobs |
|
| 110 | + $loader->getShared('EE_Cron_Tasks'); |
|
| 111 | + $loader->getShared('EE_Request_Handler'); |
|
| 112 | + $loader->getShared('EE_System'); |
|
| 113 | + return $this->response; |
|
| 114 | + } |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @return EE_Request |
|
| 120 | + */ |
|
| 121 | + public function request() |
|
| 122 | + { |
|
| 123 | + return $this->request; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + |
|
| 128 | + /** |
|
| 129 | + * @return EE_Response |
|
| 130 | + */ |
|
| 131 | + public function response() |
|
| 132 | + { |
|
| 133 | + return $this->response; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @return EE_Dependency_Map |
|
| 140 | + * @throws EE_Error |
|
| 141 | + */ |
|
| 142 | + public function dependency_map() |
|
| 143 | + { |
|
| 144 | + if (! $this->dependency_map instanceof EE_Dependency_Map) { |
|
| 145 | + throw new EE_Error( |
|
| 146 | + sprintf( |
|
| 147 | + __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'), |
|
| 148 | + print_r($this->dependency_map, true) |
|
| 149 | + ) |
|
| 150 | + ); |
|
| 151 | + } |
|
| 152 | + return $this->dependency_map; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @return EE_Registry |
|
| 159 | + * @throws EE_Error |
|
| 160 | + */ |
|
| 161 | + public function registry() |
|
| 162 | + { |
|
| 163 | + if (! $this->registry instanceof EE_Registry) { |
|
| 164 | + throw new EE_Error( |
|
| 165 | + sprintf( |
|
| 166 | + __('Invalid EE_Registry: "%1$s"', 'event_espresso'), |
|
| 167 | + print_r($this->registry, true) |
|
| 168 | + ) |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + return $this->registry; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + /** |
|
| 177 | + * @return EE_Dependency_Map |
|
| 178 | + */ |
|
| 179 | + private function _load_dependency_map() |
|
| 180 | + { |
|
| 181 | + if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) { |
|
| 182 | + EE_Error::add_error( |
|
| 183 | + __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'), |
|
| 184 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 185 | + ); |
|
| 186 | + wp_die(EE_Error::get_notices()); |
|
| 187 | + } |
|
| 188 | + require_once(EE_CORE . 'EE_Dependency_Map.core.php'); |
|
| 189 | + return EE_Dependency_Map::instance($this->request, $this->response); |
|
| 190 | + } |
|
| 191 | + |
|
| 192 | + |
|
| 193 | + |
|
| 194 | + /** |
|
| 195 | + * @return EE_Registry |
|
| 196 | + * @throws \InvalidArgumentException |
|
| 197 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 198 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 199 | + */ |
|
| 200 | + private function _load_registry() |
|
| 201 | + { |
|
| 202 | + if (! is_readable(EE_CORE . 'EE_Registry.core.php')) { |
|
| 203 | + EE_Error::add_error( |
|
| 204 | + __('The EE_Registry core class could not be loaded.', 'event_espresso'), |
|
| 205 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 206 | + ); |
|
| 207 | + wp_die(EE_Error::get_notices()); |
|
| 208 | + } |
|
| 209 | + require_once(EE_CORE . 'EE_Registry.core.php'); |
|
| 210 | + return EE_Registry::instance($this->dependency_map); |
|
| 211 | + } |
|
| 212 | + |
|
| 213 | + |
|
| 214 | + |
|
| 215 | + /** |
|
| 216 | + * @return void |
|
| 217 | + */ |
|
| 218 | + private function _load_class_tools() |
|
| 219 | + { |
|
| 220 | + if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) { |
|
| 221 | + EE_Error::add_error( |
|
| 222 | + __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'), |
|
| 223 | + __FILE__, __FUNCTION__, __LINE__ |
|
| 224 | + ); |
|
| 225 | + } |
|
| 226 | + require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php'); |
|
| 227 | + } |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + |
|
| 231 | + /** |
|
| 232 | + * called after the request stack has been fully processed |
|
| 233 | + * if any of the middleware apps has requested the plugin be deactivated, then we do that now |
|
| 234 | + * |
|
| 235 | + * @param EE_Request $request |
|
| 236 | + * @param EE_Response $response |
|
| 237 | + */ |
|
| 238 | + public function handle_response(EE_Request $request, EE_Response $response) |
|
| 239 | + { |
|
| 240 | + if ($response->plugin_deactivated()) { |
|
| 241 | + espresso_deactivate_plugin(EE_PLUGIN_BASENAME); |
|
| 242 | + } |
|
| 243 | + } |
|
| 244 | 244 | |
| 245 | 245 | |
| 246 | 246 | |
@@ -121,7 +121,7 @@ |
||
| 121 | 121 | |
| 122 | 122 | |
| 123 | 123 | /** |
| 124 | - * @return Version |
|
| 124 | + * @return string |
|
| 125 | 125 | */ |
| 126 | 126 | public function versionValueObject() |
| 127 | 127 | { |
@@ -21,112 +21,112 @@ |
||
| 21 | 21 | abstract class DomainBase implements DomainInterface |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * Equivalent to `__FILE__` for main plugin file. |
|
| 26 | - * |
|
| 27 | - * @var FilePath |
|
| 28 | - */ |
|
| 29 | - private $plugin_file; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * String indicating version for plugin |
|
| 33 | - * |
|
| 34 | - * @var string |
|
| 35 | - */ |
|
| 36 | - private $version; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * @var string $plugin_basename |
|
| 40 | - */ |
|
| 41 | - private $plugin_basename; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * @var string $plugin_path |
|
| 45 | - */ |
|
| 46 | - private $plugin_path; |
|
| 47 | - |
|
| 48 | - /** |
|
| 49 | - * @var string $plugin_url |
|
| 50 | - */ |
|
| 51 | - private $plugin_url; |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * Initializes internal properties. |
|
| 57 | - * |
|
| 58 | - * @param FilePath $plugin_file |
|
| 59 | - * @param Version $version |
|
| 60 | - * @throws InvalidArgumentException |
|
| 61 | - * @throws DomainException |
|
| 62 | - */ |
|
| 63 | - public function __construct(FilePath $plugin_file, Version $version) |
|
| 64 | - { |
|
| 65 | - $this->plugin_file = $plugin_file; |
|
| 66 | - $this->version = $version; |
|
| 67 | - $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
| 68 | - $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
| 69 | - $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * @return string |
|
| 75 | - */ |
|
| 76 | - public function pluginFile() |
|
| 77 | - { |
|
| 78 | - return (string) $this->plugin_file; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @return string |
|
| 85 | - */ |
|
| 86 | - public function pluginBasename() |
|
| 87 | - { |
|
| 88 | - return $this->plugin_basename; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @return string |
|
| 95 | - */ |
|
| 96 | - public function pluginPath() |
|
| 97 | - { |
|
| 98 | - return $this->plugin_path; |
|
| 99 | - } |
|
| 100 | - |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @return string |
|
| 105 | - */ |
|
| 106 | - public function pluginUrl() |
|
| 107 | - { |
|
| 108 | - return $this->plugin_url; |
|
| 109 | - } |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - |
|
| 113 | - /** |
|
| 114 | - * @return string |
|
| 115 | - */ |
|
| 116 | - public function version() |
|
| 117 | - { |
|
| 118 | - return (string) $this->version; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * @return Version |
|
| 125 | - */ |
|
| 126 | - public function versionValueObject() |
|
| 127 | - { |
|
| 128 | - return $this->version; |
|
| 129 | - } |
|
| 24 | + /** |
|
| 25 | + * Equivalent to `__FILE__` for main plugin file. |
|
| 26 | + * |
|
| 27 | + * @var FilePath |
|
| 28 | + */ |
|
| 29 | + private $plugin_file; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * String indicating version for plugin |
|
| 33 | + * |
|
| 34 | + * @var string |
|
| 35 | + */ |
|
| 36 | + private $version; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * @var string $plugin_basename |
|
| 40 | + */ |
|
| 41 | + private $plugin_basename; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * @var string $plugin_path |
|
| 45 | + */ |
|
| 46 | + private $plugin_path; |
|
| 47 | + |
|
| 48 | + /** |
|
| 49 | + * @var string $plugin_url |
|
| 50 | + */ |
|
| 51 | + private $plugin_url; |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * Initializes internal properties. |
|
| 57 | + * |
|
| 58 | + * @param FilePath $plugin_file |
|
| 59 | + * @param Version $version |
|
| 60 | + * @throws InvalidArgumentException |
|
| 61 | + * @throws DomainException |
|
| 62 | + */ |
|
| 63 | + public function __construct(FilePath $plugin_file, Version $version) |
|
| 64 | + { |
|
| 65 | + $this->plugin_file = $plugin_file; |
|
| 66 | + $this->version = $version; |
|
| 67 | + $this->plugin_basename = plugin_basename($this->pluginFile()); |
|
| 68 | + $this->plugin_path = plugin_dir_path($this->pluginFile()); |
|
| 69 | + $this->plugin_url = plugin_dir_url($this->pluginFile()); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * @return string |
|
| 75 | + */ |
|
| 76 | + public function pluginFile() |
|
| 77 | + { |
|
| 78 | + return (string) $this->plugin_file; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @return string |
|
| 85 | + */ |
|
| 86 | + public function pluginBasename() |
|
| 87 | + { |
|
| 88 | + return $this->plugin_basename; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @return string |
|
| 95 | + */ |
|
| 96 | + public function pluginPath() |
|
| 97 | + { |
|
| 98 | + return $this->plugin_path; |
|
| 99 | + } |
|
| 100 | + |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @return string |
|
| 105 | + */ |
|
| 106 | + public function pluginUrl() |
|
| 107 | + { |
|
| 108 | + return $this->plugin_url; |
|
| 109 | + } |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + |
|
| 113 | + /** |
|
| 114 | + * @return string |
|
| 115 | + */ |
|
| 116 | + public function version() |
|
| 117 | + { |
|
| 118 | + return (string) $this->version; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * @return Version |
|
| 125 | + */ |
|
| 126 | + public function versionValueObject() |
|
| 127 | + { |
|
| 128 | + return $this->version; |
|
| 129 | + } |
|
| 130 | 130 | |
| 131 | 131 | |
| 132 | 132 | } |
@@ -20,297 +20,297 @@ |
||
| 20 | 20 | class Version |
| 21 | 21 | { |
| 22 | 22 | |
| 23 | - const RELEASE_TYPE_RC = 'rc'; |
|
| 24 | - |
|
| 25 | - const RELEASE_TYPE_BETA = 'beta'; |
|
| 26 | - |
|
| 27 | - const RELEASE_TYPE_DECAF = 'decaf'; |
|
| 28 | - |
|
| 29 | - const RELEASE_TYPE_PROD = 'p'; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var int $major |
|
| 33 | - */ |
|
| 34 | - private $major; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var int $minor |
|
| 38 | - */ |
|
| 39 | - private $minor; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var int $patch |
|
| 43 | - */ |
|
| 44 | - private $patch; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string $release |
|
| 48 | - */ |
|
| 49 | - private $release; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @var int $build |
|
| 53 | - */ |
|
| 54 | - private $build; |
|
| 55 | - |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * Version constructor. |
|
| 59 | - * |
|
| 60 | - * @param int $major |
|
| 61 | - * @param int $minor |
|
| 62 | - * @param int $patch |
|
| 63 | - * @param string $release |
|
| 64 | - * @param int $build |
|
| 65 | - * @throws InvalidDataTypeException |
|
| 66 | - * @throws InvalidArgumentException |
|
| 67 | - */ |
|
| 68 | - public function __construct($major, $minor, $patch, $release = Version::RELEASE_TYPE_PROD, $build = 0) |
|
| 69 | - { |
|
| 70 | - $this->setMajor($major); |
|
| 71 | - $this->setMinor($minor); |
|
| 72 | - $this->setPatch($patch); |
|
| 73 | - $this->setRelease($release); |
|
| 74 | - $this->setBuild($build); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @param string $version_string |
|
| 80 | - * @return Version |
|
| 81 | - * @throws InvalidArgumentException |
|
| 82 | - */ |
|
| 83 | - public static function fromString($version_string) |
|
| 84 | - { |
|
| 85 | - // compare incoming version string against the lowest possible valid version |
|
| 86 | - if (version_compare($version_string, '0.0.1.dev.001', '<')) { |
|
| 87 | - throw new InvalidArgumentException( |
|
| 88 | - sprintf( |
|
| 89 | - esc_html__('"%1$s" is not a valid version string', 'event_espresso'), |
|
| 90 | - $version_string |
|
| 91 | - ) |
|
| 92 | - ); |
|
| 93 | - } |
|
| 94 | - // break apart incoming version string |
|
| 95 | - $version_parts = explode('.', $version_string); |
|
| 96 | - // verify that version string at least contains {major}.{minor}.{patch} |
|
| 97 | - if (count($version_parts) < 3) { |
|
| 98 | - throw new InvalidArgumentException( |
|
| 99 | - sprintf( |
|
| 100 | - esc_html__( |
|
| 101 | - 'At minimum, a version string needs to be in a "{major}.{minor}.{patch}" format, therefore "%1$s" is not valid', |
|
| 102 | - 'event_espresso' |
|
| 103 | - ), |
|
| 104 | - $version_string |
|
| 105 | - ) |
|
| 106 | - ); |
|
| 107 | - } |
|
| 108 | - // add defaults for missing pieces |
|
| 109 | - $version_parts += array(0,0,0,'p',0); |
|
| 110 | - // reassign to individual variables |
|
| 111 | - list($major, $minor, $patch, $release, $build) = $version_parts; |
|
| 112 | - return new Version( |
|
| 113 | - (int) $major, |
|
| 114 | - (int) $minor, |
|
| 115 | - (int) $patch, |
|
| 116 | - $release, |
|
| 117 | - (int) $build |
|
| 118 | - ); |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @return int |
|
| 124 | - */ |
|
| 125 | - public function major() |
|
| 126 | - { |
|
| 127 | - return $this->major; |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * @param int|string $major |
|
| 133 | - * @throws InvalidDataTypeException |
|
| 134 | - */ |
|
| 135 | - private function setMajor($major) |
|
| 136 | - { |
|
| 137 | - if (! is_int($major)) { |
|
| 138 | - throw new InvalidDataTypeException( |
|
| 139 | - '$major', |
|
| 140 | - $major, |
|
| 141 | - 'integer' |
|
| 142 | - ); |
|
| 143 | - } |
|
| 144 | - $this->major = absint($major); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * @return int |
|
| 150 | - */ |
|
| 151 | - public function minor() |
|
| 152 | - { |
|
| 153 | - return $this->minor; |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - /** |
|
| 158 | - * @param int|string $minor |
|
| 159 | - * @throws InvalidDataTypeException |
|
| 160 | - */ |
|
| 161 | - private function setMinor($minor) |
|
| 162 | - { |
|
| 163 | - if (! is_int($minor)) { |
|
| 164 | - throw new InvalidDataTypeException( |
|
| 165 | - '$minor', |
|
| 166 | - $minor, |
|
| 167 | - 'integer' |
|
| 168 | - ); |
|
| 169 | - } |
|
| 170 | - $this->minor = absint($minor); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * @return int |
|
| 176 | - */ |
|
| 177 | - public function patch() |
|
| 178 | - { |
|
| 179 | - return $this->patch; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - |
|
| 183 | - /** |
|
| 184 | - * @param int|string $patch |
|
| 185 | - * @throws InvalidDataTypeException |
|
| 186 | - */ |
|
| 187 | - private function setPatch($patch) |
|
| 188 | - { |
|
| 189 | - if (! is_int($patch)) { |
|
| 190 | - throw new InvalidDataTypeException( |
|
| 191 | - '$patch', |
|
| 192 | - $patch, |
|
| 193 | - 'integer' |
|
| 194 | - ); |
|
| 195 | - } |
|
| 196 | - $this->patch = absint($patch); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @return string |
|
| 202 | - */ |
|
| 203 | - public function release() |
|
| 204 | - { |
|
| 205 | - return $this->release; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * @param string $release |
|
| 211 | - * @throws InvalidArgumentException |
|
| 212 | - */ |
|
| 213 | - private function setRelease($release) |
|
| 214 | - { |
|
| 215 | - $valid_release_types = array( |
|
| 216 | - Version::RELEASE_TYPE_RC, |
|
| 217 | - Version::RELEASE_TYPE_BETA, |
|
| 218 | - Version::RELEASE_TYPE_DECAF, |
|
| 219 | - Version::RELEASE_TYPE_PROD, |
|
| 220 | - ); |
|
| 221 | - if (! in_array($release, $valid_release_types, true)) { |
|
| 222 | - throw new InvalidArgumentException( |
|
| 223 | - sprintf( |
|
| 224 | - esc_html__( |
|
| 225 | - '"%1$s" is not a valid release type. Please use one of the following values: %2$s', |
|
| 226 | - 'event_espresso' |
|
| 227 | - ), |
|
| 228 | - $release, |
|
| 229 | - implode(', ', $valid_release_types) |
|
| 230 | - ) |
|
| 231 | - ); |
|
| 232 | - } |
|
| 233 | - $this->release = $release; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - /** |
|
| 238 | - * @return int |
|
| 239 | - */ |
|
| 240 | - public function build() |
|
| 241 | - { |
|
| 242 | - return $this->build; |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - /** |
|
| 247 | - * @param int|string $build |
|
| 248 | - * @throws InvalidDataTypeException |
|
| 249 | - */ |
|
| 250 | - private function setBuild($build) |
|
| 251 | - { |
|
| 252 | - if (! is_int($build)) { |
|
| 253 | - throw new InvalidDataTypeException( |
|
| 254 | - '$build', |
|
| 255 | - $build, |
|
| 256 | - 'integer' |
|
| 257 | - ); |
|
| 258 | - } |
|
| 259 | - $this->build = absint($build); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * @param Version $other_version |
|
| 265 | - * @return int |
|
| 266 | - */ |
|
| 267 | - public function compare(Version $other_version) |
|
| 268 | - { |
|
| 269 | - return version_compare((string) $this, (string) $other_version); |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - |
|
| 273 | - /** |
|
| 274 | - * @param Version $other_version |
|
| 275 | - * @return bool |
|
| 276 | - */ |
|
| 277 | - public function equals(Version $other_version) |
|
| 278 | - { |
|
| 279 | - return version_compare((string) $this, (string) $other_version, '=='); |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - /** |
|
| 284 | - * @param Version $other_version |
|
| 285 | - * @return bool |
|
| 286 | - */ |
|
| 287 | - public function newerThan(Version $other_version) |
|
| 288 | - { |
|
| 289 | - return version_compare((string) $this, (string) $other_version, '>'); |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @param Version $other_version |
|
| 295 | - * @return bool |
|
| 296 | - */ |
|
| 297 | - public function olderThan(Version $other_version) |
|
| 298 | - { |
|
| 299 | - return version_compare((string) $this, (string) $other_version, '<'); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * @return string |
|
| 305 | - */ |
|
| 306 | - public function __toString() |
|
| 307 | - { |
|
| 308 | - $version_string = "{$this->major}.{$this->minor}.{$this->patch}.{$this->release}"; |
|
| 309 | - if($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) { |
|
| 310 | - $version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT); |
|
| 311 | - } |
|
| 312 | - return $version_string; |
|
| 313 | - } |
|
| 23 | + const RELEASE_TYPE_RC = 'rc'; |
|
| 24 | + |
|
| 25 | + const RELEASE_TYPE_BETA = 'beta'; |
|
| 26 | + |
|
| 27 | + const RELEASE_TYPE_DECAF = 'decaf'; |
|
| 28 | + |
|
| 29 | + const RELEASE_TYPE_PROD = 'p'; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var int $major |
|
| 33 | + */ |
|
| 34 | + private $major; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var int $minor |
|
| 38 | + */ |
|
| 39 | + private $minor; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var int $patch |
|
| 43 | + */ |
|
| 44 | + private $patch; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string $release |
|
| 48 | + */ |
|
| 49 | + private $release; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @var int $build |
|
| 53 | + */ |
|
| 54 | + private $build; |
|
| 55 | + |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * Version constructor. |
|
| 59 | + * |
|
| 60 | + * @param int $major |
|
| 61 | + * @param int $minor |
|
| 62 | + * @param int $patch |
|
| 63 | + * @param string $release |
|
| 64 | + * @param int $build |
|
| 65 | + * @throws InvalidDataTypeException |
|
| 66 | + * @throws InvalidArgumentException |
|
| 67 | + */ |
|
| 68 | + public function __construct($major, $minor, $patch, $release = Version::RELEASE_TYPE_PROD, $build = 0) |
|
| 69 | + { |
|
| 70 | + $this->setMajor($major); |
|
| 71 | + $this->setMinor($minor); |
|
| 72 | + $this->setPatch($patch); |
|
| 73 | + $this->setRelease($release); |
|
| 74 | + $this->setBuild($build); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @param string $version_string |
|
| 80 | + * @return Version |
|
| 81 | + * @throws InvalidArgumentException |
|
| 82 | + */ |
|
| 83 | + public static function fromString($version_string) |
|
| 84 | + { |
|
| 85 | + // compare incoming version string against the lowest possible valid version |
|
| 86 | + if (version_compare($version_string, '0.0.1.dev.001', '<')) { |
|
| 87 | + throw new InvalidArgumentException( |
|
| 88 | + sprintf( |
|
| 89 | + esc_html__('"%1$s" is not a valid version string', 'event_espresso'), |
|
| 90 | + $version_string |
|
| 91 | + ) |
|
| 92 | + ); |
|
| 93 | + } |
|
| 94 | + // break apart incoming version string |
|
| 95 | + $version_parts = explode('.', $version_string); |
|
| 96 | + // verify that version string at least contains {major}.{minor}.{patch} |
|
| 97 | + if (count($version_parts) < 3) { |
|
| 98 | + throw new InvalidArgumentException( |
|
| 99 | + sprintf( |
|
| 100 | + esc_html__( |
|
| 101 | + 'At minimum, a version string needs to be in a "{major}.{minor}.{patch}" format, therefore "%1$s" is not valid', |
|
| 102 | + 'event_espresso' |
|
| 103 | + ), |
|
| 104 | + $version_string |
|
| 105 | + ) |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | + // add defaults for missing pieces |
|
| 109 | + $version_parts += array(0,0,0,'p',0); |
|
| 110 | + // reassign to individual variables |
|
| 111 | + list($major, $minor, $patch, $release, $build) = $version_parts; |
|
| 112 | + return new Version( |
|
| 113 | + (int) $major, |
|
| 114 | + (int) $minor, |
|
| 115 | + (int) $patch, |
|
| 116 | + $release, |
|
| 117 | + (int) $build |
|
| 118 | + ); |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @return int |
|
| 124 | + */ |
|
| 125 | + public function major() |
|
| 126 | + { |
|
| 127 | + return $this->major; |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * @param int|string $major |
|
| 133 | + * @throws InvalidDataTypeException |
|
| 134 | + */ |
|
| 135 | + private function setMajor($major) |
|
| 136 | + { |
|
| 137 | + if (! is_int($major)) { |
|
| 138 | + throw new InvalidDataTypeException( |
|
| 139 | + '$major', |
|
| 140 | + $major, |
|
| 141 | + 'integer' |
|
| 142 | + ); |
|
| 143 | + } |
|
| 144 | + $this->major = absint($major); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * @return int |
|
| 150 | + */ |
|
| 151 | + public function minor() |
|
| 152 | + { |
|
| 153 | + return $this->minor; |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + /** |
|
| 158 | + * @param int|string $minor |
|
| 159 | + * @throws InvalidDataTypeException |
|
| 160 | + */ |
|
| 161 | + private function setMinor($minor) |
|
| 162 | + { |
|
| 163 | + if (! is_int($minor)) { |
|
| 164 | + throw new InvalidDataTypeException( |
|
| 165 | + '$minor', |
|
| 166 | + $minor, |
|
| 167 | + 'integer' |
|
| 168 | + ); |
|
| 169 | + } |
|
| 170 | + $this->minor = absint($minor); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * @return int |
|
| 176 | + */ |
|
| 177 | + public function patch() |
|
| 178 | + { |
|
| 179 | + return $this->patch; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + |
|
| 183 | + /** |
|
| 184 | + * @param int|string $patch |
|
| 185 | + * @throws InvalidDataTypeException |
|
| 186 | + */ |
|
| 187 | + private function setPatch($patch) |
|
| 188 | + { |
|
| 189 | + if (! is_int($patch)) { |
|
| 190 | + throw new InvalidDataTypeException( |
|
| 191 | + '$patch', |
|
| 192 | + $patch, |
|
| 193 | + 'integer' |
|
| 194 | + ); |
|
| 195 | + } |
|
| 196 | + $this->patch = absint($patch); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @return string |
|
| 202 | + */ |
|
| 203 | + public function release() |
|
| 204 | + { |
|
| 205 | + return $this->release; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * @param string $release |
|
| 211 | + * @throws InvalidArgumentException |
|
| 212 | + */ |
|
| 213 | + private function setRelease($release) |
|
| 214 | + { |
|
| 215 | + $valid_release_types = array( |
|
| 216 | + Version::RELEASE_TYPE_RC, |
|
| 217 | + Version::RELEASE_TYPE_BETA, |
|
| 218 | + Version::RELEASE_TYPE_DECAF, |
|
| 219 | + Version::RELEASE_TYPE_PROD, |
|
| 220 | + ); |
|
| 221 | + if (! in_array($release, $valid_release_types, true)) { |
|
| 222 | + throw new InvalidArgumentException( |
|
| 223 | + sprintf( |
|
| 224 | + esc_html__( |
|
| 225 | + '"%1$s" is not a valid release type. Please use one of the following values: %2$s', |
|
| 226 | + 'event_espresso' |
|
| 227 | + ), |
|
| 228 | + $release, |
|
| 229 | + implode(', ', $valid_release_types) |
|
| 230 | + ) |
|
| 231 | + ); |
|
| 232 | + } |
|
| 233 | + $this->release = $release; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + /** |
|
| 238 | + * @return int |
|
| 239 | + */ |
|
| 240 | + public function build() |
|
| 241 | + { |
|
| 242 | + return $this->build; |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + /** |
|
| 247 | + * @param int|string $build |
|
| 248 | + * @throws InvalidDataTypeException |
|
| 249 | + */ |
|
| 250 | + private function setBuild($build) |
|
| 251 | + { |
|
| 252 | + if (! is_int($build)) { |
|
| 253 | + throw new InvalidDataTypeException( |
|
| 254 | + '$build', |
|
| 255 | + $build, |
|
| 256 | + 'integer' |
|
| 257 | + ); |
|
| 258 | + } |
|
| 259 | + $this->build = absint($build); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * @param Version $other_version |
|
| 265 | + * @return int |
|
| 266 | + */ |
|
| 267 | + public function compare(Version $other_version) |
|
| 268 | + { |
|
| 269 | + return version_compare((string) $this, (string) $other_version); |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + |
|
| 273 | + /** |
|
| 274 | + * @param Version $other_version |
|
| 275 | + * @return bool |
|
| 276 | + */ |
|
| 277 | + public function equals(Version $other_version) |
|
| 278 | + { |
|
| 279 | + return version_compare((string) $this, (string) $other_version, '=='); |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + /** |
|
| 284 | + * @param Version $other_version |
|
| 285 | + * @return bool |
|
| 286 | + */ |
|
| 287 | + public function newerThan(Version $other_version) |
|
| 288 | + { |
|
| 289 | + return version_compare((string) $this, (string) $other_version, '>'); |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @param Version $other_version |
|
| 295 | + * @return bool |
|
| 296 | + */ |
|
| 297 | + public function olderThan(Version $other_version) |
|
| 298 | + { |
|
| 299 | + return version_compare((string) $this, (string) $other_version, '<'); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * @return string |
|
| 305 | + */ |
|
| 306 | + public function __toString() |
|
| 307 | + { |
|
| 308 | + $version_string = "{$this->major}.{$this->minor}.{$this->patch}.{$this->release}"; |
|
| 309 | + if($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) { |
|
| 310 | + $version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT); |
|
| 311 | + } |
|
| 312 | + return $version_string; |
|
| 313 | + } |
|
| 314 | 314 | |
| 315 | 315 | |
| 316 | 316 | |
@@ -106,7 +106,7 @@ discard block |
||
| 106 | 106 | ); |
| 107 | 107 | } |
| 108 | 108 | // add defaults for missing pieces |
| 109 | - $version_parts += array(0,0,0,'p',0); |
|
| 109 | + $version_parts += array(0, 0, 0, 'p', 0); |
|
| 110 | 110 | // reassign to individual variables |
| 111 | 111 | list($major, $minor, $patch, $release, $build) = $version_parts; |
| 112 | 112 | return new Version( |
@@ -134,7 +134,7 @@ discard block |
||
| 134 | 134 | */ |
| 135 | 135 | private function setMajor($major) |
| 136 | 136 | { |
| 137 | - if (! is_int($major)) { |
|
| 137 | + if ( ! is_int($major)) { |
|
| 138 | 138 | throw new InvalidDataTypeException( |
| 139 | 139 | '$major', |
| 140 | 140 | $major, |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | */ |
| 161 | 161 | private function setMinor($minor) |
| 162 | 162 | { |
| 163 | - if (! is_int($minor)) { |
|
| 163 | + if ( ! is_int($minor)) { |
|
| 164 | 164 | throw new InvalidDataTypeException( |
| 165 | 165 | '$minor', |
| 166 | 166 | $minor, |
@@ -186,7 +186,7 @@ discard block |
||
| 186 | 186 | */ |
| 187 | 187 | private function setPatch($patch) |
| 188 | 188 | { |
| 189 | - if (! is_int($patch)) { |
|
| 189 | + if ( ! is_int($patch)) { |
|
| 190 | 190 | throw new InvalidDataTypeException( |
| 191 | 191 | '$patch', |
| 192 | 192 | $patch, |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | Version::RELEASE_TYPE_DECAF, |
| 219 | 219 | Version::RELEASE_TYPE_PROD, |
| 220 | 220 | ); |
| 221 | - if (! in_array($release, $valid_release_types, true)) { |
|
| 221 | + if ( ! in_array($release, $valid_release_types, true)) { |
|
| 222 | 222 | throw new InvalidArgumentException( |
| 223 | 223 | sprintf( |
| 224 | 224 | esc_html__( |
@@ -249,7 +249,7 @@ discard block |
||
| 249 | 249 | */ |
| 250 | 250 | private function setBuild($build) |
| 251 | 251 | { |
| 252 | - if (! is_int($build)) { |
|
| 252 | + if ( ! is_int($build)) { |
|
| 253 | 253 | throw new InvalidDataTypeException( |
| 254 | 254 | '$build', |
| 255 | 255 | $build, |
@@ -306,8 +306,8 @@ discard block |
||
| 306 | 306 | public function __toString() |
| 307 | 307 | { |
| 308 | 308 | $version_string = "{$this->major}.{$this->minor}.{$this->patch}.{$this->release}"; |
| 309 | - if($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) { |
|
| 310 | - $version_string .= '.' . str_pad($this->build, 3, '0', STR_PAD_LEFT); |
|
| 309 | + if ($this->release !== Version::RELEASE_TYPE_PROD && $this->release !== Version::RELEASE_TYPE_DECAF) { |
|
| 310 | + $version_string .= '.'.str_pad($this->build, 3, '0', STR_PAD_LEFT); |
|
| 311 | 311 | } |
| 312 | 312 | return $version_string; |
| 313 | 313 | } |
@@ -22,174 +22,174 @@ |
||
| 22 | 22 | class EE_Register_Payment_Method implements EEI_Plugin_API |
| 23 | 23 | { |
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Holds values for registered payment methods |
|
| 27 | - * |
|
| 28 | - * @var array |
|
| 29 | - */ |
|
| 30 | - protected static $_settings = array(); |
|
| 31 | - |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * Method for registering new EE_PMT_Base children |
|
| 36 | - * |
|
| 37 | - * @since 4.5.0 |
|
| 38 | - * @param string $payment_method_id a unique identifier for this set of modules Required. |
|
| 39 | - * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
| 40 | - * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
| 41 | - * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
| 42 | - * the files EE_PMT_Payomatic.pm.php) |
|
| 43 | - * } |
|
| 44 | - * @throws EE_Error |
|
| 45 | - * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
| 46 | - * children, or to the EED_Module files themselves |
|
| 47 | - * @return void |
|
| 48 | - * @throws InvalidDataTypeException |
|
| 49 | - * @throws DomainException |
|
| 50 | - * @throws InvalidArgumentException |
|
| 51 | - * @throws InvalidInterfaceException |
|
| 52 | - * @throws InvalidDataTypeException |
|
| 53 | - */ |
|
| 54 | - public static function register($payment_method_id = null, $setup_args = array()) |
|
| 55 | - { |
|
| 56 | - //required fields MUST be present, so let's make sure they are. |
|
| 57 | - if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
| 58 | - throw new EE_Error( |
|
| 59 | - esc_html__( |
|
| 60 | - 'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
| 61 | - 'event_espresso' |
|
| 62 | - ) |
|
| 63 | - ); |
|
| 64 | - } |
|
| 65 | - //make sure we don't register twice |
|
| 66 | - if (isset(self::$_settings[$payment_method_id])) { |
|
| 67 | - return; |
|
| 68 | - } |
|
| 69 | - //make sure this was called in the right place! |
|
| 70 | - if ( |
|
| 71 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 72 | - || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
| 73 | - ) { |
|
| 74 | - EE_Error::doing_it_wrong( |
|
| 75 | - __METHOD__, |
|
| 76 | - esc_html__( |
|
| 77 | - 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
| 78 | - 'event_espresso' |
|
| 79 | - ), |
|
| 80 | - '4.3.0' |
|
| 81 | - ); |
|
| 82 | - } |
|
| 83 | - //setup $_settings array from incoming values. |
|
| 84 | - self::$_settings[$payment_method_id] = array( |
|
| 85 | - // array of full server paths to any EE_PMT_Base children used |
|
| 86 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
| 87 | - ? (array)$setup_args['payment_method_paths'] |
|
| 88 | - : array(), |
|
| 89 | - ); |
|
| 90 | - // add to list of modules to be registered |
|
| 91 | - add_filter( |
|
| 92 | - 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
| 93 | - array('EE_Register_Payment_Method', 'add_payment_methods') |
|
| 94 | - ); |
|
| 95 | - // If EE_Payment_Method_Manager::register_payment_methods has already been called, |
|
| 96 | - // then we need to add our caps for this payment method manually |
|
| 97 | - if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
|
| 98 | - $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 99 | - // register payment methods directly |
|
| 100 | - foreach (self::$_settings[$payment_method_id]['payment_method_paths'] as $payment_method_path) { |
|
| 101 | - $payment_method_manager->register_payment_method($payment_method_path); |
|
| 102 | - } |
|
| 103 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 104 | - $capabilities->addCaps( |
|
| 105 | - self::getPaymentMethodCapabilities(self::$_settings[$payment_method_id]) |
|
| 106 | - ); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - |
|
| 111 | - |
|
| 112 | - /** |
|
| 113 | - * Filters the list of payment methods to add ours. |
|
| 114 | - * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
| 115 | - * |
|
| 116 | - * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
| 117 | - * @return array |
|
| 118 | - */ |
|
| 119 | - public static function add_payment_methods($payment_method_folders) |
|
| 120 | - { |
|
| 121 | - foreach (self::$_settings as $settings) { |
|
| 122 | - foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
| 123 | - $payment_method_folders[] = $payment_method_path; |
|
| 124 | - } |
|
| 125 | - } |
|
| 126 | - return $payment_method_folders; |
|
| 127 | - } |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * This deregisters a module that was previously registered with a specific $module_id. |
|
| 133 | - * |
|
| 134 | - * @since 4.3.0 |
|
| 135 | - * |
|
| 136 | - * @param string $module_id the name for the module that was previously registered |
|
| 137 | - * @return void |
|
| 138 | - * @throws DomainException |
|
| 139 | - * @throws EE_Error |
|
| 140 | - * @throws InvalidArgumentException |
|
| 141 | - * @throws InvalidInterfaceException |
|
| 142 | - * @throws InvalidDataTypeException |
|
| 143 | - */ |
|
| 144 | - public static function deregister($module_id = null) |
|
| 145 | - { |
|
| 146 | - if (isset(self::$_settings[$module_id])) { |
|
| 147 | - |
|
| 148 | - //set action for just this module id to delay deregistration until core is loaded and ready. |
|
| 149 | - $module_settings = self::$_settings[$module_id]; |
|
| 150 | - unset(self::$_settings[$module_id]); |
|
| 151 | - add_action( |
|
| 152 | - 'AHEE__EE_System__core_loaded_and_ready', |
|
| 153 | - function () use ($module_settings) { |
|
| 154 | - $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 155 | - $capabilities->removeCaps( |
|
| 156 | - EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
|
| 157 | - ); |
|
| 158 | - } |
|
| 159 | - ); |
|
| 160 | - } |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - |
|
| 165 | - /** |
|
| 166 | - * returns an array of the caps that get added when a Payment Method is registered |
|
| 167 | - * |
|
| 168 | - * @param array $settings |
|
| 169 | - * @return array |
|
| 170 | - * @throws DomainException |
|
| 171 | - * @throws EE_Error |
|
| 172 | - * @throws InvalidArgumentException |
|
| 173 | - * @throws InvalidInterfaceException |
|
| 174 | - * @throws InvalidDataTypeException |
|
| 175 | - * @access private Developers do NOT use this method. It's only public for PHP5.3 closure support (see deregister) |
|
| 176 | - * When we drop support for PHP5.3 this will be made private again. You have been warned. |
|
| 177 | - * |
|
| 178 | - */ |
|
| 179 | - public static function getPaymentMethodCapabilities(array $settings) |
|
| 180 | - { |
|
| 181 | - $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 182 | - $payment_method_caps = array('administrator' => array()); |
|
| 183 | - if (isset($settings['payment_method_paths'])) { |
|
| 184 | - foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
| 185 | - $payment_method_caps = $payment_method_manager->addPaymentMethodCap( |
|
| 186 | - strtolower(basename($payment_method_path)), |
|
| 187 | - $payment_method_caps |
|
| 188 | - ); |
|
| 189 | - } |
|
| 190 | - } |
|
| 191 | - return $payment_method_caps; |
|
| 192 | - } |
|
| 25 | + /** |
|
| 26 | + * Holds values for registered payment methods |
|
| 27 | + * |
|
| 28 | + * @var array |
|
| 29 | + */ |
|
| 30 | + protected static $_settings = array(); |
|
| 31 | + |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * Method for registering new EE_PMT_Base children |
|
| 36 | + * |
|
| 37 | + * @since 4.5.0 |
|
| 38 | + * @param string $payment_method_id a unique identifier for this set of modules Required. |
|
| 39 | + * @param array $setup_args an array of arguments provided for registering modules Required.{ |
|
| 40 | + * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class |
|
| 41 | + * (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains |
|
| 42 | + * the files EE_PMT_Payomatic.pm.php) |
|
| 43 | + * } |
|
| 44 | + * @throws EE_Error |
|
| 45 | + * @type array payment_method_paths an array of full server paths to folders containing any EE_PMT_Base |
|
| 46 | + * children, or to the EED_Module files themselves |
|
| 47 | + * @return void |
|
| 48 | + * @throws InvalidDataTypeException |
|
| 49 | + * @throws DomainException |
|
| 50 | + * @throws InvalidArgumentException |
|
| 51 | + * @throws InvalidInterfaceException |
|
| 52 | + * @throws InvalidDataTypeException |
|
| 53 | + */ |
|
| 54 | + public static function register($payment_method_id = null, $setup_args = array()) |
|
| 55 | + { |
|
| 56 | + //required fields MUST be present, so let's make sure they are. |
|
| 57 | + if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) { |
|
| 58 | + throw new EE_Error( |
|
| 59 | + esc_html__( |
|
| 60 | + 'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)', |
|
| 61 | + 'event_espresso' |
|
| 62 | + ) |
|
| 63 | + ); |
|
| 64 | + } |
|
| 65 | + //make sure we don't register twice |
|
| 66 | + if (isset(self::$_settings[$payment_method_id])) { |
|
| 67 | + return; |
|
| 68 | + } |
|
| 69 | + //make sure this was called in the right place! |
|
| 70 | + if ( |
|
| 71 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 72 | + || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets') |
|
| 73 | + ) { |
|
| 74 | + EE_Error::doing_it_wrong( |
|
| 75 | + __METHOD__, |
|
| 76 | + esc_html__( |
|
| 77 | + 'An attempt to register modules has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.', |
|
| 78 | + 'event_espresso' |
|
| 79 | + ), |
|
| 80 | + '4.3.0' |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | + //setup $_settings array from incoming values. |
|
| 84 | + self::$_settings[$payment_method_id] = array( |
|
| 85 | + // array of full server paths to any EE_PMT_Base children used |
|
| 86 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
| 87 | + ? (array)$setup_args['payment_method_paths'] |
|
| 88 | + : array(), |
|
| 89 | + ); |
|
| 90 | + // add to list of modules to be registered |
|
| 91 | + add_filter( |
|
| 92 | + 'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register', |
|
| 93 | + array('EE_Register_Payment_Method', 'add_payment_methods') |
|
| 94 | + ); |
|
| 95 | + // If EE_Payment_Method_Manager::register_payment_methods has already been called, |
|
| 96 | + // then we need to add our caps for this payment method manually |
|
| 97 | + if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) { |
|
| 98 | + $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 99 | + // register payment methods directly |
|
| 100 | + foreach (self::$_settings[$payment_method_id]['payment_method_paths'] as $payment_method_path) { |
|
| 101 | + $payment_method_manager->register_payment_method($payment_method_path); |
|
| 102 | + } |
|
| 103 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 104 | + $capabilities->addCaps( |
|
| 105 | + self::getPaymentMethodCapabilities(self::$_settings[$payment_method_id]) |
|
| 106 | + ); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + |
|
| 111 | + |
|
| 112 | + /** |
|
| 113 | + * Filters the list of payment methods to add ours. |
|
| 114 | + * and they're just full filepaths to FOLDERS containing a payment method class file. Eg. |
|
| 115 | + * |
|
| 116 | + * @param array $payment_method_folders array of paths to all payment methods that require registering |
|
| 117 | + * @return array |
|
| 118 | + */ |
|
| 119 | + public static function add_payment_methods($payment_method_folders) |
|
| 120 | + { |
|
| 121 | + foreach (self::$_settings as $settings) { |
|
| 122 | + foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
| 123 | + $payment_method_folders[] = $payment_method_path; |
|
| 124 | + } |
|
| 125 | + } |
|
| 126 | + return $payment_method_folders; |
|
| 127 | + } |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * This deregisters a module that was previously registered with a specific $module_id. |
|
| 133 | + * |
|
| 134 | + * @since 4.3.0 |
|
| 135 | + * |
|
| 136 | + * @param string $module_id the name for the module that was previously registered |
|
| 137 | + * @return void |
|
| 138 | + * @throws DomainException |
|
| 139 | + * @throws EE_Error |
|
| 140 | + * @throws InvalidArgumentException |
|
| 141 | + * @throws InvalidInterfaceException |
|
| 142 | + * @throws InvalidDataTypeException |
|
| 143 | + */ |
|
| 144 | + public static function deregister($module_id = null) |
|
| 145 | + { |
|
| 146 | + if (isset(self::$_settings[$module_id])) { |
|
| 147 | + |
|
| 148 | + //set action for just this module id to delay deregistration until core is loaded and ready. |
|
| 149 | + $module_settings = self::$_settings[$module_id]; |
|
| 150 | + unset(self::$_settings[$module_id]); |
|
| 151 | + add_action( |
|
| 152 | + 'AHEE__EE_System__core_loaded_and_ready', |
|
| 153 | + function () use ($module_settings) { |
|
| 154 | + $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
|
| 155 | + $capabilities->removeCaps( |
|
| 156 | + EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
|
| 157 | + ); |
|
| 158 | + } |
|
| 159 | + ); |
|
| 160 | + } |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + |
|
| 165 | + /** |
|
| 166 | + * returns an array of the caps that get added when a Payment Method is registered |
|
| 167 | + * |
|
| 168 | + * @param array $settings |
|
| 169 | + * @return array |
|
| 170 | + * @throws DomainException |
|
| 171 | + * @throws EE_Error |
|
| 172 | + * @throws InvalidArgumentException |
|
| 173 | + * @throws InvalidInterfaceException |
|
| 174 | + * @throws InvalidDataTypeException |
|
| 175 | + * @access private Developers do NOT use this method. It's only public for PHP5.3 closure support (see deregister) |
|
| 176 | + * When we drop support for PHP5.3 this will be made private again. You have been warned. |
|
| 177 | + * |
|
| 178 | + */ |
|
| 179 | + public static function getPaymentMethodCapabilities(array $settings) |
|
| 180 | + { |
|
| 181 | + $payment_method_manager = LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 182 | + $payment_method_caps = array('administrator' => array()); |
|
| 183 | + if (isset($settings['payment_method_paths'])) { |
|
| 184 | + foreach ($settings['payment_method_paths'] as $payment_method_path) { |
|
| 185 | + $payment_method_caps = $payment_method_manager->addPaymentMethodCap( |
|
| 186 | + strtolower(basename($payment_method_path)), |
|
| 187 | + $payment_method_caps |
|
| 188 | + ); |
|
| 189 | + } |
|
| 190 | + } |
|
| 191 | + return $payment_method_caps; |
|
| 192 | + } |
|
| 193 | 193 | |
| 194 | 194 | } |
| 195 | 195 | // End of file EE_Register_Payment_Method.lib.php |
@@ -84,7 +84,7 @@ discard block |
||
| 84 | 84 | self::$_settings[$payment_method_id] = array( |
| 85 | 85 | // array of full server paths to any EE_PMT_Base children used |
| 86 | 86 | 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
| 87 | - ? (array)$setup_args['payment_method_paths'] |
|
| 87 | + ? (array) $setup_args['payment_method_paths'] |
|
| 88 | 88 | : array(), |
| 89 | 89 | ); |
| 90 | 90 | // add to list of modules to be registered |
@@ -150,7 +150,7 @@ discard block |
||
| 150 | 150 | unset(self::$_settings[$module_id]); |
| 151 | 151 | add_action( |
| 152 | 152 | 'AHEE__EE_System__core_loaded_and_ready', |
| 153 | - function () use ($module_settings) { |
|
| 153 | + function() use ($module_settings) { |
|
| 154 | 154 | $capabilities = LoaderFactory::getLoader()->getShared('EE_Capabilities'); |
| 155 | 155 | $capabilities->removeCaps( |
| 156 | 156 | EE_Register_Payment_Method::getPaymentMethodCapabilities($module_settings) |
@@ -18,786 +18,786 @@ discard block |
||
| 18 | 18 | { |
| 19 | 19 | |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * prefix to be added onto an addon's plugin slug to make a wp option name |
|
| 23 | - * which will be used to store the plugin's activation history |
|
| 24 | - */ |
|
| 25 | - const ee_addon_version_history_option_prefix = 'ee_version_history_'; |
|
| 26 | - |
|
| 27 | - /** |
|
| 28 | - * @var $_version |
|
| 29 | - * @type string |
|
| 30 | - */ |
|
| 31 | - protected $_version = ''; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * @var $_min_core_version |
|
| 35 | - * @type string |
|
| 36 | - */ |
|
| 37 | - protected $_min_core_version = ''; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * derived from plugin 'main_file_path using plugin_basename() |
|
| 41 | - * |
|
| 42 | - * @type string $_plugin_basename |
|
| 43 | - */ |
|
| 44 | - protected $_plugin_basename = ''; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * A non-internationalized name to identify this addon for use in URLs, etc |
|
| 48 | - * |
|
| 49 | - * @type string $_plugin_slug |
|
| 50 | - */ |
|
| 51 | - protected $_plugin_slug = ''; |
|
| 52 | - |
|
| 53 | - /** |
|
| 54 | - * A non-internationalized name to identify this addon. Eg 'Calendar','MailChimp',etc/ |
|
| 55 | - * |
|
| 56 | - * @type string _addon_name |
|
| 57 | - */ |
|
| 58 | - protected $_addon_name = ''; |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * one of the EE_System::req_type_* constants |
|
| 62 | - * |
|
| 63 | - * @type int $_req_type |
|
| 64 | - */ |
|
| 65 | - protected $_req_type; |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * page slug to be used when generating the "Settings" link on the WP plugin page |
|
| 69 | - * |
|
| 70 | - * @type string $_plugin_action_slug |
|
| 71 | - */ |
|
| 72 | - protected $_plugin_action_slug = ''; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
| 76 | - * that can be used for adding upgrading/marketing info |
|
| 77 | - * |
|
| 78 | - * @type array $_plugins_page_row |
|
| 79 | - */ |
|
| 80 | - protected $_plugins_page_row = array(); |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc. |
|
| 86 | - * |
|
| 87 | - * @type string |
|
| 88 | - */ |
|
| 89 | - protected $_main_plugin_file; |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * @var EE_Dependency_Map $dependency_map |
|
| 94 | - */ |
|
| 95 | - private $dependency_map; |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @var DomainInterface $domain |
|
| 100 | - */ |
|
| 101 | - private $domain; |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * @param EE_Dependency_Map $dependency_map [optional] |
|
| 106 | - * @param DomainInterface $domain [optional] |
|
| 107 | - */ |
|
| 108 | - public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null) |
|
| 109 | - { |
|
| 110 | - if($dependency_map instanceof EE_Dependency_Map) { |
|
| 111 | - $this->setDependencyMap($dependency_map); |
|
| 112 | - } |
|
| 113 | - if ($domain instanceof DomainInterface) { |
|
| 114 | - $this->setDomain($domain); |
|
| 115 | - } |
|
| 116 | - add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init')); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @param EE_Dependency_Map $dependency_map |
|
| 122 | - */ |
|
| 123 | - public function setDependencyMap($dependency_map) |
|
| 124 | - { |
|
| 125 | - $this->dependency_map = $dependency_map; |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * @return EE_Dependency_Map |
|
| 131 | - */ |
|
| 132 | - public function dependencyMap() |
|
| 133 | - { |
|
| 134 | - return $this->dependency_map; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @param DomainInterface $domain |
|
| 140 | - */ |
|
| 141 | - public function setDomain(DomainInterface $domain) |
|
| 142 | - { |
|
| 143 | - $this->domain = $domain; |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @return DomainInterface |
|
| 148 | - */ |
|
| 149 | - public function domain() |
|
| 150 | - { |
|
| 151 | - return $this->domain; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param mixed $version |
|
| 157 | - */ |
|
| 158 | - public function set_version($version = null) |
|
| 159 | - { |
|
| 160 | - $this->_version = $version; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * get__version |
|
| 166 | - * |
|
| 167 | - * @return string |
|
| 168 | - */ |
|
| 169 | - public function version() |
|
| 170 | - { |
|
| 171 | - return $this->_version; |
|
| 172 | - } |
|
| 173 | - |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * @param mixed $min_core_version |
|
| 177 | - */ |
|
| 178 | - public function set_min_core_version($min_core_version = null) |
|
| 179 | - { |
|
| 180 | - $this->_min_core_version = $min_core_version; |
|
| 181 | - } |
|
| 182 | - |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * get__min_core_version |
|
| 186 | - * |
|
| 187 | - * @return string |
|
| 188 | - */ |
|
| 189 | - public function min_core_version() |
|
| 190 | - { |
|
| 191 | - return $this->_min_core_version; |
|
| 192 | - } |
|
| 193 | - |
|
| 194 | - |
|
| 195 | - /** |
|
| 196 | - * Sets addon_name |
|
| 197 | - * |
|
| 198 | - * @param string $addon_name |
|
| 199 | - * @return boolean |
|
| 200 | - */ |
|
| 201 | - public function set_name($addon_name) |
|
| 202 | - { |
|
| 203 | - return $this->_addon_name = $addon_name; |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - |
|
| 207 | - /** |
|
| 208 | - * Gets addon_name |
|
| 209 | - * |
|
| 210 | - * @return string |
|
| 211 | - */ |
|
| 212 | - public function name() |
|
| 213 | - { |
|
| 214 | - return $this->_addon_name; |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * @return string |
|
| 220 | - */ |
|
| 221 | - public function plugin_basename() |
|
| 222 | - { |
|
| 223 | - |
|
| 224 | - return $this->_plugin_basename; |
|
| 225 | - } |
|
| 226 | - |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * @param string $plugin_basename |
|
| 230 | - */ |
|
| 231 | - public function set_plugin_basename($plugin_basename) |
|
| 232 | - { |
|
| 233 | - |
|
| 234 | - $this->_plugin_basename = $plugin_basename; |
|
| 235 | - } |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * @return string |
|
| 240 | - */ |
|
| 241 | - public function plugin_slug() |
|
| 242 | - { |
|
| 243 | - |
|
| 244 | - return $this->_plugin_slug; |
|
| 245 | - } |
|
| 246 | - |
|
| 247 | - |
|
| 248 | - /** |
|
| 249 | - * @param string $plugin_slug |
|
| 250 | - */ |
|
| 251 | - public function set_plugin_slug($plugin_slug) |
|
| 252 | - { |
|
| 253 | - |
|
| 254 | - $this->_plugin_slug = $plugin_slug; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - /** |
|
| 259 | - * @return string |
|
| 260 | - */ |
|
| 261 | - public function plugin_action_slug() |
|
| 262 | - { |
|
| 263 | - |
|
| 264 | - return $this->_plugin_action_slug; |
|
| 265 | - } |
|
| 266 | - |
|
| 267 | - |
|
| 268 | - /** |
|
| 269 | - * @param string $plugin_action_slug |
|
| 270 | - */ |
|
| 271 | - public function set_plugin_action_slug($plugin_action_slug) |
|
| 272 | - { |
|
| 273 | - |
|
| 274 | - $this->_plugin_action_slug = $plugin_action_slug; |
|
| 275 | - } |
|
| 276 | - |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * @return array |
|
| 280 | - */ |
|
| 281 | - public function get_plugins_page_row() |
|
| 282 | - { |
|
| 283 | - |
|
| 284 | - return $this->_plugins_page_row; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - |
|
| 288 | - /** |
|
| 289 | - * @param array $plugins_page_row |
|
| 290 | - */ |
|
| 291 | - public function set_plugins_page_row($plugins_page_row = array()) |
|
| 292 | - { |
|
| 293 | - // sigh.... check for example content that I stupidly merged to master and remove it if found |
|
| 294 | - if (! is_array($plugins_page_row) |
|
| 295 | - && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false |
|
| 296 | - ) { |
|
| 297 | - $plugins_page_row = array(); |
|
| 298 | - } |
|
| 299 | - $this->_plugins_page_row = (array) $plugins_page_row; |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - /** |
|
| 304 | - * Called when EE core detects this addon has been activated for the first time. |
|
| 305 | - * If the site isn't in maintenance mode, should setup the addon's database |
|
| 306 | - * |
|
| 307 | - * @return void |
|
| 308 | - */ |
|
| 309 | - public function new_install() |
|
| 310 | - { |
|
| 311 | - $classname = get_class($this); |
|
| 312 | - do_action("AHEE__{$classname}__new_install"); |
|
| 313 | - do_action('AHEE__EE_Addon__new_install', $this); |
|
| 314 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 315 | - add_action( |
|
| 316 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 317 | - array($this, 'initialize_db_if_no_migrations_required') |
|
| 318 | - ); |
|
| 319 | - } |
|
| 320 | - |
|
| 321 | - |
|
| 322 | - /** |
|
| 323 | - * Called when EE core detects this addon has been reactivated. When this happens, |
|
| 324 | - * it's good to just check that your data is still intact |
|
| 325 | - * |
|
| 326 | - * @return void |
|
| 327 | - */ |
|
| 328 | - public function reactivation() |
|
| 329 | - { |
|
| 330 | - $classname = get_class($this); |
|
| 331 | - do_action("AHEE__{$classname}__reactivation"); |
|
| 332 | - do_action('AHEE__EE_Addon__reactivation', $this); |
|
| 333 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 334 | - add_action( |
|
| 335 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 336 | - array($this, 'initialize_db_if_no_migrations_required') |
|
| 337 | - ); |
|
| 338 | - } |
|
| 339 | - |
|
| 340 | - |
|
| 341 | - /** |
|
| 342 | - * Called when the registered deactivation hook for this addon fires. |
|
| 343 | - * @throws EE_Error |
|
| 344 | - */ |
|
| 345 | - public function deactivation() |
|
| 346 | - { |
|
| 347 | - $classname = get_class($this); |
|
| 348 | - do_action("AHEE__{$classname}__deactivation"); |
|
| 349 | - do_action('AHEE__EE_Addon__deactivation', $this); |
|
| 350 | - //check if the site no longer needs to be in maintenance mode |
|
| 351 | - EE_Register_Addon::deregister($this->name()); |
|
| 352 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - |
|
| 356 | - /** |
|
| 357 | - * Takes care of double-checking that we're not in maintenance mode, and then |
|
| 358 | - * initializing this addon's necessary initial data. This is called by default on new activations |
|
| 359 | - * and reactivations. |
|
| 360 | - * |
|
| 361 | - * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data. |
|
| 362 | - * This is a resource-intensive job so we prefer to only do it when necessary |
|
| 363 | - * @return void |
|
| 364 | - * @throws \EE_Error |
|
| 365 | - */ |
|
| 366 | - public function initialize_db_if_no_migrations_required($verify_schema = true) |
|
| 367 | - { |
|
| 368 | - if ($verify_schema === '') { |
|
| 369 | - //wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name |
|
| 370 | - //(ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it |
|
| 371 | - //calls them with an argument of an empty string (ie ""), which evaluates to false |
|
| 372 | - //so we need to treat the empty string as if nothing had been passed, and should instead use the default |
|
| 373 | - $verify_schema = true; |
|
| 374 | - } |
|
| 375 | - if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 376 | - if ($verify_schema) { |
|
| 377 | - $this->initialize_db(); |
|
| 378 | - } |
|
| 379 | - $this->initialize_default_data(); |
|
| 380 | - //@todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe |
|
| 381 | - EE_Data_Migration_Manager::instance()->update_current_database_state_to( |
|
| 382 | - array( |
|
| 383 | - 'slug' => $this->name(), |
|
| 384 | - 'version' => $this->version(), |
|
| 385 | - ) |
|
| 386 | - ); |
|
| 387 | - /* make sure core's data is a-ok |
|
| 21 | + /** |
|
| 22 | + * prefix to be added onto an addon's plugin slug to make a wp option name |
|
| 23 | + * which will be used to store the plugin's activation history |
|
| 24 | + */ |
|
| 25 | + const ee_addon_version_history_option_prefix = 'ee_version_history_'; |
|
| 26 | + |
|
| 27 | + /** |
|
| 28 | + * @var $_version |
|
| 29 | + * @type string |
|
| 30 | + */ |
|
| 31 | + protected $_version = ''; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * @var $_min_core_version |
|
| 35 | + * @type string |
|
| 36 | + */ |
|
| 37 | + protected $_min_core_version = ''; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * derived from plugin 'main_file_path using plugin_basename() |
|
| 41 | + * |
|
| 42 | + * @type string $_plugin_basename |
|
| 43 | + */ |
|
| 44 | + protected $_plugin_basename = ''; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * A non-internationalized name to identify this addon for use in URLs, etc |
|
| 48 | + * |
|
| 49 | + * @type string $_plugin_slug |
|
| 50 | + */ |
|
| 51 | + protected $_plugin_slug = ''; |
|
| 52 | + |
|
| 53 | + /** |
|
| 54 | + * A non-internationalized name to identify this addon. Eg 'Calendar','MailChimp',etc/ |
|
| 55 | + * |
|
| 56 | + * @type string _addon_name |
|
| 57 | + */ |
|
| 58 | + protected $_addon_name = ''; |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * one of the EE_System::req_type_* constants |
|
| 62 | + * |
|
| 63 | + * @type int $_req_type |
|
| 64 | + */ |
|
| 65 | + protected $_req_type; |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * page slug to be used when generating the "Settings" link on the WP plugin page |
|
| 69 | + * |
|
| 70 | + * @type string $_plugin_action_slug |
|
| 71 | + */ |
|
| 72 | + protected $_plugin_action_slug = ''; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
| 76 | + * that can be used for adding upgrading/marketing info |
|
| 77 | + * |
|
| 78 | + * @type array $_plugins_page_row |
|
| 79 | + */ |
|
| 80 | + protected $_plugins_page_row = array(); |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * filepath to the main file, which can be used for register_activation_hook, register_deactivation_hook, etc. |
|
| 86 | + * |
|
| 87 | + * @type string |
|
| 88 | + */ |
|
| 89 | + protected $_main_plugin_file; |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * @var EE_Dependency_Map $dependency_map |
|
| 94 | + */ |
|
| 95 | + private $dependency_map; |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @var DomainInterface $domain |
|
| 100 | + */ |
|
| 101 | + private $domain; |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * @param EE_Dependency_Map $dependency_map [optional] |
|
| 106 | + * @param DomainInterface $domain [optional] |
|
| 107 | + */ |
|
| 108 | + public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null) |
|
| 109 | + { |
|
| 110 | + if($dependency_map instanceof EE_Dependency_Map) { |
|
| 111 | + $this->setDependencyMap($dependency_map); |
|
| 112 | + } |
|
| 113 | + if ($domain instanceof DomainInterface) { |
|
| 114 | + $this->setDomain($domain); |
|
| 115 | + } |
|
| 116 | + add_action('AHEE__EE_System__load_controllers__load_admin_controllers', array($this, 'admin_init')); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @param EE_Dependency_Map $dependency_map |
|
| 122 | + */ |
|
| 123 | + public function setDependencyMap($dependency_map) |
|
| 124 | + { |
|
| 125 | + $this->dependency_map = $dependency_map; |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * @return EE_Dependency_Map |
|
| 131 | + */ |
|
| 132 | + public function dependencyMap() |
|
| 133 | + { |
|
| 134 | + return $this->dependency_map; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param DomainInterface $domain |
|
| 140 | + */ |
|
| 141 | + public function setDomain(DomainInterface $domain) |
|
| 142 | + { |
|
| 143 | + $this->domain = $domain; |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @return DomainInterface |
|
| 148 | + */ |
|
| 149 | + public function domain() |
|
| 150 | + { |
|
| 151 | + return $this->domain; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param mixed $version |
|
| 157 | + */ |
|
| 158 | + public function set_version($version = null) |
|
| 159 | + { |
|
| 160 | + $this->_version = $version; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * get__version |
|
| 166 | + * |
|
| 167 | + * @return string |
|
| 168 | + */ |
|
| 169 | + public function version() |
|
| 170 | + { |
|
| 171 | + return $this->_version; |
|
| 172 | + } |
|
| 173 | + |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * @param mixed $min_core_version |
|
| 177 | + */ |
|
| 178 | + public function set_min_core_version($min_core_version = null) |
|
| 179 | + { |
|
| 180 | + $this->_min_core_version = $min_core_version; |
|
| 181 | + } |
|
| 182 | + |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * get__min_core_version |
|
| 186 | + * |
|
| 187 | + * @return string |
|
| 188 | + */ |
|
| 189 | + public function min_core_version() |
|
| 190 | + { |
|
| 191 | + return $this->_min_core_version; |
|
| 192 | + } |
|
| 193 | + |
|
| 194 | + |
|
| 195 | + /** |
|
| 196 | + * Sets addon_name |
|
| 197 | + * |
|
| 198 | + * @param string $addon_name |
|
| 199 | + * @return boolean |
|
| 200 | + */ |
|
| 201 | + public function set_name($addon_name) |
|
| 202 | + { |
|
| 203 | + return $this->_addon_name = $addon_name; |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + |
|
| 207 | + /** |
|
| 208 | + * Gets addon_name |
|
| 209 | + * |
|
| 210 | + * @return string |
|
| 211 | + */ |
|
| 212 | + public function name() |
|
| 213 | + { |
|
| 214 | + return $this->_addon_name; |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * @return string |
|
| 220 | + */ |
|
| 221 | + public function plugin_basename() |
|
| 222 | + { |
|
| 223 | + |
|
| 224 | + return $this->_plugin_basename; |
|
| 225 | + } |
|
| 226 | + |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * @param string $plugin_basename |
|
| 230 | + */ |
|
| 231 | + public function set_plugin_basename($plugin_basename) |
|
| 232 | + { |
|
| 233 | + |
|
| 234 | + $this->_plugin_basename = $plugin_basename; |
|
| 235 | + } |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * @return string |
|
| 240 | + */ |
|
| 241 | + public function plugin_slug() |
|
| 242 | + { |
|
| 243 | + |
|
| 244 | + return $this->_plugin_slug; |
|
| 245 | + } |
|
| 246 | + |
|
| 247 | + |
|
| 248 | + /** |
|
| 249 | + * @param string $plugin_slug |
|
| 250 | + */ |
|
| 251 | + public function set_plugin_slug($plugin_slug) |
|
| 252 | + { |
|
| 253 | + |
|
| 254 | + $this->_plugin_slug = $plugin_slug; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + /** |
|
| 259 | + * @return string |
|
| 260 | + */ |
|
| 261 | + public function plugin_action_slug() |
|
| 262 | + { |
|
| 263 | + |
|
| 264 | + return $this->_plugin_action_slug; |
|
| 265 | + } |
|
| 266 | + |
|
| 267 | + |
|
| 268 | + /** |
|
| 269 | + * @param string $plugin_action_slug |
|
| 270 | + */ |
|
| 271 | + public function set_plugin_action_slug($plugin_action_slug) |
|
| 272 | + { |
|
| 273 | + |
|
| 274 | + $this->_plugin_action_slug = $plugin_action_slug; |
|
| 275 | + } |
|
| 276 | + |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * @return array |
|
| 280 | + */ |
|
| 281 | + public function get_plugins_page_row() |
|
| 282 | + { |
|
| 283 | + |
|
| 284 | + return $this->_plugins_page_row; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + |
|
| 288 | + /** |
|
| 289 | + * @param array $plugins_page_row |
|
| 290 | + */ |
|
| 291 | + public function set_plugins_page_row($plugins_page_row = array()) |
|
| 292 | + { |
|
| 293 | + // sigh.... check for example content that I stupidly merged to master and remove it if found |
|
| 294 | + if (! is_array($plugins_page_row) |
|
| 295 | + && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false |
|
| 296 | + ) { |
|
| 297 | + $plugins_page_row = array(); |
|
| 298 | + } |
|
| 299 | + $this->_plugins_page_row = (array) $plugins_page_row; |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + /** |
|
| 304 | + * Called when EE core detects this addon has been activated for the first time. |
|
| 305 | + * If the site isn't in maintenance mode, should setup the addon's database |
|
| 306 | + * |
|
| 307 | + * @return void |
|
| 308 | + */ |
|
| 309 | + public function new_install() |
|
| 310 | + { |
|
| 311 | + $classname = get_class($this); |
|
| 312 | + do_action("AHEE__{$classname}__new_install"); |
|
| 313 | + do_action('AHEE__EE_Addon__new_install', $this); |
|
| 314 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 315 | + add_action( |
|
| 316 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 317 | + array($this, 'initialize_db_if_no_migrations_required') |
|
| 318 | + ); |
|
| 319 | + } |
|
| 320 | + |
|
| 321 | + |
|
| 322 | + /** |
|
| 323 | + * Called when EE core detects this addon has been reactivated. When this happens, |
|
| 324 | + * it's good to just check that your data is still intact |
|
| 325 | + * |
|
| 326 | + * @return void |
|
| 327 | + */ |
|
| 328 | + public function reactivation() |
|
| 329 | + { |
|
| 330 | + $classname = get_class($this); |
|
| 331 | + do_action("AHEE__{$classname}__reactivation"); |
|
| 332 | + do_action('AHEE__EE_Addon__reactivation', $this); |
|
| 333 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 334 | + add_action( |
|
| 335 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 336 | + array($this, 'initialize_db_if_no_migrations_required') |
|
| 337 | + ); |
|
| 338 | + } |
|
| 339 | + |
|
| 340 | + |
|
| 341 | + /** |
|
| 342 | + * Called when the registered deactivation hook for this addon fires. |
|
| 343 | + * @throws EE_Error |
|
| 344 | + */ |
|
| 345 | + public function deactivation() |
|
| 346 | + { |
|
| 347 | + $classname = get_class($this); |
|
| 348 | + do_action("AHEE__{$classname}__deactivation"); |
|
| 349 | + do_action('AHEE__EE_Addon__deactivation', $this); |
|
| 350 | + //check if the site no longer needs to be in maintenance mode |
|
| 351 | + EE_Register_Addon::deregister($this->name()); |
|
| 352 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + |
|
| 356 | + /** |
|
| 357 | + * Takes care of double-checking that we're not in maintenance mode, and then |
|
| 358 | + * initializing this addon's necessary initial data. This is called by default on new activations |
|
| 359 | + * and reactivations. |
|
| 360 | + * |
|
| 361 | + * @param boolean $verify_schema whether to verify the database's schema for this addon, or just its data. |
|
| 362 | + * This is a resource-intensive job so we prefer to only do it when necessary |
|
| 363 | + * @return void |
|
| 364 | + * @throws \EE_Error |
|
| 365 | + */ |
|
| 366 | + public function initialize_db_if_no_migrations_required($verify_schema = true) |
|
| 367 | + { |
|
| 368 | + if ($verify_schema === '') { |
|
| 369 | + //wp core bug imo: if no args are passed to `do_action('some_hook_name')` besides the hook's name |
|
| 370 | + //(ie, no 2nd or 3rd arguments), instead of calling the registered callbacks with no arguments, it |
|
| 371 | + //calls them with an argument of an empty string (ie ""), which evaluates to false |
|
| 372 | + //so we need to treat the empty string as if nothing had been passed, and should instead use the default |
|
| 373 | + $verify_schema = true; |
|
| 374 | + } |
|
| 375 | + if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 376 | + if ($verify_schema) { |
|
| 377 | + $this->initialize_db(); |
|
| 378 | + } |
|
| 379 | + $this->initialize_default_data(); |
|
| 380 | + //@todo: this will probably need to be adjusted in 4.4 as the array changed formats I believe |
|
| 381 | + EE_Data_Migration_Manager::instance()->update_current_database_state_to( |
|
| 382 | + array( |
|
| 383 | + 'slug' => $this->name(), |
|
| 384 | + 'version' => $this->version(), |
|
| 385 | + ) |
|
| 386 | + ); |
|
| 387 | + /* make sure core's data is a-ok |
|
| 388 | 388 | * (at the time of writing, we especially want to verify all the caps are present |
| 389 | 389 | * because payment method type capabilities are added dynamically, and it's |
| 390 | 390 | * possible this addon added a payment method. But it's also possible |
| 391 | 391 | * other data needs to be verified) |
| 392 | 392 | */ |
| 393 | - EEH_Activation::initialize_db_content(); |
|
| 394 | - update_option('ee_flush_rewrite_rules', true); |
|
| 395 | - //in case there are lots of addons being activated at once, let's force garbage collection |
|
| 396 | - //to help avoid memory limit errors |
|
| 397 | - //EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true ); |
|
| 398 | - gc_collect_cycles(); |
|
| 399 | - } else { |
|
| 400 | - //ask the data migration manager to init this addon's data |
|
| 401 | - //when migrations are finished because we can't do it now |
|
| 402 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name()); |
|
| 403 | - } |
|
| 404 | - } |
|
| 405 | - |
|
| 406 | - |
|
| 407 | - /** |
|
| 408 | - * Used to setup this addon's database tables, but not necessarily any default |
|
| 409 | - * data in them. The default is to actually use the most up-to-date data migration script |
|
| 410 | - * for this addon, and just use its schema_changes_before_migration() and schema_changes_after_migration() |
|
| 411 | - * methods to setup the db. |
|
| 412 | - */ |
|
| 413 | - public function initialize_db() |
|
| 414 | - { |
|
| 415 | - //find the migration script that sets the database to be compatible with the code |
|
| 416 | - $current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name()); |
|
| 417 | - if ($current_dms_name) { |
|
| 418 | - $current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name); |
|
| 419 | - $current_data_migration_script->set_migrating(false); |
|
| 420 | - $current_data_migration_script->schema_changes_before_migration(); |
|
| 421 | - $current_data_migration_script->schema_changes_after_migration(); |
|
| 422 | - if ($current_data_migration_script->get_errors()) { |
|
| 423 | - foreach ($current_data_migration_script->get_errors() as $error) { |
|
| 424 | - EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 425 | - } |
|
| 426 | - } |
|
| 427 | - } |
|
| 428 | - //if not DMS was found that should be ok. This addon just doesn't require any database changes |
|
| 429 | - EE_Data_Migration_Manager::instance()->update_current_database_state_to( |
|
| 430 | - array( |
|
| 431 | - 'slug' => $this->name(), |
|
| 432 | - 'version' => $this->version(), |
|
| 433 | - ) |
|
| 434 | - ); |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * If you want to setup default data for the addon, override this method, and call |
|
| 440 | - * parent::initialize_default_data() from within it. This is normally called |
|
| 441 | - * from EE_Addon::initialize_db_if_no_migrations_required(), just after EE_Addon::initialize_db() |
|
| 442 | - * and should verify default data is present (but this is also called |
|
| 443 | - * on reactivations and just after migrations, so please verify you actually want |
|
| 444 | - * to ADD default data, because it may already be present). |
|
| 445 | - * However, please call this parent (currently it just fires a hook which other |
|
| 446 | - * addons may be depending on) |
|
| 447 | - */ |
|
| 448 | - public function initialize_default_data() |
|
| 449 | - { |
|
| 450 | - /** |
|
| 451 | - * Called when an addon is ensuring its default data is set (possibly called |
|
| 452 | - * on a reactivation, so first check for the absence of other data before setting |
|
| 453 | - * default data) |
|
| 454 | - * |
|
| 455 | - * @param EE_Addon $addon the addon that called this |
|
| 456 | - */ |
|
| 457 | - do_action('AHEE__EE_Addon__initialize_default_data__begin', $this); |
|
| 458 | - //override to insert default data. It is safe to use the models here |
|
| 459 | - //because the site should not be in maintenance mode |
|
| 460 | - } |
|
| 461 | - |
|
| 462 | - |
|
| 463 | - /** |
|
| 464 | - * EE Core detected that this addon has been upgraded. We should check if there |
|
| 465 | - * are any new migration scripts, and if so put the site into maintenance mode until |
|
| 466 | - * they're ran |
|
| 467 | - * |
|
| 468 | - * @return void |
|
| 469 | - */ |
|
| 470 | - public function upgrade() |
|
| 471 | - { |
|
| 472 | - $classname = get_class($this); |
|
| 473 | - do_action("AHEE__{$classname}__upgrade"); |
|
| 474 | - do_action('AHEE__EE_Addon__upgrade', $this); |
|
| 475 | - EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 476 | - //also it's possible there is new default data that needs to be added |
|
| 477 | - add_action( |
|
| 478 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 479 | - array($this, 'initialize_db_if_no_migrations_required') |
|
| 480 | - ); |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - |
|
| 484 | - /** |
|
| 485 | - * If Core detects this addon has been downgraded, you may want to invoke some special logic here. |
|
| 486 | - */ |
|
| 487 | - public function downgrade() |
|
| 488 | - { |
|
| 489 | - $classname = get_class($this); |
|
| 490 | - do_action("AHEE__{$classname}__downgrade"); |
|
| 491 | - do_action('AHEE__EE_Addon__downgrade', $this); |
|
| 492 | - //it's possible there's old default data that needs to be double-checked |
|
| 493 | - add_action( |
|
| 494 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 495 | - array($this, 'initialize_db_if_no_migrations_required') |
|
| 496 | - ); |
|
| 497 | - } |
|
| 498 | - |
|
| 499 | - |
|
| 500 | - /** |
|
| 501 | - * set_db_update_option_name |
|
| 502 | - * Until we do something better, we'll just check for migration scripts upon |
|
| 503 | - * plugin activation only. In the future, we'll want to do it on plugin updates too |
|
| 504 | - * |
|
| 505 | - * @return bool |
|
| 506 | - */ |
|
| 507 | - public function set_db_update_option_name() |
|
| 508 | - { |
|
| 509 | - EE_Error::doing_it_wrong( |
|
| 510 | - __FUNCTION__, |
|
| 511 | - esc_html__( |
|
| 512 | - 'EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option', |
|
| 513 | - 'event_espresso' |
|
| 514 | - ), |
|
| 515 | - '4.3.0.alpha.016' |
|
| 516 | - ); |
|
| 517 | - //let's just handle this on the next request, ok? right now we're just not really ready |
|
| 518 | - return $this->set_activation_indicator_option(); |
|
| 519 | - } |
|
| 520 | - |
|
| 521 | - |
|
| 522 | - /** |
|
| 523 | - * Returns the name of the activation indicator option |
|
| 524 | - * (an option which is set temporarily to indicate that this addon was just activated) |
|
| 525 | - * |
|
| 526 | - * @deprecated since version 4.3.0.alpha.016 |
|
| 527 | - * @return string |
|
| 528 | - */ |
|
| 529 | - public function get_db_update_option_name() |
|
| 530 | - { |
|
| 531 | - EE_Error::doing_it_wrong( |
|
| 532 | - __FUNCTION__, |
|
| 533 | - esc_html__( |
|
| 534 | - 'EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name', |
|
| 535 | - 'event_espresso' |
|
| 536 | - ), |
|
| 537 | - '4.3.0.alpha.016' |
|
| 538 | - ); |
|
| 539 | - return $this->get_activation_indicator_option_name(); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * When the addon is activated, this should be called to set a wordpress option that |
|
| 545 | - * indicates it was activated. This is especially useful for detecting reactivations. |
|
| 546 | - * |
|
| 547 | - * @return bool |
|
| 548 | - */ |
|
| 549 | - public function set_activation_indicator_option() |
|
| 550 | - { |
|
| 551 | - // let's just handle this on the next request, ok? right now we're just not really ready |
|
| 552 | - return update_option($this->get_activation_indicator_option_name(), true); |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - |
|
| 556 | - /** |
|
| 557 | - * Gets the name of the wp option which is used to temporarily indicate that this addon was activated |
|
| 558 | - * |
|
| 559 | - * @return string |
|
| 560 | - */ |
|
| 561 | - public function get_activation_indicator_option_name() |
|
| 562 | - { |
|
| 563 | - return 'ee_activation_' . $this->name(); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - |
|
| 567 | - /** |
|
| 568 | - * Used by EE_System to set the request type of this addon. Should not be used by addon developers |
|
| 569 | - * |
|
| 570 | - * @param int $req_type |
|
| 571 | - */ |
|
| 572 | - public function set_req_type($req_type) |
|
| 573 | - { |
|
| 574 | - $this->_req_type = $req_type; |
|
| 575 | - } |
|
| 576 | - |
|
| 577 | - |
|
| 578 | - /** |
|
| 579 | - * Returns the request type of this addon (ie, EE_System::req_type_normal, EE_System::req_type_new_activation, |
|
| 580 | - * EE_System::req_type_reactivation, EE_System::req_type_upgrade, or EE_System::req_type_downgrade). This is set by |
|
| 581 | - * EE_System when it is checking for new install or upgrades of addons |
|
| 582 | - */ |
|
| 583 | - public function detect_req_type() |
|
| 584 | - { |
|
| 585 | - if (! $this->_req_type) { |
|
| 586 | - $this->detect_activation_or_upgrade(); |
|
| 587 | - } |
|
| 588 | - return $this->_req_type; |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.) |
|
| 594 | - * Should only be called once per request |
|
| 595 | - * |
|
| 596 | - * @return void |
|
| 597 | - */ |
|
| 598 | - public function detect_activation_or_upgrade() |
|
| 599 | - { |
|
| 600 | - $activation_history_for_addon = $this->get_activation_history(); |
|
| 393 | + EEH_Activation::initialize_db_content(); |
|
| 394 | + update_option('ee_flush_rewrite_rules', true); |
|
| 395 | + //in case there are lots of addons being activated at once, let's force garbage collection |
|
| 396 | + //to help avoid memory limit errors |
|
| 397 | + //EEH_Debug_Tools::instance()->measure_memory( 'db content initialized for ' . get_class( $this), true ); |
|
| 398 | + gc_collect_cycles(); |
|
| 399 | + } else { |
|
| 400 | + //ask the data migration manager to init this addon's data |
|
| 401 | + //when migrations are finished because we can't do it now |
|
| 402 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for($this->name()); |
|
| 403 | + } |
|
| 404 | + } |
|
| 405 | + |
|
| 406 | + |
|
| 407 | + /** |
|
| 408 | + * Used to setup this addon's database tables, but not necessarily any default |
|
| 409 | + * data in them. The default is to actually use the most up-to-date data migration script |
|
| 410 | + * for this addon, and just use its schema_changes_before_migration() and schema_changes_after_migration() |
|
| 411 | + * methods to setup the db. |
|
| 412 | + */ |
|
| 413 | + public function initialize_db() |
|
| 414 | + { |
|
| 415 | + //find the migration script that sets the database to be compatible with the code |
|
| 416 | + $current_dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms($this->name()); |
|
| 417 | + if ($current_dms_name) { |
|
| 418 | + $current_data_migration_script = EE_Registry::instance()->load_dms($current_dms_name); |
|
| 419 | + $current_data_migration_script->set_migrating(false); |
|
| 420 | + $current_data_migration_script->schema_changes_before_migration(); |
|
| 421 | + $current_data_migration_script->schema_changes_after_migration(); |
|
| 422 | + if ($current_data_migration_script->get_errors()) { |
|
| 423 | + foreach ($current_data_migration_script->get_errors() as $error) { |
|
| 424 | + EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__); |
|
| 425 | + } |
|
| 426 | + } |
|
| 427 | + } |
|
| 428 | + //if not DMS was found that should be ok. This addon just doesn't require any database changes |
|
| 429 | + EE_Data_Migration_Manager::instance()->update_current_database_state_to( |
|
| 430 | + array( |
|
| 431 | + 'slug' => $this->name(), |
|
| 432 | + 'version' => $this->version(), |
|
| 433 | + ) |
|
| 434 | + ); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * If you want to setup default data for the addon, override this method, and call |
|
| 440 | + * parent::initialize_default_data() from within it. This is normally called |
|
| 441 | + * from EE_Addon::initialize_db_if_no_migrations_required(), just after EE_Addon::initialize_db() |
|
| 442 | + * and should verify default data is present (but this is also called |
|
| 443 | + * on reactivations and just after migrations, so please verify you actually want |
|
| 444 | + * to ADD default data, because it may already be present). |
|
| 445 | + * However, please call this parent (currently it just fires a hook which other |
|
| 446 | + * addons may be depending on) |
|
| 447 | + */ |
|
| 448 | + public function initialize_default_data() |
|
| 449 | + { |
|
| 450 | + /** |
|
| 451 | + * Called when an addon is ensuring its default data is set (possibly called |
|
| 452 | + * on a reactivation, so first check for the absence of other data before setting |
|
| 453 | + * default data) |
|
| 454 | + * |
|
| 455 | + * @param EE_Addon $addon the addon that called this |
|
| 456 | + */ |
|
| 457 | + do_action('AHEE__EE_Addon__initialize_default_data__begin', $this); |
|
| 458 | + //override to insert default data. It is safe to use the models here |
|
| 459 | + //because the site should not be in maintenance mode |
|
| 460 | + } |
|
| 461 | + |
|
| 462 | + |
|
| 463 | + /** |
|
| 464 | + * EE Core detected that this addon has been upgraded. We should check if there |
|
| 465 | + * are any new migration scripts, and if so put the site into maintenance mode until |
|
| 466 | + * they're ran |
|
| 467 | + * |
|
| 468 | + * @return void |
|
| 469 | + */ |
|
| 470 | + public function upgrade() |
|
| 471 | + { |
|
| 472 | + $classname = get_class($this); |
|
| 473 | + do_action("AHEE__{$classname}__upgrade"); |
|
| 474 | + do_action('AHEE__EE_Addon__upgrade', $this); |
|
| 475 | + EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old(); |
|
| 476 | + //also it's possible there is new default data that needs to be added |
|
| 477 | + add_action( |
|
| 478 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 479 | + array($this, 'initialize_db_if_no_migrations_required') |
|
| 480 | + ); |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + |
|
| 484 | + /** |
|
| 485 | + * If Core detects this addon has been downgraded, you may want to invoke some special logic here. |
|
| 486 | + */ |
|
| 487 | + public function downgrade() |
|
| 488 | + { |
|
| 489 | + $classname = get_class($this); |
|
| 490 | + do_action("AHEE__{$classname}__downgrade"); |
|
| 491 | + do_action('AHEE__EE_Addon__downgrade', $this); |
|
| 492 | + //it's possible there's old default data that needs to be double-checked |
|
| 493 | + add_action( |
|
| 494 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 495 | + array($this, 'initialize_db_if_no_migrations_required') |
|
| 496 | + ); |
|
| 497 | + } |
|
| 498 | + |
|
| 499 | + |
|
| 500 | + /** |
|
| 501 | + * set_db_update_option_name |
|
| 502 | + * Until we do something better, we'll just check for migration scripts upon |
|
| 503 | + * plugin activation only. In the future, we'll want to do it on plugin updates too |
|
| 504 | + * |
|
| 505 | + * @return bool |
|
| 506 | + */ |
|
| 507 | + public function set_db_update_option_name() |
|
| 508 | + { |
|
| 509 | + EE_Error::doing_it_wrong( |
|
| 510 | + __FUNCTION__, |
|
| 511 | + esc_html__( |
|
| 512 | + 'EE_Addon::set_db_update_option_name was renamed to EE_Addon::set_activation_indicator_option', |
|
| 513 | + 'event_espresso' |
|
| 514 | + ), |
|
| 515 | + '4.3.0.alpha.016' |
|
| 516 | + ); |
|
| 517 | + //let's just handle this on the next request, ok? right now we're just not really ready |
|
| 518 | + return $this->set_activation_indicator_option(); |
|
| 519 | + } |
|
| 520 | + |
|
| 521 | + |
|
| 522 | + /** |
|
| 523 | + * Returns the name of the activation indicator option |
|
| 524 | + * (an option which is set temporarily to indicate that this addon was just activated) |
|
| 525 | + * |
|
| 526 | + * @deprecated since version 4.3.0.alpha.016 |
|
| 527 | + * @return string |
|
| 528 | + */ |
|
| 529 | + public function get_db_update_option_name() |
|
| 530 | + { |
|
| 531 | + EE_Error::doing_it_wrong( |
|
| 532 | + __FUNCTION__, |
|
| 533 | + esc_html__( |
|
| 534 | + 'EE_Addon::get_db_update_option was renamed to EE_Addon::get_activation_indicator_option_name', |
|
| 535 | + 'event_espresso' |
|
| 536 | + ), |
|
| 537 | + '4.3.0.alpha.016' |
|
| 538 | + ); |
|
| 539 | + return $this->get_activation_indicator_option_name(); |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * When the addon is activated, this should be called to set a wordpress option that |
|
| 545 | + * indicates it was activated. This is especially useful for detecting reactivations. |
|
| 546 | + * |
|
| 547 | + * @return bool |
|
| 548 | + */ |
|
| 549 | + public function set_activation_indicator_option() |
|
| 550 | + { |
|
| 551 | + // let's just handle this on the next request, ok? right now we're just not really ready |
|
| 552 | + return update_option($this->get_activation_indicator_option_name(), true); |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + |
|
| 556 | + /** |
|
| 557 | + * Gets the name of the wp option which is used to temporarily indicate that this addon was activated |
|
| 558 | + * |
|
| 559 | + * @return string |
|
| 560 | + */ |
|
| 561 | + public function get_activation_indicator_option_name() |
|
| 562 | + { |
|
| 563 | + return 'ee_activation_' . $this->name(); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + |
|
| 567 | + /** |
|
| 568 | + * Used by EE_System to set the request type of this addon. Should not be used by addon developers |
|
| 569 | + * |
|
| 570 | + * @param int $req_type |
|
| 571 | + */ |
|
| 572 | + public function set_req_type($req_type) |
|
| 573 | + { |
|
| 574 | + $this->_req_type = $req_type; |
|
| 575 | + } |
|
| 576 | + |
|
| 577 | + |
|
| 578 | + /** |
|
| 579 | + * Returns the request type of this addon (ie, EE_System::req_type_normal, EE_System::req_type_new_activation, |
|
| 580 | + * EE_System::req_type_reactivation, EE_System::req_type_upgrade, or EE_System::req_type_downgrade). This is set by |
|
| 581 | + * EE_System when it is checking for new install or upgrades of addons |
|
| 582 | + */ |
|
| 583 | + public function detect_req_type() |
|
| 584 | + { |
|
| 585 | + if (! $this->_req_type) { |
|
| 586 | + $this->detect_activation_or_upgrade(); |
|
| 587 | + } |
|
| 588 | + return $this->_req_type; |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * Detects the request type for this addon (whether it was just activated, upgrades, a normal request, etc.) |
|
| 594 | + * Should only be called once per request |
|
| 595 | + * |
|
| 596 | + * @return void |
|
| 597 | + */ |
|
| 598 | + public function detect_activation_or_upgrade() |
|
| 599 | + { |
|
| 600 | + $activation_history_for_addon = $this->get_activation_history(); |
|
| 601 | 601 | // d($activation_history_for_addon); |
| 602 | - $request_type = EE_System::detect_req_type_given_activation_history( |
|
| 603 | - $activation_history_for_addon, |
|
| 604 | - $this->get_activation_indicator_option_name(), |
|
| 605 | - $this->version() |
|
| 606 | - ); |
|
| 607 | - $this->set_req_type($request_type); |
|
| 608 | - $classname = get_class($this); |
|
| 609 | - switch ($request_type) { |
|
| 610 | - case EE_System::req_type_new_activation: |
|
| 611 | - do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation"); |
|
| 612 | - do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this); |
|
| 613 | - $this->new_install(); |
|
| 614 | - $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 615 | - break; |
|
| 616 | - case EE_System::req_type_reactivation: |
|
| 617 | - do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation"); |
|
| 618 | - do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this); |
|
| 619 | - $this->reactivation(); |
|
| 620 | - $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 621 | - break; |
|
| 622 | - case EE_System::req_type_upgrade: |
|
| 623 | - do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade"); |
|
| 624 | - do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this); |
|
| 625 | - $this->upgrade(); |
|
| 626 | - $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 627 | - break; |
|
| 628 | - case EE_System::req_type_downgrade: |
|
| 629 | - do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade"); |
|
| 630 | - do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this); |
|
| 631 | - $this->downgrade(); |
|
| 632 | - $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 633 | - break; |
|
| 634 | - case EE_System::req_type_normal: |
|
| 635 | - default: |
|
| 602 | + $request_type = EE_System::detect_req_type_given_activation_history( |
|
| 603 | + $activation_history_for_addon, |
|
| 604 | + $this->get_activation_indicator_option_name(), |
|
| 605 | + $this->version() |
|
| 606 | + ); |
|
| 607 | + $this->set_req_type($request_type); |
|
| 608 | + $classname = get_class($this); |
|
| 609 | + switch ($request_type) { |
|
| 610 | + case EE_System::req_type_new_activation: |
|
| 611 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__new_activation"); |
|
| 612 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__new_activation', $this); |
|
| 613 | + $this->new_install(); |
|
| 614 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 615 | + break; |
|
| 616 | + case EE_System::req_type_reactivation: |
|
| 617 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__reactivation"); |
|
| 618 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__reactivation', $this); |
|
| 619 | + $this->reactivation(); |
|
| 620 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 621 | + break; |
|
| 622 | + case EE_System::req_type_upgrade: |
|
| 623 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__upgrade"); |
|
| 624 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__upgrade', $this); |
|
| 625 | + $this->upgrade(); |
|
| 626 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 627 | + break; |
|
| 628 | + case EE_System::req_type_downgrade: |
|
| 629 | + do_action("AHEE__{$classname}__detect_activations_or_upgrades__downgrade"); |
|
| 630 | + do_action('AHEE__EE_Addon__detect_activations_or_upgrades__downgrade', $this); |
|
| 631 | + $this->downgrade(); |
|
| 632 | + $this->update_list_of_installed_versions($activation_history_for_addon); |
|
| 633 | + break; |
|
| 634 | + case EE_System::req_type_normal: |
|
| 635 | + default: |
|
| 636 | 636 | // $this->_maybe_redirect_to_ee_about(); |
| 637 | - break; |
|
| 638 | - } |
|
| 639 | - |
|
| 640 | - do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete"); |
|
| 641 | - } |
|
| 642 | - |
|
| 643 | - /** |
|
| 644 | - * Updates the version history for this addon |
|
| 645 | - * |
|
| 646 | - * @param array $version_history |
|
| 647 | - * @param string $current_version_to_add |
|
| 648 | - * @return boolean success |
|
| 649 | - */ |
|
| 650 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 651 | - { |
|
| 652 | - if (! $version_history) { |
|
| 653 | - $version_history = $this->get_activation_history(); |
|
| 654 | - } |
|
| 655 | - if ($current_version_to_add === null) { |
|
| 656 | - $current_version_to_add = $this->version(); |
|
| 657 | - } |
|
| 658 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
| 659 | - // resave |
|
| 637 | + break; |
|
| 638 | + } |
|
| 639 | + |
|
| 640 | + do_action("AHEE__{$classname}__detect_if_activation_or_upgrade__complete"); |
|
| 641 | + } |
|
| 642 | + |
|
| 643 | + /** |
|
| 644 | + * Updates the version history for this addon |
|
| 645 | + * |
|
| 646 | + * @param array $version_history |
|
| 647 | + * @param string $current_version_to_add |
|
| 648 | + * @return boolean success |
|
| 649 | + */ |
|
| 650 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 651 | + { |
|
| 652 | + if (! $version_history) { |
|
| 653 | + $version_history = $this->get_activation_history(); |
|
| 654 | + } |
|
| 655 | + if ($current_version_to_add === null) { |
|
| 656 | + $current_version_to_add = $this->version(); |
|
| 657 | + } |
|
| 658 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
| 659 | + // resave |
|
| 660 | 660 | // echo "updating list of installed versions:".$this->get_activation_history_option_name();d($version_history); |
| 661 | - return update_option($this->get_activation_history_option_name(), $version_history); |
|
| 662 | - } |
|
| 663 | - |
|
| 664 | - /** |
|
| 665 | - * Gets the name of the wp option that stores the activation history |
|
| 666 | - * of this addon |
|
| 667 | - * |
|
| 668 | - * @return string |
|
| 669 | - */ |
|
| 670 | - public function get_activation_history_option_name() |
|
| 671 | - { |
|
| 672 | - return self::ee_addon_version_history_option_prefix . $this->name(); |
|
| 673 | - } |
|
| 674 | - |
|
| 675 | - |
|
| 676 | - /** |
|
| 677 | - * Gets the wp option which stores the activation history for this addon |
|
| 678 | - * |
|
| 679 | - * @return array |
|
| 680 | - */ |
|
| 681 | - public function get_activation_history() |
|
| 682 | - { |
|
| 683 | - return get_option($this->get_activation_history_option_name(), null); |
|
| 684 | - } |
|
| 685 | - |
|
| 686 | - |
|
| 687 | - /** |
|
| 688 | - * @param string $config_section |
|
| 689 | - */ |
|
| 690 | - public function set_config_section($config_section = '') |
|
| 691 | - { |
|
| 692 | - $this->_config_section = ! empty($config_section) ? $config_section : 'addons'; |
|
| 693 | - } |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * Sets the filepath to the main plugin file |
|
| 697 | - * |
|
| 698 | - * @param string $filepath |
|
| 699 | - */ |
|
| 700 | - public function set_main_plugin_file($filepath) |
|
| 701 | - { |
|
| 702 | - $this->_main_plugin_file = $filepath; |
|
| 703 | - } |
|
| 704 | - |
|
| 705 | - /** |
|
| 706 | - * gets the filepath to teh main file |
|
| 707 | - * |
|
| 708 | - * @return string |
|
| 709 | - */ |
|
| 710 | - public function get_main_plugin_file() |
|
| 711 | - { |
|
| 712 | - return $this->_main_plugin_file; |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - /** |
|
| 716 | - * Gets the filename (no path) of the main file (the main file loaded |
|
| 717 | - * by WP) |
|
| 718 | - * |
|
| 719 | - * @return string |
|
| 720 | - */ |
|
| 721 | - public function get_main_plugin_file_basename() |
|
| 722 | - { |
|
| 723 | - return plugin_basename($this->get_main_plugin_file()); |
|
| 724 | - } |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * Gets the folder name which contains the main plugin file |
|
| 728 | - * |
|
| 729 | - * @return string |
|
| 730 | - */ |
|
| 731 | - public function get_main_plugin_file_dirname() |
|
| 732 | - { |
|
| 733 | - return dirname($this->get_main_plugin_file()); |
|
| 734 | - } |
|
| 735 | - |
|
| 736 | - |
|
| 737 | - /** |
|
| 738 | - * sets hooks used in the admin |
|
| 739 | - * |
|
| 740 | - * @return void |
|
| 741 | - */ |
|
| 742 | - public function admin_init() |
|
| 743 | - { |
|
| 744 | - // is admin and not in M-Mode ? |
|
| 745 | - if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
| 746 | - add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); |
|
| 747 | - add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3); |
|
| 748 | - } |
|
| 749 | - } |
|
| 750 | - |
|
| 751 | - |
|
| 752 | - /** |
|
| 753 | - * plugin_actions |
|
| 754 | - * Add a settings link to the Plugins page, so people can go straight from the plugin page to the settings page. |
|
| 755 | - * |
|
| 756 | - * @param $links |
|
| 757 | - * @param $file |
|
| 758 | - * @return array |
|
| 759 | - */ |
|
| 760 | - public function plugin_action_links($links, $file) |
|
| 761 | - { |
|
| 762 | - if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') { |
|
| 763 | - // before other links |
|
| 764 | - array_unshift( |
|
| 765 | - $links, |
|
| 766 | - '<a href="admin.php?page=' . $this->plugin_action_slug() . '">' |
|
| 767 | - . esc_html__('Settings', 'event_espresso') |
|
| 768 | - . '</a>' |
|
| 769 | - ); |
|
| 770 | - } |
|
| 771 | - return $links; |
|
| 772 | - } |
|
| 773 | - |
|
| 774 | - |
|
| 775 | - /** |
|
| 776 | - * after_plugin_row |
|
| 777 | - * Add additional content to the plugins page plugin row |
|
| 778 | - * Inserts another row |
|
| 779 | - * |
|
| 780 | - * @param $plugin_file |
|
| 781 | - * @param $plugin_data |
|
| 782 | - * @param $status |
|
| 783 | - * @return void |
|
| 784 | - */ |
|
| 785 | - public function after_plugin_row($plugin_file, $plugin_data, $status) |
|
| 786 | - { |
|
| 787 | - $after_plugin_row = ''; |
|
| 788 | - $plugins_page_row = $this->get_plugins_page_row(); |
|
| 789 | - if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) { |
|
| 790 | - $class = $status ? 'active' : 'inactive'; |
|
| 791 | - $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : ''; |
|
| 792 | - $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : ''; |
|
| 793 | - $description = isset($plugins_page_row['description']) |
|
| 794 | - ? $plugins_page_row['description'] |
|
| 795 | - : ''; |
|
| 796 | - if (! empty($link_text) && ! empty($link_url) && ! empty($description)) { |
|
| 797 | - $after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">'; |
|
| 798 | - $after_plugin_row .= '<th class="check-column" scope="row"></th>'; |
|
| 799 | - $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">'; |
|
| 800 | - $after_plugin_row .= '<style> |
|
| 661 | + return update_option($this->get_activation_history_option_name(), $version_history); |
|
| 662 | + } |
|
| 663 | + |
|
| 664 | + /** |
|
| 665 | + * Gets the name of the wp option that stores the activation history |
|
| 666 | + * of this addon |
|
| 667 | + * |
|
| 668 | + * @return string |
|
| 669 | + */ |
|
| 670 | + public function get_activation_history_option_name() |
|
| 671 | + { |
|
| 672 | + return self::ee_addon_version_history_option_prefix . $this->name(); |
|
| 673 | + } |
|
| 674 | + |
|
| 675 | + |
|
| 676 | + /** |
|
| 677 | + * Gets the wp option which stores the activation history for this addon |
|
| 678 | + * |
|
| 679 | + * @return array |
|
| 680 | + */ |
|
| 681 | + public function get_activation_history() |
|
| 682 | + { |
|
| 683 | + return get_option($this->get_activation_history_option_name(), null); |
|
| 684 | + } |
|
| 685 | + |
|
| 686 | + |
|
| 687 | + /** |
|
| 688 | + * @param string $config_section |
|
| 689 | + */ |
|
| 690 | + public function set_config_section($config_section = '') |
|
| 691 | + { |
|
| 692 | + $this->_config_section = ! empty($config_section) ? $config_section : 'addons'; |
|
| 693 | + } |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * Sets the filepath to the main plugin file |
|
| 697 | + * |
|
| 698 | + * @param string $filepath |
|
| 699 | + */ |
|
| 700 | + public function set_main_plugin_file($filepath) |
|
| 701 | + { |
|
| 702 | + $this->_main_plugin_file = $filepath; |
|
| 703 | + } |
|
| 704 | + |
|
| 705 | + /** |
|
| 706 | + * gets the filepath to teh main file |
|
| 707 | + * |
|
| 708 | + * @return string |
|
| 709 | + */ |
|
| 710 | + public function get_main_plugin_file() |
|
| 711 | + { |
|
| 712 | + return $this->_main_plugin_file; |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + /** |
|
| 716 | + * Gets the filename (no path) of the main file (the main file loaded |
|
| 717 | + * by WP) |
|
| 718 | + * |
|
| 719 | + * @return string |
|
| 720 | + */ |
|
| 721 | + public function get_main_plugin_file_basename() |
|
| 722 | + { |
|
| 723 | + return plugin_basename($this->get_main_plugin_file()); |
|
| 724 | + } |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * Gets the folder name which contains the main plugin file |
|
| 728 | + * |
|
| 729 | + * @return string |
|
| 730 | + */ |
|
| 731 | + public function get_main_plugin_file_dirname() |
|
| 732 | + { |
|
| 733 | + return dirname($this->get_main_plugin_file()); |
|
| 734 | + } |
|
| 735 | + |
|
| 736 | + |
|
| 737 | + /** |
|
| 738 | + * sets hooks used in the admin |
|
| 739 | + * |
|
| 740 | + * @return void |
|
| 741 | + */ |
|
| 742 | + public function admin_init() |
|
| 743 | + { |
|
| 744 | + // is admin and not in M-Mode ? |
|
| 745 | + if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
|
| 746 | + add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); |
|
| 747 | + add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3); |
|
| 748 | + } |
|
| 749 | + } |
|
| 750 | + |
|
| 751 | + |
|
| 752 | + /** |
|
| 753 | + * plugin_actions |
|
| 754 | + * Add a settings link to the Plugins page, so people can go straight from the plugin page to the settings page. |
|
| 755 | + * |
|
| 756 | + * @param $links |
|
| 757 | + * @param $file |
|
| 758 | + * @return array |
|
| 759 | + */ |
|
| 760 | + public function plugin_action_links($links, $file) |
|
| 761 | + { |
|
| 762 | + if ($file === $this->plugin_basename() && $this->plugin_action_slug() !== '') { |
|
| 763 | + // before other links |
|
| 764 | + array_unshift( |
|
| 765 | + $links, |
|
| 766 | + '<a href="admin.php?page=' . $this->plugin_action_slug() . '">' |
|
| 767 | + . esc_html__('Settings', 'event_espresso') |
|
| 768 | + . '</a>' |
|
| 769 | + ); |
|
| 770 | + } |
|
| 771 | + return $links; |
|
| 772 | + } |
|
| 773 | + |
|
| 774 | + |
|
| 775 | + /** |
|
| 776 | + * after_plugin_row |
|
| 777 | + * Add additional content to the plugins page plugin row |
|
| 778 | + * Inserts another row |
|
| 779 | + * |
|
| 780 | + * @param $plugin_file |
|
| 781 | + * @param $plugin_data |
|
| 782 | + * @param $status |
|
| 783 | + * @return void |
|
| 784 | + */ |
|
| 785 | + public function after_plugin_row($plugin_file, $plugin_data, $status) |
|
| 786 | + { |
|
| 787 | + $after_plugin_row = ''; |
|
| 788 | + $plugins_page_row = $this->get_plugins_page_row(); |
|
| 789 | + if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) { |
|
| 790 | + $class = $status ? 'active' : 'inactive'; |
|
| 791 | + $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : ''; |
|
| 792 | + $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : ''; |
|
| 793 | + $description = isset($plugins_page_row['description']) |
|
| 794 | + ? $plugins_page_row['description'] |
|
| 795 | + : ''; |
|
| 796 | + if (! empty($link_text) && ! empty($link_url) && ! empty($description)) { |
|
| 797 | + $after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">'; |
|
| 798 | + $after_plugin_row .= '<th class="check-column" scope="row"></th>'; |
|
| 799 | + $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">'; |
|
| 800 | + $after_plugin_row .= '<style> |
|
| 801 | 801 | .ee-button, |
| 802 | 802 | .ee-button:active, |
| 803 | 803 | .ee-button:visited { |
@@ -834,49 +834,49 @@ discard block |
||
| 834 | 834 | } |
| 835 | 835 | .ee-button:active { top:0; } |
| 836 | 836 | </style>'; |
| 837 | - $after_plugin_row .= ' |
|
| 837 | + $after_plugin_row .= ' |
|
| 838 | 838 | <p class="ee-addon-upsell-info-dv"> |
| 839 | 839 | <a class="ee-button" href="' . $link_url . '">' |
| 840 | - . $link_text |
|
| 841 | - . ' <span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>' |
|
| 842 | - . '</a> |
|
| 840 | + . $link_text |
|
| 841 | + . ' <span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>' |
|
| 842 | + . '</a> |
|
| 843 | 843 | </p>'; |
| 844 | - $after_plugin_row .= '</td>'; |
|
| 845 | - $after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">'; |
|
| 846 | - $after_plugin_row .= $description; |
|
| 847 | - $after_plugin_row .= '</td>'; |
|
| 848 | - $after_plugin_row .= '</tr>'; |
|
| 849 | - } else { |
|
| 850 | - $after_plugin_row .= $description; |
|
| 851 | - } |
|
| 852 | - } |
|
| 853 | - |
|
| 854 | - echo $after_plugin_row; |
|
| 855 | - } |
|
| 856 | - |
|
| 857 | - |
|
| 858 | - /** |
|
| 859 | - * A safe space for addons to add additional logic like setting hooks that need to be set early in the request. |
|
| 860 | - * Child classes that have logic like that to run can override this method declaration. This was not made abstract |
|
| 861 | - * for back compat reasons. |
|
| 862 | - * |
|
| 863 | - * This will fire on the `AHEE__EE_System__load_espresso_addons__complete` hook at priority 999. |
|
| 864 | - * |
|
| 865 | - * It is recommended, if client code is `de-registering` an add-on, then do it on the |
|
| 866 | - * `AHEE__EE_System__load_espresso_addons__complete` hook before priority 999 so as to ensure any code logic in this |
|
| 867 | - * callback does not get run/set in that request. |
|
| 868 | - * |
|
| 869 | - * Also, keep in mind that if a registered add-on happens to be deactivated via |
|
| 870 | - * EE_System::_deactivate_incompatible_addons() because its incompatible, any code executed in this method |
|
| 871 | - * (including setting hooks etc) will have executed before the plugin was deactivated. If you use |
|
| 872 | - * `after_registration` to set any filter and/or action hooks and want to ensure they are removed on this add-on's |
|
| 873 | - * deactivation, you can override `EE_Addon::deactivation` and unset your hooks and filters there. Just remember |
|
| 874 | - * to call `parent::deactivation`. |
|
| 875 | - * |
|
| 876 | - * @since 4.9.26 |
|
| 877 | - */ |
|
| 878 | - public function after_registration() |
|
| 879 | - { |
|
| 880 | - // cricket chirp... cricket chirp... |
|
| 881 | - } |
|
| 844 | + $after_plugin_row .= '</td>'; |
|
| 845 | + $after_plugin_row .= '<td class="ee-addon-upsell-info-desc-td column-description desc">'; |
|
| 846 | + $after_plugin_row .= $description; |
|
| 847 | + $after_plugin_row .= '</td>'; |
|
| 848 | + $after_plugin_row .= '</tr>'; |
|
| 849 | + } else { |
|
| 850 | + $after_plugin_row .= $description; |
|
| 851 | + } |
|
| 852 | + } |
|
| 853 | + |
|
| 854 | + echo $after_plugin_row; |
|
| 855 | + } |
|
| 856 | + |
|
| 857 | + |
|
| 858 | + /** |
|
| 859 | + * A safe space for addons to add additional logic like setting hooks that need to be set early in the request. |
|
| 860 | + * Child classes that have logic like that to run can override this method declaration. This was not made abstract |
|
| 861 | + * for back compat reasons. |
|
| 862 | + * |
|
| 863 | + * This will fire on the `AHEE__EE_System__load_espresso_addons__complete` hook at priority 999. |
|
| 864 | + * |
|
| 865 | + * It is recommended, if client code is `de-registering` an add-on, then do it on the |
|
| 866 | + * `AHEE__EE_System__load_espresso_addons__complete` hook before priority 999 so as to ensure any code logic in this |
|
| 867 | + * callback does not get run/set in that request. |
|
| 868 | + * |
|
| 869 | + * Also, keep in mind that if a registered add-on happens to be deactivated via |
|
| 870 | + * EE_System::_deactivate_incompatible_addons() because its incompatible, any code executed in this method |
|
| 871 | + * (including setting hooks etc) will have executed before the plugin was deactivated. If you use |
|
| 872 | + * `after_registration` to set any filter and/or action hooks and want to ensure they are removed on this add-on's |
|
| 873 | + * deactivation, you can override `EE_Addon::deactivation` and unset your hooks and filters there. Just remember |
|
| 874 | + * to call `parent::deactivation`. |
|
| 875 | + * |
|
| 876 | + * @since 4.9.26 |
|
| 877 | + */ |
|
| 878 | + public function after_registration() |
|
| 879 | + { |
|
| 880 | + // cricket chirp... cricket chirp... |
|
| 881 | + } |
|
| 882 | 882 | } |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | */ |
| 108 | 108 | public function __construct(EE_Dependency_Map $dependency_map = null, DomainInterface $domain = null) |
| 109 | 109 | { |
| 110 | - if($dependency_map instanceof EE_Dependency_Map) { |
|
| 110 | + if ($dependency_map instanceof EE_Dependency_Map) { |
|
| 111 | 111 | $this->setDependencyMap($dependency_map); |
| 112 | 112 | } |
| 113 | 113 | if ($domain instanceof DomainInterface) { |
@@ -291,7 +291,7 @@ discard block |
||
| 291 | 291 | public function set_plugins_page_row($plugins_page_row = array()) |
| 292 | 292 | { |
| 293 | 293 | // sigh.... check for example content that I stupidly merged to master and remove it if found |
| 294 | - if (! is_array($plugins_page_row) |
|
| 294 | + if ( ! is_array($plugins_page_row) |
|
| 295 | 295 | && strpos($plugins_page_row, '<h3>Promotions Addon Upsell Info</h3>') !== false |
| 296 | 296 | ) { |
| 297 | 297 | $plugins_page_row = array(); |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | */ |
| 561 | 561 | public function get_activation_indicator_option_name() |
| 562 | 562 | { |
| 563 | - return 'ee_activation_' . $this->name(); |
|
| 563 | + return 'ee_activation_'.$this->name(); |
|
| 564 | 564 | } |
| 565 | 565 | |
| 566 | 566 | |
@@ -582,7 +582,7 @@ discard block |
||
| 582 | 582 | */ |
| 583 | 583 | public function detect_req_type() |
| 584 | 584 | { |
| 585 | - if (! $this->_req_type) { |
|
| 585 | + if ( ! $this->_req_type) { |
|
| 586 | 586 | $this->detect_activation_or_upgrade(); |
| 587 | 587 | } |
| 588 | 588 | return $this->_req_type; |
@@ -649,7 +649,7 @@ discard block |
||
| 649 | 649 | */ |
| 650 | 650 | public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
| 651 | 651 | { |
| 652 | - if (! $version_history) { |
|
| 652 | + if ( ! $version_history) { |
|
| 653 | 653 | $version_history = $this->get_activation_history(); |
| 654 | 654 | } |
| 655 | 655 | if ($current_version_to_add === null) { |
@@ -669,7 +669,7 @@ discard block |
||
| 669 | 669 | */ |
| 670 | 670 | public function get_activation_history_option_name() |
| 671 | 671 | { |
| 672 | - return self::ee_addon_version_history_option_prefix . $this->name(); |
|
| 672 | + return self::ee_addon_version_history_option_prefix.$this->name(); |
|
| 673 | 673 | } |
| 674 | 674 | |
| 675 | 675 | |
@@ -744,7 +744,7 @@ discard block |
||
| 744 | 744 | // is admin and not in M-Mode ? |
| 745 | 745 | if (is_admin() && ! EE_Maintenance_Mode::instance()->level()) { |
| 746 | 746 | add_filter('plugin_action_links', array($this, 'plugin_action_links'), 10, 2); |
| 747 | - add_filter('after_plugin_row_' . $this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3); |
|
| 747 | + add_filter('after_plugin_row_'.$this->_plugin_basename, array($this, 'after_plugin_row'), 10, 3); |
|
| 748 | 748 | } |
| 749 | 749 | } |
| 750 | 750 | |
@@ -763,7 +763,7 @@ discard block |
||
| 763 | 763 | // before other links |
| 764 | 764 | array_unshift( |
| 765 | 765 | $links, |
| 766 | - '<a href="admin.php?page=' . $this->plugin_action_slug() . '">' |
|
| 766 | + '<a href="admin.php?page='.$this->plugin_action_slug().'">' |
|
| 767 | 767 | . esc_html__('Settings', 'event_espresso') |
| 768 | 768 | . '</a>' |
| 769 | 769 | ); |
@@ -786,15 +786,15 @@ discard block |
||
| 786 | 786 | { |
| 787 | 787 | $after_plugin_row = ''; |
| 788 | 788 | $plugins_page_row = $this->get_plugins_page_row(); |
| 789 | - if (! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) { |
|
| 789 | + if ( ! empty($plugins_page_row) && $plugin_file === $this->plugin_basename()) { |
|
| 790 | 790 | $class = $status ? 'active' : 'inactive'; |
| 791 | 791 | $link_text = isset($plugins_page_row['link_text']) ? $plugins_page_row['link_text'] : ''; |
| 792 | 792 | $link_url = isset($plugins_page_row['link_url']) ? $plugins_page_row['link_url'] : ''; |
| 793 | 793 | $description = isset($plugins_page_row['description']) |
| 794 | 794 | ? $plugins_page_row['description'] |
| 795 | 795 | : ''; |
| 796 | - if (! empty($link_text) && ! empty($link_url) && ! empty($description)) { |
|
| 797 | - $after_plugin_row .= '<tr id="' . sanitize_title($plugin_file) . '-ee-addon" class="' . $class . '">'; |
|
| 796 | + if ( ! empty($link_text) && ! empty($link_url) && ! empty($description)) { |
|
| 797 | + $after_plugin_row .= '<tr id="'.sanitize_title($plugin_file).'-ee-addon" class="'.$class.'">'; |
|
| 798 | 798 | $after_plugin_row .= '<th class="check-column" scope="row"></th>'; |
| 799 | 799 | $after_plugin_row .= '<td class="ee-addon-upsell-info-title-td plugin-title column-primary">'; |
| 800 | 800 | $after_plugin_row .= '<style> |
@@ -836,7 +836,7 @@ discard block |
||
| 836 | 836 | </style>'; |
| 837 | 837 | $after_plugin_row .= ' |
| 838 | 838 | <p class="ee-addon-upsell-info-dv"> |
| 839 | - <a class="ee-button" href="' . $link_url . '">' |
|
| 839 | + <a class="ee-button" href="' . $link_url.'">' |
|
| 840 | 840 | . $link_text |
| 841 | 841 | . ' <span class="dashicons dashicons-arrow-right-alt2" style="margin:0;"></span>' |
| 842 | 842 | . '</a> |
@@ -24,1137 +24,1137 @@ |
||
| 24 | 24 | { |
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * possibly truncated version of the EE core version string |
|
| 29 | - * |
|
| 30 | - * @var string |
|
| 31 | - */ |
|
| 32 | - protected static $_core_version = ''; |
|
| 27 | + /** |
|
| 28 | + * possibly truncated version of the EE core version string |
|
| 29 | + * |
|
| 30 | + * @var string |
|
| 31 | + */ |
|
| 32 | + protected static $_core_version = ''; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * Holds values for registered addons |
|
| 36 | - * |
|
| 37 | - * @var array |
|
| 38 | - */ |
|
| 39 | - protected static $_settings = array(); |
|
| 34 | + /** |
|
| 35 | + * Holds values for registered addons |
|
| 36 | + * |
|
| 37 | + * @var array |
|
| 38 | + */ |
|
| 39 | + protected static $_settings = array(); |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var array $_incompatible_addons keys are addon SLUGS |
|
| 43 | - * (first argument passed to EE_Register_Addon::register()), keys are |
|
| 44 | - * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
| 45 | - * Generally this should be used sparingly, as we don't want to muddle up |
|
| 46 | - * EE core with knowledge of ALL the addons out there. |
|
| 47 | - * If you want NO versions of an addon to run with a certain version of core, |
|
| 48 | - * it's usually best to define the addon's "min_core_version" as part of its call |
|
| 49 | - * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
| 50 | - * minimum plugin version. |
|
| 51 | - * @access protected |
|
| 52 | - */ |
|
| 53 | - protected static $_incompatible_addons = array( |
|
| 54 | - 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
| 55 | - 'Promotions' => '1.0.0.rc.084', |
|
| 56 | - ); |
|
| 41 | + /** |
|
| 42 | + * @var array $_incompatible_addons keys are addon SLUGS |
|
| 43 | + * (first argument passed to EE_Register_Addon::register()), keys are |
|
| 44 | + * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004). |
|
| 45 | + * Generally this should be used sparingly, as we don't want to muddle up |
|
| 46 | + * EE core with knowledge of ALL the addons out there. |
|
| 47 | + * If you want NO versions of an addon to run with a certain version of core, |
|
| 48 | + * it's usually best to define the addon's "min_core_version" as part of its call |
|
| 49 | + * to EE_Register_Addon::register(), rather than using this array with a super high value for its |
|
| 50 | + * minimum plugin version. |
|
| 51 | + * @access protected |
|
| 52 | + */ |
|
| 53 | + protected static $_incompatible_addons = array( |
|
| 54 | + 'Multi_Event_Registration' => '2.0.11.rc.002', |
|
| 55 | + 'Promotions' => '1.0.0.rc.084', |
|
| 56 | + ); |
|
| 57 | 57 | |
| 58 | 58 | |
| 59 | - /** |
|
| 60 | - * We should always be comparing core to a version like '4.3.0.rc.000', |
|
| 61 | - * not just '4.3.0'. |
|
| 62 | - * So if the addon developer doesn't provide that full version string, |
|
| 63 | - * fill in the blanks for them |
|
| 64 | - * |
|
| 65 | - * @param string $min_core_version |
|
| 66 | - * @return string always like '4.3.0.rc.000' |
|
| 67 | - */ |
|
| 68 | - protected static function _effective_version($min_core_version) |
|
| 69 | - { |
|
| 70 | - // versions: 4 . 3 . 1 . p . 123 |
|
| 71 | - // offsets: 0 . 1 . 2 . 3 . 4 |
|
| 72 | - $version_parts = explode('.', $min_core_version); |
|
| 73 | - //check they specified the micro version (after 2nd period) |
|
| 74 | - if (! isset($version_parts[2])) { |
|
| 75 | - $version_parts[2] = '0'; |
|
| 76 | - } |
|
| 77 | - //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
| 78 | - //soon we can assume that's 'rc', but this current version is 'alpha' |
|
| 79 | - if (! isset($version_parts[3])) { |
|
| 80 | - $version_parts[3] = 'dev'; |
|
| 81 | - } |
|
| 82 | - if (! isset($version_parts[4])) { |
|
| 83 | - $version_parts[4] = '000'; |
|
| 84 | - } |
|
| 85 | - return implode('.', $version_parts); |
|
| 86 | - } |
|
| 59 | + /** |
|
| 60 | + * We should always be comparing core to a version like '4.3.0.rc.000', |
|
| 61 | + * not just '4.3.0'. |
|
| 62 | + * So if the addon developer doesn't provide that full version string, |
|
| 63 | + * fill in the blanks for them |
|
| 64 | + * |
|
| 65 | + * @param string $min_core_version |
|
| 66 | + * @return string always like '4.3.0.rc.000' |
|
| 67 | + */ |
|
| 68 | + protected static function _effective_version($min_core_version) |
|
| 69 | + { |
|
| 70 | + // versions: 4 . 3 . 1 . p . 123 |
|
| 71 | + // offsets: 0 . 1 . 2 . 3 . 4 |
|
| 72 | + $version_parts = explode('.', $min_core_version); |
|
| 73 | + //check they specified the micro version (after 2nd period) |
|
| 74 | + if (! isset($version_parts[2])) { |
|
| 75 | + $version_parts[2] = '0'; |
|
| 76 | + } |
|
| 77 | + //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
|
| 78 | + //soon we can assume that's 'rc', but this current version is 'alpha' |
|
| 79 | + if (! isset($version_parts[3])) { |
|
| 80 | + $version_parts[3] = 'dev'; |
|
| 81 | + } |
|
| 82 | + if (! isset($version_parts[4])) { |
|
| 83 | + $version_parts[4] = '000'; |
|
| 84 | + } |
|
| 85 | + return implode('.', $version_parts); |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | 88 | |
| 89 | - /** |
|
| 90 | - * Returns whether or not the min core version requirement of the addon is met |
|
| 91 | - * |
|
| 92 | - * @param string $min_core_version the minimum core version required by the addon |
|
| 93 | - * @param string $actual_core_version the actual core version, optional |
|
| 94 | - * @return boolean |
|
| 95 | - */ |
|
| 96 | - public static function _meets_min_core_version_requirement( |
|
| 97 | - $min_core_version, |
|
| 98 | - $actual_core_version = EVENT_ESPRESSO_VERSION |
|
| 99 | - ) { |
|
| 100 | - return version_compare( |
|
| 101 | - self::_effective_version($actual_core_version), |
|
| 102 | - self::_effective_version($min_core_version), |
|
| 103 | - '>=' |
|
| 104 | - ); |
|
| 105 | - } |
|
| 89 | + /** |
|
| 90 | + * Returns whether or not the min core version requirement of the addon is met |
|
| 91 | + * |
|
| 92 | + * @param string $min_core_version the minimum core version required by the addon |
|
| 93 | + * @param string $actual_core_version the actual core version, optional |
|
| 94 | + * @return boolean |
|
| 95 | + */ |
|
| 96 | + public static function _meets_min_core_version_requirement( |
|
| 97 | + $min_core_version, |
|
| 98 | + $actual_core_version = EVENT_ESPRESSO_VERSION |
|
| 99 | + ) { |
|
| 100 | + return version_compare( |
|
| 101 | + self::_effective_version($actual_core_version), |
|
| 102 | + self::_effective_version($min_core_version), |
|
| 103 | + '>=' |
|
| 104 | + ); |
|
| 105 | + } |
|
| 106 | 106 | |
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * Method for registering new EE_Addons. |
|
| 110 | - * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
| 111 | - * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
| 112 | - * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
| 113 | - * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
| 114 | - * 'activate_plugin', it registers the addon still, but its components are not registered |
|
| 115 | - * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
| 116 | - * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
| 117 | - * (so that we can detect that the addon has activated on the subsequent request) |
|
| 118 | - * |
|
| 119 | - * @since 4.3.0 |
|
| 120 | - * @param string $addon_name the EE_Addon's name. Required. |
|
| 121 | - * @param array $setup_args { |
|
| 122 | - * An array of arguments provided for registering the |
|
| 123 | - * message type. |
|
| 124 | - * @type string $class_name the addon's main file name. |
|
| 125 | - * If left blank, generated from the addon name, |
|
| 126 | - * changes something like "calendar" to "EE_Calendar" |
|
| 127 | - * @type string $min_core_version the minimum version of EE Core that the |
|
| 128 | - * addon will work with. eg "4.8.1.rc.084" |
|
| 129 | - * @type string $version the "software" version for the addon. eg |
|
| 130 | - * "1.0.0.p" for a first stable release, or |
|
| 131 | - * "1.0.0.rc.043" for a version in progress |
|
| 132 | - * @type string $main_file_path the full server path to the main file |
|
| 133 | - * loaded directly by WP |
|
| 134 | - * @type string $domain_fqcn Fully Qualified Class Name |
|
| 135 | - * for the addon's Domain class |
|
| 136 | - * (see EventEspresso\core\domain\Domain) |
|
| 137 | - * @type string $admin_path full server path to the folder where the |
|
| 138 | - * addon\'s admin files reside |
|
| 139 | - * @type string $admin_callback a method to be called when the EE Admin is |
|
| 140 | - * first invoked, can be used for hooking into |
|
| 141 | - * any admin page |
|
| 142 | - * @type string $config_section the section name for this addon's |
|
| 143 | - * configuration settings section |
|
| 144 | - * (defaults to "addons") |
|
| 145 | - * @type string $config_class the class name for this addon's |
|
| 146 | - * configuration settings object |
|
| 147 | - * @type string $config_name the class name for this addon's |
|
| 148 | - * configuration settings object |
|
| 149 | - * @type string $autoloader_paths an array of class names and the full server |
|
| 150 | - * paths to those files. Required. |
|
| 151 | - * @type string $autoloader_folders an array of "full server paths" for any |
|
| 152 | - * folders containing classes that might be |
|
| 153 | - * invoked by the addon |
|
| 154 | - * @type string $dms_paths an array of full server paths to folders that |
|
| 155 | - * contain data migration scripts. Required. |
|
| 156 | - * @type string $module_paths an array of full server paths to any |
|
| 157 | - * EED_Modules used by the addon |
|
| 158 | - * @type string $shortcode_paths an array of full server paths to folders |
|
| 159 | - * that contain EES_Shortcodes |
|
| 160 | - * @type string $widget_paths an array of full server paths to folders |
|
| 161 | - * that contain WP_Widgets |
|
| 162 | - * @type string $pue_options |
|
| 163 | - * @type array $capabilities an array indexed by role name |
|
| 164 | - * (i.e administrator,author ) and the values |
|
| 165 | - * are an array of caps to add to the role. |
|
| 166 | - * 'administrator' => array( |
|
| 167 | - * 'read_addon', |
|
| 168 | - * 'edit_addon', |
|
| 169 | - * etc. |
|
| 170 | - * ). |
|
| 171 | - * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
| 172 | - * for any addons that need to register any |
|
| 173 | - * special meta mapped capabilities. Should |
|
| 174 | - * be indexed where the key is the |
|
| 175 | - * EE_Meta_Capability_Map class name and the |
|
| 176 | - * values are the arguments sent to the class. |
|
| 177 | - * @type array $model_paths array of folders containing DB models |
|
| 178 | - * @see EE_Register_Model |
|
| 179 | - * @type array $class_paths array of folders containing DB classes |
|
| 180 | - * @see EE_Register_Model |
|
| 181 | - * @type array $model_extension_paths array of folders containing DB model |
|
| 182 | - * extensions |
|
| 183 | - * @see EE_Register_Model_Extension |
|
| 184 | - * @type array $class_extension_paths array of folders containing DB class |
|
| 185 | - * extensions |
|
| 186 | - * @see EE_Register_Model_Extension |
|
| 187 | - * @type array message_types { |
|
| 188 | - * An array of message types with the key as |
|
| 189 | - * the message type name and the values as |
|
| 190 | - * below: |
|
| 191 | - * @type string $mtfilename The filename of the message type being |
|
| 192 | - * registered. This will be the main |
|
| 193 | - * EE_{Message Type Name}_message_type class. |
|
| 194 | - * (eg. EE_Declined_Registration_message_type.class.php) |
|
| 195 | - * Required. |
|
| 196 | - * @type array $autoloadpaths An array of paths to add to the messages |
|
| 197 | - * autoloader for the new message type. |
|
| 198 | - * Required. |
|
| 199 | - * @type array $messengers_to_activate_with An array of messengers that this message |
|
| 200 | - * type should activate with. Each value in |
|
| 201 | - * the |
|
| 202 | - * array |
|
| 203 | - * should match the name property of a |
|
| 204 | - * EE_messenger. Optional. |
|
| 205 | - * @type array $messengers_to_validate_with An array of messengers that this message |
|
| 206 | - * type should validate with. Each value in |
|
| 207 | - * the |
|
| 208 | - * array |
|
| 209 | - * should match the name property of an |
|
| 210 | - * EE_messenger. |
|
| 211 | - * Optional. |
|
| 212 | - * } |
|
| 213 | - * @type array $custom_post_types |
|
| 214 | - * @type array $custom_taxonomies |
|
| 215 | - * @type array $payment_method_paths each element is the folder containing the |
|
| 216 | - * EE_PMT_Base child class |
|
| 217 | - * (eg, |
|
| 218 | - * '/wp-content/plugins/my_plugin/Payomatic/' |
|
| 219 | - * which contains the files |
|
| 220 | - * EE_PMT_Payomatic.pm.php) |
|
| 221 | - * @type array $default_terms |
|
| 222 | - * @type array $namespace { |
|
| 223 | - * An array with two items for registering the |
|
| 224 | - * addon's namespace. (If, for some reason, you |
|
| 225 | - * require additional namespaces, |
|
| 226 | - * use EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 227 | - * directly) |
|
| 228 | - * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 229 | - * @type string $FQNS the namespace prefix |
|
| 230 | - * @type string $DIR a base directory for class files in the |
|
| 231 | - * namespace. |
|
| 232 | - * } |
|
| 233 | - * } |
|
| 234 | - * @return void |
|
| 235 | - * @throws DomainException |
|
| 236 | - * @throws EE_Error |
|
| 237 | - * @throws InvalidArgumentException |
|
| 238 | - * @throws ReflectionException |
|
| 239 | - * @throws InvalidDataTypeException |
|
| 240 | - * @throws InvalidInterfaceException |
|
| 241 | - */ |
|
| 242 | - public static function register($addon_name = '', $setup_args = array()) |
|
| 243 | - { |
|
| 244 | - // required fields MUST be present, so let's make sure they are. |
|
| 245 | - EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
| 246 | - // get class name for addon |
|
| 247 | - $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
| 248 | - //setup $_settings array from incoming values. |
|
| 249 | - $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
| 250 | - // setup PUE |
|
| 251 | - EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
| 252 | - // does this addon work with this version of core or WordPress ? |
|
| 253 | - if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 254 | - return; |
|
| 255 | - } |
|
| 256 | - // register namespaces |
|
| 257 | - EE_Register_Addon::_setup_namespaces($addon_settings); |
|
| 258 | - // check if this is an activation request |
|
| 259 | - if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
| 260 | - // dont bother setting up the rest of the addon atm |
|
| 261 | - return; |
|
| 262 | - } |
|
| 263 | - // we need cars |
|
| 264 | - EE_Register_Addon::_setup_autoloaders($addon_name); |
|
| 265 | - // register new models and extensions |
|
| 266 | - EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
| 267 | - // setup DMS |
|
| 268 | - EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
| 269 | - // if config_class is present let's register config. |
|
| 270 | - EE_Register_Addon::_register_config($addon_name); |
|
| 271 | - // register admin pages |
|
| 272 | - EE_Register_Addon::_register_admin_pages($addon_name); |
|
| 273 | - // add to list of modules to be registered |
|
| 274 | - EE_Register_Addon::_register_modules($addon_name); |
|
| 275 | - // add to list of shortcodes to be registered |
|
| 276 | - EE_Register_Addon::_register_shortcodes($addon_name); |
|
| 277 | - // add to list of widgets to be registered |
|
| 278 | - EE_Register_Addon::_register_widgets($addon_name); |
|
| 279 | - // register capability related stuff. |
|
| 280 | - EE_Register_Addon::_register_capabilities($addon_name); |
|
| 281 | - // any message type to register? |
|
| 282 | - EE_Register_Addon::_register_message_types($addon_name); |
|
| 283 | - // any custom post type/ custom capabilities or default terms to register |
|
| 284 | - EE_Register_Addon::_register_custom_post_types($addon_name); |
|
| 285 | - // and any payment methods |
|
| 286 | - EE_Register_Addon::_register_payment_methods($addon_name); |
|
| 287 | - // load and instantiate main addon class |
|
| 288 | - $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
| 289 | - //delay calling after_registration hook on each addon until after all add-ons have been registered. |
|
| 290 | - add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999); |
|
| 291 | - } |
|
| 108 | + /** |
|
| 109 | + * Method for registering new EE_Addons. |
|
| 110 | + * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE |
|
| 111 | + * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it |
|
| 112 | + * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon |
|
| 113 | + * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after |
|
| 114 | + * 'activate_plugin', it registers the addon still, but its components are not registered |
|
| 115 | + * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do |
|
| 116 | + * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns |
|
| 117 | + * (so that we can detect that the addon has activated on the subsequent request) |
|
| 118 | + * |
|
| 119 | + * @since 4.3.0 |
|
| 120 | + * @param string $addon_name the EE_Addon's name. Required. |
|
| 121 | + * @param array $setup_args { |
|
| 122 | + * An array of arguments provided for registering the |
|
| 123 | + * message type. |
|
| 124 | + * @type string $class_name the addon's main file name. |
|
| 125 | + * If left blank, generated from the addon name, |
|
| 126 | + * changes something like "calendar" to "EE_Calendar" |
|
| 127 | + * @type string $min_core_version the minimum version of EE Core that the |
|
| 128 | + * addon will work with. eg "4.8.1.rc.084" |
|
| 129 | + * @type string $version the "software" version for the addon. eg |
|
| 130 | + * "1.0.0.p" for a first stable release, or |
|
| 131 | + * "1.0.0.rc.043" for a version in progress |
|
| 132 | + * @type string $main_file_path the full server path to the main file |
|
| 133 | + * loaded directly by WP |
|
| 134 | + * @type string $domain_fqcn Fully Qualified Class Name |
|
| 135 | + * for the addon's Domain class |
|
| 136 | + * (see EventEspresso\core\domain\Domain) |
|
| 137 | + * @type string $admin_path full server path to the folder where the |
|
| 138 | + * addon\'s admin files reside |
|
| 139 | + * @type string $admin_callback a method to be called when the EE Admin is |
|
| 140 | + * first invoked, can be used for hooking into |
|
| 141 | + * any admin page |
|
| 142 | + * @type string $config_section the section name for this addon's |
|
| 143 | + * configuration settings section |
|
| 144 | + * (defaults to "addons") |
|
| 145 | + * @type string $config_class the class name for this addon's |
|
| 146 | + * configuration settings object |
|
| 147 | + * @type string $config_name the class name for this addon's |
|
| 148 | + * configuration settings object |
|
| 149 | + * @type string $autoloader_paths an array of class names and the full server |
|
| 150 | + * paths to those files. Required. |
|
| 151 | + * @type string $autoloader_folders an array of "full server paths" for any |
|
| 152 | + * folders containing classes that might be |
|
| 153 | + * invoked by the addon |
|
| 154 | + * @type string $dms_paths an array of full server paths to folders that |
|
| 155 | + * contain data migration scripts. Required. |
|
| 156 | + * @type string $module_paths an array of full server paths to any |
|
| 157 | + * EED_Modules used by the addon |
|
| 158 | + * @type string $shortcode_paths an array of full server paths to folders |
|
| 159 | + * that contain EES_Shortcodes |
|
| 160 | + * @type string $widget_paths an array of full server paths to folders |
|
| 161 | + * that contain WP_Widgets |
|
| 162 | + * @type string $pue_options |
|
| 163 | + * @type array $capabilities an array indexed by role name |
|
| 164 | + * (i.e administrator,author ) and the values |
|
| 165 | + * are an array of caps to add to the role. |
|
| 166 | + * 'administrator' => array( |
|
| 167 | + * 'read_addon', |
|
| 168 | + * 'edit_addon', |
|
| 169 | + * etc. |
|
| 170 | + * ). |
|
| 171 | + * @type EE_Meta_Capability_Map[] $capability_maps an array of EE_Meta_Capability_Map object |
|
| 172 | + * for any addons that need to register any |
|
| 173 | + * special meta mapped capabilities. Should |
|
| 174 | + * be indexed where the key is the |
|
| 175 | + * EE_Meta_Capability_Map class name and the |
|
| 176 | + * values are the arguments sent to the class. |
|
| 177 | + * @type array $model_paths array of folders containing DB models |
|
| 178 | + * @see EE_Register_Model |
|
| 179 | + * @type array $class_paths array of folders containing DB classes |
|
| 180 | + * @see EE_Register_Model |
|
| 181 | + * @type array $model_extension_paths array of folders containing DB model |
|
| 182 | + * extensions |
|
| 183 | + * @see EE_Register_Model_Extension |
|
| 184 | + * @type array $class_extension_paths array of folders containing DB class |
|
| 185 | + * extensions |
|
| 186 | + * @see EE_Register_Model_Extension |
|
| 187 | + * @type array message_types { |
|
| 188 | + * An array of message types with the key as |
|
| 189 | + * the message type name and the values as |
|
| 190 | + * below: |
|
| 191 | + * @type string $mtfilename The filename of the message type being |
|
| 192 | + * registered. This will be the main |
|
| 193 | + * EE_{Message Type Name}_message_type class. |
|
| 194 | + * (eg. EE_Declined_Registration_message_type.class.php) |
|
| 195 | + * Required. |
|
| 196 | + * @type array $autoloadpaths An array of paths to add to the messages |
|
| 197 | + * autoloader for the new message type. |
|
| 198 | + * Required. |
|
| 199 | + * @type array $messengers_to_activate_with An array of messengers that this message |
|
| 200 | + * type should activate with. Each value in |
|
| 201 | + * the |
|
| 202 | + * array |
|
| 203 | + * should match the name property of a |
|
| 204 | + * EE_messenger. Optional. |
|
| 205 | + * @type array $messengers_to_validate_with An array of messengers that this message |
|
| 206 | + * type should validate with. Each value in |
|
| 207 | + * the |
|
| 208 | + * array |
|
| 209 | + * should match the name property of an |
|
| 210 | + * EE_messenger. |
|
| 211 | + * Optional. |
|
| 212 | + * } |
|
| 213 | + * @type array $custom_post_types |
|
| 214 | + * @type array $custom_taxonomies |
|
| 215 | + * @type array $payment_method_paths each element is the folder containing the |
|
| 216 | + * EE_PMT_Base child class |
|
| 217 | + * (eg, |
|
| 218 | + * '/wp-content/plugins/my_plugin/Payomatic/' |
|
| 219 | + * which contains the files |
|
| 220 | + * EE_PMT_Payomatic.pm.php) |
|
| 221 | + * @type array $default_terms |
|
| 222 | + * @type array $namespace { |
|
| 223 | + * An array with two items for registering the |
|
| 224 | + * addon's namespace. (If, for some reason, you |
|
| 225 | + * require additional namespaces, |
|
| 226 | + * use EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 227 | + * directly) |
|
| 228 | + * @see EventEspresso\core\Psr4Autoloader::addNamespace() |
|
| 229 | + * @type string $FQNS the namespace prefix |
|
| 230 | + * @type string $DIR a base directory for class files in the |
|
| 231 | + * namespace. |
|
| 232 | + * } |
|
| 233 | + * } |
|
| 234 | + * @return void |
|
| 235 | + * @throws DomainException |
|
| 236 | + * @throws EE_Error |
|
| 237 | + * @throws InvalidArgumentException |
|
| 238 | + * @throws ReflectionException |
|
| 239 | + * @throws InvalidDataTypeException |
|
| 240 | + * @throws InvalidInterfaceException |
|
| 241 | + */ |
|
| 242 | + public static function register($addon_name = '', $setup_args = array()) |
|
| 243 | + { |
|
| 244 | + // required fields MUST be present, so let's make sure they are. |
|
| 245 | + EE_Register_Addon::_verify_parameters($addon_name, $setup_args); |
|
| 246 | + // get class name for addon |
|
| 247 | + $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args); |
|
| 248 | + //setup $_settings array from incoming values. |
|
| 249 | + $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args); |
|
| 250 | + // setup PUE |
|
| 251 | + EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
|
| 252 | + // does this addon work with this version of core or WordPress ? |
|
| 253 | + if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 254 | + return; |
|
| 255 | + } |
|
| 256 | + // register namespaces |
|
| 257 | + EE_Register_Addon::_setup_namespaces($addon_settings); |
|
| 258 | + // check if this is an activation request |
|
| 259 | + if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) { |
|
| 260 | + // dont bother setting up the rest of the addon atm |
|
| 261 | + return; |
|
| 262 | + } |
|
| 263 | + // we need cars |
|
| 264 | + EE_Register_Addon::_setup_autoloaders($addon_name); |
|
| 265 | + // register new models and extensions |
|
| 266 | + EE_Register_Addon::_register_models_and_extensions($addon_name); |
|
| 267 | + // setup DMS |
|
| 268 | + EE_Register_Addon::_register_data_migration_scripts($addon_name); |
|
| 269 | + // if config_class is present let's register config. |
|
| 270 | + EE_Register_Addon::_register_config($addon_name); |
|
| 271 | + // register admin pages |
|
| 272 | + EE_Register_Addon::_register_admin_pages($addon_name); |
|
| 273 | + // add to list of modules to be registered |
|
| 274 | + EE_Register_Addon::_register_modules($addon_name); |
|
| 275 | + // add to list of shortcodes to be registered |
|
| 276 | + EE_Register_Addon::_register_shortcodes($addon_name); |
|
| 277 | + // add to list of widgets to be registered |
|
| 278 | + EE_Register_Addon::_register_widgets($addon_name); |
|
| 279 | + // register capability related stuff. |
|
| 280 | + EE_Register_Addon::_register_capabilities($addon_name); |
|
| 281 | + // any message type to register? |
|
| 282 | + EE_Register_Addon::_register_message_types($addon_name); |
|
| 283 | + // any custom post type/ custom capabilities or default terms to register |
|
| 284 | + EE_Register_Addon::_register_custom_post_types($addon_name); |
|
| 285 | + // and any payment methods |
|
| 286 | + EE_Register_Addon::_register_payment_methods($addon_name); |
|
| 287 | + // load and instantiate main addon class |
|
| 288 | + $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name); |
|
| 289 | + //delay calling after_registration hook on each addon until after all add-ons have been registered. |
|
| 290 | + add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999); |
|
| 291 | + } |
|
| 292 | 292 | |
| 293 | 293 | |
| 294 | - /** |
|
| 295 | - * @param string $addon_name |
|
| 296 | - * @param array $setup_args |
|
| 297 | - * @return void |
|
| 298 | - * @throws EE_Error |
|
| 299 | - */ |
|
| 300 | - private static function _verify_parameters($addon_name, array $setup_args) |
|
| 301 | - { |
|
| 302 | - // required fields MUST be present, so let's make sure they are. |
|
| 303 | - if (empty($addon_name) || ! is_array($setup_args)) { |
|
| 304 | - throw new EE_Error( |
|
| 305 | - __( |
|
| 306 | - 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
| 307 | - 'event_espresso' |
|
| 308 | - ) |
|
| 309 | - ); |
|
| 310 | - } |
|
| 311 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 312 | - throw new EE_Error( |
|
| 313 | - sprintf( |
|
| 314 | - __( |
|
| 315 | - 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
| 316 | - 'event_espresso' |
|
| 317 | - ), |
|
| 318 | - implode(',', array_keys($setup_args)) |
|
| 319 | - ) |
|
| 320 | - ); |
|
| 321 | - } |
|
| 322 | - // check that addon has not already been registered with that name |
|
| 323 | - if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
| 324 | - throw new EE_Error( |
|
| 325 | - sprintf( |
|
| 326 | - __( |
|
| 327 | - 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
| 328 | - 'event_espresso' |
|
| 329 | - ), |
|
| 330 | - $addon_name |
|
| 331 | - ) |
|
| 332 | - ); |
|
| 333 | - } |
|
| 334 | - } |
|
| 294 | + /** |
|
| 295 | + * @param string $addon_name |
|
| 296 | + * @param array $setup_args |
|
| 297 | + * @return void |
|
| 298 | + * @throws EE_Error |
|
| 299 | + */ |
|
| 300 | + private static function _verify_parameters($addon_name, array $setup_args) |
|
| 301 | + { |
|
| 302 | + // required fields MUST be present, so let's make sure they are. |
|
| 303 | + if (empty($addon_name) || ! is_array($setup_args)) { |
|
| 304 | + throw new EE_Error( |
|
| 305 | + __( |
|
| 306 | + 'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.', |
|
| 307 | + 'event_espresso' |
|
| 308 | + ) |
|
| 309 | + ); |
|
| 310 | + } |
|
| 311 | + if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 312 | + throw new EE_Error( |
|
| 313 | + sprintf( |
|
| 314 | + __( |
|
| 315 | + 'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s', |
|
| 316 | + 'event_espresso' |
|
| 317 | + ), |
|
| 318 | + implode(',', array_keys($setup_args)) |
|
| 319 | + ) |
|
| 320 | + ); |
|
| 321 | + } |
|
| 322 | + // check that addon has not already been registered with that name |
|
| 323 | + if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
| 324 | + throw new EE_Error( |
|
| 325 | + sprintf( |
|
| 326 | + __( |
|
| 327 | + 'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.', |
|
| 328 | + 'event_espresso' |
|
| 329 | + ), |
|
| 330 | + $addon_name |
|
| 331 | + ) |
|
| 332 | + ); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | 335 | |
| 336 | 336 | |
| 337 | - /** |
|
| 338 | - * @param string $addon_name |
|
| 339 | - * @param array $setup_args |
|
| 340 | - * @return string |
|
| 341 | - */ |
|
| 342 | - private static function _parse_class_name($addon_name, array $setup_args) |
|
| 343 | - { |
|
| 344 | - if (empty($setup_args['class_name'])) { |
|
| 345 | - // generate one by first separating name with spaces |
|
| 346 | - $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
| 347 | - //capitalize, then replace spaces with underscores |
|
| 348 | - $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
| 349 | - } else { |
|
| 350 | - $class_name = $setup_args['class_name']; |
|
| 351 | - } |
|
| 352 | - // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
|
| 353 | - return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
|
| 354 | - ? $class_name |
|
| 355 | - : 'EE_' . $class_name; |
|
| 356 | - } |
|
| 337 | + /** |
|
| 338 | + * @param string $addon_name |
|
| 339 | + * @param array $setup_args |
|
| 340 | + * @return string |
|
| 341 | + */ |
|
| 342 | + private static function _parse_class_name($addon_name, array $setup_args) |
|
| 343 | + { |
|
| 344 | + if (empty($setup_args['class_name'])) { |
|
| 345 | + // generate one by first separating name with spaces |
|
| 346 | + $class_name = str_replace(array('-', '_'), ' ', trim($addon_name)); |
|
| 347 | + //capitalize, then replace spaces with underscores |
|
| 348 | + $class_name = str_replace(' ', '_', ucwords($class_name)); |
|
| 349 | + } else { |
|
| 350 | + $class_name = $setup_args['class_name']; |
|
| 351 | + } |
|
| 352 | + // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
|
| 353 | + return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
|
| 354 | + ? $class_name |
|
| 355 | + : 'EE_' . $class_name; |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | |
| 359 | - /** |
|
| 360 | - * @param string $class_name |
|
| 361 | - * @param array $setup_args |
|
| 362 | - * @return array |
|
| 363 | - */ |
|
| 364 | - private static function _get_addon_settings($class_name, array $setup_args) |
|
| 365 | - { |
|
| 366 | - //setup $_settings array from incoming values. |
|
| 367 | - $addon_settings = array( |
|
| 368 | - // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
| 369 | - 'class_name' => $class_name, |
|
| 370 | - // the addon slug for use in URLs, etc |
|
| 371 | - 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
| 372 | - ? (string) $setup_args['plugin_slug'] |
|
| 373 | - : '', |
|
| 374 | - // page slug to be used when generating the "Settings" link on the WP plugin page |
|
| 375 | - 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
| 376 | - ? (string) $setup_args['plugin_action_slug'] |
|
| 377 | - : '', |
|
| 378 | - // the "software" version for the addon |
|
| 379 | - 'version' => isset($setup_args['version']) |
|
| 380 | - ? (string) $setup_args['version'] |
|
| 381 | - : '', |
|
| 382 | - // the minimum version of EE Core that the addon will work with |
|
| 383 | - 'min_core_version' => isset($setup_args['min_core_version']) |
|
| 384 | - ? (string) $setup_args['min_core_version'] |
|
| 385 | - : '', |
|
| 386 | - // the minimum version of WordPress that the addon will work with |
|
| 387 | - 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
| 388 | - ? (string) $setup_args['min_wp_version'] |
|
| 389 | - : EE_MIN_WP_VER_REQUIRED, |
|
| 390 | - // full server path to main file (file loaded directly by WP) |
|
| 391 | - 'main_file_path' => isset($setup_args['main_file_path']) |
|
| 392 | - ? (string) $setup_args['main_file_path'] |
|
| 393 | - : '', |
|
| 394 | - // Fully Qualified Class Name for the addon's Domain class |
|
| 395 | - 'domain_fqcn' => isset($setup_args['domain_fqcn']) |
|
| 396 | - ? (string) $setup_args['domain_fqcn'] |
|
| 397 | - : '', |
|
| 398 | - // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
| 399 | - 'admin_path' => isset($setup_args['admin_path']) |
|
| 400 | - ? (string) $setup_args['admin_path'] : '', |
|
| 401 | - // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
| 402 | - 'admin_callback' => isset($setup_args['admin_callback']) |
|
| 403 | - ? (string) $setup_args['admin_callback'] |
|
| 404 | - : '', |
|
| 405 | - // the section name for this addon's configuration settings section (defaults to "addons") |
|
| 406 | - 'config_section' => isset($setup_args['config_section']) |
|
| 407 | - ? (string) $setup_args['config_section'] |
|
| 408 | - : 'addons', |
|
| 409 | - // the class name for this addon's configuration settings object |
|
| 410 | - 'config_class' => isset($setup_args['config_class']) |
|
| 411 | - ? (string) $setup_args['config_class'] : '', |
|
| 412 | - //the name given to the config for this addons' configuration settings object (optional) |
|
| 413 | - 'config_name' => isset($setup_args['config_name']) |
|
| 414 | - ? (string) $setup_args['config_name'] : '', |
|
| 415 | - // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
| 416 | - 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
| 417 | - ? (array) $setup_args['autoloader_paths'] |
|
| 418 | - : array(), |
|
| 419 | - // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
| 420 | - 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
| 421 | - ? (array) $setup_args['autoloader_folders'] |
|
| 422 | - : array(), |
|
| 423 | - // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
| 424 | - 'dms_paths' => isset($setup_args['dms_paths']) |
|
| 425 | - ? (array) $setup_args['dms_paths'] |
|
| 426 | - : array(), |
|
| 427 | - // array of full server paths to any EED_Modules used by the addon |
|
| 428 | - 'module_paths' => isset($setup_args['module_paths']) |
|
| 429 | - ? (array) $setup_args['module_paths'] |
|
| 430 | - : array(), |
|
| 431 | - // array of full server paths to any EES_Shortcodes used by the addon |
|
| 432 | - 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
| 433 | - ? (array) $setup_args['shortcode_paths'] |
|
| 434 | - : array(), |
|
| 435 | - 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
| 436 | - ? (array) $setup_args['shortcode_fqcns'] |
|
| 437 | - : array(), |
|
| 438 | - // array of full server paths to any WP_Widgets used by the addon |
|
| 439 | - 'widget_paths' => isset($setup_args['widget_paths']) |
|
| 440 | - ? (array) $setup_args['widget_paths'] |
|
| 441 | - : array(), |
|
| 442 | - // array of PUE options used by the addon |
|
| 443 | - 'pue_options' => isset($setup_args['pue_options']) |
|
| 444 | - ? (array) $setup_args['pue_options'] |
|
| 445 | - : array(), |
|
| 446 | - 'message_types' => isset($setup_args['message_types']) |
|
| 447 | - ? (array) $setup_args['message_types'] |
|
| 448 | - : array(), |
|
| 449 | - 'capabilities' => isset($setup_args['capabilities']) |
|
| 450 | - ? (array) $setup_args['capabilities'] |
|
| 451 | - : array(), |
|
| 452 | - 'capability_maps' => isset($setup_args['capability_maps']) |
|
| 453 | - ? (array) $setup_args['capability_maps'] |
|
| 454 | - : array(), |
|
| 455 | - 'model_paths' => isset($setup_args['model_paths']) |
|
| 456 | - ? (array) $setup_args['model_paths'] |
|
| 457 | - : array(), |
|
| 458 | - 'class_paths' => isset($setup_args['class_paths']) |
|
| 459 | - ? (array) $setup_args['class_paths'] |
|
| 460 | - : array(), |
|
| 461 | - 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
| 462 | - ? (array) $setup_args['model_extension_paths'] |
|
| 463 | - : array(), |
|
| 464 | - 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
| 465 | - ? (array) $setup_args['class_extension_paths'] |
|
| 466 | - : array(), |
|
| 467 | - 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
| 468 | - ? (array) $setup_args['custom_post_types'] |
|
| 469 | - : array(), |
|
| 470 | - 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
| 471 | - ? (array) $setup_args['custom_taxonomies'] |
|
| 472 | - : array(), |
|
| 473 | - 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
| 474 | - ? (array) $setup_args['payment_method_paths'] |
|
| 475 | - : array(), |
|
| 476 | - 'default_terms' => isset($setup_args['default_terms']) |
|
| 477 | - ? (array) $setup_args['default_terms'] |
|
| 478 | - : array(), |
|
| 479 | - // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
| 480 | - // that can be used for adding upgrading/marketing info |
|
| 481 | - 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
| 482 | - ? $setup_args['plugins_page_row'] |
|
| 483 | - : '', |
|
| 484 | - 'namespace' => isset( |
|
| 485 | - $setup_args['namespace']['FQNS'], |
|
| 486 | - $setup_args['namespace']['DIR'] |
|
| 487 | - ) |
|
| 488 | - ? (array) $setup_args['namespace'] |
|
| 489 | - : array(), |
|
| 490 | - ); |
|
| 491 | - // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
| 492 | - // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
| 493 | - $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
| 494 | - && ! empty($addon_settings['admin_path']) |
|
| 495 | - ? $addon_settings['plugin_slug'] |
|
| 496 | - : $addon_settings['plugin_action_slug']; |
|
| 497 | - // full server path to main file (file loaded directly by WP) |
|
| 498 | - $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
| 499 | - return $addon_settings; |
|
| 500 | - } |
|
| 359 | + /** |
|
| 360 | + * @param string $class_name |
|
| 361 | + * @param array $setup_args |
|
| 362 | + * @return array |
|
| 363 | + */ |
|
| 364 | + private static function _get_addon_settings($class_name, array $setup_args) |
|
| 365 | + { |
|
| 366 | + //setup $_settings array from incoming values. |
|
| 367 | + $addon_settings = array( |
|
| 368 | + // generated from the addon name, changes something like "calendar" to "EE_Calendar" |
|
| 369 | + 'class_name' => $class_name, |
|
| 370 | + // the addon slug for use in URLs, etc |
|
| 371 | + 'plugin_slug' => isset($setup_args['plugin_slug']) |
|
| 372 | + ? (string) $setup_args['plugin_slug'] |
|
| 373 | + : '', |
|
| 374 | + // page slug to be used when generating the "Settings" link on the WP plugin page |
|
| 375 | + 'plugin_action_slug' => isset($setup_args['plugin_action_slug']) |
|
| 376 | + ? (string) $setup_args['plugin_action_slug'] |
|
| 377 | + : '', |
|
| 378 | + // the "software" version for the addon |
|
| 379 | + 'version' => isset($setup_args['version']) |
|
| 380 | + ? (string) $setup_args['version'] |
|
| 381 | + : '', |
|
| 382 | + // the minimum version of EE Core that the addon will work with |
|
| 383 | + 'min_core_version' => isset($setup_args['min_core_version']) |
|
| 384 | + ? (string) $setup_args['min_core_version'] |
|
| 385 | + : '', |
|
| 386 | + // the minimum version of WordPress that the addon will work with |
|
| 387 | + 'min_wp_version' => isset($setup_args['min_wp_version']) |
|
| 388 | + ? (string) $setup_args['min_wp_version'] |
|
| 389 | + : EE_MIN_WP_VER_REQUIRED, |
|
| 390 | + // full server path to main file (file loaded directly by WP) |
|
| 391 | + 'main_file_path' => isset($setup_args['main_file_path']) |
|
| 392 | + ? (string) $setup_args['main_file_path'] |
|
| 393 | + : '', |
|
| 394 | + // Fully Qualified Class Name for the addon's Domain class |
|
| 395 | + 'domain_fqcn' => isset($setup_args['domain_fqcn']) |
|
| 396 | + ? (string) $setup_args['domain_fqcn'] |
|
| 397 | + : '', |
|
| 398 | + // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages |
|
| 399 | + 'admin_path' => isset($setup_args['admin_path']) |
|
| 400 | + ? (string) $setup_args['admin_path'] : '', |
|
| 401 | + // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page |
|
| 402 | + 'admin_callback' => isset($setup_args['admin_callback']) |
|
| 403 | + ? (string) $setup_args['admin_callback'] |
|
| 404 | + : '', |
|
| 405 | + // the section name for this addon's configuration settings section (defaults to "addons") |
|
| 406 | + 'config_section' => isset($setup_args['config_section']) |
|
| 407 | + ? (string) $setup_args['config_section'] |
|
| 408 | + : 'addons', |
|
| 409 | + // the class name for this addon's configuration settings object |
|
| 410 | + 'config_class' => isset($setup_args['config_class']) |
|
| 411 | + ? (string) $setup_args['config_class'] : '', |
|
| 412 | + //the name given to the config for this addons' configuration settings object (optional) |
|
| 413 | + 'config_name' => isset($setup_args['config_name']) |
|
| 414 | + ? (string) $setup_args['config_name'] : '', |
|
| 415 | + // an array of "class names" => "full server paths" for any classes that might be invoked by the addon |
|
| 416 | + 'autoloader_paths' => isset($setup_args['autoloader_paths']) |
|
| 417 | + ? (array) $setup_args['autoloader_paths'] |
|
| 418 | + : array(), |
|
| 419 | + // an array of "full server paths" for any folders containing classes that might be invoked by the addon |
|
| 420 | + 'autoloader_folders' => isset($setup_args['autoloader_folders']) |
|
| 421 | + ? (array) $setup_args['autoloader_folders'] |
|
| 422 | + : array(), |
|
| 423 | + // array of full server paths to any EE_DMS data migration scripts used by the addon |
|
| 424 | + 'dms_paths' => isset($setup_args['dms_paths']) |
|
| 425 | + ? (array) $setup_args['dms_paths'] |
|
| 426 | + : array(), |
|
| 427 | + // array of full server paths to any EED_Modules used by the addon |
|
| 428 | + 'module_paths' => isset($setup_args['module_paths']) |
|
| 429 | + ? (array) $setup_args['module_paths'] |
|
| 430 | + : array(), |
|
| 431 | + // array of full server paths to any EES_Shortcodes used by the addon |
|
| 432 | + 'shortcode_paths' => isset($setup_args['shortcode_paths']) |
|
| 433 | + ? (array) $setup_args['shortcode_paths'] |
|
| 434 | + : array(), |
|
| 435 | + 'shortcode_fqcns' => isset($setup_args['shortcode_fqcns']) |
|
| 436 | + ? (array) $setup_args['shortcode_fqcns'] |
|
| 437 | + : array(), |
|
| 438 | + // array of full server paths to any WP_Widgets used by the addon |
|
| 439 | + 'widget_paths' => isset($setup_args['widget_paths']) |
|
| 440 | + ? (array) $setup_args['widget_paths'] |
|
| 441 | + : array(), |
|
| 442 | + // array of PUE options used by the addon |
|
| 443 | + 'pue_options' => isset($setup_args['pue_options']) |
|
| 444 | + ? (array) $setup_args['pue_options'] |
|
| 445 | + : array(), |
|
| 446 | + 'message_types' => isset($setup_args['message_types']) |
|
| 447 | + ? (array) $setup_args['message_types'] |
|
| 448 | + : array(), |
|
| 449 | + 'capabilities' => isset($setup_args['capabilities']) |
|
| 450 | + ? (array) $setup_args['capabilities'] |
|
| 451 | + : array(), |
|
| 452 | + 'capability_maps' => isset($setup_args['capability_maps']) |
|
| 453 | + ? (array) $setup_args['capability_maps'] |
|
| 454 | + : array(), |
|
| 455 | + 'model_paths' => isset($setup_args['model_paths']) |
|
| 456 | + ? (array) $setup_args['model_paths'] |
|
| 457 | + : array(), |
|
| 458 | + 'class_paths' => isset($setup_args['class_paths']) |
|
| 459 | + ? (array) $setup_args['class_paths'] |
|
| 460 | + : array(), |
|
| 461 | + 'model_extension_paths' => isset($setup_args['model_extension_paths']) |
|
| 462 | + ? (array) $setup_args['model_extension_paths'] |
|
| 463 | + : array(), |
|
| 464 | + 'class_extension_paths' => isset($setup_args['class_extension_paths']) |
|
| 465 | + ? (array) $setup_args['class_extension_paths'] |
|
| 466 | + : array(), |
|
| 467 | + 'custom_post_types' => isset($setup_args['custom_post_types']) |
|
| 468 | + ? (array) $setup_args['custom_post_types'] |
|
| 469 | + : array(), |
|
| 470 | + 'custom_taxonomies' => isset($setup_args['custom_taxonomies']) |
|
| 471 | + ? (array) $setup_args['custom_taxonomies'] |
|
| 472 | + : array(), |
|
| 473 | + 'payment_method_paths' => isset($setup_args['payment_method_paths']) |
|
| 474 | + ? (array) $setup_args['payment_method_paths'] |
|
| 475 | + : array(), |
|
| 476 | + 'default_terms' => isset($setup_args['default_terms']) |
|
| 477 | + ? (array) $setup_args['default_terms'] |
|
| 478 | + : array(), |
|
| 479 | + // if not empty, inserts a new table row after this plugin's row on the WP Plugins page |
|
| 480 | + // that can be used for adding upgrading/marketing info |
|
| 481 | + 'plugins_page_row' => isset($setup_args['plugins_page_row']) |
|
| 482 | + ? $setup_args['plugins_page_row'] |
|
| 483 | + : '', |
|
| 484 | + 'namespace' => isset( |
|
| 485 | + $setup_args['namespace']['FQNS'], |
|
| 486 | + $setup_args['namespace']['DIR'] |
|
| 487 | + ) |
|
| 488 | + ? (array) $setup_args['namespace'] |
|
| 489 | + : array(), |
|
| 490 | + ); |
|
| 491 | + // if plugin_action_slug is NOT set, but an admin page path IS set, |
|
| 492 | + // then let's just use the plugin_slug since that will be used for linking to the admin page |
|
| 493 | + $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug']) |
|
| 494 | + && ! empty($addon_settings['admin_path']) |
|
| 495 | + ? $addon_settings['plugin_slug'] |
|
| 496 | + : $addon_settings['plugin_action_slug']; |
|
| 497 | + // full server path to main file (file loaded directly by WP) |
|
| 498 | + $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']); |
|
| 499 | + return $addon_settings; |
|
| 500 | + } |
|
| 501 | 501 | |
| 502 | 502 | |
| 503 | - /** |
|
| 504 | - * @param string $addon_name |
|
| 505 | - * @param array $addon_settings |
|
| 506 | - * @return boolean |
|
| 507 | - */ |
|
| 508 | - private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
| 509 | - { |
|
| 510 | - global $wp_version; |
|
| 511 | - $incompatibility_message = ''; |
|
| 512 | - //check whether this addon version is compatible with EE core |
|
| 513 | - if ( |
|
| 514 | - isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
| 515 | - && ! self::_meets_min_core_version_requirement( |
|
| 516 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
| 517 | - $addon_settings['version'] |
|
| 518 | - ) |
|
| 519 | - ) { |
|
| 520 | - $incompatibility_message = sprintf( |
|
| 521 | - __( |
|
| 522 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
| 523 | - ), |
|
| 524 | - $addon_name, |
|
| 525 | - '<br />', |
|
| 526 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
| 527 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
| 528 | - '</span><br />' |
|
| 529 | - ); |
|
| 530 | - } elseif ( |
|
| 531 | - ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
| 532 | - ) { |
|
| 533 | - $incompatibility_message = sprintf( |
|
| 534 | - __( |
|
| 535 | - '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
| 536 | - 'event_espresso' |
|
| 537 | - ), |
|
| 538 | - $addon_name, |
|
| 539 | - self::_effective_version($addon_settings['min_core_version']), |
|
| 540 | - self::_effective_version(espresso_version()), |
|
| 541 | - '<br />', |
|
| 542 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
| 543 | - '</span><br />' |
|
| 544 | - ); |
|
| 545 | - } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
| 546 | - $incompatibility_message = sprintf( |
|
| 547 | - __( |
|
| 548 | - '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
| 549 | - 'event_espresso' |
|
| 550 | - ), |
|
| 551 | - $addon_name, |
|
| 552 | - $addon_settings['min_wp_version'], |
|
| 553 | - '<br />', |
|
| 554 | - '<span style="font-weight: bold; color: #D54E21;">', |
|
| 555 | - '</span><br />' |
|
| 556 | - ); |
|
| 557 | - } |
|
| 558 | - if (! empty($incompatibility_message)) { |
|
| 559 | - // remove 'activate' from the REQUEST |
|
| 560 | - // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
| 561 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 562 | - if (current_user_can('activate_plugins')) { |
|
| 563 | - // show an error message indicating the plugin didn't activate properly |
|
| 564 | - EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
| 565 | - } |
|
| 566 | - // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
| 567 | - return false; |
|
| 568 | - } |
|
| 569 | - // addon IS compatible |
|
| 570 | - return true; |
|
| 571 | - } |
|
| 503 | + /** |
|
| 504 | + * @param string $addon_name |
|
| 505 | + * @param array $addon_settings |
|
| 506 | + * @return boolean |
|
| 507 | + */ |
|
| 508 | + private static function _addon_is_compatible($addon_name, array $addon_settings) |
|
| 509 | + { |
|
| 510 | + global $wp_version; |
|
| 511 | + $incompatibility_message = ''; |
|
| 512 | + //check whether this addon version is compatible with EE core |
|
| 513 | + if ( |
|
| 514 | + isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
| 515 | + && ! self::_meets_min_core_version_requirement( |
|
| 516 | + EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
| 517 | + $addon_settings['version'] |
|
| 518 | + ) |
|
| 519 | + ) { |
|
| 520 | + $incompatibility_message = sprintf( |
|
| 521 | + __( |
|
| 522 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.' |
|
| 523 | + ), |
|
| 524 | + $addon_name, |
|
| 525 | + '<br />', |
|
| 526 | + EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
| 527 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
| 528 | + '</span><br />' |
|
| 529 | + ); |
|
| 530 | + } elseif ( |
|
| 531 | + ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version()) |
|
| 532 | + ) { |
|
| 533 | + $incompatibility_message = sprintf( |
|
| 534 | + __( |
|
| 535 | + '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".', |
|
| 536 | + 'event_espresso' |
|
| 537 | + ), |
|
| 538 | + $addon_name, |
|
| 539 | + self::_effective_version($addon_settings['min_core_version']), |
|
| 540 | + self::_effective_version(espresso_version()), |
|
| 541 | + '<br />', |
|
| 542 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
| 543 | + '</span><br />' |
|
| 544 | + ); |
|
| 545 | + } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) { |
|
| 546 | + $incompatibility_message = sprintf( |
|
| 547 | + __( |
|
| 548 | + '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.', |
|
| 549 | + 'event_espresso' |
|
| 550 | + ), |
|
| 551 | + $addon_name, |
|
| 552 | + $addon_settings['min_wp_version'], |
|
| 553 | + '<br />', |
|
| 554 | + '<span style="font-weight: bold; color: #D54E21;">', |
|
| 555 | + '</span><br />' |
|
| 556 | + ); |
|
| 557 | + } |
|
| 558 | + if (! empty($incompatibility_message)) { |
|
| 559 | + // remove 'activate' from the REQUEST |
|
| 560 | + // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
|
| 561 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 562 | + if (current_user_can('activate_plugins')) { |
|
| 563 | + // show an error message indicating the plugin didn't activate properly |
|
| 564 | + EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__); |
|
| 565 | + } |
|
| 566 | + // BAIL FROM THE ADDON REGISTRATION PROCESS |
|
| 567 | + return false; |
|
| 568 | + } |
|
| 569 | + // addon IS compatible |
|
| 570 | + return true; |
|
| 571 | + } |
|
| 572 | 572 | |
| 573 | 573 | |
| 574 | - /** |
|
| 575 | - * if plugin update engine is being used for auto-updates, |
|
| 576 | - * then let's set that up now before going any further so that ALL addons can be updated |
|
| 577 | - * (not needed if PUE is not being used) |
|
| 578 | - * |
|
| 579 | - * @param string $addon_name |
|
| 580 | - * @param string $class_name |
|
| 581 | - * @param array $setup_args |
|
| 582 | - * @return void |
|
| 583 | - */ |
|
| 584 | - private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
| 585 | - { |
|
| 586 | - if (! empty($setup_args['pue_options'])) { |
|
| 587 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
| 588 | - 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
| 589 | - ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
| 590 | - : 'espresso_' . strtolower($class_name), |
|
| 591 | - 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
| 592 | - ? (string) $setup_args['pue_options']['plugin_basename'] |
|
| 593 | - : plugin_basename($setup_args['main_file_path']), |
|
| 594 | - 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
| 595 | - ? (string) $setup_args['pue_options']['checkPeriod'] |
|
| 596 | - : '24', |
|
| 597 | - 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
| 598 | - ? (string) $setup_args['pue_options']['use_wp_update'] |
|
| 599 | - : false, |
|
| 600 | - ); |
|
| 601 | - add_action( |
|
| 602 | - 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
| 603 | - array('EE_Register_Addon', 'load_pue_update') |
|
| 604 | - ); |
|
| 605 | - } |
|
| 606 | - } |
|
| 574 | + /** |
|
| 575 | + * if plugin update engine is being used for auto-updates, |
|
| 576 | + * then let's set that up now before going any further so that ALL addons can be updated |
|
| 577 | + * (not needed if PUE is not being used) |
|
| 578 | + * |
|
| 579 | + * @param string $addon_name |
|
| 580 | + * @param string $class_name |
|
| 581 | + * @param array $setup_args |
|
| 582 | + * @return void |
|
| 583 | + */ |
|
| 584 | + private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
|
| 585 | + { |
|
| 586 | + if (! empty($setup_args['pue_options'])) { |
|
| 587 | + self::$_settings[ $addon_name ]['pue_options'] = array( |
|
| 588 | + 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
|
| 589 | + ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
|
| 590 | + : 'espresso_' . strtolower($class_name), |
|
| 591 | + 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
|
| 592 | + ? (string) $setup_args['pue_options']['plugin_basename'] |
|
| 593 | + : plugin_basename($setup_args['main_file_path']), |
|
| 594 | + 'checkPeriod' => isset($setup_args['pue_options']['checkPeriod']) |
|
| 595 | + ? (string) $setup_args['pue_options']['checkPeriod'] |
|
| 596 | + : '24', |
|
| 597 | + 'use_wp_update' => isset($setup_args['pue_options']['use_wp_update']) |
|
| 598 | + ? (string) $setup_args['pue_options']['use_wp_update'] |
|
| 599 | + : false, |
|
| 600 | + ); |
|
| 601 | + add_action( |
|
| 602 | + 'AHEE__EE_System__brew_espresso__after_pue_init', |
|
| 603 | + array('EE_Register_Addon', 'load_pue_update') |
|
| 604 | + ); |
|
| 605 | + } |
|
| 606 | + } |
|
| 607 | 607 | |
| 608 | 608 | |
| 609 | - /** |
|
| 610 | - * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
| 611 | - * |
|
| 612 | - * @param array $addon_settings |
|
| 613 | - * @return void |
|
| 614 | - */ |
|
| 615 | - private static function _setup_namespaces(array $addon_settings) |
|
| 616 | - { |
|
| 617 | - // |
|
| 618 | - if ( |
|
| 619 | - isset( |
|
| 620 | - $addon_settings['namespace']['FQNS'], |
|
| 621 | - $addon_settings['namespace']['DIR'] |
|
| 622 | - ) |
|
| 623 | - ) { |
|
| 624 | - EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
| 625 | - $addon_settings['namespace']['FQNS'], |
|
| 626 | - $addon_settings['namespace']['DIR'] |
|
| 627 | - ); |
|
| 628 | - } |
|
| 629 | - } |
|
| 609 | + /** |
|
| 610 | + * register namespaces right away before any other files or classes get loaded, but AFTER the version checks |
|
| 611 | + * |
|
| 612 | + * @param array $addon_settings |
|
| 613 | + * @return void |
|
| 614 | + */ |
|
| 615 | + private static function _setup_namespaces(array $addon_settings) |
|
| 616 | + { |
|
| 617 | + // |
|
| 618 | + if ( |
|
| 619 | + isset( |
|
| 620 | + $addon_settings['namespace']['FQNS'], |
|
| 621 | + $addon_settings['namespace']['DIR'] |
|
| 622 | + ) |
|
| 623 | + ) { |
|
| 624 | + EE_Psr4AutoloaderInit::psr4_loader()->addNamespace( |
|
| 625 | + $addon_settings['namespace']['FQNS'], |
|
| 626 | + $addon_settings['namespace']['DIR'] |
|
| 627 | + ); |
|
| 628 | + } |
|
| 629 | + } |
|
| 630 | 630 | |
| 631 | 631 | |
| 632 | - /** |
|
| 633 | - * @param string $addon_name |
|
| 634 | - * @param array $addon_settings |
|
| 635 | - * @return bool |
|
| 636 | - * @throws EE_Error |
|
| 637 | - * @throws InvalidArgumentException |
|
| 638 | - * @throws ReflectionException |
|
| 639 | - * @throws InvalidDataTypeException |
|
| 640 | - * @throws InvalidInterfaceException |
|
| 641 | - */ |
|
| 642 | - private static function _addon_activation($addon_name, array $addon_settings) |
|
| 643 | - { |
|
| 644 | - // this is an activation request |
|
| 645 | - if (did_action('activate_plugin')) { |
|
| 646 | - //to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
| 647 | - //(as the newly-activated addon wasn't around the first time addons were registered). |
|
| 648 | - //Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
| 649 | - //property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
| 650 | - if (! isset(self::$_settings[ $addon_name ]) |
|
| 651 | - || (isset(self::$_settings[ $addon_name ]) |
|
| 652 | - && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
| 653 | - ) |
|
| 654 | - ) { |
|
| 655 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
| 656 | - $addon = self::_load_and_init_addon_class($addon_name); |
|
| 657 | - $addon->set_activation_indicator_option(); |
|
| 658 | - // dont bother setting up the rest of the addon. |
|
| 659 | - // we know it was just activated and the request will end soon |
|
| 660 | - } |
|
| 661 | - return true; |
|
| 662 | - } |
|
| 663 | - // make sure this was called in the right place! |
|
| 664 | - if ( |
|
| 665 | - ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 666 | - || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 667 | - ) { |
|
| 668 | - EE_Error::doing_it_wrong( |
|
| 669 | - __METHOD__, |
|
| 670 | - sprintf( |
|
| 671 | - __( |
|
| 672 | - 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
| 673 | - 'event_espresso' |
|
| 674 | - ), |
|
| 675 | - $addon_name |
|
| 676 | - ), |
|
| 677 | - '4.3.0' |
|
| 678 | - ); |
|
| 679 | - } |
|
| 680 | - // make sure addon settings are set correctly without overwriting anything existing |
|
| 681 | - if (isset(self::$_settings[ $addon_name ])) { |
|
| 682 | - self::$_settings[ $addon_name ] += $addon_settings; |
|
| 683 | - } else { |
|
| 684 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
| 685 | - } |
|
| 686 | - return false; |
|
| 687 | - } |
|
| 632 | + /** |
|
| 633 | + * @param string $addon_name |
|
| 634 | + * @param array $addon_settings |
|
| 635 | + * @return bool |
|
| 636 | + * @throws EE_Error |
|
| 637 | + * @throws InvalidArgumentException |
|
| 638 | + * @throws ReflectionException |
|
| 639 | + * @throws InvalidDataTypeException |
|
| 640 | + * @throws InvalidInterfaceException |
|
| 641 | + */ |
|
| 642 | + private static function _addon_activation($addon_name, array $addon_settings) |
|
| 643 | + { |
|
| 644 | + // this is an activation request |
|
| 645 | + if (did_action('activate_plugin')) { |
|
| 646 | + //to find if THIS is the addon that was activated, just check if we have already registered it or not |
|
| 647 | + //(as the newly-activated addon wasn't around the first time addons were registered). |
|
| 648 | + //Note: the presence of pue_options in the addon registration options will initialize the $_settings |
|
| 649 | + //property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
|
| 650 | + if (! isset(self::$_settings[ $addon_name ]) |
|
| 651 | + || (isset(self::$_settings[ $addon_name ]) |
|
| 652 | + && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
| 653 | + ) |
|
| 654 | + ) { |
|
| 655 | + self::$_settings[ $addon_name ] = $addon_settings; |
|
| 656 | + $addon = self::_load_and_init_addon_class($addon_name); |
|
| 657 | + $addon->set_activation_indicator_option(); |
|
| 658 | + // dont bother setting up the rest of the addon. |
|
| 659 | + // we know it was just activated and the request will end soon |
|
| 660 | + } |
|
| 661 | + return true; |
|
| 662 | + } |
|
| 663 | + // make sure this was called in the right place! |
|
| 664 | + if ( |
|
| 665 | + ! did_action('AHEE__EE_System__load_espresso_addons') |
|
| 666 | + || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin') |
|
| 667 | + ) { |
|
| 668 | + EE_Error::doing_it_wrong( |
|
| 669 | + __METHOD__, |
|
| 670 | + sprintf( |
|
| 671 | + __( |
|
| 672 | + 'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time. Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.', |
|
| 673 | + 'event_espresso' |
|
| 674 | + ), |
|
| 675 | + $addon_name |
|
| 676 | + ), |
|
| 677 | + '4.3.0' |
|
| 678 | + ); |
|
| 679 | + } |
|
| 680 | + // make sure addon settings are set correctly without overwriting anything existing |
|
| 681 | + if (isset(self::$_settings[ $addon_name ])) { |
|
| 682 | + self::$_settings[ $addon_name ] += $addon_settings; |
|
| 683 | + } else { |
|
| 684 | + self::$_settings[ $addon_name ] = $addon_settings; |
|
| 685 | + } |
|
| 686 | + return false; |
|
| 687 | + } |
|
| 688 | 688 | |
| 689 | 689 | |
| 690 | - /** |
|
| 691 | - * @param string $addon_name |
|
| 692 | - * @return void |
|
| 693 | - * @throws EE_Error |
|
| 694 | - */ |
|
| 695 | - private static function _setup_autoloaders($addon_name) |
|
| 696 | - { |
|
| 697 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
| 698 | - // setup autoloader for single file |
|
| 699 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
| 700 | - } |
|
| 701 | - // setup autoloaders for folders |
|
| 702 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
| 703 | - foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
| 704 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
| 705 | - } |
|
| 706 | - } |
|
| 707 | - } |
|
| 690 | + /** |
|
| 691 | + * @param string $addon_name |
|
| 692 | + * @return void |
|
| 693 | + * @throws EE_Error |
|
| 694 | + */ |
|
| 695 | + private static function _setup_autoloaders($addon_name) |
|
| 696 | + { |
|
| 697 | + if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
| 698 | + // setup autoloader for single file |
|
| 699 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
| 700 | + } |
|
| 701 | + // setup autoloaders for folders |
|
| 702 | + if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
| 703 | + foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
| 704 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
|
| 705 | + } |
|
| 706 | + } |
|
| 707 | + } |
|
| 708 | 708 | |
| 709 | 709 | |
| 710 | - /** |
|
| 711 | - * register new models and extensions |
|
| 712 | - * |
|
| 713 | - * @param string $addon_name |
|
| 714 | - * @return void |
|
| 715 | - * @throws EE_Error |
|
| 716 | - */ |
|
| 717 | - private static function _register_models_and_extensions($addon_name) |
|
| 718 | - { |
|
| 719 | - // register new models |
|
| 720 | - if ( |
|
| 721 | - ! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
| 722 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
| 723 | - ) { |
|
| 724 | - EE_Register_Model::register( |
|
| 725 | - $addon_name, |
|
| 726 | - array( |
|
| 727 | - 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
| 728 | - 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
| 729 | - ) |
|
| 730 | - ); |
|
| 731 | - } |
|
| 732 | - // register model extensions |
|
| 733 | - if ( |
|
| 734 | - ! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
| 735 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
| 736 | - ) { |
|
| 737 | - EE_Register_Model_Extensions::register( |
|
| 738 | - $addon_name, |
|
| 739 | - array( |
|
| 740 | - 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
| 741 | - 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
| 742 | - ) |
|
| 743 | - ); |
|
| 744 | - } |
|
| 745 | - } |
|
| 710 | + /** |
|
| 711 | + * register new models and extensions |
|
| 712 | + * |
|
| 713 | + * @param string $addon_name |
|
| 714 | + * @return void |
|
| 715 | + * @throws EE_Error |
|
| 716 | + */ |
|
| 717 | + private static function _register_models_and_extensions($addon_name) |
|
| 718 | + { |
|
| 719 | + // register new models |
|
| 720 | + if ( |
|
| 721 | + ! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
| 722 | + || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
| 723 | + ) { |
|
| 724 | + EE_Register_Model::register( |
|
| 725 | + $addon_name, |
|
| 726 | + array( |
|
| 727 | + 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
| 728 | + 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
| 729 | + ) |
|
| 730 | + ); |
|
| 731 | + } |
|
| 732 | + // register model extensions |
|
| 733 | + if ( |
|
| 734 | + ! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
| 735 | + || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
| 736 | + ) { |
|
| 737 | + EE_Register_Model_Extensions::register( |
|
| 738 | + $addon_name, |
|
| 739 | + array( |
|
| 740 | + 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
| 741 | + 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
| 742 | + ) |
|
| 743 | + ); |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | 746 | |
| 747 | 747 | |
| 748 | - /** |
|
| 749 | - * @param string $addon_name |
|
| 750 | - * @return void |
|
| 751 | - * @throws EE_Error |
|
| 752 | - */ |
|
| 753 | - private static function _register_data_migration_scripts($addon_name) |
|
| 754 | - { |
|
| 755 | - // setup DMS |
|
| 756 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
| 757 | - EE_Register_Data_Migration_Scripts::register( |
|
| 758 | - $addon_name, |
|
| 759 | - array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
| 760 | - ); |
|
| 761 | - } |
|
| 762 | - } |
|
| 748 | + /** |
|
| 749 | + * @param string $addon_name |
|
| 750 | + * @return void |
|
| 751 | + * @throws EE_Error |
|
| 752 | + */ |
|
| 753 | + private static function _register_data_migration_scripts($addon_name) |
|
| 754 | + { |
|
| 755 | + // setup DMS |
|
| 756 | + if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
| 757 | + EE_Register_Data_Migration_Scripts::register( |
|
| 758 | + $addon_name, |
|
| 759 | + array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
| 760 | + ); |
|
| 761 | + } |
|
| 762 | + } |
|
| 763 | 763 | |
| 764 | 764 | |
| 765 | - /** |
|
| 766 | - * @param string $addon_name |
|
| 767 | - * @return void |
|
| 768 | - * @throws EE_Error |
|
| 769 | - */ |
|
| 770 | - private static function _register_config($addon_name) |
|
| 771 | - { |
|
| 772 | - // if config_class is present let's register config. |
|
| 773 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
| 774 | - EE_Register_Config::register( |
|
| 775 | - self::$_settings[ $addon_name ]['config_class'], |
|
| 776 | - array( |
|
| 777 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
| 778 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
| 779 | - ) |
|
| 780 | - ); |
|
| 781 | - } |
|
| 782 | - } |
|
| 765 | + /** |
|
| 766 | + * @param string $addon_name |
|
| 767 | + * @return void |
|
| 768 | + * @throws EE_Error |
|
| 769 | + */ |
|
| 770 | + private static function _register_config($addon_name) |
|
| 771 | + { |
|
| 772 | + // if config_class is present let's register config. |
|
| 773 | + if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
| 774 | + EE_Register_Config::register( |
|
| 775 | + self::$_settings[ $addon_name ]['config_class'], |
|
| 776 | + array( |
|
| 777 | + 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
| 778 | + 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
| 779 | + ) |
|
| 780 | + ); |
|
| 781 | + } |
|
| 782 | + } |
|
| 783 | 783 | |
| 784 | 784 | |
| 785 | - /** |
|
| 786 | - * @param string $addon_name |
|
| 787 | - * @return void |
|
| 788 | - * @throws EE_Error |
|
| 789 | - */ |
|
| 790 | - private static function _register_admin_pages($addon_name) |
|
| 791 | - { |
|
| 792 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
| 793 | - EE_Register_Admin_Page::register( |
|
| 794 | - $addon_name, |
|
| 795 | - array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
| 796 | - ); |
|
| 797 | - } |
|
| 798 | - } |
|
| 785 | + /** |
|
| 786 | + * @param string $addon_name |
|
| 787 | + * @return void |
|
| 788 | + * @throws EE_Error |
|
| 789 | + */ |
|
| 790 | + private static function _register_admin_pages($addon_name) |
|
| 791 | + { |
|
| 792 | + if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
| 793 | + EE_Register_Admin_Page::register( |
|
| 794 | + $addon_name, |
|
| 795 | + array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
| 796 | + ); |
|
| 797 | + } |
|
| 798 | + } |
|
| 799 | 799 | |
| 800 | 800 | |
| 801 | - /** |
|
| 802 | - * @param string $addon_name |
|
| 803 | - * @return void |
|
| 804 | - * @throws EE_Error |
|
| 805 | - */ |
|
| 806 | - private static function _register_modules($addon_name) |
|
| 807 | - { |
|
| 808 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
| 809 | - EE_Register_Module::register( |
|
| 810 | - $addon_name, |
|
| 811 | - array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
| 812 | - ); |
|
| 813 | - } |
|
| 814 | - } |
|
| 801 | + /** |
|
| 802 | + * @param string $addon_name |
|
| 803 | + * @return void |
|
| 804 | + * @throws EE_Error |
|
| 805 | + */ |
|
| 806 | + private static function _register_modules($addon_name) |
|
| 807 | + { |
|
| 808 | + if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
| 809 | + EE_Register_Module::register( |
|
| 810 | + $addon_name, |
|
| 811 | + array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
| 812 | + ); |
|
| 813 | + } |
|
| 814 | + } |
|
| 815 | 815 | |
| 816 | 816 | |
| 817 | - /** |
|
| 818 | - * @param string $addon_name |
|
| 819 | - * @return void |
|
| 820 | - * @throws EE_Error |
|
| 821 | - */ |
|
| 822 | - private static function _register_shortcodes($addon_name) |
|
| 823 | - { |
|
| 824 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 825 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 826 | - ) { |
|
| 827 | - EE_Register_Shortcode::register( |
|
| 828 | - $addon_name, |
|
| 829 | - array( |
|
| 830 | - 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 831 | - ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
| 832 | - : array(), |
|
| 833 | - 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 834 | - ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
| 835 | - : array(), |
|
| 836 | - ) |
|
| 837 | - ); |
|
| 838 | - } |
|
| 839 | - } |
|
| 817 | + /** |
|
| 818 | + * @param string $addon_name |
|
| 819 | + * @return void |
|
| 820 | + * @throws EE_Error |
|
| 821 | + */ |
|
| 822 | + private static function _register_shortcodes($addon_name) |
|
| 823 | + { |
|
| 824 | + if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 825 | + || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 826 | + ) { |
|
| 827 | + EE_Register_Shortcode::register( |
|
| 828 | + $addon_name, |
|
| 829 | + array( |
|
| 830 | + 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 831 | + ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
| 832 | + : array(), |
|
| 833 | + 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 834 | + ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
| 835 | + : array(), |
|
| 836 | + ) |
|
| 837 | + ); |
|
| 838 | + } |
|
| 839 | + } |
|
| 840 | 840 | |
| 841 | 841 | |
| 842 | - /** |
|
| 843 | - * @param string $addon_name |
|
| 844 | - * @return void |
|
| 845 | - * @throws EE_Error |
|
| 846 | - */ |
|
| 847 | - private static function _register_widgets($addon_name) |
|
| 848 | - { |
|
| 849 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
| 850 | - EE_Register_Widget::register( |
|
| 851 | - $addon_name, |
|
| 852 | - array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
| 853 | - ); |
|
| 854 | - } |
|
| 855 | - } |
|
| 842 | + /** |
|
| 843 | + * @param string $addon_name |
|
| 844 | + * @return void |
|
| 845 | + * @throws EE_Error |
|
| 846 | + */ |
|
| 847 | + private static function _register_widgets($addon_name) |
|
| 848 | + { |
|
| 849 | + if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
| 850 | + EE_Register_Widget::register( |
|
| 851 | + $addon_name, |
|
| 852 | + array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
| 853 | + ); |
|
| 854 | + } |
|
| 855 | + } |
|
| 856 | 856 | |
| 857 | 857 | |
| 858 | - /** |
|
| 859 | - * @param string $addon_name |
|
| 860 | - * @return void |
|
| 861 | - * @throws EE_Error |
|
| 862 | - */ |
|
| 863 | - private static function _register_capabilities($addon_name) |
|
| 864 | - { |
|
| 865 | - if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
| 866 | - EE_Register_Capabilities::register( |
|
| 867 | - $addon_name, |
|
| 868 | - array( |
|
| 869 | - 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
| 870 | - 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
| 871 | - ) |
|
| 872 | - ); |
|
| 873 | - } |
|
| 874 | - } |
|
| 858 | + /** |
|
| 859 | + * @param string $addon_name |
|
| 860 | + * @return void |
|
| 861 | + * @throws EE_Error |
|
| 862 | + */ |
|
| 863 | + private static function _register_capabilities($addon_name) |
|
| 864 | + { |
|
| 865 | + if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
| 866 | + EE_Register_Capabilities::register( |
|
| 867 | + $addon_name, |
|
| 868 | + array( |
|
| 869 | + 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
| 870 | + 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
| 871 | + ) |
|
| 872 | + ); |
|
| 873 | + } |
|
| 874 | + } |
|
| 875 | 875 | |
| 876 | 876 | |
| 877 | - /** |
|
| 878 | - * @param string $addon_name |
|
| 879 | - * @return void |
|
| 880 | - * @throws EE_Error |
|
| 881 | - */ |
|
| 882 | - private static function _register_message_types($addon_name) |
|
| 883 | - { |
|
| 884 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
| 885 | - add_action( |
|
| 886 | - 'EE_Brewing_Regular___messages_caf', |
|
| 887 | - array('EE_Register_Addon', 'register_message_types') |
|
| 888 | - ); |
|
| 889 | - } |
|
| 890 | - } |
|
| 877 | + /** |
|
| 878 | + * @param string $addon_name |
|
| 879 | + * @return void |
|
| 880 | + * @throws EE_Error |
|
| 881 | + */ |
|
| 882 | + private static function _register_message_types($addon_name) |
|
| 883 | + { |
|
| 884 | + if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
| 885 | + add_action( |
|
| 886 | + 'EE_Brewing_Regular___messages_caf', |
|
| 887 | + array('EE_Register_Addon', 'register_message_types') |
|
| 888 | + ); |
|
| 889 | + } |
|
| 890 | + } |
|
| 891 | 891 | |
| 892 | 892 | |
| 893 | - /** |
|
| 894 | - * @param string $addon_name |
|
| 895 | - * @return void |
|
| 896 | - * @throws EE_Error |
|
| 897 | - */ |
|
| 898 | - private static function _register_custom_post_types($addon_name) |
|
| 899 | - { |
|
| 900 | - if ( |
|
| 901 | - ! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
| 902 | - || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
| 903 | - ) { |
|
| 904 | - EE_Register_CPT::register( |
|
| 905 | - $addon_name, |
|
| 906 | - array( |
|
| 907 | - 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
| 908 | - 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
| 909 | - 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
| 910 | - ) |
|
| 911 | - ); |
|
| 912 | - } |
|
| 913 | - } |
|
| 893 | + /** |
|
| 894 | + * @param string $addon_name |
|
| 895 | + * @return void |
|
| 896 | + * @throws EE_Error |
|
| 897 | + */ |
|
| 898 | + private static function _register_custom_post_types($addon_name) |
|
| 899 | + { |
|
| 900 | + if ( |
|
| 901 | + ! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
| 902 | + || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
| 903 | + ) { |
|
| 904 | + EE_Register_CPT::register( |
|
| 905 | + $addon_name, |
|
| 906 | + array( |
|
| 907 | + 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
| 908 | + 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
| 909 | + 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
| 910 | + ) |
|
| 911 | + ); |
|
| 912 | + } |
|
| 913 | + } |
|
| 914 | 914 | |
| 915 | 915 | |
| 916 | - /** |
|
| 917 | - * @param string $addon_name |
|
| 918 | - * @return void |
|
| 919 | - * @throws InvalidArgumentException |
|
| 920 | - * @throws InvalidInterfaceException |
|
| 921 | - * @throws InvalidDataTypeException |
|
| 922 | - * @throws DomainException |
|
| 923 | - * @throws EE_Error |
|
| 924 | - */ |
|
| 925 | - private static function _register_payment_methods($addon_name) |
|
| 926 | - { |
|
| 927 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
| 928 | - EE_Register_Payment_Method::register( |
|
| 929 | - $addon_name, |
|
| 930 | - array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
| 931 | - ); |
|
| 932 | - } |
|
| 933 | - } |
|
| 916 | + /** |
|
| 917 | + * @param string $addon_name |
|
| 918 | + * @return void |
|
| 919 | + * @throws InvalidArgumentException |
|
| 920 | + * @throws InvalidInterfaceException |
|
| 921 | + * @throws InvalidDataTypeException |
|
| 922 | + * @throws DomainException |
|
| 923 | + * @throws EE_Error |
|
| 924 | + */ |
|
| 925 | + private static function _register_payment_methods($addon_name) |
|
| 926 | + { |
|
| 927 | + if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
| 928 | + EE_Register_Payment_Method::register( |
|
| 929 | + $addon_name, |
|
| 930 | + array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
| 931 | + ); |
|
| 932 | + } |
|
| 933 | + } |
|
| 934 | 934 | |
| 935 | 935 | |
| 936 | - /** |
|
| 937 | - * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
| 938 | - * |
|
| 939 | - * @param string $addon_name |
|
| 940 | - * @return EE_Addon |
|
| 941 | - * @throws InvalidArgumentException |
|
| 942 | - * @throws InvalidInterfaceException |
|
| 943 | - * @throws InvalidDataTypeException |
|
| 944 | - * @throws ReflectionException |
|
| 945 | - * @throws EE_Error |
|
| 946 | - */ |
|
| 947 | - private static function _load_and_init_addon_class($addon_name) |
|
| 948 | - { |
|
| 949 | - $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
|
| 950 | - $addon = $loader->getShared( |
|
| 951 | - self::$_settings[ $addon_name ]['class_name'], |
|
| 952 | - array('EE_Registry::create(addon)' => true) |
|
| 953 | - ); |
|
| 954 | - // setter inject dep map if required |
|
| 955 | - if($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null){ |
|
| 956 | - $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
|
| 957 | - } |
|
| 958 | - // setter inject domain if required |
|
| 959 | - if( |
|
| 960 | - $addon instanceof RequiresDomainInterface |
|
| 961 | - && self::$_settings[ $addon_name ]['domain_fqcn'] !== '' |
|
| 962 | - && $addon->domain() === null |
|
| 963 | - ){ |
|
| 964 | - $addon->setDomain( |
|
| 965 | - $loader->getShared( |
|
| 966 | - self::$_settings[ $addon_name ]['domain_fqcn'], |
|
| 967 | - array( |
|
| 968 | - self::$_settings[ $addon_name ]['main_file_path'], |
|
| 969 | - self::$_settings[ $addon_name ]['version'] |
|
| 970 | - ) |
|
| 971 | - ) |
|
| 972 | - ); |
|
| 973 | - } |
|
| 936 | + /** |
|
| 937 | + * Loads and instantiates the EE_Addon class and adds it onto the registry |
|
| 938 | + * |
|
| 939 | + * @param string $addon_name |
|
| 940 | + * @return EE_Addon |
|
| 941 | + * @throws InvalidArgumentException |
|
| 942 | + * @throws InvalidInterfaceException |
|
| 943 | + * @throws InvalidDataTypeException |
|
| 944 | + * @throws ReflectionException |
|
| 945 | + * @throws EE_Error |
|
| 946 | + */ |
|
| 947 | + private static function _load_and_init_addon_class($addon_name) |
|
| 948 | + { |
|
| 949 | + $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
|
| 950 | + $addon = $loader->getShared( |
|
| 951 | + self::$_settings[ $addon_name ]['class_name'], |
|
| 952 | + array('EE_Registry::create(addon)' => true) |
|
| 953 | + ); |
|
| 954 | + // setter inject dep map if required |
|
| 955 | + if($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null){ |
|
| 956 | + $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
|
| 957 | + } |
|
| 958 | + // setter inject domain if required |
|
| 959 | + if( |
|
| 960 | + $addon instanceof RequiresDomainInterface |
|
| 961 | + && self::$_settings[ $addon_name ]['domain_fqcn'] !== '' |
|
| 962 | + && $addon->domain() === null |
|
| 963 | + ){ |
|
| 964 | + $addon->setDomain( |
|
| 965 | + $loader->getShared( |
|
| 966 | + self::$_settings[ $addon_name ]['domain_fqcn'], |
|
| 967 | + array( |
|
| 968 | + self::$_settings[ $addon_name ]['main_file_path'], |
|
| 969 | + self::$_settings[ $addon_name ]['version'] |
|
| 970 | + ) |
|
| 971 | + ) |
|
| 972 | + ); |
|
| 973 | + } |
|
| 974 | 974 | |
| 975 | - $addon->set_name($addon_name); |
|
| 976 | - $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
| 977 | - $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
| 978 | - $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
| 979 | - $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
| 980 | - $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
| 981 | - $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
| 982 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
| 983 | - $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
| 984 | - $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
| 985 | - $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
| 986 | - //unfortunately this can't be hooked in upon construction, because we don't have |
|
| 987 | - //the plugin mainfile's path upon construction. |
|
| 988 | - register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
| 989 | - // call any additional admin_callback functions during load_admin_controller hook |
|
| 990 | - if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
| 991 | - add_action( |
|
| 992 | - 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
| 993 | - array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
| 994 | - ); |
|
| 995 | - } |
|
| 996 | - return $addon; |
|
| 997 | - } |
|
| 975 | + $addon->set_name($addon_name); |
|
| 976 | + $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
| 977 | + $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
| 978 | + $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
| 979 | + $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
| 980 | + $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
| 981 | + $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
| 982 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
| 983 | + $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
| 984 | + $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
| 985 | + $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
| 986 | + //unfortunately this can't be hooked in upon construction, because we don't have |
|
| 987 | + //the plugin mainfile's path upon construction. |
|
| 988 | + register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
|
| 989 | + // call any additional admin_callback functions during load_admin_controller hook |
|
| 990 | + if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
| 991 | + add_action( |
|
| 992 | + 'AHEE__EE_System__load_controllers__load_admin_controllers', |
|
| 993 | + array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
| 994 | + ); |
|
| 995 | + } |
|
| 996 | + return $addon; |
|
| 997 | + } |
|
| 998 | 998 | |
| 999 | 999 | |
| 1000 | - /** |
|
| 1001 | - * load_pue_update - Update notifications |
|
| 1002 | - * |
|
| 1003 | - * @return void |
|
| 1004 | - * @throws InvalidArgumentException |
|
| 1005 | - * @throws InvalidDataTypeException |
|
| 1006 | - * @throws InvalidInterfaceException |
|
| 1007 | - */ |
|
| 1008 | - public static function load_pue_update() |
|
| 1009 | - { |
|
| 1010 | - // load PUE client |
|
| 1011 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
| 1012 | - // cycle thru settings |
|
| 1013 | - foreach (self::$_settings as $settings) { |
|
| 1014 | - if (! empty($settings['pue_options'])) { |
|
| 1015 | - // initiate the class and start the plugin update engine! |
|
| 1016 | - new PluginUpdateEngineChecker( |
|
| 1017 | - // host file URL |
|
| 1018 | - 'https://eventespresso.com', |
|
| 1019 | - // plugin slug(s) |
|
| 1020 | - array( |
|
| 1021 | - 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
| 1022 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
| 1023 | - ), |
|
| 1024 | - // options |
|
| 1025 | - array( |
|
| 1026 | - 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
| 1027 | - 'lang_domain' => 'event_espresso', |
|
| 1028 | - 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
| 1029 | - 'option_key' => 'site_license_key', |
|
| 1030 | - 'options_page_slug' => 'event_espresso', |
|
| 1031 | - 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
| 1032 | - // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
| 1033 | - 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
| 1034 | - ) |
|
| 1035 | - ); |
|
| 1036 | - } |
|
| 1037 | - } |
|
| 1038 | - } |
|
| 1000 | + /** |
|
| 1001 | + * load_pue_update - Update notifications |
|
| 1002 | + * |
|
| 1003 | + * @return void |
|
| 1004 | + * @throws InvalidArgumentException |
|
| 1005 | + * @throws InvalidDataTypeException |
|
| 1006 | + * @throws InvalidInterfaceException |
|
| 1007 | + */ |
|
| 1008 | + public static function load_pue_update() |
|
| 1009 | + { |
|
| 1010 | + // load PUE client |
|
| 1011 | + require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
| 1012 | + // cycle thru settings |
|
| 1013 | + foreach (self::$_settings as $settings) { |
|
| 1014 | + if (! empty($settings['pue_options'])) { |
|
| 1015 | + // initiate the class and start the plugin update engine! |
|
| 1016 | + new PluginUpdateEngineChecker( |
|
| 1017 | + // host file URL |
|
| 1018 | + 'https://eventespresso.com', |
|
| 1019 | + // plugin slug(s) |
|
| 1020 | + array( |
|
| 1021 | + 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
|
| 1022 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
| 1023 | + ), |
|
| 1024 | + // options |
|
| 1025 | + array( |
|
| 1026 | + 'apikey' => EE_Registry::instance()->NET_CFG->core->site_license_key, |
|
| 1027 | + 'lang_domain' => 'event_espresso', |
|
| 1028 | + 'checkPeriod' => $settings['pue_options']['checkPeriod'], |
|
| 1029 | + 'option_key' => 'site_license_key', |
|
| 1030 | + 'options_page_slug' => 'event_espresso', |
|
| 1031 | + 'plugin_basename' => $settings['pue_options']['plugin_basename'], |
|
| 1032 | + // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP |
|
| 1033 | + 'use_wp_update' => $settings['pue_options']['use_wp_update'], |
|
| 1034 | + ) |
|
| 1035 | + ); |
|
| 1036 | + } |
|
| 1037 | + } |
|
| 1038 | + } |
|
| 1039 | 1039 | |
| 1040 | 1040 | |
| 1041 | - /** |
|
| 1042 | - * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
| 1043 | - * |
|
| 1044 | - * @since 4.4.0 |
|
| 1045 | - * @return void |
|
| 1046 | - * @throws EE_Error |
|
| 1047 | - */ |
|
| 1048 | - public static function register_message_types() |
|
| 1049 | - { |
|
| 1050 | - foreach (self::$_settings as $addon_name => $settings) { |
|
| 1051 | - if (! empty($settings['message_types'])) { |
|
| 1052 | - foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
| 1053 | - EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
| 1054 | - } |
|
| 1055 | - } |
|
| 1056 | - } |
|
| 1057 | - } |
|
| 1041 | + /** |
|
| 1042 | + * Callback for EE_Brewing_Regular__messages_caf hook used to register message types. |
|
| 1043 | + * |
|
| 1044 | + * @since 4.4.0 |
|
| 1045 | + * @return void |
|
| 1046 | + * @throws EE_Error |
|
| 1047 | + */ |
|
| 1048 | + public static function register_message_types() |
|
| 1049 | + { |
|
| 1050 | + foreach (self::$_settings as $addon_name => $settings) { |
|
| 1051 | + if (! empty($settings['message_types'])) { |
|
| 1052 | + foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
|
| 1053 | + EE_Register_Message_Type::register($message_type, $message_type_settings); |
|
| 1054 | + } |
|
| 1055 | + } |
|
| 1056 | + } |
|
| 1057 | + } |
|
| 1058 | 1058 | |
| 1059 | 1059 | |
| 1060 | - /** |
|
| 1061 | - * This deregisters an addon that was previously registered with a specific addon_name. |
|
| 1062 | - * |
|
| 1063 | - * @since 4.3.0 |
|
| 1064 | - * @param string $addon_name the name for the addon that was previously registered |
|
| 1065 | - * @throws DomainException |
|
| 1066 | - * @throws EE_Error |
|
| 1067 | - * @throws InvalidArgumentException |
|
| 1068 | - * @throws InvalidDataTypeException |
|
| 1069 | - * @throws InvalidInterfaceException |
|
| 1070 | - */ |
|
| 1071 | - public static function deregister($addon_name = null) |
|
| 1072 | - { |
|
| 1073 | - if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
| 1074 | - do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
| 1075 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
| 1076 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
| 1077 | - // setup DMS |
|
| 1078 | - EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
| 1079 | - } |
|
| 1080 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
| 1081 | - // register admin page |
|
| 1082 | - EE_Register_Admin_Page::deregister($addon_name); |
|
| 1083 | - } |
|
| 1084 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
| 1085 | - // add to list of modules to be registered |
|
| 1086 | - EE_Register_Module::deregister($addon_name); |
|
| 1087 | - } |
|
| 1088 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 1089 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 1090 | - ) { |
|
| 1091 | - // add to list of shortcodes to be registered |
|
| 1092 | - EE_Register_Shortcode::deregister($addon_name); |
|
| 1093 | - } |
|
| 1094 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
| 1095 | - // if config_class present let's register config. |
|
| 1096 | - EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
| 1097 | - } |
|
| 1098 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
| 1099 | - // add to list of widgets to be registered |
|
| 1100 | - EE_Register_Widget::deregister($addon_name); |
|
| 1101 | - } |
|
| 1102 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
| 1103 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
| 1104 | - ) { |
|
| 1105 | - // add to list of shortcodes to be registered |
|
| 1106 | - EE_Register_Model::deregister($addon_name); |
|
| 1107 | - } |
|
| 1108 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
| 1109 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
| 1110 | - ) { |
|
| 1111 | - // add to list of shortcodes to be registered |
|
| 1112 | - EE_Register_Model_Extensions::deregister($addon_name); |
|
| 1113 | - } |
|
| 1114 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
| 1115 | - foreach ( |
|
| 1116 | - (array) self::$_settings[ $addon_name ]['message_types'] as $message_type => |
|
| 1117 | - $message_type_settings |
|
| 1118 | - ) { |
|
| 1119 | - EE_Register_Message_Type::deregister($message_type); |
|
| 1120 | - } |
|
| 1121 | - } |
|
| 1122 | - //deregister capabilities for addon |
|
| 1123 | - if ( |
|
| 1124 | - ! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
| 1125 | - || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
| 1126 | - ) { |
|
| 1127 | - EE_Register_Capabilities::deregister($addon_name); |
|
| 1128 | - } |
|
| 1129 | - //deregister custom_post_types for addon |
|
| 1130 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
| 1131 | - EE_Register_CPT::deregister($addon_name); |
|
| 1132 | - } |
|
| 1133 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
| 1134 | - EE_Register_Payment_Method::deregister($addon_name); |
|
| 1135 | - } |
|
| 1136 | - $addon = EE_Registry::instance()->getAddon($class_name); |
|
| 1137 | - if ($addon instanceof EE_Addon) { |
|
| 1138 | - remove_action( |
|
| 1139 | - 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
| 1140 | - array($addon, 'deactivation') |
|
| 1141 | - ); |
|
| 1142 | - remove_action( |
|
| 1143 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 1144 | - array($addon, 'initialize_db_if_no_migrations_required') |
|
| 1145 | - ); |
|
| 1146 | - //remove `after_registration` call |
|
| 1147 | - remove_action( |
|
| 1148 | - 'AHEE__EE_System__load_espresso_addons__complete', |
|
| 1149 | - array($addon, 'after_registration'), |
|
| 1150 | - 999 |
|
| 1151 | - ); |
|
| 1152 | - } |
|
| 1153 | - EE_Registry::instance()->removeAddon($class_name); |
|
| 1154 | - unset(self::$_settings[ $addon_name ]); |
|
| 1155 | - do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
| 1156 | - } |
|
| 1157 | - } |
|
| 1060 | + /** |
|
| 1061 | + * This deregisters an addon that was previously registered with a specific addon_name. |
|
| 1062 | + * |
|
| 1063 | + * @since 4.3.0 |
|
| 1064 | + * @param string $addon_name the name for the addon that was previously registered |
|
| 1065 | + * @throws DomainException |
|
| 1066 | + * @throws EE_Error |
|
| 1067 | + * @throws InvalidArgumentException |
|
| 1068 | + * @throws InvalidDataTypeException |
|
| 1069 | + * @throws InvalidInterfaceException |
|
| 1070 | + */ |
|
| 1071 | + public static function deregister($addon_name = null) |
|
| 1072 | + { |
|
| 1073 | + if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
| 1074 | + do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
|
| 1075 | + $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
| 1076 | + if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
| 1077 | + // setup DMS |
|
| 1078 | + EE_Register_Data_Migration_Scripts::deregister($addon_name); |
|
| 1079 | + } |
|
| 1080 | + if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
| 1081 | + // register admin page |
|
| 1082 | + EE_Register_Admin_Page::deregister($addon_name); |
|
| 1083 | + } |
|
| 1084 | + if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
| 1085 | + // add to list of modules to be registered |
|
| 1086 | + EE_Register_Module::deregister($addon_name); |
|
| 1087 | + } |
|
| 1088 | + if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 1089 | + || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 1090 | + ) { |
|
| 1091 | + // add to list of shortcodes to be registered |
|
| 1092 | + EE_Register_Shortcode::deregister($addon_name); |
|
| 1093 | + } |
|
| 1094 | + if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
| 1095 | + // if config_class present let's register config. |
|
| 1096 | + EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
| 1097 | + } |
|
| 1098 | + if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
| 1099 | + // add to list of widgets to be registered |
|
| 1100 | + EE_Register_Widget::deregister($addon_name); |
|
| 1101 | + } |
|
| 1102 | + if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
| 1103 | + || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
| 1104 | + ) { |
|
| 1105 | + // add to list of shortcodes to be registered |
|
| 1106 | + EE_Register_Model::deregister($addon_name); |
|
| 1107 | + } |
|
| 1108 | + if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
| 1109 | + || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
| 1110 | + ) { |
|
| 1111 | + // add to list of shortcodes to be registered |
|
| 1112 | + EE_Register_Model_Extensions::deregister($addon_name); |
|
| 1113 | + } |
|
| 1114 | + if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
| 1115 | + foreach ( |
|
| 1116 | + (array) self::$_settings[ $addon_name ]['message_types'] as $message_type => |
|
| 1117 | + $message_type_settings |
|
| 1118 | + ) { |
|
| 1119 | + EE_Register_Message_Type::deregister($message_type); |
|
| 1120 | + } |
|
| 1121 | + } |
|
| 1122 | + //deregister capabilities for addon |
|
| 1123 | + if ( |
|
| 1124 | + ! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
| 1125 | + || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
| 1126 | + ) { |
|
| 1127 | + EE_Register_Capabilities::deregister($addon_name); |
|
| 1128 | + } |
|
| 1129 | + //deregister custom_post_types for addon |
|
| 1130 | + if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
| 1131 | + EE_Register_CPT::deregister($addon_name); |
|
| 1132 | + } |
|
| 1133 | + if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
| 1134 | + EE_Register_Payment_Method::deregister($addon_name); |
|
| 1135 | + } |
|
| 1136 | + $addon = EE_Registry::instance()->getAddon($class_name); |
|
| 1137 | + if ($addon instanceof EE_Addon) { |
|
| 1138 | + remove_action( |
|
| 1139 | + 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
| 1140 | + array($addon, 'deactivation') |
|
| 1141 | + ); |
|
| 1142 | + remove_action( |
|
| 1143 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 1144 | + array($addon, 'initialize_db_if_no_migrations_required') |
|
| 1145 | + ); |
|
| 1146 | + //remove `after_registration` call |
|
| 1147 | + remove_action( |
|
| 1148 | + 'AHEE__EE_System__load_espresso_addons__complete', |
|
| 1149 | + array($addon, 'after_registration'), |
|
| 1150 | + 999 |
|
| 1151 | + ); |
|
| 1152 | + } |
|
| 1153 | + EE_Registry::instance()->removeAddon($class_name); |
|
| 1154 | + unset(self::$_settings[ $addon_name ]); |
|
| 1155 | + do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
|
| 1156 | + } |
|
| 1157 | + } |
|
| 1158 | 1158 | |
| 1159 | 1159 | |
| 1160 | 1160 | } |
@@ -71,15 +71,15 @@ discard block |
||
| 71 | 71 | // offsets: 0 . 1 . 2 . 3 . 4 |
| 72 | 72 | $version_parts = explode('.', $min_core_version); |
| 73 | 73 | //check they specified the micro version (after 2nd period) |
| 74 | - if (! isset($version_parts[2])) { |
|
| 74 | + if ( ! isset($version_parts[2])) { |
|
| 75 | 75 | $version_parts[2] = '0'; |
| 76 | 76 | } |
| 77 | 77 | //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible |
| 78 | 78 | //soon we can assume that's 'rc', but this current version is 'alpha' |
| 79 | - if (! isset($version_parts[3])) { |
|
| 79 | + if ( ! isset($version_parts[3])) { |
|
| 80 | 80 | $version_parts[3] = 'dev'; |
| 81 | 81 | } |
| 82 | - if (! isset($version_parts[4])) { |
|
| 82 | + if ( ! isset($version_parts[4])) { |
|
| 83 | 83 | $version_parts[4] = '000'; |
| 84 | 84 | } |
| 85 | 85 | return implode('.', $version_parts); |
@@ -250,7 +250,7 @@ discard block |
||
| 250 | 250 | // setup PUE |
| 251 | 251 | EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args); |
| 252 | 252 | // does this addon work with this version of core or WordPress ? |
| 253 | - if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 253 | + if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) { |
|
| 254 | 254 | return; |
| 255 | 255 | } |
| 256 | 256 | // register namespaces |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | ) |
| 309 | 309 | ); |
| 310 | 310 | } |
| 311 | - if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 311 | + if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) { |
|
| 312 | 312 | throw new EE_Error( |
| 313 | 313 | sprintf( |
| 314 | 314 | __( |
@@ -320,7 +320,7 @@ discard block |
||
| 320 | 320 | ); |
| 321 | 321 | } |
| 322 | 322 | // check that addon has not already been registered with that name |
| 323 | - if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) { |
|
| 323 | + if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) { |
|
| 324 | 324 | throw new EE_Error( |
| 325 | 325 | sprintf( |
| 326 | 326 | __( |
@@ -352,7 +352,7 @@ discard block |
||
| 352 | 352 | // check if classname is fully qualified or is a legacy classname already prefixed with 'EE_' |
| 353 | 353 | return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0 |
| 354 | 354 | ? $class_name |
| 355 | - : 'EE_' . $class_name; |
|
| 355 | + : 'EE_'.$class_name; |
|
| 356 | 356 | } |
| 357 | 357 | |
| 358 | 358 | |
@@ -511,9 +511,9 @@ discard block |
||
| 511 | 511 | $incompatibility_message = ''; |
| 512 | 512 | //check whether this addon version is compatible with EE core |
| 513 | 513 | if ( |
| 514 | - isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ]) |
|
| 514 | + isset(EE_Register_Addon::$_incompatible_addons[$addon_name]) |
|
| 515 | 515 | && ! self::_meets_min_core_version_requirement( |
| 516 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
| 516 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
| 517 | 517 | $addon_settings['version'] |
| 518 | 518 | ) |
| 519 | 519 | ) { |
@@ -523,7 +523,7 @@ discard block |
||
| 523 | 523 | ), |
| 524 | 524 | $addon_name, |
| 525 | 525 | '<br />', |
| 526 | - EE_Register_Addon::$_incompatible_addons[ $addon_name ], |
|
| 526 | + EE_Register_Addon::$_incompatible_addons[$addon_name], |
|
| 527 | 527 | '<span style="font-weight: bold; color: #D54E21;">', |
| 528 | 528 | '</span><br />' |
| 529 | 529 | ); |
@@ -555,7 +555,7 @@ discard block |
||
| 555 | 555 | '</span><br />' |
| 556 | 556 | ); |
| 557 | 557 | } |
| 558 | - if (! empty($incompatibility_message)) { |
|
| 558 | + if ( ! empty($incompatibility_message)) { |
|
| 559 | 559 | // remove 'activate' from the REQUEST |
| 560 | 560 | // so WP doesn't erroneously tell the user the plugin activated fine when it didn't |
| 561 | 561 | unset($_GET['activate'], $_REQUEST['activate']); |
@@ -583,11 +583,11 @@ discard block |
||
| 583 | 583 | */ |
| 584 | 584 | private static function _parse_pue_options($addon_name, $class_name, array $setup_args) |
| 585 | 585 | { |
| 586 | - if (! empty($setup_args['pue_options'])) { |
|
| 587 | - self::$_settings[ $addon_name ]['pue_options'] = array( |
|
| 586 | + if ( ! empty($setup_args['pue_options'])) { |
|
| 587 | + self::$_settings[$addon_name]['pue_options'] = array( |
|
| 588 | 588 | 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug']) |
| 589 | 589 | ? (string) $setup_args['pue_options']['pue_plugin_slug'] |
| 590 | - : 'espresso_' . strtolower($class_name), |
|
| 590 | + : 'espresso_'.strtolower($class_name), |
|
| 591 | 591 | 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename']) |
| 592 | 592 | ? (string) $setup_args['pue_options']['plugin_basename'] |
| 593 | 593 | : plugin_basename($setup_args['main_file_path']), |
@@ -647,12 +647,12 @@ discard block |
||
| 647 | 647 | //(as the newly-activated addon wasn't around the first time addons were registered). |
| 648 | 648 | //Note: the presence of pue_options in the addon registration options will initialize the $_settings |
| 649 | 649 | //property for the add-on, but the add-on is only partially initialized. Hence, the additional check. |
| 650 | - if (! isset(self::$_settings[ $addon_name ]) |
|
| 651 | - || (isset(self::$_settings[ $addon_name ]) |
|
| 652 | - && ! isset(self::$_settings[ $addon_name ]['class_name']) |
|
| 650 | + if ( ! isset(self::$_settings[$addon_name]) |
|
| 651 | + || (isset(self::$_settings[$addon_name]) |
|
| 652 | + && ! isset(self::$_settings[$addon_name]['class_name']) |
|
| 653 | 653 | ) |
| 654 | 654 | ) { |
| 655 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
| 655 | + self::$_settings[$addon_name] = $addon_settings; |
|
| 656 | 656 | $addon = self::_load_and_init_addon_class($addon_name); |
| 657 | 657 | $addon->set_activation_indicator_option(); |
| 658 | 658 | // dont bother setting up the rest of the addon. |
@@ -678,10 +678,10 @@ discard block |
||
| 678 | 678 | ); |
| 679 | 679 | } |
| 680 | 680 | // make sure addon settings are set correctly without overwriting anything existing |
| 681 | - if (isset(self::$_settings[ $addon_name ])) { |
|
| 682 | - self::$_settings[ $addon_name ] += $addon_settings; |
|
| 681 | + if (isset(self::$_settings[$addon_name])) { |
|
| 682 | + self::$_settings[$addon_name] += $addon_settings; |
|
| 683 | 683 | } else { |
| 684 | - self::$_settings[ $addon_name ] = $addon_settings; |
|
| 684 | + self::$_settings[$addon_name] = $addon_settings; |
|
| 685 | 685 | } |
| 686 | 686 | return false; |
| 687 | 687 | } |
@@ -694,13 +694,13 @@ discard block |
||
| 694 | 694 | */ |
| 695 | 695 | private static function _setup_autoloaders($addon_name) |
| 696 | 696 | { |
| 697 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) { |
|
| 697 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) { |
|
| 698 | 698 | // setup autoloader for single file |
| 699 | - EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']); |
|
| 699 | + EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']); |
|
| 700 | 700 | } |
| 701 | 701 | // setup autoloaders for folders |
| 702 | - if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) { |
|
| 703 | - foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) { |
|
| 702 | + if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) { |
|
| 703 | + foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) { |
|
| 704 | 704 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder); |
| 705 | 705 | } |
| 706 | 706 | } |
@@ -718,27 +718,27 @@ discard block |
||
| 718 | 718 | { |
| 719 | 719 | // register new models |
| 720 | 720 | if ( |
| 721 | - ! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
| 722 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
| 721 | + ! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 722 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
| 723 | 723 | ) { |
| 724 | 724 | EE_Register_Model::register( |
| 725 | 725 | $addon_name, |
| 726 | 726 | array( |
| 727 | - 'model_paths' => self::$_settings[ $addon_name ]['model_paths'], |
|
| 728 | - 'class_paths' => self::$_settings[ $addon_name ]['class_paths'], |
|
| 727 | + 'model_paths' => self::$_settings[$addon_name]['model_paths'], |
|
| 728 | + 'class_paths' => self::$_settings[$addon_name]['class_paths'], |
|
| 729 | 729 | ) |
| 730 | 730 | ); |
| 731 | 731 | } |
| 732 | 732 | // register model extensions |
| 733 | 733 | if ( |
| 734 | - ! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
| 735 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
| 734 | + ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 735 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
| 736 | 736 | ) { |
| 737 | 737 | EE_Register_Model_Extensions::register( |
| 738 | 738 | $addon_name, |
| 739 | 739 | array( |
| 740 | - 'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'], |
|
| 741 | - 'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'], |
|
| 740 | + 'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'], |
|
| 741 | + 'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'], |
|
| 742 | 742 | ) |
| 743 | 743 | ); |
| 744 | 744 | } |
@@ -753,10 +753,10 @@ discard block |
||
| 753 | 753 | private static function _register_data_migration_scripts($addon_name) |
| 754 | 754 | { |
| 755 | 755 | // setup DMS |
| 756 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
| 756 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 757 | 757 | EE_Register_Data_Migration_Scripts::register( |
| 758 | 758 | $addon_name, |
| 759 | - array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths']) |
|
| 759 | + array('dms_paths' => self::$_settings[$addon_name]['dms_paths']) |
|
| 760 | 760 | ); |
| 761 | 761 | } |
| 762 | 762 | } |
@@ -770,12 +770,12 @@ discard block |
||
| 770 | 770 | private static function _register_config($addon_name) |
| 771 | 771 | { |
| 772 | 772 | // if config_class is present let's register config. |
| 773 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
| 773 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 774 | 774 | EE_Register_Config::register( |
| 775 | - self::$_settings[ $addon_name ]['config_class'], |
|
| 775 | + self::$_settings[$addon_name]['config_class'], |
|
| 776 | 776 | array( |
| 777 | - 'config_section' => self::$_settings[ $addon_name ]['config_section'], |
|
| 778 | - 'config_name' => self::$_settings[ $addon_name ]['config_name'], |
|
| 777 | + 'config_section' => self::$_settings[$addon_name]['config_section'], |
|
| 778 | + 'config_name' => self::$_settings[$addon_name]['config_name'], |
|
| 779 | 779 | ) |
| 780 | 780 | ); |
| 781 | 781 | } |
@@ -789,10 +789,10 @@ discard block |
||
| 789 | 789 | */ |
| 790 | 790 | private static function _register_admin_pages($addon_name) |
| 791 | 791 | { |
| 792 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
| 792 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 793 | 793 | EE_Register_Admin_Page::register( |
| 794 | 794 | $addon_name, |
| 795 | - array('page_path' => self::$_settings[ $addon_name ]['admin_path']) |
|
| 795 | + array('page_path' => self::$_settings[$addon_name]['admin_path']) |
|
| 796 | 796 | ); |
| 797 | 797 | } |
| 798 | 798 | } |
@@ -805,10 +805,10 @@ discard block |
||
| 805 | 805 | */ |
| 806 | 806 | private static function _register_modules($addon_name) |
| 807 | 807 | { |
| 808 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
| 808 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 809 | 809 | EE_Register_Module::register( |
| 810 | 810 | $addon_name, |
| 811 | - array('module_paths' => self::$_settings[ $addon_name ]['module_paths']) |
|
| 811 | + array('module_paths' => self::$_settings[$addon_name]['module_paths']) |
|
| 812 | 812 | ); |
| 813 | 813 | } |
| 814 | 814 | } |
@@ -821,17 +821,17 @@ discard block |
||
| 821 | 821 | */ |
| 822 | 822 | private static function _register_shortcodes($addon_name) |
| 823 | 823 | { |
| 824 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 825 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 824 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths']) |
|
| 825 | + || ! empty(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
| 826 | 826 | ) { |
| 827 | 827 | EE_Register_Shortcode::register( |
| 828 | 828 | $addon_name, |
| 829 | 829 | array( |
| 830 | - 'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 831 | - ? self::$_settings[ $addon_name ]['shortcode_paths'] |
|
| 830 | + 'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths']) |
|
| 831 | + ? self::$_settings[$addon_name]['shortcode_paths'] |
|
| 832 | 832 | : array(), |
| 833 | - 'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 834 | - ? self::$_settings[ $addon_name ]['shortcode_fqcns'] |
|
| 833 | + 'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
| 834 | + ? self::$_settings[$addon_name]['shortcode_fqcns'] |
|
| 835 | 835 | : array(), |
| 836 | 836 | ) |
| 837 | 837 | ); |
@@ -846,10 +846,10 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | private static function _register_widgets($addon_name) |
| 848 | 848 | { |
| 849 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
| 849 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 850 | 850 | EE_Register_Widget::register( |
| 851 | 851 | $addon_name, |
| 852 | - array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths']) |
|
| 852 | + array('widget_paths' => self::$_settings[$addon_name]['widget_paths']) |
|
| 853 | 853 | ); |
| 854 | 854 | } |
| 855 | 855 | } |
@@ -862,12 +862,12 @@ discard block |
||
| 862 | 862 | */ |
| 863 | 863 | private static function _register_capabilities($addon_name) |
| 864 | 864 | { |
| 865 | - if (! empty(self::$_settings[ $addon_name ]['capabilities'])) { |
|
| 865 | + if ( ! empty(self::$_settings[$addon_name]['capabilities'])) { |
|
| 866 | 866 | EE_Register_Capabilities::register( |
| 867 | 867 | $addon_name, |
| 868 | 868 | array( |
| 869 | - 'capabilities' => self::$_settings[ $addon_name ]['capabilities'], |
|
| 870 | - 'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'], |
|
| 869 | + 'capabilities' => self::$_settings[$addon_name]['capabilities'], |
|
| 870 | + 'capability_maps' => self::$_settings[$addon_name]['capability_maps'], |
|
| 871 | 871 | ) |
| 872 | 872 | ); |
| 873 | 873 | } |
@@ -881,7 +881,7 @@ discard block |
||
| 881 | 881 | */ |
| 882 | 882 | private static function _register_message_types($addon_name) |
| 883 | 883 | { |
| 884 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
| 884 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 885 | 885 | add_action( |
| 886 | 886 | 'EE_Brewing_Regular___messages_caf', |
| 887 | 887 | array('EE_Register_Addon', 'register_message_types') |
@@ -898,15 +898,15 @@ discard block |
||
| 898 | 898 | private static function _register_custom_post_types($addon_name) |
| 899 | 899 | { |
| 900 | 900 | if ( |
| 901 | - ! empty(self::$_settings[ $addon_name ]['custom_post_types']) |
|
| 902 | - || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies']) |
|
| 901 | + ! empty(self::$_settings[$addon_name]['custom_post_types']) |
|
| 902 | + || ! empty(self::$_settings[$addon_name]['custom_taxonomies']) |
|
| 903 | 903 | ) { |
| 904 | 904 | EE_Register_CPT::register( |
| 905 | 905 | $addon_name, |
| 906 | 906 | array( |
| 907 | - 'cpts' => self::$_settings[ $addon_name ]['custom_post_types'], |
|
| 908 | - 'cts' => self::$_settings[ $addon_name ]['custom_taxonomies'], |
|
| 909 | - 'default_terms' => self::$_settings[ $addon_name ]['default_terms'], |
|
| 907 | + 'cpts' => self::$_settings[$addon_name]['custom_post_types'], |
|
| 908 | + 'cts' => self::$_settings[$addon_name]['custom_taxonomies'], |
|
| 909 | + 'default_terms' => self::$_settings[$addon_name]['default_terms'], |
|
| 910 | 910 | ) |
| 911 | 911 | ); |
| 912 | 912 | } |
@@ -924,10 +924,10 @@ discard block |
||
| 924 | 924 | */ |
| 925 | 925 | private static function _register_payment_methods($addon_name) |
| 926 | 926 | { |
| 927 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
| 927 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
| 928 | 928 | EE_Register_Payment_Method::register( |
| 929 | 929 | $addon_name, |
| 930 | - array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths']) |
|
| 930 | + array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths']) |
|
| 931 | 931 | ); |
| 932 | 932 | } |
| 933 | 933 | } |
@@ -948,49 +948,49 @@ discard block |
||
| 948 | 948 | { |
| 949 | 949 | $loader = EventEspresso\core\services\loaders\LoaderFactory::getLoader(); |
| 950 | 950 | $addon = $loader->getShared( |
| 951 | - self::$_settings[ $addon_name ]['class_name'], |
|
| 951 | + self::$_settings[$addon_name]['class_name'], |
|
| 952 | 952 | array('EE_Registry::create(addon)' => true) |
| 953 | 953 | ); |
| 954 | 954 | // setter inject dep map if required |
| 955 | - if($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null){ |
|
| 955 | + if ($addon instanceof RequiresDependencyMapInterface && $addon->dependencyMap() === null) { |
|
| 956 | 956 | $addon->setDependencyMap($loader->getShared('EE_Dependency_Map')); |
| 957 | 957 | } |
| 958 | 958 | // setter inject domain if required |
| 959 | - if( |
|
| 959 | + if ( |
|
| 960 | 960 | $addon instanceof RequiresDomainInterface |
| 961 | - && self::$_settings[ $addon_name ]['domain_fqcn'] !== '' |
|
| 961 | + && self::$_settings[$addon_name]['domain_fqcn'] !== '' |
|
| 962 | 962 | && $addon->domain() === null |
| 963 | - ){ |
|
| 963 | + ) { |
|
| 964 | 964 | $addon->setDomain( |
| 965 | 965 | $loader->getShared( |
| 966 | - self::$_settings[ $addon_name ]['domain_fqcn'], |
|
| 966 | + self::$_settings[$addon_name]['domain_fqcn'], |
|
| 967 | 967 | array( |
| 968 | - self::$_settings[ $addon_name ]['main_file_path'], |
|
| 969 | - self::$_settings[ $addon_name ]['version'] |
|
| 968 | + self::$_settings[$addon_name]['main_file_path'], |
|
| 969 | + self::$_settings[$addon_name]['version'] |
|
| 970 | 970 | ) |
| 971 | 971 | ) |
| 972 | 972 | ); |
| 973 | 973 | } |
| 974 | 974 | |
| 975 | 975 | $addon->set_name($addon_name); |
| 976 | - $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']); |
|
| 977 | - $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']); |
|
| 978 | - $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']); |
|
| 979 | - $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']); |
|
| 980 | - $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']); |
|
| 981 | - $addon->set_version(self::$_settings[ $addon_name ]['version']); |
|
| 982 | - $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version'])); |
|
| 983 | - $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']); |
|
| 984 | - $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']); |
|
| 985 | - $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']); |
|
| 976 | + $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']); |
|
| 977 | + $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']); |
|
| 978 | + $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']); |
|
| 979 | + $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']); |
|
| 980 | + $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']); |
|
| 981 | + $addon->set_version(self::$_settings[$addon_name]['version']); |
|
| 982 | + $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version'])); |
|
| 983 | + $addon->set_config_section(self::$_settings[$addon_name]['config_section']); |
|
| 984 | + $addon->set_config_class(self::$_settings[$addon_name]['config_class']); |
|
| 985 | + $addon->set_config_name(self::$_settings[$addon_name]['config_name']); |
|
| 986 | 986 | //unfortunately this can't be hooked in upon construction, because we don't have |
| 987 | 987 | //the plugin mainfile's path upon construction. |
| 988 | 988 | register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation')); |
| 989 | 989 | // call any additional admin_callback functions during load_admin_controller hook |
| 990 | - if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) { |
|
| 990 | + if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) { |
|
| 991 | 991 | add_action( |
| 992 | 992 | 'AHEE__EE_System__load_controllers__load_admin_controllers', |
| 993 | - array($addon, self::$_settings[ $addon_name ]['admin_callback']) |
|
| 993 | + array($addon, self::$_settings[$addon_name]['admin_callback']) |
|
| 994 | 994 | ); |
| 995 | 995 | } |
| 996 | 996 | return $addon; |
@@ -1008,10 +1008,10 @@ discard block |
||
| 1008 | 1008 | public static function load_pue_update() |
| 1009 | 1009 | { |
| 1010 | 1010 | // load PUE client |
| 1011 | - require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php'; |
|
| 1011 | + require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php'; |
|
| 1012 | 1012 | // cycle thru settings |
| 1013 | 1013 | foreach (self::$_settings as $settings) { |
| 1014 | - if (! empty($settings['pue_options'])) { |
|
| 1014 | + if ( ! empty($settings['pue_options'])) { |
|
| 1015 | 1015 | // initiate the class and start the plugin update engine! |
| 1016 | 1016 | new PluginUpdateEngineChecker( |
| 1017 | 1017 | // host file URL |
@@ -1019,7 +1019,7 @@ discard block |
||
| 1019 | 1019 | // plugin slug(s) |
| 1020 | 1020 | array( |
| 1021 | 1021 | 'premium' => array('p' => $settings['pue_options']['pue_plugin_slug']), |
| 1022 | - 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'), |
|
| 1022 | + 'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'), |
|
| 1023 | 1023 | ), |
| 1024 | 1024 | // options |
| 1025 | 1025 | array( |
@@ -1048,7 +1048,7 @@ discard block |
||
| 1048 | 1048 | public static function register_message_types() |
| 1049 | 1049 | { |
| 1050 | 1050 | foreach (self::$_settings as $addon_name => $settings) { |
| 1051 | - if (! empty($settings['message_types'])) { |
|
| 1051 | + if ( ! empty($settings['message_types'])) { |
|
| 1052 | 1052 | foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) { |
| 1053 | 1053 | EE_Register_Message_Type::register($message_type, $message_type_settings); |
| 1054 | 1054 | } |
@@ -1070,50 +1070,50 @@ discard block |
||
| 1070 | 1070 | */ |
| 1071 | 1071 | public static function deregister($addon_name = null) |
| 1072 | 1072 | { |
| 1073 | - if (isset(self::$_settings[ $addon_name ]['class_name'])) { |
|
| 1073 | + if (isset(self::$_settings[$addon_name]['class_name'])) { |
|
| 1074 | 1074 | do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name); |
| 1075 | - $class_name = self::$_settings[ $addon_name ]['class_name']; |
|
| 1076 | - if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) { |
|
| 1075 | + $class_name = self::$_settings[$addon_name]['class_name']; |
|
| 1076 | + if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) { |
|
| 1077 | 1077 | // setup DMS |
| 1078 | 1078 | EE_Register_Data_Migration_Scripts::deregister($addon_name); |
| 1079 | 1079 | } |
| 1080 | - if (! empty(self::$_settings[ $addon_name ]['admin_path'])) { |
|
| 1080 | + if ( ! empty(self::$_settings[$addon_name]['admin_path'])) { |
|
| 1081 | 1081 | // register admin page |
| 1082 | 1082 | EE_Register_Admin_Page::deregister($addon_name); |
| 1083 | 1083 | } |
| 1084 | - if (! empty(self::$_settings[ $addon_name ]['module_paths'])) { |
|
| 1084 | + if ( ! empty(self::$_settings[$addon_name]['module_paths'])) { |
|
| 1085 | 1085 | // add to list of modules to be registered |
| 1086 | 1086 | EE_Register_Module::deregister($addon_name); |
| 1087 | 1087 | } |
| 1088 | - if (! empty(self::$_settings[ $addon_name ]['shortcode_paths']) |
|
| 1089 | - || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns']) |
|
| 1088 | + if ( ! empty(self::$_settings[$addon_name]['shortcode_paths']) |
|
| 1089 | + || ! empty(self::$_settings[$addon_name]['shortcode_fqcns']) |
|
| 1090 | 1090 | ) { |
| 1091 | 1091 | // add to list of shortcodes to be registered |
| 1092 | 1092 | EE_Register_Shortcode::deregister($addon_name); |
| 1093 | 1093 | } |
| 1094 | - if (! empty(self::$_settings[ $addon_name ]['config_class'])) { |
|
| 1094 | + if ( ! empty(self::$_settings[$addon_name]['config_class'])) { |
|
| 1095 | 1095 | // if config_class present let's register config. |
| 1096 | - EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']); |
|
| 1096 | + EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']); |
|
| 1097 | 1097 | } |
| 1098 | - if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) { |
|
| 1098 | + if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) { |
|
| 1099 | 1099 | // add to list of widgets to be registered |
| 1100 | 1100 | EE_Register_Widget::deregister($addon_name); |
| 1101 | 1101 | } |
| 1102 | - if (! empty(self::$_settings[ $addon_name ]['model_paths']) |
|
| 1103 | - || ! empty(self::$_settings[ $addon_name ]['class_paths']) |
|
| 1102 | + if ( ! empty(self::$_settings[$addon_name]['model_paths']) |
|
| 1103 | + || ! empty(self::$_settings[$addon_name]['class_paths']) |
|
| 1104 | 1104 | ) { |
| 1105 | 1105 | // add to list of shortcodes to be registered |
| 1106 | 1106 | EE_Register_Model::deregister($addon_name); |
| 1107 | 1107 | } |
| 1108 | - if (! empty(self::$_settings[ $addon_name ]['model_extension_paths']) |
|
| 1109 | - || ! empty(self::$_settings[ $addon_name ]['class_extension_paths']) |
|
| 1108 | + if ( ! empty(self::$_settings[$addon_name]['model_extension_paths']) |
|
| 1109 | + || ! empty(self::$_settings[$addon_name]['class_extension_paths']) |
|
| 1110 | 1110 | ) { |
| 1111 | 1111 | // add to list of shortcodes to be registered |
| 1112 | 1112 | EE_Register_Model_Extensions::deregister($addon_name); |
| 1113 | 1113 | } |
| 1114 | - if (! empty(self::$_settings[ $addon_name ]['message_types'])) { |
|
| 1114 | + if ( ! empty(self::$_settings[$addon_name]['message_types'])) { |
|
| 1115 | 1115 | foreach ( |
| 1116 | - (array) self::$_settings[ $addon_name ]['message_types'] as $message_type => |
|
| 1116 | + (array) self::$_settings[$addon_name]['message_types'] as $message_type => |
|
| 1117 | 1117 | $message_type_settings |
| 1118 | 1118 | ) { |
| 1119 | 1119 | EE_Register_Message_Type::deregister($message_type); |
@@ -1121,22 +1121,22 @@ discard block |
||
| 1121 | 1121 | } |
| 1122 | 1122 | //deregister capabilities for addon |
| 1123 | 1123 | if ( |
| 1124 | - ! empty(self::$_settings[ $addon_name ]['capabilities']) |
|
| 1125 | - || ! empty(self::$_settings[ $addon_name ]['capability_maps']) |
|
| 1124 | + ! empty(self::$_settings[$addon_name]['capabilities']) |
|
| 1125 | + || ! empty(self::$_settings[$addon_name]['capability_maps']) |
|
| 1126 | 1126 | ) { |
| 1127 | 1127 | EE_Register_Capabilities::deregister($addon_name); |
| 1128 | 1128 | } |
| 1129 | 1129 | //deregister custom_post_types for addon |
| 1130 | - if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) { |
|
| 1130 | + if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) { |
|
| 1131 | 1131 | EE_Register_CPT::deregister($addon_name); |
| 1132 | 1132 | } |
| 1133 | - if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) { |
|
| 1133 | + if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) { |
|
| 1134 | 1134 | EE_Register_Payment_Method::deregister($addon_name); |
| 1135 | 1135 | } |
| 1136 | 1136 | $addon = EE_Registry::instance()->getAddon($class_name); |
| 1137 | 1137 | if ($addon instanceof EE_Addon) { |
| 1138 | 1138 | remove_action( |
| 1139 | - 'deactivate_' . $addon->get_main_plugin_file_basename(), |
|
| 1139 | + 'deactivate_'.$addon->get_main_plugin_file_basename(), |
|
| 1140 | 1140 | array($addon, 'deactivation') |
| 1141 | 1141 | ); |
| 1142 | 1142 | remove_action( |
@@ -1151,7 +1151,7 @@ discard block |
||
| 1151 | 1151 | ); |
| 1152 | 1152 | } |
| 1153 | 1153 | EE_Registry::instance()->removeAddon($class_name); |
| 1154 | - unset(self::$_settings[ $addon_name ]); |
|
| 1154 | + unset(self::$_settings[$addon_name]); |
|
| 1155 | 1155 | do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name); |
| 1156 | 1156 | } |
| 1157 | 1157 | } |
@@ -18,16 +18,16 @@ |
||
| 18 | 18 | interface RequiresDomainInterface |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param DomainInterface $domain |
|
| 23 | - */ |
|
| 24 | - public function setDomain(DomainInterface $domain); |
|
| 21 | + /** |
|
| 22 | + * @param DomainInterface $domain |
|
| 23 | + */ |
|
| 24 | + public function setDomain(DomainInterface $domain); |
|
| 25 | 25 | |
| 26 | 26 | |
| 27 | - /** |
|
| 28 | - * @return DomainInterface |
|
| 29 | - */ |
|
| 30 | - public function domain(); |
|
| 27 | + /** |
|
| 28 | + * @return DomainInterface |
|
| 29 | + */ |
|
| 30 | + public function domain(); |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | // Location: RequiresDomainInterface.php |