@@ -28,332 +28,332 @@ |
||
| 28 | 28 | class PersistentAdminNotice implements RequiresCapCheckInterface |
| 29 | 29 | { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string $name |
|
| 33 | - */ |
|
| 34 | - protected $name = ''; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * @var string $message |
|
| 38 | - */ |
|
| 39 | - protected $message = ''; |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @var boolean $force_update |
|
| 43 | - */ |
|
| 44 | - protected $force_update = false; |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * @var string $capability |
|
| 48 | - */ |
|
| 49 | - protected $capability = 'manage_options'; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @var string $cap_context |
|
| 53 | - */ |
|
| 54 | - protected $cap_context = 'view persistent admin notice'; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * @var boolean $dismissed |
|
| 58 | - */ |
|
| 59 | - protected $dismissed = false; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * @var CapCheckInterface $cap_check |
|
| 63 | - */ |
|
| 64 | - protected $cap_check; |
|
| 65 | - |
|
| 66 | - /** |
|
| 67 | - * if true, then this notice will be deleted from the database |
|
| 68 | - * |
|
| 69 | - * @var boolean $purge |
|
| 70 | - */ |
|
| 71 | - protected $purge = false; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager |
|
| 75 | - * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer |
|
| 76 | - * |
|
| 77 | - * @var boolean $registered |
|
| 78 | - */ |
|
| 79 | - private $registered = false; |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * PersistentAdminNotice constructor |
|
| 85 | - * |
|
| 86 | - * @param string $name [required] the name, or key of the Persistent Admin Notice to be stored |
|
| 87 | - * @param string $message [required] the message to be stored persistently until dismissed |
|
| 88 | - * @param bool $force_update enforce the reappearance of a persistent message |
|
| 89 | - * @param string $capability user capability required to view this notice |
|
| 90 | - * @param string $cap_context description for why the cap check is being performed |
|
| 91 | - * @param bool $dismissed whether or not the user has already dismissed/viewed this notice |
|
| 92 | - * @throws InvalidDataTypeException |
|
| 93 | - */ |
|
| 94 | - public function __construct( |
|
| 95 | - $name, |
|
| 96 | - $message, |
|
| 97 | - $force_update = false, |
|
| 98 | - $capability = 'manage_options', |
|
| 99 | - $cap_context = 'view persistent admin notice', |
|
| 100 | - $dismissed = false |
|
| 101 | - ) { |
|
| 102 | - $this->setName($name); |
|
| 103 | - $this->setMessage($message); |
|
| 104 | - $this->setForceUpdate($force_update); |
|
| 105 | - $this->setCapability($capability); |
|
| 106 | - $this->setCapContext($cap_context); |
|
| 107 | - $this->setDismissed($dismissed); |
|
| 108 | - add_action( |
|
| 109 | - 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
| 110 | - array($this, 'registerPersistentAdminNotice') |
|
| 111 | - ); |
|
| 112 | - add_action('shutdown', array($this, 'confirmRegistered'), 999); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @return string |
|
| 119 | - */ |
|
| 120 | - public function getName() |
|
| 121 | - { |
|
| 122 | - return $this->name; |
|
| 123 | - } |
|
| 124 | - |
|
| 125 | - |
|
| 126 | - |
|
| 127 | - /** |
|
| 128 | - * @param string $name |
|
| 129 | - * @throws InvalidDataTypeException |
|
| 130 | - */ |
|
| 131 | - private function setName($name) |
|
| 132 | - { |
|
| 133 | - if (! is_string($name)) { |
|
| 134 | - throw new InvalidDataTypeException('$name', $name, 'string'); |
|
| 135 | - } |
|
| 136 | - $this->name = sanitize_key($name); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - |
|
| 140 | - |
|
| 141 | - /** |
|
| 142 | - * @return string |
|
| 143 | - */ |
|
| 144 | - public function getMessage() |
|
| 145 | - { |
|
| 146 | - return $this->message; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * @param string $message |
|
| 153 | - * @throws InvalidDataTypeException |
|
| 154 | - */ |
|
| 155 | - private function setMessage($message) |
|
| 156 | - { |
|
| 157 | - if (! is_string($message)) { |
|
| 158 | - throw new InvalidDataTypeException('$message', $message, 'string'); |
|
| 159 | - } |
|
| 160 | - global $allowedtags; |
|
| 161 | - $allowedtags['br'] = array(); |
|
| 162 | - $this->message = wp_kses($message, $allowedtags); |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * @return bool |
|
| 169 | - */ |
|
| 170 | - public function getForceUpdate() |
|
| 171 | - { |
|
| 172 | - return $this->force_update; |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * @param bool $force_update |
|
| 179 | - */ |
|
| 180 | - private function setForceUpdate($force_update) |
|
| 181 | - { |
|
| 182 | - $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @return string |
|
| 189 | - */ |
|
| 190 | - public function getCapability() |
|
| 191 | - { |
|
| 192 | - return $this->capability; |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - /** |
|
| 198 | - * @param string $capability |
|
| 199 | - * @throws InvalidDataTypeException |
|
| 200 | - */ |
|
| 201 | - private function setCapability($capability) |
|
| 202 | - { |
|
| 203 | - if (! is_string($capability)) { |
|
| 204 | - throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
| 205 | - } |
|
| 206 | - $this->capability = ! empty($capability) ? $capability : 'manage_options'; |
|
| 207 | - } |
|
| 31 | + /** |
|
| 32 | + * @var string $name |
|
| 33 | + */ |
|
| 34 | + protected $name = ''; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * @var string $message |
|
| 38 | + */ |
|
| 39 | + protected $message = ''; |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @var boolean $force_update |
|
| 43 | + */ |
|
| 44 | + protected $force_update = false; |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * @var string $capability |
|
| 48 | + */ |
|
| 49 | + protected $capability = 'manage_options'; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @var string $cap_context |
|
| 53 | + */ |
|
| 54 | + protected $cap_context = 'view persistent admin notice'; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * @var boolean $dismissed |
|
| 58 | + */ |
|
| 59 | + protected $dismissed = false; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * @var CapCheckInterface $cap_check |
|
| 63 | + */ |
|
| 64 | + protected $cap_check; |
|
| 65 | + |
|
| 66 | + /** |
|
| 67 | + * if true, then this notice will be deleted from the database |
|
| 68 | + * |
|
| 69 | + * @var boolean $purge |
|
| 70 | + */ |
|
| 71 | + protected $purge = false; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * gets set to true if notice is successfully registered with the PersistentAdminNoticeManager |
|
| 75 | + * if false, and WP_DEBUG is on, then an exception will be thrown in the admin footer |
|
| 76 | + * |
|
| 77 | + * @var boolean $registered |
|
| 78 | + */ |
|
| 79 | + private $registered = false; |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * PersistentAdminNotice constructor |
|
| 85 | + * |
|
| 86 | + * @param string $name [required] the name, or key of the Persistent Admin Notice to be stored |
|
| 87 | + * @param string $message [required] the message to be stored persistently until dismissed |
|
| 88 | + * @param bool $force_update enforce the reappearance of a persistent message |
|
| 89 | + * @param string $capability user capability required to view this notice |
|
| 90 | + * @param string $cap_context description for why the cap check is being performed |
|
| 91 | + * @param bool $dismissed whether or not the user has already dismissed/viewed this notice |
|
| 92 | + * @throws InvalidDataTypeException |
|
| 93 | + */ |
|
| 94 | + public function __construct( |
|
| 95 | + $name, |
|
| 96 | + $message, |
|
| 97 | + $force_update = false, |
|
| 98 | + $capability = 'manage_options', |
|
| 99 | + $cap_context = 'view persistent admin notice', |
|
| 100 | + $dismissed = false |
|
| 101 | + ) { |
|
| 102 | + $this->setName($name); |
|
| 103 | + $this->setMessage($message); |
|
| 104 | + $this->setForceUpdate($force_update); |
|
| 105 | + $this->setCapability($capability); |
|
| 106 | + $this->setCapContext($cap_context); |
|
| 107 | + $this->setDismissed($dismissed); |
|
| 108 | + add_action( |
|
| 109 | + 'AHEE__EventEspresso_core_services_notifications_PersistentAdminNoticeManager__registerNotices', |
|
| 110 | + array($this, 'registerPersistentAdminNotice') |
|
| 111 | + ); |
|
| 112 | + add_action('shutdown', array($this, 'confirmRegistered'), 999); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @return string |
|
| 119 | + */ |
|
| 120 | + public function getName() |
|
| 121 | + { |
|
| 122 | + return $this->name; |
|
| 123 | + } |
|
| 124 | + |
|
| 125 | + |
|
| 126 | + |
|
| 127 | + /** |
|
| 128 | + * @param string $name |
|
| 129 | + * @throws InvalidDataTypeException |
|
| 130 | + */ |
|
| 131 | + private function setName($name) |
|
| 132 | + { |
|
| 133 | + if (! is_string($name)) { |
|
| 134 | + throw new InvalidDataTypeException('$name', $name, 'string'); |
|
| 135 | + } |
|
| 136 | + $this->name = sanitize_key($name); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + |
|
| 140 | + |
|
| 141 | + /** |
|
| 142 | + * @return string |
|
| 143 | + */ |
|
| 144 | + public function getMessage() |
|
| 145 | + { |
|
| 146 | + return $this->message; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * @param string $message |
|
| 153 | + * @throws InvalidDataTypeException |
|
| 154 | + */ |
|
| 155 | + private function setMessage($message) |
|
| 156 | + { |
|
| 157 | + if (! is_string($message)) { |
|
| 158 | + throw new InvalidDataTypeException('$message', $message, 'string'); |
|
| 159 | + } |
|
| 160 | + global $allowedtags; |
|
| 161 | + $allowedtags['br'] = array(); |
|
| 162 | + $this->message = wp_kses($message, $allowedtags); |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * @return bool |
|
| 169 | + */ |
|
| 170 | + public function getForceUpdate() |
|
| 171 | + { |
|
| 172 | + return $this->force_update; |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * @param bool $force_update |
|
| 179 | + */ |
|
| 180 | + private function setForceUpdate($force_update) |
|
| 181 | + { |
|
| 182 | + $this->force_update = filter_var($force_update, FILTER_VALIDATE_BOOLEAN); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @return string |
|
| 189 | + */ |
|
| 190 | + public function getCapability() |
|
| 191 | + { |
|
| 192 | + return $this->capability; |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + /** |
|
| 198 | + * @param string $capability |
|
| 199 | + * @throws InvalidDataTypeException |
|
| 200 | + */ |
|
| 201 | + private function setCapability($capability) |
|
| 202 | + { |
|
| 203 | + if (! is_string($capability)) { |
|
| 204 | + throw new InvalidDataTypeException('$capability', $capability, 'string'); |
|
| 205 | + } |
|
| 206 | + $this->capability = ! empty($capability) ? $capability : 'manage_options'; |
|
| 207 | + } |
|
| 208 | 208 | |
| 209 | 209 | |
| 210 | 210 | |
| 211 | - /** |
|
| 212 | - * @return string |
|
| 213 | - */ |
|
| 214 | - public function getCapContext() |
|
| 215 | - { |
|
| 216 | - return $this->cap_context; |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - |
|
| 221 | - /** |
|
| 222 | - * @param string $cap_context |
|
| 223 | - * @throws InvalidDataTypeException |
|
| 224 | - */ |
|
| 225 | - private function setCapContext($cap_context) |
|
| 226 | - { |
|
| 227 | - if (! is_string($cap_context)) { |
|
| 228 | - throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
|
| 229 | - } |
|
| 230 | - $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice'; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @return bool |
|
| 237 | - */ |
|
| 238 | - public function getDismissed() |
|
| 239 | - { |
|
| 240 | - return $this->dismissed; |
|
| 241 | - } |
|
| 242 | - |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @param bool $dismissed |
|
| 247 | - */ |
|
| 248 | - public function setDismissed($dismissed) |
|
| 249 | - { |
|
| 250 | - $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN); |
|
| 251 | - } |
|
| 252 | - |
|
| 253 | - |
|
| 254 | - |
|
| 255 | - /** |
|
| 256 | - * @return CapCheckInterface |
|
| 257 | - * @throws InvalidDataTypeException |
|
| 258 | - */ |
|
| 259 | - public function getCapCheck() |
|
| 260 | - { |
|
| 261 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
| 262 | - $this->setCapCheck( |
|
| 263 | - new CapCheck( |
|
| 264 | - $this->capability, |
|
| 265 | - $this->cap_context |
|
| 266 | - ) |
|
| 267 | - ); |
|
| 268 | - } |
|
| 269 | - return $this->cap_check; |
|
| 270 | - } |
|
| 271 | - |
|
| 272 | - |
|
| 273 | - |
|
| 274 | - /** |
|
| 275 | - * @param CapCheckInterface $cap_check |
|
| 276 | - */ |
|
| 277 | - private function setCapCheck(CapCheckInterface $cap_check) |
|
| 278 | - { |
|
| 279 | - $this->cap_check = $cap_check; |
|
| 280 | - } |
|
| 281 | - |
|
| 282 | - |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * @return bool |
|
| 286 | - */ |
|
| 287 | - public function getPurge() |
|
| 288 | - { |
|
| 289 | - return $this->purge; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * @param bool $purge |
|
| 296 | - */ |
|
| 297 | - public function setPurge($purge) |
|
| 298 | - { |
|
| 299 | - $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN); |
|
| 300 | - } |
|
| 301 | - |
|
| 302 | - |
|
| 303 | - |
|
| 304 | - /** |
|
| 305 | - * given a valid PersistentAdminNotice Collection, |
|
| 306 | - * this notice will be added if it is not already found in the collection (using its name as the identifier) |
|
| 307 | - * if an existing notice is found that has already been dismissed, |
|
| 308 | - * but we are overriding with a forced update, then we will toggle its dismissed state, |
|
| 309 | - * so that the notice is displayed again |
|
| 310 | - * |
|
| 311 | - * @param Collection $persistent_admin_notice_collection |
|
| 312 | - * @throws InvalidEntityException |
|
| 313 | - */ |
|
| 314 | - public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection) |
|
| 315 | - { |
|
| 316 | - if ($this->registered) { |
|
| 317 | - return; |
|
| 318 | - } |
|
| 319 | - // first check if this notice has already been added to the collection |
|
| 320 | - if ($persistent_admin_notice_collection->has($this->name)) { |
|
| 321 | - /** @var PersistentAdminNotice $existing */ |
|
| 322 | - $existing = $persistent_admin_notice_collection->get($this->name); |
|
| 323 | - // we don't need to add it again (we can't actually) |
|
| 324 | - // but if it has already been dismissed, and we are overriding with a forced update |
|
| 325 | - if ($existing->getDismissed() && $this->getForceUpdate()) { |
|
| 326 | - // then toggle the notice's dismissed state to true |
|
| 327 | - // so that it gets displayed again |
|
| 328 | - $existing->setDismissed(false); |
|
| 329 | - // and make sure the message is set |
|
| 330 | - $existing->setMessage($this->message); |
|
| 331 | - } |
|
| 332 | - } else { |
|
| 333 | - $persistent_admin_notice_collection->add($this, $this->name); |
|
| 334 | - } |
|
| 335 | - $this->registered = true; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - |
|
| 340 | - /** |
|
| 341 | - * @throws Exception |
|
| 342 | - */ |
|
| 343 | - public function confirmRegistered() |
|
| 344 | - { |
|
| 345 | - if (! $this->registered && WP_DEBUG) { |
|
| 346 | - throw new DomainException( |
|
| 347 | - sprintf( |
|
| 348 | - esc_html__( |
|
| 349 | - 'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.', |
|
| 350 | - 'event_espresso' |
|
| 351 | - ), |
|
| 352 | - $this->name |
|
| 353 | - ) |
|
| 354 | - ); |
|
| 355 | - } |
|
| 356 | - } |
|
| 211 | + /** |
|
| 212 | + * @return string |
|
| 213 | + */ |
|
| 214 | + public function getCapContext() |
|
| 215 | + { |
|
| 216 | + return $this->cap_context; |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + |
|
| 221 | + /** |
|
| 222 | + * @param string $cap_context |
|
| 223 | + * @throws InvalidDataTypeException |
|
| 224 | + */ |
|
| 225 | + private function setCapContext($cap_context) |
|
| 226 | + { |
|
| 227 | + if (! is_string($cap_context)) { |
|
| 228 | + throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
|
| 229 | + } |
|
| 230 | + $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice'; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @return bool |
|
| 237 | + */ |
|
| 238 | + public function getDismissed() |
|
| 239 | + { |
|
| 240 | + return $this->dismissed; |
|
| 241 | + } |
|
| 242 | + |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @param bool $dismissed |
|
| 247 | + */ |
|
| 248 | + public function setDismissed($dismissed) |
|
| 249 | + { |
|
| 250 | + $this->dismissed = filter_var($dismissed, FILTER_VALIDATE_BOOLEAN); |
|
| 251 | + } |
|
| 252 | + |
|
| 253 | + |
|
| 254 | + |
|
| 255 | + /** |
|
| 256 | + * @return CapCheckInterface |
|
| 257 | + * @throws InvalidDataTypeException |
|
| 258 | + */ |
|
| 259 | + public function getCapCheck() |
|
| 260 | + { |
|
| 261 | + if (! $this->cap_check instanceof CapCheckInterface) { |
|
| 262 | + $this->setCapCheck( |
|
| 263 | + new CapCheck( |
|
| 264 | + $this->capability, |
|
| 265 | + $this->cap_context |
|
| 266 | + ) |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | + return $this->cap_check; |
|
| 270 | + } |
|
| 271 | + |
|
| 272 | + |
|
| 273 | + |
|
| 274 | + /** |
|
| 275 | + * @param CapCheckInterface $cap_check |
|
| 276 | + */ |
|
| 277 | + private function setCapCheck(CapCheckInterface $cap_check) |
|
| 278 | + { |
|
| 279 | + $this->cap_check = $cap_check; |
|
| 280 | + } |
|
| 281 | + |
|
| 282 | + |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * @return bool |
|
| 286 | + */ |
|
| 287 | + public function getPurge() |
|
| 288 | + { |
|
| 289 | + return $this->purge; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * @param bool $purge |
|
| 296 | + */ |
|
| 297 | + public function setPurge($purge) |
|
| 298 | + { |
|
| 299 | + $this->purge = filter_var($purge, FILTER_VALIDATE_BOOLEAN); |
|
| 300 | + } |
|
| 301 | + |
|
| 302 | + |
|
| 303 | + |
|
| 304 | + /** |
|
| 305 | + * given a valid PersistentAdminNotice Collection, |
|
| 306 | + * this notice will be added if it is not already found in the collection (using its name as the identifier) |
|
| 307 | + * if an existing notice is found that has already been dismissed, |
|
| 308 | + * but we are overriding with a forced update, then we will toggle its dismissed state, |
|
| 309 | + * so that the notice is displayed again |
|
| 310 | + * |
|
| 311 | + * @param Collection $persistent_admin_notice_collection |
|
| 312 | + * @throws InvalidEntityException |
|
| 313 | + */ |
|
| 314 | + public function registerPersistentAdminNotice(Collection $persistent_admin_notice_collection) |
|
| 315 | + { |
|
| 316 | + if ($this->registered) { |
|
| 317 | + return; |
|
| 318 | + } |
|
| 319 | + // first check if this notice has already been added to the collection |
|
| 320 | + if ($persistent_admin_notice_collection->has($this->name)) { |
|
| 321 | + /** @var PersistentAdminNotice $existing */ |
|
| 322 | + $existing = $persistent_admin_notice_collection->get($this->name); |
|
| 323 | + // we don't need to add it again (we can't actually) |
|
| 324 | + // but if it has already been dismissed, and we are overriding with a forced update |
|
| 325 | + if ($existing->getDismissed() && $this->getForceUpdate()) { |
|
| 326 | + // then toggle the notice's dismissed state to true |
|
| 327 | + // so that it gets displayed again |
|
| 328 | + $existing->setDismissed(false); |
|
| 329 | + // and make sure the message is set |
|
| 330 | + $existing->setMessage($this->message); |
|
| 331 | + } |
|
| 332 | + } else { |
|
| 333 | + $persistent_admin_notice_collection->add($this, $this->name); |
|
| 334 | + } |
|
| 335 | + $this->registered = true; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + |
|
| 340 | + /** |
|
| 341 | + * @throws Exception |
|
| 342 | + */ |
|
| 343 | + public function confirmRegistered() |
|
| 344 | + { |
|
| 345 | + if (! $this->registered && WP_DEBUG) { |
|
| 346 | + throw new DomainException( |
|
| 347 | + sprintf( |
|
| 348 | + esc_html__( |
|
| 349 | + 'The "%1$s" PersistentAdminNotice was not successfully registered. Please ensure that it is being created prior to either the "admin_notices" or "network_admin_notices" hooks being triggered.', |
|
| 350 | + 'event_espresso' |
|
| 351 | + ), |
|
| 352 | + $this->name |
|
| 353 | + ) |
|
| 354 | + ); |
|
| 355 | + } |
|
| 356 | + } |
|
| 357 | 357 | |
| 358 | 358 | |
| 359 | 359 | } |
@@ -130,7 +130,7 @@ discard block |
||
| 130 | 130 | */ |
| 131 | 131 | private function setName($name) |
| 132 | 132 | { |
| 133 | - if (! is_string($name)) { |
|
| 133 | + if ( ! is_string($name)) { |
|
| 134 | 134 | throw new InvalidDataTypeException('$name', $name, 'string'); |
| 135 | 135 | } |
| 136 | 136 | $this->name = sanitize_key($name); |
@@ -154,7 +154,7 @@ discard block |
||
| 154 | 154 | */ |
| 155 | 155 | private function setMessage($message) |
| 156 | 156 | { |
| 157 | - if (! is_string($message)) { |
|
| 157 | + if ( ! is_string($message)) { |
|
| 158 | 158 | throw new InvalidDataTypeException('$message', $message, 'string'); |
| 159 | 159 | } |
| 160 | 160 | global $allowedtags; |
@@ -200,7 +200,7 @@ discard block |
||
| 200 | 200 | */ |
| 201 | 201 | private function setCapability($capability) |
| 202 | 202 | { |
| 203 | - if (! is_string($capability)) { |
|
| 203 | + if ( ! is_string($capability)) { |
|
| 204 | 204 | throw new InvalidDataTypeException('$capability', $capability, 'string'); |
| 205 | 205 | } |
| 206 | 206 | $this->capability = ! empty($capability) ? $capability : 'manage_options'; |
@@ -224,7 +224,7 @@ discard block |
||
| 224 | 224 | */ |
| 225 | 225 | private function setCapContext($cap_context) |
| 226 | 226 | { |
| 227 | - if (! is_string($cap_context)) { |
|
| 227 | + if ( ! is_string($cap_context)) { |
|
| 228 | 228 | throw new InvalidDataTypeException('$cap_context', $cap_context, 'string'); |
| 229 | 229 | } |
| 230 | 230 | $this->cap_context = ! empty($cap_context) ? $cap_context : 'view persistent admin notice'; |
@@ -258,7 +258,7 @@ discard block |
||
| 258 | 258 | */ |
| 259 | 259 | public function getCapCheck() |
| 260 | 260 | { |
| 261 | - if (! $this->cap_check instanceof CapCheckInterface) { |
|
| 261 | + if ( ! $this->cap_check instanceof CapCheckInterface) { |
|
| 262 | 262 | $this->setCapCheck( |
| 263 | 263 | new CapCheck( |
| 264 | 264 | $this->capability, |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | */ |
| 343 | 343 | public function confirmRegistered() |
| 344 | 344 | { |
| 345 | - if (! $this->registered && WP_DEBUG) { |
|
| 345 | + if ( ! $this->registered && WP_DEBUG) { |
|
| 346 | 346 | throw new DomainException( |
| 347 | 347 | sprintf( |
| 348 | 348 | esc_html__( |
@@ -38,216 +38,216 @@ |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | - /** |
|
| 43 | - * espresso_duplicate_plugin_error |
|
| 44 | - * displays if more than one version of EE is activated at the same time |
|
| 45 | - */ |
|
| 46 | - function espresso_duplicate_plugin_error() |
|
| 47 | - { |
|
| 48 | - ?> |
|
| 41 | + if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | + /** |
|
| 43 | + * espresso_duplicate_plugin_error |
|
| 44 | + * displays if more than one version of EE is activated at the same time |
|
| 45 | + */ |
|
| 46 | + function espresso_duplicate_plugin_error() |
|
| 47 | + { |
|
| 48 | + ?> |
|
| 49 | 49 | <div class="error"> |
| 50 | 50 | <p> |
| 51 | 51 | <?php |
| 52 | - echo esc_html__( |
|
| 53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | - 'event_espresso' |
|
| 55 | - ); ?> |
|
| 52 | + echo esc_html__( |
|
| 53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
| 54 | + 'event_espresso' |
|
| 55 | + ); ?> |
|
| 56 | 56 | </p> |
| 57 | 57 | </div> |
| 58 | 58 | <?php |
| 59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | - } |
|
| 61 | - } |
|
| 62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 60 | + } |
|
| 61 | + } |
|
| 62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
| 63 | 63 | |
| 64 | 64 | } else { |
| 65 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | - /** |
|
| 68 | - * espresso_minimum_php_version_error |
|
| 69 | - * @return void |
|
| 70 | - */ |
|
| 71 | - function espresso_minimum_php_version_error() |
|
| 72 | - { |
|
| 73 | - ?> |
|
| 65 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
| 66 | + if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | + /** |
|
| 68 | + * espresso_minimum_php_version_error |
|
| 69 | + * @return void |
|
| 70 | + */ |
|
| 71 | + function espresso_minimum_php_version_error() |
|
| 72 | + { |
|
| 73 | + ?> |
|
| 74 | 74 | <div class="error"> |
| 75 | 75 | <p> |
| 76 | 76 | <?php |
| 77 | - printf( |
|
| 78 | - esc_html__( |
|
| 79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | - 'event_espresso' |
|
| 81 | - ), |
|
| 82 | - EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | - PHP_VERSION, |
|
| 84 | - '<br/>', |
|
| 85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | - ); |
|
| 87 | - ?> |
|
| 77 | + printf( |
|
| 78 | + esc_html__( |
|
| 79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
| 80 | + 'event_espresso' |
|
| 81 | + ), |
|
| 82 | + EE_MIN_PHP_VER_REQUIRED, |
|
| 83 | + PHP_VERSION, |
|
| 84 | + '<br/>', |
|
| 85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
| 86 | + ); |
|
| 87 | + ?> |
|
| 88 | 88 | </p> |
| 89 | 89 | </div> |
| 90 | 90 | <?php |
| 91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | - } |
|
| 91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | - } else { |
|
| 96 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | - /** |
|
| 98 | - * espresso_version |
|
| 99 | - * Returns the plugin version |
|
| 100 | - * |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - function espresso_version() |
|
| 104 | - { |
|
| 105 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.54.rc.021'); |
|
| 106 | - } |
|
| 94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
| 95 | + } else { |
|
| 96 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
| 97 | + /** |
|
| 98 | + * espresso_version |
|
| 99 | + * Returns the plugin version |
|
| 100 | + * |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + function espresso_version() |
|
| 104 | + { |
|
| 105 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.54.rc.021'); |
|
| 106 | + } |
|
| 107 | 107 | |
| 108 | - /** |
|
| 109 | - * espresso_plugin_activation |
|
| 110 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | - */ |
|
| 112 | - function espresso_plugin_activation() |
|
| 113 | - { |
|
| 114 | - update_option('ee_espresso_activation', true); |
|
| 115 | - } |
|
| 108 | + /** |
|
| 109 | + * espresso_plugin_activation |
|
| 110 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
| 111 | + */ |
|
| 112 | + function espresso_plugin_activation() |
|
| 113 | + { |
|
| 114 | + update_option('ee_espresso_activation', true); |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | - /** |
|
| 119 | - * espresso_load_error_handling |
|
| 120 | - * this function loads EE's class for handling exceptions and errors |
|
| 121 | - */ |
|
| 122 | - function espresso_load_error_handling() |
|
| 123 | - { |
|
| 124 | - static $error_handling_loaded = false; |
|
| 125 | - if ($error_handling_loaded) { |
|
| 126 | - return; |
|
| 127 | - } |
|
| 128 | - // load debugging tools |
|
| 129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 131 | - \EEH_Debug_Tools::instance(); |
|
| 132 | - } |
|
| 133 | - // load error handling |
|
| 134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
| 136 | - } else { |
|
| 137 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 138 | - } |
|
| 139 | - $error_handling_loaded = true; |
|
| 140 | - } |
|
| 117 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
| 118 | + /** |
|
| 119 | + * espresso_load_error_handling |
|
| 120 | + * this function loads EE's class for handling exceptions and errors |
|
| 121 | + */ |
|
| 122 | + function espresso_load_error_handling() |
|
| 123 | + { |
|
| 124 | + static $error_handling_loaded = false; |
|
| 125 | + if ($error_handling_loaded) { |
|
| 126 | + return; |
|
| 127 | + } |
|
| 128 | + // load debugging tools |
|
| 129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 130 | + require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 131 | + \EEH_Debug_Tools::instance(); |
|
| 132 | + } |
|
| 133 | + // load error handling |
|
| 134 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 135 | + require_once EE_CORE . 'EE_Error.core.php'; |
|
| 136 | + } else { |
|
| 137 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
| 138 | + } |
|
| 139 | + $error_handling_loaded = true; |
|
| 140 | + } |
|
| 141 | 141 | |
| 142 | - /** |
|
| 143 | - * espresso_load_required |
|
| 144 | - * given a class name and path, this function will load that file or throw an exception |
|
| 145 | - * |
|
| 146 | - * @param string $classname |
|
| 147 | - * @param string $full_path_to_file |
|
| 148 | - * @throws EE_Error |
|
| 149 | - */ |
|
| 150 | - function espresso_load_required($classname, $full_path_to_file) |
|
| 151 | - { |
|
| 152 | - if (is_readable($full_path_to_file)) { |
|
| 153 | - require_once $full_path_to_file; |
|
| 154 | - } else { |
|
| 155 | - throw new \EE_Error ( |
|
| 156 | - sprintf( |
|
| 157 | - esc_html__( |
|
| 158 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 159 | - 'event_espresso' |
|
| 160 | - ), |
|
| 161 | - $classname |
|
| 162 | - ) |
|
| 163 | - ); |
|
| 164 | - } |
|
| 165 | - } |
|
| 142 | + /** |
|
| 143 | + * espresso_load_required |
|
| 144 | + * given a class name and path, this function will load that file or throw an exception |
|
| 145 | + * |
|
| 146 | + * @param string $classname |
|
| 147 | + * @param string $full_path_to_file |
|
| 148 | + * @throws EE_Error |
|
| 149 | + */ |
|
| 150 | + function espresso_load_required($classname, $full_path_to_file) |
|
| 151 | + { |
|
| 152 | + if (is_readable($full_path_to_file)) { |
|
| 153 | + require_once $full_path_to_file; |
|
| 154 | + } else { |
|
| 155 | + throw new \EE_Error ( |
|
| 156 | + sprintf( |
|
| 157 | + esc_html__( |
|
| 158 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
| 159 | + 'event_espresso' |
|
| 160 | + ), |
|
| 161 | + $classname |
|
| 162 | + ) |
|
| 163 | + ); |
|
| 164 | + } |
|
| 165 | + } |
|
| 166 | 166 | |
| 167 | - /** |
|
| 168 | - * @since 4.9.27 |
|
| 169 | - * @throws \EE_Error |
|
| 170 | - * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 171 | - * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 172 | - * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 173 | - * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 174 | - * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 175 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
| 176 | - * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
| 177 | - * @throws \OutOfBoundsException |
|
| 178 | - */ |
|
| 179 | - function bootstrap_espresso() |
|
| 180 | - { |
|
| 181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 182 | - try { |
|
| 183 | - espresso_load_error_handling(); |
|
| 184 | - espresso_load_required( |
|
| 185 | - 'EEH_Base', |
|
| 186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 187 | - ); |
|
| 188 | - espresso_load_required( |
|
| 189 | - 'EEH_File', |
|
| 190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 191 | - ); |
|
| 192 | - espresso_load_required( |
|
| 193 | - 'EEH_File', |
|
| 194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 195 | - ); |
|
| 196 | - espresso_load_required( |
|
| 197 | - 'EEH_Array', |
|
| 198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 199 | - ); |
|
| 200 | - // instantiate and configure PSR4 autoloader |
|
| 201 | - espresso_load_required( |
|
| 202 | - 'Psr4Autoloader', |
|
| 203 | - EE_CORE . 'Psr4Autoloader.php' |
|
| 204 | - ); |
|
| 205 | - espresso_load_required( |
|
| 206 | - 'EE_Psr4AutoloaderInit', |
|
| 207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 208 | - ); |
|
| 209 | - $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
| 210 | - $AutoloaderInit->initializeAutoloader(); |
|
| 211 | - espresso_load_required( |
|
| 212 | - 'EE_Request', |
|
| 213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 214 | - ); |
|
| 215 | - espresso_load_required( |
|
| 216 | - 'EE_Response', |
|
| 217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 218 | - ); |
|
| 219 | - espresso_load_required( |
|
| 220 | - 'EE_Bootstrap', |
|
| 221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
| 222 | - ); |
|
| 223 | - // bootstrap EE and the request stack |
|
| 224 | - new EE_Bootstrap( |
|
| 225 | - new EE_Request($_GET, $_POST, $_COOKIE), |
|
| 226 | - new EE_Response() |
|
| 227 | - ); |
|
| 228 | - } catch (Exception $e) { |
|
| 229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 230 | - new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - bootstrap_espresso(); |
|
| 234 | - } |
|
| 167 | + /** |
|
| 168 | + * @since 4.9.27 |
|
| 169 | + * @throws \EE_Error |
|
| 170 | + * @throws \EventEspresso\core\exceptions\InvalidInterfaceException |
|
| 171 | + * @throws \EventEspresso\core\exceptions\InvalidEntityException |
|
| 172 | + * @throws \EventEspresso\core\exceptions\InvalidIdentifierException |
|
| 173 | + * @throws \EventEspresso\core\exceptions\InvalidClassException |
|
| 174 | + * @throws \EventEspresso\core\exceptions\InvalidDataTypeException |
|
| 175 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException |
|
| 176 | + * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException |
|
| 177 | + * @throws \OutOfBoundsException |
|
| 178 | + */ |
|
| 179 | + function bootstrap_espresso() |
|
| 180 | + { |
|
| 181 | + require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 182 | + try { |
|
| 183 | + espresso_load_error_handling(); |
|
| 184 | + espresso_load_required( |
|
| 185 | + 'EEH_Base', |
|
| 186 | + EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 187 | + ); |
|
| 188 | + espresso_load_required( |
|
| 189 | + 'EEH_File', |
|
| 190 | + EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 191 | + ); |
|
| 192 | + espresso_load_required( |
|
| 193 | + 'EEH_File', |
|
| 194 | + EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 195 | + ); |
|
| 196 | + espresso_load_required( |
|
| 197 | + 'EEH_Array', |
|
| 198 | + EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 199 | + ); |
|
| 200 | + // instantiate and configure PSR4 autoloader |
|
| 201 | + espresso_load_required( |
|
| 202 | + 'Psr4Autoloader', |
|
| 203 | + EE_CORE . 'Psr4Autoloader.php' |
|
| 204 | + ); |
|
| 205 | + espresso_load_required( |
|
| 206 | + 'EE_Psr4AutoloaderInit', |
|
| 207 | + EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 208 | + ); |
|
| 209 | + $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
|
| 210 | + $AutoloaderInit->initializeAutoloader(); |
|
| 211 | + espresso_load_required( |
|
| 212 | + 'EE_Request', |
|
| 213 | + EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 214 | + ); |
|
| 215 | + espresso_load_required( |
|
| 216 | + 'EE_Response', |
|
| 217 | + EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 218 | + ); |
|
| 219 | + espresso_load_required( |
|
| 220 | + 'EE_Bootstrap', |
|
| 221 | + EE_CORE . 'EE_Bootstrap.core.php' |
|
| 222 | + ); |
|
| 223 | + // bootstrap EE and the request stack |
|
| 224 | + new EE_Bootstrap( |
|
| 225 | + new EE_Request($_GET, $_POST, $_COOKIE), |
|
| 226 | + new EE_Response() |
|
| 227 | + ); |
|
| 228 | + } catch (Exception $e) { |
|
| 229 | + require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 230 | + new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + bootstrap_espresso(); |
|
| 234 | + } |
|
| 235 | 235 | } |
| 236 | 236 | if (! function_exists('espresso_deactivate_plugin')) { |
| 237 | - /** |
|
| 238 | - * deactivate_plugin |
|
| 239 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 240 | - * |
|
| 241 | - * @access public |
|
| 242 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 243 | - * @return void |
|
| 244 | - */ |
|
| 245 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
| 246 | - { |
|
| 247 | - if (! function_exists('deactivate_plugins')) { |
|
| 248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 249 | - } |
|
| 250 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
| 251 | - deactivate_plugins($plugin_basename); |
|
| 252 | - } |
|
| 237 | + /** |
|
| 238 | + * deactivate_plugin |
|
| 239 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
| 240 | + * |
|
| 241 | + * @access public |
|
| 242 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
| 243 | + * @return void |
|
| 244 | + */ |
|
| 245 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
| 246 | + { |
|
| 247 | + if (! function_exists('deactivate_plugins')) { |
|
| 248 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 249 | + } |
|
| 250 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
| 251 | + deactivate_plugins($plugin_basename); |
|
| 252 | + } |
|
| 253 | 253 | } |
@@ -38,7 +38,7 @@ discard block |
||
| 38 | 38 | * @since 4.0 |
| 39 | 39 | */ |
| 40 | 40 | if (function_exists('espresso_version')) { |
| 41 | - if (! function_exists('espresso_duplicate_plugin_error')) { |
|
| 41 | + if ( ! function_exists('espresso_duplicate_plugin_error')) { |
|
| 42 | 42 | /** |
| 43 | 43 | * espresso_duplicate_plugin_error |
| 44 | 44 | * displays if more than one version of EE is activated at the same time |
@@ -63,7 +63,7 @@ discard block |
||
| 63 | 63 | |
| 64 | 64 | } else { |
| 65 | 65 | define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
| 66 | - if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 66 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
| 67 | 67 | /** |
| 68 | 68 | * espresso_minimum_php_version_error |
| 69 | 69 | * @return void |
@@ -126,13 +126,13 @@ discard block |
||
| 126 | 126 | return; |
| 127 | 127 | } |
| 128 | 128 | // load debugging tools |
| 129 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
| 130 | - require_once EE_HELPERS . 'EEH_Debug_Tools.helper.php'; |
|
| 129 | + if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) { |
|
| 130 | + require_once EE_HELPERS.'EEH_Debug_Tools.helper.php'; |
|
| 131 | 131 | \EEH_Debug_Tools::instance(); |
| 132 | 132 | } |
| 133 | 133 | // load error handling |
| 134 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
| 135 | - require_once EE_CORE . 'EE_Error.core.php'; |
|
| 134 | + if (is_readable(EE_CORE.'EE_Error.core.php')) { |
|
| 135 | + require_once EE_CORE.'EE_Error.core.php'; |
|
| 136 | 136 | } else { |
| 137 | 137 | wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
| 138 | 138 | } |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | if (is_readable($full_path_to_file)) { |
| 153 | 153 | require_once $full_path_to_file; |
| 154 | 154 | } else { |
| 155 | - throw new \EE_Error ( |
|
| 155 | + throw new \EE_Error( |
|
| 156 | 156 | sprintf( |
| 157 | 157 | esc_html__( |
| 158 | 158 | 'The %s class file could not be located or is not readable due to file permissions.', |
@@ -178,47 +178,47 @@ discard block |
||
| 178 | 178 | */ |
| 179 | 179 | function bootstrap_espresso() |
| 180 | 180 | { |
| 181 | - require_once __DIR__ . '/core/espresso_definitions.php'; |
|
| 181 | + require_once __DIR__.'/core/espresso_definitions.php'; |
|
| 182 | 182 | try { |
| 183 | 183 | espresso_load_error_handling(); |
| 184 | 184 | espresso_load_required( |
| 185 | 185 | 'EEH_Base', |
| 186 | - EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' |
|
| 186 | + EE_CORE.'helpers'.DS.'EEH_Base.helper.php' |
|
| 187 | 187 | ); |
| 188 | 188 | espresso_load_required( |
| 189 | 189 | 'EEH_File', |
| 190 | - EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php' |
|
| 190 | + EE_CORE.'interfaces'.DS.'EEHI_File.interface.php' |
|
| 191 | 191 | ); |
| 192 | 192 | espresso_load_required( |
| 193 | 193 | 'EEH_File', |
| 194 | - EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' |
|
| 194 | + EE_CORE.'helpers'.DS.'EEH_File.helper.php' |
|
| 195 | 195 | ); |
| 196 | 196 | espresso_load_required( |
| 197 | 197 | 'EEH_Array', |
| 198 | - EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php' |
|
| 198 | + EE_CORE.'helpers'.DS.'EEH_Array.helper.php' |
|
| 199 | 199 | ); |
| 200 | 200 | // instantiate and configure PSR4 autoloader |
| 201 | 201 | espresso_load_required( |
| 202 | 202 | 'Psr4Autoloader', |
| 203 | - EE_CORE . 'Psr4Autoloader.php' |
|
| 203 | + EE_CORE.'Psr4Autoloader.php' |
|
| 204 | 204 | ); |
| 205 | 205 | espresso_load_required( |
| 206 | 206 | 'EE_Psr4AutoloaderInit', |
| 207 | - EE_CORE . 'EE_Psr4AutoloaderInit.core.php' |
|
| 207 | + EE_CORE.'EE_Psr4AutoloaderInit.core.php' |
|
| 208 | 208 | ); |
| 209 | 209 | $AutoloaderInit = new EE_Psr4AutoloaderInit(); |
| 210 | 210 | $AutoloaderInit->initializeAutoloader(); |
| 211 | 211 | espresso_load_required( |
| 212 | 212 | 'EE_Request', |
| 213 | - EE_CORE . 'request_stack' . DS . 'EE_Request.core.php' |
|
| 213 | + EE_CORE.'request_stack'.DS.'EE_Request.core.php' |
|
| 214 | 214 | ); |
| 215 | 215 | espresso_load_required( |
| 216 | 216 | 'EE_Response', |
| 217 | - EE_CORE . 'request_stack' . DS . 'EE_Response.core.php' |
|
| 217 | + EE_CORE.'request_stack'.DS.'EE_Response.core.php' |
|
| 218 | 218 | ); |
| 219 | 219 | espresso_load_required( |
| 220 | 220 | 'EE_Bootstrap', |
| 221 | - EE_CORE . 'EE_Bootstrap.core.php' |
|
| 221 | + EE_CORE.'EE_Bootstrap.core.php' |
|
| 222 | 222 | ); |
| 223 | 223 | // bootstrap EE and the request stack |
| 224 | 224 | new EE_Bootstrap( |
@@ -226,14 +226,14 @@ discard block |
||
| 226 | 226 | new EE_Response() |
| 227 | 227 | ); |
| 228 | 228 | } catch (Exception $e) { |
| 229 | - require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php'; |
|
| 229 | + require_once EE_CORE.'exceptions'.DS.'ExceptionStackTraceDisplay.php'; |
|
| 230 | 230 | new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e); |
| 231 | 231 | } |
| 232 | 232 | } |
| 233 | 233 | bootstrap_espresso(); |
| 234 | 234 | } |
| 235 | 235 | } |
| 236 | -if (! function_exists('espresso_deactivate_plugin')) { |
|
| 236 | +if ( ! function_exists('espresso_deactivate_plugin')) { |
|
| 237 | 237 | /** |
| 238 | 238 | * deactivate_plugin |
| 239 | 239 | * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
@@ -244,8 +244,8 @@ discard block |
||
| 244 | 244 | */ |
| 245 | 245 | function espresso_deactivate_plugin($plugin_basename = '') |
| 246 | 246 | { |
| 247 | - if (! function_exists('deactivate_plugins')) { |
|
| 248 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 247 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 248 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
| 249 | 249 | } |
| 250 | 250 | unset($_GET['activate'], $_REQUEST['activate']); |
| 251 | 251 | deactivate_plugins($plugin_basename); |