@@ -21,1188 +21,1188 @@ |
||
| 21 | 21 | { |
| 22 | 22 | |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
| 26 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
| 27 | - */ |
|
| 28 | - const req_type_normal = 0; |
|
| 29 | - |
|
| 30 | - /** |
|
| 31 | - * Indicates this is a brand new installation of EE so we should install |
|
| 32 | - * tables and default data etc |
|
| 33 | - */ |
|
| 34 | - const req_type_new_activation = 1; |
|
| 35 | - |
|
| 36 | - /** |
|
| 37 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
| 38 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
| 39 | - * and that default data is setup too |
|
| 40 | - */ |
|
| 41 | - const req_type_reactivation = 2; |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * indicates that EE has been upgraded since its previous request. |
|
| 45 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
| 46 | - */ |
|
| 47 | - const req_type_upgrade = 3; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
| 51 | - */ |
|
| 52 | - const req_type_downgrade = 4; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @deprecated since version 4.6.0.dev.006 |
|
| 56 | - * Now whenever a new_activation is detected the request type is still just |
|
| 57 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
| 58 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
| 59 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
| 60 | - * (Specifically, when the migration manager indicates migrations are finished |
|
| 61 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
| 62 | - */ |
|
| 63 | - const req_type_activation_but_not_installed = 5; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
| 67 | - */ |
|
| 68 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @var EE_System $_instance |
|
| 73 | - */ |
|
| 74 | - private static $_instance; |
|
| 75 | - |
|
| 76 | - /** |
|
| 77 | - * @var EE_Registry $registry |
|
| 78 | - */ |
|
| 79 | - private $registry; |
|
| 80 | - |
|
| 81 | - /** |
|
| 82 | - * @var LoaderInterface $loader |
|
| 83 | - */ |
|
| 84 | - private $loader; |
|
| 85 | - |
|
| 86 | - /** |
|
| 87 | - * @var EE_Capabilities $capabilities |
|
| 88 | - */ |
|
| 89 | - private $capabilities; |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * @var EE_Request $request |
|
| 93 | - */ |
|
| 94 | - private $request; |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
| 98 | - */ |
|
| 99 | - private $maintenance_mode; |
|
| 100 | - |
|
| 101 | - /** |
|
| 102 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
| 103 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
| 104 | - * |
|
| 105 | - * @var int $_req_type |
|
| 106 | - */ |
|
| 107 | - private $_req_type; |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
| 111 | - * |
|
| 112 | - * @var boolean $_major_version_change |
|
| 113 | - */ |
|
| 114 | - private $_major_version_change = false; |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * @singleton method used to instantiate class object |
|
| 120 | - * @param EE_Registry|null $registry |
|
| 121 | - * @param LoaderInterface|null $loader |
|
| 122 | - * @param EE_Capabilities|null $capabilities |
|
| 123 | - * @param EE_Request|null $request |
|
| 124 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
| 125 | - * @return EE_System |
|
| 126 | - */ |
|
| 127 | - public static function instance( |
|
| 128 | - EE_Registry $registry = null, |
|
| 129 | - LoaderInterface $loader = null, |
|
| 130 | - EE_Capabilities $capabilities = null, |
|
| 131 | - EE_Request $request = null, |
|
| 132 | - EE_Maintenance_Mode $maintenance_mode = null |
|
| 133 | - ) { |
|
| 134 | - // check if class object is instantiated |
|
| 135 | - if (! self::$_instance instanceof EE_System) { |
|
| 136 | - self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode); |
|
| 137 | - } |
|
| 138 | - return self::$_instance; |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - |
|
| 143 | - /** |
|
| 144 | - * resets the instance and returns it |
|
| 145 | - * |
|
| 146 | - * @return EE_System |
|
| 147 | - */ |
|
| 148 | - public static function reset() |
|
| 149 | - { |
|
| 150 | - self::$_instance->_req_type = null; |
|
| 151 | - //make sure none of the old hooks are left hanging around |
|
| 152 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 153 | - //we need to reset the migration manager in order for it to detect DMSs properly |
|
| 154 | - EE_Data_Migration_Manager::reset(); |
|
| 155 | - self::instance()->detect_activations_or_upgrades(); |
|
| 156 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
| 157 | - return self::instance(); |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * sets hooks for running rest of system |
|
| 164 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 165 | - * starting EE Addons from any other point may lead to problems |
|
| 166 | - * |
|
| 167 | - * @param EE_Registry $registry |
|
| 168 | - * @param LoaderInterface $loader |
|
| 169 | - * @param EE_Capabilities $capabilities |
|
| 170 | - * @param EE_Request $request |
|
| 171 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
| 172 | - */ |
|
| 173 | - private function __construct( |
|
| 174 | - EE_Registry $registry, |
|
| 175 | - LoaderInterface $loader, |
|
| 176 | - EE_Capabilities $capabilities, |
|
| 177 | - EE_Request $request, |
|
| 178 | - EE_Maintenance_Mode $maintenance_mode |
|
| 179 | - ) { |
|
| 180 | - $this->registry = $registry; |
|
| 181 | - $this->loader = $loader; |
|
| 182 | - $this->capabilities = $capabilities; |
|
| 183 | - $this->request = $request; |
|
| 184 | - $this->maintenance_mode = $maintenance_mode; |
|
| 185 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
| 186 | - add_action( |
|
| 187 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 188 | - array($this, 'loadCapabilities'), |
|
| 189 | - 5 |
|
| 190 | - ); |
|
| 191 | - add_action( |
|
| 192 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 193 | - array($this, 'loadCommandBus'), |
|
| 194 | - 7 |
|
| 195 | - ); |
|
| 196 | - add_action( |
|
| 197 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 198 | - array($this, 'loadPluginApi'), |
|
| 199 | - 9 |
|
| 200 | - ); |
|
| 201 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
| 202 | - add_action( |
|
| 203 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 204 | - array($this, 'load_espresso_addons') |
|
| 205 | - ); |
|
| 206 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
| 207 | - // because the newly-activated addon didn't get a chance to run at all |
|
| 208 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
| 209 | - // detect whether install or upgrade |
|
| 210 | - add_action( |
|
| 211 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
| 212 | - array($this, 'detect_activations_or_upgrades'), |
|
| 213 | - 3 |
|
| 214 | - ); |
|
| 215 | - // load EE_Config, EE_Textdomain, etc |
|
| 216 | - add_action( |
|
| 217 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 218 | - array($this, 'load_core_configuration'), |
|
| 219 | - 5 |
|
| 220 | - ); |
|
| 221 | - // load EE_Config, EE_Textdomain, etc |
|
| 222 | - add_action( |
|
| 223 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
| 224 | - array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 225 | - 7 |
|
| 226 | - ); |
|
| 227 | - // you wanna get going? I wanna get going... let's get going! |
|
| 228 | - add_action( |
|
| 229 | - 'AHEE__EE_Bootstrap__brew_espresso', |
|
| 230 | - array($this, 'brew_espresso'), |
|
| 231 | - 9 |
|
| 232 | - ); |
|
| 233 | - //other housekeeping |
|
| 234 | - //exclude EE critical pages from wp_list_pages |
|
| 235 | - add_filter( |
|
| 236 | - 'wp_list_pages_excludes', |
|
| 237 | - array($this, 'remove_pages_from_wp_list_pages'), |
|
| 238 | - 10 |
|
| 239 | - ); |
|
| 240 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
| 241 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
| 242 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
| 243 | - } |
|
| 244 | - |
|
| 245 | - |
|
| 246 | - |
|
| 247 | - /** |
|
| 248 | - * load and setup EE_Capabilities |
|
| 249 | - * |
|
| 250 | - * @return void |
|
| 251 | - * @throws EE_Error |
|
| 252 | - */ |
|
| 253 | - public function loadCapabilities() |
|
| 254 | - { |
|
| 255 | - $this->loader->getShared('EE_Capabilities'); |
|
| 256 | - add_action( |
|
| 257 | - 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
| 258 | - function() { |
|
| 259 | - LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 260 | - } |
|
| 261 | - ); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - |
|
| 266 | - /** |
|
| 267 | - * create and cache the CommandBus, and also add middleware |
|
| 268 | - * The CapChecker middleware requires the use of EE_Capabilities |
|
| 269 | - * which is why we need to load the CommandBus after Caps are set up |
|
| 270 | - * |
|
| 271 | - * @return void |
|
| 272 | - * @throws EE_Error |
|
| 273 | - */ |
|
| 274 | - public function loadCommandBus() |
|
| 275 | - { |
|
| 276 | - $this->loader->getShared( |
|
| 277 | - 'CommandBusInterface', |
|
| 278 | - array( |
|
| 279 | - null, |
|
| 280 | - apply_filters( |
|
| 281 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 282 | - array( |
|
| 283 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
| 284 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
| 285 | - ) |
|
| 286 | - ), |
|
| 287 | - ) |
|
| 288 | - ); |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * @return void |
|
| 295 | - * @throws EE_Error |
|
| 296 | - */ |
|
| 297 | - public function loadPluginApi() |
|
| 298 | - { |
|
| 299 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
| 300 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
| 301 | - EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - |
|
| 306 | - /** |
|
| 307 | - * load_espresso_addons |
|
| 308 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
| 309 | - * this is hooked into both: |
|
| 310 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 311 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 312 | - * and the WP 'activate_plugin' hook point |
|
| 313 | - * |
|
| 314 | - * @access public |
|
| 315 | - * @return void |
|
| 316 | - * @throws EE_Error |
|
| 317 | - */ |
|
| 318 | - public function load_espresso_addons() |
|
| 319 | - { |
|
| 320 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 321 | - //if the WP API basic auth plugin isn't already loaded, load it now. |
|
| 322 | - //We want it for mobile apps. Just include the entire plugin |
|
| 323 | - //also, don't load the basic auth when a plugin is getting activated, because |
|
| 324 | - //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
| 325 | - //and causes a fatal error |
|
| 326 | - if ( |
|
| 327 | - ! ( |
|
| 328 | - isset($_GET['activate']) |
|
| 329 | - && $_GET['activate'] === 'true' |
|
| 330 | - ) |
|
| 331 | - && ! function_exists('json_basic_auth_handler') |
|
| 332 | - && ! function_exists('json_basic_auth_error') |
|
| 333 | - && ! ( |
|
| 334 | - isset($_GET['action']) |
|
| 335 | - && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
|
| 336 | - ) |
|
| 337 | - ) { |
|
| 338 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
| 339 | - } |
|
| 340 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - |
|
| 344 | - |
|
| 345 | - /** |
|
| 346 | - * detect_activations_or_upgrades |
|
| 347 | - * Checks for activation or upgrade of core first; |
|
| 348 | - * then also checks if any registered addons have been activated or upgraded |
|
| 349 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
| 350 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
| 351 | - * |
|
| 352 | - * @access public |
|
| 353 | - * @return void |
|
| 354 | - */ |
|
| 355 | - public function detect_activations_or_upgrades() |
|
| 356 | - { |
|
| 357 | - //first off: let's make sure to handle core |
|
| 358 | - $this->detect_if_activation_or_upgrade(); |
|
| 359 | - foreach ($this->registry->addons as $addon) { |
|
| 360 | - if ($addon instanceof EE_Addon) { |
|
| 361 | - //detect teh request type for that addon |
|
| 362 | - $addon->detect_activation_or_upgrade(); |
|
| 363 | - } |
|
| 364 | - } |
|
| 365 | - } |
|
| 366 | - |
|
| 367 | - |
|
| 368 | - |
|
| 369 | - /** |
|
| 370 | - * detect_if_activation_or_upgrade |
|
| 371 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
| 372 | - * and either setting up the DB or setting up maintenance mode etc. |
|
| 373 | - * |
|
| 374 | - * @access public |
|
| 375 | - * @return void |
|
| 376 | - */ |
|
| 377 | - public function detect_if_activation_or_upgrade() |
|
| 378 | - { |
|
| 379 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
| 380 | - // check if db has been updated, or if its a brand-new installation |
|
| 381 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
| 382 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
| 383 | - //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
| 384 | - switch ($request_type) { |
|
| 385 | - case EE_System::req_type_new_activation: |
|
| 386 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
| 387 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 388 | - break; |
|
| 389 | - case EE_System::req_type_reactivation: |
|
| 390 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
| 391 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 392 | - break; |
|
| 393 | - case EE_System::req_type_upgrade: |
|
| 394 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
| 395 | - //migrations may be required now that we've upgraded |
|
| 396 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 397 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 398 | - // echo "done upgrade";die; |
|
| 399 | - break; |
|
| 400 | - case EE_System::req_type_downgrade: |
|
| 401 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
| 402 | - //its possible migrations are no longer required |
|
| 403 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 404 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 405 | - break; |
|
| 406 | - case EE_System::req_type_normal: |
|
| 407 | - default: |
|
| 408 | - // $this->_maybe_redirect_to_ee_about(); |
|
| 409 | - break; |
|
| 410 | - } |
|
| 411 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - |
|
| 415 | - |
|
| 416 | - /** |
|
| 417 | - * Updates the list of installed versions and sets hooks for |
|
| 418 | - * initializing the database later during the request |
|
| 419 | - * |
|
| 420 | - * @param array $espresso_db_update |
|
| 421 | - */ |
|
| 422 | - private function _handle_core_version_change($espresso_db_update) |
|
| 423 | - { |
|
| 424 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
| 425 | - //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
| 426 | - add_action( |
|
| 427 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 428 | - array($this, 'initialize_db_if_no_migrations_required') |
|
| 429 | - ); |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
| 436 | - * information about what versions of EE have been installed and activated, |
|
| 437 | - * NOT necessarily the state of the database |
|
| 438 | - * |
|
| 439 | - * @param mixed $espresso_db_update the value of the WordPress option. |
|
| 440 | - * If not supplied, fetches it from the options table |
|
| 441 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
| 442 | - */ |
|
| 443 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
| 444 | - { |
|
| 445 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
| 446 | - if (! $espresso_db_update) { |
|
| 447 | - $espresso_db_update = get_option('espresso_db_update'); |
|
| 448 | - } |
|
| 449 | - // check that option is an array |
|
| 450 | - if (! is_array($espresso_db_update)) { |
|
| 451 | - // if option is FALSE, then it never existed |
|
| 452 | - if ($espresso_db_update === false) { |
|
| 453 | - // make $espresso_db_update an array and save option with autoload OFF |
|
| 454 | - $espresso_db_update = array(); |
|
| 455 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
| 456 | - } else { |
|
| 457 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
| 458 | - $espresso_db_update = array($espresso_db_update => array()); |
|
| 459 | - update_option('espresso_db_update', $espresso_db_update); |
|
| 460 | - } |
|
| 461 | - } else { |
|
| 462 | - $corrected_db_update = array(); |
|
| 463 | - //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
| 464 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
| 465 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
| 466 | - //the key is an int, and the value IS NOT an array |
|
| 467 | - //so it must be numerically-indexed, where values are versions installed... |
|
| 468 | - //fix it! |
|
| 469 | - $version_string = $should_be_array; |
|
| 470 | - $corrected_db_update[$version_string] = array('unknown-date'); |
|
| 471 | - } else { |
|
| 472 | - //ok it checks out |
|
| 473 | - $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
| 474 | - } |
|
| 475 | - } |
|
| 476 | - $espresso_db_update = $corrected_db_update; |
|
| 477 | - update_option('espresso_db_update', $espresso_db_update); |
|
| 478 | - } |
|
| 479 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
| 480 | - return $espresso_db_update; |
|
| 481 | - } |
|
| 482 | - |
|
| 483 | - |
|
| 484 | - |
|
| 485 | - /** |
|
| 486 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
| 487 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
| 488 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
| 489 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
| 490 | - * so that it will be done when migrations are finished |
|
| 491 | - * |
|
| 492 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
| 493 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
| 494 | - * This is a resource-intensive job |
|
| 495 | - * so we prefer to only do it when necessary |
|
| 496 | - * @return void |
|
| 497 | - * @throws EE_Error |
|
| 498 | - */ |
|
| 499 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
| 500 | - { |
|
| 501 | - $request_type = $this->detect_req_type(); |
|
| 502 | - //only initialize system if we're not in maintenance mode. |
|
| 503 | - if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 504 | - update_option('ee_flush_rewrite_rules', true); |
|
| 505 | - if ($verify_schema) { |
|
| 506 | - EEH_Activation::initialize_db_and_folders(); |
|
| 507 | - } |
|
| 508 | - EEH_Activation::initialize_db_content(); |
|
| 509 | - EEH_Activation::system_initialization(); |
|
| 510 | - if ($initialize_addons_too) { |
|
| 511 | - $this->initialize_addons(); |
|
| 512 | - } |
|
| 513 | - } else { |
|
| 514 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
| 515 | - } |
|
| 516 | - if ($request_type === EE_System::req_type_new_activation |
|
| 517 | - || $request_type === EE_System::req_type_reactivation |
|
| 518 | - || ( |
|
| 519 | - $request_type === EE_System::req_type_upgrade |
|
| 520 | - && $this->is_major_version_change() |
|
| 521 | - ) |
|
| 522 | - ) { |
|
| 523 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
| 524 | - } |
|
| 525 | - } |
|
| 526 | - |
|
| 527 | - |
|
| 528 | - |
|
| 529 | - /** |
|
| 530 | - * Initializes the db for all registered addons |
|
| 531 | - * |
|
| 532 | - * @throws EE_Error |
|
| 533 | - */ |
|
| 534 | - public function initialize_addons() |
|
| 535 | - { |
|
| 536 | - //foreach registered addon, make sure its db is up-to-date too |
|
| 537 | - foreach ($this->registry->addons as $addon) { |
|
| 538 | - if ($addon instanceof EE_Addon) { |
|
| 539 | - $addon->initialize_db_if_no_migrations_required(); |
|
| 540 | - } |
|
| 541 | - } |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - |
|
| 545 | - |
|
| 546 | - /** |
|
| 547 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
| 548 | - * |
|
| 549 | - * @param array $version_history |
|
| 550 | - * @param string $current_version_to_add version to be added to the version history |
|
| 551 | - * @return boolean success as to whether or not this option was changed |
|
| 552 | - */ |
|
| 553 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 554 | - { |
|
| 555 | - if (! $version_history) { |
|
| 556 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
| 557 | - } |
|
| 558 | - if ($current_version_to_add === null) { |
|
| 559 | - $current_version_to_add = espresso_version(); |
|
| 560 | - } |
|
| 561 | - $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
| 562 | - // re-save |
|
| 563 | - return update_option('espresso_db_update', $version_history); |
|
| 564 | - } |
|
| 565 | - |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - /** |
|
| 569 | - * Detects if the current version indicated in the has existed in the list of |
|
| 570 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
| 571 | - * |
|
| 572 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
| 573 | - * If not supplied, fetches it from the options table. |
|
| 574 | - * Also, caches its result so later parts of the code can also know whether |
|
| 575 | - * there's been an update or not. This way we can add the current version to |
|
| 576 | - * espresso_db_update, but still know if this is a new install or not |
|
| 577 | - * @return int one of the constants on EE_System::req_type_ |
|
| 578 | - */ |
|
| 579 | - public function detect_req_type($espresso_db_update = null) |
|
| 580 | - { |
|
| 581 | - if ($this->_req_type === null) { |
|
| 582 | - $espresso_db_update = ! empty($espresso_db_update) |
|
| 583 | - ? $espresso_db_update |
|
| 584 | - : $this->fix_espresso_db_upgrade_option(); |
|
| 585 | - $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
| 586 | - $espresso_db_update, |
|
| 587 | - 'ee_espresso_activation', espresso_version() |
|
| 588 | - ); |
|
| 589 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
| 590 | - } |
|
| 591 | - return $this->_req_type; |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - |
|
| 595 | - |
|
| 596 | - /** |
|
| 597 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
| 598 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
| 599 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
| 600 | - * |
|
| 601 | - * @param $activation_history |
|
| 602 | - * @return bool |
|
| 603 | - */ |
|
| 604 | - private function _detect_major_version_change($activation_history) |
|
| 605 | - { |
|
| 606 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
| 607 | - $previous_version_parts = explode('.', $previous_version); |
|
| 608 | - $current_version_parts = explode('.', espresso_version()); |
|
| 609 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
| 610 | - && ($previous_version_parts[0] !== $current_version_parts[0] |
|
| 611 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
| 612 | - ); |
|
| 613 | - } |
|
| 614 | - |
|
| 615 | - |
|
| 616 | - |
|
| 617 | - /** |
|
| 618 | - * Returns true if either the major or minor version of EE changed during this request. |
|
| 619 | - * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
| 620 | - * |
|
| 621 | - * @return bool |
|
| 622 | - */ |
|
| 623 | - public function is_major_version_change() |
|
| 624 | - { |
|
| 625 | - return $this->_major_version_change; |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - |
|
| 629 | - |
|
| 630 | - /** |
|
| 631 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
| 632 | - * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
| 633 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
| 634 | - * just activated to (for core that will always be espresso_version()) |
|
| 635 | - * |
|
| 636 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
| 637 | - * ee plugin. for core that's 'espresso_db_update' |
|
| 638 | - * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
| 639 | - * indicate that this plugin was just activated |
|
| 640 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
| 641 | - * espresso_version()) |
|
| 642 | - * @return int one of the constants on EE_System::req_type_* |
|
| 643 | - */ |
|
| 644 | - public static function detect_req_type_given_activation_history( |
|
| 645 | - $activation_history_for_addon, |
|
| 646 | - $activation_indicator_option_name, |
|
| 647 | - $version_to_upgrade_to |
|
| 648 | - ) { |
|
| 649 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
| 650 | - if ($activation_history_for_addon) { |
|
| 651 | - //it exists, so this isn't a completely new install |
|
| 652 | - //check if this version already in that list of previously installed versions |
|
| 653 | - if (! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
| 654 | - //it a version we haven't seen before |
|
| 655 | - if ($version_is_higher === 1) { |
|
| 656 | - $req_type = EE_System::req_type_upgrade; |
|
| 657 | - } else { |
|
| 658 | - $req_type = EE_System::req_type_downgrade; |
|
| 659 | - } |
|
| 660 | - delete_option($activation_indicator_option_name); |
|
| 661 | - } else { |
|
| 662 | - // its not an update. maybe a reactivation? |
|
| 663 | - if (get_option($activation_indicator_option_name, false)) { |
|
| 664 | - if ($version_is_higher === -1) { |
|
| 665 | - $req_type = EE_System::req_type_downgrade; |
|
| 666 | - } else if ($version_is_higher === 0) { |
|
| 667 | - //we've seen this version before, but it's an activation. must be a reactivation |
|
| 668 | - $req_type = EE_System::req_type_reactivation; |
|
| 669 | - } else {//$version_is_higher === 1 |
|
| 670 | - $req_type = EE_System::req_type_upgrade; |
|
| 671 | - } |
|
| 672 | - delete_option($activation_indicator_option_name); |
|
| 673 | - } else { |
|
| 674 | - //we've seen this version before and the activation indicate doesn't show it was just activated |
|
| 675 | - if ($version_is_higher === -1) { |
|
| 676 | - $req_type = EE_System::req_type_downgrade; |
|
| 677 | - } else if ($version_is_higher === 0) { |
|
| 678 | - //we've seen this version before and it's not an activation. its normal request |
|
| 679 | - $req_type = EE_System::req_type_normal; |
|
| 680 | - } else {//$version_is_higher === 1 |
|
| 681 | - $req_type = EE_System::req_type_upgrade; |
|
| 682 | - } |
|
| 683 | - } |
|
| 684 | - } |
|
| 685 | - } else { |
|
| 686 | - //brand new install |
|
| 687 | - $req_type = EE_System::req_type_new_activation; |
|
| 688 | - delete_option($activation_indicator_option_name); |
|
| 689 | - } |
|
| 690 | - return $req_type; |
|
| 691 | - } |
|
| 692 | - |
|
| 693 | - |
|
| 694 | - |
|
| 695 | - /** |
|
| 696 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
| 697 | - * the $activation_history_for_addon |
|
| 698 | - * |
|
| 699 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
| 700 | - * sometimes containing 'unknown-date' |
|
| 701 | - * @param string $version_to_upgrade_to (current version) |
|
| 702 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
| 703 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
| 704 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
| 705 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
| 706 | - */ |
|
| 707 | - private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
| 708 | - { |
|
| 709 | - //find the most recently-activated version |
|
| 710 | - $most_recently_active_version = |
|
| 711 | - EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
| 712 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
| 713 | - } |
|
| 714 | - |
|
| 715 | - |
|
| 716 | - |
|
| 717 | - /** |
|
| 718 | - * Gets the most recently active version listed in the activation history, |
|
| 719 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
| 720 | - * |
|
| 721 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
| 722 | - * sometimes containing 'unknown-date' |
|
| 723 | - * @return string |
|
| 724 | - */ |
|
| 725 | - private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
| 726 | - { |
|
| 727 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
| 728 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
| 729 | - if (is_array($activation_history)) { |
|
| 730 | - foreach ($activation_history as $version => $times_activated) { |
|
| 731 | - //check there is a record of when this version was activated. Otherwise, |
|
| 732 | - //mark it as unknown |
|
| 733 | - if (! $times_activated) { |
|
| 734 | - $times_activated = array('unknown-date'); |
|
| 735 | - } |
|
| 736 | - if (is_string($times_activated)) { |
|
| 737 | - $times_activated = array($times_activated); |
|
| 738 | - } |
|
| 739 | - foreach ($times_activated as $an_activation) { |
|
| 740 | - if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
| 741 | - $most_recently_active_version = $version; |
|
| 742 | - $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
| 743 | - ? '1970-01-01 00:00:00' |
|
| 744 | - : $an_activation; |
|
| 745 | - } |
|
| 746 | - } |
|
| 747 | - } |
|
| 748 | - } |
|
| 749 | - return $most_recently_active_version; |
|
| 750 | - } |
|
| 751 | - |
|
| 752 | - |
|
| 753 | - |
|
| 754 | - /** |
|
| 755 | - * This redirects to the about EE page after activation |
|
| 756 | - * |
|
| 757 | - * @return void |
|
| 758 | - */ |
|
| 759 | - public function redirect_to_about_ee() |
|
| 760 | - { |
|
| 761 | - $notices = EE_Error::get_notices(false); |
|
| 762 | - //if current user is an admin and it's not an ajax or rest request |
|
| 763 | - if ( |
|
| 764 | - ! (defined('DOING_AJAX') && DOING_AJAX) |
|
| 765 | - && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
| 766 | - && ! isset($notices['errors']) |
|
| 767 | - && apply_filters( |
|
| 768 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
| 769 | - $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
| 770 | - ) |
|
| 771 | - ) { |
|
| 772 | - $query_params = array('page' => 'espresso_about'); |
|
| 773 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
| 774 | - $query_params['new_activation'] = true; |
|
| 775 | - } |
|
| 776 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
| 777 | - $query_params['reactivation'] = true; |
|
| 778 | - } |
|
| 779 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
| 780 | - wp_safe_redirect($url); |
|
| 781 | - exit(); |
|
| 782 | - } |
|
| 783 | - } |
|
| 784 | - |
|
| 785 | - |
|
| 786 | - |
|
| 787 | - /** |
|
| 788 | - * load_core_configuration |
|
| 789 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 790 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 791 | - * |
|
| 792 | - * @return void |
|
| 793 | - * @throws ReflectionException |
|
| 794 | - */ |
|
| 795 | - public function load_core_configuration() |
|
| 796 | - { |
|
| 797 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 798 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
| 799 | - //load textdomain |
|
| 800 | - EE_Load_Textdomain::load_textdomain(); |
|
| 801 | - // load and setup EE_Config and EE_Network_Config |
|
| 802 | - $config = $this->loader->getShared('EE_Config'); |
|
| 803 | - $this->loader->getShared('EE_Network_Config'); |
|
| 804 | - // setup autoloaders |
|
| 805 | - // enable logging? |
|
| 806 | - if ($config->admin->use_full_logging) { |
|
| 807 | - $this->loader->getShared('EE_Log'); |
|
| 808 | - } |
|
| 809 | - // check for activation errors |
|
| 810 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
| 811 | - if ($activation_errors) { |
|
| 812 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 813 | - update_option('ee_plugin_activation_errors', false); |
|
| 814 | - } |
|
| 815 | - // get model names |
|
| 816 | - $this->_parse_model_names(); |
|
| 817 | - //load caf stuff a chance to play during the activation process too. |
|
| 818 | - $this->_maybe_brew_regular(); |
|
| 819 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - |
|
| 823 | - |
|
| 824 | - /** |
|
| 825 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
| 826 | - * |
|
| 827 | - * @return void |
|
| 828 | - * @throws ReflectionException |
|
| 829 | - */ |
|
| 830 | - private function _parse_model_names() |
|
| 831 | - { |
|
| 832 | - //get all the files in the EE_MODELS folder that end in .model.php |
|
| 833 | - $models = glob(EE_MODELS . '*.model.php'); |
|
| 834 | - $model_names = array(); |
|
| 835 | - $non_abstract_db_models = array(); |
|
| 836 | - foreach ($models as $model) { |
|
| 837 | - // get model classname |
|
| 838 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 839 | - $short_name = str_replace('EEM_', '', $classname); |
|
| 840 | - $reflectionClass = new ReflectionClass($classname); |
|
| 841 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 842 | - $non_abstract_db_models[$short_name] = $classname; |
|
| 843 | - } |
|
| 844 | - $model_names[$short_name] = $classname; |
|
| 845 | - } |
|
| 846 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 847 | - $this->registry->non_abstract_db_models = apply_filters( |
|
| 848 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
| 849 | - $non_abstract_db_models |
|
| 850 | - ); |
|
| 851 | - } |
|
| 852 | - |
|
| 853 | - |
|
| 854 | - |
|
| 855 | - /** |
|
| 856 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
| 857 | - * that need to be setup before our EE_System launches. |
|
| 858 | - * |
|
| 859 | - * @return void |
|
| 860 | - */ |
|
| 861 | - private function _maybe_brew_regular() |
|
| 862 | - { |
|
| 863 | - if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
| 864 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 865 | - } |
|
| 866 | - } |
|
| 867 | - |
|
| 868 | - |
|
| 869 | - |
|
| 870 | - /** |
|
| 871 | - * register_shortcodes_modules_and_widgets |
|
| 872 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
| 873 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
| 874 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
| 875 | - * |
|
| 876 | - * @access public |
|
| 877 | - * @return void |
|
| 878 | - * @throws Exception |
|
| 879 | - */ |
|
| 880 | - public function register_shortcodes_modules_and_widgets() |
|
| 881 | - { |
|
| 882 | - try { |
|
| 883 | - // load, register, and add shortcodes the new way |
|
| 884 | - $this->loader->getShared( |
|
| 885 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager', |
|
| 886 | - array( |
|
| 887 | - // and the old way, but we'll put it under control of the new system |
|
| 888 | - EE_Config::getLegacyShortcodesManager() |
|
| 889 | - ) |
|
| 890 | - ); |
|
| 891 | - } catch (Exception $exception) { |
|
| 892 | - new ExceptionStackTraceDisplay($exception); |
|
| 893 | - } |
|
| 894 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 895 | - // check for addons using old hook point |
|
| 896 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 897 | - $this->_incompatible_addon_error(); |
|
| 898 | - } |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - |
|
| 902 | - |
|
| 903 | - /** |
|
| 904 | - * _incompatible_addon_error |
|
| 905 | - * |
|
| 906 | - * @access public |
|
| 907 | - * @return void |
|
| 908 | - */ |
|
| 909 | - private function _incompatible_addon_error() |
|
| 910 | - { |
|
| 911 | - // get array of classes hooking into here |
|
| 912 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
| 913 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
| 914 | - ); |
|
| 915 | - if (! empty($class_names)) { |
|
| 916 | - $msg = __( |
|
| 917 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
| 918 | - 'event_espresso' |
|
| 919 | - ); |
|
| 920 | - $msg .= '<ul>'; |
|
| 921 | - foreach ($class_names as $class_name) { |
|
| 922 | - $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
| 923 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
| 924 | - $class_name |
|
| 925 | - ) . '</b></li>'; |
|
| 926 | - } |
|
| 927 | - $msg .= '</ul>'; |
|
| 928 | - $msg .= __( |
|
| 929 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
| 930 | - 'event_espresso' |
|
| 931 | - ); |
|
| 932 | - // save list of incompatible addons to wp-options for later use |
|
| 933 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 934 | - if (is_admin()) { |
|
| 935 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 936 | - } |
|
| 937 | - } |
|
| 938 | - } |
|
| 939 | - |
|
| 940 | - |
|
| 941 | - |
|
| 942 | - /** |
|
| 943 | - * brew_espresso |
|
| 944 | - * begins the process of setting hooks for initializing EE in the correct order |
|
| 945 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
| 946 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
| 947 | - * |
|
| 948 | - * @return void |
|
| 949 | - */ |
|
| 950 | - public function brew_espresso() |
|
| 951 | - { |
|
| 952 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 953 | - // load some final core systems |
|
| 954 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 955 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
| 956 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 957 | - add_action('init', array($this, 'load_controllers'), 7); |
|
| 958 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 959 | - add_action('init', array($this, 'initialize'), 10); |
|
| 960 | - add_action('init', array($this, 'initialize_last'), 100); |
|
| 961 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 962 | - // pew pew pew |
|
| 963 | - $this->loader->getShared('EE_PUE'); |
|
| 964 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 965 | - } |
|
| 966 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 967 | - } |
|
| 968 | - |
|
| 969 | - |
|
| 970 | - |
|
| 971 | - /** |
|
| 972 | - * set_hooks_for_core |
|
| 973 | - * |
|
| 974 | - * @access public |
|
| 975 | - * @return void |
|
| 976 | - * @throws EE_Error |
|
| 977 | - */ |
|
| 978 | - public function set_hooks_for_core() |
|
| 979 | - { |
|
| 980 | - $this->_deactivate_incompatible_addons(); |
|
| 981 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 982 | - //caps need to be initialized on every request so that capability maps are set. |
|
| 983 | - //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
| 984 | - $this->registry->CAP->init_caps(); |
|
| 985 | - } |
|
| 986 | - |
|
| 987 | - |
|
| 988 | - |
|
| 989 | - /** |
|
| 990 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
| 991 | - * deactivates any addons considered incompatible with the current version of EE |
|
| 992 | - */ |
|
| 993 | - private function _deactivate_incompatible_addons() |
|
| 994 | - { |
|
| 995 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
| 996 | - if (! empty($incompatible_addons)) { |
|
| 997 | - $active_plugins = get_option('active_plugins', array()); |
|
| 998 | - foreach ($active_plugins as $active_plugin) { |
|
| 999 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
| 1000 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
| 1001 | - unset($_GET['activate']); |
|
| 1002 | - espresso_deactivate_plugin($active_plugin); |
|
| 1003 | - } |
|
| 1004 | - } |
|
| 1005 | - } |
|
| 1006 | - } |
|
| 1007 | - } |
|
| 1008 | - |
|
| 1009 | - |
|
| 1010 | - |
|
| 1011 | - /** |
|
| 1012 | - * perform_activations_upgrades_and_migrations |
|
| 1013 | - * |
|
| 1014 | - * @access public |
|
| 1015 | - * @return void |
|
| 1016 | - */ |
|
| 1017 | - public function perform_activations_upgrades_and_migrations() |
|
| 1018 | - { |
|
| 1019 | - //first check if we had previously attempted to setup EE's directories but failed |
|
| 1020 | - if (EEH_Activation::upload_directories_incomplete()) { |
|
| 1021 | - EEH_Activation::create_upload_directories(); |
|
| 1022 | - } |
|
| 1023 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 1024 | - } |
|
| 1025 | - |
|
| 1026 | - |
|
| 1027 | - |
|
| 1028 | - /** |
|
| 1029 | - * load_CPTs_and_session |
|
| 1030 | - * |
|
| 1031 | - * @access public |
|
| 1032 | - * @return void |
|
| 1033 | - */ |
|
| 1034 | - public function load_CPTs_and_session() |
|
| 1035 | - { |
|
| 1036 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 1037 | - // register Custom Post Types |
|
| 1038 | - $this->loader->getShared('EE_Register_CPTs'); |
|
| 1039 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 1040 | - } |
|
| 1041 | - |
|
| 1042 | - |
|
| 1043 | - |
|
| 1044 | - /** |
|
| 1045 | - * load_controllers |
|
| 1046 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
| 1047 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
| 1048 | - * time |
|
| 1049 | - * |
|
| 1050 | - * @access public |
|
| 1051 | - * @return void |
|
| 1052 | - */ |
|
| 1053 | - public function load_controllers() |
|
| 1054 | - { |
|
| 1055 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
| 1056 | - // let's get it started |
|
| 1057 | - if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
| 1058 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 1059 | - $this->loader->getShared('EE_Front_Controller'); |
|
| 1060 | - } else if (! EE_FRONT_AJAX) { |
|
| 1061 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 1062 | - $this->loader->getShared('EE_Admin'); |
|
| 1063 | - } |
|
| 1064 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 1065 | - } |
|
| 1066 | - |
|
| 1067 | - |
|
| 1068 | - |
|
| 1069 | - /** |
|
| 1070 | - * core_loaded_and_ready |
|
| 1071 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
| 1072 | - * |
|
| 1073 | - * @access public |
|
| 1074 | - * @return void |
|
| 1075 | - */ |
|
| 1076 | - public function core_loaded_and_ready() |
|
| 1077 | - { |
|
| 1078 | - $this->loader->getShared('EE_Session'); |
|
| 1079 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 1080 | - // load_espresso_template_tags |
|
| 1081 | - if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
| 1082 | - require_once(EE_PUBLIC . 'template_tags.php'); |
|
| 1083 | - } |
|
| 1084 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 1085 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 1086 | - } |
|
| 1087 | - |
|
| 1088 | - |
|
| 1089 | - |
|
| 1090 | - /** |
|
| 1091 | - * initialize |
|
| 1092 | - * this is the best place to begin initializing client code |
|
| 1093 | - * |
|
| 1094 | - * @access public |
|
| 1095 | - * @return void |
|
| 1096 | - */ |
|
| 1097 | - public function initialize() |
|
| 1098 | - { |
|
| 1099 | - do_action('AHEE__EE_System__initialize'); |
|
| 1100 | - } |
|
| 1101 | - |
|
| 1102 | - |
|
| 1103 | - |
|
| 1104 | - /** |
|
| 1105 | - * initialize_last |
|
| 1106 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
| 1107 | - * initialize has done so |
|
| 1108 | - * |
|
| 1109 | - * @access public |
|
| 1110 | - * @return void |
|
| 1111 | - */ |
|
| 1112 | - public function initialize_last() |
|
| 1113 | - { |
|
| 1114 | - do_action('AHEE__EE_System__initialize_last'); |
|
| 1115 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
| 1116 | - } |
|
| 1117 | - |
|
| 1118 | - |
|
| 1119 | - |
|
| 1120 | - /** |
|
| 1121 | - * @return void |
|
| 1122 | - * @throws EE_Error |
|
| 1123 | - */ |
|
| 1124 | - public function addEspressoToolbar() |
|
| 1125 | - { |
|
| 1126 | - $this->loader->getShared( |
|
| 1127 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
| 1128 | - array($this->registry->CAP) |
|
| 1129 | - ); |
|
| 1130 | - } |
|
| 1131 | - |
|
| 1132 | - |
|
| 1133 | - |
|
| 1134 | - /** |
|
| 1135 | - * do_not_cache |
|
| 1136 | - * sets no cache headers and defines no cache constants for WP plugins |
|
| 1137 | - * |
|
| 1138 | - * @access public |
|
| 1139 | - * @return void |
|
| 1140 | - */ |
|
| 1141 | - public static function do_not_cache() |
|
| 1142 | - { |
|
| 1143 | - // set no cache constants |
|
| 1144 | - if (! defined('DONOTCACHEPAGE')) { |
|
| 1145 | - define('DONOTCACHEPAGE', true); |
|
| 1146 | - } |
|
| 1147 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
| 1148 | - define('DONOTCACHCEOBJECT', true); |
|
| 1149 | - } |
|
| 1150 | - if (! defined('DONOTCACHEDB')) { |
|
| 1151 | - define('DONOTCACHEDB', true); |
|
| 1152 | - } |
|
| 1153 | - // add no cache headers |
|
| 1154 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 1155 | - // plus a little extra for nginx and Google Chrome |
|
| 1156 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 1157 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
| 1158 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 1159 | - } |
|
| 1160 | - |
|
| 1161 | - |
|
| 1162 | - |
|
| 1163 | - /** |
|
| 1164 | - * extra_nocache_headers |
|
| 1165 | - * |
|
| 1166 | - * @access public |
|
| 1167 | - * @param $headers |
|
| 1168 | - * @return array |
|
| 1169 | - */ |
|
| 1170 | - public static function extra_nocache_headers($headers) |
|
| 1171 | - { |
|
| 1172 | - // for NGINX |
|
| 1173 | - $headers['X-Accel-Expires'] = 0; |
|
| 1174 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
| 1175 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
| 1176 | - return $headers; |
|
| 1177 | - } |
|
| 1178 | - |
|
| 1179 | - |
|
| 1180 | - |
|
| 1181 | - /** |
|
| 1182 | - * nocache_headers |
|
| 1183 | - * |
|
| 1184 | - * @access public |
|
| 1185 | - * @return void |
|
| 1186 | - */ |
|
| 1187 | - public static function nocache_headers() |
|
| 1188 | - { |
|
| 1189 | - nocache_headers(); |
|
| 1190 | - } |
|
| 1191 | - |
|
| 1192 | - |
|
| 1193 | - |
|
| 1194 | - |
|
| 1195 | - /** |
|
| 1196 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
| 1197 | - * never returned with the function. |
|
| 1198 | - * |
|
| 1199 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
| 1200 | - * @return array |
|
| 1201 | - */ |
|
| 1202 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
| 1203 | - { |
|
| 1204 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 1205 | - } |
|
| 24 | + /** |
|
| 25 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
| 26 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
| 27 | + */ |
|
| 28 | + const req_type_normal = 0; |
|
| 29 | + |
|
| 30 | + /** |
|
| 31 | + * Indicates this is a brand new installation of EE so we should install |
|
| 32 | + * tables and default data etc |
|
| 33 | + */ |
|
| 34 | + const req_type_new_activation = 1; |
|
| 35 | + |
|
| 36 | + /** |
|
| 37 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
| 38 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
| 39 | + * and that default data is setup too |
|
| 40 | + */ |
|
| 41 | + const req_type_reactivation = 2; |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * indicates that EE has been upgraded since its previous request. |
|
| 45 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
| 46 | + */ |
|
| 47 | + const req_type_upgrade = 3; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
| 51 | + */ |
|
| 52 | + const req_type_downgrade = 4; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @deprecated since version 4.6.0.dev.006 |
|
| 56 | + * Now whenever a new_activation is detected the request type is still just |
|
| 57 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
| 58 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
| 59 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
| 60 | + * (Specifically, when the migration manager indicates migrations are finished |
|
| 61 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
| 62 | + */ |
|
| 63 | + const req_type_activation_but_not_installed = 5; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
| 67 | + */ |
|
| 68 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @var EE_System $_instance |
|
| 73 | + */ |
|
| 74 | + private static $_instance; |
|
| 75 | + |
|
| 76 | + /** |
|
| 77 | + * @var EE_Registry $registry |
|
| 78 | + */ |
|
| 79 | + private $registry; |
|
| 80 | + |
|
| 81 | + /** |
|
| 82 | + * @var LoaderInterface $loader |
|
| 83 | + */ |
|
| 84 | + private $loader; |
|
| 85 | + |
|
| 86 | + /** |
|
| 87 | + * @var EE_Capabilities $capabilities |
|
| 88 | + */ |
|
| 89 | + private $capabilities; |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * @var EE_Request $request |
|
| 93 | + */ |
|
| 94 | + private $request; |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
| 98 | + */ |
|
| 99 | + private $maintenance_mode; |
|
| 100 | + |
|
| 101 | + /** |
|
| 102 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
| 103 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
| 104 | + * |
|
| 105 | + * @var int $_req_type |
|
| 106 | + */ |
|
| 107 | + private $_req_type; |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
| 111 | + * |
|
| 112 | + * @var boolean $_major_version_change |
|
| 113 | + */ |
|
| 114 | + private $_major_version_change = false; |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * @singleton method used to instantiate class object |
|
| 120 | + * @param EE_Registry|null $registry |
|
| 121 | + * @param LoaderInterface|null $loader |
|
| 122 | + * @param EE_Capabilities|null $capabilities |
|
| 123 | + * @param EE_Request|null $request |
|
| 124 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
| 125 | + * @return EE_System |
|
| 126 | + */ |
|
| 127 | + public static function instance( |
|
| 128 | + EE_Registry $registry = null, |
|
| 129 | + LoaderInterface $loader = null, |
|
| 130 | + EE_Capabilities $capabilities = null, |
|
| 131 | + EE_Request $request = null, |
|
| 132 | + EE_Maintenance_Mode $maintenance_mode = null |
|
| 133 | + ) { |
|
| 134 | + // check if class object is instantiated |
|
| 135 | + if (! self::$_instance instanceof EE_System) { |
|
| 136 | + self::$_instance = new self($registry, $loader, $capabilities, $request, $maintenance_mode); |
|
| 137 | + } |
|
| 138 | + return self::$_instance; |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + |
|
| 143 | + /** |
|
| 144 | + * resets the instance and returns it |
|
| 145 | + * |
|
| 146 | + * @return EE_System |
|
| 147 | + */ |
|
| 148 | + public static function reset() |
|
| 149 | + { |
|
| 150 | + self::$_instance->_req_type = null; |
|
| 151 | + //make sure none of the old hooks are left hanging around |
|
| 152 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 153 | + //we need to reset the migration manager in order for it to detect DMSs properly |
|
| 154 | + EE_Data_Migration_Manager::reset(); |
|
| 155 | + self::instance()->detect_activations_or_upgrades(); |
|
| 156 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
| 157 | + return self::instance(); |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * sets hooks for running rest of system |
|
| 164 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 165 | + * starting EE Addons from any other point may lead to problems |
|
| 166 | + * |
|
| 167 | + * @param EE_Registry $registry |
|
| 168 | + * @param LoaderInterface $loader |
|
| 169 | + * @param EE_Capabilities $capabilities |
|
| 170 | + * @param EE_Request $request |
|
| 171 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
| 172 | + */ |
|
| 173 | + private function __construct( |
|
| 174 | + EE_Registry $registry, |
|
| 175 | + LoaderInterface $loader, |
|
| 176 | + EE_Capabilities $capabilities, |
|
| 177 | + EE_Request $request, |
|
| 178 | + EE_Maintenance_Mode $maintenance_mode |
|
| 179 | + ) { |
|
| 180 | + $this->registry = $registry; |
|
| 181 | + $this->loader = $loader; |
|
| 182 | + $this->capabilities = $capabilities; |
|
| 183 | + $this->request = $request; |
|
| 184 | + $this->maintenance_mode = $maintenance_mode; |
|
| 185 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
| 186 | + add_action( |
|
| 187 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 188 | + array($this, 'loadCapabilities'), |
|
| 189 | + 5 |
|
| 190 | + ); |
|
| 191 | + add_action( |
|
| 192 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 193 | + array($this, 'loadCommandBus'), |
|
| 194 | + 7 |
|
| 195 | + ); |
|
| 196 | + add_action( |
|
| 197 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 198 | + array($this, 'loadPluginApi'), |
|
| 199 | + 9 |
|
| 200 | + ); |
|
| 201 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
| 202 | + add_action( |
|
| 203 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 204 | + array($this, 'load_espresso_addons') |
|
| 205 | + ); |
|
| 206 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
| 207 | + // because the newly-activated addon didn't get a chance to run at all |
|
| 208 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
| 209 | + // detect whether install or upgrade |
|
| 210 | + add_action( |
|
| 211 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
| 212 | + array($this, 'detect_activations_or_upgrades'), |
|
| 213 | + 3 |
|
| 214 | + ); |
|
| 215 | + // load EE_Config, EE_Textdomain, etc |
|
| 216 | + add_action( |
|
| 217 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 218 | + array($this, 'load_core_configuration'), |
|
| 219 | + 5 |
|
| 220 | + ); |
|
| 221 | + // load EE_Config, EE_Textdomain, etc |
|
| 222 | + add_action( |
|
| 223 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
| 224 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 225 | + 7 |
|
| 226 | + ); |
|
| 227 | + // you wanna get going? I wanna get going... let's get going! |
|
| 228 | + add_action( |
|
| 229 | + 'AHEE__EE_Bootstrap__brew_espresso', |
|
| 230 | + array($this, 'brew_espresso'), |
|
| 231 | + 9 |
|
| 232 | + ); |
|
| 233 | + //other housekeeping |
|
| 234 | + //exclude EE critical pages from wp_list_pages |
|
| 235 | + add_filter( |
|
| 236 | + 'wp_list_pages_excludes', |
|
| 237 | + array($this, 'remove_pages_from_wp_list_pages'), |
|
| 238 | + 10 |
|
| 239 | + ); |
|
| 240 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
| 241 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
| 242 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
| 243 | + } |
|
| 244 | + |
|
| 245 | + |
|
| 246 | + |
|
| 247 | + /** |
|
| 248 | + * load and setup EE_Capabilities |
|
| 249 | + * |
|
| 250 | + * @return void |
|
| 251 | + * @throws EE_Error |
|
| 252 | + */ |
|
| 253 | + public function loadCapabilities() |
|
| 254 | + { |
|
| 255 | + $this->loader->getShared('EE_Capabilities'); |
|
| 256 | + add_action( |
|
| 257 | + 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
| 258 | + function() { |
|
| 259 | + LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 260 | + } |
|
| 261 | + ); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + |
|
| 266 | + /** |
|
| 267 | + * create and cache the CommandBus, and also add middleware |
|
| 268 | + * The CapChecker middleware requires the use of EE_Capabilities |
|
| 269 | + * which is why we need to load the CommandBus after Caps are set up |
|
| 270 | + * |
|
| 271 | + * @return void |
|
| 272 | + * @throws EE_Error |
|
| 273 | + */ |
|
| 274 | + public function loadCommandBus() |
|
| 275 | + { |
|
| 276 | + $this->loader->getShared( |
|
| 277 | + 'CommandBusInterface', |
|
| 278 | + array( |
|
| 279 | + null, |
|
| 280 | + apply_filters( |
|
| 281 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 282 | + array( |
|
| 283 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
| 284 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
| 285 | + ) |
|
| 286 | + ), |
|
| 287 | + ) |
|
| 288 | + ); |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * @return void |
|
| 295 | + * @throws EE_Error |
|
| 296 | + */ |
|
| 297 | + public function loadPluginApi() |
|
| 298 | + { |
|
| 299 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
| 300 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
| 301 | + EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + |
|
| 306 | + /** |
|
| 307 | + * load_espresso_addons |
|
| 308 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
| 309 | + * this is hooked into both: |
|
| 310 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 311 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 312 | + * and the WP 'activate_plugin' hook point |
|
| 313 | + * |
|
| 314 | + * @access public |
|
| 315 | + * @return void |
|
| 316 | + * @throws EE_Error |
|
| 317 | + */ |
|
| 318 | + public function load_espresso_addons() |
|
| 319 | + { |
|
| 320 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 321 | + //if the WP API basic auth plugin isn't already loaded, load it now. |
|
| 322 | + //We want it for mobile apps. Just include the entire plugin |
|
| 323 | + //also, don't load the basic auth when a plugin is getting activated, because |
|
| 324 | + //it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
| 325 | + //and causes a fatal error |
|
| 326 | + if ( |
|
| 327 | + ! ( |
|
| 328 | + isset($_GET['activate']) |
|
| 329 | + && $_GET['activate'] === 'true' |
|
| 330 | + ) |
|
| 331 | + && ! function_exists('json_basic_auth_handler') |
|
| 332 | + && ! function_exists('json_basic_auth_error') |
|
| 333 | + && ! ( |
|
| 334 | + isset($_GET['action']) |
|
| 335 | + && in_array($_GET['action'], array('activate', 'activate-selected'), true) |
|
| 336 | + ) |
|
| 337 | + ) { |
|
| 338 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php'; |
|
| 339 | + } |
|
| 340 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + |
|
| 344 | + |
|
| 345 | + /** |
|
| 346 | + * detect_activations_or_upgrades |
|
| 347 | + * Checks for activation or upgrade of core first; |
|
| 348 | + * then also checks if any registered addons have been activated or upgraded |
|
| 349 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
| 350 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
| 351 | + * |
|
| 352 | + * @access public |
|
| 353 | + * @return void |
|
| 354 | + */ |
|
| 355 | + public function detect_activations_or_upgrades() |
|
| 356 | + { |
|
| 357 | + //first off: let's make sure to handle core |
|
| 358 | + $this->detect_if_activation_or_upgrade(); |
|
| 359 | + foreach ($this->registry->addons as $addon) { |
|
| 360 | + if ($addon instanceof EE_Addon) { |
|
| 361 | + //detect teh request type for that addon |
|
| 362 | + $addon->detect_activation_or_upgrade(); |
|
| 363 | + } |
|
| 364 | + } |
|
| 365 | + } |
|
| 366 | + |
|
| 367 | + |
|
| 368 | + |
|
| 369 | + /** |
|
| 370 | + * detect_if_activation_or_upgrade |
|
| 371 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
| 372 | + * and either setting up the DB or setting up maintenance mode etc. |
|
| 373 | + * |
|
| 374 | + * @access public |
|
| 375 | + * @return void |
|
| 376 | + */ |
|
| 377 | + public function detect_if_activation_or_upgrade() |
|
| 378 | + { |
|
| 379 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
| 380 | + // check if db has been updated, or if its a brand-new installation |
|
| 381 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
| 382 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
| 383 | + //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
| 384 | + switch ($request_type) { |
|
| 385 | + case EE_System::req_type_new_activation: |
|
| 386 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
| 387 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 388 | + break; |
|
| 389 | + case EE_System::req_type_reactivation: |
|
| 390 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
| 391 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 392 | + break; |
|
| 393 | + case EE_System::req_type_upgrade: |
|
| 394 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
| 395 | + //migrations may be required now that we've upgraded |
|
| 396 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 397 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 398 | + // echo "done upgrade";die; |
|
| 399 | + break; |
|
| 400 | + case EE_System::req_type_downgrade: |
|
| 401 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
| 402 | + //its possible migrations are no longer required |
|
| 403 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 404 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 405 | + break; |
|
| 406 | + case EE_System::req_type_normal: |
|
| 407 | + default: |
|
| 408 | + // $this->_maybe_redirect_to_ee_about(); |
|
| 409 | + break; |
|
| 410 | + } |
|
| 411 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + |
|
| 415 | + |
|
| 416 | + /** |
|
| 417 | + * Updates the list of installed versions and sets hooks for |
|
| 418 | + * initializing the database later during the request |
|
| 419 | + * |
|
| 420 | + * @param array $espresso_db_update |
|
| 421 | + */ |
|
| 422 | + private function _handle_core_version_change($espresso_db_update) |
|
| 423 | + { |
|
| 424 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
| 425 | + //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
| 426 | + add_action( |
|
| 427 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 428 | + array($this, 'initialize_db_if_no_migrations_required') |
|
| 429 | + ); |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
| 436 | + * information about what versions of EE have been installed and activated, |
|
| 437 | + * NOT necessarily the state of the database |
|
| 438 | + * |
|
| 439 | + * @param mixed $espresso_db_update the value of the WordPress option. |
|
| 440 | + * If not supplied, fetches it from the options table |
|
| 441 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
| 442 | + */ |
|
| 443 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
| 444 | + { |
|
| 445 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
| 446 | + if (! $espresso_db_update) { |
|
| 447 | + $espresso_db_update = get_option('espresso_db_update'); |
|
| 448 | + } |
|
| 449 | + // check that option is an array |
|
| 450 | + if (! is_array($espresso_db_update)) { |
|
| 451 | + // if option is FALSE, then it never existed |
|
| 452 | + if ($espresso_db_update === false) { |
|
| 453 | + // make $espresso_db_update an array and save option with autoload OFF |
|
| 454 | + $espresso_db_update = array(); |
|
| 455 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
| 456 | + } else { |
|
| 457 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
| 458 | + $espresso_db_update = array($espresso_db_update => array()); |
|
| 459 | + update_option('espresso_db_update', $espresso_db_update); |
|
| 460 | + } |
|
| 461 | + } else { |
|
| 462 | + $corrected_db_update = array(); |
|
| 463 | + //if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
| 464 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
| 465 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
| 466 | + //the key is an int, and the value IS NOT an array |
|
| 467 | + //so it must be numerically-indexed, where values are versions installed... |
|
| 468 | + //fix it! |
|
| 469 | + $version_string = $should_be_array; |
|
| 470 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
| 471 | + } else { |
|
| 472 | + //ok it checks out |
|
| 473 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
| 474 | + } |
|
| 475 | + } |
|
| 476 | + $espresso_db_update = $corrected_db_update; |
|
| 477 | + update_option('espresso_db_update', $espresso_db_update); |
|
| 478 | + } |
|
| 479 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
| 480 | + return $espresso_db_update; |
|
| 481 | + } |
|
| 482 | + |
|
| 483 | + |
|
| 484 | + |
|
| 485 | + /** |
|
| 486 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
| 487 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
| 488 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
| 489 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
| 490 | + * so that it will be done when migrations are finished |
|
| 491 | + * |
|
| 492 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
| 493 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
| 494 | + * This is a resource-intensive job |
|
| 495 | + * so we prefer to only do it when necessary |
|
| 496 | + * @return void |
|
| 497 | + * @throws EE_Error |
|
| 498 | + */ |
|
| 499 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
| 500 | + { |
|
| 501 | + $request_type = $this->detect_req_type(); |
|
| 502 | + //only initialize system if we're not in maintenance mode. |
|
| 503 | + if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 504 | + update_option('ee_flush_rewrite_rules', true); |
|
| 505 | + if ($verify_schema) { |
|
| 506 | + EEH_Activation::initialize_db_and_folders(); |
|
| 507 | + } |
|
| 508 | + EEH_Activation::initialize_db_content(); |
|
| 509 | + EEH_Activation::system_initialization(); |
|
| 510 | + if ($initialize_addons_too) { |
|
| 511 | + $this->initialize_addons(); |
|
| 512 | + } |
|
| 513 | + } else { |
|
| 514 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
| 515 | + } |
|
| 516 | + if ($request_type === EE_System::req_type_new_activation |
|
| 517 | + || $request_type === EE_System::req_type_reactivation |
|
| 518 | + || ( |
|
| 519 | + $request_type === EE_System::req_type_upgrade |
|
| 520 | + && $this->is_major_version_change() |
|
| 521 | + ) |
|
| 522 | + ) { |
|
| 523 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
| 524 | + } |
|
| 525 | + } |
|
| 526 | + |
|
| 527 | + |
|
| 528 | + |
|
| 529 | + /** |
|
| 530 | + * Initializes the db for all registered addons |
|
| 531 | + * |
|
| 532 | + * @throws EE_Error |
|
| 533 | + */ |
|
| 534 | + public function initialize_addons() |
|
| 535 | + { |
|
| 536 | + //foreach registered addon, make sure its db is up-to-date too |
|
| 537 | + foreach ($this->registry->addons as $addon) { |
|
| 538 | + if ($addon instanceof EE_Addon) { |
|
| 539 | + $addon->initialize_db_if_no_migrations_required(); |
|
| 540 | + } |
|
| 541 | + } |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + |
|
| 545 | + |
|
| 546 | + /** |
|
| 547 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
| 548 | + * |
|
| 549 | + * @param array $version_history |
|
| 550 | + * @param string $current_version_to_add version to be added to the version history |
|
| 551 | + * @return boolean success as to whether or not this option was changed |
|
| 552 | + */ |
|
| 553 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 554 | + { |
|
| 555 | + if (! $version_history) { |
|
| 556 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
| 557 | + } |
|
| 558 | + if ($current_version_to_add === null) { |
|
| 559 | + $current_version_to_add = espresso_version(); |
|
| 560 | + } |
|
| 561 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
| 562 | + // re-save |
|
| 563 | + return update_option('espresso_db_update', $version_history); |
|
| 564 | + } |
|
| 565 | + |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + /** |
|
| 569 | + * Detects if the current version indicated in the has existed in the list of |
|
| 570 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
| 571 | + * |
|
| 572 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
| 573 | + * If not supplied, fetches it from the options table. |
|
| 574 | + * Also, caches its result so later parts of the code can also know whether |
|
| 575 | + * there's been an update or not. This way we can add the current version to |
|
| 576 | + * espresso_db_update, but still know if this is a new install or not |
|
| 577 | + * @return int one of the constants on EE_System::req_type_ |
|
| 578 | + */ |
|
| 579 | + public function detect_req_type($espresso_db_update = null) |
|
| 580 | + { |
|
| 581 | + if ($this->_req_type === null) { |
|
| 582 | + $espresso_db_update = ! empty($espresso_db_update) |
|
| 583 | + ? $espresso_db_update |
|
| 584 | + : $this->fix_espresso_db_upgrade_option(); |
|
| 585 | + $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
| 586 | + $espresso_db_update, |
|
| 587 | + 'ee_espresso_activation', espresso_version() |
|
| 588 | + ); |
|
| 589 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
| 590 | + } |
|
| 591 | + return $this->_req_type; |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + |
|
| 595 | + |
|
| 596 | + /** |
|
| 597 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
| 598 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
| 599 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
| 600 | + * |
|
| 601 | + * @param $activation_history |
|
| 602 | + * @return bool |
|
| 603 | + */ |
|
| 604 | + private function _detect_major_version_change($activation_history) |
|
| 605 | + { |
|
| 606 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
| 607 | + $previous_version_parts = explode('.', $previous_version); |
|
| 608 | + $current_version_parts = explode('.', espresso_version()); |
|
| 609 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
| 610 | + && ($previous_version_parts[0] !== $current_version_parts[0] |
|
| 611 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
| 612 | + ); |
|
| 613 | + } |
|
| 614 | + |
|
| 615 | + |
|
| 616 | + |
|
| 617 | + /** |
|
| 618 | + * Returns true if either the major or minor version of EE changed during this request. |
|
| 619 | + * Eg 4.9.0.rc.001 to 4.10.0.rc.000, but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
| 620 | + * |
|
| 621 | + * @return bool |
|
| 622 | + */ |
|
| 623 | + public function is_major_version_change() |
|
| 624 | + { |
|
| 625 | + return $this->_major_version_change; |
|
| 626 | + } |
|
| 627 | + |
|
| 628 | + |
|
| 629 | + |
|
| 630 | + /** |
|
| 631 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
| 632 | + * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
| 633 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
| 634 | + * just activated to (for core that will always be espresso_version()) |
|
| 635 | + * |
|
| 636 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
| 637 | + * ee plugin. for core that's 'espresso_db_update' |
|
| 638 | + * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
| 639 | + * indicate that this plugin was just activated |
|
| 640 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
| 641 | + * espresso_version()) |
|
| 642 | + * @return int one of the constants on EE_System::req_type_* |
|
| 643 | + */ |
|
| 644 | + public static function detect_req_type_given_activation_history( |
|
| 645 | + $activation_history_for_addon, |
|
| 646 | + $activation_indicator_option_name, |
|
| 647 | + $version_to_upgrade_to |
|
| 648 | + ) { |
|
| 649 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
| 650 | + if ($activation_history_for_addon) { |
|
| 651 | + //it exists, so this isn't a completely new install |
|
| 652 | + //check if this version already in that list of previously installed versions |
|
| 653 | + if (! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
| 654 | + //it a version we haven't seen before |
|
| 655 | + if ($version_is_higher === 1) { |
|
| 656 | + $req_type = EE_System::req_type_upgrade; |
|
| 657 | + } else { |
|
| 658 | + $req_type = EE_System::req_type_downgrade; |
|
| 659 | + } |
|
| 660 | + delete_option($activation_indicator_option_name); |
|
| 661 | + } else { |
|
| 662 | + // its not an update. maybe a reactivation? |
|
| 663 | + if (get_option($activation_indicator_option_name, false)) { |
|
| 664 | + if ($version_is_higher === -1) { |
|
| 665 | + $req_type = EE_System::req_type_downgrade; |
|
| 666 | + } else if ($version_is_higher === 0) { |
|
| 667 | + //we've seen this version before, but it's an activation. must be a reactivation |
|
| 668 | + $req_type = EE_System::req_type_reactivation; |
|
| 669 | + } else {//$version_is_higher === 1 |
|
| 670 | + $req_type = EE_System::req_type_upgrade; |
|
| 671 | + } |
|
| 672 | + delete_option($activation_indicator_option_name); |
|
| 673 | + } else { |
|
| 674 | + //we've seen this version before and the activation indicate doesn't show it was just activated |
|
| 675 | + if ($version_is_higher === -1) { |
|
| 676 | + $req_type = EE_System::req_type_downgrade; |
|
| 677 | + } else if ($version_is_higher === 0) { |
|
| 678 | + //we've seen this version before and it's not an activation. its normal request |
|
| 679 | + $req_type = EE_System::req_type_normal; |
|
| 680 | + } else {//$version_is_higher === 1 |
|
| 681 | + $req_type = EE_System::req_type_upgrade; |
|
| 682 | + } |
|
| 683 | + } |
|
| 684 | + } |
|
| 685 | + } else { |
|
| 686 | + //brand new install |
|
| 687 | + $req_type = EE_System::req_type_new_activation; |
|
| 688 | + delete_option($activation_indicator_option_name); |
|
| 689 | + } |
|
| 690 | + return $req_type; |
|
| 691 | + } |
|
| 692 | + |
|
| 693 | + |
|
| 694 | + |
|
| 695 | + /** |
|
| 696 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
| 697 | + * the $activation_history_for_addon |
|
| 698 | + * |
|
| 699 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
| 700 | + * sometimes containing 'unknown-date' |
|
| 701 | + * @param string $version_to_upgrade_to (current version) |
|
| 702 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
| 703 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
| 704 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
| 705 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
| 706 | + */ |
|
| 707 | + private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
| 708 | + { |
|
| 709 | + //find the most recently-activated version |
|
| 710 | + $most_recently_active_version = |
|
| 711 | + EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
| 712 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
| 713 | + } |
|
| 714 | + |
|
| 715 | + |
|
| 716 | + |
|
| 717 | + /** |
|
| 718 | + * Gets the most recently active version listed in the activation history, |
|
| 719 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
| 720 | + * |
|
| 721 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
| 722 | + * sometimes containing 'unknown-date' |
|
| 723 | + * @return string |
|
| 724 | + */ |
|
| 725 | + private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
| 726 | + { |
|
| 727 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
| 728 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
| 729 | + if (is_array($activation_history)) { |
|
| 730 | + foreach ($activation_history as $version => $times_activated) { |
|
| 731 | + //check there is a record of when this version was activated. Otherwise, |
|
| 732 | + //mark it as unknown |
|
| 733 | + if (! $times_activated) { |
|
| 734 | + $times_activated = array('unknown-date'); |
|
| 735 | + } |
|
| 736 | + if (is_string($times_activated)) { |
|
| 737 | + $times_activated = array($times_activated); |
|
| 738 | + } |
|
| 739 | + foreach ($times_activated as $an_activation) { |
|
| 740 | + if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) { |
|
| 741 | + $most_recently_active_version = $version; |
|
| 742 | + $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
| 743 | + ? '1970-01-01 00:00:00' |
|
| 744 | + : $an_activation; |
|
| 745 | + } |
|
| 746 | + } |
|
| 747 | + } |
|
| 748 | + } |
|
| 749 | + return $most_recently_active_version; |
|
| 750 | + } |
|
| 751 | + |
|
| 752 | + |
|
| 753 | + |
|
| 754 | + /** |
|
| 755 | + * This redirects to the about EE page after activation |
|
| 756 | + * |
|
| 757 | + * @return void |
|
| 758 | + */ |
|
| 759 | + public function redirect_to_about_ee() |
|
| 760 | + { |
|
| 761 | + $notices = EE_Error::get_notices(false); |
|
| 762 | + //if current user is an admin and it's not an ajax or rest request |
|
| 763 | + if ( |
|
| 764 | + ! (defined('DOING_AJAX') && DOING_AJAX) |
|
| 765 | + && ! (defined('REST_REQUEST') && REST_REQUEST) |
|
| 766 | + && ! isset($notices['errors']) |
|
| 767 | + && apply_filters( |
|
| 768 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
| 769 | + $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
| 770 | + ) |
|
| 771 | + ) { |
|
| 772 | + $query_params = array('page' => 'espresso_about'); |
|
| 773 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
| 774 | + $query_params['new_activation'] = true; |
|
| 775 | + } |
|
| 776 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
| 777 | + $query_params['reactivation'] = true; |
|
| 778 | + } |
|
| 779 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
| 780 | + wp_safe_redirect($url); |
|
| 781 | + exit(); |
|
| 782 | + } |
|
| 783 | + } |
|
| 784 | + |
|
| 785 | + |
|
| 786 | + |
|
| 787 | + /** |
|
| 788 | + * load_core_configuration |
|
| 789 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 790 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 791 | + * |
|
| 792 | + * @return void |
|
| 793 | + * @throws ReflectionException |
|
| 794 | + */ |
|
| 795 | + public function load_core_configuration() |
|
| 796 | + { |
|
| 797 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 798 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
| 799 | + //load textdomain |
|
| 800 | + EE_Load_Textdomain::load_textdomain(); |
|
| 801 | + // load and setup EE_Config and EE_Network_Config |
|
| 802 | + $config = $this->loader->getShared('EE_Config'); |
|
| 803 | + $this->loader->getShared('EE_Network_Config'); |
|
| 804 | + // setup autoloaders |
|
| 805 | + // enable logging? |
|
| 806 | + if ($config->admin->use_full_logging) { |
|
| 807 | + $this->loader->getShared('EE_Log'); |
|
| 808 | + } |
|
| 809 | + // check for activation errors |
|
| 810 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
| 811 | + if ($activation_errors) { |
|
| 812 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 813 | + update_option('ee_plugin_activation_errors', false); |
|
| 814 | + } |
|
| 815 | + // get model names |
|
| 816 | + $this->_parse_model_names(); |
|
| 817 | + //load caf stuff a chance to play during the activation process too. |
|
| 818 | + $this->_maybe_brew_regular(); |
|
| 819 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + |
|
| 823 | + |
|
| 824 | + /** |
|
| 825 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
| 826 | + * |
|
| 827 | + * @return void |
|
| 828 | + * @throws ReflectionException |
|
| 829 | + */ |
|
| 830 | + private function _parse_model_names() |
|
| 831 | + { |
|
| 832 | + //get all the files in the EE_MODELS folder that end in .model.php |
|
| 833 | + $models = glob(EE_MODELS . '*.model.php'); |
|
| 834 | + $model_names = array(); |
|
| 835 | + $non_abstract_db_models = array(); |
|
| 836 | + foreach ($models as $model) { |
|
| 837 | + // get model classname |
|
| 838 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 839 | + $short_name = str_replace('EEM_', '', $classname); |
|
| 840 | + $reflectionClass = new ReflectionClass($classname); |
|
| 841 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 842 | + $non_abstract_db_models[$short_name] = $classname; |
|
| 843 | + } |
|
| 844 | + $model_names[$short_name] = $classname; |
|
| 845 | + } |
|
| 846 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 847 | + $this->registry->non_abstract_db_models = apply_filters( |
|
| 848 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
| 849 | + $non_abstract_db_models |
|
| 850 | + ); |
|
| 851 | + } |
|
| 852 | + |
|
| 853 | + |
|
| 854 | + |
|
| 855 | + /** |
|
| 856 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
| 857 | + * that need to be setup before our EE_System launches. |
|
| 858 | + * |
|
| 859 | + * @return void |
|
| 860 | + */ |
|
| 861 | + private function _maybe_brew_regular() |
|
| 862 | + { |
|
| 863 | + if ((! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) { |
|
| 864 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 865 | + } |
|
| 866 | + } |
|
| 867 | + |
|
| 868 | + |
|
| 869 | + |
|
| 870 | + /** |
|
| 871 | + * register_shortcodes_modules_and_widgets |
|
| 872 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
| 873 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
| 874 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
| 875 | + * |
|
| 876 | + * @access public |
|
| 877 | + * @return void |
|
| 878 | + * @throws Exception |
|
| 879 | + */ |
|
| 880 | + public function register_shortcodes_modules_and_widgets() |
|
| 881 | + { |
|
| 882 | + try { |
|
| 883 | + // load, register, and add shortcodes the new way |
|
| 884 | + $this->loader->getShared( |
|
| 885 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager', |
|
| 886 | + array( |
|
| 887 | + // and the old way, but we'll put it under control of the new system |
|
| 888 | + EE_Config::getLegacyShortcodesManager() |
|
| 889 | + ) |
|
| 890 | + ); |
|
| 891 | + } catch (Exception $exception) { |
|
| 892 | + new ExceptionStackTraceDisplay($exception); |
|
| 893 | + } |
|
| 894 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 895 | + // check for addons using old hook point |
|
| 896 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 897 | + $this->_incompatible_addon_error(); |
|
| 898 | + } |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + |
|
| 902 | + |
|
| 903 | + /** |
|
| 904 | + * _incompatible_addon_error |
|
| 905 | + * |
|
| 906 | + * @access public |
|
| 907 | + * @return void |
|
| 908 | + */ |
|
| 909 | + private function _incompatible_addon_error() |
|
| 910 | + { |
|
| 911 | + // get array of classes hooking into here |
|
| 912 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
| 913 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
| 914 | + ); |
|
| 915 | + if (! empty($class_names)) { |
|
| 916 | + $msg = __( |
|
| 917 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
| 918 | + 'event_espresso' |
|
| 919 | + ); |
|
| 920 | + $msg .= '<ul>'; |
|
| 921 | + foreach ($class_names as $class_name) { |
|
| 922 | + $msg .= '<li><b>Event Espresso - ' . str_replace( |
|
| 923 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '', |
|
| 924 | + $class_name |
|
| 925 | + ) . '</b></li>'; |
|
| 926 | + } |
|
| 927 | + $msg .= '</ul>'; |
|
| 928 | + $msg .= __( |
|
| 929 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
| 930 | + 'event_espresso' |
|
| 931 | + ); |
|
| 932 | + // save list of incompatible addons to wp-options for later use |
|
| 933 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 934 | + if (is_admin()) { |
|
| 935 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 936 | + } |
|
| 937 | + } |
|
| 938 | + } |
|
| 939 | + |
|
| 940 | + |
|
| 941 | + |
|
| 942 | + /** |
|
| 943 | + * brew_espresso |
|
| 944 | + * begins the process of setting hooks for initializing EE in the correct order |
|
| 945 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
| 946 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
| 947 | + * |
|
| 948 | + * @return void |
|
| 949 | + */ |
|
| 950 | + public function brew_espresso() |
|
| 951 | + { |
|
| 952 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 953 | + // load some final core systems |
|
| 954 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 955 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
| 956 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 957 | + add_action('init', array($this, 'load_controllers'), 7); |
|
| 958 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 959 | + add_action('init', array($this, 'initialize'), 10); |
|
| 960 | + add_action('init', array($this, 'initialize_last'), 100); |
|
| 961 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 962 | + // pew pew pew |
|
| 963 | + $this->loader->getShared('EE_PUE'); |
|
| 964 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 965 | + } |
|
| 966 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 967 | + } |
|
| 968 | + |
|
| 969 | + |
|
| 970 | + |
|
| 971 | + /** |
|
| 972 | + * set_hooks_for_core |
|
| 973 | + * |
|
| 974 | + * @access public |
|
| 975 | + * @return void |
|
| 976 | + * @throws EE_Error |
|
| 977 | + */ |
|
| 978 | + public function set_hooks_for_core() |
|
| 979 | + { |
|
| 980 | + $this->_deactivate_incompatible_addons(); |
|
| 981 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 982 | + //caps need to be initialized on every request so that capability maps are set. |
|
| 983 | + //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
| 984 | + $this->registry->CAP->init_caps(); |
|
| 985 | + } |
|
| 986 | + |
|
| 987 | + |
|
| 988 | + |
|
| 989 | + /** |
|
| 990 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
| 991 | + * deactivates any addons considered incompatible with the current version of EE |
|
| 992 | + */ |
|
| 993 | + private function _deactivate_incompatible_addons() |
|
| 994 | + { |
|
| 995 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
| 996 | + if (! empty($incompatible_addons)) { |
|
| 997 | + $active_plugins = get_option('active_plugins', array()); |
|
| 998 | + foreach ($active_plugins as $active_plugin) { |
|
| 999 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
| 1000 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
| 1001 | + unset($_GET['activate']); |
|
| 1002 | + espresso_deactivate_plugin($active_plugin); |
|
| 1003 | + } |
|
| 1004 | + } |
|
| 1005 | + } |
|
| 1006 | + } |
|
| 1007 | + } |
|
| 1008 | + |
|
| 1009 | + |
|
| 1010 | + |
|
| 1011 | + /** |
|
| 1012 | + * perform_activations_upgrades_and_migrations |
|
| 1013 | + * |
|
| 1014 | + * @access public |
|
| 1015 | + * @return void |
|
| 1016 | + */ |
|
| 1017 | + public function perform_activations_upgrades_and_migrations() |
|
| 1018 | + { |
|
| 1019 | + //first check if we had previously attempted to setup EE's directories but failed |
|
| 1020 | + if (EEH_Activation::upload_directories_incomplete()) { |
|
| 1021 | + EEH_Activation::create_upload_directories(); |
|
| 1022 | + } |
|
| 1023 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 1024 | + } |
|
| 1025 | + |
|
| 1026 | + |
|
| 1027 | + |
|
| 1028 | + /** |
|
| 1029 | + * load_CPTs_and_session |
|
| 1030 | + * |
|
| 1031 | + * @access public |
|
| 1032 | + * @return void |
|
| 1033 | + */ |
|
| 1034 | + public function load_CPTs_and_session() |
|
| 1035 | + { |
|
| 1036 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 1037 | + // register Custom Post Types |
|
| 1038 | + $this->loader->getShared('EE_Register_CPTs'); |
|
| 1039 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 1040 | + } |
|
| 1041 | + |
|
| 1042 | + |
|
| 1043 | + |
|
| 1044 | + /** |
|
| 1045 | + * load_controllers |
|
| 1046 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
| 1047 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
| 1048 | + * time |
|
| 1049 | + * |
|
| 1050 | + * @access public |
|
| 1051 | + * @return void |
|
| 1052 | + */ |
|
| 1053 | + public function load_controllers() |
|
| 1054 | + { |
|
| 1055 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
| 1056 | + // let's get it started |
|
| 1057 | + if (! is_admin() && ! $this->maintenance_mode->level()) { |
|
| 1058 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 1059 | + $this->loader->getShared('EE_Front_Controller'); |
|
| 1060 | + } else if (! EE_FRONT_AJAX) { |
|
| 1061 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 1062 | + $this->loader->getShared('EE_Admin'); |
|
| 1063 | + } |
|
| 1064 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 1065 | + } |
|
| 1066 | + |
|
| 1067 | + |
|
| 1068 | + |
|
| 1069 | + /** |
|
| 1070 | + * core_loaded_and_ready |
|
| 1071 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
| 1072 | + * |
|
| 1073 | + * @access public |
|
| 1074 | + * @return void |
|
| 1075 | + */ |
|
| 1076 | + public function core_loaded_and_ready() |
|
| 1077 | + { |
|
| 1078 | + $this->loader->getShared('EE_Session'); |
|
| 1079 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 1080 | + // load_espresso_template_tags |
|
| 1081 | + if (is_readable(EE_PUBLIC . 'template_tags.php')) { |
|
| 1082 | + require_once(EE_PUBLIC . 'template_tags.php'); |
|
| 1083 | + } |
|
| 1084 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 1085 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 1086 | + } |
|
| 1087 | + |
|
| 1088 | + |
|
| 1089 | + |
|
| 1090 | + /** |
|
| 1091 | + * initialize |
|
| 1092 | + * this is the best place to begin initializing client code |
|
| 1093 | + * |
|
| 1094 | + * @access public |
|
| 1095 | + * @return void |
|
| 1096 | + */ |
|
| 1097 | + public function initialize() |
|
| 1098 | + { |
|
| 1099 | + do_action('AHEE__EE_System__initialize'); |
|
| 1100 | + } |
|
| 1101 | + |
|
| 1102 | + |
|
| 1103 | + |
|
| 1104 | + /** |
|
| 1105 | + * initialize_last |
|
| 1106 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
| 1107 | + * initialize has done so |
|
| 1108 | + * |
|
| 1109 | + * @access public |
|
| 1110 | + * @return void |
|
| 1111 | + */ |
|
| 1112 | + public function initialize_last() |
|
| 1113 | + { |
|
| 1114 | + do_action('AHEE__EE_System__initialize_last'); |
|
| 1115 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
| 1116 | + } |
|
| 1117 | + |
|
| 1118 | + |
|
| 1119 | + |
|
| 1120 | + /** |
|
| 1121 | + * @return void |
|
| 1122 | + * @throws EE_Error |
|
| 1123 | + */ |
|
| 1124 | + public function addEspressoToolbar() |
|
| 1125 | + { |
|
| 1126 | + $this->loader->getShared( |
|
| 1127 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
| 1128 | + array($this->registry->CAP) |
|
| 1129 | + ); |
|
| 1130 | + } |
|
| 1131 | + |
|
| 1132 | + |
|
| 1133 | + |
|
| 1134 | + /** |
|
| 1135 | + * do_not_cache |
|
| 1136 | + * sets no cache headers and defines no cache constants for WP plugins |
|
| 1137 | + * |
|
| 1138 | + * @access public |
|
| 1139 | + * @return void |
|
| 1140 | + */ |
|
| 1141 | + public static function do_not_cache() |
|
| 1142 | + { |
|
| 1143 | + // set no cache constants |
|
| 1144 | + if (! defined('DONOTCACHEPAGE')) { |
|
| 1145 | + define('DONOTCACHEPAGE', true); |
|
| 1146 | + } |
|
| 1147 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
| 1148 | + define('DONOTCACHCEOBJECT', true); |
|
| 1149 | + } |
|
| 1150 | + if (! defined('DONOTCACHEDB')) { |
|
| 1151 | + define('DONOTCACHEDB', true); |
|
| 1152 | + } |
|
| 1153 | + // add no cache headers |
|
| 1154 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 1155 | + // plus a little extra for nginx and Google Chrome |
|
| 1156 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 1157 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
| 1158 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 1159 | + } |
|
| 1160 | + |
|
| 1161 | + |
|
| 1162 | + |
|
| 1163 | + /** |
|
| 1164 | + * extra_nocache_headers |
|
| 1165 | + * |
|
| 1166 | + * @access public |
|
| 1167 | + * @param $headers |
|
| 1168 | + * @return array |
|
| 1169 | + */ |
|
| 1170 | + public static function extra_nocache_headers($headers) |
|
| 1171 | + { |
|
| 1172 | + // for NGINX |
|
| 1173 | + $headers['X-Accel-Expires'] = 0; |
|
| 1174 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
| 1175 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
| 1176 | + return $headers; |
|
| 1177 | + } |
|
| 1178 | + |
|
| 1179 | + |
|
| 1180 | + |
|
| 1181 | + /** |
|
| 1182 | + * nocache_headers |
|
| 1183 | + * |
|
| 1184 | + * @access public |
|
| 1185 | + * @return void |
|
| 1186 | + */ |
|
| 1187 | + public static function nocache_headers() |
|
| 1188 | + { |
|
| 1189 | + nocache_headers(); |
|
| 1190 | + } |
|
| 1191 | + |
|
| 1192 | + |
|
| 1193 | + |
|
| 1194 | + |
|
| 1195 | + /** |
|
| 1196 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
| 1197 | + * never returned with the function. |
|
| 1198 | + * |
|
| 1199 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
| 1200 | + * @return array |
|
| 1201 | + */ |
|
| 1202 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
| 1203 | + { |
|
| 1204 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 1205 | + } |
|
| 1206 | 1206 | |
| 1207 | 1207 | |
| 1208 | 1208 | |
@@ -8,646 +8,646 @@ |
||
| 8 | 8 | class EE_Email_messenger extends EE_messenger |
| 9 | 9 | { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * To field for email |
|
| 13 | - * @var string |
|
| 14 | - */ |
|
| 15 | - protected $_to = ''; |
|
| 16 | - |
|
| 17 | - |
|
| 18 | - /** |
|
| 19 | - * CC field for email. |
|
| 20 | - * @var string |
|
| 21 | - */ |
|
| 22 | - protected $_cc = ''; |
|
| 23 | - |
|
| 24 | - /** |
|
| 25 | - * From field for email |
|
| 26 | - * @var string |
|
| 27 | - */ |
|
| 28 | - protected $_from = ''; |
|
| 29 | - |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * Subject field for email |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - protected $_subject = ''; |
|
| 36 | - |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Content field for email |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - protected $_content = ''; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * constructor |
|
| 47 | - * |
|
| 48 | - * @access public |
|
| 49 | - */ |
|
| 50 | - public function __construct() |
|
| 51 | - { |
|
| 52 | - //set name and description properties |
|
| 53 | - $this->name = 'email'; |
|
| 54 | - $this->description = sprintf( |
|
| 55 | - esc_html__( |
|
| 56 | - 'This messenger delivers messages via email using the built-in %s function included with WordPress', |
|
| 57 | - 'event_espresso' |
|
| 58 | - ), |
|
| 59 | - '<code>wp_mail</code>' |
|
| 60 | - ); |
|
| 61 | - $this->label = array( |
|
| 62 | - 'singular' => esc_html__('email', 'event_espresso'), |
|
| 63 | - 'plural' => esc_html__('emails', 'event_espresso'), |
|
| 64 | - ); |
|
| 65 | - $this->activate_on_install = true; |
|
| 66 | - |
|
| 67 | - //we're using defaults so let's call parent constructor that will take care of setting up all the other |
|
| 68 | - // properties |
|
| 69 | - parent::__construct(); |
|
| 70 | - } |
|
| 71 | - |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * see abstract declaration in parent class for details. |
|
| 75 | - */ |
|
| 76 | - protected function _set_admin_pages() |
|
| 77 | - { |
|
| 78 | - $this->admin_registered_pages = array( |
|
| 79 | - 'events_edit' => true, |
|
| 80 | - ); |
|
| 81 | - } |
|
| 82 | - |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * see abstract declaration in parent class for details |
|
| 86 | - */ |
|
| 87 | - protected function _set_valid_shortcodes() |
|
| 88 | - { |
|
| 89 | - //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the |
|
| 90 | - // message type. |
|
| 91 | - $this->_valid_shortcodes = array( |
|
| 92 | - 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
| 93 | - 'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
| 94 | - 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
| 95 | - ); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * see abstract declaration in parent class for details |
|
| 101 | - * |
|
| 102 | - * @access protected |
|
| 103 | - * @return void |
|
| 104 | - */ |
|
| 105 | - protected function _set_validator_config() |
|
| 106 | - { |
|
| 107 | - $valid_shortcodes = $this->get_valid_shortcodes(); |
|
| 108 | - |
|
| 109 | - $this->_validator_config = array( |
|
| 110 | - 'to' => array( |
|
| 111 | - 'shortcodes' => $valid_shortcodes['to'], |
|
| 112 | - 'type' => 'email', |
|
| 113 | - ), |
|
| 114 | - 'cc' => array( |
|
| 115 | - 'shortcodes' => $valid_shortcodes['to'], |
|
| 116 | - 'type' => 'email', |
|
| 117 | - ), |
|
| 118 | - 'from' => array( |
|
| 119 | - 'shortcodes' => $valid_shortcodes['from'], |
|
| 120 | - 'type' => 'email', |
|
| 121 | - ), |
|
| 122 | - 'subject' => array( |
|
| 123 | - 'shortcodes' => array( |
|
| 124 | - 'organization', |
|
| 125 | - 'primary_registration_details', |
|
| 126 | - 'event_author', |
|
| 127 | - 'primary_registration_details', |
|
| 128 | - 'recipient_details', |
|
| 129 | - ), |
|
| 130 | - ), |
|
| 131 | - 'content' => array( |
|
| 132 | - 'shortcodes' => array( |
|
| 133 | - 'event_list', |
|
| 134 | - 'attendee_list', |
|
| 135 | - 'ticket_list', |
|
| 136 | - 'organization', |
|
| 137 | - 'primary_registration_details', |
|
| 138 | - 'primary_registration_list', |
|
| 139 | - 'event_author', |
|
| 140 | - 'recipient_details', |
|
| 141 | - 'recipient_list', |
|
| 142 | - 'transaction', |
|
| 143 | - 'messenger', |
|
| 144 | - ), |
|
| 145 | - ), |
|
| 146 | - 'attendee_list' => array( |
|
| 147 | - 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
| 148 | - 'required' => array('[ATTENDEE_LIST]'), |
|
| 149 | - ), |
|
| 150 | - 'event_list' => array( |
|
| 151 | - 'shortcodes' => array( |
|
| 152 | - 'event', |
|
| 153 | - 'attendee_list', |
|
| 154 | - 'ticket_list', |
|
| 155 | - 'venue', |
|
| 156 | - 'datetime_list', |
|
| 157 | - 'attendee', |
|
| 158 | - 'primary_registration_details', |
|
| 159 | - 'primary_registration_list', |
|
| 160 | - 'event_author', |
|
| 161 | - 'recipient_details', |
|
| 162 | - 'recipient_list', |
|
| 163 | - ), |
|
| 164 | - 'required' => array('[EVENT_LIST]'), |
|
| 165 | - ), |
|
| 166 | - 'ticket_list' => array( |
|
| 167 | - 'shortcodes' => array( |
|
| 168 | - 'event_list', |
|
| 169 | - 'attendee_list', |
|
| 170 | - 'ticket', |
|
| 171 | - 'datetime_list', |
|
| 172 | - 'primary_registration_details', |
|
| 173 | - 'recipient_details', |
|
| 174 | - ), |
|
| 175 | - 'required' => array('[TICKET_LIST]'), |
|
| 176 | - ), |
|
| 177 | - 'datetime_list' => array( |
|
| 178 | - 'shortcodes' => array('datetime'), |
|
| 179 | - 'required' => array('[DATETIME_LIST]'), |
|
| 180 | - ), |
|
| 181 | - ); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - |
|
| 185 | - /** |
|
| 186 | - * @see parent EE_messenger class for docs |
|
| 187 | - * @since 4.5.0 |
|
| 188 | - */ |
|
| 189 | - public function do_secondary_messenger_hooks($sending_messenger_name) |
|
| 190 | - { |
|
| 191 | - if ($sending_messenger_name = 'html') { |
|
| 192 | - add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
| 193 | - } |
|
| 194 | - } |
|
| 195 | - |
|
| 196 | - |
|
| 197 | - public function add_email_css( |
|
| 198 | - $variation_path, |
|
| 199 | - $messenger, |
|
| 200 | - $message_type, |
|
| 201 | - $type, |
|
| 202 | - $variation, |
|
| 203 | - $file_extension, |
|
| 204 | - $url, |
|
| 205 | - EE_Messages_Template_Pack $template_pack |
|
| 206 | - ) { |
|
| 207 | - //prevent recursion on this callback. |
|
| 208 | - remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
| 209 | - $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false); |
|
| 210 | - |
|
| 211 | - add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
| 212 | - return $variation; |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * See parent for details |
|
| 218 | - * |
|
| 219 | - * @access protected |
|
| 220 | - * @return void |
|
| 221 | - */ |
|
| 222 | - protected function _set_test_settings_fields() |
|
| 223 | - { |
|
| 224 | - $this->_test_settings_fields = array( |
|
| 225 | - 'to' => array( |
|
| 226 | - 'input' => 'text', |
|
| 227 | - 'label' => esc_html__('Send a test email to', 'event_espresso'), |
|
| 228 | - 'type' => 'email', |
|
| 229 | - 'required' => true, |
|
| 230 | - 'validation' => true, |
|
| 231 | - 'css_class' => 'large-text', |
|
| 232 | - 'format' => '%s', |
|
| 233 | - 'default' => get_bloginfo('admin_email'), |
|
| 234 | - ), |
|
| 235 | - 'subject' => array( |
|
| 236 | - 'input' => 'hidden', |
|
| 237 | - 'label' => '', |
|
| 238 | - 'type' => 'string', |
|
| 239 | - 'required' => false, |
|
| 240 | - 'validation' => false, |
|
| 241 | - 'format' => '%s', |
|
| 242 | - 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
| 243 | - 'default' => '', |
|
| 244 | - 'css_class' => '', |
|
| 245 | - ), |
|
| 246 | - ); |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * _set_template_fields |
|
| 252 | - * This sets up the fields that a messenger requires for the message to go out. |
|
| 253 | - * |
|
| 254 | - * @access protected |
|
| 255 | - * @return void |
|
| 256 | - */ |
|
| 257 | - protected function _set_template_fields() |
|
| 258 | - { |
|
| 259 | - // any extra template fields that are NOT used by the messenger but will get used by a messenger field for |
|
| 260 | - // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field |
|
| 261 | - // they relate to. This is important for the Messages_admin to know what fields to display to the user. |
|
| 262 | - // Also, notice that the "values" are equal to the field type that messages admin will use to know what |
|
| 263 | - // kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array |
|
| 264 | - // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be |
|
| 265 | - // displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and |
|
| 266 | - // will not be displayed/parsed. |
|
| 267 | - $this->_template_fields = array( |
|
| 268 | - 'to' => array( |
|
| 269 | - 'input' => 'text', |
|
| 270 | - 'label' => esc_html_x( |
|
| 271 | - 'To', |
|
| 272 | - 'Label for the "To" field for email addresses', |
|
| 273 | - 'event_espresso' |
|
| 274 | - ), |
|
| 275 | - 'type' => 'string', |
|
| 276 | - 'required' => true, |
|
| 277 | - 'validation' => true, |
|
| 278 | - 'css_class' => 'large-text', |
|
| 279 | - 'format' => '%s', |
|
| 280 | - ), |
|
| 281 | - 'cc' => array( |
|
| 282 | - 'input' => 'text', |
|
| 283 | - 'label' => esc_html_x( |
|
| 284 | - 'CC', |
|
| 285 | - 'Label for the "Carbon Copy" field used for additional email addresses', |
|
| 286 | - 'event_espresso' |
|
| 287 | - ), |
|
| 288 | - 'type' => 'string', |
|
| 289 | - 'required' => false, |
|
| 290 | - 'validation' => true, |
|
| 291 | - 'css_class' => 'large-text', |
|
| 292 | - 'format' => '%s', |
|
| 293 | - ), |
|
| 294 | - 'from' => array( |
|
| 295 | - 'input' => 'text', |
|
| 296 | - 'label' => esc_html_x( |
|
| 297 | - 'From', |
|
| 298 | - 'Label for the "From" field for email addresses.', |
|
| 299 | - 'event_espresso' |
|
| 300 | - ), |
|
| 301 | - 'type' => 'string', |
|
| 302 | - 'required' => true, |
|
| 303 | - 'validation' => true, |
|
| 304 | - 'css_class' => 'large-text', |
|
| 305 | - 'format' => '%s', |
|
| 306 | - ), |
|
| 307 | - 'subject' => array( |
|
| 308 | - 'input' => 'text', |
|
| 309 | - 'label' => esc_html_x( |
|
| 310 | - 'Subject', |
|
| 311 | - 'Label for the "Subject" field (short description of contents) for emails.', |
|
| 312 | - 'event_espresso' |
|
| 313 | - ), |
|
| 314 | - 'type' => 'string', |
|
| 315 | - 'required' => true, |
|
| 316 | - 'validation' => true, |
|
| 317 | - 'css_class' => 'large-text', |
|
| 318 | - 'format' => '%s', |
|
| 319 | - ), |
|
| 320 | - 'content' => '', |
|
| 321 | - //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
| 322 | - 'extra' => array( |
|
| 323 | - 'content' => array( |
|
| 324 | - 'main' => array( |
|
| 325 | - 'input' => 'wp_editor', |
|
| 326 | - 'label' => esc_html__('Main Content', 'event_espresso'), |
|
| 327 | - 'type' => 'string', |
|
| 328 | - 'required' => true, |
|
| 329 | - 'validation' => true, |
|
| 330 | - 'format' => '%s', |
|
| 331 | - 'rows' => '15', |
|
| 332 | - ), |
|
| 333 | - 'event_list' => array( |
|
| 334 | - 'input' => 'wp_editor', |
|
| 335 | - 'label' => '[EVENT_LIST]', |
|
| 336 | - 'type' => 'string', |
|
| 337 | - 'required' => true, |
|
| 338 | - 'validation' => true, |
|
| 339 | - 'format' => '%s', |
|
| 340 | - 'rows' => '15', |
|
| 341 | - 'shortcodes_required' => array('[EVENT_LIST]'), |
|
| 342 | - ), |
|
| 343 | - 'attendee_list' => array( |
|
| 344 | - 'input' => 'textarea', |
|
| 345 | - 'label' => '[ATTENDEE_LIST]', |
|
| 346 | - 'type' => 'string', |
|
| 347 | - 'required' => true, |
|
| 348 | - 'validation' => true, |
|
| 349 | - 'format' => '%s', |
|
| 350 | - 'css_class' => 'large-text', |
|
| 351 | - 'rows' => '5', |
|
| 352 | - 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
| 353 | - ), |
|
| 354 | - 'ticket_list' => array( |
|
| 355 | - 'input' => 'textarea', |
|
| 356 | - 'label' => '[TICKET_LIST]', |
|
| 357 | - 'type' => 'string', |
|
| 358 | - 'required' => true, |
|
| 359 | - 'validation' => true, |
|
| 360 | - 'format' => '%s', |
|
| 361 | - 'css_class' => 'large-text', |
|
| 362 | - 'rows' => '10', |
|
| 363 | - 'shortcodes_required' => array('[TICKET_LIST]'), |
|
| 364 | - ), |
|
| 365 | - 'datetime_list' => array( |
|
| 366 | - 'input' => 'textarea', |
|
| 367 | - 'label' => '[DATETIME_LIST]', |
|
| 368 | - 'type' => 'string', |
|
| 369 | - 'required' => true, |
|
| 370 | - 'validation' => true, |
|
| 371 | - 'format' => '%s', |
|
| 372 | - 'css_class' => 'large-text', |
|
| 373 | - 'rows' => '10', |
|
| 374 | - 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
| 375 | - ), |
|
| 376 | - ), |
|
| 377 | - ), |
|
| 378 | - ); |
|
| 379 | - } |
|
| 380 | - |
|
| 381 | - |
|
| 382 | - /** |
|
| 383 | - * See definition of this class in parent |
|
| 384 | - */ |
|
| 385 | - protected function _set_default_message_types() |
|
| 386 | - { |
|
| 387 | - $this->_default_message_types = array( |
|
| 388 | - 'payment', |
|
| 389 | - 'payment_refund', |
|
| 390 | - 'registration', |
|
| 391 | - 'not_approved_registration', |
|
| 392 | - 'pending_approval', |
|
| 393 | - ); |
|
| 394 | - } |
|
| 395 | - |
|
| 396 | - |
|
| 397 | - /** |
|
| 398 | - * @see definition of this class in parent |
|
| 399 | - * @since 4.5.0 |
|
| 400 | - */ |
|
| 401 | - protected function _set_valid_message_types() |
|
| 402 | - { |
|
| 403 | - $this->_valid_message_types = array( |
|
| 404 | - 'payment', |
|
| 405 | - 'registration', |
|
| 406 | - 'not_approved_registration', |
|
| 407 | - 'declined_registration', |
|
| 408 | - 'cancelled_registration', |
|
| 409 | - 'pending_approval', |
|
| 410 | - 'registration_summary', |
|
| 411 | - 'payment_reminder', |
|
| 412 | - 'payment_declined', |
|
| 413 | - 'payment_refund', |
|
| 414 | - ); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - |
|
| 418 | - /** |
|
| 419 | - * setting up admin_settings_fields for messenger. |
|
| 420 | - */ |
|
| 421 | - protected function _set_admin_settings_fields() |
|
| 422 | - { |
|
| 423 | - } |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * We just deliver the messages don't kill us!! |
|
| 427 | - * |
|
| 428 | - * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if |
|
| 429 | - * present. |
|
| 430 | - * @throws EE_Error |
|
| 431 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
| 432 | - */ |
|
| 433 | - protected function _send_message() |
|
| 434 | - { |
|
| 435 | - $success = wp_mail( |
|
| 436 | - html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"), |
|
| 437 | - stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")), |
|
| 438 | - $this->_body(), |
|
| 439 | - $this->_headers() |
|
| 440 | - ); |
|
| 441 | - if (! $success) { |
|
| 442 | - EE_Error::add_error( |
|
| 443 | - sprintf( |
|
| 444 | - esc_html__( |
|
| 445 | - 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', |
|
| 446 | - 'event_espresso' |
|
| 447 | - ), |
|
| 448 | - $this->_to, |
|
| 449 | - $this->_from, |
|
| 450 | - '<br />' |
|
| 451 | - ), |
|
| 452 | - __FILE__, |
|
| 453 | - __FUNCTION__, |
|
| 454 | - __LINE__ |
|
| 455 | - ); |
|
| 456 | - } |
|
| 457 | - return $success; |
|
| 458 | - } |
|
| 459 | - |
|
| 460 | - |
|
| 461 | - /** |
|
| 462 | - * see parent for definition |
|
| 463 | - * |
|
| 464 | - * @return string html body of the message content and the related css. |
|
| 465 | - * @throws EE_Error |
|
| 466 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
| 467 | - */ |
|
| 468 | - protected function _preview() |
|
| 469 | - { |
|
| 470 | - return $this->_body(true); |
|
| 471 | - } |
|
| 472 | - |
|
| 473 | - |
|
| 474 | - /** |
|
| 475 | - * Setup headers for email |
|
| 476 | - * |
|
| 477 | - * @access protected |
|
| 478 | - * @return string formatted header for email |
|
| 479 | - */ |
|
| 480 | - protected function _headers() |
|
| 481 | - { |
|
| 482 | - $this->_ensure_has_from_email_address(); |
|
| 483 | - $from = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8")); |
|
| 484 | - $headers = array( |
|
| 485 | - 'MIME-Version: 1.0', |
|
| 486 | - 'From:' . $from, |
|
| 487 | - 'Reply-To:' . $from, |
|
| 488 | - 'Content-Type:text/html; charset=utf-8', |
|
| 489 | - ); |
|
| 490 | - |
|
| 491 | - if (! empty($this->_cc)) { |
|
| 492 | - $headers[] = 'cc: ' . $this->_cc; |
|
| 493 | - } |
|
| 494 | - |
|
| 495 | - //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
|
| 496 | - // header. |
|
| 497 | - add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
| 498 | - add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
| 499 | - return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
| 500 | - } |
|
| 501 | - |
|
| 502 | - |
|
| 503 | - /** |
|
| 504 | - * This simply ensures that the from address is not empty. If it is, then we use whatever is set as the site email |
|
| 505 | - * address for the from address to avoid problems with sending emails. |
|
| 506 | - */ |
|
| 507 | - protected function _ensure_has_from_email_address() |
|
| 508 | - { |
|
| 509 | - if (empty($this->_from)) { |
|
| 510 | - $this->_from = get_bloginfo('admin_email'); |
|
| 511 | - } |
|
| 512 | - } |
|
| 513 | - |
|
| 514 | - |
|
| 515 | - /** |
|
| 516 | - * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}> |
|
| 517 | - * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY* |
|
| 518 | - * be empty |
|
| 519 | - * |
|
| 520 | - * @since 4.3.1 |
|
| 521 | - * @return array |
|
| 522 | - */ |
|
| 523 | - private function _parse_from() |
|
| 524 | - { |
|
| 525 | - if (strpos($this->_from, '<') !== false) { |
|
| 526 | - $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
| 527 | - $from_name = str_replace('"', '', $from_name); |
|
| 528 | - $from_name = trim($from_name); |
|
| 529 | - |
|
| 530 | - $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
| 531 | - $from_email = str_replace('>', '', $from_email); |
|
| 532 | - $from_email = trim($from_email); |
|
| 533 | - } elseif (trim($this->_from) !== '') { |
|
| 534 | - $from_name = ''; |
|
| 535 | - $from_email = trim($this->_from); |
|
| 536 | - } else { |
|
| 537 | - $from_name = $from_email = ''; |
|
| 538 | - } |
|
| 539 | - return array($from_name, $from_email); |
|
| 540 | - } |
|
| 541 | - |
|
| 542 | - |
|
| 543 | - /** |
|
| 544 | - * Callback for the wp_mail_from filter. |
|
| 545 | - * |
|
| 546 | - * @since 4.3.1 |
|
| 547 | - * @param string $from_email What the original from_email is. |
|
| 548 | - * @return string |
|
| 549 | - */ |
|
| 550 | - public function set_from_address($from_email) |
|
| 551 | - { |
|
| 552 | - $parsed_from = $this->_parse_from(); |
|
| 553 | - //includes fallback if the parsing failed. |
|
| 554 | - $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) |
|
| 555 | - ? $parsed_from[1] |
|
| 556 | - : get_bloginfo('admin_email'); |
|
| 557 | - return $from_email; |
|
| 558 | - } |
|
| 559 | - |
|
| 560 | - |
|
| 561 | - /** |
|
| 562 | - * Callback fro the wp_mail_from_name filter. |
|
| 563 | - * |
|
| 564 | - * @since 4.3.1 |
|
| 565 | - * @param string $from_name The original from_name. |
|
| 566 | - * @return string |
|
| 567 | - */ |
|
| 568 | - public function set_from_name($from_name) |
|
| 569 | - { |
|
| 570 | - $parsed_from = $this->_parse_from(); |
|
| 571 | - if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
| 572 | - $from_name = $parsed_from[0]; |
|
| 573 | - } |
|
| 574 | - |
|
| 575 | - //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
|
| 576 | - $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name; |
|
| 577 | - |
|
| 578 | - return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8")); |
|
| 579 | - } |
|
| 580 | - |
|
| 581 | - |
|
| 582 | - /** |
|
| 583 | - * setup body for email |
|
| 584 | - * |
|
| 585 | - * @param bool $preview will determine whether this is preview template or not. |
|
| 586 | - * @return string formatted body for email. |
|
| 587 | - * @throws EE_Error |
|
| 588 | - * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
| 589 | - */ |
|
| 590 | - protected function _body($preview = false) |
|
| 591 | - { |
|
| 592 | - //setup template args! |
|
| 593 | - $this->_template_args = array( |
|
| 594 | - 'subject' => $this->_subject, |
|
| 595 | - 'from' => $this->_from, |
|
| 596 | - 'main_body' => wpautop( |
|
| 597 | - stripslashes_deep( |
|
| 598 | - html_entity_decode($this->_content, ENT_QUOTES, "UTF-8") |
|
| 599 | - ) |
|
| 600 | - ), |
|
| 601 | - ); |
|
| 602 | - $body = $this->_get_main_template($preview); |
|
| 603 | - |
|
| 604 | - /** |
|
| 605 | - * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
|
| 606 | - * |
|
| 607 | - * @type bool $preview Indicates whether a preview is being generated or not. |
|
| 608 | - * @return bool true indicates to use the inliner, false bypasses it. |
|
| 609 | - */ |
|
| 610 | - if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
| 611 | - //require CssToInlineStyles library and its dependencies via composer autoloader |
|
| 612 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
| 613 | - |
|
| 614 | - //now if this isn't a preview, let's setup the body so it has inline styles |
|
| 615 | - if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
| 616 | - $style = file_get_contents( |
|
| 617 | - $this->get_variation( |
|
| 618 | - $this->_tmp_pack, |
|
| 619 | - $this->_incoming_message_type->name, |
|
| 620 | - false, |
|
| 621 | - 'main', |
|
| 622 | - $this->_variation |
|
| 623 | - ), |
|
| 624 | - true |
|
| 625 | - ); |
|
| 626 | - $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
| 627 | - //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
| 628 | - $body = ltrim($CSS->convert(true), ">\n"); |
|
| 629 | - //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
| 630 | - $body = ltrim($body, "<?"); |
|
| 631 | - } |
|
| 632 | - |
|
| 633 | - } |
|
| 634 | - return $body; |
|
| 635 | - } |
|
| 636 | - |
|
| 637 | - |
|
| 638 | - /** |
|
| 639 | - * This just returns any existing test settings that might be saved in the database |
|
| 640 | - * |
|
| 641 | - * @access public |
|
| 642 | - * @return array |
|
| 643 | - */ |
|
| 644 | - public function get_existing_test_settings() |
|
| 645 | - { |
|
| 646 | - $settings = parent::get_existing_test_settings(); |
|
| 647 | - //override subject if present because we always want it to be fresh. |
|
| 648 | - if (is_array($settings) && ! empty($settings['subject'])) { |
|
| 649 | - $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
| 650 | - } |
|
| 651 | - return $settings; |
|
| 652 | - } |
|
| 11 | + /** |
|
| 12 | + * To field for email |
|
| 13 | + * @var string |
|
| 14 | + */ |
|
| 15 | + protected $_to = ''; |
|
| 16 | + |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | + * CC field for email. |
|
| 20 | + * @var string |
|
| 21 | + */ |
|
| 22 | + protected $_cc = ''; |
|
| 23 | + |
|
| 24 | + /** |
|
| 25 | + * From field for email |
|
| 26 | + * @var string |
|
| 27 | + */ |
|
| 28 | + protected $_from = ''; |
|
| 29 | + |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * Subject field for email |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + protected $_subject = ''; |
|
| 36 | + |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Content field for email |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + protected $_content = ''; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * constructor |
|
| 47 | + * |
|
| 48 | + * @access public |
|
| 49 | + */ |
|
| 50 | + public function __construct() |
|
| 51 | + { |
|
| 52 | + //set name and description properties |
|
| 53 | + $this->name = 'email'; |
|
| 54 | + $this->description = sprintf( |
|
| 55 | + esc_html__( |
|
| 56 | + 'This messenger delivers messages via email using the built-in %s function included with WordPress', |
|
| 57 | + 'event_espresso' |
|
| 58 | + ), |
|
| 59 | + '<code>wp_mail</code>' |
|
| 60 | + ); |
|
| 61 | + $this->label = array( |
|
| 62 | + 'singular' => esc_html__('email', 'event_espresso'), |
|
| 63 | + 'plural' => esc_html__('emails', 'event_espresso'), |
|
| 64 | + ); |
|
| 65 | + $this->activate_on_install = true; |
|
| 66 | + |
|
| 67 | + //we're using defaults so let's call parent constructor that will take care of setting up all the other |
|
| 68 | + // properties |
|
| 69 | + parent::__construct(); |
|
| 70 | + } |
|
| 71 | + |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * see abstract declaration in parent class for details. |
|
| 75 | + */ |
|
| 76 | + protected function _set_admin_pages() |
|
| 77 | + { |
|
| 78 | + $this->admin_registered_pages = array( |
|
| 79 | + 'events_edit' => true, |
|
| 80 | + ); |
|
| 81 | + } |
|
| 82 | + |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * see abstract declaration in parent class for details |
|
| 86 | + */ |
|
| 87 | + protected function _set_valid_shortcodes() |
|
| 88 | + { |
|
| 89 | + //remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the |
|
| 90 | + // message type. |
|
| 91 | + $this->_valid_shortcodes = array( |
|
| 92 | + 'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
| 93 | + 'cc' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
| 94 | + 'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'), |
|
| 95 | + ); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * see abstract declaration in parent class for details |
|
| 101 | + * |
|
| 102 | + * @access protected |
|
| 103 | + * @return void |
|
| 104 | + */ |
|
| 105 | + protected function _set_validator_config() |
|
| 106 | + { |
|
| 107 | + $valid_shortcodes = $this->get_valid_shortcodes(); |
|
| 108 | + |
|
| 109 | + $this->_validator_config = array( |
|
| 110 | + 'to' => array( |
|
| 111 | + 'shortcodes' => $valid_shortcodes['to'], |
|
| 112 | + 'type' => 'email', |
|
| 113 | + ), |
|
| 114 | + 'cc' => array( |
|
| 115 | + 'shortcodes' => $valid_shortcodes['to'], |
|
| 116 | + 'type' => 'email', |
|
| 117 | + ), |
|
| 118 | + 'from' => array( |
|
| 119 | + 'shortcodes' => $valid_shortcodes['from'], |
|
| 120 | + 'type' => 'email', |
|
| 121 | + ), |
|
| 122 | + 'subject' => array( |
|
| 123 | + 'shortcodes' => array( |
|
| 124 | + 'organization', |
|
| 125 | + 'primary_registration_details', |
|
| 126 | + 'event_author', |
|
| 127 | + 'primary_registration_details', |
|
| 128 | + 'recipient_details', |
|
| 129 | + ), |
|
| 130 | + ), |
|
| 131 | + 'content' => array( |
|
| 132 | + 'shortcodes' => array( |
|
| 133 | + 'event_list', |
|
| 134 | + 'attendee_list', |
|
| 135 | + 'ticket_list', |
|
| 136 | + 'organization', |
|
| 137 | + 'primary_registration_details', |
|
| 138 | + 'primary_registration_list', |
|
| 139 | + 'event_author', |
|
| 140 | + 'recipient_details', |
|
| 141 | + 'recipient_list', |
|
| 142 | + 'transaction', |
|
| 143 | + 'messenger', |
|
| 144 | + ), |
|
| 145 | + ), |
|
| 146 | + 'attendee_list' => array( |
|
| 147 | + 'shortcodes' => array('attendee', 'event_list', 'ticket_list'), |
|
| 148 | + 'required' => array('[ATTENDEE_LIST]'), |
|
| 149 | + ), |
|
| 150 | + 'event_list' => array( |
|
| 151 | + 'shortcodes' => array( |
|
| 152 | + 'event', |
|
| 153 | + 'attendee_list', |
|
| 154 | + 'ticket_list', |
|
| 155 | + 'venue', |
|
| 156 | + 'datetime_list', |
|
| 157 | + 'attendee', |
|
| 158 | + 'primary_registration_details', |
|
| 159 | + 'primary_registration_list', |
|
| 160 | + 'event_author', |
|
| 161 | + 'recipient_details', |
|
| 162 | + 'recipient_list', |
|
| 163 | + ), |
|
| 164 | + 'required' => array('[EVENT_LIST]'), |
|
| 165 | + ), |
|
| 166 | + 'ticket_list' => array( |
|
| 167 | + 'shortcodes' => array( |
|
| 168 | + 'event_list', |
|
| 169 | + 'attendee_list', |
|
| 170 | + 'ticket', |
|
| 171 | + 'datetime_list', |
|
| 172 | + 'primary_registration_details', |
|
| 173 | + 'recipient_details', |
|
| 174 | + ), |
|
| 175 | + 'required' => array('[TICKET_LIST]'), |
|
| 176 | + ), |
|
| 177 | + 'datetime_list' => array( |
|
| 178 | + 'shortcodes' => array('datetime'), |
|
| 179 | + 'required' => array('[DATETIME_LIST]'), |
|
| 180 | + ), |
|
| 181 | + ); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + |
|
| 185 | + /** |
|
| 186 | + * @see parent EE_messenger class for docs |
|
| 187 | + * @since 4.5.0 |
|
| 188 | + */ |
|
| 189 | + public function do_secondary_messenger_hooks($sending_messenger_name) |
|
| 190 | + { |
|
| 191 | + if ($sending_messenger_name = 'html') { |
|
| 192 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
| 193 | + } |
|
| 194 | + } |
|
| 195 | + |
|
| 196 | + |
|
| 197 | + public function add_email_css( |
|
| 198 | + $variation_path, |
|
| 199 | + $messenger, |
|
| 200 | + $message_type, |
|
| 201 | + $type, |
|
| 202 | + $variation, |
|
| 203 | + $file_extension, |
|
| 204 | + $url, |
|
| 205 | + EE_Messages_Template_Pack $template_pack |
|
| 206 | + ) { |
|
| 207 | + //prevent recursion on this callback. |
|
| 208 | + remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10); |
|
| 209 | + $variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, false); |
|
| 210 | + |
|
| 211 | + add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8); |
|
| 212 | + return $variation; |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * See parent for details |
|
| 218 | + * |
|
| 219 | + * @access protected |
|
| 220 | + * @return void |
|
| 221 | + */ |
|
| 222 | + protected function _set_test_settings_fields() |
|
| 223 | + { |
|
| 224 | + $this->_test_settings_fields = array( |
|
| 225 | + 'to' => array( |
|
| 226 | + 'input' => 'text', |
|
| 227 | + 'label' => esc_html__('Send a test email to', 'event_espresso'), |
|
| 228 | + 'type' => 'email', |
|
| 229 | + 'required' => true, |
|
| 230 | + 'validation' => true, |
|
| 231 | + 'css_class' => 'large-text', |
|
| 232 | + 'format' => '%s', |
|
| 233 | + 'default' => get_bloginfo('admin_email'), |
|
| 234 | + ), |
|
| 235 | + 'subject' => array( |
|
| 236 | + 'input' => 'hidden', |
|
| 237 | + 'label' => '', |
|
| 238 | + 'type' => 'string', |
|
| 239 | + 'required' => false, |
|
| 240 | + 'validation' => false, |
|
| 241 | + 'format' => '%s', |
|
| 242 | + 'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')), |
|
| 243 | + 'default' => '', |
|
| 244 | + 'css_class' => '', |
|
| 245 | + ), |
|
| 246 | + ); |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * _set_template_fields |
|
| 252 | + * This sets up the fields that a messenger requires for the message to go out. |
|
| 253 | + * |
|
| 254 | + * @access protected |
|
| 255 | + * @return void |
|
| 256 | + */ |
|
| 257 | + protected function _set_template_fields() |
|
| 258 | + { |
|
| 259 | + // any extra template fields that are NOT used by the messenger but will get used by a messenger field for |
|
| 260 | + // shortcode replacement get added to the 'extra' key in an associated array indexed by the messenger field |
|
| 261 | + // they relate to. This is important for the Messages_admin to know what fields to display to the user. |
|
| 262 | + // Also, notice that the "values" are equal to the field type that messages admin will use to know what |
|
| 263 | + // kind of field to display. The values ALSO have one index labeled "shortcode". the values in that array |
|
| 264 | + // indicate which ACTUAL SHORTCODE (i.e. [SHORTCODE]) is required in order for this extra field to be |
|
| 265 | + // displayed. If the required shortcode isn't part of the shortcodes array then the field is not needed and |
|
| 266 | + // will not be displayed/parsed. |
|
| 267 | + $this->_template_fields = array( |
|
| 268 | + 'to' => array( |
|
| 269 | + 'input' => 'text', |
|
| 270 | + 'label' => esc_html_x( |
|
| 271 | + 'To', |
|
| 272 | + 'Label for the "To" field for email addresses', |
|
| 273 | + 'event_espresso' |
|
| 274 | + ), |
|
| 275 | + 'type' => 'string', |
|
| 276 | + 'required' => true, |
|
| 277 | + 'validation' => true, |
|
| 278 | + 'css_class' => 'large-text', |
|
| 279 | + 'format' => '%s', |
|
| 280 | + ), |
|
| 281 | + 'cc' => array( |
|
| 282 | + 'input' => 'text', |
|
| 283 | + 'label' => esc_html_x( |
|
| 284 | + 'CC', |
|
| 285 | + 'Label for the "Carbon Copy" field used for additional email addresses', |
|
| 286 | + 'event_espresso' |
|
| 287 | + ), |
|
| 288 | + 'type' => 'string', |
|
| 289 | + 'required' => false, |
|
| 290 | + 'validation' => true, |
|
| 291 | + 'css_class' => 'large-text', |
|
| 292 | + 'format' => '%s', |
|
| 293 | + ), |
|
| 294 | + 'from' => array( |
|
| 295 | + 'input' => 'text', |
|
| 296 | + 'label' => esc_html_x( |
|
| 297 | + 'From', |
|
| 298 | + 'Label for the "From" field for email addresses.', |
|
| 299 | + 'event_espresso' |
|
| 300 | + ), |
|
| 301 | + 'type' => 'string', |
|
| 302 | + 'required' => true, |
|
| 303 | + 'validation' => true, |
|
| 304 | + 'css_class' => 'large-text', |
|
| 305 | + 'format' => '%s', |
|
| 306 | + ), |
|
| 307 | + 'subject' => array( |
|
| 308 | + 'input' => 'text', |
|
| 309 | + 'label' => esc_html_x( |
|
| 310 | + 'Subject', |
|
| 311 | + 'Label for the "Subject" field (short description of contents) for emails.', |
|
| 312 | + 'event_espresso' |
|
| 313 | + ), |
|
| 314 | + 'type' => 'string', |
|
| 315 | + 'required' => true, |
|
| 316 | + 'validation' => true, |
|
| 317 | + 'css_class' => 'large-text', |
|
| 318 | + 'format' => '%s', |
|
| 319 | + ), |
|
| 320 | + 'content' => '', |
|
| 321 | + //left empty b/c it is in the "extra array" but messenger still needs needs to know this is a field. |
|
| 322 | + 'extra' => array( |
|
| 323 | + 'content' => array( |
|
| 324 | + 'main' => array( |
|
| 325 | + 'input' => 'wp_editor', |
|
| 326 | + 'label' => esc_html__('Main Content', 'event_espresso'), |
|
| 327 | + 'type' => 'string', |
|
| 328 | + 'required' => true, |
|
| 329 | + 'validation' => true, |
|
| 330 | + 'format' => '%s', |
|
| 331 | + 'rows' => '15', |
|
| 332 | + ), |
|
| 333 | + 'event_list' => array( |
|
| 334 | + 'input' => 'wp_editor', |
|
| 335 | + 'label' => '[EVENT_LIST]', |
|
| 336 | + 'type' => 'string', |
|
| 337 | + 'required' => true, |
|
| 338 | + 'validation' => true, |
|
| 339 | + 'format' => '%s', |
|
| 340 | + 'rows' => '15', |
|
| 341 | + 'shortcodes_required' => array('[EVENT_LIST]'), |
|
| 342 | + ), |
|
| 343 | + 'attendee_list' => array( |
|
| 344 | + 'input' => 'textarea', |
|
| 345 | + 'label' => '[ATTENDEE_LIST]', |
|
| 346 | + 'type' => 'string', |
|
| 347 | + 'required' => true, |
|
| 348 | + 'validation' => true, |
|
| 349 | + 'format' => '%s', |
|
| 350 | + 'css_class' => 'large-text', |
|
| 351 | + 'rows' => '5', |
|
| 352 | + 'shortcodes_required' => array('[ATTENDEE_LIST]'), |
|
| 353 | + ), |
|
| 354 | + 'ticket_list' => array( |
|
| 355 | + 'input' => 'textarea', |
|
| 356 | + 'label' => '[TICKET_LIST]', |
|
| 357 | + 'type' => 'string', |
|
| 358 | + 'required' => true, |
|
| 359 | + 'validation' => true, |
|
| 360 | + 'format' => '%s', |
|
| 361 | + 'css_class' => 'large-text', |
|
| 362 | + 'rows' => '10', |
|
| 363 | + 'shortcodes_required' => array('[TICKET_LIST]'), |
|
| 364 | + ), |
|
| 365 | + 'datetime_list' => array( |
|
| 366 | + 'input' => 'textarea', |
|
| 367 | + 'label' => '[DATETIME_LIST]', |
|
| 368 | + 'type' => 'string', |
|
| 369 | + 'required' => true, |
|
| 370 | + 'validation' => true, |
|
| 371 | + 'format' => '%s', |
|
| 372 | + 'css_class' => 'large-text', |
|
| 373 | + 'rows' => '10', |
|
| 374 | + 'shortcodes_required' => array('[DATETIME_LIST]'), |
|
| 375 | + ), |
|
| 376 | + ), |
|
| 377 | + ), |
|
| 378 | + ); |
|
| 379 | + } |
|
| 380 | + |
|
| 381 | + |
|
| 382 | + /** |
|
| 383 | + * See definition of this class in parent |
|
| 384 | + */ |
|
| 385 | + protected function _set_default_message_types() |
|
| 386 | + { |
|
| 387 | + $this->_default_message_types = array( |
|
| 388 | + 'payment', |
|
| 389 | + 'payment_refund', |
|
| 390 | + 'registration', |
|
| 391 | + 'not_approved_registration', |
|
| 392 | + 'pending_approval', |
|
| 393 | + ); |
|
| 394 | + } |
|
| 395 | + |
|
| 396 | + |
|
| 397 | + /** |
|
| 398 | + * @see definition of this class in parent |
|
| 399 | + * @since 4.5.0 |
|
| 400 | + */ |
|
| 401 | + protected function _set_valid_message_types() |
|
| 402 | + { |
|
| 403 | + $this->_valid_message_types = array( |
|
| 404 | + 'payment', |
|
| 405 | + 'registration', |
|
| 406 | + 'not_approved_registration', |
|
| 407 | + 'declined_registration', |
|
| 408 | + 'cancelled_registration', |
|
| 409 | + 'pending_approval', |
|
| 410 | + 'registration_summary', |
|
| 411 | + 'payment_reminder', |
|
| 412 | + 'payment_declined', |
|
| 413 | + 'payment_refund', |
|
| 414 | + ); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + |
|
| 418 | + /** |
|
| 419 | + * setting up admin_settings_fields for messenger. |
|
| 420 | + */ |
|
| 421 | + protected function _set_admin_settings_fields() |
|
| 422 | + { |
|
| 423 | + } |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * We just deliver the messages don't kill us!! |
|
| 427 | + * |
|
| 428 | + * @return bool|WP_Error true if message delivered, false if it didn't deliver OR bubble up any error object if |
|
| 429 | + * present. |
|
| 430 | + * @throws EE_Error |
|
| 431 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
| 432 | + */ |
|
| 433 | + protected function _send_message() |
|
| 434 | + { |
|
| 435 | + $success = wp_mail( |
|
| 436 | + html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"), |
|
| 437 | + stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")), |
|
| 438 | + $this->_body(), |
|
| 439 | + $this->_headers() |
|
| 440 | + ); |
|
| 441 | + if (! $success) { |
|
| 442 | + EE_Error::add_error( |
|
| 443 | + sprintf( |
|
| 444 | + esc_html__( |
|
| 445 | + 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', |
|
| 446 | + 'event_espresso' |
|
| 447 | + ), |
|
| 448 | + $this->_to, |
|
| 449 | + $this->_from, |
|
| 450 | + '<br />' |
|
| 451 | + ), |
|
| 452 | + __FILE__, |
|
| 453 | + __FUNCTION__, |
|
| 454 | + __LINE__ |
|
| 455 | + ); |
|
| 456 | + } |
|
| 457 | + return $success; |
|
| 458 | + } |
|
| 459 | + |
|
| 460 | + |
|
| 461 | + /** |
|
| 462 | + * see parent for definition |
|
| 463 | + * |
|
| 464 | + * @return string html body of the message content and the related css. |
|
| 465 | + * @throws EE_Error |
|
| 466 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
| 467 | + */ |
|
| 468 | + protected function _preview() |
|
| 469 | + { |
|
| 470 | + return $this->_body(true); |
|
| 471 | + } |
|
| 472 | + |
|
| 473 | + |
|
| 474 | + /** |
|
| 475 | + * Setup headers for email |
|
| 476 | + * |
|
| 477 | + * @access protected |
|
| 478 | + * @return string formatted header for email |
|
| 479 | + */ |
|
| 480 | + protected function _headers() |
|
| 481 | + { |
|
| 482 | + $this->_ensure_has_from_email_address(); |
|
| 483 | + $from = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8")); |
|
| 484 | + $headers = array( |
|
| 485 | + 'MIME-Version: 1.0', |
|
| 486 | + 'From:' . $from, |
|
| 487 | + 'Reply-To:' . $from, |
|
| 488 | + 'Content-Type:text/html; charset=utf-8', |
|
| 489 | + ); |
|
| 490 | + |
|
| 491 | + if (! empty($this->_cc)) { |
|
| 492 | + $headers[] = 'cc: ' . $this->_cc; |
|
| 493 | + } |
|
| 494 | + |
|
| 495 | + //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
|
| 496 | + // header. |
|
| 497 | + add_filter('wp_mail_from', array($this, 'set_from_address'), 100); |
|
| 498 | + add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100); |
|
| 499 | + return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this); |
|
| 500 | + } |
|
| 501 | + |
|
| 502 | + |
|
| 503 | + /** |
|
| 504 | + * This simply ensures that the from address is not empty. If it is, then we use whatever is set as the site email |
|
| 505 | + * address for the from address to avoid problems with sending emails. |
|
| 506 | + */ |
|
| 507 | + protected function _ensure_has_from_email_address() |
|
| 508 | + { |
|
| 509 | + if (empty($this->_from)) { |
|
| 510 | + $this->_from = get_bloginfo('admin_email'); |
|
| 511 | + } |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + |
|
| 515 | + /** |
|
| 516 | + * This simply parses whatever is set as the $_from address and determines if it is in the format {name} <{email}> |
|
| 517 | + * or just {email} and returns an array with the "from_name" and "from_email" as the values. Note from_name *MAY* |
|
| 518 | + * be empty |
|
| 519 | + * |
|
| 520 | + * @since 4.3.1 |
|
| 521 | + * @return array |
|
| 522 | + */ |
|
| 523 | + private function _parse_from() |
|
| 524 | + { |
|
| 525 | + if (strpos($this->_from, '<') !== false) { |
|
| 526 | + $from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1); |
|
| 527 | + $from_name = str_replace('"', '', $from_name); |
|
| 528 | + $from_name = trim($from_name); |
|
| 529 | + |
|
| 530 | + $from_email = substr($this->_from, strpos($this->_from, '<') + 1); |
|
| 531 | + $from_email = str_replace('>', '', $from_email); |
|
| 532 | + $from_email = trim($from_email); |
|
| 533 | + } elseif (trim($this->_from) !== '') { |
|
| 534 | + $from_name = ''; |
|
| 535 | + $from_email = trim($this->_from); |
|
| 536 | + } else { |
|
| 537 | + $from_name = $from_email = ''; |
|
| 538 | + } |
|
| 539 | + return array($from_name, $from_email); |
|
| 540 | + } |
|
| 541 | + |
|
| 542 | + |
|
| 543 | + /** |
|
| 544 | + * Callback for the wp_mail_from filter. |
|
| 545 | + * |
|
| 546 | + * @since 4.3.1 |
|
| 547 | + * @param string $from_email What the original from_email is. |
|
| 548 | + * @return string |
|
| 549 | + */ |
|
| 550 | + public function set_from_address($from_email) |
|
| 551 | + { |
|
| 552 | + $parsed_from = $this->_parse_from(); |
|
| 553 | + //includes fallback if the parsing failed. |
|
| 554 | + $from_email = is_array($parsed_from) && ! empty($parsed_from[1]) |
|
| 555 | + ? $parsed_from[1] |
|
| 556 | + : get_bloginfo('admin_email'); |
|
| 557 | + return $from_email; |
|
| 558 | + } |
|
| 559 | + |
|
| 560 | + |
|
| 561 | + /** |
|
| 562 | + * Callback fro the wp_mail_from_name filter. |
|
| 563 | + * |
|
| 564 | + * @since 4.3.1 |
|
| 565 | + * @param string $from_name The original from_name. |
|
| 566 | + * @return string |
|
| 567 | + */ |
|
| 568 | + public function set_from_name($from_name) |
|
| 569 | + { |
|
| 570 | + $parsed_from = $this->_parse_from(); |
|
| 571 | + if (is_array($parsed_from) && ! empty($parsed_from[0])) { |
|
| 572 | + $from_name = $parsed_from[0]; |
|
| 573 | + } |
|
| 574 | + |
|
| 575 | + //if from name is "WordPress" let's sub in the site name instead (more friendly!) |
|
| 576 | + $from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name; |
|
| 577 | + |
|
| 578 | + return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8")); |
|
| 579 | + } |
|
| 580 | + |
|
| 581 | + |
|
| 582 | + /** |
|
| 583 | + * setup body for email |
|
| 584 | + * |
|
| 585 | + * @param bool $preview will determine whether this is preview template or not. |
|
| 586 | + * @return string formatted body for email. |
|
| 587 | + * @throws EE_Error |
|
| 588 | + * @throws \TijsVerkoyen\CssToInlineStyles\Exception |
|
| 589 | + */ |
|
| 590 | + protected function _body($preview = false) |
|
| 591 | + { |
|
| 592 | + //setup template args! |
|
| 593 | + $this->_template_args = array( |
|
| 594 | + 'subject' => $this->_subject, |
|
| 595 | + 'from' => $this->_from, |
|
| 596 | + 'main_body' => wpautop( |
|
| 597 | + stripslashes_deep( |
|
| 598 | + html_entity_decode($this->_content, ENT_QUOTES, "UTF-8") |
|
| 599 | + ) |
|
| 600 | + ), |
|
| 601 | + ); |
|
| 602 | + $body = $this->_get_main_template($preview); |
|
| 603 | + |
|
| 604 | + /** |
|
| 605 | + * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
|
| 606 | + * |
|
| 607 | + * @type bool $preview Indicates whether a preview is being generated or not. |
|
| 608 | + * @return bool true indicates to use the inliner, false bypasses it. |
|
| 609 | + */ |
|
| 610 | + if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
|
| 611 | + //require CssToInlineStyles library and its dependencies via composer autoloader |
|
| 612 | + require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
| 613 | + |
|
| 614 | + //now if this isn't a preview, let's setup the body so it has inline styles |
|
| 615 | + if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
| 616 | + $style = file_get_contents( |
|
| 617 | + $this->get_variation( |
|
| 618 | + $this->_tmp_pack, |
|
| 619 | + $this->_incoming_message_type->name, |
|
| 620 | + false, |
|
| 621 | + 'main', |
|
| 622 | + $this->_variation |
|
| 623 | + ), |
|
| 624 | + true |
|
| 625 | + ); |
|
| 626 | + $CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style); |
|
| 627 | + //for some reason the library has a bracket and new line at the beginning. This takes care of that. |
|
| 628 | + $body = ltrim($CSS->convert(true), ">\n"); |
|
| 629 | + //see https://events.codebasehq.com/projects/event-espresso/tickets/8609 |
|
| 630 | + $body = ltrim($body, "<?"); |
|
| 631 | + } |
|
| 632 | + |
|
| 633 | + } |
|
| 634 | + return $body; |
|
| 635 | + } |
|
| 636 | + |
|
| 637 | + |
|
| 638 | + /** |
|
| 639 | + * This just returns any existing test settings that might be saved in the database |
|
| 640 | + * |
|
| 641 | + * @access public |
|
| 642 | + * @return array |
|
| 643 | + */ |
|
| 644 | + public function get_existing_test_settings() |
|
| 645 | + { |
|
| 646 | + $settings = parent::get_existing_test_settings(); |
|
| 647 | + //override subject if present because we always want it to be fresh. |
|
| 648 | + if (is_array($settings) && ! empty($settings['subject'])) { |
|
| 649 | + $settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')); |
|
| 650 | + } |
|
| 651 | + return $settings; |
|
| 652 | + } |
|
| 653 | 653 | } |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | ), |
| 59 | 59 | '<code>wp_mail</code>' |
| 60 | 60 | ); |
| 61 | - $this->label = array( |
|
| 61 | + $this->label = array( |
|
| 62 | 62 | 'singular' => esc_html__('email', 'event_espresso'), |
| 63 | 63 | 'plural' => esc_html__('emails', 'event_espresso'), |
| 64 | 64 | ); |
@@ -438,7 +438,7 @@ discard block |
||
| 438 | 438 | $this->_body(), |
| 439 | 439 | $this->_headers() |
| 440 | 440 | ); |
| 441 | - if (! $success) { |
|
| 441 | + if ( ! $success) { |
|
| 442 | 442 | EE_Error::add_error( |
| 443 | 443 | sprintf( |
| 444 | 444 | esc_html__( |
@@ -483,13 +483,13 @@ discard block |
||
| 483 | 483 | $from = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8")); |
| 484 | 484 | $headers = array( |
| 485 | 485 | 'MIME-Version: 1.0', |
| 486 | - 'From:' . $from, |
|
| 487 | - 'Reply-To:' . $from, |
|
| 486 | + 'From:'.$from, |
|
| 487 | + 'Reply-To:'.$from, |
|
| 488 | 488 | 'Content-Type:text/html; charset=utf-8', |
| 489 | 489 | ); |
| 490 | 490 | |
| 491 | - if (! empty($this->_cc)) { |
|
| 492 | - $headers[] = 'cc: ' . $this->_cc; |
|
| 491 | + if ( ! empty($this->_cc)) { |
|
| 492 | + $headers[] = 'cc: '.$this->_cc; |
|
| 493 | 493 | } |
| 494 | 494 | |
| 495 | 495 | //but wait! Header's for the from is NOT reliable because some plugins don't respect From: as set in the |
@@ -599,7 +599,7 @@ discard block |
||
| 599 | 599 | ) |
| 600 | 600 | ), |
| 601 | 601 | ); |
| 602 | - $body = $this->_get_main_template($preview); |
|
| 602 | + $body = $this->_get_main_template($preview); |
|
| 603 | 603 | |
| 604 | 604 | /** |
| 605 | 605 | * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched. |
@@ -609,10 +609,10 @@ discard block |
||
| 609 | 609 | */ |
| 610 | 610 | if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) { |
| 611 | 611 | //require CssToInlineStyles library and its dependencies via composer autoloader |
| 612 | - require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php'; |
|
| 612 | + require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php'; |
|
| 613 | 613 | |
| 614 | 614 | //now if this isn't a preview, let's setup the body so it has inline styles |
| 615 | - if (! $preview || ($preview && defined('DOING_AJAX'))) { |
|
| 615 | + if ( ! $preview || ($preview && defined('DOING_AJAX'))) { |
|
| 616 | 616 | $style = file_get_contents( |
| 617 | 617 | $this->get_variation( |
| 618 | 618 | $this->_tmp_pack, |
@@ -14,254 +14,254 @@ |
||
| 14 | 14 | class MessagesAdmin extends CoreAdmin |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - /** |
|
| 18 | - * Context slug for the admin messages context. |
|
| 19 | - * @var string |
|
| 20 | - */ |
|
| 21 | - const ADMIN_CONTEXT_SLUG = 'admin'; |
|
| 17 | + /** |
|
| 18 | + * Context slug for the admin messages context. |
|
| 19 | + * @var string |
|
| 20 | + */ |
|
| 21 | + const ADMIN_CONTEXT_SLUG = 'admin'; |
|
| 22 | 22 | |
| 23 | - /** |
|
| 24 | - * Context slug for the primary attendee messages context |
|
| 25 | - * @var string |
|
| 26 | - */ |
|
| 27 | - const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee'; |
|
| 23 | + /** |
|
| 24 | + * Context slug for the primary attendee messages context |
|
| 25 | + * @var string |
|
| 26 | + */ |
|
| 27 | + const PRIMARY_ATTENDEE_CONTEXT_SLUG = 'primary_attendee'; |
|
| 28 | 28 | |
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Status reference for the EEM_Message::status_sent status. |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - const MESSAGE_STATUS_SENT = 'MSN'; |
|
| 30 | + /** |
|
| 31 | + * Status reference for the EEM_Message::status_sent status. |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + const MESSAGE_STATUS_SENT = 'MSN'; |
|
| 35 | 35 | |
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * Message type slug for the Payment Failed message type |
|
| 39 | - */ |
|
| 40 | - const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed'; |
|
| 37 | + /** |
|
| 38 | + * Message type slug for the Payment Failed message type |
|
| 39 | + */ |
|
| 40 | + const PAYMENT_FAILED_MESSAGE_TYPE_SLUG = 'payment_failed'; |
|
| 41 | 41 | |
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * Selector for the Global Messages "Send on same request" field in the Messages Settings tab. |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = |
|
| 48 | - '#global_messages_settings-do-messages-on-same-request'; |
|
| 49 | - |
|
| 43 | + /** |
|
| 44 | + * Selector for the Global Messages "Send on same request" field in the Messages Settings tab. |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + const GLOBAL_MESSAGES_SETTINGS_ON_REQUEST_SELECTION_SELECTOR = |
|
| 48 | + '#global_messages_settings-do-messages-on-same-request'; |
|
| 49 | + |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Selector for the Global Messages Settings submit button in the Messages Settings tab. |
|
| 53 | - * @var string |
|
| 54 | - */ |
|
| 55 | - const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit'; |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * This is the container where active message types for a messenger are found/dragged to. |
|
| 60 | - * @var string |
|
| 61 | - */ |
|
| 62 | - const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types'; |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Locator for the context switcher selector on the Message Template Editor page. |
|
| 67 | - * @var string |
|
| 68 | - */ |
|
| 69 | - const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select"; |
|
| 70 | - |
|
| 71 | - |
|
| 72 | - /** |
|
| 73 | - * Locator for the context switcher submit button in the Message Template Editor page. |
|
| 74 | - * @var string |
|
| 75 | - */ |
|
| 76 | - const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt"; |
|
| 77 | - |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * Locator for the dialog container used for housing viewed messages in the message activity list table. |
|
| 81 | - * @var string |
|
| 82 | - */ |
|
| 83 | - const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content'; |
|
| 84 | - |
|
| 85 | - |
|
| 86 | - |
|
| 87 | - /** |
|
| 88 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 89 | - * a string. |
|
| 90 | - * @return string |
|
| 91 | - */ |
|
| 92 | - public static function messageActivityListTableUrl($additional_params = '') |
|
| 93 | - { |
|
| 94 | - return self::adminUrl('espresso_messages', 'default', $additional_params); |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 100 | - * a string. |
|
| 101 | - * @return string |
|
| 102 | - */ |
|
| 103 | - public static function defaultMessageTemplateListTableUrl($additional_params = '') |
|
| 104 | - { |
|
| 105 | - return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - |
|
| 109 | - /** |
|
| 110 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 111 | - * a string. |
|
| 112 | - * @return string |
|
| 113 | - */ |
|
| 114 | - public static function customMessageTemplateListTableUrl($additional_params = '') |
|
| 115 | - { |
|
| 116 | - return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @return string |
|
| 122 | - */ |
|
| 123 | - public static function messageSettingsUrl() |
|
| 124 | - { |
|
| 125 | - return self::adminUrl('espresso_messages', 'settings'); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - |
|
| 129 | - |
|
| 130 | - public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger( |
|
| 131 | - $message_type_slug, |
|
| 132 | - $messenger_slug = 'email' |
|
| 133 | - ) { |
|
| 134 | - return "#$message_type_slug-messagetype-$messenger_slug"; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * @param string $message_type_slug |
|
| 140 | - * @param string $context |
|
| 141 | - * @return string |
|
| 142 | - */ |
|
| 143 | - public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
|
| 144 | - { |
|
| 145 | - return $context |
|
| 146 | - ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
| 147 | - : '.' . $message_type_slug . '-edit-link'; |
|
| 148 | - } |
|
| 149 | - |
|
| 150 | - |
|
| 151 | - /** |
|
| 152 | - * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters. |
|
| 153 | - * |
|
| 154 | - * @param $field |
|
| 155 | - * @param $message_type_label |
|
| 156 | - * @param string $message_status |
|
| 157 | - * @param string $messenger |
|
| 158 | - * @param string $context |
|
| 159 | - * @param string $table_cell_content_for_field |
|
| 160 | - * @param int $number_in_set It's possible that the given parameters could match multiple items in the view. |
|
| 161 | - * This allows you to indicate which item from the set to match. If this is set to 0 |
|
| 162 | - * then all matches for the locator will be returned. |
|
| 163 | - * @return string |
|
| 164 | - */ |
|
| 165 | - public static function messagesActivityListTableCellSelectorFor( |
|
| 166 | - $field, |
|
| 167 | - $message_type_label, |
|
| 168 | - $message_status = self::MESSAGE_STATUS_SENT, |
|
| 169 | - $messenger = 'Email', |
|
| 170 | - $context = 'Event Admin', |
|
| 171 | - $table_cell_content_for_field = '', |
|
| 172 | - $number_in_set = 1 |
|
| 173 | - ) { |
|
| 174 | - $selector = "//tbody[@id='the-list']"; |
|
| 175 | - $selector .= "//tr[contains(@class, 'msg-status-$message_status')]" |
|
| 176 | - . "//td[contains(@class, 'message_type') and text()='$message_type_label']"; |
|
| 177 | - if ($messenger) { |
|
| 178 | - $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']"; |
|
| 179 | - } |
|
| 180 | - $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']"; |
|
| 181 | - $selector .= $table_cell_content_for_field |
|
| 182 | - ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']" |
|
| 183 | - : "/ancestor::tr/td[contains(@class, 'column-$field')]"; |
|
| 184 | - return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Selector for the Create Custom button found in the message template list table. |
|
| 190 | - * @param string $message_type_label |
|
| 191 | - * @param string $messenger_label |
|
| 192 | - * @return string |
|
| 193 | - */ |
|
| 194 | - public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label) |
|
| 195 | - { |
|
| 196 | - $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']" |
|
| 197 | - . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]" |
|
| 198 | - . "//ancestor::tr/td/a[@class='button button-small']"; |
|
| 199 | - return $selector; |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - |
|
| 203 | - /** |
|
| 204 | - * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to |
|
| 205 | - * the FIRST match (which will be the latest message sent if the table is default sorted). |
|
| 206 | - * |
|
| 207 | - * @param string $message_type_label The visible message type label for the row you want to match |
|
| 208 | - * @param string $message_status The status of the message for the row you want to match. |
|
| 209 | - * @param string $messenger The visible messenger label for the row you want to match. |
|
| 210 | - * @param string $context The visible context label for the row you want to match. |
|
| 211 | - * @param int $number_in_set It's possible that the given parameters could match multiple items in the |
|
| 212 | - * view. This allows you to indicate which item from the set to match. |
|
| 213 | - * @return string |
|
| 214 | - */ |
|
| 215 | - public static function messagesActivityListTableViewButtonSelectorFor( |
|
| 216 | - $message_type_label, |
|
| 217 | - $message_status = self::MESSAGE_STATUS_SENT, |
|
| 218 | - $messenger = 'Email', |
|
| 219 | - $context = 'Event Admin', |
|
| 220 | - $number_in_set = 1 |
|
| 221 | - ) { |
|
| 222 | - $selector = self::messagesActivityListTableCellSelectorFor( |
|
| 223 | - 'action', |
|
| 224 | - $message_type_label, |
|
| 225 | - $message_status, |
|
| 226 | - $messenger, |
|
| 227 | - $context, |
|
| 228 | - '', |
|
| 229 | - $number_in_set |
|
| 230 | - ); |
|
| 231 | - $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')" |
|
| 232 | - . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]"; |
|
| 233 | - return $selector; |
|
| 234 | - } |
|
| 235 | - |
|
| 236 | - |
|
| 237 | - |
|
| 238 | - /** |
|
| 239 | - * Locator for the delete action link for a message item in the message activity list table. |
|
| 240 | - * Note: The link is not visible by default, so the column would need hovered over for the link to appear. |
|
| 241 | - * @param $message_type_label |
|
| 242 | - * @param string $message_status |
|
| 243 | - * @param string $messenger |
|
| 244 | - * @param string $context |
|
| 245 | - * @param int $number_in_set |
|
| 246 | - * @return string |
|
| 247 | - */ |
|
| 248 | - public static function messagesActivityListTableDeleteActionSelectorFor( |
|
| 249 | - $message_type_label, |
|
| 250 | - $message_status = self::MESSAGE_STATUS_SENT, |
|
| 251 | - $messenger = 'Email', |
|
| 252 | - $context = 'Event Admin', |
|
| 253 | - $number_in_set = 1 |
|
| 254 | - ) { |
|
| 255 | - $selector = self::messagesActivityListTableCellSelectorFor( |
|
| 256 | - 'to', |
|
| 257 | - $message_type_label, |
|
| 258 | - $message_status, |
|
| 259 | - $messenger, |
|
| 260 | - $context, |
|
| 261 | - '', |
|
| 262 | - $number_in_set |
|
| 263 | - ); |
|
| 264 | - $selector .= "/div/span[@class='delete']/a"; |
|
| 265 | - return $selector; |
|
| 266 | - } |
|
| 51 | + /** |
|
| 52 | + * Selector for the Global Messages Settings submit button in the Messages Settings tab. |
|
| 53 | + * @var string |
|
| 54 | + */ |
|
| 55 | + const GLOBAL_MESSAGES_SETTINGS_SUBMIT_SELECTOR = '#global_messages_settings-update-settings-submit'; |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * This is the container where active message types for a messenger are found/dragged to. |
|
| 60 | + * @var string |
|
| 61 | + */ |
|
| 62 | + const MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR = '#active-message-types'; |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Locator for the context switcher selector on the Message Template Editor page. |
|
| 67 | + * @var string |
|
| 68 | + */ |
|
| 69 | + const MESSAGES_CONTEXT_SWITCHER_SELECTOR = "//form[@id='ee-msg-context-switcher-frm']/select"; |
|
| 70 | + |
|
| 71 | + |
|
| 72 | + /** |
|
| 73 | + * Locator for the context switcher submit button in the Message Template Editor page. |
|
| 74 | + * @var string |
|
| 75 | + */ |
|
| 76 | + const MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR = "#submit-msg-context-switcher-sbmt"; |
|
| 77 | + |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * Locator for the dialog container used for housing viewed messages in the message activity list table. |
|
| 81 | + * @var string |
|
| 82 | + */ |
|
| 83 | + const MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR = '.ee-admin-dialog-container-inner-content'; |
|
| 84 | + |
|
| 85 | + |
|
| 86 | + |
|
| 87 | + /** |
|
| 88 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 89 | + * a string. |
|
| 90 | + * @return string |
|
| 91 | + */ |
|
| 92 | + public static function messageActivityListTableUrl($additional_params = '') |
|
| 93 | + { |
|
| 94 | + return self::adminUrl('espresso_messages', 'default', $additional_params); |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 100 | + * a string. |
|
| 101 | + * @return string |
|
| 102 | + */ |
|
| 103 | + public static function defaultMessageTemplateListTableUrl($additional_params = '') |
|
| 104 | + { |
|
| 105 | + return self::adminUrl('espresso_messages', 'global_mtps', $additional_params); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + |
|
| 109 | + /** |
|
| 110 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 111 | + * a string. |
|
| 112 | + * @return string |
|
| 113 | + */ |
|
| 114 | + public static function customMessageTemplateListTableUrl($additional_params = '') |
|
| 115 | + { |
|
| 116 | + return self::adminUrl('espresso_messages', 'custom_mtps', $additional_params); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @return string |
|
| 122 | + */ |
|
| 123 | + public static function messageSettingsUrl() |
|
| 124 | + { |
|
| 125 | + return self::adminUrl('espresso_messages', 'settings'); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + |
|
| 129 | + |
|
| 130 | + public static function draggableSettingsBoxSelectorForMessageTypeAndMessenger( |
|
| 131 | + $message_type_slug, |
|
| 132 | + $messenger_slug = 'email' |
|
| 133 | + ) { |
|
| 134 | + return "#$message_type_slug-messagetype-$messenger_slug"; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * @param string $message_type_slug |
|
| 140 | + * @param string $context |
|
| 141 | + * @return string |
|
| 142 | + */ |
|
| 143 | + public static function editMessageTemplateClassByMessageType($message_type_slug, $context = '') |
|
| 144 | + { |
|
| 145 | + return $context |
|
| 146 | + ? '.' . $message_type_slug . '-' . $context . '-edit-link' |
|
| 147 | + : '.' . $message_type_slug . '-edit-link'; |
|
| 148 | + } |
|
| 149 | + |
|
| 150 | + |
|
| 151 | + /** |
|
| 152 | + * Selector for (a) specific table cell(s) in the Messages Activity list table for the given parameters. |
|
| 153 | + * |
|
| 154 | + * @param $field |
|
| 155 | + * @param $message_type_label |
|
| 156 | + * @param string $message_status |
|
| 157 | + * @param string $messenger |
|
| 158 | + * @param string $context |
|
| 159 | + * @param string $table_cell_content_for_field |
|
| 160 | + * @param int $number_in_set It's possible that the given parameters could match multiple items in the view. |
|
| 161 | + * This allows you to indicate which item from the set to match. If this is set to 0 |
|
| 162 | + * then all matches for the locator will be returned. |
|
| 163 | + * @return string |
|
| 164 | + */ |
|
| 165 | + public static function messagesActivityListTableCellSelectorFor( |
|
| 166 | + $field, |
|
| 167 | + $message_type_label, |
|
| 168 | + $message_status = self::MESSAGE_STATUS_SENT, |
|
| 169 | + $messenger = 'Email', |
|
| 170 | + $context = 'Event Admin', |
|
| 171 | + $table_cell_content_for_field = '', |
|
| 172 | + $number_in_set = 1 |
|
| 173 | + ) { |
|
| 174 | + $selector = "//tbody[@id='the-list']"; |
|
| 175 | + $selector .= "//tr[contains(@class, 'msg-status-$message_status')]" |
|
| 176 | + . "//td[contains(@class, 'message_type') and text()='$message_type_label']"; |
|
| 177 | + if ($messenger) { |
|
| 178 | + $selector .= "/ancestor::tr/td[contains(@class, 'messenger') and text()='$messenger']"; |
|
| 179 | + } |
|
| 180 | + $selector .= "/ancestor::tr/td[contains(@class, 'column-context') and text()='$context']"; |
|
| 181 | + $selector .= $table_cell_content_for_field |
|
| 182 | + ? "/ancestor::tr/td[contains(@class, 'column-$field') and text()='$table_cell_content_for_field']" |
|
| 183 | + : "/ancestor::tr/td[contains(@class, 'column-$field')]"; |
|
| 184 | + return $number_in_set > 0 ? Locator::elementAt($selector, $number_in_set) : $selector; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Selector for the Create Custom button found in the message template list table. |
|
| 190 | + * @param string $message_type_label |
|
| 191 | + * @param string $messenger_label |
|
| 192 | + * @return string |
|
| 193 | + */ |
|
| 194 | + public static function createCustomButtonForMessageTypeAndMessenger($message_type_label, $messenger_label) |
|
| 195 | + { |
|
| 196 | + $selector = "//tr/td[contains(@class, 'message_type') and text()='$message_type_label']" |
|
| 197 | + . "//ancestor::tr/td[contains(@class, 'messenger') and contains(., '$messenger_label')]" |
|
| 198 | + . "//ancestor::tr/td/a[@class='button button-small']"; |
|
| 199 | + return $selector; |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + |
|
| 203 | + /** |
|
| 204 | + * Note, this could potentially match multiple buttons in the view so the selector is intentionally restricted to |
|
| 205 | + * the FIRST match (which will be the latest message sent if the table is default sorted). |
|
| 206 | + * |
|
| 207 | + * @param string $message_type_label The visible message type label for the row you want to match |
|
| 208 | + * @param string $message_status The status of the message for the row you want to match. |
|
| 209 | + * @param string $messenger The visible messenger label for the row you want to match. |
|
| 210 | + * @param string $context The visible context label for the row you want to match. |
|
| 211 | + * @param int $number_in_set It's possible that the given parameters could match multiple items in the |
|
| 212 | + * view. This allows you to indicate which item from the set to match. |
|
| 213 | + * @return string |
|
| 214 | + */ |
|
| 215 | + public static function messagesActivityListTableViewButtonSelectorFor( |
|
| 216 | + $message_type_label, |
|
| 217 | + $message_status = self::MESSAGE_STATUS_SENT, |
|
| 218 | + $messenger = 'Email', |
|
| 219 | + $context = 'Event Admin', |
|
| 220 | + $number_in_set = 1 |
|
| 221 | + ) { |
|
| 222 | + $selector = self::messagesActivityListTableCellSelectorFor( |
|
| 223 | + 'action', |
|
| 224 | + $message_type_label, |
|
| 225 | + $message_status, |
|
| 226 | + $messenger, |
|
| 227 | + $context, |
|
| 228 | + '', |
|
| 229 | + $number_in_set |
|
| 230 | + ); |
|
| 231 | + $selector .= "/a/span[contains(@class, 'ee-message-action-link-view')" |
|
| 232 | + . " and not(contains(@class, 'ee-message-action-link-view_transaction'))]"; |
|
| 233 | + return $selector; |
|
| 234 | + } |
|
| 235 | + |
|
| 236 | + |
|
| 237 | + |
|
| 238 | + /** |
|
| 239 | + * Locator for the delete action link for a message item in the message activity list table. |
|
| 240 | + * Note: The link is not visible by default, so the column would need hovered over for the link to appear. |
|
| 241 | + * @param $message_type_label |
|
| 242 | + * @param string $message_status |
|
| 243 | + * @param string $messenger |
|
| 244 | + * @param string $context |
|
| 245 | + * @param int $number_in_set |
|
| 246 | + * @return string |
|
| 247 | + */ |
|
| 248 | + public static function messagesActivityListTableDeleteActionSelectorFor( |
|
| 249 | + $message_type_label, |
|
| 250 | + $message_status = self::MESSAGE_STATUS_SENT, |
|
| 251 | + $messenger = 'Email', |
|
| 252 | + $context = 'Event Admin', |
|
| 253 | + $number_in_set = 1 |
|
| 254 | + ) { |
|
| 255 | + $selector = self::messagesActivityListTableCellSelectorFor( |
|
| 256 | + 'to', |
|
| 257 | + $message_type_label, |
|
| 258 | + $message_status, |
|
| 259 | + $messenger, |
|
| 260 | + $context, |
|
| 261 | + '', |
|
| 262 | + $number_in_set |
|
| 263 | + ); |
|
| 264 | + $selector .= "/div/span[@class='delete']/a"; |
|
| 265 | + return $selector; |
|
| 266 | + } |
|
| 267 | 267 | } |
| 268 | 268 | \ No newline at end of file |
@@ -18,14 +18,14 @@ discard block |
||
| 18 | 18 | $event_one_link = $event_two_link = $event_three_link = ''; |
| 19 | 19 | |
| 20 | 20 | $I->wantTo( |
| 21 | - 'Test that when registrations for multiple events are completed, and those events share the same custom' |
|
| 22 | - . 'template, that that custom template will be used.' |
|
| 21 | + 'Test that when registrations for multiple events are completed, and those events share the same custom' |
|
| 22 | + . 'template, that that custom template will be used.' |
|
| 23 | 23 | ); |
| 24 | 24 | |
| 25 | 25 | //need the MER plugin active for this test (we'll deactivate it after). |
| 26 | 26 | $I->ensurePluginActive( |
| 27 | - 'event-espresso-mer-multi-event-registration', |
|
| 28 | - 'activated' |
|
| 27 | + 'event-espresso-mer-multi-event-registration', |
|
| 28 | + 'activated' |
|
| 29 | 29 | ); |
| 30 | 30 | |
| 31 | 31 | $I->loginAsAdmin(); |
@@ -83,9 +83,9 @@ discard block |
||
| 83 | 83 | |
| 84 | 84 | |
| 85 | 85 | $test_registration_details = array( |
| 86 | - 'fname' => 'CTGuy', |
|
| 87 | - 'lname' => 'Dude', |
|
| 88 | - 'email' => '[email protected]' |
|
| 86 | + 'fname' => 'CTGuy', |
|
| 87 | + 'lname' => 'Dude', |
|
| 88 | + 'email' => '[email protected]' |
|
| 89 | 89 | ); |
| 90 | 90 | |
| 91 | 91 | $I->amGoingTo('Register for Event One and Event Two and verify Custom Template A was used.'); |
@@ -111,23 +111,23 @@ discard block |
||
| 111 | 111 | $I->loginAsAdmin(); |
| 112 | 112 | $I->amOnMessagesActivityListTablePage(); |
| 113 | 113 | $I->viewMessageInMessagesListTableFor( |
| 114 | - 'Registration Approved', |
|
| 115 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 116 | - 'Email', |
|
| 117 | - 'Registrant' |
|
| 114 | + 'Registration Approved', |
|
| 115 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 116 | + 'Email', |
|
| 117 | + 'Registrant' |
|
| 118 | 118 | ); |
| 119 | 119 | $I->seeTextInViewMessageModal($custom_template_a_label); |
| 120 | 120 | $I->dismissMessageModal(); |
| 121 | 121 | $I->deleteMessageInMessagesListTableFor( |
| 122 | - 'Registration Approved', |
|
| 123 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 124 | - 'Email', |
|
| 125 | - 'Registrant' |
|
| 122 | + 'Registration Approved', |
|
| 123 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 124 | + 'Email', |
|
| 125 | + 'Registrant' |
|
| 126 | 126 | ); |
| 127 | 127 | |
| 128 | 128 | //verify admin context |
| 129 | 129 | $I->viewMessageInMessagesListTableFor( |
| 130 | - 'Registration Approved' |
|
| 130 | + 'Registration Approved' |
|
| 131 | 131 | ); |
| 132 | 132 | $I->seeTextInViewMessageModal($custom_template_a_label); |
| 133 | 133 | $I->dismissMessageModal(); |
@@ -156,25 +156,25 @@ discard block |
||
| 156 | 156 | $I->loginAsAdmin(); |
| 157 | 157 | $I->amOnMessagesActivityListTablePage(); |
| 158 | 158 | $I->viewMessageInMessagesListTableFor( |
| 159 | - 'Registration Approved', |
|
| 160 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 161 | - 'Email', |
|
| 162 | - 'Registrant' |
|
| 159 | + 'Registration Approved', |
|
| 160 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 161 | + 'Email', |
|
| 162 | + 'Registrant' |
|
| 163 | 163 | ); |
| 164 | 164 | $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR); |
| 165 | 165 | $I->dontSeeTextInViewMessageModal($custom_template_a_label); |
| 166 | 166 | $I->dontSeeTextInViewMessageModal($custom_template_b_label); |
| 167 | 167 | $I->dismissMessageModal(); |
| 168 | 168 | $I->deleteMessageInMessagesListTableFor( |
| 169 | - 'Registration Approved', |
|
| 170 | - MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 171 | - 'Email', |
|
| 172 | - 'Registrant' |
|
| 169 | + 'Registration Approved', |
|
| 170 | + MessagesAdmin::MESSAGE_STATUS_SENT, |
|
| 171 | + 'Email', |
|
| 172 | + 'Registrant' |
|
| 173 | 173 | ); |
| 174 | 174 | |
| 175 | 175 | //verify admin context |
| 176 | 176 | $I->viewMessageInMessagesListTableFor( |
| 177 | - 'Registration Approved' |
|
| 177 | + 'Registration Approved' |
|
| 178 | 178 | ); |
| 179 | 179 | $I->waitForElementVisible(MessagesAdmin::MESSAGES_LIST_TABLE_VIEW_MESSAGE_DIALOG_CONTAINER_SELECTOR); |
| 180 | 180 | $I->dontSee($custom_template_a_label); |
@@ -186,6 +186,6 @@ discard block |
||
| 186 | 186 | |
| 187 | 187 | //deactivate MER plugin so its not active for future tests |
| 188 | 188 | $I->ensurePluginDeactivated( |
| 189 | - 'event-espresso-mer-multi-event-registration', |
|
| 190 | - 'Plugin deactivated' |
|
| 189 | + 'event-espresso-mer-multi-event-registration', |
|
| 190 | + 'Plugin deactivated' |
|
| 191 | 191 | ); |
| 192 | 192 | \ No newline at end of file |
@@ -10,242 +10,242 @@ |
||
| 10 | 10 | */ |
| 11 | 11 | trait MessagesAdmin |
| 12 | 12 | { |
| 13 | - /** |
|
| 14 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 15 | - * a string. |
|
| 16 | - */ |
|
| 17 | - public function amOnMessagesActivityListTablePage($additional_params = '') |
|
| 18 | - { |
|
| 19 | - $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 24 | - * a string. |
|
| 25 | - */ |
|
| 26 | - public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
| 27 | - { |
|
| 28 | - $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 34 | - * a string. |
|
| 35 | - */ |
|
| 36 | - public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
| 37 | - { |
|
| 38 | - $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * Directs to message settings page |
|
| 44 | - */ |
|
| 45 | - public function amOnMessageSettingsPage() |
|
| 46 | - { |
|
| 47 | - $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
| 48 | - } |
|
| 49 | - |
|
| 50 | - |
|
| 51 | - public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
| 52 | - { |
|
| 53 | - $this->actor()->dragAndDrop( |
|
| 54 | - MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
| 55 | - MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
| 56 | - ); |
|
| 57 | - } |
|
| 58 | - |
|
| 59 | - |
|
| 60 | - /** |
|
| 61 | - * Assumes you are already on the list table page that has the ui for editing the template. |
|
| 62 | - * @param string $message_type_slug |
|
| 63 | - * @param string $context [optional] if you want to click directly to the given context in the editor |
|
| 64 | - */ |
|
| 65 | - public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
| 66 | - { |
|
| 67 | - $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
| 73 | - * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
| 74 | - * |
|
| 75 | - * @param int $expected_occurence_count |
|
| 76 | - * @param string $text_to_check_for |
|
| 77 | - * @param string $field |
|
| 78 | - * @param string $message_type_label |
|
| 79 | - * @param string $message_status |
|
| 80 | - * @param string $messenger |
|
| 81 | - * @param string $context |
|
| 82 | - */ |
|
| 83 | - public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
| 84 | - $expected_occurence_count, |
|
| 85 | - $text_to_check_for, |
|
| 86 | - $field, |
|
| 87 | - $message_type_label, |
|
| 88 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 89 | - $messenger = 'Email', |
|
| 90 | - $context = 'Event Admin' |
|
| 91 | - ) { |
|
| 92 | - $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 93 | - $field, |
|
| 94 | - $message_type_label, |
|
| 95 | - $message_status, |
|
| 96 | - $messenger, |
|
| 97 | - $context, |
|
| 98 | - $text_to_check_for, |
|
| 99 | - 0 |
|
| 100 | - )); |
|
| 101 | - $actual_count = count($elements); |
|
| 102 | - $this->actor()->assertEquals( |
|
| 103 | - $expected_occurence_count, |
|
| 104 | - $actual_count, |
|
| 105 | - sprintf( |
|
| 106 | - 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
| 107 | - $expected_occurence_count, |
|
| 108 | - $text_to_check_for, |
|
| 109 | - $field, |
|
| 110 | - $actual_count |
|
| 111 | - ) |
|
| 112 | - ); |
|
| 113 | - } |
|
| 114 | - |
|
| 115 | - |
|
| 116 | - /** |
|
| 117 | - * This will create a custom message template for the given messenger and message type from the context of the |
|
| 118 | - * default (global) message template list table. |
|
| 119 | - * Also takes care of verifying the template was created. |
|
| 120 | - * @param string $message_type_label |
|
| 121 | - * @param string $messenger_label |
|
| 122 | - */ |
|
| 123 | - public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
| 124 | - { |
|
| 125 | - $this->amOnDefaultMessageTemplateListTablePage(); |
|
| 126 | - $this->actor()->click( |
|
| 127 | - MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
| 128 | - $message_type_label, |
|
| 129 | - $messenger_label |
|
| 130 | - ) |
|
| 131 | - ); |
|
| 132 | - $this->actor()->seeInField('#title', 'New Custom Template'); |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - /** |
|
| 137 | - * This switches the context of the current messages template to the given reference. |
|
| 138 | - * @param string $context_reference This should be the visible label for the option. |
|
| 139 | - */ |
|
| 140 | - public function switchContextTo($context_reference) |
|
| 141 | - { |
|
| 142 | - $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
| 143 | - $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
| 144 | - $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - |
|
| 148 | - /** |
|
| 149 | - * This takes care of clicking the View Message icon for the given parameters. |
|
| 150 | - * Assumes you are already viewing the messages activity list table. |
|
| 151 | - * @param $message_type_label |
|
| 152 | - * @param $message_status |
|
| 153 | - * @param string $messenger |
|
| 154 | - * @param string $context |
|
| 155 | - * @param int $number_in_set |
|
| 156 | - */ |
|
| 157 | - public function viewMessageInMessagesListTableFor( |
|
| 158 | - $message_type_label, |
|
| 159 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 160 | - $messenger = 'Email', |
|
| 161 | - $context = 'Event Admin', |
|
| 162 | - $number_in_set = 1 |
|
| 163 | - ) { |
|
| 164 | - $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
| 165 | - $message_type_label, |
|
| 166 | - $message_status, |
|
| 167 | - $messenger, |
|
| 168 | - $context, |
|
| 169 | - $number_in_set |
|
| 170 | - )); |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
| 176 | - * Assumes you are already viewing the messages activity list table. |
|
| 177 | - * @param $message_type_label |
|
| 178 | - * @param $message_status |
|
| 179 | - * @param string $messenger |
|
| 180 | - * @param string $context |
|
| 181 | - * @param int $number_in_set |
|
| 182 | - */ |
|
| 183 | - public function deleteMessageInMessagesListTableFor( |
|
| 184 | - $message_type_label, |
|
| 185 | - $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 186 | - $messenger = 'Email', |
|
| 187 | - $context = 'Event Admin', |
|
| 188 | - $number_in_set = 1 |
|
| 189 | - ) { |
|
| 190 | - $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
| 191 | - $message_type_label, |
|
| 192 | - $message_status, |
|
| 193 | - $messenger, |
|
| 194 | - $context, |
|
| 195 | - $number_in_set |
|
| 196 | - ); |
|
| 197 | - $this->actor()->moveMouseOver( |
|
| 198 | - MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 199 | - 'to', |
|
| 200 | - $message_type_label, |
|
| 201 | - $message_status, |
|
| 202 | - $messenger, |
|
| 203 | - $context, |
|
| 204 | - '', |
|
| 205 | - $number_in_set |
|
| 206 | - ), |
|
| 207 | - 5, |
|
| 208 | - 5 |
|
| 209 | - ); |
|
| 210 | - $this->actor()->waitForElementVisible( |
|
| 211 | - $delete_action_selector |
|
| 212 | - ); |
|
| 213 | - $this->actor()->click( |
|
| 214 | - $delete_action_selector |
|
| 215 | - ); |
|
| 216 | - $this->actor()->waitForText('successfully deleted'); |
|
| 217 | - } |
|
| 218 | - |
|
| 219 | - |
|
| 220 | - /** |
|
| 221 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 222 | - * list table, this will take care of validating the given text is in that window. |
|
| 223 | - * @param string $text_to_view |
|
| 224 | - */ |
|
| 225 | - public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
| 226 | - { |
|
| 227 | - $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 228 | - $this->actor()->switchToIframe('message-view-window'); |
|
| 229 | - $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
| 230 | - $this->actor()->switchToIframe(); |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 236 | - * list table, this will take care of validating the given text is NOT that window. |
|
| 237 | - * @param string $text_to_view |
|
| 238 | - */ |
|
| 239 | - public function dontSeeTextInViewMessageModal($text_to_view) |
|
| 240 | - { |
|
| 241 | - $this->seeTextInViewMessageModal($text_to_view, true); |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - public function dismissMessageModal() |
|
| 246 | - { |
|
| 247 | - $this->actor()->click('#espresso-admin-page-overlay-dv'); |
|
| 248 | - //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail. |
|
| 249 | - $this->actor()->click('form#EE_Message_List_Table-table-frm'); |
|
| 250 | - } |
|
| 13 | + /** |
|
| 14 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 15 | + * a string. |
|
| 16 | + */ |
|
| 17 | + public function amOnMessagesActivityListTablePage($additional_params = '') |
|
| 18 | + { |
|
| 19 | + $this->actor()->amOnAdminPage(MessagesPage::messageActivityListTableUrl($additional_params)); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 24 | + * a string. |
|
| 25 | + */ |
|
| 26 | + public function amOnDefaultMessageTemplateListTablePage($additional_params = '') |
|
| 27 | + { |
|
| 28 | + $this->actor()->amOnAdminPage(MessagesPage::defaultMessageTemplateListTableUrl($additional_params)); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @param string $additional_params Any additional request parameters for the generated url should be included as |
|
| 34 | + * a string. |
|
| 35 | + */ |
|
| 36 | + public function amOnCustomMessageTemplateListTablePage($additional_params = '') |
|
| 37 | + { |
|
| 38 | + $this->actor()->amOnAdminPage(MessagesPage::customMessageTemplateListTableUrl($additional_params)); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * Directs to message settings page |
|
| 44 | + */ |
|
| 45 | + public function amOnMessageSettingsPage() |
|
| 46 | + { |
|
| 47 | + $this->actor()->amOnAdminPage(MessagesPage::messageSettingsUrl()); |
|
| 48 | + } |
|
| 49 | + |
|
| 50 | + |
|
| 51 | + public function activateMessageTypeForMessenger($message_type_slug, $messenger_slug = 'email') |
|
| 52 | + { |
|
| 53 | + $this->actor()->dragAndDrop( |
|
| 54 | + MessagesPage::draggableSettingsBoxSelectorForMessageTypeAndMessenger($message_type_slug, $messenger_slug), |
|
| 55 | + MessagesPage::MESSAGES_SETTINGS_ACTIVE_MESSAGE_TYPES_CONTAINER_SELECTOR |
|
| 56 | + ); |
|
| 57 | + } |
|
| 58 | + |
|
| 59 | + |
|
| 60 | + /** |
|
| 61 | + * Assumes you are already on the list table page that has the ui for editing the template. |
|
| 62 | + * @param string $message_type_slug |
|
| 63 | + * @param string $context [optional] if you want to click directly to the given context in the editor |
|
| 64 | + */ |
|
| 65 | + public function clickToEditMessageTemplateByMessageType($message_type_slug, $context = '') |
|
| 66 | + { |
|
| 67 | + $this->actor()->click(MessagesPage::editMessageTemplateClassByMessageType($message_type_slug, $context)); |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * Use this action to verify that the count for the given text in the specified field is as expected. For example |
|
| 73 | + * filling the condition of, "There should only be 1 instance of `[email protected]` in all the 'to' column. |
|
| 74 | + * |
|
| 75 | + * @param int $expected_occurence_count |
|
| 76 | + * @param string $text_to_check_for |
|
| 77 | + * @param string $field |
|
| 78 | + * @param string $message_type_label |
|
| 79 | + * @param string $message_status |
|
| 80 | + * @param string $messenger |
|
| 81 | + * @param string $context |
|
| 82 | + */ |
|
| 83 | + public function verifyMatchingCountofTextInMessageActivityListTableFor( |
|
| 84 | + $expected_occurence_count, |
|
| 85 | + $text_to_check_for, |
|
| 86 | + $field, |
|
| 87 | + $message_type_label, |
|
| 88 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 89 | + $messenger = 'Email', |
|
| 90 | + $context = 'Event Admin' |
|
| 91 | + ) { |
|
| 92 | + $elements = $this->actor()->grabMultiple(MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 93 | + $field, |
|
| 94 | + $message_type_label, |
|
| 95 | + $message_status, |
|
| 96 | + $messenger, |
|
| 97 | + $context, |
|
| 98 | + $text_to_check_for, |
|
| 99 | + 0 |
|
| 100 | + )); |
|
| 101 | + $actual_count = count($elements); |
|
| 102 | + $this->actor()->assertEquals( |
|
| 103 | + $expected_occurence_count, |
|
| 104 | + $actual_count, |
|
| 105 | + sprintf( |
|
| 106 | + 'Expected %s of the %s text for the %s field but there were actually %s counted.', |
|
| 107 | + $expected_occurence_count, |
|
| 108 | + $text_to_check_for, |
|
| 109 | + $field, |
|
| 110 | + $actual_count |
|
| 111 | + ) |
|
| 112 | + ); |
|
| 113 | + } |
|
| 114 | + |
|
| 115 | + |
|
| 116 | + /** |
|
| 117 | + * This will create a custom message template for the given messenger and message type from the context of the |
|
| 118 | + * default (global) message template list table. |
|
| 119 | + * Also takes care of verifying the template was created. |
|
| 120 | + * @param string $message_type_label |
|
| 121 | + * @param string $messenger_label |
|
| 122 | + */ |
|
| 123 | + public function createCustomMessageTemplateFromDefaultFor($message_type_label, $messenger_label) |
|
| 124 | + { |
|
| 125 | + $this->amOnDefaultMessageTemplateListTablePage(); |
|
| 126 | + $this->actor()->click( |
|
| 127 | + MessagesPage::createCustomButtonForMessageTypeAndMessenger( |
|
| 128 | + $message_type_label, |
|
| 129 | + $messenger_label |
|
| 130 | + ) |
|
| 131 | + ); |
|
| 132 | + $this->actor()->seeInField('#title', 'New Custom Template'); |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + /** |
|
| 137 | + * This switches the context of the current messages template to the given reference. |
|
| 138 | + * @param string $context_reference This should be the visible label for the option. |
|
| 139 | + */ |
|
| 140 | + public function switchContextTo($context_reference) |
|
| 141 | + { |
|
| 142 | + $this->actor()->selectOption(MessagesPage::MESSAGES_CONTEXT_SWITCHER_SELECTOR, $context_reference); |
|
| 143 | + $this->actor()->click(MessagesPage::MESSAGES_CONTEXT_SWITCHER_BUTTON_SELECTOR); |
|
| 144 | + $this->actor()->waitForText($context_reference, 10, 'h1'); |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + |
|
| 148 | + /** |
|
| 149 | + * This takes care of clicking the View Message icon for the given parameters. |
|
| 150 | + * Assumes you are already viewing the messages activity list table. |
|
| 151 | + * @param $message_type_label |
|
| 152 | + * @param $message_status |
|
| 153 | + * @param string $messenger |
|
| 154 | + * @param string $context |
|
| 155 | + * @param int $number_in_set |
|
| 156 | + */ |
|
| 157 | + public function viewMessageInMessagesListTableFor( |
|
| 158 | + $message_type_label, |
|
| 159 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 160 | + $messenger = 'Email', |
|
| 161 | + $context = 'Event Admin', |
|
| 162 | + $number_in_set = 1 |
|
| 163 | + ) { |
|
| 164 | + $this->actor()->click(MessagesPage::messagesActivityListTableViewButtonSelectorFor( |
|
| 165 | + $message_type_label, |
|
| 166 | + $message_status, |
|
| 167 | + $messenger, |
|
| 168 | + $context, |
|
| 169 | + $number_in_set |
|
| 170 | + )); |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * Takes care of deleting a message matching the given parameters via the message activity list table. |
|
| 176 | + * Assumes you are already viewing the messages activity list table. |
|
| 177 | + * @param $message_type_label |
|
| 178 | + * @param $message_status |
|
| 179 | + * @param string $messenger |
|
| 180 | + * @param string $context |
|
| 181 | + * @param int $number_in_set |
|
| 182 | + */ |
|
| 183 | + public function deleteMessageInMessagesListTableFor( |
|
| 184 | + $message_type_label, |
|
| 185 | + $message_status = MessagesPage::MESSAGE_STATUS_SENT, |
|
| 186 | + $messenger = 'Email', |
|
| 187 | + $context = 'Event Admin', |
|
| 188 | + $number_in_set = 1 |
|
| 189 | + ) { |
|
| 190 | + $delete_action_selector = MessagesPage::messagesActivityListTableDeleteActionSelectorFor( |
|
| 191 | + $message_type_label, |
|
| 192 | + $message_status, |
|
| 193 | + $messenger, |
|
| 194 | + $context, |
|
| 195 | + $number_in_set |
|
| 196 | + ); |
|
| 197 | + $this->actor()->moveMouseOver( |
|
| 198 | + MessagesPage::messagesActivityListTableCellSelectorFor( |
|
| 199 | + 'to', |
|
| 200 | + $message_type_label, |
|
| 201 | + $message_status, |
|
| 202 | + $messenger, |
|
| 203 | + $context, |
|
| 204 | + '', |
|
| 205 | + $number_in_set |
|
| 206 | + ), |
|
| 207 | + 5, |
|
| 208 | + 5 |
|
| 209 | + ); |
|
| 210 | + $this->actor()->waitForElementVisible( |
|
| 211 | + $delete_action_selector |
|
| 212 | + ); |
|
| 213 | + $this->actor()->click( |
|
| 214 | + $delete_action_selector |
|
| 215 | + ); |
|
| 216 | + $this->actor()->waitForText('successfully deleted'); |
|
| 217 | + } |
|
| 218 | + |
|
| 219 | + |
|
| 220 | + /** |
|
| 221 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 222 | + * list table, this will take care of validating the given text is in that window. |
|
| 223 | + * @param string $text_to_view |
|
| 224 | + */ |
|
| 225 | + public function seeTextInViewMessageModal($text_to_view, $should_not_see = false) |
|
| 226 | + { |
|
| 227 | + $this->actor()->waitForElementVisible('.ee-admin-dialog-container-inner-content'); |
|
| 228 | + $this->actor()->switchToIframe('message-view-window'); |
|
| 229 | + $should_not_see ? $this->actor()->dontSee($text_to_view) : $this->actor()->see($text_to_view); |
|
| 230 | + $this->actor()->switchToIframe(); |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * Assuming you have already triggered the view modal for a single message from the context of the message activity |
|
| 236 | + * list table, this will take care of validating the given text is NOT that window. |
|
| 237 | + * @param string $text_to_view |
|
| 238 | + */ |
|
| 239 | + public function dontSeeTextInViewMessageModal($text_to_view) |
|
| 240 | + { |
|
| 241 | + $this->seeTextInViewMessageModal($text_to_view, true); |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + public function dismissMessageModal() |
|
| 246 | + { |
|
| 247 | + $this->actor()->click('#espresso-admin-page-overlay-dv'); |
|
| 248 | + //this is needed otherwise phantom js gets stuck in the wrong context and any future element events will fail. |
|
| 249 | + $this->actor()->click('form#EE_Message_List_Table-table-frm'); |
|
| 250 | + } |
|
| 251 | 251 | } |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
| 3 | - exit('NO direct script access allowed'); |
|
| 3 | + exit('NO direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | |
| 6 | 6 | |
@@ -17,1177 +17,1177 @@ discard block |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * This is used to hold the reports template data which is setup early in the request. |
|
| 22 | - * |
|
| 23 | - * @type array |
|
| 24 | - */ |
|
| 25 | - protected $_reports_template_data = array(); |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * Extend_Registrations_Admin_Page constructor. |
|
| 31 | - * |
|
| 32 | - * @param bool $routing |
|
| 33 | - */ |
|
| 34 | - public function __construct($routing = true) |
|
| 35 | - { |
|
| 36 | - parent::__construct($routing); |
|
| 37 | - if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 38 | - define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | - define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | - define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 41 | - } |
|
| 42 | - } |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - protected function _extend_page_config() |
|
| 47 | - { |
|
| 48 | - $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | - $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | - ? $this->_req_data['_REG_ID'] |
|
| 51 | - : 0; |
|
| 52 | - // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
| 53 | - // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
| 54 | - // ? $this->_req_data['post'] : $att_id; |
|
| 55 | - $new_page_routes = array( |
|
| 56 | - 'reports' => array( |
|
| 57 | - 'func' => '_registration_reports', |
|
| 58 | - 'capability' => 'ee_read_registrations', |
|
| 59 | - ), |
|
| 60 | - 'registration_checkins' => array( |
|
| 61 | - 'func' => '_registration_checkin_list_table', |
|
| 62 | - 'capability' => 'ee_read_checkins', |
|
| 63 | - ), |
|
| 64 | - 'newsletter_selected_send' => array( |
|
| 65 | - 'func' => '_newsletter_selected_send', |
|
| 66 | - 'noheader' => true, |
|
| 67 | - 'capability' => 'ee_send_message', |
|
| 68 | - ), |
|
| 69 | - 'delete_checkin_rows' => array( |
|
| 70 | - 'func' => '_delete_checkin_rows', |
|
| 71 | - 'noheader' => true, |
|
| 72 | - 'capability' => 'ee_delete_checkins', |
|
| 73 | - ), |
|
| 74 | - 'delete_checkin_row' => array( |
|
| 75 | - 'func' => '_delete_checkin_row', |
|
| 76 | - 'noheader' => true, |
|
| 77 | - 'capability' => 'ee_delete_checkin', |
|
| 78 | - 'obj_id' => $reg_id, |
|
| 79 | - ), |
|
| 80 | - 'toggle_checkin_status' => array( |
|
| 81 | - 'func' => '_toggle_checkin_status', |
|
| 82 | - 'noheader' => true, |
|
| 83 | - 'capability' => 'ee_edit_checkin', |
|
| 84 | - 'obj_id' => $reg_id, |
|
| 85 | - ), |
|
| 86 | - 'toggle_checkin_status_bulk' => array( |
|
| 87 | - 'func' => '_toggle_checkin_status', |
|
| 88 | - 'noheader' => true, |
|
| 89 | - 'capability' => 'ee_edit_checkins' |
|
| 90 | - ), |
|
| 91 | - 'event_registrations' => array( |
|
| 92 | - 'func' => '_event_registrations_list_table', |
|
| 93 | - 'capability' => 'ee_read_checkins', |
|
| 94 | - ), |
|
| 95 | - 'registrations_checkin_report' => array( |
|
| 96 | - 'func' => '_registrations_checkin_report', |
|
| 97 | - 'noheader' => true, |
|
| 98 | - 'capability' => 'ee_read_registrations', |
|
| 99 | - ), |
|
| 100 | - ); |
|
| 101 | - $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 102 | - $new_page_config = array( |
|
| 103 | - 'reports' => array( |
|
| 104 | - 'nav' => array( |
|
| 105 | - 'label' => __('Reports', 'event_espresso'), |
|
| 106 | - 'order' => 30, |
|
| 107 | - ), |
|
| 108 | - 'help_tabs' => array( |
|
| 109 | - 'registrations_reports_help_tab' => array( |
|
| 110 | - 'title' => __('Registration Reports', 'event_espresso'), |
|
| 111 | - 'filename' => 'registrations_reports', |
|
| 112 | - ), |
|
| 113 | - ), |
|
| 114 | - /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 115 | - 'require_nonce' => false, |
|
| 116 | - ), |
|
| 117 | - 'event_registrations' => array( |
|
| 118 | - 'nav' => array( |
|
| 119 | - 'label' => __('Event Check-In', 'event_espresso'), |
|
| 120 | - 'order' => 10, |
|
| 121 | - 'persistent' => true, |
|
| 122 | - ), |
|
| 123 | - 'help_tabs' => array( |
|
| 124 | - 'registrations_event_checkin_help_tab' => array( |
|
| 125 | - 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
| 126 | - 'filename' => 'registrations_event_checkin', |
|
| 127 | - ), |
|
| 128 | - 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 129 | - 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 130 | - 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 131 | - ), |
|
| 132 | - 'registrations_event_checkin_filters_help_tab' => array( |
|
| 133 | - 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
| 134 | - 'filename' => 'registrations_event_checkin_filters', |
|
| 135 | - ), |
|
| 136 | - 'registrations_event_checkin_views_help_tab' => array( |
|
| 137 | - 'title' => __('Event Check-In Views', 'event_espresso'), |
|
| 138 | - 'filename' => 'registrations_event_checkin_views', |
|
| 139 | - ), |
|
| 140 | - 'registrations_event_checkin_other_help_tab' => array( |
|
| 141 | - 'title' => __('Event Check-In Other', 'event_espresso'), |
|
| 142 | - 'filename' => 'registrations_event_checkin_other', |
|
| 143 | - ), |
|
| 144 | - ), |
|
| 145 | - 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 146 | - 'qtips' => array('Registration_List_Table_Tips'), |
|
| 147 | - 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 148 | - 'metaboxes' => array(), |
|
| 149 | - 'require_nonce' => false, |
|
| 150 | - ), |
|
| 151 | - 'registration_checkins' => array( |
|
| 152 | - 'nav' => array( |
|
| 153 | - 'label' => __('Check-In Records', 'event_espresso'), |
|
| 154 | - 'order' => 15, |
|
| 155 | - 'persistent' => false, |
|
| 156 | - ), |
|
| 157 | - 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 158 | - //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 159 | - 'metaboxes' => array(), |
|
| 160 | - 'require_nonce' => false, |
|
| 161 | - ), |
|
| 162 | - ); |
|
| 163 | - $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 164 | - $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 165 | - $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - |
|
| 170 | - protected function _ajax_hooks() |
|
| 171 | - { |
|
| 172 | - parent::_ajax_hooks(); |
|
| 173 | - add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - public function load_scripts_styles() |
|
| 179 | - { |
|
| 180 | - parent::load_scripts_styles(); |
|
| 181 | - //if newsletter message type is active then let's add filter and load js for it. |
|
| 182 | - if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 183 | - //enqueue newsletter js |
|
| 184 | - wp_enqueue_script( |
|
| 185 | - 'ee-newsletter-trigger', |
|
| 186 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 187 | - array('ee-dialog'), |
|
| 188 | - EVENT_ESPRESSO_VERSION, |
|
| 189 | - true |
|
| 190 | - ); |
|
| 191 | - wp_enqueue_style( |
|
| 192 | - 'ee-newsletter-trigger-css', |
|
| 193 | - REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 194 | - array(), |
|
| 195 | - EVENT_ESPRESSO_VERSION |
|
| 196 | - ); |
|
| 197 | - //hook in buttons for newsletter message type trigger. |
|
| 198 | - add_action( |
|
| 199 | - 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 200 | - array($this, 'add_newsletter_action_buttons'), |
|
| 201 | - 10 |
|
| 202 | - ); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - |
|
| 206 | - |
|
| 207 | - |
|
| 208 | - public function load_scripts_styles_reports() |
|
| 209 | - { |
|
| 210 | - wp_register_script( |
|
| 211 | - 'ee-reg-reports-js', |
|
| 212 | - REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 213 | - array('google-charts'), |
|
| 214 | - EVENT_ESPRESSO_VERSION, |
|
| 215 | - true |
|
| 216 | - ); |
|
| 217 | - wp_enqueue_script('ee-reg-reports-js'); |
|
| 218 | - $this->_registration_reports_js_setup(); |
|
| 219 | - } |
|
| 220 | - |
|
| 221 | - |
|
| 222 | - |
|
| 223 | - protected function _add_screen_options_event_registrations() |
|
| 224 | - { |
|
| 225 | - $this->_per_page_screen_option(); |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - |
|
| 229 | - |
|
| 230 | - protected function _add_screen_options_registration_checkins() |
|
| 231 | - { |
|
| 232 | - $page_title = $this->_admin_page_title; |
|
| 233 | - $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
| 234 | - $this->_per_page_screen_option(); |
|
| 235 | - $this->_admin_page_title = $page_title; |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - |
|
| 240 | - protected function _set_list_table_views_event_registrations() |
|
| 241 | - { |
|
| 242 | - $this->_views = array( |
|
| 243 | - 'all' => array( |
|
| 244 | - 'slug' => 'all', |
|
| 245 | - 'label' => __('All', 'event_espresso'), |
|
| 246 | - 'count' => 0, |
|
| 247 | - 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 248 | - ? array() |
|
| 249 | - : array( |
|
| 250 | - 'toggle_checkin_status_bulk' => __('Toggle Check-In', 'event_espresso'), |
|
| 251 | - ), |
|
| 252 | - ), |
|
| 253 | - ); |
|
| 254 | - } |
|
| 255 | - |
|
| 256 | - |
|
| 257 | - |
|
| 258 | - protected function _set_list_table_views_registration_checkins() |
|
| 259 | - { |
|
| 260 | - $this->_views = array( |
|
| 261 | - 'all' => array( |
|
| 262 | - 'slug' => 'all', |
|
| 263 | - 'label' => __('All', 'event_espresso'), |
|
| 264 | - 'count' => 0, |
|
| 265 | - 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
| 266 | - ), |
|
| 267 | - ); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - |
|
| 272 | - /** |
|
| 273 | - * callback for ajax action. |
|
| 274 | - * |
|
| 275 | - * @since 4.3.0 |
|
| 276 | - * @return void (JSON) |
|
| 277 | - * @throws \EE_Error |
|
| 278 | - */ |
|
| 279 | - public function get_newsletter_form_content() |
|
| 280 | - { |
|
| 281 | - //do a nonce check cause we're not coming in from an normal route here. |
|
| 282 | - $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 283 | - $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 284 | - ) : ''; |
|
| 285 | - $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 286 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 287 | - //let's get the mtp for the incoming MTP_ ID |
|
| 288 | - if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 289 | - EE_Error::add_error( |
|
| 290 | - __( |
|
| 291 | - 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 292 | - 'event_espresso' |
|
| 293 | - ), |
|
| 294 | - __FILE__, |
|
| 295 | - __FUNCTION__, |
|
| 296 | - __LINE__ |
|
| 297 | - ); |
|
| 298 | - $this->_template_args['success'] = false; |
|
| 299 | - $this->_template_args['error'] = true; |
|
| 300 | - $this->_return_json(); |
|
| 301 | - } |
|
| 302 | - $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 303 | - if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 304 | - EE_Error::add_error( |
|
| 305 | - sprintf( |
|
| 306 | - __( |
|
| 307 | - 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 308 | - 'event_espresso' |
|
| 309 | - ), |
|
| 310 | - $this->_req_data['GRP_ID'] |
|
| 311 | - ), |
|
| 312 | - __FILE__, |
|
| 313 | - __FUNCTION__, |
|
| 314 | - __LINE__ |
|
| 315 | - ); |
|
| 316 | - $this->_template_args['success'] = false; |
|
| 317 | - $this->_template_args['error'] = true; |
|
| 318 | - $this->_return_json(); |
|
| 319 | - } |
|
| 320 | - $MTPs = $MTPG->context_templates(); |
|
| 321 | - $MTPs = $MTPs['attendee']; |
|
| 322 | - $template_fields = array(); |
|
| 323 | - /** @var EE_Message_Template $MTP */ |
|
| 324 | - foreach ($MTPs as $MTP) { |
|
| 325 | - $field = $MTP->get('MTP_template_field'); |
|
| 326 | - if ($field === 'content') { |
|
| 327 | - $content = $MTP->get('MTP_content'); |
|
| 328 | - if ( ! empty($content['newsletter_content'])) { |
|
| 329 | - $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 330 | - } |
|
| 331 | - continue; |
|
| 332 | - } |
|
| 333 | - $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 334 | - } |
|
| 335 | - $this->_template_args['success'] = true; |
|
| 336 | - $this->_template_args['error'] = false; |
|
| 337 | - $this->_template_args['data'] = array( |
|
| 338 | - 'batch_message_from' => isset($template_fields['from']) |
|
| 339 | - ? $template_fields['from'] |
|
| 340 | - : '', |
|
| 341 | - 'batch_message_subject' => isset($template_fields['subject']) |
|
| 342 | - ? $template_fields['subject'] |
|
| 343 | - : '', |
|
| 344 | - 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 345 | - ? $template_fields['newsletter_content'] |
|
| 346 | - : '', |
|
| 347 | - ); |
|
| 348 | - $this->_return_json(); |
|
| 349 | - } |
|
| 350 | - |
|
| 351 | - |
|
| 352 | - |
|
| 353 | - /** |
|
| 354 | - * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 355 | - * |
|
| 356 | - * @since 4.3.0 |
|
| 357 | - * @param EE_Admin_List_Table $list_table |
|
| 358 | - * @return void |
|
| 359 | - */ |
|
| 360 | - public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 361 | - { |
|
| 362 | - if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 363 | - 'ee_send_message', |
|
| 364 | - 'espresso_registrations_newsletter_selected_send' |
|
| 365 | - ) |
|
| 366 | - ) { |
|
| 367 | - return; |
|
| 368 | - } |
|
| 369 | - $routes_to_add_to = array( |
|
| 370 | - 'contact_list', |
|
| 371 | - 'event_registrations', |
|
| 372 | - 'default', |
|
| 373 | - ); |
|
| 374 | - if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 375 | - if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 376 | - || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 377 | - ) { |
|
| 378 | - echo ''; |
|
| 379 | - } else { |
|
| 380 | - $button_text = sprintf( |
|
| 381 | - __('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 382 | - '<span class="send-selected-newsletter-count">0</span>' |
|
| 383 | - ); |
|
| 384 | - echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
| 385 | - . $button_text |
|
| 386 | - . '</button>'; |
|
| 387 | - add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 388 | - } |
|
| 389 | - } |
|
| 390 | - } |
|
| 391 | - |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - public function newsletter_send_form_skeleton() |
|
| 395 | - { |
|
| 396 | - $list_table = $this->_list_table_object; |
|
| 397 | - $codes = array(); |
|
| 398 | - //need to templates for the newsletter message type for the template selector. |
|
| 399 | - $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 400 | - $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 401 | - array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 402 | - ); |
|
| 403 | - foreach ($mtps as $mtp) { |
|
| 404 | - $name = $mtp->name(); |
|
| 405 | - $values[] = array( |
|
| 406 | - 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
| 407 | - 'id' => $mtp->ID(), |
|
| 408 | - ); |
|
| 409 | - } |
|
| 410 | - //need to get a list of shortcodes that are available for the newsletter message type. |
|
| 411 | - $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
| 412 | - foreach ($shortcodes as $field => $shortcode_array) { |
|
| 413 | - $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
| 414 | - } |
|
| 415 | - $shortcodes = $codes; |
|
| 416 | - $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 417 | - $form_template_args = array( |
|
| 418 | - 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 419 | - 'form_route' => 'newsletter_selected_send', |
|
| 420 | - 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 421 | - 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 422 | - 'redirect_back_to' => $this->_req_action, |
|
| 423 | - 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 424 | - 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 425 | - 'shortcodes' => $shortcodes, |
|
| 426 | - 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 427 | - ); |
|
| 428 | - EEH_Template::display_template($form_template, $form_template_args); |
|
| 429 | - } |
|
| 430 | - |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - /** |
|
| 434 | - * Handles sending selected registrations/contacts a newsletter. |
|
| 435 | - * |
|
| 436 | - * @since 4.3.0 |
|
| 437 | - * @return void |
|
| 438 | - * @throws \EE_Error |
|
| 439 | - */ |
|
| 440 | - protected function _newsletter_selected_send() |
|
| 441 | - { |
|
| 442 | - $success = true; |
|
| 443 | - //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 444 | - if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 445 | - EE_Error::add_error( |
|
| 446 | - __( |
|
| 447 | - 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 448 | - 'event_espresso' |
|
| 449 | - ), |
|
| 450 | - __FILE__, |
|
| 451 | - __FUNCTION__, |
|
| 452 | - __LINE__ |
|
| 453 | - ); |
|
| 454 | - $success = false; |
|
| 455 | - } |
|
| 456 | - if ($success) { |
|
| 457 | - //update Message template in case there are any changes |
|
| 458 | - $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 459 | - $this->_req_data['newsletter_mtp_selected'] |
|
| 460 | - ); |
|
| 461 | - $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 462 | - ? $Message_Template_Group->context_templates() |
|
| 463 | - : array(); |
|
| 464 | - if (empty($Message_Templates)) { |
|
| 465 | - EE_Error::add_error( |
|
| 466 | - __( |
|
| 467 | - 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 468 | - 'event_espresso' |
|
| 469 | - ), |
|
| 470 | - __FILE__, |
|
| 471 | - __FUNCTION__, |
|
| 472 | - __LINE__ |
|
| 473 | - ); |
|
| 474 | - } |
|
| 475 | - //let's just update the specific fields |
|
| 476 | - foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 477 | - if ($Message_Template instanceof EE_Message_Template) { |
|
| 478 | - $field = $Message_Template->get('MTP_template_field'); |
|
| 479 | - $content = $Message_Template->get('MTP_content'); |
|
| 480 | - $new_content = $content; |
|
| 481 | - switch ($field) { |
|
| 482 | - case 'from' : |
|
| 483 | - $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 484 | - ? $this->_req_data['batch_message']['from'] |
|
| 485 | - : $content; |
|
| 486 | - break; |
|
| 487 | - case 'subject' : |
|
| 488 | - $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 489 | - ? $this->_req_data['batch_message']['subject'] |
|
| 490 | - : $content; |
|
| 491 | - break; |
|
| 492 | - case 'content' : |
|
| 493 | - $new_content = $content; |
|
| 494 | - $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 495 | - ? $this->_req_data['batch_message']['content'] |
|
| 496 | - : $content['newsletter_content']; |
|
| 497 | - break; |
|
| 498 | - default : |
|
| 499 | - //continue the foreach loop, we don't want to set $new_content nor save. |
|
| 500 | - continue 2; |
|
| 501 | - } |
|
| 502 | - $Message_Template->set('MTP_content', $new_content); |
|
| 503 | - $Message_Template->save(); |
|
| 504 | - } |
|
| 505 | - } |
|
| 506 | - //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 507 | - $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 508 | - ? $this->_req_data['batch_message']['id_type'] |
|
| 509 | - : 'registration'; |
|
| 510 | - //id_type will affect how we assemble the ids. |
|
| 511 | - $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 512 | - ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 513 | - : array(); |
|
| 514 | - $registrations_used_for_contact_data = array(); |
|
| 515 | - //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 516 | - switch ($id_type) { |
|
| 517 | - case 'registration' : |
|
| 518 | - $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 519 | - array( |
|
| 520 | - array( |
|
| 521 | - 'REG_ID' => array('IN', $ids), |
|
| 522 | - ), |
|
| 523 | - ) |
|
| 524 | - ); |
|
| 525 | - break; |
|
| 526 | - case 'contact' : |
|
| 527 | - $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 528 | - ->get_latest_registration_for_each_of_given_contacts($ids); |
|
| 529 | - break; |
|
| 530 | - } |
|
| 531 | - do_action( |
|
| 532 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 533 | - $registrations_used_for_contact_data, |
|
| 534 | - $Message_Template_Group->ID() |
|
| 535 | - ); |
|
| 536 | - //kept for backward compat, internally we no longer use this action. |
|
| 537 | - //@deprecated 4.8.36.rc.002 |
|
| 538 | - $contacts = $id_type === 'registration' |
|
| 539 | - ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 540 | - : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 541 | - do_action( |
|
| 542 | - 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 543 | - $contacts, |
|
| 544 | - $Message_Template_Group->ID() |
|
| 545 | - ); |
|
| 546 | - } |
|
| 547 | - $query_args = array( |
|
| 548 | - 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 549 | - ? $this->_req_data['redirect_back_to'] |
|
| 550 | - : 'default', |
|
| 551 | - ); |
|
| 552 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 553 | - } |
|
| 554 | - |
|
| 555 | - |
|
| 556 | - |
|
| 557 | - /** |
|
| 558 | - * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 559 | - * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 560 | - */ |
|
| 561 | - protected function _registration_reports_js_setup() |
|
| 562 | - { |
|
| 563 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 564 | - $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * generates Business Reports regarding Registrations |
|
| 571 | - * |
|
| 572 | - * @access protected |
|
| 573 | - * @return void |
|
| 574 | - */ |
|
| 575 | - protected function _registration_reports() |
|
| 576 | - { |
|
| 577 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 578 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 579 | - $template_path, |
|
| 580 | - $this->_reports_template_data, |
|
| 581 | - true |
|
| 582 | - ); |
|
| 583 | - // the final template wrapper |
|
| 584 | - $this->display_admin_page_with_no_sidebar(); |
|
| 585 | - } |
|
| 586 | - |
|
| 587 | - |
|
| 588 | - |
|
| 589 | - /** |
|
| 590 | - * Generates Business Report showing total registrations per day. |
|
| 591 | - * |
|
| 592 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 593 | - * @return string |
|
| 594 | - */ |
|
| 595 | - private function _registrations_per_day_report($period = '-1 month') |
|
| 596 | - { |
|
| 597 | - $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 598 | - $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 599 | - $results = (array)$results; |
|
| 600 | - $regs = array(); |
|
| 601 | - $subtitle = ''; |
|
| 602 | - if ($results) { |
|
| 603 | - $column_titles = array(); |
|
| 604 | - $tracker = 0; |
|
| 605 | - foreach ($results as $result) { |
|
| 606 | - $report_column_values = array(); |
|
| 607 | - foreach ($result as $property_name => $property_value) { |
|
| 608 | - $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 609 | - : (int)$property_value; |
|
| 610 | - $report_column_values[] = $property_value; |
|
| 611 | - if ($tracker === 0) { |
|
| 612 | - if ($property_name === 'Registration_REG_date') { |
|
| 613 | - $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
| 614 | - } else { |
|
| 615 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 616 | - } |
|
| 617 | - } |
|
| 618 | - } |
|
| 619 | - $tracker++; |
|
| 620 | - $regs[] = $report_column_values; |
|
| 621 | - } |
|
| 622 | - //make sure the column_titles is pushed to the beginning of the array |
|
| 623 | - array_unshift($regs, $column_titles); |
|
| 624 | - //setup the date range. |
|
| 625 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 626 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 627 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 628 | - $subtitle = sprintf( |
|
| 629 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 630 | - $beginning_date->format('Y-m-d'), |
|
| 631 | - $ending_date->format('Y-m-d') |
|
| 632 | - ); |
|
| 633 | - } |
|
| 634 | - $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
| 635 | - $report_params = array( |
|
| 636 | - 'title' => $report_title, |
|
| 637 | - 'subtitle' => $subtitle, |
|
| 638 | - 'id' => $report_ID, |
|
| 639 | - 'regs' => $regs, |
|
| 640 | - 'noResults' => empty($regs), |
|
| 641 | - 'noRegsMsg' => sprintf( |
|
| 642 | - __( |
|
| 643 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 644 | - 'event_espresso' |
|
| 645 | - ), |
|
| 646 | - '<h2>' . $report_title . '</h2><p>', |
|
| 647 | - '</p>' |
|
| 648 | - ), |
|
| 649 | - ); |
|
| 650 | - wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 651 | - return $report_ID; |
|
| 652 | - } |
|
| 653 | - |
|
| 654 | - |
|
| 655 | - |
|
| 656 | - /** |
|
| 657 | - * Generates Business Report showing total registrations per event. |
|
| 658 | - * |
|
| 659 | - * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 660 | - * @return string |
|
| 661 | - */ |
|
| 662 | - private function _registrations_per_event_report($period = '-1 month') |
|
| 663 | - { |
|
| 664 | - $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 665 | - $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 666 | - $results = (array)$results; |
|
| 667 | - $regs = array(); |
|
| 668 | - $subtitle = ''; |
|
| 669 | - if ($results) { |
|
| 670 | - $column_titles = array(); |
|
| 671 | - $tracker = 0; |
|
| 672 | - foreach ($results as $result) { |
|
| 673 | - $report_column_values = array(); |
|
| 674 | - foreach ($result as $property_name => $property_value) { |
|
| 675 | - $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 676 | - $property_value, |
|
| 677 | - 4, |
|
| 678 | - '...' |
|
| 679 | - ) : (int)$property_value; |
|
| 680 | - $report_column_values[] = $property_value; |
|
| 681 | - if ($tracker === 0) { |
|
| 682 | - if ($property_name === 'Registration_Event') { |
|
| 683 | - $column_titles[] = __('Event', 'event_espresso'); |
|
| 684 | - } else { |
|
| 685 | - $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 686 | - } |
|
| 687 | - } |
|
| 688 | - } |
|
| 689 | - $tracker++; |
|
| 690 | - $regs[] = $report_column_values; |
|
| 691 | - } |
|
| 692 | - //make sure the column_titles is pushed to the beginning of the array |
|
| 693 | - array_unshift($regs, $column_titles); |
|
| 694 | - //setup the date range. |
|
| 695 | - $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 696 | - $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 697 | - $ending_date = new DateTime("now", $DateTimeZone); |
|
| 698 | - $subtitle = sprintf( |
|
| 699 | - _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 700 | - $beginning_date->format('Y-m-d'), |
|
| 701 | - $ending_date->format('Y-m-d') |
|
| 702 | - ); |
|
| 703 | - } |
|
| 704 | - $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
| 705 | - $report_params = array( |
|
| 706 | - 'title' => $report_title, |
|
| 707 | - 'subtitle' => $subtitle, |
|
| 708 | - 'id' => $report_ID, |
|
| 709 | - 'regs' => $regs, |
|
| 710 | - 'noResults' => empty($regs), |
|
| 711 | - 'noRegsMsg' => sprintf( |
|
| 712 | - __( |
|
| 713 | - '%sThere are currently no registration records in the last month for this report.%s', |
|
| 714 | - 'event_espresso' |
|
| 715 | - ), |
|
| 716 | - '<h2>' . $report_title . '</h2><p>', |
|
| 717 | - '</p>' |
|
| 718 | - ), |
|
| 719 | - ); |
|
| 720 | - wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 721 | - return $report_ID; |
|
| 722 | - } |
|
| 723 | - |
|
| 724 | - |
|
| 725 | - |
|
| 726 | - /** |
|
| 727 | - * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 728 | - * |
|
| 729 | - * @access protected |
|
| 730 | - * @return void |
|
| 731 | - * @throws \EE_Error |
|
| 732 | - */ |
|
| 733 | - protected function _registration_checkin_list_table() |
|
| 734 | - { |
|
| 735 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 736 | - $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
| 737 | - /** @var EE_Registration $registration */ |
|
| 738 | - $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 739 | - $attendee = $registration->attendee(); |
|
| 740 | - $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 741 | - 'new_registration', |
|
| 742 | - 'add-registrant', |
|
| 743 | - array('event_id' => $registration->event_ID()), |
|
| 744 | - 'add-new-h2' |
|
| 745 | - ); |
|
| 746 | - $legend_items = array( |
|
| 747 | - 'checkin' => array( |
|
| 748 | - 'class' => 'ee-icon ee-icon-check-in', |
|
| 749 | - 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
| 750 | - ), |
|
| 751 | - 'checkout' => array( |
|
| 752 | - 'class' => 'ee-icon ee-icon-check-out', |
|
| 753 | - 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
| 754 | - ), |
|
| 755 | - ); |
|
| 756 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 757 | - $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 758 | - /** @var EE_Datetime $datetime */ |
|
| 759 | - $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
| 760 | - $datetime_label = ''; |
|
| 761 | - if ($datetime instanceof EE_Datetime) { |
|
| 762 | - $datetime_label = $datetime->get_dtt_display_name(true); |
|
| 763 | - $datetime_label .= ! empty($datetime_label) |
|
| 764 | - ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 765 | - : $datetime->get_dtt_display_name(); |
|
| 766 | - } |
|
| 767 | - $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
| 768 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 769 | - array( |
|
| 770 | - 'action' => 'event_registrations', |
|
| 771 | - 'event_id' => $registration->event_ID(), |
|
| 772 | - 'DTT_ID' => $dtt_id, |
|
| 773 | - ), |
|
| 774 | - $this->_admin_base_url |
|
| 775 | - ) |
|
| 776 | - : ''; |
|
| 777 | - $datetime_link = ! empty($datetime_link) |
|
| 778 | - ? '<a href="' . $datetime_link . '">' |
|
| 779 | - . '<span id="checkin-dtt">' |
|
| 780 | - . $datetime_label |
|
| 781 | - . '</span></a>' |
|
| 782 | - : $datetime_label; |
|
| 783 | - $attendee_name = $attendee instanceof EE_Attendee |
|
| 784 | - ? $attendee->full_name() |
|
| 785 | - : ''; |
|
| 786 | - $attendee_link = $attendee instanceof EE_Attendee |
|
| 787 | - ? $attendee->get_admin_details_link() |
|
| 788 | - : ''; |
|
| 789 | - $attendee_link = ! empty($attendee_link) |
|
| 790 | - ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 791 | - . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 792 | - . '<span id="checkin-attendee-name">' |
|
| 793 | - . $attendee_name |
|
| 794 | - . '</span></a>' |
|
| 795 | - : ''; |
|
| 796 | - $event_link = $registration->event() instanceof EE_Event |
|
| 797 | - ? $registration->event()->get_admin_details_link() |
|
| 798 | - : ''; |
|
| 799 | - $event_link = ! empty($event_link) |
|
| 800 | - ? '<a href="' . $event_link . '"' |
|
| 801 | - . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 802 | - . '<span id="checkin-event-name">' |
|
| 803 | - . $registration->event_name() |
|
| 804 | - . '</span>' |
|
| 805 | - . '</a>' |
|
| 806 | - : ''; |
|
| 807 | - $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 808 | - ? '<h2>' . sprintf( |
|
| 809 | - esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
| 810 | - $attendee_link, |
|
| 811 | - $datetime_link, |
|
| 812 | - $event_link |
|
| 813 | - ) . '</h2>' |
|
| 814 | - : ''; |
|
| 815 | - $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 816 | - ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 817 | - $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 818 | - ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 819 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 820 | - } |
|
| 821 | - |
|
| 822 | - |
|
| 823 | - |
|
| 824 | - /** |
|
| 825 | - * toggle the Check-in status for the given registration (coming from ajax) |
|
| 826 | - * |
|
| 827 | - * @return void (JSON) |
|
| 828 | - */ |
|
| 829 | - public function toggle_checkin_status() |
|
| 830 | - { |
|
| 831 | - //first make sure we have the necessary data |
|
| 832 | - if ( ! isset($this->_req_data['_regid'])) { |
|
| 833 | - EE_Error::add_error( |
|
| 834 | - __( |
|
| 835 | - 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 836 | - 'event_espresso' |
|
| 837 | - ), |
|
| 838 | - __FILE__, |
|
| 839 | - __FUNCTION__, |
|
| 840 | - __LINE__ |
|
| 841 | - ); |
|
| 842 | - $this->_template_args['success'] = false; |
|
| 843 | - $this->_template_args['error'] = true; |
|
| 844 | - $this->_return_json(); |
|
| 845 | - }; |
|
| 846 | - //do a nonce check cause we're not coming in from an normal route here. |
|
| 847 | - $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 848 | - : ''; |
|
| 849 | - $nonce_ref = 'checkin_nonce'; |
|
| 850 | - $this->_verify_nonce($nonce, $nonce_ref); |
|
| 851 | - //beautiful! Made it this far so let's get the status. |
|
| 852 | - $new_status = $this->_toggle_checkin_status(); |
|
| 853 | - //setup new class to return via ajax |
|
| 854 | - $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
|
| 855 | - . $new_status; |
|
| 856 | - $this->_template_args['success'] = true; |
|
| 857 | - $this->_return_json(); |
|
| 858 | - } |
|
| 859 | - |
|
| 860 | - |
|
| 861 | - |
|
| 862 | - /** |
|
| 863 | - * handles toggling the checkin status for the registration, |
|
| 864 | - * |
|
| 865 | - * @access protected |
|
| 866 | - * @return int|void |
|
| 867 | - */ |
|
| 868 | - protected function _toggle_checkin_status() |
|
| 869 | - { |
|
| 870 | - //first let's get the query args out of the way for the redirect |
|
| 871 | - $query_args = array( |
|
| 872 | - 'action' => 'event_registrations', |
|
| 873 | - 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 874 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 875 | - ); |
|
| 876 | - $new_status = false; |
|
| 877 | - // bulk action check in toggle |
|
| 878 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 879 | - // cycle thru checkboxes |
|
| 880 | - while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 881 | - $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 882 | - $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 883 | - } |
|
| 884 | - } elseif (isset($this->_req_data['_regid'])) { |
|
| 885 | - //coming from ajax request |
|
| 886 | - $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 887 | - $query_args['DTT_ID'] = $DTT_ID; |
|
| 888 | - $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 889 | - } else { |
|
| 890 | - EE_Error::add_error( |
|
| 891 | - __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 892 | - __FILE__, |
|
| 893 | - __FUNCTION__, |
|
| 894 | - __LINE__ |
|
| 895 | - ); |
|
| 896 | - } |
|
| 897 | - if (defined('DOING_AJAX')) { |
|
| 898 | - return $new_status; |
|
| 899 | - } |
|
| 900 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 901 | - } |
|
| 902 | - |
|
| 903 | - |
|
| 904 | - |
|
| 905 | - /** |
|
| 906 | - * This is toggles a single Check-in for the given registration and datetime. |
|
| 907 | - * |
|
| 908 | - * @param int $REG_ID The registration we're toggling |
|
| 909 | - * @param int $DTT_ID The datetime we're toggling |
|
| 910 | - * @return int The new status toggled to. |
|
| 911 | - * @throws \EE_Error |
|
| 912 | - */ |
|
| 913 | - private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 914 | - { |
|
| 915 | - /** @var EE_Registration $REG */ |
|
| 916 | - $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 917 | - $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 918 | - if ($new_status !== false) { |
|
| 919 | - EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 920 | - } else { |
|
| 921 | - EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 922 | - $new_status = false; |
|
| 923 | - } |
|
| 924 | - return $new_status; |
|
| 925 | - } |
|
| 926 | - |
|
| 927 | - |
|
| 928 | - |
|
| 929 | - /** |
|
| 930 | - * Takes care of deleting multiple EE_Checkin table rows |
|
| 931 | - * |
|
| 932 | - * @access protected |
|
| 933 | - * @return void |
|
| 934 | - * @throws \EE_Error |
|
| 935 | - */ |
|
| 936 | - protected function _delete_checkin_rows() |
|
| 937 | - { |
|
| 938 | - $query_args = array( |
|
| 939 | - 'action' => 'registration_checkins', |
|
| 940 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 941 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 942 | - ); |
|
| 943 | - $errors = 0; |
|
| 944 | - if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 945 | - while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 946 | - if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 947 | - $errors++; |
|
| 948 | - } |
|
| 949 | - } |
|
| 950 | - } else { |
|
| 951 | - EE_Error::add_error( |
|
| 952 | - __( |
|
| 953 | - 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 954 | - 'event_espresso' |
|
| 955 | - ), |
|
| 956 | - __FILE__, |
|
| 957 | - __FUNCTION__, |
|
| 958 | - __LINE__ |
|
| 959 | - ); |
|
| 960 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 961 | - } |
|
| 962 | - if ($errors > 0) { |
|
| 963 | - EE_Error::add_error( |
|
| 964 | - sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 965 | - __FILE__, |
|
| 966 | - __FUNCTION__, |
|
| 967 | - __LINE__ |
|
| 968 | - ); |
|
| 969 | - } else { |
|
| 970 | - EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
| 971 | - } |
|
| 972 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 973 | - } |
|
| 974 | - |
|
| 975 | - |
|
| 976 | - |
|
| 977 | - /** |
|
| 978 | - * Deletes a single EE_Checkin row |
|
| 979 | - * |
|
| 980 | - * @return void |
|
| 981 | - * @throws \EE_Error |
|
| 982 | - */ |
|
| 983 | - protected function _delete_checkin_row() |
|
| 984 | - { |
|
| 985 | - $query_args = array( |
|
| 986 | - 'action' => 'registration_checkins', |
|
| 987 | - 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 988 | - '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 989 | - ); |
|
| 990 | - if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 991 | - if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 992 | - EE_Error::add_error( |
|
| 993 | - __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 994 | - __FILE__, |
|
| 995 | - __FUNCTION__, |
|
| 996 | - __LINE__ |
|
| 997 | - ); |
|
| 998 | - } else { |
|
| 999 | - EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
| 1000 | - } |
|
| 1001 | - } else { |
|
| 1002 | - EE_Error::add_error( |
|
| 1003 | - __( |
|
| 1004 | - 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 1005 | - 'event_espresso' |
|
| 1006 | - ), |
|
| 1007 | - __FILE__, |
|
| 1008 | - __FUNCTION__, |
|
| 1009 | - __LINE__ |
|
| 1010 | - ); |
|
| 1011 | - } |
|
| 1012 | - $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1013 | - } |
|
| 1014 | - |
|
| 1015 | - |
|
| 1016 | - |
|
| 1017 | - /** |
|
| 1018 | - * generates HTML for the Event Registrations List Table |
|
| 1019 | - * |
|
| 1020 | - * @access protected |
|
| 1021 | - * @return void |
|
| 1022 | - * @throws \EE_Error |
|
| 1023 | - */ |
|
| 1024 | - protected function _event_registrations_list_table() |
|
| 1025 | - { |
|
| 1026 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1027 | - $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 1028 | - ? $this->get_action_link_or_button( |
|
| 1029 | - 'new_registration', |
|
| 1030 | - 'add-registrant', |
|
| 1031 | - array('event_id' => $this->_req_data['event_id']), |
|
| 1032 | - 'add-new-h2', |
|
| 1033 | - '', |
|
| 1034 | - false |
|
| 1035 | - ) |
|
| 1036 | - : ''; |
|
| 1037 | - $legend_items = array( |
|
| 1038 | - 'star-icon' => array( |
|
| 1039 | - 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1040 | - 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1041 | - ), |
|
| 1042 | - 'checkin' => array( |
|
| 1043 | - 'class' => 'ee-icon ee-icon-check-in', |
|
| 1044 | - 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
| 1045 | - ), |
|
| 1046 | - 'checkout' => array( |
|
| 1047 | - 'class' => 'ee-icon ee-icon-check-out', |
|
| 1048 | - 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
| 1049 | - ), |
|
| 1050 | - 'nocheckinrecord' => array( |
|
| 1051 | - 'class' => 'dashicons dashicons-no', |
|
| 1052 | - 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
| 1053 | - ), |
|
| 1054 | - 'view_details' => array( |
|
| 1055 | - 'class' => 'dashicons dashicons-search', |
|
| 1056 | - 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
| 1057 | - ), |
|
| 1058 | - 'approved_status' => array( |
|
| 1059 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1060 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1061 | - ), |
|
| 1062 | - 'cancelled_status' => array( |
|
| 1063 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1064 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1065 | - ), |
|
| 1066 | - 'declined_status' => array( |
|
| 1067 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1068 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1069 | - ), |
|
| 1070 | - 'not_approved' => array( |
|
| 1071 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1072 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1073 | - ), |
|
| 1074 | - 'pending_status' => array( |
|
| 1075 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1076 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1077 | - ), |
|
| 1078 | - 'wait_list' => array( |
|
| 1079 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1080 | - 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1081 | - ), |
|
| 1082 | - ); |
|
| 1083 | - $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1084 | - $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1085 | - $this->_template_args['before_list_table'] = ! empty($event_id) |
|
| 1086 | - ? '<h2>' . sprintf( |
|
| 1087 | - __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1088 | - EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1089 | - ) . '</h2>' |
|
| 1090 | - : ''; |
|
| 1091 | - //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
| 1092 | - /** @var EE_Event $event */ |
|
| 1093 | - $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1094 | - $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1095 | - $datetime = null; |
|
| 1096 | - if ($event instanceof EE_Event) { |
|
| 1097 | - $datetimes_on_event = $event->datetimes(); |
|
| 1098 | - if (count($datetimes_on_event) === 1) { |
|
| 1099 | - $datetime = reset($datetimes_on_event); |
|
| 1100 | - } |
|
| 1101 | - } |
|
| 1102 | - $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1103 | - if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1104 | - $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1105 | - $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1106 | - $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1107 | - $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1108 | - $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1109 | - $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1110 | - } |
|
| 1111 | - //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
| 1112 | - //represents |
|
| 1113 | - if ( ! $datetime instanceof EE_Datetime) { |
|
| 1114 | - $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1115 | - . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1116 | - 'event_espresso') |
|
| 1117 | - . '</p>'; |
|
| 1118 | - } |
|
| 1119 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1120 | - } |
|
| 1121 | - |
|
| 1122 | - /** |
|
| 1123 | - * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1124 | - * conditions) |
|
| 1125 | - * |
|
| 1126 | - * @return void ends the request by a redirect or download |
|
| 1127 | - */ |
|
| 1128 | - public function _registrations_checkin_report() |
|
| 1129 | - { |
|
| 1130 | - $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1131 | - } |
|
| 1132 | - |
|
| 1133 | - /** |
|
| 1134 | - * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1135 | - * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1136 | - * |
|
| 1137 | - * @param array $request |
|
| 1138 | - * @param int $per_page |
|
| 1139 | - * @param bool $count |
|
| 1140 | - * @return array |
|
| 1141 | - */ |
|
| 1142 | - protected function _get_checkin_query_params_from_request( |
|
| 1143 | - $request, |
|
| 1144 | - $per_page = 10, |
|
| 1145 | - $count = false |
|
| 1146 | - ) { |
|
| 1147 | - $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1148 | - //unlike the regular registrations list table, |
|
| 1149 | - $status_ids_array = apply_filters( |
|
| 1150 | - 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1151 | - array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1152 | - ); |
|
| 1153 | - $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1154 | - return $query_params; |
|
| 1155 | - } |
|
| 1156 | - |
|
| 1157 | - |
|
| 1158 | - |
|
| 1159 | - |
|
| 1160 | - /** |
|
| 1161 | - * Gets registrations for an event |
|
| 1162 | - * |
|
| 1163 | - * @param int $per_page |
|
| 1164 | - * @param bool $count whether to return count or data. |
|
| 1165 | - * @param bool $trash |
|
| 1166 | - * @param string $orderby |
|
| 1167 | - * @return EE_Registration[]|int |
|
| 1168 | - * @throws \EE_Error |
|
| 1169 | - */ |
|
| 1170 | - public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1171 | - { |
|
| 1172 | - //normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1173 | - $request = $this->_req_data; |
|
| 1174 | - $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1175 | - $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1176 | - if($trash){ |
|
| 1177 | - $request['status'] = 'trash'; |
|
| 1178 | - } |
|
| 1179 | - $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1180 | - /** |
|
| 1181 | - * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1182 | - * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1183 | - * @see EEM_Base::get_all() |
|
| 1184 | - */ |
|
| 1185 | - $query_params['group_by'] = ''; |
|
| 1186 | - |
|
| 1187 | - return $count |
|
| 1188 | - ? EEM_Registration::instance()->count($query_params) |
|
| 1189 | - /** @type EE_Registration[] */ |
|
| 1190 | - : EEM_Registration::instance()->get_all($query_params); |
|
| 1191 | - } |
|
| 20 | + /** |
|
| 21 | + * This is used to hold the reports template data which is setup early in the request. |
|
| 22 | + * |
|
| 23 | + * @type array |
|
| 24 | + */ |
|
| 25 | + protected $_reports_template_data = array(); |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * Extend_Registrations_Admin_Page constructor. |
|
| 31 | + * |
|
| 32 | + * @param bool $routing |
|
| 33 | + */ |
|
| 34 | + public function __construct($routing = true) |
|
| 35 | + { |
|
| 36 | + parent::__construct($routing); |
|
| 37 | + if ( ! defined('REG_CAF_TEMPLATE_PATH')) { |
|
| 38 | + define('REG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/templates/'); |
|
| 39 | + define('REG_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'registrations/assets/'); |
|
| 40 | + define('REG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registrations/assets/'); |
|
| 41 | + } |
|
| 42 | + } |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + protected function _extend_page_config() |
|
| 47 | + { |
|
| 48 | + $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'registrations'; |
|
| 49 | + $reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) |
|
| 50 | + ? $this->_req_data['_REG_ID'] |
|
| 51 | + : 0; |
|
| 52 | + // $att_id = ! empty( $this->_req_data['ATT_ID'] ) ? ! is_array( $this->_req_data['ATT_ID'] ) : 0; |
|
| 53 | + // $att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) |
|
| 54 | + // ? $this->_req_data['post'] : $att_id; |
|
| 55 | + $new_page_routes = array( |
|
| 56 | + 'reports' => array( |
|
| 57 | + 'func' => '_registration_reports', |
|
| 58 | + 'capability' => 'ee_read_registrations', |
|
| 59 | + ), |
|
| 60 | + 'registration_checkins' => array( |
|
| 61 | + 'func' => '_registration_checkin_list_table', |
|
| 62 | + 'capability' => 'ee_read_checkins', |
|
| 63 | + ), |
|
| 64 | + 'newsletter_selected_send' => array( |
|
| 65 | + 'func' => '_newsletter_selected_send', |
|
| 66 | + 'noheader' => true, |
|
| 67 | + 'capability' => 'ee_send_message', |
|
| 68 | + ), |
|
| 69 | + 'delete_checkin_rows' => array( |
|
| 70 | + 'func' => '_delete_checkin_rows', |
|
| 71 | + 'noheader' => true, |
|
| 72 | + 'capability' => 'ee_delete_checkins', |
|
| 73 | + ), |
|
| 74 | + 'delete_checkin_row' => array( |
|
| 75 | + 'func' => '_delete_checkin_row', |
|
| 76 | + 'noheader' => true, |
|
| 77 | + 'capability' => 'ee_delete_checkin', |
|
| 78 | + 'obj_id' => $reg_id, |
|
| 79 | + ), |
|
| 80 | + 'toggle_checkin_status' => array( |
|
| 81 | + 'func' => '_toggle_checkin_status', |
|
| 82 | + 'noheader' => true, |
|
| 83 | + 'capability' => 'ee_edit_checkin', |
|
| 84 | + 'obj_id' => $reg_id, |
|
| 85 | + ), |
|
| 86 | + 'toggle_checkin_status_bulk' => array( |
|
| 87 | + 'func' => '_toggle_checkin_status', |
|
| 88 | + 'noheader' => true, |
|
| 89 | + 'capability' => 'ee_edit_checkins' |
|
| 90 | + ), |
|
| 91 | + 'event_registrations' => array( |
|
| 92 | + 'func' => '_event_registrations_list_table', |
|
| 93 | + 'capability' => 'ee_read_checkins', |
|
| 94 | + ), |
|
| 95 | + 'registrations_checkin_report' => array( |
|
| 96 | + 'func' => '_registrations_checkin_report', |
|
| 97 | + 'noheader' => true, |
|
| 98 | + 'capability' => 'ee_read_registrations', |
|
| 99 | + ), |
|
| 100 | + ); |
|
| 101 | + $this->_page_routes = array_merge($this->_page_routes, $new_page_routes); |
|
| 102 | + $new_page_config = array( |
|
| 103 | + 'reports' => array( |
|
| 104 | + 'nav' => array( |
|
| 105 | + 'label' => __('Reports', 'event_espresso'), |
|
| 106 | + 'order' => 30, |
|
| 107 | + ), |
|
| 108 | + 'help_tabs' => array( |
|
| 109 | + 'registrations_reports_help_tab' => array( |
|
| 110 | + 'title' => __('Registration Reports', 'event_espresso'), |
|
| 111 | + 'filename' => 'registrations_reports', |
|
| 112 | + ), |
|
| 113 | + ), |
|
| 114 | + /*'help_tour' => array( 'Registration_Reports_Help_Tour' ),*/ |
|
| 115 | + 'require_nonce' => false, |
|
| 116 | + ), |
|
| 117 | + 'event_registrations' => array( |
|
| 118 | + 'nav' => array( |
|
| 119 | + 'label' => __('Event Check-In', 'event_espresso'), |
|
| 120 | + 'order' => 10, |
|
| 121 | + 'persistent' => true, |
|
| 122 | + ), |
|
| 123 | + 'help_tabs' => array( |
|
| 124 | + 'registrations_event_checkin_help_tab' => array( |
|
| 125 | + 'title' => __('Registrations Event Check-In', 'event_espresso'), |
|
| 126 | + 'filename' => 'registrations_event_checkin', |
|
| 127 | + ), |
|
| 128 | + 'registrations_event_checkin_table_column_headings_help_tab' => array( |
|
| 129 | + 'title' => __('Event Check-In Table Column Headings', 'event_espresso'), |
|
| 130 | + 'filename' => 'registrations_event_checkin_table_column_headings', |
|
| 131 | + ), |
|
| 132 | + 'registrations_event_checkin_filters_help_tab' => array( |
|
| 133 | + 'title' => __('Event Check-In Filters', 'event_espresso'), |
|
| 134 | + 'filename' => 'registrations_event_checkin_filters', |
|
| 135 | + ), |
|
| 136 | + 'registrations_event_checkin_views_help_tab' => array( |
|
| 137 | + 'title' => __('Event Check-In Views', 'event_espresso'), |
|
| 138 | + 'filename' => 'registrations_event_checkin_views', |
|
| 139 | + ), |
|
| 140 | + 'registrations_event_checkin_other_help_tab' => array( |
|
| 141 | + 'title' => __('Event Check-In Other', 'event_espresso'), |
|
| 142 | + 'filename' => 'registrations_event_checkin_other', |
|
| 143 | + ), |
|
| 144 | + ), |
|
| 145 | + 'help_tour' => array('Event_Checkin_Help_Tour'), |
|
| 146 | + 'qtips' => array('Registration_List_Table_Tips'), |
|
| 147 | + 'list_table' => 'EE_Event_Registrations_List_Table', |
|
| 148 | + 'metaboxes' => array(), |
|
| 149 | + 'require_nonce' => false, |
|
| 150 | + ), |
|
| 151 | + 'registration_checkins' => array( |
|
| 152 | + 'nav' => array( |
|
| 153 | + 'label' => __('Check-In Records', 'event_espresso'), |
|
| 154 | + 'order' => 15, |
|
| 155 | + 'persistent' => false, |
|
| 156 | + ), |
|
| 157 | + 'list_table' => 'EE_Registration_CheckIn_List_Table', |
|
| 158 | + //'help_tour' => array( 'Checkin_Toggle_View_Help_Tour' ), |
|
| 159 | + 'metaboxes' => array(), |
|
| 160 | + 'require_nonce' => false, |
|
| 161 | + ), |
|
| 162 | + ); |
|
| 163 | + $this->_page_config = array_merge($this->_page_config, $new_page_config); |
|
| 164 | + $this->_page_config['contact_list']['list_table'] = 'Extend_EE_Attendee_Contact_List_Table'; |
|
| 165 | + $this->_page_config['default']['list_table'] = 'Extend_EE_Registrations_List_Table'; |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + |
|
| 170 | + protected function _ajax_hooks() |
|
| 171 | + { |
|
| 172 | + parent::_ajax_hooks(); |
|
| 173 | + add_action('wp_ajax_get_newsletter_form_content', array($this, 'get_newsletter_form_content')); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + public function load_scripts_styles() |
|
| 179 | + { |
|
| 180 | + parent::load_scripts_styles(); |
|
| 181 | + //if newsletter message type is active then let's add filter and load js for it. |
|
| 182 | + if (EEH_MSG_Template::is_mt_active('newsletter')) { |
|
| 183 | + //enqueue newsletter js |
|
| 184 | + wp_enqueue_script( |
|
| 185 | + 'ee-newsletter-trigger', |
|
| 186 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.js', |
|
| 187 | + array('ee-dialog'), |
|
| 188 | + EVENT_ESPRESSO_VERSION, |
|
| 189 | + true |
|
| 190 | + ); |
|
| 191 | + wp_enqueue_style( |
|
| 192 | + 'ee-newsletter-trigger-css', |
|
| 193 | + REG_CAF_ASSETS_URL . 'ee-newsletter-trigger.css', |
|
| 194 | + array(), |
|
| 195 | + EVENT_ESPRESSO_VERSION |
|
| 196 | + ); |
|
| 197 | + //hook in buttons for newsletter message type trigger. |
|
| 198 | + add_action( |
|
| 199 | + 'AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', |
|
| 200 | + array($this, 'add_newsletter_action_buttons'), |
|
| 201 | + 10 |
|
| 202 | + ); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + |
|
| 206 | + |
|
| 207 | + |
|
| 208 | + public function load_scripts_styles_reports() |
|
| 209 | + { |
|
| 210 | + wp_register_script( |
|
| 211 | + 'ee-reg-reports-js', |
|
| 212 | + REG_CAF_ASSETS_URL . 'ee-registration-admin-reports.js', |
|
| 213 | + array('google-charts'), |
|
| 214 | + EVENT_ESPRESSO_VERSION, |
|
| 215 | + true |
|
| 216 | + ); |
|
| 217 | + wp_enqueue_script('ee-reg-reports-js'); |
|
| 218 | + $this->_registration_reports_js_setup(); |
|
| 219 | + } |
|
| 220 | + |
|
| 221 | + |
|
| 222 | + |
|
| 223 | + protected function _add_screen_options_event_registrations() |
|
| 224 | + { |
|
| 225 | + $this->_per_page_screen_option(); |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + |
|
| 229 | + |
|
| 230 | + protected function _add_screen_options_registration_checkins() |
|
| 231 | + { |
|
| 232 | + $page_title = $this->_admin_page_title; |
|
| 233 | + $this->_admin_page_title = __('Check-In Records', 'event_espresso'); |
|
| 234 | + $this->_per_page_screen_option(); |
|
| 235 | + $this->_admin_page_title = $page_title; |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + |
|
| 240 | + protected function _set_list_table_views_event_registrations() |
|
| 241 | + { |
|
| 242 | + $this->_views = array( |
|
| 243 | + 'all' => array( |
|
| 244 | + 'slug' => 'all', |
|
| 245 | + 'label' => __('All', 'event_espresso'), |
|
| 246 | + 'count' => 0, |
|
| 247 | + 'bulk_action' => ! isset($this->_req_data['event_id']) |
|
| 248 | + ? array() |
|
| 249 | + : array( |
|
| 250 | + 'toggle_checkin_status_bulk' => __('Toggle Check-In', 'event_espresso'), |
|
| 251 | + ), |
|
| 252 | + ), |
|
| 253 | + ); |
|
| 254 | + } |
|
| 255 | + |
|
| 256 | + |
|
| 257 | + |
|
| 258 | + protected function _set_list_table_views_registration_checkins() |
|
| 259 | + { |
|
| 260 | + $this->_views = array( |
|
| 261 | + 'all' => array( |
|
| 262 | + 'slug' => 'all', |
|
| 263 | + 'label' => __('All', 'event_espresso'), |
|
| 264 | + 'count' => 0, |
|
| 265 | + 'bulk_action' => array('delete_checkin_rows' => __('Delete Check-In Rows', 'event_espresso')), |
|
| 266 | + ), |
|
| 267 | + ); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + |
|
| 272 | + /** |
|
| 273 | + * callback for ajax action. |
|
| 274 | + * |
|
| 275 | + * @since 4.3.0 |
|
| 276 | + * @return void (JSON) |
|
| 277 | + * @throws \EE_Error |
|
| 278 | + */ |
|
| 279 | + public function get_newsletter_form_content() |
|
| 280 | + { |
|
| 281 | + //do a nonce check cause we're not coming in from an normal route here. |
|
| 282 | + $nonce = isset($this->_req_data['get_newsletter_form_content_nonce']) ? sanitize_text_field( |
|
| 283 | + $this->_req_data['get_newsletter_form_content_nonce'] |
|
| 284 | + ) : ''; |
|
| 285 | + $nonce_ref = 'get_newsletter_form_content_nonce'; |
|
| 286 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 287 | + //let's get the mtp for the incoming MTP_ ID |
|
| 288 | + if ( ! isset($this->_req_data['GRP_ID'])) { |
|
| 289 | + EE_Error::add_error( |
|
| 290 | + __( |
|
| 291 | + 'There must be something broken with the js or html structure because the required data for getting a message template group is not present (need an GRP_ID).', |
|
| 292 | + 'event_espresso' |
|
| 293 | + ), |
|
| 294 | + __FILE__, |
|
| 295 | + __FUNCTION__, |
|
| 296 | + __LINE__ |
|
| 297 | + ); |
|
| 298 | + $this->_template_args['success'] = false; |
|
| 299 | + $this->_template_args['error'] = true; |
|
| 300 | + $this->_return_json(); |
|
| 301 | + } |
|
| 302 | + $MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($this->_req_data['GRP_ID']); |
|
| 303 | + if ( ! $MTPG instanceof EE_Message_Template_Group) { |
|
| 304 | + EE_Error::add_error( |
|
| 305 | + sprintf( |
|
| 306 | + __( |
|
| 307 | + 'The GRP_ID given (%d) does not appear to have a corresponding row in the database.', |
|
| 308 | + 'event_espresso' |
|
| 309 | + ), |
|
| 310 | + $this->_req_data['GRP_ID'] |
|
| 311 | + ), |
|
| 312 | + __FILE__, |
|
| 313 | + __FUNCTION__, |
|
| 314 | + __LINE__ |
|
| 315 | + ); |
|
| 316 | + $this->_template_args['success'] = false; |
|
| 317 | + $this->_template_args['error'] = true; |
|
| 318 | + $this->_return_json(); |
|
| 319 | + } |
|
| 320 | + $MTPs = $MTPG->context_templates(); |
|
| 321 | + $MTPs = $MTPs['attendee']; |
|
| 322 | + $template_fields = array(); |
|
| 323 | + /** @var EE_Message_Template $MTP */ |
|
| 324 | + foreach ($MTPs as $MTP) { |
|
| 325 | + $field = $MTP->get('MTP_template_field'); |
|
| 326 | + if ($field === 'content') { |
|
| 327 | + $content = $MTP->get('MTP_content'); |
|
| 328 | + if ( ! empty($content['newsletter_content'])) { |
|
| 329 | + $template_fields['newsletter_content'] = $content['newsletter_content']; |
|
| 330 | + } |
|
| 331 | + continue; |
|
| 332 | + } |
|
| 333 | + $template_fields[$MTP->get('MTP_template_field')] = $MTP->get('MTP_content'); |
|
| 334 | + } |
|
| 335 | + $this->_template_args['success'] = true; |
|
| 336 | + $this->_template_args['error'] = false; |
|
| 337 | + $this->_template_args['data'] = array( |
|
| 338 | + 'batch_message_from' => isset($template_fields['from']) |
|
| 339 | + ? $template_fields['from'] |
|
| 340 | + : '', |
|
| 341 | + 'batch_message_subject' => isset($template_fields['subject']) |
|
| 342 | + ? $template_fields['subject'] |
|
| 343 | + : '', |
|
| 344 | + 'batch_message_content' => isset($template_fields['newsletter_content']) |
|
| 345 | + ? $template_fields['newsletter_content'] |
|
| 346 | + : '', |
|
| 347 | + ); |
|
| 348 | + $this->_return_json(); |
|
| 349 | + } |
|
| 350 | + |
|
| 351 | + |
|
| 352 | + |
|
| 353 | + /** |
|
| 354 | + * callback for AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons action |
|
| 355 | + * |
|
| 356 | + * @since 4.3.0 |
|
| 357 | + * @param EE_Admin_List_Table $list_table |
|
| 358 | + * @return void |
|
| 359 | + */ |
|
| 360 | + public function add_newsletter_action_buttons(EE_Admin_List_Table $list_table) |
|
| 361 | + { |
|
| 362 | + if ( ! EE_Registry::instance()->CAP->current_user_can( |
|
| 363 | + 'ee_send_message', |
|
| 364 | + 'espresso_registrations_newsletter_selected_send' |
|
| 365 | + ) |
|
| 366 | + ) { |
|
| 367 | + return; |
|
| 368 | + } |
|
| 369 | + $routes_to_add_to = array( |
|
| 370 | + 'contact_list', |
|
| 371 | + 'event_registrations', |
|
| 372 | + 'default', |
|
| 373 | + ); |
|
| 374 | + if ($this->_current_page === 'espresso_registrations' && in_array($this->_req_action, $routes_to_add_to)) { |
|
| 375 | + if (($this->_req_action === 'event_registrations' && empty($this->_req_data['event_id'])) |
|
| 376 | + || (isset($this->_req_data['status']) && $this->_req_data['status'] === 'trash') |
|
| 377 | + ) { |
|
| 378 | + echo ''; |
|
| 379 | + } else { |
|
| 380 | + $button_text = sprintf( |
|
| 381 | + __('Send Batch Message (%s selected)', 'event_espresso'), |
|
| 382 | + '<span class="send-selected-newsletter-count">0</span>' |
|
| 383 | + ); |
|
| 384 | + echo '<button id="selected-batch-send-trigger" class="button secondary-button"><span class="dashicons dashicons-email "></span>' |
|
| 385 | + . $button_text |
|
| 386 | + . '</button>'; |
|
| 387 | + add_action('admin_footer', array($this, 'newsletter_send_form_skeleton')); |
|
| 388 | + } |
|
| 389 | + } |
|
| 390 | + } |
|
| 391 | + |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + public function newsletter_send_form_skeleton() |
|
| 395 | + { |
|
| 396 | + $list_table = $this->_list_table_object; |
|
| 397 | + $codes = array(); |
|
| 398 | + //need to templates for the newsletter message type for the template selector. |
|
| 399 | + $values[] = array('text' => __('Select Template to Use', 'event_espresso'), 'id' => 0); |
|
| 400 | + $mtps = EEM_Message_Template_Group::instance()->get_all( |
|
| 401 | + array(array('MTP_message_type' => 'newsletter', 'MTP_messenger' => 'email')) |
|
| 402 | + ); |
|
| 403 | + foreach ($mtps as $mtp) { |
|
| 404 | + $name = $mtp->name(); |
|
| 405 | + $values[] = array( |
|
| 406 | + 'text' => empty($name) ? __('Global', 'event_espresso') : $name, |
|
| 407 | + 'id' => $mtp->ID(), |
|
| 408 | + ); |
|
| 409 | + } |
|
| 410 | + //need to get a list of shortcodes that are available for the newsletter message type. |
|
| 411 | + $shortcodes = EEH_MSG_Template::get_shortcodes('newsletter', 'email', array(), 'attendee', false); |
|
| 412 | + foreach ($shortcodes as $field => $shortcode_array) { |
|
| 413 | + $codes[$field] = implode(', ', array_keys($shortcode_array)); |
|
| 414 | + } |
|
| 415 | + $shortcodes = $codes; |
|
| 416 | + $form_template = REG_CAF_TEMPLATE_PATH . 'newsletter-send-form.template.php'; |
|
| 417 | + $form_template_args = array( |
|
| 418 | + 'form_action' => admin_url('admin.php?page=espresso_registrations'), |
|
| 419 | + 'form_route' => 'newsletter_selected_send', |
|
| 420 | + 'form_nonce_name' => 'newsletter_selected_send_nonce', |
|
| 421 | + 'form_nonce' => wp_create_nonce('newsletter_selected_send_nonce'), |
|
| 422 | + 'redirect_back_to' => $this->_req_action, |
|
| 423 | + 'ajax_nonce' => wp_create_nonce('get_newsletter_form_content_nonce'), |
|
| 424 | + 'template_selector' => EEH_Form_Fields::select_input('newsletter_mtp_selected', $values), |
|
| 425 | + 'shortcodes' => $shortcodes, |
|
| 426 | + 'id_type' => $list_table instanceof EE_Attendee_Contact_List_Table ? 'contact' : 'registration', |
|
| 427 | + ); |
|
| 428 | + EEH_Template::display_template($form_template, $form_template_args); |
|
| 429 | + } |
|
| 430 | + |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + /** |
|
| 434 | + * Handles sending selected registrations/contacts a newsletter. |
|
| 435 | + * |
|
| 436 | + * @since 4.3.0 |
|
| 437 | + * @return void |
|
| 438 | + * @throws \EE_Error |
|
| 439 | + */ |
|
| 440 | + protected function _newsletter_selected_send() |
|
| 441 | + { |
|
| 442 | + $success = true; |
|
| 443 | + //first we need to make sure we have a GRP_ID so we know what template we're sending and updating! |
|
| 444 | + if (empty($this->_req_data['newsletter_mtp_selected'])) { |
|
| 445 | + EE_Error::add_error( |
|
| 446 | + __( |
|
| 447 | + 'In order to send a message, a Message Template GRP_ID is needed. It was not provided so messages were not sent.', |
|
| 448 | + 'event_espresso' |
|
| 449 | + ), |
|
| 450 | + __FILE__, |
|
| 451 | + __FUNCTION__, |
|
| 452 | + __LINE__ |
|
| 453 | + ); |
|
| 454 | + $success = false; |
|
| 455 | + } |
|
| 456 | + if ($success) { |
|
| 457 | + //update Message template in case there are any changes |
|
| 458 | + $Message_Template_Group = EEM_Message_Template_Group::instance()->get_one_by_ID( |
|
| 459 | + $this->_req_data['newsletter_mtp_selected'] |
|
| 460 | + ); |
|
| 461 | + $Message_Templates = $Message_Template_Group instanceof EE_Message_Template_Group |
|
| 462 | + ? $Message_Template_Group->context_templates() |
|
| 463 | + : array(); |
|
| 464 | + if (empty($Message_Templates)) { |
|
| 465 | + EE_Error::add_error( |
|
| 466 | + __( |
|
| 467 | + 'Unable to retrieve message template fields from the db. Messages not sent.', |
|
| 468 | + 'event_espresso' |
|
| 469 | + ), |
|
| 470 | + __FILE__, |
|
| 471 | + __FUNCTION__, |
|
| 472 | + __LINE__ |
|
| 473 | + ); |
|
| 474 | + } |
|
| 475 | + //let's just update the specific fields |
|
| 476 | + foreach ($Message_Templates['attendee'] as $Message_Template) { |
|
| 477 | + if ($Message_Template instanceof EE_Message_Template) { |
|
| 478 | + $field = $Message_Template->get('MTP_template_field'); |
|
| 479 | + $content = $Message_Template->get('MTP_content'); |
|
| 480 | + $new_content = $content; |
|
| 481 | + switch ($field) { |
|
| 482 | + case 'from' : |
|
| 483 | + $new_content = ! empty($this->_req_data['batch_message']['from']) |
|
| 484 | + ? $this->_req_data['batch_message']['from'] |
|
| 485 | + : $content; |
|
| 486 | + break; |
|
| 487 | + case 'subject' : |
|
| 488 | + $new_content = ! empty($this->_req_data['batch_message']['subject']) |
|
| 489 | + ? $this->_req_data['batch_message']['subject'] |
|
| 490 | + : $content; |
|
| 491 | + break; |
|
| 492 | + case 'content' : |
|
| 493 | + $new_content = $content; |
|
| 494 | + $new_content['newsletter_content'] = ! empty($this->_req_data['batch_message']['content']) |
|
| 495 | + ? $this->_req_data['batch_message']['content'] |
|
| 496 | + : $content['newsletter_content']; |
|
| 497 | + break; |
|
| 498 | + default : |
|
| 499 | + //continue the foreach loop, we don't want to set $new_content nor save. |
|
| 500 | + continue 2; |
|
| 501 | + } |
|
| 502 | + $Message_Template->set('MTP_content', $new_content); |
|
| 503 | + $Message_Template->save(); |
|
| 504 | + } |
|
| 505 | + } |
|
| 506 | + //great fields are updated! now let's make sure we just have contact objects (EE_Attendee). |
|
| 507 | + $id_type = ! empty($this->_req_data['batch_message']['id_type']) |
|
| 508 | + ? $this->_req_data['batch_message']['id_type'] |
|
| 509 | + : 'registration'; |
|
| 510 | + //id_type will affect how we assemble the ids. |
|
| 511 | + $ids = ! empty($this->_req_data['batch_message']['ids']) |
|
| 512 | + ? json_decode(stripslashes($this->_req_data['batch_message']['ids'])) |
|
| 513 | + : array(); |
|
| 514 | + $registrations_used_for_contact_data = array(); |
|
| 515 | + //using switch because eventually we'll have other contexts that will be used for generating messages. |
|
| 516 | + switch ($id_type) { |
|
| 517 | + case 'registration' : |
|
| 518 | + $registrations_used_for_contact_data = EEM_Registration::instance()->get_all( |
|
| 519 | + array( |
|
| 520 | + array( |
|
| 521 | + 'REG_ID' => array('IN', $ids), |
|
| 522 | + ), |
|
| 523 | + ) |
|
| 524 | + ); |
|
| 525 | + break; |
|
| 526 | + case 'contact' : |
|
| 527 | + $registrations_used_for_contact_data = EEM_Registration::instance() |
|
| 528 | + ->get_latest_registration_for_each_of_given_contacts($ids); |
|
| 529 | + break; |
|
| 530 | + } |
|
| 531 | + do_action( |
|
| 532 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', |
|
| 533 | + $registrations_used_for_contact_data, |
|
| 534 | + $Message_Template_Group->ID() |
|
| 535 | + ); |
|
| 536 | + //kept for backward compat, internally we no longer use this action. |
|
| 537 | + //@deprecated 4.8.36.rc.002 |
|
| 538 | + $contacts = $id_type === 'registration' |
|
| 539 | + ? EEM_Attendee::instance()->get_array_of_contacts_from_reg_ids($ids) |
|
| 540 | + : EEM_Attendee::instance()->get_all(array(array('ATT_ID' => array('in', $ids)))); |
|
| 541 | + do_action( |
|
| 542 | + 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', |
|
| 543 | + $contacts, |
|
| 544 | + $Message_Template_Group->ID() |
|
| 545 | + ); |
|
| 546 | + } |
|
| 547 | + $query_args = array( |
|
| 548 | + 'action' => ! empty($this->_req_data['redirect_back_to']) |
|
| 549 | + ? $this->_req_data['redirect_back_to'] |
|
| 550 | + : 'default', |
|
| 551 | + ); |
|
| 552 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 553 | + } |
|
| 554 | + |
|
| 555 | + |
|
| 556 | + |
|
| 557 | + /** |
|
| 558 | + * This is called when javascript is being enqueued to setup the various data needed for the reports js. |
|
| 559 | + * Also $this->{$_reports_template_data} property is set for later usage by the _registration_reports method. |
|
| 560 | + */ |
|
| 561 | + protected function _registration_reports_js_setup() |
|
| 562 | + { |
|
| 563 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_day_report(); |
|
| 564 | + $this->_reports_template_data['admin_reports'][] = $this->_registrations_per_event_report(); |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * generates Business Reports regarding Registrations |
|
| 571 | + * |
|
| 572 | + * @access protected |
|
| 573 | + * @return void |
|
| 574 | + */ |
|
| 575 | + protected function _registration_reports() |
|
| 576 | + { |
|
| 577 | + $template_path = EE_ADMIN_TEMPLATE . 'admin_reports.template.php'; |
|
| 578 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
| 579 | + $template_path, |
|
| 580 | + $this->_reports_template_data, |
|
| 581 | + true |
|
| 582 | + ); |
|
| 583 | + // the final template wrapper |
|
| 584 | + $this->display_admin_page_with_no_sidebar(); |
|
| 585 | + } |
|
| 586 | + |
|
| 587 | + |
|
| 588 | + |
|
| 589 | + /** |
|
| 590 | + * Generates Business Report showing total registrations per day. |
|
| 591 | + * |
|
| 592 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 593 | + * @return string |
|
| 594 | + */ |
|
| 595 | + private function _registrations_per_day_report($period = '-1 month') |
|
| 596 | + { |
|
| 597 | + $report_ID = 'reg-admin-registrations-per-day-report-dv'; |
|
| 598 | + $results = EEM_Registration::instance()->get_registrations_per_day_and_per_status_report($period); |
|
| 599 | + $results = (array)$results; |
|
| 600 | + $regs = array(); |
|
| 601 | + $subtitle = ''; |
|
| 602 | + if ($results) { |
|
| 603 | + $column_titles = array(); |
|
| 604 | + $tracker = 0; |
|
| 605 | + foreach ($results as $result) { |
|
| 606 | + $report_column_values = array(); |
|
| 607 | + foreach ($result as $property_name => $property_value) { |
|
| 608 | + $property_value = $property_name === 'Registration_REG_date' ? $property_value |
|
| 609 | + : (int)$property_value; |
|
| 610 | + $report_column_values[] = $property_value; |
|
| 611 | + if ($tracker === 0) { |
|
| 612 | + if ($property_name === 'Registration_REG_date') { |
|
| 613 | + $column_titles[] = __('Date (only days with registrations are shown)', 'event_espresso'); |
|
| 614 | + } else { |
|
| 615 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 616 | + } |
|
| 617 | + } |
|
| 618 | + } |
|
| 619 | + $tracker++; |
|
| 620 | + $regs[] = $report_column_values; |
|
| 621 | + } |
|
| 622 | + //make sure the column_titles is pushed to the beginning of the array |
|
| 623 | + array_unshift($regs, $column_titles); |
|
| 624 | + //setup the date range. |
|
| 625 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 626 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 627 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 628 | + $subtitle = sprintf( |
|
| 629 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 630 | + $beginning_date->format('Y-m-d'), |
|
| 631 | + $ending_date->format('Y-m-d') |
|
| 632 | + ); |
|
| 633 | + } |
|
| 634 | + $report_title = __('Total Registrations per Day', 'event_espresso'); |
|
| 635 | + $report_params = array( |
|
| 636 | + 'title' => $report_title, |
|
| 637 | + 'subtitle' => $subtitle, |
|
| 638 | + 'id' => $report_ID, |
|
| 639 | + 'regs' => $regs, |
|
| 640 | + 'noResults' => empty($regs), |
|
| 641 | + 'noRegsMsg' => sprintf( |
|
| 642 | + __( |
|
| 643 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 644 | + 'event_espresso' |
|
| 645 | + ), |
|
| 646 | + '<h2>' . $report_title . '</h2><p>', |
|
| 647 | + '</p>' |
|
| 648 | + ), |
|
| 649 | + ); |
|
| 650 | + wp_localize_script('ee-reg-reports-js', 'regPerDay', $report_params); |
|
| 651 | + return $report_ID; |
|
| 652 | + } |
|
| 653 | + |
|
| 654 | + |
|
| 655 | + |
|
| 656 | + /** |
|
| 657 | + * Generates Business Report showing total registrations per event. |
|
| 658 | + * |
|
| 659 | + * @param string $period The period (acceptable by PHP Datetime constructor) for which the report is generated. |
|
| 660 | + * @return string |
|
| 661 | + */ |
|
| 662 | + private function _registrations_per_event_report($period = '-1 month') |
|
| 663 | + { |
|
| 664 | + $report_ID = 'reg-admin-registrations-per-event-report-dv'; |
|
| 665 | + $results = EEM_Registration::instance()->get_registrations_per_event_and_per_status_report($period); |
|
| 666 | + $results = (array)$results; |
|
| 667 | + $regs = array(); |
|
| 668 | + $subtitle = ''; |
|
| 669 | + if ($results) { |
|
| 670 | + $column_titles = array(); |
|
| 671 | + $tracker = 0; |
|
| 672 | + foreach ($results as $result) { |
|
| 673 | + $report_column_values = array(); |
|
| 674 | + foreach ($result as $property_name => $property_value) { |
|
| 675 | + $property_value = $property_name === 'Registration_Event' ? wp_trim_words( |
|
| 676 | + $property_value, |
|
| 677 | + 4, |
|
| 678 | + '...' |
|
| 679 | + ) : (int)$property_value; |
|
| 680 | + $report_column_values[] = $property_value; |
|
| 681 | + if ($tracker === 0) { |
|
| 682 | + if ($property_name === 'Registration_Event') { |
|
| 683 | + $column_titles[] = __('Event', 'event_espresso'); |
|
| 684 | + } else { |
|
| 685 | + $column_titles[] = EEH_Template::pretty_status($property_name, false, 'sentence'); |
|
| 686 | + } |
|
| 687 | + } |
|
| 688 | + } |
|
| 689 | + $tracker++; |
|
| 690 | + $regs[] = $report_column_values; |
|
| 691 | + } |
|
| 692 | + //make sure the column_titles is pushed to the beginning of the array |
|
| 693 | + array_unshift($regs, $column_titles); |
|
| 694 | + //setup the date range. |
|
| 695 | + $DateTimeZone = new DateTimeZone(EEH_DTT_Helper::get_timezone()); |
|
| 696 | + $beginning_date = new DateTime("now " . $period, $DateTimeZone); |
|
| 697 | + $ending_date = new DateTime("now", $DateTimeZone); |
|
| 698 | + $subtitle = sprintf( |
|
| 699 | + _x('For the period: %1$s to %2$s', 'Used to give date range', 'event_espresso'), |
|
| 700 | + $beginning_date->format('Y-m-d'), |
|
| 701 | + $ending_date->format('Y-m-d') |
|
| 702 | + ); |
|
| 703 | + } |
|
| 704 | + $report_title = __('Total Registrations per Event', 'event_espresso'); |
|
| 705 | + $report_params = array( |
|
| 706 | + 'title' => $report_title, |
|
| 707 | + 'subtitle' => $subtitle, |
|
| 708 | + 'id' => $report_ID, |
|
| 709 | + 'regs' => $regs, |
|
| 710 | + 'noResults' => empty($regs), |
|
| 711 | + 'noRegsMsg' => sprintf( |
|
| 712 | + __( |
|
| 713 | + '%sThere are currently no registration records in the last month for this report.%s', |
|
| 714 | + 'event_espresso' |
|
| 715 | + ), |
|
| 716 | + '<h2>' . $report_title . '</h2><p>', |
|
| 717 | + '</p>' |
|
| 718 | + ), |
|
| 719 | + ); |
|
| 720 | + wp_localize_script('ee-reg-reports-js', 'regPerEvent', $report_params); |
|
| 721 | + return $report_ID; |
|
| 722 | + } |
|
| 723 | + |
|
| 724 | + |
|
| 725 | + |
|
| 726 | + /** |
|
| 727 | + * generates HTML for the Registration Check-in list table (showing all Check-ins for a specific registration) |
|
| 728 | + * |
|
| 729 | + * @access protected |
|
| 730 | + * @return void |
|
| 731 | + * @throws \EE_Error |
|
| 732 | + */ |
|
| 733 | + protected function _registration_checkin_list_table() |
|
| 734 | + { |
|
| 735 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 736 | + $reg_id = isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : null; |
|
| 737 | + /** @var EE_Registration $registration */ |
|
| 738 | + $registration = EEM_Registration::instance()->get_one_by_ID($reg_id); |
|
| 739 | + $attendee = $registration->attendee(); |
|
| 740 | + $this->_admin_page_title .= $this->get_action_link_or_button( |
|
| 741 | + 'new_registration', |
|
| 742 | + 'add-registrant', |
|
| 743 | + array('event_id' => $registration->event_ID()), |
|
| 744 | + 'add-new-h2' |
|
| 745 | + ); |
|
| 746 | + $legend_items = array( |
|
| 747 | + 'checkin' => array( |
|
| 748 | + 'class' => 'ee-icon ee-icon-check-in', |
|
| 749 | + 'desc' => __('This indicates the attendee has been checked in', 'event_espresso'), |
|
| 750 | + ), |
|
| 751 | + 'checkout' => array( |
|
| 752 | + 'class' => 'ee-icon ee-icon-check-out', |
|
| 753 | + 'desc' => __('This indicates the attendee has been checked out', 'event_espresso'), |
|
| 754 | + ), |
|
| 755 | + ); |
|
| 756 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 757 | + $dtt_id = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 758 | + /** @var EE_Datetime $datetime */ |
|
| 759 | + $datetime = EEM_Datetime::instance()->get_one_by_ID($dtt_id); |
|
| 760 | + $datetime_label = ''; |
|
| 761 | + if ($datetime instanceof EE_Datetime) { |
|
| 762 | + $datetime_label = $datetime->get_dtt_display_name(true); |
|
| 763 | + $datetime_label .= ! empty($datetime_label) |
|
| 764 | + ? ' (' . $datetime->get_dtt_display_name() . ')' |
|
| 765 | + : $datetime->get_dtt_display_name(); |
|
| 766 | + } |
|
| 767 | + $datetime_link = ! empty($dtt_id) && $registration instanceof EE_Registration |
|
| 768 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
| 769 | + array( |
|
| 770 | + 'action' => 'event_registrations', |
|
| 771 | + 'event_id' => $registration->event_ID(), |
|
| 772 | + 'DTT_ID' => $dtt_id, |
|
| 773 | + ), |
|
| 774 | + $this->_admin_base_url |
|
| 775 | + ) |
|
| 776 | + : ''; |
|
| 777 | + $datetime_link = ! empty($datetime_link) |
|
| 778 | + ? '<a href="' . $datetime_link . '">' |
|
| 779 | + . '<span id="checkin-dtt">' |
|
| 780 | + . $datetime_label |
|
| 781 | + . '</span></a>' |
|
| 782 | + : $datetime_label; |
|
| 783 | + $attendee_name = $attendee instanceof EE_Attendee |
|
| 784 | + ? $attendee->full_name() |
|
| 785 | + : ''; |
|
| 786 | + $attendee_link = $attendee instanceof EE_Attendee |
|
| 787 | + ? $attendee->get_admin_details_link() |
|
| 788 | + : ''; |
|
| 789 | + $attendee_link = ! empty($attendee_link) |
|
| 790 | + ? '<a href="' . $attendee->get_admin_details_link() . '"' |
|
| 791 | + . ' title="' . esc_html__('Click for attendee details', 'event_espresso') . '">' |
|
| 792 | + . '<span id="checkin-attendee-name">' |
|
| 793 | + . $attendee_name |
|
| 794 | + . '</span></a>' |
|
| 795 | + : ''; |
|
| 796 | + $event_link = $registration->event() instanceof EE_Event |
|
| 797 | + ? $registration->event()->get_admin_details_link() |
|
| 798 | + : ''; |
|
| 799 | + $event_link = ! empty($event_link) |
|
| 800 | + ? '<a href="' . $event_link . '"' |
|
| 801 | + . ' title="' . esc_html__('Click here to edit event.', 'event_espresso') . '">' |
|
| 802 | + . '<span id="checkin-event-name">' |
|
| 803 | + . $registration->event_name() |
|
| 804 | + . '</span>' |
|
| 805 | + . '</a>' |
|
| 806 | + : ''; |
|
| 807 | + $this->_template_args['before_list_table'] = ! empty($reg_id) && ! empty($dtt_id) |
|
| 808 | + ? '<h2>' . sprintf( |
|
| 809 | + esc_html__('Displaying check in records for %1$s for %2$s at the event, %3$s', 'event_espresso'), |
|
| 810 | + $attendee_link, |
|
| 811 | + $datetime_link, |
|
| 812 | + $event_link |
|
| 813 | + ) . '</h2>' |
|
| 814 | + : ''; |
|
| 815 | + $this->_template_args['list_table_hidden_fields'] = ! empty($reg_id) |
|
| 816 | + ? '<input type="hidden" name="_REGID" value="' . $reg_id . '">' : ''; |
|
| 817 | + $this->_template_args['list_table_hidden_fields'] .= ! empty($dtt_id) |
|
| 818 | + ? '<input type="hidden" name="DTT_ID" value="' . $dtt_id . '">' : ''; |
|
| 819 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 820 | + } |
|
| 821 | + |
|
| 822 | + |
|
| 823 | + |
|
| 824 | + /** |
|
| 825 | + * toggle the Check-in status for the given registration (coming from ajax) |
|
| 826 | + * |
|
| 827 | + * @return void (JSON) |
|
| 828 | + */ |
|
| 829 | + public function toggle_checkin_status() |
|
| 830 | + { |
|
| 831 | + //first make sure we have the necessary data |
|
| 832 | + if ( ! isset($this->_req_data['_regid'])) { |
|
| 833 | + EE_Error::add_error( |
|
| 834 | + __( |
|
| 835 | + 'There must be something broken with the html structure because the required data for toggling the Check-in status is not being sent via ajax', |
|
| 836 | + 'event_espresso' |
|
| 837 | + ), |
|
| 838 | + __FILE__, |
|
| 839 | + __FUNCTION__, |
|
| 840 | + __LINE__ |
|
| 841 | + ); |
|
| 842 | + $this->_template_args['success'] = false; |
|
| 843 | + $this->_template_args['error'] = true; |
|
| 844 | + $this->_return_json(); |
|
| 845 | + }; |
|
| 846 | + //do a nonce check cause we're not coming in from an normal route here. |
|
| 847 | + $nonce = isset($this->_req_data['checkinnonce']) ? sanitize_text_field($this->_req_data['checkinnonce']) |
|
| 848 | + : ''; |
|
| 849 | + $nonce_ref = 'checkin_nonce'; |
|
| 850 | + $this->_verify_nonce($nonce, $nonce_ref); |
|
| 851 | + //beautiful! Made it this far so let's get the status. |
|
| 852 | + $new_status = $this->_toggle_checkin_status(); |
|
| 853 | + //setup new class to return via ajax |
|
| 854 | + $this->_template_args['admin_page_content'] = 'clickable trigger-checkin checkin-icons checkedin-status-' |
|
| 855 | + . $new_status; |
|
| 856 | + $this->_template_args['success'] = true; |
|
| 857 | + $this->_return_json(); |
|
| 858 | + } |
|
| 859 | + |
|
| 860 | + |
|
| 861 | + |
|
| 862 | + /** |
|
| 863 | + * handles toggling the checkin status for the registration, |
|
| 864 | + * |
|
| 865 | + * @access protected |
|
| 866 | + * @return int|void |
|
| 867 | + */ |
|
| 868 | + protected function _toggle_checkin_status() |
|
| 869 | + { |
|
| 870 | + //first let's get the query args out of the way for the redirect |
|
| 871 | + $query_args = array( |
|
| 872 | + 'action' => 'event_registrations', |
|
| 873 | + 'event_id' => isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null, |
|
| 874 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null, |
|
| 875 | + ); |
|
| 876 | + $new_status = false; |
|
| 877 | + // bulk action check in toggle |
|
| 878 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 879 | + // cycle thru checkboxes |
|
| 880 | + while (list($REG_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 881 | + $DTT_ID = isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : null; |
|
| 882 | + $new_status = $this->_toggle_checkin($REG_ID, $DTT_ID); |
|
| 883 | + } |
|
| 884 | + } elseif (isset($this->_req_data['_regid'])) { |
|
| 885 | + //coming from ajax request |
|
| 886 | + $DTT_ID = isset($this->_req_data['dttid']) ? $this->_req_data['dttid'] : null; |
|
| 887 | + $query_args['DTT_ID'] = $DTT_ID; |
|
| 888 | + $new_status = $this->_toggle_checkin($this->_req_data['_regid'], $DTT_ID); |
|
| 889 | + } else { |
|
| 890 | + EE_Error::add_error( |
|
| 891 | + __('Missing some required data to toggle the Check-in', 'event_espresso'), |
|
| 892 | + __FILE__, |
|
| 893 | + __FUNCTION__, |
|
| 894 | + __LINE__ |
|
| 895 | + ); |
|
| 896 | + } |
|
| 897 | + if (defined('DOING_AJAX')) { |
|
| 898 | + return $new_status; |
|
| 899 | + } |
|
| 900 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 901 | + } |
|
| 902 | + |
|
| 903 | + |
|
| 904 | + |
|
| 905 | + /** |
|
| 906 | + * This is toggles a single Check-in for the given registration and datetime. |
|
| 907 | + * |
|
| 908 | + * @param int $REG_ID The registration we're toggling |
|
| 909 | + * @param int $DTT_ID The datetime we're toggling |
|
| 910 | + * @return int The new status toggled to. |
|
| 911 | + * @throws \EE_Error |
|
| 912 | + */ |
|
| 913 | + private function _toggle_checkin($REG_ID, $DTT_ID) |
|
| 914 | + { |
|
| 915 | + /** @var EE_Registration $REG */ |
|
| 916 | + $REG = EEM_Registration::instance()->get_one_by_ID($REG_ID); |
|
| 917 | + $new_status = $REG->toggle_checkin_status($DTT_ID); |
|
| 918 | + if ($new_status !== false) { |
|
| 919 | + EE_Error::add_success($REG->get_checkin_msg($DTT_ID)); |
|
| 920 | + } else { |
|
| 921 | + EE_Error::add_error($REG->get_checkin_msg($DTT_ID, true), __FILE__, __FUNCTION__, __LINE__); |
|
| 922 | + $new_status = false; |
|
| 923 | + } |
|
| 924 | + return $new_status; |
|
| 925 | + } |
|
| 926 | + |
|
| 927 | + |
|
| 928 | + |
|
| 929 | + /** |
|
| 930 | + * Takes care of deleting multiple EE_Checkin table rows |
|
| 931 | + * |
|
| 932 | + * @access protected |
|
| 933 | + * @return void |
|
| 934 | + * @throws \EE_Error |
|
| 935 | + */ |
|
| 936 | + protected function _delete_checkin_rows() |
|
| 937 | + { |
|
| 938 | + $query_args = array( |
|
| 939 | + 'action' => 'registration_checkins', |
|
| 940 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 941 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 942 | + ); |
|
| 943 | + $errors = 0; |
|
| 944 | + if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) { |
|
| 945 | + while (list($CHK_ID, $value) = each($this->_req_data['checkbox'])) { |
|
| 946 | + if ( ! EEM_Checkin::instance()->delete_by_ID($CHK_ID)) { |
|
| 947 | + $errors++; |
|
| 948 | + } |
|
| 949 | + } |
|
| 950 | + } else { |
|
| 951 | + EE_Error::add_error( |
|
| 952 | + __( |
|
| 953 | + 'So, something went wrong with the bulk delete because there was no data received for instructions on WHAT to delete!', |
|
| 954 | + 'event_espresso' |
|
| 955 | + ), |
|
| 956 | + __FILE__, |
|
| 957 | + __FUNCTION__, |
|
| 958 | + __LINE__ |
|
| 959 | + ); |
|
| 960 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 961 | + } |
|
| 962 | + if ($errors > 0) { |
|
| 963 | + EE_Error::add_error( |
|
| 964 | + sprintf(__('There were %d records that did not delete successfully', 'event_espresso'), $errors), |
|
| 965 | + __FILE__, |
|
| 966 | + __FUNCTION__, |
|
| 967 | + __LINE__ |
|
| 968 | + ); |
|
| 969 | + } else { |
|
| 970 | + EE_Error::add_success(__('Records were successfully deleted', 'event_espresso')); |
|
| 971 | + } |
|
| 972 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 973 | + } |
|
| 974 | + |
|
| 975 | + |
|
| 976 | + |
|
| 977 | + /** |
|
| 978 | + * Deletes a single EE_Checkin row |
|
| 979 | + * |
|
| 980 | + * @return void |
|
| 981 | + * @throws \EE_Error |
|
| 982 | + */ |
|
| 983 | + protected function _delete_checkin_row() |
|
| 984 | + { |
|
| 985 | + $query_args = array( |
|
| 986 | + 'action' => 'registration_checkins', |
|
| 987 | + 'DTT_ID' => isset($this->_req_data['DTT_ID']) ? $this->_req_data['DTT_ID'] : 0, |
|
| 988 | + '_REGID' => isset($this->_req_data['_REGID']) ? $this->_req_data['_REGID'] : 0, |
|
| 989 | + ); |
|
| 990 | + if ( ! empty($this->_req_data['CHK_ID'])) { |
|
| 991 | + if ( ! EEM_Checkin::instance()->delete_by_ID($this->_req_data['CHK_ID'])) { |
|
| 992 | + EE_Error::add_error( |
|
| 993 | + __('Something went wrong and this check-in record was not deleted', 'event_espresso'), |
|
| 994 | + __FILE__, |
|
| 995 | + __FUNCTION__, |
|
| 996 | + __LINE__ |
|
| 997 | + ); |
|
| 998 | + } else { |
|
| 999 | + EE_Error::add_success(__('Check-In record successfully deleted', 'event_espresso')); |
|
| 1000 | + } |
|
| 1001 | + } else { |
|
| 1002 | + EE_Error::add_error( |
|
| 1003 | + __( |
|
| 1004 | + 'In order to delete a Check-in record, there must be a Check-In ID available. There is not. It is not your fault, there is just a gremlin living in the code', |
|
| 1005 | + 'event_espresso' |
|
| 1006 | + ), |
|
| 1007 | + __FILE__, |
|
| 1008 | + __FUNCTION__, |
|
| 1009 | + __LINE__ |
|
| 1010 | + ); |
|
| 1011 | + } |
|
| 1012 | + $this->_redirect_after_action(false, '', '', $query_args, true); |
|
| 1013 | + } |
|
| 1014 | + |
|
| 1015 | + |
|
| 1016 | + |
|
| 1017 | + /** |
|
| 1018 | + * generates HTML for the Event Registrations List Table |
|
| 1019 | + * |
|
| 1020 | + * @access protected |
|
| 1021 | + * @return void |
|
| 1022 | + * @throws \EE_Error |
|
| 1023 | + */ |
|
| 1024 | + protected function _event_registrations_list_table() |
|
| 1025 | + { |
|
| 1026 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
| 1027 | + $this->_admin_page_title .= isset($this->_req_data['event_id']) |
|
| 1028 | + ? $this->get_action_link_or_button( |
|
| 1029 | + 'new_registration', |
|
| 1030 | + 'add-registrant', |
|
| 1031 | + array('event_id' => $this->_req_data['event_id']), |
|
| 1032 | + 'add-new-h2', |
|
| 1033 | + '', |
|
| 1034 | + false |
|
| 1035 | + ) |
|
| 1036 | + : ''; |
|
| 1037 | + $legend_items = array( |
|
| 1038 | + 'star-icon' => array( |
|
| 1039 | + 'class' => 'dashicons dashicons-star-filled lt-blue-icon ee-icon-size-8', |
|
| 1040 | + 'desc' => __('This Registrant is the Primary Registrant', 'event_espresso'), |
|
| 1041 | + ), |
|
| 1042 | + 'checkin' => array( |
|
| 1043 | + 'class' => 'ee-icon ee-icon-check-in', |
|
| 1044 | + 'desc' => __('This Registrant has been Checked In', 'event_espresso'), |
|
| 1045 | + ), |
|
| 1046 | + 'checkout' => array( |
|
| 1047 | + 'class' => 'ee-icon ee-icon-check-out', |
|
| 1048 | + 'desc' => __('This Registrant has been Checked Out', 'event_espresso'), |
|
| 1049 | + ), |
|
| 1050 | + 'nocheckinrecord' => array( |
|
| 1051 | + 'class' => 'dashicons dashicons-no', |
|
| 1052 | + 'desc' => __('No Check-in Record has been Created for this Registrant', 'event_espresso'), |
|
| 1053 | + ), |
|
| 1054 | + 'view_details' => array( |
|
| 1055 | + 'class' => 'dashicons dashicons-search', |
|
| 1056 | + 'desc' => __('View All Check-in Records for this Registrant', 'event_espresso'), |
|
| 1057 | + ), |
|
| 1058 | + 'approved_status' => array( |
|
| 1059 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved, |
|
| 1060 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence'), |
|
| 1061 | + ), |
|
| 1062 | + 'cancelled_status' => array( |
|
| 1063 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled, |
|
| 1064 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence'), |
|
| 1065 | + ), |
|
| 1066 | + 'declined_status' => array( |
|
| 1067 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined, |
|
| 1068 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence'), |
|
| 1069 | + ), |
|
| 1070 | + 'not_approved' => array( |
|
| 1071 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved, |
|
| 1072 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence'), |
|
| 1073 | + ), |
|
| 1074 | + 'pending_status' => array( |
|
| 1075 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment, |
|
| 1076 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence'), |
|
| 1077 | + ), |
|
| 1078 | + 'wait_list' => array( |
|
| 1079 | + 'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_wait_list, |
|
| 1080 | + 'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_wait_list, false, 'sentence'), |
|
| 1081 | + ), |
|
| 1082 | + ); |
|
| 1083 | + $this->_template_args['after_list_table'] = $this->_display_legend($legend_items); |
|
| 1084 | + $event_id = isset($this->_req_data['event_id']) ? $this->_req_data['event_id'] : null; |
|
| 1085 | + $this->_template_args['before_list_table'] = ! empty($event_id) |
|
| 1086 | + ? '<h2>' . sprintf( |
|
| 1087 | + __('Viewing Registrations for Event: %s', 'event_espresso'), |
|
| 1088 | + EEM_Event::instance()->get_one_by_ID($event_id)->get('EVT_name') |
|
| 1089 | + ) . '</h2>' |
|
| 1090 | + : ''; |
|
| 1091 | + //need to get the number of datetimes on the event and set default datetime_id if there is only one datetime on the event. |
|
| 1092 | + /** @var EE_Event $event */ |
|
| 1093 | + $event = EEM_Event::instance()->get_one_by_ID($event_id); |
|
| 1094 | + $DTT_ID = ! empty($this->_req_data['DTT_ID']) ? absint($this->_req_data['DTT_ID']) : 0; |
|
| 1095 | + $datetime = null; |
|
| 1096 | + if ($event instanceof EE_Event) { |
|
| 1097 | + $datetimes_on_event = $event->datetimes(); |
|
| 1098 | + if (count($datetimes_on_event) === 1) { |
|
| 1099 | + $datetime = reset($datetimes_on_event); |
|
| 1100 | + } |
|
| 1101 | + } |
|
| 1102 | + $datetime = $datetime instanceof EE_Datetime ? $datetime : EEM_Datetime::instance()->get_one_by_ID($DTT_ID); |
|
| 1103 | + if ($datetime instanceof EE_Datetime && $this->_template_args['before_list_table'] !== '') { |
|
| 1104 | + $this->_template_args['before_list_table'] = substr($this->_template_args['before_list_table'], 0, -5); |
|
| 1105 | + $this->_template_args['before_list_table'] .= ' <span class="drk-grey-text">'; |
|
| 1106 | + $this->_template_args['before_list_table'] .= '<span class="dashicons dashicons-calendar"></span>'; |
|
| 1107 | + $this->_template_args['before_list_table'] .= $datetime->name(); |
|
| 1108 | + $this->_template_args['before_list_table'] .= ' ( ' . $datetime->date_and_time_range() . ' )'; |
|
| 1109 | + $this->_template_args['before_list_table'] .= '</span></h2>'; |
|
| 1110 | + } |
|
| 1111 | + //if no datetime, then we're on the initial view, so let's give some helpful instructions on what the status column |
|
| 1112 | + //represents |
|
| 1113 | + if ( ! $datetime instanceof EE_Datetime) { |
|
| 1114 | + $this->_template_args['before_list_table'] .= '<br><p class="description">' |
|
| 1115 | + . __('In this view, the check-in status represents the latest check-in record for the registration in that row.', |
|
| 1116 | + 'event_espresso') |
|
| 1117 | + . '</p>'; |
|
| 1118 | + } |
|
| 1119 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
| 1120 | + } |
|
| 1121 | + |
|
| 1122 | + /** |
|
| 1123 | + * Download the registrations check-in report (same as the normal registration report, but with different where |
|
| 1124 | + * conditions) |
|
| 1125 | + * |
|
| 1126 | + * @return void ends the request by a redirect or download |
|
| 1127 | + */ |
|
| 1128 | + public function _registrations_checkin_report() |
|
| 1129 | + { |
|
| 1130 | + $this->_registrations_report_base('_get_checkin_query_params_from_request'); |
|
| 1131 | + } |
|
| 1132 | + |
|
| 1133 | + /** |
|
| 1134 | + * Gets the query params from the request, plus adds a where condition for the registration status, |
|
| 1135 | + * because on the checkin page we only ever want to see approved and pending-approval registrations |
|
| 1136 | + * |
|
| 1137 | + * @param array $request |
|
| 1138 | + * @param int $per_page |
|
| 1139 | + * @param bool $count |
|
| 1140 | + * @return array |
|
| 1141 | + */ |
|
| 1142 | + protected function _get_checkin_query_params_from_request( |
|
| 1143 | + $request, |
|
| 1144 | + $per_page = 10, |
|
| 1145 | + $count = false |
|
| 1146 | + ) { |
|
| 1147 | + $query_params = $this->_get_registration_query_parameters($request, $per_page, $count); |
|
| 1148 | + //unlike the regular registrations list table, |
|
| 1149 | + $status_ids_array = apply_filters( |
|
| 1150 | + 'FHEE__Extend_Registrations_Admin_Page__get_event_attendees__status_ids_array', |
|
| 1151 | + array(EEM_Registration::status_id_pending_payment, EEM_Registration::status_id_approved) |
|
| 1152 | + ); |
|
| 1153 | + $query_params[0]['STS_ID'] = array('IN', $status_ids_array); |
|
| 1154 | + return $query_params; |
|
| 1155 | + } |
|
| 1156 | + |
|
| 1157 | + |
|
| 1158 | + |
|
| 1159 | + |
|
| 1160 | + /** |
|
| 1161 | + * Gets registrations for an event |
|
| 1162 | + * |
|
| 1163 | + * @param int $per_page |
|
| 1164 | + * @param bool $count whether to return count or data. |
|
| 1165 | + * @param bool $trash |
|
| 1166 | + * @param string $orderby |
|
| 1167 | + * @return EE_Registration[]|int |
|
| 1168 | + * @throws \EE_Error |
|
| 1169 | + */ |
|
| 1170 | + public function get_event_attendees($per_page = 10, $count = false, $trash = false, $orderby = 'ATT_fname') |
|
| 1171 | + { |
|
| 1172 | + //normalize some request params that get setup by the parent `get_registrations` method. |
|
| 1173 | + $request = $this->_req_data; |
|
| 1174 | + $request['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : $orderby; |
|
| 1175 | + $request['order'] = ! empty($this->_req_data['order']) ? $this->_req_data['order'] : 'ASC'; |
|
| 1176 | + if($trash){ |
|
| 1177 | + $request['status'] = 'trash'; |
|
| 1178 | + } |
|
| 1179 | + $query_params = $this->_get_checkin_query_params_from_request( $request, $per_page, $count ); |
|
| 1180 | + /** |
|
| 1181 | + * Override the default groupby added by EEM_Base so that sorts with multiple order bys work as expected |
|
| 1182 | + * @link https://events.codebasehq.com/projects/event-espresso/tickets/10093 |
|
| 1183 | + * @see EEM_Base::get_all() |
|
| 1184 | + */ |
|
| 1185 | + $query_params['group_by'] = ''; |
|
| 1186 | + |
|
| 1187 | + return $count |
|
| 1188 | + ? EEM_Registration::instance()->count($query_params) |
|
| 1189 | + /** @type EE_Registration[] */ |
|
| 1190 | + : EEM_Registration::instance()->get_all($query_params); |
|
| 1191 | + } |
|
| 1192 | 1192 | |
| 1193 | 1193 | } //end class Registrations Admin Page |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | $this->_admin_base_url = EE_MSG_ADMIN_URL; |
| 88 | 88 | $this->_admin_base_path = EE_MSG_ADMIN; |
| 89 | 89 | |
| 90 | - $this->_activate_state = isset($this->_req_data['activate_state']) ? (array)$this->_req_data['activate_state'] : array(); |
|
| 90 | + $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array(); |
|
| 91 | 91 | |
| 92 | 92 | $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null; |
| 93 | 93 | $this->_load_message_resource_manager(); |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | array('none_selected' => __('Show All Messengers', 'event_espresso')), |
| 220 | 220 | $messenger_options |
| 221 | 221 | ); |
| 222 | - $input = new EE_Select_Input( |
|
| 222 | + $input = new EE_Select_Input( |
|
| 223 | 223 | $messenger_options, |
| 224 | 224 | array( |
| 225 | 225 | 'html_name' => 'ee_messenger_filter_by', |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | array('none_selected' => __('Show All Message Types', 'event_espresso')), |
| 258 | 258 | $message_type_options |
| 259 | 259 | ); |
| 260 | - $input = new EE_Select_Input( |
|
| 260 | + $input = new EE_Select_Input( |
|
| 261 | 261 | $message_type_options, |
| 262 | 262 | array( |
| 263 | 263 | 'html_name' => 'ee_message_type_filter_by', |
@@ -295,7 +295,7 @@ discard block |
||
| 295 | 295 | array('none_selected' => __('Show all Contexts', 'event_espresso')), |
| 296 | 296 | $context_options |
| 297 | 297 | ); |
| 298 | - $input = new EE_Select_Input( |
|
| 298 | + $input = new EE_Select_Input( |
|
| 299 | 299 | $context_options, |
| 300 | 300 | array( |
| 301 | 301 | 'html_name' => 'ee_context_filter_by', |
@@ -676,47 +676,47 @@ discard block |
||
| 676 | 676 | |
| 677 | 677 | public function messages_help_tab() |
| 678 | 678 | { |
| 679 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php'); |
|
| 679 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php'); |
|
| 680 | 680 | } |
| 681 | 681 | |
| 682 | 682 | |
| 683 | 683 | public function messengers_help_tab() |
| 684 | 684 | { |
| 685 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php'); |
|
| 685 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php'); |
|
| 686 | 686 | } |
| 687 | 687 | |
| 688 | 688 | |
| 689 | 689 | public function message_types_help_tab() |
| 690 | 690 | { |
| 691 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php'); |
|
| 691 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php'); |
|
| 692 | 692 | } |
| 693 | 693 | |
| 694 | 694 | |
| 695 | 695 | public function messages_overview_help_tab() |
| 696 | 696 | { |
| 697 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php'); |
|
| 697 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php'); |
|
| 698 | 698 | } |
| 699 | 699 | |
| 700 | 700 | |
| 701 | 701 | public function message_templates_help_tab() |
| 702 | 702 | { |
| 703 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php'); |
|
| 703 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php'); |
|
| 704 | 704 | } |
| 705 | 705 | |
| 706 | 706 | |
| 707 | 707 | public function edit_message_template_help_tab() |
| 708 | 708 | { |
| 709 | - $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', |
|
| 710 | - 'event_espresso') . '" />'; |
|
| 711 | - $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', |
|
| 712 | - 'event_espresso') . '" />'; |
|
| 713 | - $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', |
|
| 714 | - 'event_espresso') . '" />'; |
|
| 715 | - $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', |
|
| 716 | - 'event_espresso') . '" />'; |
|
| 717 | - $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', |
|
| 718 | - 'event_espresso') . '" />'; |
|
| 719 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', |
|
| 709 | + $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', |
|
| 710 | + 'event_espresso').'" />'; |
|
| 711 | + $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', |
|
| 712 | + 'event_espresso').'" />'; |
|
| 713 | + $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', |
|
| 714 | + 'event_espresso').'" />'; |
|
| 715 | + $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', |
|
| 716 | + 'event_espresso').'" />'; |
|
| 717 | + $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', |
|
| 718 | + 'event_espresso').'" />'; |
|
| 719 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', |
|
| 720 | 720 | $args); |
| 721 | 721 | } |
| 722 | 722 | |
@@ -725,37 +725,37 @@ discard block |
||
| 725 | 725 | { |
| 726 | 726 | $this->_set_shortcodes(); |
| 727 | 727 | $args['shortcodes'] = $this->_shortcodes; |
| 728 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', |
|
| 728 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', |
|
| 729 | 729 | $args); |
| 730 | 730 | } |
| 731 | 731 | |
| 732 | 732 | |
| 733 | 733 | public function preview_message_help_tab() |
| 734 | 734 | { |
| 735 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php'); |
|
| 735 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php'); |
|
| 736 | 736 | } |
| 737 | 737 | |
| 738 | 738 | |
| 739 | 739 | public function settings_help_tab() |
| 740 | 740 | { |
| 741 | - $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', |
|
| 742 | - 'event_espresso') . '" />'; |
|
| 743 | - $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', |
|
| 744 | - 'event_espresso') . '" />'; |
|
| 741 | + $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', |
|
| 742 | + 'event_espresso').'" />'; |
|
| 743 | + $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', |
|
| 744 | + 'event_espresso').'" />'; |
|
| 745 | 745 | $args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>'; |
| 746 | 746 | $args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>'; |
| 747 | - EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args); |
|
| 747 | + EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args); |
|
| 748 | 748 | } |
| 749 | 749 | |
| 750 | 750 | |
| 751 | 751 | public function load_scripts_styles() |
| 752 | 752 | { |
| 753 | - wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
| 753 | + wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION); |
|
| 754 | 754 | wp_enqueue_style('espresso_ee_msg'); |
| 755 | 755 | |
| 756 | - wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', |
|
| 756 | + wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', |
|
| 757 | 757 | array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true); |
| 758 | - wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL . 'ee_message_admin_list_table.js', |
|
| 758 | + wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', |
|
| 759 | 759 | array('ee-dialog'), EVENT_ESPRESSO_VERSION); |
| 760 | 760 | } |
| 761 | 761 | |
@@ -787,7 +787,7 @@ discard block |
||
| 787 | 787 | |
| 788 | 788 | $this->_set_shortcodes(); |
| 789 | 789 | |
| 790 | - EE_Registry::$i18n_js_strings['confirm_default_reset'] = sprintf( |
|
| 790 | + EE_Registry::$i18n_js_strings['confirm_default_reset'] = sprintf( |
|
| 791 | 791 | __('Are you sure you want to reset the %s %s message templates? Remember continuing will reset the templates for all contexts in this messenger and message type group.', |
| 792 | 792 | 'event_espresso'), |
| 793 | 793 | $this->_message_template_group->messenger_obj()->label['singular'], |
@@ -796,7 +796,7 @@ discard block |
||
| 796 | 796 | EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded. Any custom content in the existing template will be lost. Are you sure you wish to do this?', |
| 797 | 797 | 'event_espresso'); |
| 798 | 798 | |
| 799 | - wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), |
|
| 799 | + wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), |
|
| 800 | 800 | EVENT_ESPRESSO_VERSION); |
| 801 | 801 | |
| 802 | 802 | wp_enqueue_script('ee_admin_js'); |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | |
| 828 | 828 | public function load_scripts_styles_settings() |
| 829 | 829 | { |
| 830 | - wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), |
|
| 830 | + wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), |
|
| 831 | 831 | EVENT_ESPRESSO_VERSION); |
| 832 | 832 | wp_enqueue_style('ee-text-links'); |
| 833 | 833 | wp_enqueue_style('ee-message-settings'); |
@@ -893,7 +893,7 @@ discard block |
||
| 893 | 893 | } |
| 894 | 894 | $status_bulk_actions = $common_bulk_actions; |
| 895 | 895 | //unset bulk actions not applying to status |
| 896 | - if (! empty($status_bulk_actions)) { |
|
| 896 | + if ( ! empty($status_bulk_actions)) { |
|
| 897 | 897 | switch ($status) { |
| 898 | 898 | case EEM_Message::status_idle: |
| 899 | 899 | case EEM_Message::status_resend: |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | } |
| 919 | 919 | |
| 920 | 920 | //skip adding messenger executing status to views because it will be included with the Failed view. |
| 921 | - if ( $status === EEM_Message::status_messenger_executing ) { |
|
| 921 | + if ($status === EEM_Message::status_messenger_executing) { |
|
| 922 | 922 | continue; |
| 923 | 923 | } |
| 924 | 924 | |
@@ -944,7 +944,7 @@ discard block |
||
| 944 | 944 | $this->_search_btn_label = __('Message Activity', 'event_espresso'); |
| 945 | 945 | $this->_template_args['per_column'] = 6; |
| 946 | 946 | $this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items()); |
| 947 | - $this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>'; |
|
| 947 | + $this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>'; |
|
| 948 | 948 | $this->display_admin_list_table_page_with_no_sidebar(); |
| 949 | 949 | } |
| 950 | 950 | |
@@ -968,37 +968,37 @@ discard block |
||
| 968 | 968 | /** @type array $status_items status legend setup */ |
| 969 | 969 | $status_items = array( |
| 970 | 970 | 'sent_status' => array( |
| 971 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent, |
|
| 971 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent, |
|
| 972 | 972 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence') |
| 973 | 973 | ), |
| 974 | 974 | 'idle_status' => array( |
| 975 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle, |
|
| 975 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle, |
|
| 976 | 976 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence') |
| 977 | 977 | ), |
| 978 | 978 | 'failed_status' => array( |
| 979 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed, |
|
| 979 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed, |
|
| 980 | 980 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence') |
| 981 | 981 | ), |
| 982 | 982 | 'messenger_executing_status' => array( |
| 983 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_messenger_executing, |
|
| 983 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_messenger_executing, |
|
| 984 | 984 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_messenger_executing, false, 'sentence') |
| 985 | 985 | ), |
| 986 | 986 | 'resend_status' => array( |
| 987 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend, |
|
| 987 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend, |
|
| 988 | 988 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence') |
| 989 | 989 | ), |
| 990 | 990 | 'incomplete_status' => array( |
| 991 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete, |
|
| 991 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete, |
|
| 992 | 992 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence') |
| 993 | 993 | ), |
| 994 | 994 | 'retry_status' => array( |
| 995 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry, |
|
| 995 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry, |
|
| 996 | 996 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence') |
| 997 | 997 | ) |
| 998 | 998 | ); |
| 999 | 999 | if (EEM_Message::debug()) { |
| 1000 | 1000 | $status_items['debug_only_status'] = array( |
| 1001 | - 'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only, |
|
| 1001 | + 'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only, |
|
| 1002 | 1002 | 'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence') |
| 1003 | 1003 | ); |
| 1004 | 1004 | } |
@@ -1010,10 +1010,10 @@ discard block |
||
| 1010 | 1010 | protected function _custom_mtps_preview() |
| 1011 | 1011 | { |
| 1012 | 1012 | $this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso'); |
| 1013 | - $this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', |
|
| 1014 | - 'event_espresso') . '" />'; |
|
| 1015 | - $this->_template_args['preview_text'] = '<strong>' . __('Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.', |
|
| 1016 | - 'event_espresso') . '</strong>'; |
|
| 1013 | + $this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', |
|
| 1014 | + 'event_espresso').'" />'; |
|
| 1015 | + $this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.', |
|
| 1016 | + 'event_espresso').'</strong>'; |
|
| 1017 | 1017 | $this->display_admin_caf_preview_page('custom_message_types', false); |
| 1018 | 1018 | } |
| 1019 | 1019 | |
@@ -1261,7 +1261,7 @@ discard block |
||
| 1261 | 1261 | //let's verify if we need this extra field via the shortcodes parameter. |
| 1262 | 1262 | $continue = false; |
| 1263 | 1263 | if (isset($extra_array['shortcodes_required'])) { |
| 1264 | - foreach ((array)$extra_array['shortcodes_required'] as $shortcode) { |
|
| 1264 | + foreach ((array) $extra_array['shortcodes_required'] as $shortcode) { |
|
| 1265 | 1265 | if ( ! array_key_exists($shortcode, $this->_shortcodes)) { |
| 1266 | 1266 | $continue = true; |
| 1267 | 1267 | } |
@@ -1271,9 +1271,9 @@ discard block |
||
| 1271 | 1271 | } |
| 1272 | 1272 | } |
| 1273 | 1273 | |
| 1274 | - $field_id = $reference_field . '-' . $extra_field . '-content'; |
|
| 1274 | + $field_id = $reference_field.'-'.$extra_field.'-content'; |
|
| 1275 | 1275 | $template_form_fields[$field_id] = $extra_array; |
| 1276 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']'; |
|
| 1276 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']'; |
|
| 1277 | 1277 | $css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : ''; |
| 1278 | 1278 | |
| 1279 | 1279 | $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
@@ -1283,7 +1283,7 @@ discard block |
||
| 1283 | 1283 | is_array($validators[$extra_field]) |
| 1284 | 1284 | && isset($validators[$extra_field]['msg']) |
| 1285 | 1285 | ) |
| 1286 | - ? 'validate-error ' . $css_class |
|
| 1286 | + ? 'validate-error '.$css_class |
|
| 1287 | 1287 | : $css_class; |
| 1288 | 1288 | |
| 1289 | 1289 | $template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) |
@@ -1311,11 +1311,11 @@ discard block |
||
| 1311 | 1311 | |
| 1312 | 1312 | }/**/ |
| 1313 | 1313 | } |
| 1314 | - $templatefield_MTP_id = $reference_field . '-MTP_ID'; |
|
| 1315 | - $templatefield_templatename_id = $reference_field . '-name'; |
|
| 1314 | + $templatefield_MTP_id = $reference_field.'-MTP_ID'; |
|
| 1315 | + $templatefield_templatename_id = $reference_field.'-name'; |
|
| 1316 | 1316 | |
| 1317 | 1317 | $template_form_fields[$templatefield_MTP_id] = array( |
| 1318 | - 'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]', |
|
| 1318 | + 'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]', |
|
| 1319 | 1319 | 'label' => null, |
| 1320 | 1320 | 'input' => 'hidden', |
| 1321 | 1321 | 'type' => 'int', |
@@ -1328,7 +1328,7 @@ discard block |
||
| 1328 | 1328 | ); |
| 1329 | 1329 | |
| 1330 | 1330 | $template_form_fields[$templatefield_templatename_id] = array( |
| 1331 | - 'name' => 'MTP_template_fields[' . $reference_field . '][name]', |
|
| 1331 | + 'name' => 'MTP_template_fields['.$reference_field.'][name]', |
|
| 1332 | 1332 | 'label' => null, |
| 1333 | 1333 | 'input' => 'hidden', |
| 1334 | 1334 | 'type' => 'string', |
@@ -1342,9 +1342,9 @@ discard block |
||
| 1342 | 1342 | } |
| 1343 | 1343 | continue; //skip the next stuff, we got the necessary fields here for this dataset. |
| 1344 | 1344 | } else { |
| 1345 | - $field_id = $template_field . '-content'; |
|
| 1345 | + $field_id = $template_field.'-content'; |
|
| 1346 | 1346 | $template_form_fields[$field_id] = $field_setup_array; |
| 1347 | - $template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]'; |
|
| 1347 | + $template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]'; |
|
| 1348 | 1348 | $message_template = isset($message_templates[$context][$template_field]) |
| 1349 | 1349 | ? $message_templates[$context][$template_field] |
| 1350 | 1350 | : null; |
@@ -1365,7 +1365,7 @@ discard block |
||
| 1365 | 1365 | $template_form_fields[$field_id]['css_class'] = ! empty($v_fields) |
| 1366 | 1366 | && in_array($template_field, $v_fields) |
| 1367 | 1367 | && isset($validators[$template_field]['msg']) |
| 1368 | - ? 'validate-error ' . $css_class |
|
| 1368 | + ? 'validate-error '.$css_class |
|
| 1369 | 1369 | : $css_class; |
| 1370 | 1370 | |
| 1371 | 1371 | //shortcode selector |
@@ -1376,12 +1376,12 @@ discard block |
||
| 1376 | 1376 | |
| 1377 | 1377 | //k took care of content field(s) now let's take care of others. |
| 1378 | 1378 | |
| 1379 | - $templatefield_MTP_id = $template_field . '-MTP_ID'; |
|
| 1380 | - $templatefield_field_templatename_id = $template_field . '-name'; |
|
| 1379 | + $templatefield_MTP_id = $template_field.'-MTP_ID'; |
|
| 1380 | + $templatefield_field_templatename_id = $template_field.'-name'; |
|
| 1381 | 1381 | |
| 1382 | 1382 | //foreach template field there are actually two form fields created |
| 1383 | 1383 | $template_form_fields[$templatefield_MTP_id] = array( |
| 1384 | - 'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]', |
|
| 1384 | + 'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]', |
|
| 1385 | 1385 | 'label' => null, |
| 1386 | 1386 | 'input' => 'hidden', |
| 1387 | 1387 | 'type' => 'int', |
@@ -1394,7 +1394,7 @@ discard block |
||
| 1394 | 1394 | ); |
| 1395 | 1395 | |
| 1396 | 1396 | $template_form_fields[$templatefield_field_templatename_id] = array( |
| 1397 | - 'name' => 'MTP_template_fields[' . $template_field . '][name]', |
|
| 1397 | + 'name' => 'MTP_template_fields['.$template_field.'][name]', |
|
| 1398 | 1398 | 'label' => null, |
| 1399 | 1399 | 'input' => 'hidden', |
| 1400 | 1400 | 'type' => 'string', |
@@ -1512,7 +1512,7 @@ discard block |
||
| 1512 | 1512 | 'format' => '%d', |
| 1513 | 1513 | 'db-col' => 'MTP_deleted' |
| 1514 | 1514 | ); |
| 1515 | - $sidebar_form_fields['ee-msg-author'] = array( |
|
| 1515 | + $sidebar_form_fields['ee-msg-author'] = array( |
|
| 1516 | 1516 | 'name' => 'MTP_user_id', |
| 1517 | 1517 | 'label' => __('Author', 'event_espresso'), |
| 1518 | 1518 | 'input' => 'hidden', |
@@ -1531,17 +1531,17 @@ discard block |
||
| 1531 | 1531 | 'value' => $action |
| 1532 | 1532 | ); |
| 1533 | 1533 | |
| 1534 | - $sidebar_form_fields['ee-msg-id'] = array( |
|
| 1534 | + $sidebar_form_fields['ee-msg-id'] = array( |
|
| 1535 | 1535 | 'name' => 'id', |
| 1536 | 1536 | 'input' => 'hidden', |
| 1537 | 1537 | 'type' => 'int', |
| 1538 | 1538 | 'value' => $GRP_ID |
| 1539 | 1539 | ); |
| 1540 | 1540 | $sidebar_form_fields['ee-msg-evt-nonce'] = array( |
| 1541 | - 'name' => $action . '_nonce', |
|
| 1541 | + 'name' => $action.'_nonce', |
|
| 1542 | 1542 | 'input' => 'hidden', |
| 1543 | 1543 | 'type' => 'string', |
| 1544 | - 'value' => wp_create_nonce($action . '_nonce') |
|
| 1544 | + 'value' => wp_create_nonce($action.'_nonce') |
|
| 1545 | 1545 | ); |
| 1546 | 1546 | |
| 1547 | 1547 | if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) { |
@@ -1573,7 +1573,7 @@ discard block |
||
| 1573 | 1573 | ); |
| 1574 | 1574 | |
| 1575 | 1575 | //add preview button |
| 1576 | - $preview_url = parent::add_query_args_and_nonce( |
|
| 1576 | + $preview_url = parent::add_query_args_and_nonce( |
|
| 1577 | 1577 | array( |
| 1578 | 1578 | 'message_type' => $message_template_group->message_type(), |
| 1579 | 1579 | 'messenger' => $message_template_group->messenger(), |
@@ -1583,8 +1583,8 @@ discard block |
||
| 1583 | 1583 | ), |
| 1584 | 1584 | $this->_admin_base_url |
| 1585 | 1585 | ); |
| 1586 | - $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', |
|
| 1587 | - 'event_espresso') . '</a>'; |
|
| 1586 | + $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', |
|
| 1587 | + 'event_espresso').'</a>'; |
|
| 1588 | 1588 | |
| 1589 | 1589 | |
| 1590 | 1590 | //setup context switcher |
@@ -1613,7 +1613,7 @@ discard block |
||
| 1613 | 1613 | |
| 1614 | 1614 | $this->_template_path = $this->_template_args['GRP_ID'] |
| 1615 | 1615 | ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' |
| 1616 | - : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php'; |
|
| 1616 | + : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php'; |
|
| 1617 | 1617 | |
| 1618 | 1618 | //send along EE_Message_Template_Group object for further template use. |
| 1619 | 1619 | $this->_template_args['MTP'] = $message_template_group; |
@@ -1648,7 +1648,7 @@ discard block |
||
| 1648 | 1648 | |
| 1649 | 1649 | public function _add_form_element_before() |
| 1650 | 1650 | { |
| 1651 | - return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">'; |
|
| 1651 | + return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">'; |
|
| 1652 | 1652 | } |
| 1653 | 1653 | |
| 1654 | 1654 | public function _add_form_element_after() |
@@ -1843,14 +1843,14 @@ discard block |
||
| 1843 | 1843 | } |
| 1844 | 1844 | |
| 1845 | 1845 | //let's add a button to go back to the edit view |
| 1846 | - $query_args = array( |
|
| 1846 | + $query_args = array( |
|
| 1847 | 1847 | 'id' => $this->_req_data['GRP_ID'], |
| 1848 | 1848 | 'context' => $this->_req_data['context'], |
| 1849 | 1849 | 'action' => 'edit_message_template' |
| 1850 | 1850 | ); |
| 1851 | 1851 | $go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url); |
| 1852 | - $preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', |
|
| 1853 | - 'event_espresso') . '</a>'; |
|
| 1852 | + $preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', |
|
| 1853 | + 'event_espresso').'</a>'; |
|
| 1854 | 1854 | $message_types = $this->get_installed_message_types(); |
| 1855 | 1855 | $active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']); |
| 1856 | 1856 | $active_messenger_label = $active_messenger instanceof EE_messenger |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | ); |
| 1865 | 1865 | //setup display of preview. |
| 1866 | 1866 | $this->_admin_page_title = $preview_title; |
| 1867 | - $this->_template_args['admin_page_content'] = $preview_button . '<br />' . stripslashes($preview); |
|
| 1867 | + $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview); |
|
| 1868 | 1868 | $this->_template_args['data']['force_json'] = true; |
| 1869 | 1869 | |
| 1870 | 1870 | return ''; |
@@ -1946,7 +1946,7 @@ discard block |
||
| 1946 | 1946 | } |
| 1947 | 1947 | |
| 1948 | 1948 | //setup variation select values for the currently selected template. |
| 1949 | - $variations = $this->_message_template_group->get_template_pack()->get_variations( |
|
| 1949 | + $variations = $this->_message_template_group->get_template_pack()->get_variations( |
|
| 1950 | 1950 | $this->_message_template_group->messenger(), |
| 1951 | 1951 | $this->_message_template_group->message_type() |
| 1952 | 1952 | ); |
@@ -1960,12 +1960,12 @@ discard block |
||
| 1960 | 1960 | |
| 1961 | 1961 | $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels(); |
| 1962 | 1962 | |
| 1963 | - $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( |
|
| 1963 | + $template_args['template_packs_selector'] = EEH_Form_Fields::select_input( |
|
| 1964 | 1964 | 'MTP_template_pack', |
| 1965 | 1965 | $tp_select_values, |
| 1966 | 1966 | $this->_message_template_group->get_template_pack_name() |
| 1967 | 1967 | ); |
| 1968 | - $template_args['variations_selector'] = EEH_Form_Fields::select_input( |
|
| 1968 | + $template_args['variations_selector'] = EEH_Form_Fields::select_input( |
|
| 1969 | 1969 | 'MTP_template_variation', |
| 1970 | 1970 | $variations_select_values, |
| 1971 | 1971 | $this->_message_template_group->get_template_pack_variation() |
@@ -1975,7 +1975,7 @@ discard block |
||
| 1975 | 1975 | $template_args['template_pack_description'] = $template_pack_labels->template_pack_description; |
| 1976 | 1976 | $template_args['template_variation_description'] = $template_pack_labels->template_variation_description; |
| 1977 | 1977 | |
| 1978 | - $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php'; |
|
| 1978 | + $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php'; |
|
| 1979 | 1979 | |
| 1980 | 1980 | EEH_Template::display_template($template, $template_args); |
| 1981 | 1981 | } |
@@ -2004,7 +2004,7 @@ discard block |
||
| 2004 | 2004 | if ( ! empty($fields)) { |
| 2005 | 2005 | //yup there be fields |
| 2006 | 2006 | foreach ($fields as $field => $config) { |
| 2007 | - $field_id = $this->_message_template_group->messenger() . '_' . $field; |
|
| 2007 | + $field_id = $this->_message_template_group->messenger().'_'.$field; |
|
| 2008 | 2008 | $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings(); |
| 2009 | 2009 | $default = isset($config['default']) ? $config['default'] : ''; |
| 2010 | 2010 | $default = isset($config['value']) ? $config['value'] : $default; |
@@ -2019,7 +2019,7 @@ discard block |
||
| 2019 | 2019 | : $fix; |
| 2020 | 2020 | |
| 2021 | 2021 | $template_form_fields[$field_id] = array( |
| 2022 | - 'name' => 'test_settings_fld[' . $field . ']', |
|
| 2022 | + 'name' => 'test_settings_fld['.$field.']', |
|
| 2023 | 2023 | 'label' => $config['label'], |
| 2024 | 2024 | 'input' => $config['input'], |
| 2025 | 2025 | 'type' => $config['type'], |
@@ -2049,7 +2049,7 @@ discard block |
||
| 2049 | 2049 | } |
| 2050 | 2050 | |
| 2051 | 2051 | //and button |
| 2052 | - $test_settings_html .= '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>'; |
|
| 2052 | + $test_settings_html .= '<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'; |
|
| 2053 | 2053 | $test_settings_html .= '<div class="publishing-action alignright resetbutton">'; |
| 2054 | 2054 | $test_settings_html .= $this->get_action_link_or_button( |
| 2055 | 2055 | 'reset_to_default', |
@@ -2080,7 +2080,7 @@ discard block |
||
| 2080 | 2080 | 'linked_input_id' => $linked_input_id |
| 2081 | 2081 | ); |
| 2082 | 2082 | |
| 2083 | - return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', |
|
| 2083 | + return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', |
|
| 2084 | 2084 | $template_args, true); |
| 2085 | 2085 | } |
| 2086 | 2086 | |
@@ -2098,7 +2098,7 @@ discard block |
||
| 2098 | 2098 | //$messenger = $this->_message_template_group->messenger_obj(); |
| 2099 | 2099 | //now let's set the content depending on the status of the shortcodes array |
| 2100 | 2100 | if (empty($shortcodes)) { |
| 2101 | - $content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>'; |
|
| 2101 | + $content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>'; |
|
| 2102 | 2102 | echo $content; |
| 2103 | 2103 | } else { |
| 2104 | 2104 | //$alt = 0; |
@@ -2215,7 +2215,7 @@ discard block |
||
| 2215 | 2215 | <?php |
| 2216 | 2216 | } |
| 2217 | 2217 | //setup nonce_url |
| 2218 | - wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false); |
|
| 2218 | + wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false); |
|
| 2219 | 2219 | ?> |
| 2220 | 2220 | <select name="context"> |
| 2221 | 2221 | <?php |
@@ -2313,7 +2313,7 @@ discard block |
||
| 2313 | 2313 | : ''; |
| 2314 | 2314 | $context = ucwords(str_replace('_', ' ', $context_slug)); |
| 2315 | 2315 | |
| 2316 | - $item_desc = $messenger_label && $message_type_label ? $messenger_label . ' ' . $message_type_label . ' ' . $context . ' ' : ''; |
|
| 2316 | + $item_desc = $messenger_label && $message_type_label ? $messenger_label.' '.$message_type_label.' '.$context.' ' : ''; |
|
| 2317 | 2317 | $item_desc .= 'Message Template'; |
| 2318 | 2318 | $query_args = array(); |
| 2319 | 2319 | $edit_array = array(); |
@@ -2688,8 +2688,8 @@ discard block |
||
| 2688 | 2688 | */ |
| 2689 | 2689 | protected function _learn_more_about_message_templates_link() |
| 2690 | 2690 | { |
| 2691 | - return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', |
|
| 2692 | - 'event_espresso') . '</a>'; |
|
| 2691 | + return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', |
|
| 2692 | + 'event_espresso').'</a>'; |
|
| 2693 | 2693 | } |
| 2694 | 2694 | |
| 2695 | 2695 | |
@@ -2765,10 +2765,10 @@ discard block |
||
| 2765 | 2765 | |
| 2766 | 2766 | $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array( |
| 2767 | 2767 | 'label' => ucwords($message_type->label['singular']), |
| 2768 | - 'class' => 'message-type-' . $a_or_i, |
|
| 2769 | - 'slug_id' => $message_type->name . '-messagetype-' . $messenger->name, |
|
| 2770 | - 'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'), |
|
| 2771 | - 'href' => 'espresso_' . $message_type->name . '_message_type_settings', |
|
| 2768 | + 'class' => 'message-type-'.$a_or_i, |
|
| 2769 | + 'slug_id' => $message_type->name.'-messagetype-'.$messenger->name, |
|
| 2770 | + 'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'), |
|
| 2771 | + 'href' => 'espresso_'.$message_type->name.'_message_type_settings', |
|
| 2772 | 2772 | 'title' => $a_or_i == 'active' |
| 2773 | 2773 | ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') |
| 2774 | 2774 | : __('Drag this message type to the messenger to activate', 'event_espresso'), |
@@ -2804,9 +2804,9 @@ discard block |
||
| 2804 | 2804 | $existing_settings = $message_type->get_existing_admin_settings($messenger->name); |
| 2805 | 2805 | |
| 2806 | 2806 | foreach ($fields as $fldname => $fldprops) { |
| 2807 | - $field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname; |
|
| 2807 | + $field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname; |
|
| 2808 | 2808 | $template_form_field[$field_id] = array( |
| 2809 | - 'name' => 'message_type_settings[' . $fldname . ']', |
|
| 2809 | + 'name' => 'message_type_settings['.$fldname.']', |
|
| 2810 | 2810 | 'label' => $fldprops['label'], |
| 2811 | 2811 | 'input' => $fldprops['field_type'], |
| 2812 | 2812 | 'type' => $fldprops['value_type'], |
@@ -2847,7 +2847,7 @@ discard block |
||
| 2847 | 2847 | $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : ''; |
| 2848 | 2848 | |
| 2849 | 2849 | |
| 2850 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php'; |
|
| 2850 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php'; |
|
| 2851 | 2851 | $content = EEH_Template::display_template($template, $settings_template_args, true); |
| 2852 | 2852 | |
| 2853 | 2853 | return $content; |
@@ -2877,11 +2877,11 @@ discard block |
||
| 2877 | 2877 | $active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) |
| 2878 | 2878 | ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] |
| 2879 | 2879 | : ''; |
| 2880 | - $m_boxes[$messenger . '_a_box'] = sprintf( |
|
| 2880 | + $m_boxes[$messenger.'_a_box'] = sprintf( |
|
| 2881 | 2881 | __('%s Settings', 'event_espresso'), |
| 2882 | 2882 | $tab_array['label'] |
| 2883 | 2883 | ); |
| 2884 | - $m_template_args[$messenger . '_a_box'] = array( |
|
| 2884 | + $m_template_args[$messenger.'_a_box'] = array( |
|
| 2885 | 2885 | 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
| 2886 | 2886 | 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
| 2887 | 2887 | ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
@@ -2895,8 +2895,8 @@ discard block |
||
| 2895 | 2895 | // message type meta boxes |
| 2896 | 2896 | // (which is really just the inactive container for each messenger |
| 2897 | 2897 | // showing inactive message types for that messenger) |
| 2898 | - $mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
| 2899 | - $mt_template_args[$messenger . '_i_box'] = array( |
|
| 2898 | + $mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso'); |
|
| 2899 | + $mt_template_args[$messenger.'_i_box'] = array( |
|
| 2900 | 2900 | 'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '', |
| 2901 | 2901 | 'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
| 2902 | 2902 | ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) |
@@ -2912,14 +2912,14 @@ discard block |
||
| 2912 | 2912 | |
| 2913 | 2913 | |
| 2914 | 2914 | //register messenger metaboxes |
| 2915 | - $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
| 2915 | + $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php'; |
|
| 2916 | 2916 | foreach ($m_boxes as $box => $label) { |
| 2917 | 2917 | $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]); |
| 2918 | 2918 | $msgr = str_replace('_a_box', '', $box); |
| 2919 | 2919 | add_meta_box( |
| 2920 | - 'espresso_' . $msgr . '_settings', |
|
| 2920 | + 'espresso_'.$msgr.'_settings', |
|
| 2921 | 2921 | $label, |
| 2922 | - function ($post, $metabox) { |
|
| 2922 | + function($post, $metabox) { |
|
| 2923 | 2923 | echo EEH_Template::display_template($metabox["args"]["template_path"], |
| 2924 | 2924 | $metabox["args"]["template_args"], true); |
| 2925 | 2925 | }, |
@@ -2931,17 +2931,17 @@ discard block |
||
| 2931 | 2931 | } |
| 2932 | 2932 | |
| 2933 | 2933 | //register message type metaboxes |
| 2934 | - $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php'; |
|
| 2934 | + $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php'; |
|
| 2935 | 2935 | foreach ($mt_boxes as $box => $label) { |
| 2936 | 2936 | $callback_args = array( |
| 2937 | 2937 | 'template_path' => $mt_template_path, |
| 2938 | 2938 | 'template_args' => $mt_template_args[$box] |
| 2939 | 2939 | ); |
| 2940 | - $mt = str_replace('_i_box', '', $box); |
|
| 2940 | + $mt = str_replace('_i_box', '', $box); |
|
| 2941 | 2941 | add_meta_box( |
| 2942 | - 'espresso_' . $mt . '_inactive_mts', |
|
| 2942 | + 'espresso_'.$mt.'_inactive_mts', |
|
| 2943 | 2943 | $label, |
| 2944 | - function ($post, $metabox) { |
|
| 2944 | + function($post, $metabox) { |
|
| 2945 | 2945 | echo EEH_Template::display_template($metabox["args"]["template_path"], |
| 2946 | 2946 | $metabox["args"]["template_args"], true); |
| 2947 | 2947 | }, |
@@ -3043,7 +3043,7 @@ discard block |
||
| 3043 | 3043 | if ($form->is_valid()) { |
| 3044 | 3044 | $valid_data = $form->valid_data(); |
| 3045 | 3045 | foreach ($valid_data as $property => $value) { |
| 3046 | - $setter = 'set_' . $property; |
|
| 3046 | + $setter = 'set_'.$property; |
|
| 3047 | 3047 | if (method_exists($network_config, $setter)) { |
| 3048 | 3048 | $network_config->{$setter}($value); |
| 3049 | 3049 | } else if ( |
@@ -3072,8 +3072,8 @@ discard block |
||
| 3072 | 3072 | */ |
| 3073 | 3073 | protected function _get_mt_tabs($tab_array) |
| 3074 | 3074 | { |
| 3075 | - $tab_array = (array)$tab_array; |
|
| 3076 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php'; |
|
| 3075 | + $tab_array = (array) $tab_array; |
|
| 3076 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php'; |
|
| 3077 | 3077 | $tabs = ''; |
| 3078 | 3078 | |
| 3079 | 3079 | foreach ($tab_array as $tab) { |
@@ -3106,9 +3106,9 @@ discard block |
||
| 3106 | 3106 | $existing_settings = $messenger->get_existing_admin_settings(); |
| 3107 | 3107 | |
| 3108 | 3108 | foreach ($fields as $fldname => $fldprops) { |
| 3109 | - $field_id = $messenger->name . '-' . $fldname; |
|
| 3109 | + $field_id = $messenger->name.'-'.$fldname; |
|
| 3110 | 3110 | $template_form_field[$field_id] = array( |
| 3111 | - 'name' => 'messenger_settings[' . $field_id . ']', |
|
| 3111 | + 'name' => 'messenger_settings['.$field_id.']', |
|
| 3112 | 3112 | 'label' => $fldprops['label'], |
| 3113 | 3113 | 'input' => $fldprops['field_type'], |
| 3114 | 3114 | 'type' => $fldprops['value_type'], |
@@ -3143,7 +3143,7 @@ discard block |
||
| 3143 | 3143 | //make sure any active message types that are existing are included in the hidden fields |
| 3144 | 3144 | if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) { |
| 3145 | 3145 | foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) { |
| 3146 | - $settings_template_args['hidden_fields']['messenger_settings[message_types][' . $mt . ']'] = array( |
|
| 3146 | + $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array( |
|
| 3147 | 3147 | 'type' => 'hidden', |
| 3148 | 3148 | 'value' => $mt |
| 3149 | 3149 | ); |
@@ -3153,7 +3153,7 @@ discard block |
||
| 3153 | 3153 | $settings_template_args['hidden_fields'], |
| 3154 | 3154 | 'array' |
| 3155 | 3155 | ); |
| 3156 | - $active = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
| 3156 | + $active = $this->_message_resource_manager->is_messenger_active($messenger->name); |
|
| 3157 | 3157 | |
| 3158 | 3158 | $settings_template_args['messenger'] = $messenger->name; |
| 3159 | 3159 | $settings_template_args['description'] = $messenger->description; |
@@ -3170,9 +3170,9 @@ discard block |
||
| 3170 | 3170 | |
| 3171 | 3171 | |
| 3172 | 3172 | $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on'; |
| 3173 | - $settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce'); |
|
| 3173 | + $settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce'); |
|
| 3174 | 3174 | $settings_template_args['on_off_status'] = $active ? true : false; |
| 3175 | - $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php'; |
|
| 3175 | + $template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php'; |
|
| 3176 | 3176 | $content = EEH_Template::display_template($template, $settings_template_args, |
| 3177 | 3177 | true); |
| 3178 | 3178 | |
@@ -3200,7 +3200,7 @@ discard block |
||
| 3200 | 3200 | |
| 3201 | 3201 | //do a nonce check here since we're not arriving via a normal route |
| 3202 | 3202 | $nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : ''; |
| 3203 | - $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce'; |
|
| 3203 | + $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce'; |
|
| 3204 | 3204 | |
| 3205 | 3205 | $this->_verify_nonce($nonce, $nonce_ref); |
| 3206 | 3206 | |
@@ -3302,7 +3302,7 @@ discard block |
||
| 3302 | 3302 | |
| 3303 | 3303 | //do a nonce check here since we're not arriving via a normal route |
| 3304 | 3304 | $nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : ''; |
| 3305 | - $nonce_ref = $this->_req_data['message_type'] . '_nonce'; |
|
| 3305 | + $nonce_ref = $this->_req_data['message_type'].'_nonce'; |
|
| 3306 | 3306 | |
| 3307 | 3307 | $this->_verify_nonce($nonce, $nonce_ref); |
| 3308 | 3308 | |
@@ -1,6 +1,6 @@ discard block |
||
| 1 | 1 | <?php |
| 2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
| 3 | - exit( 'No direct script access allowed' ); |
|
| 2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
| 3 | + exit('No direct script access allowed'); |
|
| 4 | 4 | } |
| 5 | 5 | /** |
| 6 | 6 | * ************************************************************************ |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | $action_or_filter = 'action' |
| 44 | 44 | ) { |
| 45 | 45 | $action_or_filter = $action_or_filter === 'action' |
| 46 | - ? esc_html__( 'action', 'event_espresso' ) |
|
| 47 | - : esc_html__( 'filter', 'event_espresso' ); |
|
| 46 | + ? esc_html__('action', 'event_espresso') |
|
| 47 | + : esc_html__('filter', 'event_espresso'); |
|
| 48 | 48 | EE_Error::doing_it_wrong( |
| 49 | 49 | $deprecated_filter, |
| 50 | 50 | sprintf( |
@@ -68,7 +68,7 @@ discard block |
||
| 68 | 68 | * @param \EE_Checkout $checkout |
| 69 | 69 | * @return string |
| 70 | 70 | */ |
| 71 | -function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) { |
|
| 71 | +function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) { |
|
| 72 | 72 | // list of old filters |
| 73 | 73 | $deprecated_filters = array( |
| 74 | 74 | 'update_registration_details' => true, |
@@ -78,16 +78,16 @@ discard block |
||
| 78 | 78 | 'proceed_to' => true, |
| 79 | 79 | ); |
| 80 | 80 | // loop thru and call doing_it_wrong() or remove any that aren't being used |
| 81 | - foreach ( $deprecated_filters as $deprecated_filter => $on ) { |
|
| 81 | + foreach ($deprecated_filters as $deprecated_filter => $on) { |
|
| 82 | 82 | // was this filter called ? |
| 83 | - if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) { |
|
| 83 | + if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) { |
|
| 84 | 84 | // only display doing_it_wrong() notice to Event Admins during non-AJAX requests |
| 85 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) { |
|
| 85 | + if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) { |
|
| 86 | 86 | EE_Error::doing_it_wrong( |
| 87 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 87 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 88 | 88 | sprintf( |
| 89 | - __( 'The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ), |
|
| 90 | - 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter, |
|
| 89 | + __('The %1$s filter is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'), |
|
| 90 | + 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter, |
|
| 91 | 91 | '<br />', |
| 92 | 92 | 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', |
| 93 | 93 | '/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php' |
@@ -96,24 +96,24 @@ discard block |
||
| 96 | 96 | ); |
| 97 | 97 | } |
| 98 | 98 | } else { |
| 99 | - unset( $deprecated_filters[ $deprecated_filter ] ); |
|
| 99 | + unset($deprecated_filters[$deprecated_filter]); |
|
| 100 | 100 | } |
| 101 | 101 | } |
| 102 | - if ( ! empty( $deprecated_filters )) { |
|
| 103 | - |
|
| 104 | - if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) { |
|
| 105 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text ); |
|
| 106 | - } else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) { |
|
| 107 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text ); |
|
| 108 | - } else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) { |
|
| 109 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text ); |
|
| 102 | + if ( ! empty($deprecated_filters)) { |
|
| 103 | + |
|
| 104 | + if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) { |
|
| 105 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text); |
|
| 106 | + } else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) { |
|
| 107 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text); |
|
| 108 | + } else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) { |
|
| 109 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text); |
|
| 110 | 110 | } |
| 111 | - if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) { |
|
| 112 | - if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) { |
|
| 113 | - $submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text ); |
|
| 111 | + if ($checkout->next_step instanceof EE_SPCO_Reg_Step) { |
|
| 112 | + if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) { |
|
| 113 | + $submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text); |
|
| 114 | 114 | } |
| 115 | - if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) { |
|
| 116 | - $submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name(); |
|
| 115 | + if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) { |
|
| 116 | + $submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name(); |
|
| 117 | 117 | } |
| 118 | 118 | } |
| 119 | 119 | |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | return $submit_button_text; |
| 122 | 122 | |
| 123 | 123 | } |
| 124 | -add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 ); |
|
| 124 | +add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2); |
|
| 125 | 125 | |
| 126 | 126 | |
| 127 | 127 | |
@@ -132,16 +132,16 @@ discard block |
||
| 132 | 132 | * @param \EE_Checkout $checkout |
| 133 | 133 | * @param boolean $status_updates |
| 134 | 134 | */ |
| 135 | -function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) { |
|
| 135 | +function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) { |
|
| 136 | 136 | $action_ref = NULL; |
| 137 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | - $action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | - if ( $action_ref ) { |
|
| 137 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref; |
|
| 138 | + $action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref; |
|
| 139 | + if ($action_ref) { |
|
| 140 | 140 | |
| 141 | 141 | EE_Error::doing_it_wrong( |
| 142 | 142 | $action_ref, |
| 143 | 143 | sprintf( |
| 144 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ), |
|
| 144 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'), |
|
| 145 | 145 | '<br />', |
| 146 | 146 | '/core/business/EE_Transaction_Processor.class.php', |
| 147 | 147 | 'AHEE__EE_Transaction_Processor__finalize', |
@@ -151,39 +151,39 @@ discard block |
||
| 151 | 151 | ), |
| 152 | 152 | '4.6.0' |
| 153 | 153 | ); |
| 154 | - switch ( $action_ref ) { |
|
| 154 | + switch ($action_ref) { |
|
| 155 | 155 | case 'AHEE__EE_Transaction__finalize__new_transaction' : |
| 156 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request ); |
|
| 156 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request); |
|
| 157 | 157 | break; |
| 158 | 158 | case 'AHEE__EE_Transaction__finalize__all_transaction' : |
| 159 | - do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request ); |
|
| 159 | + do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request); |
|
| 160 | 160 | break; |
| 161 | 161 | } |
| 162 | 162 | } |
| 163 | 163 | } |
| 164 | -add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 ); |
|
| 164 | +add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2); |
|
| 165 | 165 | /** |
| 166 | 166 | * ee_deprecated_finalize_registration |
| 167 | 167 | * |
| 168 | 168 | * @param EE_Registration $registration |
| 169 | 169 | */ |
| 170 | -function ee_deprecated_finalize_registration( EE_Registration $registration ) { |
|
| 171 | - $action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | - if ( $action_ref ) { |
|
| 170 | +function ee_deprecated_finalize_registration(EE_Registration $registration) { |
|
| 171 | + $action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL; |
|
| 172 | + if ($action_ref) { |
|
| 173 | 173 | EE_Error::doing_it_wrong( |
| 174 | 174 | $action_ref, |
| 175 | 175 | sprintf( |
| 176 | - __( 'This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ), |
|
| 176 | + __('This action is deprecated. It *may* work as an attempt to build in backwards compatibility. However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'), |
|
| 177 | 177 | '<br />', |
| 178 | 178 | '/core/business/EE_Registration_Processor.class.php', |
| 179 | 179 | 'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook' |
| 180 | 180 | ), |
| 181 | 181 | '4.6.0' |
| 182 | 182 | ); |
| 183 | - do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ))); |
|
| 183 | + do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX))); |
|
| 184 | 184 | } |
| 185 | 185 | } |
| 186 | -add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 ); |
|
| 186 | +add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1); |
|
| 187 | 187 | |
| 188 | 188 | |
| 189 | 189 | |
@@ -191,7 +191,7 @@ discard block |
||
| 191 | 191 | * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called. |
| 192 | 192 | * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately. |
| 193 | 193 | */ |
| 194 | -function ee_deprecated_hooks(){ |
|
| 194 | +function ee_deprecated_hooks() { |
|
| 195 | 195 | /** |
| 196 | 196 | * @var $hooks array where keys are hook names, and their values are array{ |
| 197 | 197 | * @type string $version when deprecated |
@@ -202,25 +202,25 @@ discard block |
||
| 202 | 202 | $hooks = array( |
| 203 | 203 | 'AHEE__EE_System___do_setup_validations' => array( |
| 204 | 204 | 'version' => '4.6.0', |
| 205 | - 'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ), |
|
| 205 | + 'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'), |
|
| 206 | 206 | 'still_works' => FALSE |
| 207 | 207 | ) |
| 208 | 208 | ); |
| 209 | - foreach( $hooks as $name => $deprecation_info ){ |
|
| 210 | - if( has_action( $name ) ){ |
|
| 209 | + foreach ($hooks as $name => $deprecation_info) { |
|
| 210 | + if (has_action($name)) { |
|
| 211 | 211 | EE_Error::doing_it_wrong( |
| 212 | 212 | $name, |
| 213 | 213 | sprintf( |
| 214 | - __('This filter is deprecated. %1$s%2$s','event_espresso'), |
|
| 215 | - $deprecation_info[ 'still_works' ] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ), |
|
| 216 | - isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' ) |
|
| 214 | + __('This filter is deprecated. %1$s%2$s', 'event_espresso'), |
|
| 215 | + $deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'), |
|
| 216 | + isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso') |
|
| 217 | 217 | ), |
| 218 | - isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' ) |
|
| 218 | + isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso') |
|
| 219 | 219 | ); |
| 220 | 220 | } |
| 221 | 221 | } |
| 222 | 222 | } |
| 223 | -add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' ); |
|
| 223 | +add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks'); |
|
| 224 | 224 | |
| 225 | 225 | |
| 226 | 226 | |
@@ -231,9 +231,9 @@ discard block |
||
| 231 | 231 | * @return boolean |
| 232 | 232 | */ |
| 233 | 233 | function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() { |
| 234 | - $in_use = has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' ) |
|
| 235 | - || has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' ); |
|
| 236 | - if( $in_use ) { |
|
| 234 | + $in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns') |
|
| 235 | + || has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save'); |
|
| 236 | + if ($in_use) { |
|
| 237 | 237 | $msg = __( |
| 238 | 238 | 'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.' |
| 239 | 239 | . 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,' |
@@ -242,18 +242,18 @@ discard block |
||
| 242 | 242 | 'event_espresso' ) |
| 243 | 243 | ; |
| 244 | 244 | EE_Error::doing_it_wrong( |
| 245 | - __CLASS__ . '::' . __FUNCTION__, |
|
| 245 | + __CLASS__.'::'.__FUNCTION__, |
|
| 246 | 246 | $msg, |
| 247 | 247 | '4.8.32.rc.000' |
| 248 | 248 | ); |
| 249 | 249 | //it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed |
| 250 | - if ( is_admin() && ! defined( 'DOING_AJAX' ) ) { |
|
| 251 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 250 | + if (is_admin() && ! defined('DOING_AJAX')) { |
|
| 251 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 252 | 252 | } |
| 253 | 253 | } |
| 254 | 254 | return $in_use; |
| 255 | 255 | } |
| 256 | -add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' ); |
|
| 256 | +add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks'); |
|
| 257 | 257 | |
| 258 | 258 | /** |
| 259 | 259 | * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165 |
@@ -262,34 +262,34 @@ discard block |
||
| 262 | 262 | * @param EE_Admin_Page $admin_page |
| 263 | 263 | * @return void |
| 264 | 264 | */ |
| 265 | -function ee_deprecated_update_attendee_registration_form_old( $admin_page ) { |
|
| 265 | +function ee_deprecated_update_attendee_registration_form_old($admin_page) { |
|
| 266 | 266 | //check if the old hooks are in use. If not, do the default |
| 267 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 267 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 268 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 269 | 269 | return; |
| 270 | 270 | } |
| 271 | 271 | $req_data = $admin_page->get_request_data(); |
| 272 | - $qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE; |
|
| 273 | - $REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE; |
|
| 274 | - $qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns ); |
|
| 275 | - if ( ! $REG_ID || ! $qstns ) { |
|
| 276 | - EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ ); |
|
| 272 | + $qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE; |
|
| 273 | + $REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE; |
|
| 274 | + $qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns); |
|
| 275 | + if ( ! $REG_ID || ! $qstns) { |
|
| 276 | + EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__); |
|
| 277 | 277 | } |
| 278 | 278 | $success = TRUE; |
| 279 | 279 | |
| 280 | 280 | // allow others to get in on this awesome fun :D |
| 281 | - do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns ); |
|
| 281 | + do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns); |
|
| 282 | 282 | // loop thru questions... FINALLY!!! |
| 283 | 283 | |
| 284 | - foreach ( $qstns as $QST_ID => $qstn ) { |
|
| 284 | + foreach ($qstns as $QST_ID => $qstn) { |
|
| 285 | 285 | //if $qstn isn't an array then it doesn't already have an answer, so let's create the answer |
| 286 | - if ( !is_array($qstn) ) { |
|
| 287 | - $success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn); |
|
| 286 | + if ( ! is_array($qstn)) { |
|
| 287 | + $success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn); |
|
| 288 | 288 | continue; |
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | |
| 292 | - foreach ( $qstn as $ANS_ID => $ANS_value ) { |
|
| 292 | + foreach ($qstn as $ANS_ID => $ANS_value) { |
|
| 293 | 293 | //get answer |
| 294 | 294 | $query_params = array( |
| 295 | 295 | 0 => array( |
@@ -300,7 +300,7 @@ discard block |
||
| 300 | 300 | ); |
| 301 | 301 | $answer = EEM_Answer::instance()->get_one($query_params); |
| 302 | 302 | //this MAY be an array but NOT have an answer because its multi select. If so then we need to create the answer |
| 303 | - if ( ! $answer instanceof EE_Answer ) { |
|
| 303 | + if ( ! $answer instanceof EE_Answer) { |
|
| 304 | 304 | $set_values = array( |
| 305 | 305 | 'QST_ID' => $QST_ID, |
| 306 | 306 | 'REG_ID' => $REG_ID, |
@@ -315,11 +315,11 @@ discard block |
||
| 315 | 315 | } |
| 316 | 316 | } |
| 317 | 317 | $what = __('Registration Form', 'event_espresso'); |
| 318 | - $route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' ); |
|
| 319 | - $admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route ); |
|
| 318 | + $route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default'); |
|
| 319 | + $admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route); |
|
| 320 | 320 | exit; |
| 321 | 321 | } |
| 322 | -add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 ); |
|
| 322 | +add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1); |
|
| 323 | 323 | /** |
| 324 | 324 | * Render the registration admin page's custom questions area in the old fashion |
| 325 | 325 | * and firing the old hooks. When this method is removed, we can probably also |
@@ -332,31 +332,31 @@ discard block |
||
| 332 | 332 | * @return bool |
| 333 | 333 | * @throws \EE_Error |
| 334 | 334 | */ |
| 335 | -function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) { |
|
| 335 | +function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) { |
|
| 336 | 336 | //check if the old hooks are in use. If not, do the default |
| 337 | - if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | - || ! $admin_page instanceof EE_Admin_Page ) { |
|
| 337 | + if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() |
|
| 338 | + || ! $admin_page instanceof EE_Admin_Page) { |
|
| 339 | 339 | return $do_default_action; |
| 340 | 340 | } |
| 341 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 ); |
|
| 342 | - add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 ); |
|
| 343 | - add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 ); |
|
| 344 | - add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 ); |
|
| 341 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1); |
|
| 342 | + add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1); |
|
| 343 | + add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1); |
|
| 344 | + add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1); |
|
| 345 | 345 | |
| 346 | - $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') ); |
|
| 346 | + $question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID')); |
|
| 347 | 347 | |
| 348 | - EE_Registry::instance()->load_helper( 'Form_Fields' ); |
|
| 348 | + EE_Registry::instance()->load_helper('Form_Fields'); |
|
| 349 | 349 | $template_args = array( |
| 350 | - 'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ), |
|
| 350 | + 'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups), |
|
| 351 | 351 | 'reg_questions_form_action' => 'edit_registration', |
| 352 | 352 | 'REG_ID' => $registration->ID() |
| 353 | 353 | ); |
| 354 | - $template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | - echo EEH_Template::display_template( $template_path, $template_args, TRUE ); |
|
| 354 | + $template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php'; |
|
| 355 | + echo EEH_Template::display_template($template_path, $template_args, TRUE); |
|
| 356 | 356 | //indicate that we should not do the default admin page code |
| 357 | 357 | return false; |
| 358 | 358 | } |
| 359 | -add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 ); |
|
| 359 | +add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3); |
|
| 360 | 360 | |
| 361 | 361 | |
| 362 | 362 | |
@@ -397,9 +397,9 @@ discard block |
||
| 397 | 397 | '4.9.0' |
| 398 | 398 | ); |
| 399 | 399 | /** @var EE_Message_Resource_Manager $message_resource_manager */ |
| 400 | - $message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 401 | - $messenger = $message_resource_manager->get_messenger( $messenger_name ); |
|
| 402 | - $message_type = $message_resource_manager->get_message_type( $message_type_name ); |
|
| 400 | + $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 401 | + $messenger = $message_resource_manager->get_messenger($messenger_name); |
|
| 402 | + $message_type = $message_resource_manager->get_message_type($message_type_name); |
|
| 403 | 403 | return EE_Registry::instance()->load_lib( |
| 404 | 404 | 'Messages_Template_Defaults', |
| 405 | 405 | array( |
@@ -464,15 +464,15 @@ discard block |
||
| 464 | 464 | /** |
| 465 | 465 | * @param string $method |
| 466 | 466 | */ |
| 467 | - public function _class_is_deprecated( $method ) { |
|
| 467 | + public function _class_is_deprecated($method) { |
|
| 468 | 468 | EE_Error::doing_it_wrong( |
| 469 | - 'EE_messages::' . $method, |
|
| 470 | - __( 'EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.' ), |
|
| 469 | + 'EE_messages::'.$method, |
|
| 470 | + __('EE_messages has been deprecated. Please use EE_Message_Resource_Manager instead.'), |
|
| 471 | 471 | '4.9.0', |
| 472 | 472 | '4.10.0.p' |
| 473 | 473 | ); |
| 474 | 474 | // Please use EE_Message_Resource_Manager instead |
| 475 | - $this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' ); |
|
| 475 | + $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager'); |
|
| 476 | 476 | } |
| 477 | 477 | |
| 478 | 478 | |
@@ -482,10 +482,10 @@ discard block |
||
| 482 | 482 | * @param string $messenger_name |
| 483 | 483 | * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive |
| 484 | 484 | */ |
| 485 | - public function ensure_messenger_is_active( $messenger_name ) { |
|
| 485 | + public function ensure_messenger_is_active($messenger_name) { |
|
| 486 | 486 | // EE_messages has been deprecated |
| 487 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 488 | - return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name ); |
|
| 487 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 488 | + return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name); |
|
| 489 | 489 | } |
| 490 | 490 | |
| 491 | 491 | |
@@ -497,10 +497,10 @@ discard block |
||
| 497 | 497 | * @return bool true if it got activated (or was active) and false if not. |
| 498 | 498 | * @throws \EE_Error |
| 499 | 499 | */ |
| 500 | - public function ensure_message_type_is_active( $message_type, $messenger ) { |
|
| 500 | + public function ensure_message_type_is_active($message_type, $messenger) { |
|
| 501 | 501 | // EE_messages has been deprecated |
| 502 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 503 | - return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger ); |
|
| 502 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 503 | + return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger); |
|
| 504 | 504 | } |
| 505 | 505 | |
| 506 | 506 | |
@@ -513,10 +513,10 @@ discard block |
||
| 513 | 513 | * they are already setup.) |
| 514 | 514 | * @return boolean an array of generated templates or false if nothing generated/activated. |
| 515 | 515 | */ |
| 516 | - public function activate_messenger( $messenger_name, $mts_to_activate = array() ) { |
|
| 516 | + public function activate_messenger($messenger_name, $mts_to_activate = array()) { |
|
| 517 | 517 | // EE_messages has been deprecated |
| 518 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 519 | - return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate ); |
|
| 518 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 519 | + return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate); |
|
| 520 | 520 | } |
| 521 | 521 | |
| 522 | 522 | |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | * |
| 529 | 529 | * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send. |
| 530 | 530 | */ |
| 531 | - public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) { |
|
| 531 | + public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) { |
|
| 532 | 532 | // EE_messages has been deprecated |
| 533 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 534 | - return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type ); |
|
| 533 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 534 | + return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type); |
|
| 535 | 535 | } |
| 536 | 536 | |
| 537 | 537 | |
@@ -541,10 +541,10 @@ discard block |
||
| 541 | 541 | * @param string $messenger |
| 542 | 542 | * @return EE_messenger | null |
| 543 | 543 | */ |
| 544 | - public function get_messenger_if_active( $messenger ) { |
|
| 544 | + public function get_messenger_if_active($messenger) { |
|
| 545 | 545 | // EE_messages has been deprecated |
| 546 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 547 | - return $this->_message_resource_manager->get_active_messenger( $messenger ); |
|
| 546 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 547 | + return $this->_message_resource_manager->get_active_messenger($messenger); |
|
| 548 | 548 | } |
| 549 | 549 | |
| 550 | 550 | |
@@ -565,9 +565,9 @@ discard block |
||
| 565 | 565 | * 'message_type' => null |
| 566 | 566 | * ) |
| 567 | 567 | */ |
| 568 | - public function validate_for_use( EE_Message $message ) { |
|
| 568 | + public function validate_for_use(EE_Message $message) { |
|
| 569 | 569 | // EE_messages has been deprecated |
| 570 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 570 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 571 | 571 | return array( |
| 572 | 572 | 'messenger' => $message->messenger_object(), |
| 573 | 573 | 'message_type' => $message->message_type_object(), |
@@ -595,41 +595,41 @@ discard block |
||
| 595 | 595 | $send = true |
| 596 | 596 | ) { |
| 597 | 597 | // EE_messages has been deprecated |
| 598 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 598 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 599 | 599 | /** @type EE_Messages_Processor $processor */ |
| 600 | - $processor = EE_Registry::instance()->load_lib( 'Messages_Processor' ); |
|
| 600 | + $processor = EE_Registry::instance()->load_lib('Messages_Processor'); |
|
| 601 | 601 | $error = false; |
| 602 | 602 | //try to intelligently determine what method we'll call based on the incoming data. |
| 603 | 603 | //if generating and sending are different then generate and send immediately. |
| 604 | - if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) { |
|
| 604 | + if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) { |
|
| 605 | 605 | //in the legacy system, when generating and sending were different, that means all the |
| 606 | 606 | //vars are already in the request object. So let's just use that. |
| 607 | 607 | try { |
| 608 | 608 | /** @type EE_Message_To_Generate_From_Request $mtg */ |
| 609 | - $mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' ); |
|
| 610 | - $processor->generate_and_send_now( $mtg ); |
|
| 611 | - } catch ( EE_Error $e ) { |
|
| 609 | + $mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request'); |
|
| 610 | + $processor->generate_and_send_now($mtg); |
|
| 611 | + } catch (EE_Error $e) { |
|
| 612 | 612 | $error_msg = __( |
| 613 | 613 | 'Please note that a system message failed to send due to a technical issue.', |
| 614 | 614 | 'event_espresso' |
| 615 | 615 | ); |
| 616 | 616 | // add specific message for developers if WP_DEBUG in on |
| 617 | - $error_msg .= '||' . $e->getMessage(); |
|
| 618 | - EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 617 | + $error_msg .= '||'.$e->getMessage(); |
|
| 618 | + EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 619 | 619 | $error = true; |
| 620 | 620 | } |
| 621 | 621 | } else { |
| 622 | - $processor->generate_for_all_active_messengers( $type, $vars, $send ); |
|
| 622 | + $processor->generate_for_all_active_messengers($type, $vars, $send); |
|
| 623 | 623 | //let's find out if there were any errors and how many successfully were queued. |
| 624 | 624 | $count_errors = $processor->get_queue()->count_STS_in_queue( |
| 625 | - array( EEM_Message::status_failed, EEM_Message::status_debug_only ) |
|
| 625 | + array(EEM_Message::status_failed, EEM_Message::status_debug_only) |
|
| 626 | 626 | ); |
| 627 | - $count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete ); |
|
| 628 | - $count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry ); |
|
| 627 | + $count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete); |
|
| 628 | + $count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry); |
|
| 629 | 629 | $count_errors = $count_errors + $count_retry; |
| 630 | - if ( $count_errors > 0 ) { |
|
| 630 | + if ($count_errors > 0) { |
|
| 631 | 631 | $error = true; |
| 632 | - if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) { |
|
| 632 | + if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) { |
|
| 633 | 633 | $message = sprintf( |
| 634 | 634 | __( |
| 635 | 635 | 'There were %d errors and %d messages successfully queued for generation and sending', |
@@ -638,7 +638,7 @@ discard block |
||
| 638 | 638 | $count_errors, |
| 639 | 639 | $count_queued |
| 640 | 640 | ); |
| 641 | - } elseif ( $count_errors > 1 && $count_queued === 1 ) { |
|
| 641 | + } elseif ($count_errors > 1 && $count_queued === 1) { |
|
| 642 | 642 | $message = sprintf( |
| 643 | 643 | __( |
| 644 | 644 | 'There were %d errors and %d message successfully queued for generation.', |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | $count_errors, |
| 648 | 648 | $count_queued |
| 649 | 649 | ); |
| 650 | - } elseif ( $count_errors === 1 && $count_queued > 1 ) { |
|
| 650 | + } elseif ($count_errors === 1 && $count_queued > 1) { |
|
| 651 | 651 | $message = sprintf( |
| 652 | 652 | __( |
| 653 | 653 | 'There was %d error and %d messages successfully queued for generation.', |
@@ -665,9 +665,9 @@ discard block |
||
| 665 | 665 | $count_errors |
| 666 | 666 | ); |
| 667 | 667 | } |
| 668 | - EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ ); |
|
| 668 | + EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__); |
|
| 669 | 669 | } else { |
| 670 | - if ( $count_queued === 1 ) { |
|
| 670 | + if ($count_queued === 1) { |
|
| 671 | 671 | $message = sprintf( |
| 672 | 672 | __( |
| 673 | 673 | '%d message successfully queued for generation.', |
@@ -684,18 +684,18 @@ discard block |
||
| 684 | 684 | $count_queued |
| 685 | 685 | ); |
| 686 | 686 | } |
| 687 | - EE_Error::add_success( $message ); |
|
| 687 | + EE_Error::add_success($message); |
|
| 688 | 688 | } |
| 689 | 689 | } |
| 690 | 690 | //if no error then return the generated message(s). |
| 691 | - if ( ! $error && ! $send ) { |
|
| 692 | - $generated_queue = $processor->generate_queue( false ); |
|
| 691 | + if ( ! $error && ! $send) { |
|
| 692 | + $generated_queue = $processor->generate_queue(false); |
|
| 693 | 693 | //get message and return. |
| 694 | 694 | $generated_queue->get_message_repository()->rewind(); |
| 695 | 695 | $messages = array(); |
| 696 | - while ( $generated_queue->get_message_repository()->valid() ) { |
|
| 696 | + while ($generated_queue->get_message_repository()->valid()) { |
|
| 697 | 697 | $message = $generated_queue->get_message_repository()->current(); |
| 698 | - if ( $message instanceof EE_Message ) { |
|
| 698 | + if ($message instanceof EE_Message) { |
|
| 699 | 699 | //set properties that might be expected by add-ons (backward compat) |
| 700 | 700 | $message->content = $message->content(); |
| 701 | 701 | $message->template_pack = $message->get_template_pack(); |
@@ -720,10 +720,10 @@ discard block |
||
| 720 | 720 | * @param bool $send true we will do a test send using the messenger delivery, false we just do a regular preview |
| 721 | 721 | * @return string The body of the message. |
| 722 | 722 | */ |
| 723 | - public function preview_message( $type, $context, $messenger, $send = false ) { |
|
| 723 | + public function preview_message($type, $context, $messenger, $send = false) { |
|
| 724 | 724 | // EE_messages has been deprecated |
| 725 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 726 | - return EED_Messages::preview_message( $type, $context, $messenger, $send ); |
|
| 725 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 726 | + return EED_Messages::preview_message($type, $context, $messenger, $send); |
|
| 727 | 727 | } |
| 728 | 728 | |
| 729 | 729 | |
@@ -737,14 +737,14 @@ discard block |
||
| 737 | 737 | * |
| 738 | 738 | * @return bool success or fail. |
| 739 | 739 | */ |
| 740 | - public function send_message_with_messenger_only( $messenger, $message_type, $message ) { |
|
| 740 | + public function send_message_with_messenger_only($messenger, $message_type, $message) { |
|
| 741 | 741 | // EE_messages has been deprecated |
| 742 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 742 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 743 | 743 | //setup for sending to new method. |
| 744 | 744 | /** @type EE_Messages_Queue $queue */ |
| 745 | - $queue = EE_Registry::instance()->load_lib( 'Messages_Queue' ); |
|
| 745 | + $queue = EE_Registry::instance()->load_lib('Messages_Queue'); |
|
| 746 | 746 | //make sure we have a proper message object |
| 747 | - if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) { |
|
| 747 | + if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) { |
|
| 748 | 748 | $msg = EE_Message_Factory::create( |
| 749 | 749 | array( |
| 750 | 750 | 'MSG_messenger' => $messenger, |
@@ -756,15 +756,15 @@ discard block |
||
| 756 | 756 | } else { |
| 757 | 757 | $msg = $message; |
| 758 | 758 | } |
| 759 | - if ( ! $msg instanceof EE_Message ) { |
|
| 759 | + if ( ! $msg instanceof EE_Message) { |
|
| 760 | 760 | return false; |
| 761 | 761 | } |
| 762 | 762 | //make sure any content in a content property (if not empty) is set on the MSG_content. |
| 763 | - if ( ! empty( $msg->content ) ) { |
|
| 764 | - $msg->set( 'MSG_content', $msg->content ); |
|
| 763 | + if ( ! empty($msg->content)) { |
|
| 764 | + $msg->set('MSG_content', $msg->content); |
|
| 765 | 765 | } |
| 766 | - $queue->add( $msg ); |
|
| 767 | - return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue ); |
|
| 766 | + $queue->add($msg); |
|
| 767 | + return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue); |
|
| 768 | 768 | } |
| 769 | 769 | |
| 770 | 770 | |
@@ -778,11 +778,11 @@ discard block |
||
| 778 | 778 | * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned. |
| 779 | 779 | * @throws \EE_Error |
| 780 | 780 | */ |
| 781 | - public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) { |
|
| 781 | + public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) { |
|
| 782 | 782 | // EE_messages has been deprecated |
| 783 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 784 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 785 | - return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global ); |
|
| 783 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 784 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 785 | + return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global); |
|
| 786 | 786 | } |
| 787 | 787 | |
| 788 | 788 | |
@@ -793,11 +793,11 @@ discard block |
||
| 793 | 793 | * @param string $message_type_name name of EE_message_type |
| 794 | 794 | * @return array |
| 795 | 795 | */ |
| 796 | - public function get_fields( $messenger_name, $message_type_name ) { |
|
| 796 | + public function get_fields($messenger_name, $message_type_name) { |
|
| 797 | 797 | // EE_messages has been deprecated |
| 798 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 799 | - EE_Registry::instance()->load_helper( 'MSG_Template' ); |
|
| 800 | - return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name ); |
|
| 798 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 799 | + EE_Registry::instance()->load_helper('MSG_Template'); |
|
| 800 | + return EEH_MSG_Template::get_fields($messenger_name, $message_type_name); |
|
| 801 | 801 | } |
| 802 | 802 | |
| 803 | 803 | |
@@ -811,13 +811,13 @@ discard block |
||
| 811 | 811 | * @return array multidimensional array of messenger and message_type objects |
| 812 | 812 | * (messengers index, and message_type index); |
| 813 | 813 | */ |
| 814 | - public function get_installed( $type = 'all', $skip_cache = false ) { |
|
| 814 | + public function get_installed($type = 'all', $skip_cache = false) { |
|
| 815 | 815 | // EE_messages has been deprecated |
| 816 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 817 | - if ( $skip_cache ) { |
|
| 816 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 817 | + if ($skip_cache) { |
|
| 818 | 818 | $this->_message_resource_manager->reset_active_messengers_and_message_types(); |
| 819 | 819 | } |
| 820 | - switch ( $type ) { |
|
| 820 | + switch ($type) { |
|
| 821 | 821 | case 'messengers' : |
| 822 | 822 | return array( |
| 823 | 823 | 'messenger' => $this->_message_resource_manager->installed_messengers(), |
@@ -846,7 +846,7 @@ discard block |
||
| 846 | 846 | */ |
| 847 | 847 | public function get_active_messengers() { |
| 848 | 848 | // EE_messages has been deprecated |
| 849 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 849 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 850 | 850 | return $this->_message_resource_manager->active_messengers(); |
| 851 | 851 | } |
| 852 | 852 | |
@@ -858,7 +858,7 @@ discard block |
||
| 858 | 858 | */ |
| 859 | 859 | public function get_active_message_types() { |
| 860 | 860 | // EE_messages has been deprecated |
| 861 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 861 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 862 | 862 | return $this->_message_resource_manager->list_of_active_message_types(); |
| 863 | 863 | } |
| 864 | 864 | |
@@ -870,7 +870,7 @@ discard block |
||
| 870 | 870 | */ |
| 871 | 871 | public function get_active_message_type_objects() { |
| 872 | 872 | // EE_messages has been deprecated |
| 873 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 873 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 874 | 874 | return $this->_message_resource_manager->get_active_message_type_objects(); |
| 875 | 875 | } |
| 876 | 876 | |
@@ -882,10 +882,10 @@ discard block |
||
| 882 | 882 | * @param string $messenger The messenger being checked |
| 883 | 883 | * @return EE_message_type[] (or empty array if none present) |
| 884 | 884 | */ |
| 885 | - public function get_active_message_types_per_messenger( $messenger ) { |
|
| 885 | + public function get_active_message_types_per_messenger($messenger) { |
|
| 886 | 886 | // EE_messages has been deprecated |
| 887 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 888 | - return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger ); |
|
| 887 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 888 | + return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger); |
|
| 889 | 889 | } |
| 890 | 890 | |
| 891 | 891 | |
@@ -896,10 +896,10 @@ discard block |
||
| 896 | 896 | * @param string $message_type The string should correspond to a message type. |
| 897 | 897 | * @return EE_message_type|null |
| 898 | 898 | */ |
| 899 | - public function get_active_message_type( $messenger, $message_type ) { |
|
| 899 | + public function get_active_message_type($messenger, $message_type) { |
|
| 900 | 900 | // EE_messages has been deprecated |
| 901 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 902 | - return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type ); |
|
| 901 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 902 | + return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type); |
|
| 903 | 903 | } |
| 904 | 904 | |
| 905 | 905 | |
@@ -910,7 +910,7 @@ discard block |
||
| 910 | 910 | */ |
| 911 | 911 | public function get_installed_message_types() { |
| 912 | 912 | // EE_messages has been deprecated |
| 913 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 913 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 914 | 914 | return $this->_message_resource_manager->installed_message_types(); |
| 915 | 915 | } |
| 916 | 916 | |
@@ -922,7 +922,7 @@ discard block |
||
| 922 | 922 | */ |
| 923 | 923 | public function get_installed_messengers() { |
| 924 | 924 | // EE_messages has been deprecated |
| 925 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 925 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 926 | 926 | return $this->_message_resource_manager->installed_messengers(); |
| 927 | 927 | } |
| 928 | 928 | |
@@ -933,10 +933,10 @@ discard block |
||
| 933 | 933 | * @param bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type. |
| 934 | 934 | * @return array |
| 935 | 935 | */ |
| 936 | - public function get_all_contexts( $slugs_only = true ) { |
|
| 936 | + public function get_all_contexts($slugs_only = true) { |
|
| 937 | 937 | // EE_messages has been deprecated |
| 938 | - $this->_class_is_deprecated( __FUNCTION__ ); |
|
| 939 | - return $this->_message_resource_manager->get_all_contexts( $slugs_only ); |
|
| 938 | + $this->_class_is_deprecated(__FUNCTION__); |
|
| 939 | + return $this->_message_resource_manager->get_all_contexts($slugs_only); |
|
| 940 | 940 | } |
| 941 | 941 | |
| 942 | 942 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | add_filter( |
| 996 | 996 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css', |
| 997 | 997 | function($event_list_iframe_css) { |
| 998 | - if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) { |
|
| 998 | + if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) { |
|
| 999 | 999 | return $event_list_iframe_css; |
| 1000 | 1000 | } |
| 1001 | 1001 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | add_filter( |
| 1016 | 1016 | 'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js', |
| 1017 | 1017 | function($event_list_iframe_js) { |
| 1018 | - if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) { |
|
| 1018 | + if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) { |
|
| 1019 | 1019 | return $event_list_iframe_js; |
| 1020 | 1020 | } |
| 1021 | 1021 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1035,7 +1035,7 @@ discard block |
||
| 1035 | 1035 | add_action( |
| 1036 | 1036 | 'AHEE__EE_Capabilities__addCaps__complete', |
| 1037 | 1037 | function($capabilities_map) { |
| 1038 | - if ( ! has_action( 'AHEE__EE_Capabilities__init_role_caps__complete' )) { |
|
| 1038 | + if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) { |
|
| 1039 | 1039 | return; |
| 1040 | 1040 | } |
| 1041 | 1041 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1055,7 +1055,7 @@ discard block |
||
| 1055 | 1055 | add_filter( |
| 1056 | 1056 | 'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee', |
| 1057 | 1057 | function($existing_attendee, $registration, $attendee_data) { |
| 1058 | - if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) { |
|
| 1058 | + if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) { |
|
| 1059 | 1059 | return $existing_attendee; |
| 1060 | 1060 | } |
| 1061 | 1061 | deprecated_espresso_action_or_filter_doing_it_wrong( |
@@ -1071,7 +1071,7 @@ discard block |
||
| 1071 | 1071 | $existing_attendee, $registration, $attendee_data |
| 1072 | 1072 | ); |
| 1073 | 1073 | }, |
| 1074 | - 10,3 |
|
| 1074 | + 10, 3 |
|
| 1075 | 1075 | ); |
| 1076 | 1076 | |
| 1077 | 1077 | /** |
@@ -1135,7 +1135,7 @@ discard block |
||
| 1135 | 1135 | */ |
| 1136 | 1136 | public function event_list_title($event_list_title = '') |
| 1137 | 1137 | { |
| 1138 | - if (! empty($this->title)) { |
|
| 1138 | + if ( ! empty($this->title)) { |
|
| 1139 | 1139 | return $this->title; |
| 1140 | 1140 | } |
| 1141 | 1141 | return $event_list_title; |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : ''; |
| 477 | 477 | $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this)))); |
| 478 | 478 | global $ee_menu_slugs; |
| 479 | - $ee_menu_slugs = (array)$ee_menu_slugs; |
|
| 479 | + $ee_menu_slugs = (array) $ee_menu_slugs; |
|
| 480 | 480 | if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) { |
| 481 | 481 | return; |
| 482 | 482 | } |
@@ -491,7 +491,7 @@ discard block |
||
| 491 | 491 | //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be |
| 492 | 492 | $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action; |
| 493 | 493 | $this->_current_view = $this->_req_action; |
| 494 | - $this->_req_nonce = $this->_req_action . '_nonce'; |
|
| 494 | + $this->_req_nonce = $this->_req_action.'_nonce'; |
|
| 495 | 495 | $this->_define_page_props(); |
| 496 | 496 | $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url); |
| 497 | 497 | //default things |
@@ -512,11 +512,11 @@ discard block |
||
| 512 | 512 | $this->_extend_page_config_for_cpt(); |
| 513 | 513 | } |
| 514 | 514 | //filter routes and page_config so addons can add their stuff. Filtering done per class |
| 515 | - $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this); |
|
| 516 | - $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this); |
|
| 515 | + $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this); |
|
| 516 | + $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this); |
|
| 517 | 517 | //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action |
| 518 | - if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) { |
|
| 519 | - add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2); |
|
| 518 | + if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) { |
|
| 519 | + add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2); |
|
| 520 | 520 | } |
| 521 | 521 | //next route only if routing enabled |
| 522 | 522 | if ($this->_routing && ! defined('DOING_AJAX')) { |
@@ -526,8 +526,8 @@ discard block |
||
| 526 | 526 | if ($this->_is_UI_request) { |
| 527 | 527 | //admin_init stuff - global, all views for this page class, specific view |
| 528 | 528 | add_action('admin_init', array($this, 'admin_init'), 10); |
| 529 | - if (method_exists($this, 'admin_init_' . $this->_current_view)) { |
|
| 530 | - add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15); |
|
| 529 | + if (method_exists($this, 'admin_init_'.$this->_current_view)) { |
|
| 530 | + add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15); |
|
| 531 | 531 | } |
| 532 | 532 | } else { |
| 533 | 533 | //hijack regular WP loading and route admin request immediately |
@@ -547,17 +547,17 @@ discard block |
||
| 547 | 547 | */ |
| 548 | 548 | private function _do_other_page_hooks() |
| 549 | 549 | { |
| 550 | - $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array()); |
|
| 550 | + $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array()); |
|
| 551 | 551 | foreach ($registered_pages as $page) { |
| 552 | 552 | //now let's setup the file name and class that should be present |
| 553 | 553 | $classname = str_replace('.class.php', '', $page); |
| 554 | 554 | //autoloaders should take care of loading file |
| 555 | 555 | if ( ! class_exists($classname)) { |
| 556 | - $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
| 556 | + $error_msg[] = sprintf(esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page); |
|
| 557 | 557 | $error_msg[] = $error_msg[0] |
| 558 | 558 | . "\r\n" |
| 559 | - . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
| 560 | - 'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>'); |
|
| 559 | + . sprintf(esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class', |
|
| 560 | + 'event_espresso'), $page, '<br />', '<strong>'.$classname.'</strong>'); |
|
| 561 | 561 | throw new EE_Error(implode('||', $error_msg)); |
| 562 | 562 | } |
| 563 | 563 | $a = new ReflectionClass($classname); |
@@ -593,13 +593,13 @@ discard block |
||
| 593 | 593 | //load admin_notices - global, page class, and view specific |
| 594 | 594 | add_action('admin_notices', array($this, 'admin_notices_global'), 5); |
| 595 | 595 | add_action('admin_notices', array($this, 'admin_notices'), 10); |
| 596 | - if (method_exists($this, 'admin_notices_' . $this->_current_view)) { |
|
| 597 | - add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15); |
|
| 596 | + if (method_exists($this, 'admin_notices_'.$this->_current_view)) { |
|
| 597 | + add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15); |
|
| 598 | 598 | } |
| 599 | 599 | //load network admin_notices - global, page class, and view specific |
| 600 | 600 | add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5); |
| 601 | - if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) { |
|
| 602 | - add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view)); |
|
| 601 | + if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) { |
|
| 602 | + add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view)); |
|
| 603 | 603 | } |
| 604 | 604 | //this will save any per_page screen options if they are present |
| 605 | 605 | $this->_set_per_page_screen_options(); |
@@ -611,8 +611,8 @@ discard block |
||
| 611 | 611 | //add screen options - global, page child class, and view specific |
| 612 | 612 | $this->_add_global_screen_options(); |
| 613 | 613 | $this->_add_screen_options(); |
| 614 | - if (method_exists($this, '_add_screen_options_' . $this->_current_view)) { |
|
| 615 | - call_user_func(array($this, '_add_screen_options_' . $this->_current_view)); |
|
| 614 | + if (method_exists($this, '_add_screen_options_'.$this->_current_view)) { |
|
| 615 | + call_user_func(array($this, '_add_screen_options_'.$this->_current_view)); |
|
| 616 | 616 | } |
| 617 | 617 | //add help tab(s) and tours- set via page_config and qtips. |
| 618 | 618 | $this->_add_help_tour(); |
@@ -621,31 +621,31 @@ discard block |
||
| 621 | 621 | //add feature_pointers - global, page child class, and view specific |
| 622 | 622 | $this->_add_feature_pointers(); |
| 623 | 623 | $this->_add_global_feature_pointers(); |
| 624 | - if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) { |
|
| 625 | - call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view)); |
|
| 624 | + if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) { |
|
| 625 | + call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view)); |
|
| 626 | 626 | } |
| 627 | 627 | //enqueue scripts/styles - global, page class, and view specific |
| 628 | 628 | add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5); |
| 629 | 629 | add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10); |
| 630 | - if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) { |
|
| 631 | - add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15); |
|
| 630 | + if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) { |
|
| 631 | + add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15); |
|
| 632 | 632 | } |
| 633 | 633 | add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100); |
| 634 | 634 | //admin_print_footer_scripts - global, page child class, and view specific. NOTE, despite the name, whenever possible, scripts should NOT be loaded using this. In most cases that's doing_it_wrong(). But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these |
| 635 | 635 | add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99); |
| 636 | 636 | add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100); |
| 637 | - if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) { |
|
| 638 | - add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101); |
|
| 637 | + if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) { |
|
| 638 | + add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101); |
|
| 639 | 639 | } |
| 640 | 640 | //admin footer scripts |
| 641 | 641 | add_action('admin_footer', array($this, 'admin_footer_global'), 99); |
| 642 | 642 | add_action('admin_footer', array($this, 'admin_footer'), 100); |
| 643 | - if (method_exists($this, 'admin_footer_' . $this->_current_view)) { |
|
| 644 | - add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101); |
|
| 643 | + if (method_exists($this, 'admin_footer_'.$this->_current_view)) { |
|
| 644 | + add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101); |
|
| 645 | 645 | } |
| 646 | 646 | do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug); |
| 647 | 647 | //targeted hook |
| 648 | - do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action); |
|
| 648 | + do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action); |
|
| 649 | 649 | } |
| 650 | 650 | |
| 651 | 651 | |
@@ -721,7 +721,7 @@ discard block |
||
| 721 | 721 | // user error msg |
| 722 | 722 | $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
| 723 | 723 | // developer error msg |
| 724 | - $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
| 724 | + $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso'); |
|
| 725 | 725 | throw new EE_Error($error_msg); |
| 726 | 726 | } |
| 727 | 727 | // and that the requested page route exists |
@@ -732,7 +732,7 @@ discard block |
||
| 732 | 732 | // user error msg |
| 733 | 733 | $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
| 734 | 734 | // developer error msg |
| 735 | - $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
| 735 | + $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action); |
|
| 736 | 736 | throw new EE_Error($error_msg); |
| 737 | 737 | } |
| 738 | 738 | // and that a default route exists |
@@ -740,7 +740,7 @@ discard block |
||
| 740 | 740 | // user error msg |
| 741 | 741 | $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title); |
| 742 | 742 | // developer error msg |
| 743 | - $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
| 743 | + $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso'); |
|
| 744 | 744 | throw new EE_Error($error_msg); |
| 745 | 745 | } |
| 746 | 746 | //first lets' catch if the UI request has EVER been set. |
@@ -769,7 +769,7 @@ discard block |
||
| 769 | 769 | // user error msg |
| 770 | 770 | $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title); |
| 771 | 771 | // developer error msg |
| 772 | - $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
| 772 | + $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route); |
|
| 773 | 773 | throw new EE_Error($error_msg); |
| 774 | 774 | } |
| 775 | 775 | } |
@@ -791,7 +791,7 @@ discard block |
||
| 791 | 791 | // these are not the droids you are looking for !!! |
| 792 | 792 | $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>'); |
| 793 | 793 | if (WP_DEBUG) { |
| 794 | - $msg .= "\n " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
| 794 | + $msg .= "\n ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__); |
|
| 795 | 795 | } |
| 796 | 796 | if ( ! defined('DOING_AJAX')) { |
| 797 | 797 | wp_die($msg); |
@@ -969,7 +969,7 @@ discard block |
||
| 969 | 969 | if (strpos($key, 'nonce') !== false) { |
| 970 | 970 | continue; |
| 971 | 971 | } |
| 972 | - $args['wp_referer[' . $key . ']'] = $value; |
|
| 972 | + $args['wp_referer['.$key.']'] = $value; |
|
| 973 | 973 | } |
| 974 | 974 | } |
| 975 | 975 | return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce); |
@@ -1015,7 +1015,7 @@ discard block |
||
| 1015 | 1015 | if ($tour instanceof EE_Help_Tour_final_stop) { |
| 1016 | 1016 | continue; |
| 1017 | 1017 | } |
| 1018 | - $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>'; |
|
| 1018 | + $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>'; |
|
| 1019 | 1019 | } |
| 1020 | 1020 | $tour_buttons .= implode('<br />', $tb); |
| 1021 | 1021 | $tour_buttons .= '</div></div>'; |
@@ -1027,7 +1027,7 @@ discard block |
||
| 1027 | 1027 | throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option. However the callback given (%s) is not a valid callback. Doublecheck the spelling and make sure this method exists for the class %s', |
| 1028 | 1028 | 'event_espresso'), $config['help_sidebar'], get_class($this))); |
| 1029 | 1029 | } |
| 1030 | - $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
| 1030 | + $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar']))); |
|
| 1031 | 1031 | $content .= $tour_buttons; //add help tour buttons. |
| 1032 | 1032 | //do we have any help tours setup? Cause if we do we want to add the buttons |
| 1033 | 1033 | $this->_current_screen->set_help_sidebar($content); |
@@ -1040,13 +1040,13 @@ discard block |
||
| 1040 | 1040 | if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) { |
| 1041 | 1041 | $_ht['id'] = $this->page_slug; |
| 1042 | 1042 | $_ht['title'] = __('Help Tours', 'event_espresso'); |
| 1043 | - $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>'; |
|
| 1043 | + $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>'; |
|
| 1044 | 1044 | $this->_current_screen->add_help_tab($_ht); |
| 1045 | 1045 | }/**/ |
| 1046 | 1046 | if ( ! isset($config['help_tabs'])) { |
| 1047 | 1047 | return; |
| 1048 | 1048 | } //no help tabs for this route |
| 1049 | - foreach ((array)$config['help_tabs'] as $tab_id => $cfg) { |
|
| 1049 | + foreach ((array) $config['help_tabs'] as $tab_id => $cfg) { |
|
| 1050 | 1050 | //we're here so there ARE help tabs! |
| 1051 | 1051 | //make sure we've got what we need |
| 1052 | 1052 | if ( ! isset($cfg['title'])) { |
@@ -1061,9 +1061,9 @@ discard block |
||
| 1061 | 1061 | $content = ! empty($cfg['content']) ? $cfg['content'] : null; |
| 1062 | 1062 | //second priority goes to filename |
| 1063 | 1063 | } else if ( ! empty($cfg['filename'])) { |
| 1064 | - $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php'; |
|
| 1064 | + $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php'; |
|
| 1065 | 1065 | //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too) |
| 1066 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path; |
|
| 1066 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path; |
|
| 1067 | 1067 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
| 1068 | 1068 | if ( ! is_readable($file_path) && ! isset($cfg['callback'])) { |
| 1069 | 1069 | EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content. Please check that the string you set for the help tab on this route (%s) is the correct spelling. The file should be in %s', |
@@ -1082,7 +1082,7 @@ discard block |
||
| 1082 | 1082 | return; |
| 1083 | 1083 | } |
| 1084 | 1084 | //setup config array for help tab method |
| 1085 | - $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id; |
|
| 1085 | + $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id; |
|
| 1086 | 1086 | $_ht = array( |
| 1087 | 1087 | 'id' => $id, |
| 1088 | 1088 | 'title' => $cfg['title'], |
@@ -1120,9 +1120,9 @@ discard block |
||
| 1120 | 1120 | } |
| 1121 | 1121 | if (isset($config['help_tour'])) { |
| 1122 | 1122 | foreach ($config['help_tour'] as $tour) { |
| 1123 | - $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php'; |
|
| 1123 | + $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php'; |
|
| 1124 | 1124 | //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent |
| 1125 | - $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path; |
|
| 1125 | + $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path; |
|
| 1126 | 1126 | //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error. |
| 1127 | 1127 | if ( ! is_readable($file_path)) { |
| 1128 | 1128 | EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path. Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'), |
@@ -1132,7 +1132,7 @@ discard block |
||
| 1132 | 1132 | require_once $file_path; |
| 1133 | 1133 | if ( ! class_exists($tour)) { |
| 1134 | 1134 | $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour); |
| 1135 | - $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
| 1135 | + $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.', |
|
| 1136 | 1136 | 'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this)); |
| 1137 | 1137 | throw new EE_Error(implode('||', $error_msg)); |
| 1138 | 1138 | } |
@@ -1164,11 +1164,11 @@ discard block |
||
| 1164 | 1164 | protected function _add_qtips() |
| 1165 | 1165 | { |
| 1166 | 1166 | if (isset($this->_route_config['qtips'])) { |
| 1167 | - $qtips = (array)$this->_route_config['qtips']; |
|
| 1167 | + $qtips = (array) $this->_route_config['qtips']; |
|
| 1168 | 1168 | //load qtip loader |
| 1169 | 1169 | $path = array( |
| 1170 | - $this->_get_dir() . '/qtips/', |
|
| 1171 | - EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/', |
|
| 1170 | + $this->_get_dir().'/qtips/', |
|
| 1171 | + EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/', |
|
| 1172 | 1172 | ); |
| 1173 | 1173 | EEH_Qtip_Loader::instance()->register($qtips, $path); |
| 1174 | 1174 | } |
@@ -1198,11 +1198,11 @@ discard block |
||
| 1198 | 1198 | if ( ! $this->check_user_access($slug, true)) { |
| 1199 | 1199 | continue; |
| 1200 | 1200 | } //no nav tab becasue current user does not have access. |
| 1201 | - $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : ''; |
|
| 1201 | + $css_class = isset($config['css_class']) ? $config['css_class'].' ' : ''; |
|
| 1202 | 1202 | $this->_nav_tabs[$slug] = array( |
| 1203 | 1203 | 'url' => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url), |
| 1204 | 1204 | 'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)), |
| 1205 | - 'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class, |
|
| 1205 | + 'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class, |
|
| 1206 | 1206 | 'order' => isset($config['nav']['order']) ? $config['nav']['order'] : $i, |
| 1207 | 1207 | ); |
| 1208 | 1208 | $i++; |
@@ -1265,11 +1265,11 @@ discard block |
||
| 1265 | 1265 | $capability = empty($capability) ? 'manage_options' : $capability; |
| 1266 | 1266 | } |
| 1267 | 1267 | $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0; |
| 1268 | - if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
| 1268 | + if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) { |
|
| 1269 | 1269 | if ($verify_only) { |
| 1270 | 1270 | return false; |
| 1271 | 1271 | } else { |
| 1272 | - if ( is_user_logged_in() ) { |
|
| 1272 | + if (is_user_logged_in()) { |
|
| 1273 | 1273 | wp_die(__('You do not have access to this route.', 'event_espresso')); |
| 1274 | 1274 | } else { |
| 1275 | 1275 | return false; |
@@ -1361,7 +1361,7 @@ discard block |
||
| 1361 | 1361 | public function admin_footer_global() |
| 1362 | 1362 | { |
| 1363 | 1363 | //dialog container for dialog helper |
| 1364 | - $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n"; |
|
| 1364 | + $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n"; |
|
| 1365 | 1365 | $d_cont .= '<div class="ee-notices"></div>'; |
| 1366 | 1366 | $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>'; |
| 1367 | 1367 | $d_cont .= '</div>'; |
@@ -1371,7 +1371,7 @@ discard block |
||
| 1371 | 1371 | echo implode('<br />', $this->_help_tour[$this->_req_action]); |
| 1372 | 1372 | } |
| 1373 | 1373 | //current set timezone for timezone js |
| 1374 | - echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>'; |
|
| 1374 | + echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>'; |
|
| 1375 | 1375 | } |
| 1376 | 1376 | |
| 1377 | 1377 | |
@@ -1396,7 +1396,7 @@ discard block |
||
| 1396 | 1396 | { |
| 1397 | 1397 | $content = ''; |
| 1398 | 1398 | $help_array = empty($help_array) ? $this->_get_help_content() : $help_array; |
| 1399 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php'; |
|
| 1399 | + $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php'; |
|
| 1400 | 1400 | //loop through the array and setup content |
| 1401 | 1401 | foreach ($help_array as $trigger => $help) { |
| 1402 | 1402 | //make sure the array is setup properly |
@@ -1430,7 +1430,7 @@ discard block |
||
| 1430 | 1430 | private function _get_help_content() |
| 1431 | 1431 | { |
| 1432 | 1432 | //what is the method we're looking for? |
| 1433 | - $method_name = '_help_popup_content_' . $this->_req_action; |
|
| 1433 | + $method_name = '_help_popup_content_'.$this->_req_action; |
|
| 1434 | 1434 | //if method doesn't exist let's get out. |
| 1435 | 1435 | if ( ! method_exists($this, $method_name)) { |
| 1436 | 1436 | return array(); |
@@ -1474,8 +1474,8 @@ discard block |
||
| 1474 | 1474 | $help_content = $this->_set_help_popup_content($help_array, false); |
| 1475 | 1475 | } |
| 1476 | 1476 | //let's setup the trigger |
| 1477 | - $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
| 1478 | - $content = $content . $help_content; |
|
| 1477 | + $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>'; |
|
| 1478 | + $content = $content.$help_content; |
|
| 1479 | 1479 | if ($display) { |
| 1480 | 1480 | echo $content; |
| 1481 | 1481 | } else { |
@@ -1535,27 +1535,27 @@ discard block |
||
| 1535 | 1535 | add_action('admin_head', array($this, 'add_xdebug_style')); |
| 1536 | 1536 | } |
| 1537 | 1537 | // register all styles |
| 1538 | - wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1539 | - wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1538 | + wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1539 | + wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1540 | 1540 | //helpers styles |
| 1541 | - wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1541 | + wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION); |
|
| 1542 | 1542 | /** SCRIPTS **/ |
| 1543 | 1543 | //register all scripts |
| 1544 | - wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1545 | - wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
| 1546 | - wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
| 1544 | + wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1545 | + wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true); |
|
| 1546 | + wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true); |
|
| 1547 | 1547 | add_filter('FHEE_load_joyride', '__return_true'); |
| 1548 | 1548 | //script for sorting tables |
| 1549 | - wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1549 | + wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true); |
|
| 1550 | 1550 | //script for parsing uri's |
| 1551 | - wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1551 | + wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1552 | 1552 | //and parsing associative serialized form elements |
| 1553 | - wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1553 | + wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1554 | 1554 | //helpers scripts |
| 1555 | - wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1556 | - wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1557 | - wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
| 1558 | - wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
| 1555 | + wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true); |
|
| 1556 | + wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true); |
|
| 1557 | + wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true); |
|
| 1558 | + wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true); |
|
| 1559 | 1559 | //google charts |
| 1560 | 1560 | wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false); |
| 1561 | 1561 | // ENQUEUE ALL BASICS BY DEFAULT |
@@ -1579,7 +1579,7 @@ discard block |
||
| 1579 | 1579 | */ |
| 1580 | 1580 | if ( ! empty($this->_help_tour)) { |
| 1581 | 1581 | //register the js for kicking things off |
| 1582 | - wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
| 1582 | + wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true); |
|
| 1583 | 1583 | //setup tours for the js tour object |
| 1584 | 1584 | foreach ($this->_help_tour['tours'] as $tour) { |
| 1585 | 1585 | $tours[] = array( |
@@ -1674,17 +1674,17 @@ discard block |
||
| 1674 | 1674 | return; |
| 1675 | 1675 | } //not a list_table view so get out. |
| 1676 | 1676 | //list table functions are per view specific (because some admin pages might have more than one listtable!) |
| 1677 | - if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) { |
|
| 1677 | + if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) { |
|
| 1678 | 1678 | //user error msg |
| 1679 | 1679 | $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso'); |
| 1680 | 1680 | //developer error msg |
| 1681 | - $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
| 1682 | - $this->_req_action, '_set_list_table_views_' . $this->_req_action); |
|
| 1681 | + $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'), |
|
| 1682 | + $this->_req_action, '_set_list_table_views_'.$this->_req_action); |
|
| 1683 | 1683 | throw new EE_Error($error_msg); |
| 1684 | 1684 | } |
| 1685 | 1685 | //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally |
| 1686 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views); |
|
| 1687 | - $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views); |
|
| 1686 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views); |
|
| 1687 | + $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views); |
|
| 1688 | 1688 | $this->_views = apply_filters('FHEE_list_table_views', $this->_views); |
| 1689 | 1689 | $this->_set_list_table_view(); |
| 1690 | 1690 | $this->_set_list_table_object(); |
@@ -1759,7 +1759,7 @@ discard block |
||
| 1759 | 1759 | // check for current view |
| 1760 | 1760 | $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : ''; |
| 1761 | 1761 | $query_args['action'] = $this->_req_action; |
| 1762 | - $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
| 1762 | + $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
| 1763 | 1763 | $query_args['status'] = $view['slug']; |
| 1764 | 1764 | //merge any other arguments sent in. |
| 1765 | 1765 | if (isset($extra_query_args[$view['slug']])) { |
@@ -1797,14 +1797,14 @@ discard block |
||
| 1797 | 1797 | <select id="entries-per-page-slct" name="entries-per-page-slct">'; |
| 1798 | 1798 | foreach ($values as $value) { |
| 1799 | 1799 | if ($value < $max_entries) { |
| 1800 | - $selected = $value == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1800 | + $selected = $value == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
| 1801 | 1801 | $entries_per_page_dropdown .= ' |
| 1802 | - <option value="' . $value . '"' . $selected . '>' . $value . ' </option>'; |
|
| 1802 | + <option value="' . $value.'"'.$selected.'>'.$value.' </option>'; |
|
| 1803 | 1803 | } |
| 1804 | 1804 | } |
| 1805 | - $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : ''; |
|
| 1805 | + $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : ''; |
|
| 1806 | 1806 | $entries_per_page_dropdown .= ' |
| 1807 | - <option value="' . $max_entries . '"' . $selected . '>All </option>'; |
|
| 1807 | + <option value="' . $max_entries.'"'.$selected.'>All </option>'; |
|
| 1808 | 1808 | $entries_per_page_dropdown .= ' |
| 1809 | 1809 | </select> |
| 1810 | 1810 | entries |
@@ -1826,7 +1826,7 @@ discard block |
||
| 1826 | 1826 | public function _set_search_attributes() |
| 1827 | 1827 | { |
| 1828 | 1828 | $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label); |
| 1829 | - $this->_template_args['search']['callback'] = 'search_' . $this->page_slug; |
|
| 1829 | + $this->_template_args['search']['callback'] = 'search_'.$this->page_slug; |
|
| 1830 | 1830 | } |
| 1831 | 1831 | |
| 1832 | 1832 | /*** END LIST TABLE METHODS **/ |
@@ -1864,7 +1864,7 @@ discard block |
||
| 1864 | 1864 | // user error msg |
| 1865 | 1865 | $error_msg = __('An error occurred. The requested metabox could not be found.', 'event_espresso'); |
| 1866 | 1866 | // developer error msg |
| 1867 | - $error_msg .= '||' . sprintf( |
|
| 1867 | + $error_msg .= '||'.sprintf( |
|
| 1868 | 1868 | __( |
| 1869 | 1869 | 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.', |
| 1870 | 1870 | 'event_espresso' |
@@ -1894,15 +1894,15 @@ discard block |
||
| 1894 | 1894 | && is_array($this->_route_config['columns']) |
| 1895 | 1895 | && count($this->_route_config['columns']) === 2 |
| 1896 | 1896 | ) { |
| 1897 | - add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1])); |
|
| 1897 | + add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1])); |
|
| 1898 | 1898 | $this->_template_args['num_columns'] = $this->_route_config['columns'][0]; |
| 1899 | 1899 | $screen_id = $this->_current_screen->id; |
| 1900 | - $screen_columns = (int)get_user_option("screen_layout_$screen_id"); |
|
| 1900 | + $screen_columns = (int) get_user_option("screen_layout_$screen_id"); |
|
| 1901 | 1901 | $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1]; |
| 1902 | - $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns; |
|
| 1902 | + $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns; |
|
| 1903 | 1903 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
| 1904 | 1904 | $this->_template_args['screen'] = $this->_current_screen; |
| 1905 | - $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php'; |
|
| 1905 | + $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php'; |
|
| 1906 | 1906 | //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded. |
| 1907 | 1907 | $this->_route_config['has_metaboxes'] = true; |
| 1908 | 1908 | } |
@@ -1949,7 +1949,7 @@ discard block |
||
| 1949 | 1949 | */ |
| 1950 | 1950 | public function espresso_ratings_request() |
| 1951 | 1951 | { |
| 1952 | - $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php'; |
|
| 1952 | + $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php'; |
|
| 1953 | 1953 | EEH_Template::display_template($template_path, array()); |
| 1954 | 1954 | } |
| 1955 | 1955 | |
@@ -1957,18 +1957,18 @@ discard block |
||
| 1957 | 1957 | |
| 1958 | 1958 | public static function cached_rss_display($rss_id, $url) |
| 1959 | 1959 | { |
| 1960 | - $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading…') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>'; |
|
| 1960 | + $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading…').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>'; |
|
| 1961 | 1961 | $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX); |
| 1962 | - $pre = '<div class="espresso-rss-display">' . "\n\t"; |
|
| 1963 | - $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>'; |
|
| 1964 | - $post = '</div>' . "\n"; |
|
| 1965 | - $cache_key = 'ee_rss_' . md5($rss_id); |
|
| 1962 | + $pre = '<div class="espresso-rss-display">'."\n\t"; |
|
| 1963 | + $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>'; |
|
| 1964 | + $post = '</div>'."\n"; |
|
| 1965 | + $cache_key = 'ee_rss_'.md5($rss_id); |
|
| 1966 | 1966 | if (false != ($output = get_transient($cache_key))) { |
| 1967 | - echo $pre . $output . $post; |
|
| 1967 | + echo $pre.$output.$post; |
|
| 1968 | 1968 | return true; |
| 1969 | 1969 | } |
| 1970 | 1970 | if ( ! $doing_ajax) { |
| 1971 | - echo $pre . $loading . $post; |
|
| 1971 | + echo $pre.$loading.$post; |
|
| 1972 | 1972 | return false; |
| 1973 | 1973 | } |
| 1974 | 1974 | ob_start(); |
@@ -2027,7 +2027,7 @@ discard block |
||
| 2027 | 2027 | |
| 2028 | 2028 | public function espresso_sponsors_post_box() |
| 2029 | 2029 | { |
| 2030 | - $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
| 2030 | + $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php'; |
|
| 2031 | 2031 | EEH_Template::display_template($templatepath); |
| 2032 | 2032 | } |
| 2033 | 2033 | |
@@ -2035,7 +2035,7 @@ discard block |
||
| 2035 | 2035 | |
| 2036 | 2036 | private function _publish_post_box() |
| 2037 | 2037 | { |
| 2038 | - $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview'; |
|
| 2038 | + $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview'; |
|
| 2039 | 2039 | //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label. Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes) |
| 2040 | 2040 | if ( ! empty($this->_labels['publishbox'])) { |
| 2041 | 2041 | $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox']; |
@@ -2052,7 +2052,7 @@ discard block |
||
| 2052 | 2052 | { |
| 2053 | 2053 | //if we have extra content set let's add it in if not make sure its empty |
| 2054 | 2054 | $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : ''; |
| 2055 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php'; |
|
| 2055 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php'; |
|
| 2056 | 2056 | echo EEH_Template::display_template($template_path, $this->_template_args, true); |
| 2057 | 2057 | } |
| 2058 | 2058 | |
@@ -2221,7 +2221,7 @@ discard block |
||
| 2221 | 2221 | //if $create_func is true (default) then we automatically create the function for displaying the actual meta box. If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish) |
| 2222 | 2222 | $call_back_func = $create_func ? create_function('$post, $metabox', |
| 2223 | 2223 | 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback; |
| 2224 | - add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
| 2224 | + add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args); |
|
| 2225 | 2225 | } |
| 2226 | 2226 | |
| 2227 | 2227 | |
@@ -2302,9 +2302,9 @@ discard block |
||
| 2302 | 2302 | : 'espresso-default-admin'; |
| 2303 | 2303 | $template_path = $sidebar |
| 2304 | 2304 | ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php' |
| 2305 | - : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php'; |
|
| 2305 | + : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php'; |
|
| 2306 | 2306 | if (defined('DOING_AJAX') && DOING_AJAX) { |
| 2307 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2307 | + $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php'; |
|
| 2308 | 2308 | } |
| 2309 | 2309 | $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path; |
| 2310 | 2310 | $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : ''; |
@@ -2350,7 +2350,7 @@ discard block |
||
| 2350 | 2350 | true |
| 2351 | 2351 | ) |
| 2352 | 2352 | : $this->_template_args['preview_action_button']; |
| 2353 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php'; |
|
| 2353 | + $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php'; |
|
| 2354 | 2354 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
| 2355 | 2355 | $template_path, |
| 2356 | 2356 | $this->_template_args, |
@@ -2401,7 +2401,7 @@ discard block |
||
| 2401 | 2401 | //setup search attributes |
| 2402 | 2402 | $this->_set_search_attributes(); |
| 2403 | 2403 | $this->_template_args['current_page'] = $this->_wp_page_slug; |
| 2404 | - $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php'; |
|
| 2404 | + $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php'; |
|
| 2405 | 2405 | $this->_template_args['table_url'] = defined('DOING_AJAX') |
| 2406 | 2406 | ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url) |
| 2407 | 2407 | : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url); |
@@ -2411,29 +2411,29 @@ discard block |
||
| 2411 | 2411 | $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback(); |
| 2412 | 2412 | if ( ! empty($ajax_sorting_callback)) { |
| 2413 | 2413 | $sortable_list_table_form_fields = wp_nonce_field( |
| 2414 | - $ajax_sorting_callback . '_nonce', |
|
| 2415 | - $ajax_sorting_callback . '_nonce', |
|
| 2414 | + $ajax_sorting_callback.'_nonce', |
|
| 2415 | + $ajax_sorting_callback.'_nonce', |
|
| 2416 | 2416 | false, |
| 2417 | 2417 | false |
| 2418 | 2418 | ); |
| 2419 | 2419 | // $reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce'; |
| 2420 | 2420 | // $sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE ); |
| 2421 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />'; |
|
| 2422 | - $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />'; |
|
| 2421 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />'; |
|
| 2422 | + $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />'; |
|
| 2423 | 2423 | } else { |
| 2424 | 2424 | $sortable_list_table_form_fields = ''; |
| 2425 | 2425 | } |
| 2426 | 2426 | $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields; |
| 2427 | 2427 | $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : ''; |
| 2428 | - $nonce_ref = $this->_req_action . '_nonce'; |
|
| 2429 | - $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">'; |
|
| 2428 | + $nonce_ref = $this->_req_action.'_nonce'; |
|
| 2429 | + $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">'; |
|
| 2430 | 2430 | $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields; |
| 2431 | 2431 | //display message about search results? |
| 2432 | 2432 | $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s']) |
| 2433 | - ? '<p class="ee-search-results">' . sprintf( |
|
| 2433 | + ? '<p class="ee-search-results">'.sprintf( |
|
| 2434 | 2434 | esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'), |
| 2435 | 2435 | trim($this->_req_data['s'], '%') |
| 2436 | - ) . '</p>' |
|
| 2436 | + ).'</p>' |
|
| 2437 | 2437 | : ''; |
| 2438 | 2438 | // filter before_list_table template arg |
| 2439 | 2439 | $this->_template_args['before_list_table'] = apply_filters( |
@@ -2507,8 +2507,8 @@ discard block |
||
| 2507 | 2507 | */ |
| 2508 | 2508 | protected function _display_legend($items) |
| 2509 | 2509 | { |
| 2510 | - $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this); |
|
| 2511 | - $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php'; |
|
| 2510 | + $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this); |
|
| 2511 | + $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php'; |
|
| 2512 | 2512 | return EEH_Template::display_template($legend_template, $this->_template_args, true); |
| 2513 | 2513 | } |
| 2514 | 2514 | |
@@ -2600,13 +2600,13 @@ discard block |
||
| 2600 | 2600 | $this->_nav_tabs = $this->_get_main_nav_tabs(); |
| 2601 | 2601 | $this->_template_args['nav_tabs'] = $this->_nav_tabs; |
| 2602 | 2602 | $this->_template_args['admin_page_title'] = $this->_admin_page_title; |
| 2603 | - $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view, |
|
| 2603 | + $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view, |
|
| 2604 | 2604 | isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : ''); |
| 2605 | - $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view, |
|
| 2605 | + $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view, |
|
| 2606 | 2606 | isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : ''); |
| 2607 | 2607 | $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content(); |
| 2608 | 2608 | // load settings page wrapper template |
| 2609 | - $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php'; |
|
| 2609 | + $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php'; |
|
| 2610 | 2610 | //about page? |
| 2611 | 2611 | $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path; |
| 2612 | 2612 | if (defined('DOING_AJAX')) { |
@@ -2680,20 +2680,20 @@ discard block |
||
| 2680 | 2680 | protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null) |
| 2681 | 2681 | { |
| 2682 | 2682 | //make sure $text and $actions are in an array |
| 2683 | - $text = (array)$text; |
|
| 2684 | - $actions = (array)$actions; |
|
| 2683 | + $text = (array) $text; |
|
| 2684 | + $actions = (array) $actions; |
|
| 2685 | 2685 | $referrer_url = empty($referrer) ? '' : $referrer; |
| 2686 | - $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />' |
|
| 2687 | - : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />'; |
|
| 2686 | + $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />' |
|
| 2687 | + : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />'; |
|
| 2688 | 2688 | $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso')); |
| 2689 | 2689 | $default_names = array('save', 'save_and_close'); |
| 2690 | 2690 | //add in a hidden index for the current page (so save and close redirects properly) |
| 2691 | 2691 | $this->_template_args['save_buttons'] = $referrer_url; |
| 2692 | 2692 | foreach ($button_text as $key => $button) { |
| 2693 | 2693 | $ref = $default_names[$key]; |
| 2694 | - $id = $this->_current_view . '_' . $ref; |
|
| 2694 | + $id = $this->_current_view.'_'.$ref; |
|
| 2695 | 2695 | $name = ! empty($actions) ? $actions[$key] : $ref; |
| 2696 | - $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />'; |
|
| 2696 | + $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />'; |
|
| 2697 | 2697 | if ( ! $both) { |
| 2698 | 2698 | break; |
| 2699 | 2699 | } |
@@ -2729,15 +2729,15 @@ discard block |
||
| 2729 | 2729 | { |
| 2730 | 2730 | if (empty($route)) { |
| 2731 | 2731 | $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso'); |
| 2732 | - $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
| 2733 | - EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2732 | + $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__); |
|
| 2733 | + EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 2734 | 2734 | } |
| 2735 | 2735 | // open form |
| 2736 | - $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >'; |
|
| 2736 | + $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >'; |
|
| 2737 | 2737 | // add nonce |
| 2738 | - $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false); |
|
| 2738 | + $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false); |
|
| 2739 | 2739 | // $nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE ); |
| 2740 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce; |
|
| 2740 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce; |
|
| 2741 | 2741 | // add REQUIRED form action |
| 2742 | 2742 | $hidden_fields = array( |
| 2743 | 2743 | 'action' => array('type' => 'hidden', 'value' => $route), |
@@ -2747,8 +2747,8 @@ discard block |
||
| 2747 | 2747 | // generate form fields |
| 2748 | 2748 | $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array'); |
| 2749 | 2749 | // add fields to form |
| 2750 | - foreach ((array)$form_fields as $field_name => $form_field) { |
|
| 2751 | - $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field']; |
|
| 2750 | + foreach ((array) $form_fields as $field_name => $form_field) { |
|
| 2751 | + $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field']; |
|
| 2752 | 2752 | } |
| 2753 | 2753 | // close form |
| 2754 | 2754 | $this->_template_args['after_admin_page_content'] = '</form>'; |
@@ -2829,7 +2829,7 @@ discard block |
||
| 2829 | 2829 | * @param array $query_args The original query_args array coming into the |
| 2830 | 2830 | * method. |
| 2831 | 2831 | */ |
| 2832 | - do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args); |
|
| 2832 | + do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args); |
|
| 2833 | 2833 | //calculate where we're going (if we have a "save and close" button pushed) |
| 2834 | 2834 | if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) { |
| 2835 | 2835 | // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce |
@@ -2845,7 +2845,7 @@ discard block |
||
| 2845 | 2845 | foreach ($this->_default_route_query_args as $query_param => $query_value) { |
| 2846 | 2846 | //is there a wp_referer array in our _default_route_query_args property? |
| 2847 | 2847 | if ($query_param == 'wp_referer') { |
| 2848 | - $query_value = (array)$query_value; |
|
| 2848 | + $query_value = (array) $query_value; |
|
| 2849 | 2849 | foreach ($query_value as $reference => $value) { |
| 2850 | 2850 | if (strpos($reference, 'nonce') !== false) { |
| 2851 | 2851 | continue; |
@@ -2871,11 +2871,11 @@ discard block |
||
| 2871 | 2871 | // if redirecting to anything other than the main page, add a nonce |
| 2872 | 2872 | if (isset($query_args['action'])) { |
| 2873 | 2873 | // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars |
| 2874 | - $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce'); |
|
| 2874 | + $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce'); |
|
| 2875 | 2875 | } |
| 2876 | 2876 | //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that). |
| 2877 | - do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args); |
|
| 2878 | - $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
| 2877 | + do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args); |
|
| 2878 | + $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args); |
|
| 2879 | 2879 | // check if we're doing ajax. If we are then lets just return the results and js can handle how it wants. |
| 2880 | 2880 | if (defined('DOING_AJAX')) { |
| 2881 | 2881 | $default_data = array( |
@@ -3005,7 +3005,7 @@ discard block |
||
| 3005 | 3005 | $args = array( |
| 3006 | 3006 | 'label' => $this->_admin_page_title, |
| 3007 | 3007 | 'default' => 10, |
| 3008 | - 'option' => $this->_current_page . '_' . $this->_current_view . '_per_page', |
|
| 3008 | + 'option' => $this->_current_page.'_'.$this->_current_view.'_per_page', |
|
| 3009 | 3009 | ); |
| 3010 | 3010 | //ONLY add the screen option if the user has access to it. |
| 3011 | 3011 | if ($this->check_user_access($this->_current_view, true)) { |
@@ -3038,8 +3038,8 @@ discard block |
||
| 3038 | 3038 | $map_option = $option; |
| 3039 | 3039 | $option = str_replace('-', '_', $option); |
| 3040 | 3040 | switch ($map_option) { |
| 3041 | - case $this->_current_page . '_' . $this->_current_view . '_per_page': |
|
| 3042 | - $value = (int)$value; |
|
| 3041 | + case $this->_current_page.'_'.$this->_current_view.'_per_page': |
|
| 3042 | + $value = (int) $value; |
|
| 3043 | 3043 | if ($value < 1 || $value > 999) { |
| 3044 | 3044 | return; |
| 3045 | 3045 | } |
@@ -3066,7 +3066,7 @@ discard block |
||
| 3066 | 3066 | */ |
| 3067 | 3067 | public function set_template_args($data) |
| 3068 | 3068 | { |
| 3069 | - $this->_template_args = array_merge($this->_template_args, (array)$data); |
|
| 3069 | + $this->_template_args = array_merge($this->_template_args, (array) $data); |
|
| 3070 | 3070 | } |
| 3071 | 3071 | |
| 3072 | 3072 | |
@@ -3088,12 +3088,12 @@ discard block |
||
| 3088 | 3088 | $this->_verify_route($route); |
| 3089 | 3089 | } |
| 3090 | 3090 | //now let's set the string for what kind of transient we're setting |
| 3091 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3091 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
| 3092 | 3092 | $data = $notices ? array('notices' => $data) : $data; |
| 3093 | 3093 | //is there already a transient for this route? If there is then let's ADD to that transient |
| 3094 | 3094 | $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
| 3095 | 3095 | if ($existing) { |
| 3096 | - $data = array_merge((array)$data, (array)$existing); |
|
| 3096 | + $data = array_merge((array) $data, (array) $existing); |
|
| 3097 | 3097 | } |
| 3098 | 3098 | if (is_multisite() && is_network_admin()) { |
| 3099 | 3099 | set_site_transient($transient, $data, 8); |
@@ -3114,7 +3114,7 @@ discard block |
||
| 3114 | 3114 | { |
| 3115 | 3115 | $user_id = get_current_user_id(); |
| 3116 | 3116 | $route = ! $route ? $this->_req_action : $route; |
| 3117 | - $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id; |
|
| 3117 | + $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id; |
|
| 3118 | 3118 | $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient); |
| 3119 | 3119 | //delete transient after retrieval (just in case it hasn't expired); |
| 3120 | 3120 | if (is_multisite() && is_network_admin()) { |
@@ -3355,7 +3355,7 @@ discard block |
||
| 3355 | 3355 | */ |
| 3356 | 3356 | protected function _next_link($url, $class = 'dashicons dashicons-arrow-right') |
| 3357 | 3357 | { |
| 3358 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3358 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
| 3359 | 3359 | } |
| 3360 | 3360 | |
| 3361 | 3361 | |
@@ -3369,7 +3369,7 @@ discard block |
||
| 3369 | 3369 | */ |
| 3370 | 3370 | protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left') |
| 3371 | 3371 | { |
| 3372 | - return '<a class="' . $class . '" href="' . $url . '"></a>'; |
|
| 3372 | + return '<a class="'.$class.'" href="'.$url.'"></a>'; |
|
| 3373 | 3373 | } |
| 3374 | 3374 | |
| 3375 | 3375 | |