@@ -1,7 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | use EventEspresso\core\domain\entities\notifications\PersistentAdminNotice; |
| 4 | -use EventEspresso\core\domain\services\admin\ExitModal; |
|
| 5 | 4 | use EventEspresso\core\exceptions\InvalidDataTypeException; |
| 6 | 5 | use EventEspresso\core\exceptions\InvalidInterfaceException; |
| 7 | 6 | use EventEspresso\core\interfaces\InterminableInterface; |
@@ -21,482 +21,482 @@ discard block |
||
| 21 | 21 | final class EE_Admin implements InterminableInterface |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var EE_Admin $_instance |
|
| 26 | - */ |
|
| 27 | - private static $_instance; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
| 31 | - */ |
|
| 32 | - private $persistent_admin_notice_manager; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var LoaderInterface |
|
| 36 | - */ |
|
| 37 | - protected $loader; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var RequestInterface $request |
|
| 41 | - */ |
|
| 42 | - protected $request; |
|
| 43 | - |
|
| 44 | - |
|
| 45 | - /** |
|
| 46 | - * @singleton method used to instantiate class object |
|
| 47 | - * @return EE_Admin |
|
| 48 | - */ |
|
| 49 | - public static function instance() |
|
| 50 | - { |
|
| 51 | - // check if class object is instantiated |
|
| 52 | - if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
| 53 | - EE_Admin::$_instance = new EE_Admin(); |
|
| 54 | - } |
|
| 55 | - return EE_Admin::$_instance; |
|
| 56 | - } |
|
| 57 | - |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @return EE_Admin |
|
| 61 | - */ |
|
| 62 | - public static function reset() |
|
| 63 | - { |
|
| 64 | - EE_Admin::$_instance = null; |
|
| 65 | - return EE_Admin::instance(); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * class constructor |
|
| 71 | - * |
|
| 72 | - * @throws EE_Error |
|
| 73 | - * @throws InvalidDataTypeException |
|
| 74 | - * @throws InvalidInterfaceException |
|
| 75 | - * @throws InvalidArgumentException |
|
| 76 | - */ |
|
| 77 | - protected function __construct() |
|
| 78 | - { |
|
| 79 | - /** @var EventEspresso\core\services\request\Request $request */ |
|
| 80 | - $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\Request'); |
|
| 81 | - // define global EE_Admin constants |
|
| 82 | - $this->_define_all_constants(); |
|
| 83 | - // set autoloaders for our admin page classes based on included path information |
|
| 84 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
| 85 | - // reset Environment config (we only do this on admin page loads); |
|
| 86 | - EE_Registry::instance()->CFG->environment->recheck_values(); |
|
| 87 | - // load EE_Request_Handler early |
|
| 88 | - add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
| 89 | - add_action('admin_init', array($this, 'admin_init'), 100); |
|
| 90 | - add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 91 | - add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 92 | - add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
| 93 | - if (! $this->request->isAjax()) { |
|
| 94 | - // admin hooks |
|
| 95 | - add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
|
| 96 | - add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
|
| 97 | - add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']); |
|
| 98 | - add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2); |
|
| 99 | - add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2); |
|
| 100 | - } |
|
| 101 | - do_action('AHEE__EE_Admin__loaded'); |
|
| 102 | - } |
|
| 103 | - |
|
| 104 | - |
|
| 105 | - /** |
|
| 106 | - * _define_all_constants |
|
| 107 | - * define constants that are set globally for all admin pages |
|
| 108 | - * |
|
| 109 | - * @return void |
|
| 110 | - */ |
|
| 111 | - private function _define_all_constants() |
|
| 112 | - { |
|
| 113 | - if (! defined('EE_ADMIN_URL')) { |
|
| 114 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
| 115 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
| 116 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
| 117 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
| 118 | - define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - |
|
| 122 | - |
|
| 123 | - /** |
|
| 124 | - * filter_plugin_actions - adds links to the Plugins page listing |
|
| 125 | - * |
|
| 126 | - * @param array $links |
|
| 127 | - * @param string $plugin |
|
| 128 | - * @return array |
|
| 129 | - */ |
|
| 130 | - public function filter_plugin_actions($links, $plugin) |
|
| 131 | - { |
|
| 132 | - // set $main_file in stone |
|
| 133 | - static $main_file; |
|
| 134 | - // if $main_file is not set yet |
|
| 135 | - if (! $main_file) { |
|
| 136 | - $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
| 137 | - } |
|
| 138 | - if ($plugin === $main_file) { |
|
| 139 | - // compare current plugin to this one |
|
| 140 | - if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 141 | - $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
| 142 | - . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
| 143 | - . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
| 144 | - . '</a>'; |
|
| 145 | - array_unshift($links, $maintenance_link); |
|
| 146 | - } else { |
|
| 147 | - $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
| 148 | - . esc_html__('Settings', 'event_espresso') |
|
| 149 | - . '</a>'; |
|
| 150 | - $events_link = '<a href="admin.php?page=espresso_events">' |
|
| 151 | - . esc_html__('Events', 'event_espresso') |
|
| 152 | - . '</a>'; |
|
| 153 | - // add before other links |
|
| 154 | - array_unshift($links, $org_settings_link, $events_link); |
|
| 155 | - } |
|
| 156 | - } |
|
| 157 | - return $links; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - |
|
| 161 | - /** |
|
| 162 | - * hide_admin_pages_except_maintenance_mode |
|
| 163 | - * |
|
| 164 | - * @param array $admin_page_folder_names |
|
| 165 | - * @return array |
|
| 166 | - */ |
|
| 167 | - public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
| 168 | - { |
|
| 169 | - return array( |
|
| 170 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
| 171 | - 'about' => EE_ADMIN_PAGES . 'about/', |
|
| 172 | - 'support' => EE_ADMIN_PAGES . 'support/', |
|
| 173 | - ); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
| 179 | - * EE_Front_Controller's init phases have run |
|
| 180 | - * |
|
| 181 | - * @return void |
|
| 182 | - * @throws EE_Error |
|
| 183 | - * @throws InvalidArgumentException |
|
| 184 | - * @throws InvalidDataTypeException |
|
| 185 | - * @throws InvalidInterfaceException |
|
| 186 | - * @throws ReflectionException |
|
| 187 | - * @throws ServiceNotFoundException |
|
| 188 | - */ |
|
| 189 | - public function init() |
|
| 190 | - { |
|
| 191 | - // only enable most of the EE_Admin IF we're not in full maintenance mode |
|
| 192 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 193 | - $this->initModelsReady(); |
|
| 194 | - } |
|
| 195 | - // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
| 196 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 197 | - try { |
|
| 198 | - // this loads the controller for the admin pages which will setup routing etc |
|
| 199 | - $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader'); |
|
| 200 | - $admin_page_loader->init(); |
|
| 201 | - } catch (EE_Error $e) { |
|
| 202 | - $e->get_error(); |
|
| 203 | - } |
|
| 204 | - } |
|
| 205 | - add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
| 206 | - if (! $this->request->isAjax()) { |
|
| 207 | - // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
| 208 | - add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10); |
|
| 209 | - add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10); |
|
| 210 | - // exclude EE critical pages from all nav menus and wp_list_pages |
|
| 211 | - add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10); |
|
| 212 | - } |
|
| 213 | - } |
|
| 214 | - |
|
| 215 | - |
|
| 216 | - /** |
|
| 217 | - * Gets the loader (and if it wasn't previously set, sets it) |
|
| 218 | - * @return LoaderInterface |
|
| 219 | - * @throws InvalidArgumentException |
|
| 220 | - * @throws InvalidDataTypeException |
|
| 221 | - * @throws InvalidInterfaceException |
|
| 222 | - */ |
|
| 223 | - protected function getLoader() |
|
| 224 | - { |
|
| 225 | - if (! $this->loader instanceof LoaderInterface) { |
|
| 226 | - $this->loader = LoaderFactory::getLoader(); |
|
| 227 | - } |
|
| 228 | - return $this->loader; |
|
| 229 | - } |
|
| 230 | - |
|
| 231 | - |
|
| 232 | - /** |
|
| 233 | - * Method that's fired on admin requests (including admin ajax) but only when the models are usable |
|
| 234 | - * (ie, the site isn't in maintenance mode) |
|
| 235 | - * |
|
| 236 | - * @return void |
|
| 237 | - * @throws EE_Error |
|
| 238 | - * @throws EE_Error |
|
| 239 | - * @since 4.9.63.p |
|
| 240 | - */ |
|
| 241 | - protected function initModelsReady() |
|
| 242 | - { |
|
| 243 | - // ok so we want to enable the entire admin |
|
| 244 | - $this->persistent_admin_notice_manager = $this->loader->getShared( |
|
| 245 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
| 246 | - ); |
|
| 247 | - $this->persistent_admin_notice_manager->setReturnUrl( |
|
| 248 | - EE_Admin_Page::add_query_args_and_nonce( |
|
| 249 | - array( |
|
| 250 | - 'page' => $this->request->getRequestParam('page', ''), |
|
| 251 | - 'action' => $this->request->getRequestParam('action', ''), |
|
| 252 | - ), |
|
| 253 | - EE_ADMIN_URL |
|
| 254 | - ) |
|
| 255 | - ); |
|
| 256 | - $this->maybeSetDatetimeWarningNotice(); |
|
| 257 | - // at a glance dashboard widget |
|
| 258 | - add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
| 259 | - // filter for get_edit_post_link used on comments for custom post types |
|
| 260 | - add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
| 261 | - } |
|
| 262 | - |
|
| 263 | - |
|
| 264 | - /** |
|
| 265 | - * get_persistent_admin_notices |
|
| 266 | - * |
|
| 267 | - * @access public |
|
| 268 | - * @return void |
|
| 269 | - * @throws EE_Error |
|
| 270 | - * @throws InvalidArgumentException |
|
| 271 | - * @throws InvalidDataTypeException |
|
| 272 | - * @throws InvalidInterfaceException |
|
| 273 | - */ |
|
| 274 | - public function maybeSetDatetimeWarningNotice() |
|
| 275 | - { |
|
| 276 | - // add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
| 277 | - // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
| 278 | - // with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
| 279 | - // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
| 280 | - if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
| 281 | - && ! get_option('timezone_string') |
|
| 282 | - && EEM_Event::instance()->count() > 0 |
|
| 283 | - ) { |
|
| 284 | - new PersistentAdminNotice( |
|
| 285 | - 'datetime_fix_notice', |
|
| 286 | - sprintf( |
|
| 287 | - esc_html__( |
|
| 288 | - '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
| 289 | - 'event_espresso' |
|
| 290 | - ), |
|
| 291 | - '<strong>', |
|
| 292 | - '</strong>', |
|
| 293 | - '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
| 294 | - '</a>', |
|
| 295 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 296 | - array( |
|
| 297 | - 'page' => 'espresso_maintenance_settings', |
|
| 298 | - 'action' => 'datetime_tools', |
|
| 299 | - ), |
|
| 300 | - admin_url('admin.php') |
|
| 301 | - ) . '">' |
|
| 302 | - ), |
|
| 303 | - false, |
|
| 304 | - 'manage_options', |
|
| 305 | - 'datetime_fix_persistent_notice' |
|
| 306 | - ); |
|
| 307 | - } |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
| 313 | - * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
| 314 | - * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
| 315 | - * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
| 316 | - * normal property on the post_type object. It's found ONLY in this particular context. |
|
| 317 | - * |
|
| 318 | - * @param WP_Post $post_type WP post type object |
|
| 319 | - * @return WP_Post |
|
| 320 | - * @throws InvalidArgumentException |
|
| 321 | - * @throws InvalidDataTypeException |
|
| 322 | - * @throws InvalidInterfaceException |
|
| 323 | - */ |
|
| 324 | - public function remove_pages_from_nav_menu($post_type) |
|
| 325 | - { |
|
| 326 | - // if this isn't the "pages" post type let's get out |
|
| 327 | - if ($post_type->name !== 'page') { |
|
| 328 | - return $post_type; |
|
| 329 | - } |
|
| 330 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 331 | - $post_type->_default_query = array( |
|
| 332 | - 'post__not_in' => $critical_pages, |
|
| 333 | - ); |
|
| 334 | - return $post_type; |
|
| 335 | - } |
|
| 336 | - |
|
| 337 | - |
|
| 338 | - /** |
|
| 339 | - * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
| 340 | - * metaboxes get shown as well |
|
| 341 | - * |
|
| 342 | - * @return void |
|
| 343 | - */ |
|
| 344 | - public function enable_hidden_ee_nav_menu_metaboxes() |
|
| 345 | - { |
|
| 346 | - global $wp_meta_boxes, $pagenow; |
|
| 347 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 348 | - return; |
|
| 349 | - } |
|
| 350 | - $user = wp_get_current_user(); |
|
| 351 | - // has this been done yet? |
|
| 352 | - if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
| 353 | - return; |
|
| 354 | - } |
|
| 355 | - |
|
| 356 | - $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
| 357 | - $initial_meta_boxes = apply_filters( |
|
| 358 | - 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
| 359 | - array( |
|
| 360 | - 'nav-menu-theme-locations', |
|
| 361 | - 'add-page', |
|
| 362 | - 'add-custom-links', |
|
| 363 | - 'add-category', |
|
| 364 | - 'add-espresso_events', |
|
| 365 | - 'add-espresso_venues', |
|
| 366 | - 'add-espresso_event_categories', |
|
| 367 | - 'add-espresso_venue_categories', |
|
| 368 | - 'add-post-type-post', |
|
| 369 | - 'add-post-type-page', |
|
| 370 | - ) |
|
| 371 | - ); |
|
| 372 | - |
|
| 373 | - if (is_array($hidden_meta_boxes)) { |
|
| 374 | - foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
| 375 | - if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
| 376 | - unset($hidden_meta_boxes[ $key ]); |
|
| 377 | - } |
|
| 378 | - } |
|
| 379 | - } |
|
| 380 | - update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 381 | - update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
| 382 | - } |
|
| 383 | - |
|
| 384 | - |
|
| 385 | - /** |
|
| 386 | - * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
| 387 | - * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
| 388 | - * |
|
| 389 | - * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
| 390 | - * addons etc. |
|
| 391 | - * @return void |
|
| 392 | - */ |
|
| 393 | - public function register_custom_nav_menu_boxes() |
|
| 394 | - { |
|
| 395 | - add_meta_box( |
|
| 396 | - 'add-extra-nav-menu-pages', |
|
| 397 | - esc_html__('Event Espresso Pages', 'event_espresso'), |
|
| 398 | - array($this, 'ee_cpt_archive_pages'), |
|
| 399 | - 'nav-menus', |
|
| 400 | - 'side', |
|
| 401 | - 'core' |
|
| 402 | - ); |
|
| 403 | - } |
|
| 404 | - |
|
| 405 | - |
|
| 406 | - /** |
|
| 407 | - * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
| 408 | - * |
|
| 409 | - * @since 4.3.0 |
|
| 410 | - * @param string $link the original link generated by wp |
|
| 411 | - * @param int $id post id |
|
| 412 | - * @return string the (maybe) modified link |
|
| 413 | - */ |
|
| 414 | - public function modify_edit_post_link($link, $id) |
|
| 415 | - { |
|
| 416 | - if (! $post = get_post($id)) { |
|
| 417 | - return $link; |
|
| 418 | - } |
|
| 419 | - if ($post->post_type === 'espresso_attendees') { |
|
| 420 | - $query_args = array( |
|
| 421 | - 'action' => 'edit_attendee', |
|
| 422 | - 'post' => $id, |
|
| 423 | - ); |
|
| 424 | - return EEH_URL::add_query_args_and_nonce( |
|
| 425 | - $query_args, |
|
| 426 | - admin_url('admin.php?page=espresso_registrations') |
|
| 427 | - ); |
|
| 428 | - } |
|
| 429 | - return $link; |
|
| 430 | - } |
|
| 431 | - |
|
| 432 | - |
|
| 433 | - public function ee_cpt_archive_pages() |
|
| 434 | - { |
|
| 435 | - global $nav_menu_selected_id; |
|
| 436 | - $db_fields = false; |
|
| 437 | - $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 438 | - $current_tab = 'event-archives'; |
|
| 439 | - $removed_args = array( |
|
| 440 | - 'action', |
|
| 441 | - 'customlink-tab', |
|
| 442 | - 'edit-menu-item', |
|
| 443 | - 'menu-item', |
|
| 444 | - 'page-tab', |
|
| 445 | - '_wpnonce', |
|
| 446 | - ); |
|
| 447 | - ?> |
|
| 24 | + /** |
|
| 25 | + * @var EE_Admin $_instance |
|
| 26 | + */ |
|
| 27 | + private static $_instance; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var PersistentAdminNoticeManager $persistent_admin_notice_manager |
|
| 31 | + */ |
|
| 32 | + private $persistent_admin_notice_manager; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var LoaderInterface |
|
| 36 | + */ |
|
| 37 | + protected $loader; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var RequestInterface $request |
|
| 41 | + */ |
|
| 42 | + protected $request; |
|
| 43 | + |
|
| 44 | + |
|
| 45 | + /** |
|
| 46 | + * @singleton method used to instantiate class object |
|
| 47 | + * @return EE_Admin |
|
| 48 | + */ |
|
| 49 | + public static function instance() |
|
| 50 | + { |
|
| 51 | + // check if class object is instantiated |
|
| 52 | + if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
| 53 | + EE_Admin::$_instance = new EE_Admin(); |
|
| 54 | + } |
|
| 55 | + return EE_Admin::$_instance; |
|
| 56 | + } |
|
| 57 | + |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @return EE_Admin |
|
| 61 | + */ |
|
| 62 | + public static function reset() |
|
| 63 | + { |
|
| 64 | + EE_Admin::$_instance = null; |
|
| 65 | + return EE_Admin::instance(); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * class constructor |
|
| 71 | + * |
|
| 72 | + * @throws EE_Error |
|
| 73 | + * @throws InvalidDataTypeException |
|
| 74 | + * @throws InvalidInterfaceException |
|
| 75 | + * @throws InvalidArgumentException |
|
| 76 | + */ |
|
| 77 | + protected function __construct() |
|
| 78 | + { |
|
| 79 | + /** @var EventEspresso\core\services\request\Request $request */ |
|
| 80 | + $this->request = $this->getLoader()->getShared('EventEspresso\core\services\request\Request'); |
|
| 81 | + // define global EE_Admin constants |
|
| 82 | + $this->_define_all_constants(); |
|
| 83 | + // set autoloaders for our admin page classes based on included path information |
|
| 84 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_ADMIN); |
|
| 85 | + // reset Environment config (we only do this on admin page loads); |
|
| 86 | + EE_Registry::instance()->CFG->environment->recheck_values(); |
|
| 87 | + // load EE_Request_Handler early |
|
| 88 | + add_action('AHEE__EE_System__initialize_last', array($this, 'init')); |
|
| 89 | + add_action('admin_init', array($this, 'admin_init'), 100); |
|
| 90 | + add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 91 | + add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
|
| 92 | + add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
|
| 93 | + if (! $this->request->isAjax()) { |
|
| 94 | + // admin hooks |
|
| 95 | + add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
|
| 96 | + add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
|
| 97 | + add_action('load-plugins.php', [$this, 'hookIntoWpPluginsPage']); |
|
| 98 | + add_action('display_post_states', [$this, 'displayStateForCriticalPages'], 10, 2); |
|
| 99 | + add_filter('plugin_row_meta', [$this, 'addLinksToPluginRowMeta'], 10, 2); |
|
| 100 | + } |
|
| 101 | + do_action('AHEE__EE_Admin__loaded'); |
|
| 102 | + } |
|
| 103 | + |
|
| 104 | + |
|
| 105 | + /** |
|
| 106 | + * _define_all_constants |
|
| 107 | + * define constants that are set globally for all admin pages |
|
| 108 | + * |
|
| 109 | + * @return void |
|
| 110 | + */ |
|
| 111 | + private function _define_all_constants() |
|
| 112 | + { |
|
| 113 | + if (! defined('EE_ADMIN_URL')) { |
|
| 114 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
| 115 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
| 116 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
| 117 | + define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
| 118 | + define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + |
|
| 122 | + |
|
| 123 | + /** |
|
| 124 | + * filter_plugin_actions - adds links to the Plugins page listing |
|
| 125 | + * |
|
| 126 | + * @param array $links |
|
| 127 | + * @param string $plugin |
|
| 128 | + * @return array |
|
| 129 | + */ |
|
| 130 | + public function filter_plugin_actions($links, $plugin) |
|
| 131 | + { |
|
| 132 | + // set $main_file in stone |
|
| 133 | + static $main_file; |
|
| 134 | + // if $main_file is not set yet |
|
| 135 | + if (! $main_file) { |
|
| 136 | + $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
|
| 137 | + } |
|
| 138 | + if ($plugin === $main_file) { |
|
| 139 | + // compare current plugin to this one |
|
| 140 | + if (EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 141 | + $maintenance_link = '<a href="admin.php?page=espresso_maintenance_settings"' |
|
| 142 | + . ' title="Event Espresso is in maintenance mode. Click this link to learn why.">' |
|
| 143 | + . esc_html__('Maintenance Mode Active', 'event_espresso') |
|
| 144 | + . '</a>'; |
|
| 145 | + array_unshift($links, $maintenance_link); |
|
| 146 | + } else { |
|
| 147 | + $org_settings_link = '<a href="admin.php?page=espresso_general_settings">' |
|
| 148 | + . esc_html__('Settings', 'event_espresso') |
|
| 149 | + . '</a>'; |
|
| 150 | + $events_link = '<a href="admin.php?page=espresso_events">' |
|
| 151 | + . esc_html__('Events', 'event_espresso') |
|
| 152 | + . '</a>'; |
|
| 153 | + // add before other links |
|
| 154 | + array_unshift($links, $org_settings_link, $events_link); |
|
| 155 | + } |
|
| 156 | + } |
|
| 157 | + return $links; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + |
|
| 161 | + /** |
|
| 162 | + * hide_admin_pages_except_maintenance_mode |
|
| 163 | + * |
|
| 164 | + * @param array $admin_page_folder_names |
|
| 165 | + * @return array |
|
| 166 | + */ |
|
| 167 | + public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
|
| 168 | + { |
|
| 169 | + return array( |
|
| 170 | + 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
| 171 | + 'about' => EE_ADMIN_PAGES . 'about/', |
|
| 172 | + 'support' => EE_ADMIN_PAGES . 'support/', |
|
| 173 | + ); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * init- should fire after shortcode, module, addon, other plugin (default priority), and even |
|
| 179 | + * EE_Front_Controller's init phases have run |
|
| 180 | + * |
|
| 181 | + * @return void |
|
| 182 | + * @throws EE_Error |
|
| 183 | + * @throws InvalidArgumentException |
|
| 184 | + * @throws InvalidDataTypeException |
|
| 185 | + * @throws InvalidInterfaceException |
|
| 186 | + * @throws ReflectionException |
|
| 187 | + * @throws ServiceNotFoundException |
|
| 188 | + */ |
|
| 189 | + public function init() |
|
| 190 | + { |
|
| 191 | + // only enable most of the EE_Admin IF we're not in full maintenance mode |
|
| 192 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 193 | + $this->initModelsReady(); |
|
| 194 | + } |
|
| 195 | + // run the admin page factory but ONLY if we are doing an ee admin ajax request |
|
| 196 | + if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 197 | + try { |
|
| 198 | + // this loads the controller for the admin pages which will setup routing etc |
|
| 199 | + $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader'); |
|
| 200 | + $admin_page_loader->init(); |
|
| 201 | + } catch (EE_Error $e) { |
|
| 202 | + $e->get_error(); |
|
| 203 | + } |
|
| 204 | + } |
|
| 205 | + add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
|
| 206 | + if (! $this->request->isAjax()) { |
|
| 207 | + // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
|
| 208 | + add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10); |
|
| 209 | + add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10); |
|
| 210 | + // exclude EE critical pages from all nav menus and wp_list_pages |
|
| 211 | + add_filter('nav_menu_meta_box_object', [$this, 'remove_pages_from_nav_menu'], 10); |
|
| 212 | + } |
|
| 213 | + } |
|
| 214 | + |
|
| 215 | + |
|
| 216 | + /** |
|
| 217 | + * Gets the loader (and if it wasn't previously set, sets it) |
|
| 218 | + * @return LoaderInterface |
|
| 219 | + * @throws InvalidArgumentException |
|
| 220 | + * @throws InvalidDataTypeException |
|
| 221 | + * @throws InvalidInterfaceException |
|
| 222 | + */ |
|
| 223 | + protected function getLoader() |
|
| 224 | + { |
|
| 225 | + if (! $this->loader instanceof LoaderInterface) { |
|
| 226 | + $this->loader = LoaderFactory::getLoader(); |
|
| 227 | + } |
|
| 228 | + return $this->loader; |
|
| 229 | + } |
|
| 230 | + |
|
| 231 | + |
|
| 232 | + /** |
|
| 233 | + * Method that's fired on admin requests (including admin ajax) but only when the models are usable |
|
| 234 | + * (ie, the site isn't in maintenance mode) |
|
| 235 | + * |
|
| 236 | + * @return void |
|
| 237 | + * @throws EE_Error |
|
| 238 | + * @throws EE_Error |
|
| 239 | + * @since 4.9.63.p |
|
| 240 | + */ |
|
| 241 | + protected function initModelsReady() |
|
| 242 | + { |
|
| 243 | + // ok so we want to enable the entire admin |
|
| 244 | + $this->persistent_admin_notice_manager = $this->loader->getShared( |
|
| 245 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
| 246 | + ); |
|
| 247 | + $this->persistent_admin_notice_manager->setReturnUrl( |
|
| 248 | + EE_Admin_Page::add_query_args_and_nonce( |
|
| 249 | + array( |
|
| 250 | + 'page' => $this->request->getRequestParam('page', ''), |
|
| 251 | + 'action' => $this->request->getRequestParam('action', ''), |
|
| 252 | + ), |
|
| 253 | + EE_ADMIN_URL |
|
| 254 | + ) |
|
| 255 | + ); |
|
| 256 | + $this->maybeSetDatetimeWarningNotice(); |
|
| 257 | + // at a glance dashboard widget |
|
| 258 | + add_filter('dashboard_glance_items', array($this, 'dashboard_glance_items'), 10); |
|
| 259 | + // filter for get_edit_post_link used on comments for custom post types |
|
| 260 | + add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 2); |
|
| 261 | + } |
|
| 262 | + |
|
| 263 | + |
|
| 264 | + /** |
|
| 265 | + * get_persistent_admin_notices |
|
| 266 | + * |
|
| 267 | + * @access public |
|
| 268 | + * @return void |
|
| 269 | + * @throws EE_Error |
|
| 270 | + * @throws InvalidArgumentException |
|
| 271 | + * @throws InvalidDataTypeException |
|
| 272 | + * @throws InvalidInterfaceException |
|
| 273 | + */ |
|
| 274 | + public function maybeSetDatetimeWarningNotice() |
|
| 275 | + { |
|
| 276 | + // add dismissable notice for datetime changes. Only valid if site does not have a timezone_string set. |
|
| 277 | + // @todo This needs to stay in core for a bit to catch anyone upgrading from a version without this to a version |
|
| 278 | + // with this. But after enough time (indeterminate at this point) we can just remove this notice. |
|
| 279 | + // this was added with https://events.codebasehq.com/projects/event-espresso/tickets/10626 |
|
| 280 | + if (apply_filters('FHEE__EE_Admin__maybeSetDatetimeWarningNotice', true) |
|
| 281 | + && ! get_option('timezone_string') |
|
| 282 | + && EEM_Event::instance()->count() > 0 |
|
| 283 | + ) { |
|
| 284 | + new PersistentAdminNotice( |
|
| 285 | + 'datetime_fix_notice', |
|
| 286 | + sprintf( |
|
| 287 | + esc_html__( |
|
| 288 | + '%1$sImportant announcement related to your install of Event Espresso%2$s: There are some changes made to your site that could affect how dates display for your events and other related items with dates and times. Read more about it %3$shere%4$s. If your dates and times are displaying incorrectly (incorrect offset), you can fix it using the tool on %5$sthis page%4$s.', |
|
| 289 | + 'event_espresso' |
|
| 290 | + ), |
|
| 291 | + '<strong>', |
|
| 292 | + '</strong>', |
|
| 293 | + '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
|
| 294 | + '</a>', |
|
| 295 | + '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 296 | + array( |
|
| 297 | + 'page' => 'espresso_maintenance_settings', |
|
| 298 | + 'action' => 'datetime_tools', |
|
| 299 | + ), |
|
| 300 | + admin_url('admin.php') |
|
| 301 | + ) . '">' |
|
| 302 | + ), |
|
| 303 | + false, |
|
| 304 | + 'manage_options', |
|
| 305 | + 'datetime_fix_persistent_notice' |
|
| 306 | + ); |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * this simply hooks into the nav menu setup of pages metabox and makes sure that we remove EE critical pages from |
|
| 313 | + * the list of options. the wp function "wp_nav_menu_item_post_type_meta_box" found in |
|
| 314 | + * wp-admin/includes/nav-menu.php looks for the "_default_query" property on the post_type object and it uses that |
|
| 315 | + * to override any queries found in the existing query for the given post type. Note that _default_query is not a |
|
| 316 | + * normal property on the post_type object. It's found ONLY in this particular context. |
|
| 317 | + * |
|
| 318 | + * @param WP_Post $post_type WP post type object |
|
| 319 | + * @return WP_Post |
|
| 320 | + * @throws InvalidArgumentException |
|
| 321 | + * @throws InvalidDataTypeException |
|
| 322 | + * @throws InvalidInterfaceException |
|
| 323 | + */ |
|
| 324 | + public function remove_pages_from_nav_menu($post_type) |
|
| 325 | + { |
|
| 326 | + // if this isn't the "pages" post type let's get out |
|
| 327 | + if ($post_type->name !== 'page') { |
|
| 328 | + return $post_type; |
|
| 329 | + } |
|
| 330 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 331 | + $post_type->_default_query = array( |
|
| 332 | + 'post__not_in' => $critical_pages, |
|
| 333 | + ); |
|
| 334 | + return $post_type; |
|
| 335 | + } |
|
| 336 | + |
|
| 337 | + |
|
| 338 | + /** |
|
| 339 | + * WP by default only shows three metaboxes in "nav-menus.php" for first times users. We want to make sure our |
|
| 340 | + * metaboxes get shown as well |
|
| 341 | + * |
|
| 342 | + * @return void |
|
| 343 | + */ |
|
| 344 | + public function enable_hidden_ee_nav_menu_metaboxes() |
|
| 345 | + { |
|
| 346 | + global $wp_meta_boxes, $pagenow; |
|
| 347 | + if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 348 | + return; |
|
| 349 | + } |
|
| 350 | + $user = wp_get_current_user(); |
|
| 351 | + // has this been done yet? |
|
| 352 | + if (get_user_option('ee_nav_menu_initialized', $user->ID)) { |
|
| 353 | + return; |
|
| 354 | + } |
|
| 355 | + |
|
| 356 | + $hidden_meta_boxes = get_user_option('metaboxhidden_nav-menus', $user->ID); |
|
| 357 | + $initial_meta_boxes = apply_filters( |
|
| 358 | + 'FHEE__EE_Admin__enable_hidden_ee_nav_menu_boxes__initial_meta_boxes', |
|
| 359 | + array( |
|
| 360 | + 'nav-menu-theme-locations', |
|
| 361 | + 'add-page', |
|
| 362 | + 'add-custom-links', |
|
| 363 | + 'add-category', |
|
| 364 | + 'add-espresso_events', |
|
| 365 | + 'add-espresso_venues', |
|
| 366 | + 'add-espresso_event_categories', |
|
| 367 | + 'add-espresso_venue_categories', |
|
| 368 | + 'add-post-type-post', |
|
| 369 | + 'add-post-type-page', |
|
| 370 | + ) |
|
| 371 | + ); |
|
| 372 | + |
|
| 373 | + if (is_array($hidden_meta_boxes)) { |
|
| 374 | + foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
|
| 375 | + if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
|
| 376 | + unset($hidden_meta_boxes[ $key ]); |
|
| 377 | + } |
|
| 378 | + } |
|
| 379 | + } |
|
| 380 | + update_user_option($user->ID, 'metaboxhidden_nav-menus', $hidden_meta_boxes, true); |
|
| 381 | + update_user_option($user->ID, 'ee_nav_menu_initialized', 1, true); |
|
| 382 | + } |
|
| 383 | + |
|
| 384 | + |
|
| 385 | + /** |
|
| 386 | + * This method simply registers custom nav menu boxes for "nav_menus.php route" |
|
| 387 | + * Currently EE is using this to make sure there are menu options for our CPT archive page routes. |
|
| 388 | + * |
|
| 389 | + * @todo modify this so its more dynamic and automatic for all ee CPTs and setups and can also be hooked into by |
|
| 390 | + * addons etc. |
|
| 391 | + * @return void |
|
| 392 | + */ |
|
| 393 | + public function register_custom_nav_menu_boxes() |
|
| 394 | + { |
|
| 395 | + add_meta_box( |
|
| 396 | + 'add-extra-nav-menu-pages', |
|
| 397 | + esc_html__('Event Espresso Pages', 'event_espresso'), |
|
| 398 | + array($this, 'ee_cpt_archive_pages'), |
|
| 399 | + 'nav-menus', |
|
| 400 | + 'side', |
|
| 401 | + 'core' |
|
| 402 | + ); |
|
| 403 | + } |
|
| 404 | + |
|
| 405 | + |
|
| 406 | + /** |
|
| 407 | + * Use this to edit the post link for our cpts so that the edit link points to the correct page. |
|
| 408 | + * |
|
| 409 | + * @since 4.3.0 |
|
| 410 | + * @param string $link the original link generated by wp |
|
| 411 | + * @param int $id post id |
|
| 412 | + * @return string the (maybe) modified link |
|
| 413 | + */ |
|
| 414 | + public function modify_edit_post_link($link, $id) |
|
| 415 | + { |
|
| 416 | + if (! $post = get_post($id)) { |
|
| 417 | + return $link; |
|
| 418 | + } |
|
| 419 | + if ($post->post_type === 'espresso_attendees') { |
|
| 420 | + $query_args = array( |
|
| 421 | + 'action' => 'edit_attendee', |
|
| 422 | + 'post' => $id, |
|
| 423 | + ); |
|
| 424 | + return EEH_URL::add_query_args_and_nonce( |
|
| 425 | + $query_args, |
|
| 426 | + admin_url('admin.php?page=espresso_registrations') |
|
| 427 | + ); |
|
| 428 | + } |
|
| 429 | + return $link; |
|
| 430 | + } |
|
| 431 | + |
|
| 432 | + |
|
| 433 | + public function ee_cpt_archive_pages() |
|
| 434 | + { |
|
| 435 | + global $nav_menu_selected_id; |
|
| 436 | + $db_fields = false; |
|
| 437 | + $walker = new Walker_Nav_Menu_Checklist($db_fields); |
|
| 438 | + $current_tab = 'event-archives'; |
|
| 439 | + $removed_args = array( |
|
| 440 | + 'action', |
|
| 441 | + 'customlink-tab', |
|
| 442 | + 'edit-menu-item', |
|
| 443 | + 'menu-item', |
|
| 444 | + 'page-tab', |
|
| 445 | + '_wpnonce', |
|
| 446 | + ); |
|
| 447 | + ?> |
|
| 448 | 448 | <div id="posttype-extra-nav-menu-pages" class="posttypediv"> |
| 449 | 449 | <ul id="posttype-extra-nav-menu-pages-tabs" class="posttype-tabs add-menu-item-tabs"> |
| 450 | 450 | <li <?php echo('event-archives' === $current_tab ? ' class="tabs"' : ''); ?>> |
| 451 | 451 | <a class="nav-tab-link" data-type="tabs-panel-posttype-extra-nav-menu-pages-event-archives" |
| 452 | 452 | href="<?php |
| 453 | - if ($nav_menu_selected_id) { |
|
| 454 | - echo esc_url( |
|
| 455 | - add_query_arg( |
|
| 456 | - 'extra-nav-menu-pages-tab', |
|
| 457 | - 'event-archives', |
|
| 458 | - remove_query_arg($removed_args) |
|
| 459 | - ) |
|
| 460 | - ); |
|
| 461 | - } |
|
| 462 | - ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
| 453 | + if ($nav_menu_selected_id) { |
|
| 454 | + echo esc_url( |
|
| 455 | + add_query_arg( |
|
| 456 | + 'extra-nav-menu-pages-tab', |
|
| 457 | + 'event-archives', |
|
| 458 | + remove_query_arg($removed_args) |
|
| 459 | + ) |
|
| 460 | + ); |
|
| 461 | + } |
|
| 462 | + ?>#tabs-panel-posttype-extra-nav-menu-pages-event-archives"> |
|
| 463 | 463 | <?php esc_html_e('Event Archive Pages', 'event_espresso'); ?> |
| 464 | 464 | </a> |
| 465 | 465 | </li> |
| 466 | 466 | </ul><!-- .posttype-tabs --> |
| 467 | 467 | |
| 468 | 468 | <div id="tabs-panel-posttype-extra-nav-menu-pages-event-archives" class="tabs-panel <?php |
| 469 | - echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 470 | - ?>"> |
|
| 469 | + echo('event-archives' === $current_tab ? 'tabs-panel-active' : 'tabs-panel-inactive'); |
|
| 470 | + ?>"> |
|
| 471 | 471 | <ul id="extra-nav-menu-pageschecklist-event-archives" class="categorychecklist form-no-clear"> |
| 472 | 472 | <?php |
| 473 | - $pages = $this->_get_extra_nav_menu_pages_items(); |
|
| 474 | - $args['walker'] = $walker; |
|
| 475 | - echo walk_nav_menu_tree( |
|
| 476 | - array_map( |
|
| 477 | - array($this, '_setup_extra_nav_menu_pages_items'), |
|
| 478 | - $pages |
|
| 479 | - ), |
|
| 480 | - 0, |
|
| 481 | - (object) $args |
|
| 482 | - ); |
|
| 483 | - ?> |
|
| 473 | + $pages = $this->_get_extra_nav_menu_pages_items(); |
|
| 474 | + $args['walker'] = $walker; |
|
| 475 | + echo walk_nav_menu_tree( |
|
| 476 | + array_map( |
|
| 477 | + array($this, '_setup_extra_nav_menu_pages_items'), |
|
| 478 | + $pages |
|
| 479 | + ), |
|
| 480 | + 0, |
|
| 481 | + (object) $args |
|
| 482 | + ); |
|
| 483 | + ?> |
|
| 484 | 484 | </ul> |
| 485 | 485 | </div><!-- /.tabs-panel --> |
| 486 | 486 | |
| 487 | 487 | <p class="button-controls"> |
| 488 | 488 | <span class="list-controls"> |
| 489 | 489 | <a href="<?php |
| 490 | - echo esc_url( |
|
| 491 | - add_query_arg( |
|
| 492 | - array( |
|
| 493 | - 'extra-nav-menu-pages-tab' => 'event-archives', |
|
| 494 | - 'selectall' => 1, |
|
| 495 | - ), |
|
| 496 | - remove_query_arg($removed_args) |
|
| 497 | - ) |
|
| 498 | - ); |
|
| 499 | - ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a> |
|
| 490 | + echo esc_url( |
|
| 491 | + add_query_arg( |
|
| 492 | + array( |
|
| 493 | + 'extra-nav-menu-pages-tab' => 'event-archives', |
|
| 494 | + 'selectall' => 1, |
|
| 495 | + ), |
|
| 496 | + remove_query_arg($removed_args) |
|
| 497 | + ) |
|
| 498 | + ); |
|
| 499 | + ?>#posttype-extra-nav-menu-pages" class="select-all"><?php esc_html_e('Select All', 'event_espresso'); ?></a> |
|
| 500 | 500 | </span> |
| 501 | 501 | <span class="add-to-menu"> |
| 502 | 502 | <input type="submit"<?php wp_nav_menu_disabled_check($nav_menu_selected_id); ?> |
@@ -509,529 +509,529 @@ discard block |
||
| 509 | 509 | |
| 510 | 510 | </div><!-- /.posttypediv --> |
| 511 | 511 | <?php |
| 512 | - } |
|
| 513 | - |
|
| 514 | - |
|
| 515 | - /** |
|
| 516 | - * Returns an array of event archive nav items. |
|
| 517 | - * |
|
| 518 | - * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
| 519 | - * method we use for getting the extra nav menu items |
|
| 520 | - * @return array |
|
| 521 | - */ |
|
| 522 | - private function _get_extra_nav_menu_pages_items() |
|
| 523 | - { |
|
| 524 | - $menuitems[] = array( |
|
| 525 | - 'title' => esc_html__('Event List', 'event_espresso'), |
|
| 526 | - 'url' => get_post_type_archive_link('espresso_events'), |
|
| 527 | - 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
| 528 | - ); |
|
| 529 | - return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
| 530 | - } |
|
| 531 | - |
|
| 532 | - |
|
| 533 | - /** |
|
| 534 | - * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
| 535 | - * the properties and converts it to the menu item object. |
|
| 536 | - * |
|
| 537 | - * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
| 538 | - * @param $menu_item_values |
|
| 539 | - * @return stdClass |
|
| 540 | - */ |
|
| 541 | - private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
| 542 | - { |
|
| 543 | - $menu_item = new stdClass(); |
|
| 544 | - $keys = array( |
|
| 545 | - 'ID' => 0, |
|
| 546 | - 'db_id' => 0, |
|
| 547 | - 'menu_item_parent' => 0, |
|
| 548 | - 'object_id' => -1, |
|
| 549 | - 'post_parent' => 0, |
|
| 550 | - 'type' => 'custom', |
|
| 551 | - 'object' => '', |
|
| 552 | - 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
| 553 | - 'title' => '', |
|
| 554 | - 'url' => '', |
|
| 555 | - 'target' => '', |
|
| 556 | - 'attr_title' => '', |
|
| 557 | - 'description' => '', |
|
| 558 | - 'classes' => array(), |
|
| 559 | - 'xfn' => '', |
|
| 560 | - ); |
|
| 561 | - |
|
| 562 | - foreach ($keys as $key => $value) { |
|
| 563 | - $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; |
|
| 564 | - } |
|
| 565 | - return $menu_item; |
|
| 566 | - } |
|
| 567 | - |
|
| 568 | - |
|
| 569 | - /** |
|
| 570 | - * admin_init |
|
| 571 | - * |
|
| 572 | - * @return void |
|
| 573 | - * @throws InvalidArgumentException |
|
| 574 | - * @throws InvalidDataTypeException |
|
| 575 | - * @throws InvalidInterfaceException |
|
| 576 | - */ |
|
| 577 | - public function admin_init() |
|
| 578 | - { |
|
| 579 | - /** |
|
| 580 | - * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
| 581 | - * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
| 582 | - * - check if doing post processing. |
|
| 583 | - * - check if doing post processing of one of EE CPTs |
|
| 584 | - * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
| 585 | - */ |
|
| 586 | - if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
| 587 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
| 588 | - $custom_post_types = $this->loader->getShared( |
|
| 589 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
| 590 | - ); |
|
| 591 | - $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
|
| 592 | - } |
|
| 593 | - |
|
| 594 | - if (! $this->request->isAjax()) { |
|
| 595 | - /** |
|
| 596 | - * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
| 597 | - * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
| 598 | - * Pages" tab in the EE General Settings Admin page. |
|
| 599 | - * This is for user-proofing. |
|
| 600 | - */ |
|
| 601 | - add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
| 602 | - if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 603 | - $this->adminInitModelsReady(); |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - } |
|
| 607 | - |
|
| 608 | - |
|
| 609 | - /** |
|
| 610 | - * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode) |
|
| 611 | - */ |
|
| 612 | - protected function adminInitModelsReady() |
|
| 613 | - { |
|
| 614 | - if (function_exists('wp_add_privacy_policy_content')) { |
|
| 615 | - $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); |
|
| 616 | - } |
|
| 617 | - } |
|
| 618 | - |
|
| 619 | - |
|
| 620 | - /** |
|
| 621 | - * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
| 622 | - * |
|
| 623 | - * @param string $output Current output. |
|
| 624 | - * @return string |
|
| 625 | - * @throws InvalidArgumentException |
|
| 626 | - * @throws InvalidDataTypeException |
|
| 627 | - * @throws InvalidInterfaceException |
|
| 628 | - */ |
|
| 629 | - public function modify_dropdown_pages($output) |
|
| 630 | - { |
|
| 631 | - // get critical pages |
|
| 632 | - $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 633 | - |
|
| 634 | - // split current output by line break for easier parsing. |
|
| 635 | - $split_output = explode("\n", $output); |
|
| 636 | - |
|
| 637 | - // loop through to remove any critical pages from the array. |
|
| 638 | - foreach ($critical_pages as $page_id) { |
|
| 639 | - $needle = 'value="' . $page_id . '"'; |
|
| 640 | - foreach ($split_output as $key => $haystack) { |
|
| 641 | - if (strpos($haystack, $needle) !== false) { |
|
| 642 | - unset($split_output[ $key ]); |
|
| 643 | - } |
|
| 644 | - } |
|
| 645 | - } |
|
| 646 | - // replace output with the new contents |
|
| 647 | - return implode("\n", $split_output); |
|
| 648 | - } |
|
| 649 | - |
|
| 650 | - |
|
| 651 | - /** |
|
| 652 | - * display_admin_notices |
|
| 653 | - * |
|
| 654 | - * @return void |
|
| 655 | - */ |
|
| 656 | - public function display_admin_notices() |
|
| 657 | - { |
|
| 658 | - echo EE_Error::get_notices(); |
|
| 659 | - } |
|
| 660 | - |
|
| 661 | - |
|
| 662 | - /** |
|
| 663 | - * @param array $elements |
|
| 664 | - * @return array |
|
| 665 | - * @throws EE_Error |
|
| 666 | - * @throws InvalidArgumentException |
|
| 667 | - * @throws InvalidDataTypeException |
|
| 668 | - * @throws InvalidInterfaceException |
|
| 669 | - */ |
|
| 670 | - public function dashboard_glance_items($elements) |
|
| 671 | - { |
|
| 672 | - $elements = is_array($elements) ? $elements : array($elements); |
|
| 673 | - $events = EEM_Event::instance()->count(); |
|
| 674 | - $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 675 | - array('page' => 'espresso_events'), |
|
| 676 | - admin_url('admin.php') |
|
| 677 | - ); |
|
| 678 | - $items['events']['text'] = sprintf( |
|
| 679 | - esc_html( |
|
| 680 | - _n('%s Event', '%s Events', $events, 'event_espresso') |
|
| 681 | - ), |
|
| 682 | - number_format_i18n($events) |
|
| 683 | - ); |
|
| 684 | - $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
| 685 | - $registrations = EEM_Registration::instance()->count( |
|
| 686 | - array( |
|
| 687 | - array( |
|
| 688 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
| 689 | - ), |
|
| 690 | - ) |
|
| 691 | - ); |
|
| 692 | - $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 693 | - array('page' => 'espresso_registrations'), |
|
| 694 | - admin_url('admin.php') |
|
| 695 | - ); |
|
| 696 | - $items['registrations']['text'] = sprintf( |
|
| 697 | - esc_html( |
|
| 698 | - _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
|
| 699 | - ), |
|
| 700 | - number_format_i18n($registrations) |
|
| 701 | - ); |
|
| 702 | - $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
| 703 | - |
|
| 704 | - $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 705 | - |
|
| 706 | - foreach ($items as $type => $item_properties) { |
|
| 707 | - $elements[] = sprintf( |
|
| 708 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
| 709 | - $item_properties['url'], |
|
| 710 | - $item_properties['title'], |
|
| 711 | - $item_properties['text'] |
|
| 712 | - ); |
|
| 713 | - } |
|
| 714 | - return $elements; |
|
| 715 | - } |
|
| 716 | - |
|
| 717 | - |
|
| 718 | - /** |
|
| 719 | - * check_for_invalid_datetime_formats |
|
| 720 | - * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
| 721 | - * their selected format can be parsed by PHP |
|
| 722 | - * |
|
| 723 | - * @param $value |
|
| 724 | - * @param $option |
|
| 725 | - * @return string |
|
| 726 | - */ |
|
| 727 | - public function check_for_invalid_datetime_formats($value, $option) |
|
| 728 | - { |
|
| 729 | - // check for date_format or time_format |
|
| 730 | - switch ($option) { |
|
| 731 | - case 'date_format': |
|
| 732 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 733 | - break; |
|
| 734 | - case 'time_format': |
|
| 735 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 736 | - break; |
|
| 737 | - default: |
|
| 738 | - $date_time_format = false; |
|
| 739 | - } |
|
| 740 | - // do we have a date_time format to check ? |
|
| 741 | - if ($date_time_format) { |
|
| 742 | - $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
| 743 | - |
|
| 744 | - if (is_array($error_msg)) { |
|
| 745 | - $msg = '<p>' |
|
| 746 | - . sprintf( |
|
| 747 | - esc_html__( |
|
| 748 | - 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
| 749 | - 'event_espresso' |
|
| 750 | - ), |
|
| 751 | - date($date_time_format), |
|
| 752 | - $date_time_format |
|
| 753 | - ) |
|
| 754 | - . '</p><p><ul>'; |
|
| 755 | - |
|
| 756 | - |
|
| 757 | - foreach ($error_msg as $error) { |
|
| 758 | - $msg .= '<li>' . $error . '</li>'; |
|
| 759 | - } |
|
| 760 | - |
|
| 761 | - $msg .= '</ul></p><p>' |
|
| 762 | - . sprintf( |
|
| 763 | - esc_html__( |
|
| 764 | - '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
| 765 | - 'event_espresso' |
|
| 766 | - ), |
|
| 767 | - '<span style="color:#D54E21;">', |
|
| 768 | - '</span>' |
|
| 769 | - ) |
|
| 770 | - . '</p>'; |
|
| 771 | - |
|
| 772 | - // trigger WP settings error |
|
| 773 | - add_settings_error( |
|
| 774 | - 'date_format', |
|
| 775 | - 'date_format', |
|
| 776 | - $msg |
|
| 777 | - ); |
|
| 778 | - |
|
| 779 | - // set format to something valid |
|
| 780 | - switch ($option) { |
|
| 781 | - case 'date_format': |
|
| 782 | - $value = 'F j, Y'; |
|
| 783 | - break; |
|
| 784 | - case 'time_format': |
|
| 785 | - $value = 'g:i a'; |
|
| 786 | - break; |
|
| 787 | - } |
|
| 788 | - } |
|
| 789 | - } |
|
| 790 | - return $value; |
|
| 791 | - } |
|
| 792 | - |
|
| 793 | - |
|
| 794 | - /** |
|
| 795 | - * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
| 796 | - * |
|
| 797 | - * @param $content |
|
| 798 | - * @return string |
|
| 799 | - */ |
|
| 800 | - public function its_eSpresso($content) |
|
| 801 | - { |
|
| 802 | - return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
| 803 | - } |
|
| 804 | - |
|
| 805 | - |
|
| 806 | - /** |
|
| 807 | - * espresso_admin_footer |
|
| 808 | - * |
|
| 809 | - * @return string |
|
| 810 | - */ |
|
| 811 | - public function espresso_admin_footer() |
|
| 812 | - { |
|
| 813 | - return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
| 814 | - } |
|
| 815 | - |
|
| 816 | - |
|
| 817 | - /** |
|
| 818 | - * Hooks into the "post states" filter in a wp post type list table. |
|
| 819 | - * |
|
| 820 | - * @param array $post_states |
|
| 821 | - * @param WP_Post $post |
|
| 822 | - * @return array |
|
| 823 | - * @throws InvalidArgumentException |
|
| 824 | - * @throws InvalidDataTypeException |
|
| 825 | - * @throws InvalidInterfaceException |
|
| 826 | - */ |
|
| 827 | - public function displayStateForCriticalPages($post_states, $post) |
|
| 828 | - { |
|
| 829 | - $post_states = (array) $post_states; |
|
| 830 | - if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
| 831 | - return $post_states; |
|
| 832 | - } |
|
| 833 | - /** @var EE_Core_Config $config */ |
|
| 834 | - $config = $this->loader->getShared('EE_Config')->core; |
|
| 835 | - if (in_array($post->ID, $config->get_critical_pages_array(), true)) { |
|
| 836 | - $post_states[] = sprintf( |
|
| 837 | - /* Translators: Using company name - Event Espresso Critical Page */ |
|
| 838 | - esc_html__('%s Critical Page', 'event_espresso'), |
|
| 839 | - 'Event Espresso' |
|
| 840 | - ); |
|
| 841 | - } |
|
| 842 | - return $post_states; |
|
| 843 | - } |
|
| 844 | - |
|
| 845 | - |
|
| 846 | - /** |
|
| 847 | - * Show documentation links on the plugins page |
|
| 848 | - * |
|
| 849 | - * @param mixed $meta Plugin Row Meta |
|
| 850 | - * @param mixed $file Plugin Base file |
|
| 851 | - * @return array |
|
| 852 | - */ |
|
| 853 | - public function addLinksToPluginRowMeta($meta, $file) |
|
| 854 | - { |
|
| 855 | - if (EE_PLUGIN_BASENAME === $file) { |
|
| 856 | - $row_meta = array( |
|
| 857 | - 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"' |
|
| 858 | - . ' aria-label="' |
|
| 859 | - . esc_attr__('View Event Espresso documentation', 'event_espresso') |
|
| 860 | - . '">' |
|
| 861 | - . esc_html__('Docs', 'event_espresso') |
|
| 862 | - . '</a>', |
|
| 863 | - 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"' |
|
| 864 | - . ' aria-label="' |
|
| 865 | - . esc_attr__('View Event Espresso API docs', 'event_espresso') |
|
| 866 | - . '">' |
|
| 867 | - . esc_html__('API docs', 'event_espresso') |
|
| 868 | - . '</a>', |
|
| 869 | - ); |
|
| 870 | - return array_merge($meta, $row_meta); |
|
| 871 | - } |
|
| 872 | - return (array) $meta; |
|
| 873 | - } |
|
| 874 | - |
|
| 875 | - /**************************************************************************************/ |
|
| 876 | - /************************************* DEPRECATED *************************************/ |
|
| 877 | - /**************************************************************************************/ |
|
| 878 | - |
|
| 879 | - |
|
| 880 | - /** |
|
| 881 | - * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
| 882 | - * EE_Admin_Page route is called. |
|
| 883 | - * |
|
| 884 | - * @return void |
|
| 885 | - */ |
|
| 886 | - public function route_admin_request() |
|
| 887 | - { |
|
| 888 | - } |
|
| 889 | - |
|
| 890 | - |
|
| 891 | - /** |
|
| 892 | - * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
| 893 | - * |
|
| 894 | - * @return void |
|
| 895 | - */ |
|
| 896 | - public function wp_loaded() |
|
| 897 | - { |
|
| 898 | - } |
|
| 899 | - |
|
| 900 | - |
|
| 901 | - /** |
|
| 902 | - * static method for registering ee admin page. |
|
| 903 | - * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
| 904 | - * |
|
| 905 | - * @param $page_basename |
|
| 906 | - * @param $page_path |
|
| 907 | - * @param array $config |
|
| 908 | - * @return void |
|
| 909 | - * @throws EE_Error |
|
| 910 | - * @see EE_Register_Admin_Page::register() |
|
| 911 | - * @since 4.3.0 |
|
| 912 | - * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
| 913 | - */ |
|
| 914 | - public static function register_ee_admin_page($page_basename, $page_path, $config = []) |
|
| 915 | - { |
|
| 916 | - EE_Error::doing_it_wrong( |
|
| 917 | - __METHOD__, |
|
| 918 | - sprintf( |
|
| 919 | - esc_html__( |
|
| 920 | - 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
| 921 | - 'event_espresso' |
|
| 922 | - ), |
|
| 923 | - $page_basename |
|
| 924 | - ), |
|
| 925 | - '4.3' |
|
| 926 | - ); |
|
| 927 | - if (class_exists('EE_Register_Admin_Page')) { |
|
| 928 | - $config['page_path'] = $page_path; |
|
| 929 | - } |
|
| 930 | - EE_Register_Admin_Page::register($page_basename, $config); |
|
| 931 | - } |
|
| 932 | - |
|
| 933 | - |
|
| 934 | - /** |
|
| 935 | - * @param int $post_ID |
|
| 936 | - * @param \WP_Post $post |
|
| 937 | - * @return void |
|
| 938 | - * @deprecated 4.8.41 |
|
| 939 | - */ |
|
| 940 | - public static function parse_post_content_on_save($post_ID, $post) |
|
| 941 | - { |
|
| 942 | - EE_Error::doing_it_wrong( |
|
| 943 | - __METHOD__, |
|
| 944 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 945 | - '4.8.41' |
|
| 946 | - ); |
|
| 947 | - } |
|
| 948 | - |
|
| 949 | - |
|
| 950 | - /** |
|
| 951 | - * @param $option |
|
| 952 | - * @param $old_value |
|
| 953 | - * @param $value |
|
| 954 | - * @return void |
|
| 955 | - * @deprecated 4.8.41 |
|
| 956 | - */ |
|
| 957 | - public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
| 958 | - { |
|
| 959 | - EE_Error::doing_it_wrong( |
|
| 960 | - __METHOD__, |
|
| 961 | - esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 962 | - '4.8.41' |
|
| 963 | - ); |
|
| 964 | - } |
|
| 965 | - |
|
| 966 | - |
|
| 967 | - /** |
|
| 968 | - * @return void |
|
| 969 | - * @deprecated 4.9.27 |
|
| 970 | - */ |
|
| 971 | - public function get_persistent_admin_notices() |
|
| 972 | - { |
|
| 973 | - EE_Error::doing_it_wrong( |
|
| 974 | - __METHOD__, |
|
| 975 | - sprintf( |
|
| 976 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
| 977 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
| 978 | - ), |
|
| 979 | - '4.9.27' |
|
| 980 | - ); |
|
| 981 | - } |
|
| 982 | - |
|
| 983 | - |
|
| 984 | - /** |
|
| 985 | - * @throws InvalidInterfaceException |
|
| 986 | - * @throws InvalidDataTypeException |
|
| 987 | - * @throws DomainException |
|
| 988 | - * @deprecated 4.9.27 |
|
| 989 | - */ |
|
| 990 | - public function dismiss_ee_nag_notice_callback() |
|
| 991 | - { |
|
| 992 | - EE_Error::doing_it_wrong( |
|
| 993 | - __METHOD__, |
|
| 994 | - sprintf( |
|
| 995 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
| 996 | - '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
| 997 | - ), |
|
| 998 | - '4.9.27' |
|
| 999 | - ); |
|
| 1000 | - $this->persistent_admin_notice_manager->dismissNotice(); |
|
| 1001 | - } |
|
| 1002 | - |
|
| 1003 | - |
|
| 1004 | - /** |
|
| 1005 | - * @return void |
|
| 1006 | - * @deprecated $VID:$ |
|
| 1007 | - */ |
|
| 1008 | - public function enqueue_admin_scripts() |
|
| 1009 | - { |
|
| 1010 | - } |
|
| 1011 | - |
|
| 1012 | - |
|
| 1013 | - |
|
| 1014 | - /** |
|
| 1015 | - * @return RequestInterface |
|
| 1016 | - * @deprecated $VID:$ |
|
| 1017 | - */ |
|
| 1018 | - public function get_request() |
|
| 1019 | - { |
|
| 1020 | - EE_Error::doing_it_wrong( |
|
| 1021 | - __METHOD__, |
|
| 1022 | - sprintf( |
|
| 1023 | - esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
| 1024 | - 'EventEspresso\core\services\request\Request' |
|
| 1025 | - ), |
|
| 1026 | - '$VID:$' |
|
| 1027 | - ); |
|
| 1028 | - return $this->request; |
|
| 1029 | - } |
|
| 1030 | - |
|
| 1031 | - /** |
|
| 1032 | - * @deprecated $VID:$ |
|
| 1033 | - */ |
|
| 1034 | - public function hookIntoWpPluginsPage() |
|
| 1035 | - { |
|
| 1036 | - } |
|
| 512 | + } |
|
| 513 | + |
|
| 514 | + |
|
| 515 | + /** |
|
| 516 | + * Returns an array of event archive nav items. |
|
| 517 | + * |
|
| 518 | + * @todo for now this method is just in place so when it gets abstracted further we can substitute in whatever |
|
| 519 | + * method we use for getting the extra nav menu items |
|
| 520 | + * @return array |
|
| 521 | + */ |
|
| 522 | + private function _get_extra_nav_menu_pages_items() |
|
| 523 | + { |
|
| 524 | + $menuitems[] = array( |
|
| 525 | + 'title' => esc_html__('Event List', 'event_espresso'), |
|
| 526 | + 'url' => get_post_type_archive_link('espresso_events'), |
|
| 527 | + 'description' => esc_html__('Archive page for all events.', 'event_espresso'), |
|
| 528 | + ); |
|
| 529 | + return apply_filters('FHEE__EE_Admin__get_extra_nav_menu_pages_items', $menuitems); |
|
| 530 | + } |
|
| 531 | + |
|
| 532 | + |
|
| 533 | + /** |
|
| 534 | + * Setup nav menu walker item for usage in the event archive nav menu metabox. It receives a menu_item array with |
|
| 535 | + * the properties and converts it to the menu item object. |
|
| 536 | + * |
|
| 537 | + * @see wp_setup_nav_menu_item() in wp-includes/nav-menu.php |
|
| 538 | + * @param $menu_item_values |
|
| 539 | + * @return stdClass |
|
| 540 | + */ |
|
| 541 | + private function _setup_extra_nav_menu_pages_items($menu_item_values) |
|
| 542 | + { |
|
| 543 | + $menu_item = new stdClass(); |
|
| 544 | + $keys = array( |
|
| 545 | + 'ID' => 0, |
|
| 546 | + 'db_id' => 0, |
|
| 547 | + 'menu_item_parent' => 0, |
|
| 548 | + 'object_id' => -1, |
|
| 549 | + 'post_parent' => 0, |
|
| 550 | + 'type' => 'custom', |
|
| 551 | + 'object' => '', |
|
| 552 | + 'type_label' => esc_html__('Extra Nav Menu Item', 'event_espresso'), |
|
| 553 | + 'title' => '', |
|
| 554 | + 'url' => '', |
|
| 555 | + 'target' => '', |
|
| 556 | + 'attr_title' => '', |
|
| 557 | + 'description' => '', |
|
| 558 | + 'classes' => array(), |
|
| 559 | + 'xfn' => '', |
|
| 560 | + ); |
|
| 561 | + |
|
| 562 | + foreach ($keys as $key => $value) { |
|
| 563 | + $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; |
|
| 564 | + } |
|
| 565 | + return $menu_item; |
|
| 566 | + } |
|
| 567 | + |
|
| 568 | + |
|
| 569 | + /** |
|
| 570 | + * admin_init |
|
| 571 | + * |
|
| 572 | + * @return void |
|
| 573 | + * @throws InvalidArgumentException |
|
| 574 | + * @throws InvalidDataTypeException |
|
| 575 | + * @throws InvalidInterfaceException |
|
| 576 | + */ |
|
| 577 | + public function admin_init() |
|
| 578 | + { |
|
| 579 | + /** |
|
| 580 | + * our cpt models must be instantiated on WordPress post processing routes (wp-admin/post.php), |
|
| 581 | + * so any hooking into core WP routes is taken care of. So in this next few lines of code: |
|
| 582 | + * - check if doing post processing. |
|
| 583 | + * - check if doing post processing of one of EE CPTs |
|
| 584 | + * - instantiate the corresponding EE CPT model for the post_type being processed. |
|
| 585 | + */ |
|
| 586 | + if (isset($_POST['action'], $_POST['post_type']) && $_POST['action'] === 'editpost') { |
|
| 587 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */ |
|
| 588 | + $custom_post_types = $this->loader->getShared( |
|
| 589 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
| 590 | + ); |
|
| 591 | + $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
|
| 592 | + } |
|
| 593 | + |
|
| 594 | + if (! $this->request->isAjax()) { |
|
| 595 | + /** |
|
| 596 | + * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
|
| 597 | + * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
|
| 598 | + * Pages" tab in the EE General Settings Admin page. |
|
| 599 | + * This is for user-proofing. |
|
| 600 | + */ |
|
| 601 | + add_filter('wp_dropdown_pages', array($this, 'modify_dropdown_pages')); |
|
| 602 | + if (EE_Maintenance_Mode::instance()->models_can_query()) { |
|
| 603 | + $this->adminInitModelsReady(); |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + } |
|
| 607 | + |
|
| 608 | + |
|
| 609 | + /** |
|
| 610 | + * Runs on admin_init but only if models are usable (ie, we're not in maintenance mode) |
|
| 611 | + */ |
|
| 612 | + protected function adminInitModelsReady() |
|
| 613 | + { |
|
| 614 | + if (function_exists('wp_add_privacy_policy_content')) { |
|
| 615 | + $this->loader->getShared('EventEspresso\core\services\privacy\policy\PrivacyPolicyManager'); |
|
| 616 | + } |
|
| 617 | + } |
|
| 618 | + |
|
| 619 | + |
|
| 620 | + /** |
|
| 621 | + * Callback for wp_dropdown_pages hook to remove ee critical pages from the dropdown selection. |
|
| 622 | + * |
|
| 623 | + * @param string $output Current output. |
|
| 624 | + * @return string |
|
| 625 | + * @throws InvalidArgumentException |
|
| 626 | + * @throws InvalidDataTypeException |
|
| 627 | + * @throws InvalidInterfaceException |
|
| 628 | + */ |
|
| 629 | + public function modify_dropdown_pages($output) |
|
| 630 | + { |
|
| 631 | + // get critical pages |
|
| 632 | + $critical_pages = EE_Registry::instance()->CFG->core->get_critical_pages_array(); |
|
| 633 | + |
|
| 634 | + // split current output by line break for easier parsing. |
|
| 635 | + $split_output = explode("\n", $output); |
|
| 636 | + |
|
| 637 | + // loop through to remove any critical pages from the array. |
|
| 638 | + foreach ($critical_pages as $page_id) { |
|
| 639 | + $needle = 'value="' . $page_id . '"'; |
|
| 640 | + foreach ($split_output as $key => $haystack) { |
|
| 641 | + if (strpos($haystack, $needle) !== false) { |
|
| 642 | + unset($split_output[ $key ]); |
|
| 643 | + } |
|
| 644 | + } |
|
| 645 | + } |
|
| 646 | + // replace output with the new contents |
|
| 647 | + return implode("\n", $split_output); |
|
| 648 | + } |
|
| 649 | + |
|
| 650 | + |
|
| 651 | + /** |
|
| 652 | + * display_admin_notices |
|
| 653 | + * |
|
| 654 | + * @return void |
|
| 655 | + */ |
|
| 656 | + public function display_admin_notices() |
|
| 657 | + { |
|
| 658 | + echo EE_Error::get_notices(); |
|
| 659 | + } |
|
| 660 | + |
|
| 661 | + |
|
| 662 | + /** |
|
| 663 | + * @param array $elements |
|
| 664 | + * @return array |
|
| 665 | + * @throws EE_Error |
|
| 666 | + * @throws InvalidArgumentException |
|
| 667 | + * @throws InvalidDataTypeException |
|
| 668 | + * @throws InvalidInterfaceException |
|
| 669 | + */ |
|
| 670 | + public function dashboard_glance_items($elements) |
|
| 671 | + { |
|
| 672 | + $elements = is_array($elements) ? $elements : array($elements); |
|
| 673 | + $events = EEM_Event::instance()->count(); |
|
| 674 | + $items['events']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 675 | + array('page' => 'espresso_events'), |
|
| 676 | + admin_url('admin.php') |
|
| 677 | + ); |
|
| 678 | + $items['events']['text'] = sprintf( |
|
| 679 | + esc_html( |
|
| 680 | + _n('%s Event', '%s Events', $events, 'event_espresso') |
|
| 681 | + ), |
|
| 682 | + number_format_i18n($events) |
|
| 683 | + ); |
|
| 684 | + $items['events']['title'] = esc_html__('Click to view all Events', 'event_espresso'); |
|
| 685 | + $registrations = EEM_Registration::instance()->count( |
|
| 686 | + array( |
|
| 687 | + array( |
|
| 688 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
| 689 | + ), |
|
| 690 | + ) |
|
| 691 | + ); |
|
| 692 | + $items['registrations']['url'] = EE_Admin_Page::add_query_args_and_nonce( |
|
| 693 | + array('page' => 'espresso_registrations'), |
|
| 694 | + admin_url('admin.php') |
|
| 695 | + ); |
|
| 696 | + $items['registrations']['text'] = sprintf( |
|
| 697 | + esc_html( |
|
| 698 | + _n('%s Registration', '%s Registrations', $registrations, 'event_espresso') |
|
| 699 | + ), |
|
| 700 | + number_format_i18n($registrations) |
|
| 701 | + ); |
|
| 702 | + $items['registrations']['title'] = esc_html__('Click to view all registrations', 'event_espresso'); |
|
| 703 | + |
|
| 704 | + $items = (array) apply_filters('FHEE__EE_Admin__dashboard_glance_items__items', $items); |
|
| 705 | + |
|
| 706 | + foreach ($items as $type => $item_properties) { |
|
| 707 | + $elements[] = sprintf( |
|
| 708 | + '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
| 709 | + $item_properties['url'], |
|
| 710 | + $item_properties['title'], |
|
| 711 | + $item_properties['text'] |
|
| 712 | + ); |
|
| 713 | + } |
|
| 714 | + return $elements; |
|
| 715 | + } |
|
| 716 | + |
|
| 717 | + |
|
| 718 | + /** |
|
| 719 | + * check_for_invalid_datetime_formats |
|
| 720 | + * if an admin changes their date or time format settings on the WP General Settings admin page, verify that |
|
| 721 | + * their selected format can be parsed by PHP |
|
| 722 | + * |
|
| 723 | + * @param $value |
|
| 724 | + * @param $option |
|
| 725 | + * @return string |
|
| 726 | + */ |
|
| 727 | + public function check_for_invalid_datetime_formats($value, $option) |
|
| 728 | + { |
|
| 729 | + // check for date_format or time_format |
|
| 730 | + switch ($option) { |
|
| 731 | + case 'date_format': |
|
| 732 | + $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 733 | + break; |
|
| 734 | + case 'time_format': |
|
| 735 | + $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 736 | + break; |
|
| 737 | + default: |
|
| 738 | + $date_time_format = false; |
|
| 739 | + } |
|
| 740 | + // do we have a date_time format to check ? |
|
| 741 | + if ($date_time_format) { |
|
| 742 | + $error_msg = EEH_DTT_Helper::validate_format_string($date_time_format); |
|
| 743 | + |
|
| 744 | + if (is_array($error_msg)) { |
|
| 745 | + $msg = '<p>' |
|
| 746 | + . sprintf( |
|
| 747 | + esc_html__( |
|
| 748 | + 'The following date time "%s" ( %s ) is difficult to be properly parsed by PHP for the following reasons:', |
|
| 749 | + 'event_espresso' |
|
| 750 | + ), |
|
| 751 | + date($date_time_format), |
|
| 752 | + $date_time_format |
|
| 753 | + ) |
|
| 754 | + . '</p><p><ul>'; |
|
| 755 | + |
|
| 756 | + |
|
| 757 | + foreach ($error_msg as $error) { |
|
| 758 | + $msg .= '<li>' . $error . '</li>'; |
|
| 759 | + } |
|
| 760 | + |
|
| 761 | + $msg .= '</ul></p><p>' |
|
| 762 | + . sprintf( |
|
| 763 | + esc_html__( |
|
| 764 | + '%sPlease note that your date and time formats have been reset to "F j, Y" and "g:i a" respectively.%s', |
|
| 765 | + 'event_espresso' |
|
| 766 | + ), |
|
| 767 | + '<span style="color:#D54E21;">', |
|
| 768 | + '</span>' |
|
| 769 | + ) |
|
| 770 | + . '</p>'; |
|
| 771 | + |
|
| 772 | + // trigger WP settings error |
|
| 773 | + add_settings_error( |
|
| 774 | + 'date_format', |
|
| 775 | + 'date_format', |
|
| 776 | + $msg |
|
| 777 | + ); |
|
| 778 | + |
|
| 779 | + // set format to something valid |
|
| 780 | + switch ($option) { |
|
| 781 | + case 'date_format': |
|
| 782 | + $value = 'F j, Y'; |
|
| 783 | + break; |
|
| 784 | + case 'time_format': |
|
| 785 | + $value = 'g:i a'; |
|
| 786 | + break; |
|
| 787 | + } |
|
| 788 | + } |
|
| 789 | + } |
|
| 790 | + return $value; |
|
| 791 | + } |
|
| 792 | + |
|
| 793 | + |
|
| 794 | + /** |
|
| 795 | + * its_eSpresso - converts the less commonly used spelling of "Expresso" to "Espresso" |
|
| 796 | + * |
|
| 797 | + * @param $content |
|
| 798 | + * @return string |
|
| 799 | + */ |
|
| 800 | + public function its_eSpresso($content) |
|
| 801 | + { |
|
| 802 | + return str_replace('[EXPRESSO_', '[ESPRESSO_', $content); |
|
| 803 | + } |
|
| 804 | + |
|
| 805 | + |
|
| 806 | + /** |
|
| 807 | + * espresso_admin_footer |
|
| 808 | + * |
|
| 809 | + * @return string |
|
| 810 | + */ |
|
| 811 | + public function espresso_admin_footer() |
|
| 812 | + { |
|
| 813 | + return \EEH_Template::powered_by_event_espresso('aln-cntr', '', array('utm_content' => 'admin_footer')); |
|
| 814 | + } |
|
| 815 | + |
|
| 816 | + |
|
| 817 | + /** |
|
| 818 | + * Hooks into the "post states" filter in a wp post type list table. |
|
| 819 | + * |
|
| 820 | + * @param array $post_states |
|
| 821 | + * @param WP_Post $post |
|
| 822 | + * @return array |
|
| 823 | + * @throws InvalidArgumentException |
|
| 824 | + * @throws InvalidDataTypeException |
|
| 825 | + * @throws InvalidInterfaceException |
|
| 826 | + */ |
|
| 827 | + public function displayStateForCriticalPages($post_states, $post) |
|
| 828 | + { |
|
| 829 | + $post_states = (array) $post_states; |
|
| 830 | + if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
| 831 | + return $post_states; |
|
| 832 | + } |
|
| 833 | + /** @var EE_Core_Config $config */ |
|
| 834 | + $config = $this->loader->getShared('EE_Config')->core; |
|
| 835 | + if (in_array($post->ID, $config->get_critical_pages_array(), true)) { |
|
| 836 | + $post_states[] = sprintf( |
|
| 837 | + /* Translators: Using company name - Event Espresso Critical Page */ |
|
| 838 | + esc_html__('%s Critical Page', 'event_espresso'), |
|
| 839 | + 'Event Espresso' |
|
| 840 | + ); |
|
| 841 | + } |
|
| 842 | + return $post_states; |
|
| 843 | + } |
|
| 844 | + |
|
| 845 | + |
|
| 846 | + /** |
|
| 847 | + * Show documentation links on the plugins page |
|
| 848 | + * |
|
| 849 | + * @param mixed $meta Plugin Row Meta |
|
| 850 | + * @param mixed $file Plugin Base file |
|
| 851 | + * @return array |
|
| 852 | + */ |
|
| 853 | + public function addLinksToPluginRowMeta($meta, $file) |
|
| 854 | + { |
|
| 855 | + if (EE_PLUGIN_BASENAME === $file) { |
|
| 856 | + $row_meta = array( |
|
| 857 | + 'docs' => '<a href="https://eventespresso.com/support/documentation/versioned-docs/?doc_ver=ee4"' |
|
| 858 | + . ' aria-label="' |
|
| 859 | + . esc_attr__('View Event Espresso documentation', 'event_espresso') |
|
| 860 | + . '">' |
|
| 861 | + . esc_html__('Docs', 'event_espresso') |
|
| 862 | + . '</a>', |
|
| 863 | + 'api' => '<a href="https://github.com/eventespresso/event-espresso-core/tree/master/docs/C--REST-API"' |
|
| 864 | + . ' aria-label="' |
|
| 865 | + . esc_attr__('View Event Espresso API docs', 'event_espresso') |
|
| 866 | + . '">' |
|
| 867 | + . esc_html__('API docs', 'event_espresso') |
|
| 868 | + . '</a>', |
|
| 869 | + ); |
|
| 870 | + return array_merge($meta, $row_meta); |
|
| 871 | + } |
|
| 872 | + return (array) $meta; |
|
| 873 | + } |
|
| 874 | + |
|
| 875 | + /**************************************************************************************/ |
|
| 876 | + /************************************* DEPRECATED *************************************/ |
|
| 877 | + /**************************************************************************************/ |
|
| 878 | + |
|
| 879 | + |
|
| 880 | + /** |
|
| 881 | + * This is the action hook for the AHEE__EE_Admin_Page__route_admin_request hook that fires off right before an |
|
| 882 | + * EE_Admin_Page route is called. |
|
| 883 | + * |
|
| 884 | + * @return void |
|
| 885 | + */ |
|
| 886 | + public function route_admin_request() |
|
| 887 | + { |
|
| 888 | + } |
|
| 889 | + |
|
| 890 | + |
|
| 891 | + /** |
|
| 892 | + * wp_loaded should fire on the WordPress wp_loaded hook. This fires on a VERY late priority. |
|
| 893 | + * |
|
| 894 | + * @return void |
|
| 895 | + */ |
|
| 896 | + public function wp_loaded() |
|
| 897 | + { |
|
| 898 | + } |
|
| 899 | + |
|
| 900 | + |
|
| 901 | + /** |
|
| 902 | + * static method for registering ee admin page. |
|
| 903 | + * This method is deprecated in favor of the new location in EE_Register_Admin_Page::register. |
|
| 904 | + * |
|
| 905 | + * @param $page_basename |
|
| 906 | + * @param $page_path |
|
| 907 | + * @param array $config |
|
| 908 | + * @return void |
|
| 909 | + * @throws EE_Error |
|
| 910 | + * @see EE_Register_Admin_Page::register() |
|
| 911 | + * @since 4.3.0 |
|
| 912 | + * @deprecated 4.3.0 Use EE_Register_Admin_Page::register() instead |
|
| 913 | + */ |
|
| 914 | + public static function register_ee_admin_page($page_basename, $page_path, $config = []) |
|
| 915 | + { |
|
| 916 | + EE_Error::doing_it_wrong( |
|
| 917 | + __METHOD__, |
|
| 918 | + sprintf( |
|
| 919 | + esc_html__( |
|
| 920 | + 'Usage is deprecated. Use EE_Register_Admin_Page::register() for registering the %s admin page.', |
|
| 921 | + 'event_espresso' |
|
| 922 | + ), |
|
| 923 | + $page_basename |
|
| 924 | + ), |
|
| 925 | + '4.3' |
|
| 926 | + ); |
|
| 927 | + if (class_exists('EE_Register_Admin_Page')) { |
|
| 928 | + $config['page_path'] = $page_path; |
|
| 929 | + } |
|
| 930 | + EE_Register_Admin_Page::register($page_basename, $config); |
|
| 931 | + } |
|
| 932 | + |
|
| 933 | + |
|
| 934 | + /** |
|
| 935 | + * @param int $post_ID |
|
| 936 | + * @param \WP_Post $post |
|
| 937 | + * @return void |
|
| 938 | + * @deprecated 4.8.41 |
|
| 939 | + */ |
|
| 940 | + public static function parse_post_content_on_save($post_ID, $post) |
|
| 941 | + { |
|
| 942 | + EE_Error::doing_it_wrong( |
|
| 943 | + __METHOD__, |
|
| 944 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 945 | + '4.8.41' |
|
| 946 | + ); |
|
| 947 | + } |
|
| 948 | + |
|
| 949 | + |
|
| 950 | + /** |
|
| 951 | + * @param $option |
|
| 952 | + * @param $old_value |
|
| 953 | + * @param $value |
|
| 954 | + * @return void |
|
| 955 | + * @deprecated 4.8.41 |
|
| 956 | + */ |
|
| 957 | + public function reset_page_for_posts_on_change($option, $old_value, $value) |
|
| 958 | + { |
|
| 959 | + EE_Error::doing_it_wrong( |
|
| 960 | + __METHOD__, |
|
| 961 | + esc_html__('Usage is deprecated', 'event_espresso'), |
|
| 962 | + '4.8.41' |
|
| 963 | + ); |
|
| 964 | + } |
|
| 965 | + |
|
| 966 | + |
|
| 967 | + /** |
|
| 968 | + * @return void |
|
| 969 | + * @deprecated 4.9.27 |
|
| 970 | + */ |
|
| 971 | + public function get_persistent_admin_notices() |
|
| 972 | + { |
|
| 973 | + EE_Error::doing_it_wrong( |
|
| 974 | + __METHOD__, |
|
| 975 | + sprintf( |
|
| 976 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
| 977 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
| 978 | + ), |
|
| 979 | + '4.9.27' |
|
| 980 | + ); |
|
| 981 | + } |
|
| 982 | + |
|
| 983 | + |
|
| 984 | + /** |
|
| 985 | + * @throws InvalidInterfaceException |
|
| 986 | + * @throws InvalidDataTypeException |
|
| 987 | + * @throws DomainException |
|
| 988 | + * @deprecated 4.9.27 |
|
| 989 | + */ |
|
| 990 | + public function dismiss_ee_nag_notice_callback() |
|
| 991 | + { |
|
| 992 | + EE_Error::doing_it_wrong( |
|
| 993 | + __METHOD__, |
|
| 994 | + sprintf( |
|
| 995 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
| 996 | + '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager' |
|
| 997 | + ), |
|
| 998 | + '4.9.27' |
|
| 999 | + ); |
|
| 1000 | + $this->persistent_admin_notice_manager->dismissNotice(); |
|
| 1001 | + } |
|
| 1002 | + |
|
| 1003 | + |
|
| 1004 | + /** |
|
| 1005 | + * @return void |
|
| 1006 | + * @deprecated $VID:$ |
|
| 1007 | + */ |
|
| 1008 | + public function enqueue_admin_scripts() |
|
| 1009 | + { |
|
| 1010 | + } |
|
| 1011 | + |
|
| 1012 | + |
|
| 1013 | + |
|
| 1014 | + /** |
|
| 1015 | + * @return RequestInterface |
|
| 1016 | + * @deprecated $VID:$ |
|
| 1017 | + */ |
|
| 1018 | + public function get_request() |
|
| 1019 | + { |
|
| 1020 | + EE_Error::doing_it_wrong( |
|
| 1021 | + __METHOD__, |
|
| 1022 | + sprintf( |
|
| 1023 | + esc_html__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'), |
|
| 1024 | + 'EventEspresso\core\services\request\Request' |
|
| 1025 | + ), |
|
| 1026 | + '$VID:$' |
|
| 1027 | + ); |
|
| 1028 | + return $this->request; |
|
| 1029 | + } |
|
| 1030 | + |
|
| 1031 | + /** |
|
| 1032 | + * @deprecated $VID:$ |
|
| 1033 | + */ |
|
| 1034 | + public function hookIntoWpPluginsPage() |
|
| 1035 | + { |
|
| 1036 | + } |
|
| 1037 | 1037 | } |
@@ -49,7 +49,7 @@ discard block |
||
| 49 | 49 | public static function instance() |
| 50 | 50 | { |
| 51 | 51 | // check if class object is instantiated |
| 52 | - if (! EE_Admin::$_instance instanceof EE_Admin) { |
|
| 52 | + if ( ! EE_Admin::$_instance instanceof EE_Admin) { |
|
| 53 | 53 | EE_Admin::$_instance = new EE_Admin(); |
| 54 | 54 | } |
| 55 | 55 | return EE_Admin::$_instance; |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | add_action('admin_notices', array($this, 'display_admin_notices'), 10); |
| 91 | 91 | add_action('network_admin_notices', array($this, 'display_admin_notices'), 10); |
| 92 | 92 | add_filter('pre_update_option', array($this, 'check_for_invalid_datetime_formats'), 100, 2); |
| 93 | - if (! $this->request->isAjax()) { |
|
| 93 | + if ( ! $this->request->isAjax()) { |
|
| 94 | 94 | // admin hooks |
| 95 | 95 | add_filter('plugin_action_links', [$this, 'filter_plugin_actions'], 10, 2); |
| 96 | 96 | add_filter('admin_footer_text', [$this, 'espresso_admin_footer']); |
@@ -110,11 +110,11 @@ discard block |
||
| 110 | 110 | */ |
| 111 | 111 | private function _define_all_constants() |
| 112 | 112 | { |
| 113 | - if (! defined('EE_ADMIN_URL')) { |
|
| 114 | - define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL . 'core/admin/'); |
|
| 115 | - define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL . 'admin_pages/'); |
|
| 116 | - define('EE_ADMIN_TEMPLATE', EE_ADMIN . 'templates/'); |
|
| 117 | - define('WP_ADMIN_PATH', ABSPATH . 'wp-admin/'); |
|
| 113 | + if ( ! defined('EE_ADMIN_URL')) { |
|
| 114 | + define('EE_ADMIN_URL', EE_PLUGIN_DIR_URL.'core/admin/'); |
|
| 115 | + define('EE_ADMIN_PAGES_URL', EE_PLUGIN_DIR_URL.'admin_pages/'); |
|
| 116 | + define('EE_ADMIN_TEMPLATE', EE_ADMIN.'templates/'); |
|
| 117 | + define('WP_ADMIN_PATH', ABSPATH.'wp-admin/'); |
|
| 118 | 118 | define('WP_AJAX_URL', admin_url('admin-ajax.php')); |
| 119 | 119 | } |
| 120 | 120 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | // set $main_file in stone |
| 133 | 133 | static $main_file; |
| 134 | 134 | // if $main_file is not set yet |
| 135 | - if (! $main_file) { |
|
| 135 | + if ( ! $main_file) { |
|
| 136 | 136 | $main_file = plugin_basename(EVENT_ESPRESSO_MAIN_FILE); |
| 137 | 137 | } |
| 138 | 138 | if ($plugin === $main_file) { |
@@ -167,9 +167,9 @@ discard block |
||
| 167 | 167 | public function hide_admin_pages_except_maintenance_mode($admin_page_folder_names = array()) |
| 168 | 168 | { |
| 169 | 169 | return array( |
| 170 | - 'maintenance' => EE_ADMIN_PAGES . 'maintenance/', |
|
| 171 | - 'about' => EE_ADMIN_PAGES . 'about/', |
|
| 172 | - 'support' => EE_ADMIN_PAGES . 'support/', |
|
| 170 | + 'maintenance' => EE_ADMIN_PAGES.'maintenance/', |
|
| 171 | + 'about' => EE_ADMIN_PAGES.'about/', |
|
| 172 | + 'support' => EE_ADMIN_PAGES.'support/', |
|
| 173 | 173 | ); |
| 174 | 174 | } |
| 175 | 175 | |
@@ -193,7 +193,7 @@ discard block |
||
| 193 | 193 | $this->initModelsReady(); |
| 194 | 194 | } |
| 195 | 195 | // run the admin page factory but ONLY if we are doing an ee admin ajax request |
| 196 | - if (! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 196 | + if ( ! defined('DOING_AJAX') || EE_ADMIN_AJAX) { |
|
| 197 | 197 | try { |
| 198 | 198 | // this loads the controller for the admin pages which will setup routing etc |
| 199 | 199 | $admin_page_loader = $this->loader->getShared('EE_Admin_Page_Loader'); |
@@ -203,7 +203,7 @@ discard block |
||
| 203 | 203 | } |
| 204 | 204 | } |
| 205 | 205 | add_filter('content_save_pre', array($this, 'its_eSpresso'), 10, 1); |
| 206 | - if (! $this->request->isAjax()) { |
|
| 206 | + if ( ! $this->request->isAjax()) { |
|
| 207 | 207 | // make sure our CPTs and custom taxonomy metaboxes get shown for first time users |
| 208 | 208 | add_action('admin_head', [$this, 'enable_hidden_ee_nav_menu_metaboxes'], 10); |
| 209 | 209 | add_action('admin_head', [$this, 'register_custom_nav_menu_boxes'], 10); |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | */ |
| 223 | 223 | protected function getLoader() |
| 224 | 224 | { |
| 225 | - if (! $this->loader instanceof LoaderInterface) { |
|
| 225 | + if ( ! $this->loader instanceof LoaderInterface) { |
|
| 226 | 226 | $this->loader = LoaderFactory::getLoader(); |
| 227 | 227 | } |
| 228 | 228 | return $this->loader; |
@@ -292,13 +292,13 @@ discard block |
||
| 292 | 292 | '</strong>', |
| 293 | 293 | '<a href="https://eventespresso.com/2017/08/important-upcoming-changes-dates-times">', |
| 294 | 294 | '</a>', |
| 295 | - '<a href="' . EE_Admin_Page::add_query_args_and_nonce( |
|
| 295 | + '<a href="'.EE_Admin_Page::add_query_args_and_nonce( |
|
| 296 | 296 | array( |
| 297 | 297 | 'page' => 'espresso_maintenance_settings', |
| 298 | 298 | 'action' => 'datetime_tools', |
| 299 | 299 | ), |
| 300 | 300 | admin_url('admin.php') |
| 301 | - ) . '">' |
|
| 301 | + ).'">' |
|
| 302 | 302 | ), |
| 303 | 303 | false, |
| 304 | 304 | 'manage_options', |
@@ -344,7 +344,7 @@ discard block |
||
| 344 | 344 | public function enable_hidden_ee_nav_menu_metaboxes() |
| 345 | 345 | { |
| 346 | 346 | global $wp_meta_boxes, $pagenow; |
| 347 | - if (! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 347 | + if ( ! is_array($wp_meta_boxes) || $pagenow !== 'nav-menus.php') { |
|
| 348 | 348 | return; |
| 349 | 349 | } |
| 350 | 350 | $user = wp_get_current_user(); |
@@ -373,7 +373,7 @@ discard block |
||
| 373 | 373 | if (is_array($hidden_meta_boxes)) { |
| 374 | 374 | foreach ($hidden_meta_boxes as $key => $meta_box_id) { |
| 375 | 375 | if (in_array($meta_box_id, $initial_meta_boxes, true)) { |
| 376 | - unset($hidden_meta_boxes[ $key ]); |
|
| 376 | + unset($hidden_meta_boxes[$key]); |
|
| 377 | 377 | } |
| 378 | 378 | } |
| 379 | 379 | } |
@@ -413,7 +413,7 @@ discard block |
||
| 413 | 413 | */ |
| 414 | 414 | public function modify_edit_post_link($link, $id) |
| 415 | 415 | { |
| 416 | - if (! $post = get_post($id)) { |
|
| 416 | + if ( ! $post = get_post($id)) { |
|
| 417 | 417 | return $link; |
| 418 | 418 | } |
| 419 | 419 | if ($post->post_type === 'espresso_attendees') { |
@@ -560,7 +560,7 @@ discard block |
||
| 560 | 560 | ); |
| 561 | 561 | |
| 562 | 562 | foreach ($keys as $key => $value) { |
| 563 | - $menu_item->{$key} = isset($menu_item_values[ $key ]) ? $menu_item_values[ $key ] : $value; |
|
| 563 | + $menu_item->{$key} = isset($menu_item_values[$key]) ? $menu_item_values[$key] : $value; |
|
| 564 | 564 | } |
| 565 | 565 | return $menu_item; |
| 566 | 566 | } |
@@ -591,7 +591,7 @@ discard block |
||
| 591 | 591 | $custom_post_types->getCustomPostTypeModels($_POST['post_type']); |
| 592 | 592 | } |
| 593 | 593 | |
| 594 | - if (! $this->request->isAjax()) { |
|
| 594 | + if ( ! $this->request->isAjax()) { |
|
| 595 | 595 | /** |
| 596 | 596 | * This code excludes EE critical pages anywhere `wp_dropdown_pages` is used to create a dropdown for selecting |
| 597 | 597 | * critical pages. The only place critical pages need included in a generated dropdown is on the "Critical |
@@ -636,10 +636,10 @@ discard block |
||
| 636 | 636 | |
| 637 | 637 | // loop through to remove any critical pages from the array. |
| 638 | 638 | foreach ($critical_pages as $page_id) { |
| 639 | - $needle = 'value="' . $page_id . '"'; |
|
| 639 | + $needle = 'value="'.$page_id.'"'; |
|
| 640 | 640 | foreach ($split_output as $key => $haystack) { |
| 641 | 641 | if (strpos($haystack, $needle) !== false) { |
| 642 | - unset($split_output[ $key ]); |
|
| 642 | + unset($split_output[$key]); |
|
| 643 | 643 | } |
| 644 | 644 | } |
| 645 | 645 | } |
@@ -705,7 +705,7 @@ discard block |
||
| 705 | 705 | |
| 706 | 706 | foreach ($items as $type => $item_properties) { |
| 707 | 707 | $elements[] = sprintf( |
| 708 | - '<a class="ee-dashboard-link-' . $type . '" href="%s" title="%s">%s</a>', |
|
| 708 | + '<a class="ee-dashboard-link-'.$type.'" href="%s" title="%s">%s</a>', |
|
| 709 | 709 | $item_properties['url'], |
| 710 | 710 | $item_properties['title'], |
| 711 | 711 | $item_properties['text'] |
@@ -729,10 +729,10 @@ discard block |
||
| 729 | 729 | // check for date_format or time_format |
| 730 | 730 | switch ($option) { |
| 731 | 731 | case 'date_format': |
| 732 | - $date_time_format = $value . ' ' . get_option('time_format'); |
|
| 732 | + $date_time_format = $value.' '.get_option('time_format'); |
|
| 733 | 733 | break; |
| 734 | 734 | case 'time_format': |
| 735 | - $date_time_format = get_option('date_format') . ' ' . $value; |
|
| 735 | + $date_time_format = get_option('date_format').' '.$value; |
|
| 736 | 736 | break; |
| 737 | 737 | default: |
| 738 | 738 | $date_time_format = false; |
@@ -755,7 +755,7 @@ discard block |
||
| 755 | 755 | |
| 756 | 756 | |
| 757 | 757 | foreach ($error_msg as $error) { |
| 758 | - $msg .= '<li>' . $error . '</li>'; |
|
| 758 | + $msg .= '<li>'.$error.'</li>'; |
|
| 759 | 759 | } |
| 760 | 760 | |
| 761 | 761 | $msg .= '</ul></p><p>' |
@@ -827,7 +827,7 @@ discard block |
||
| 827 | 827 | public function displayStateForCriticalPages($post_states, $post) |
| 828 | 828 | { |
| 829 | 829 | $post_states = (array) $post_states; |
| 830 | - if (! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
| 830 | + if ( ! $post instanceof WP_Post || $post->post_type !== 'page') { |
|
| 831 | 831 | return $post_states; |
| 832 | 832 | } |
| 833 | 833 | /** @var EE_Core_Config $config */ |
@@ -57,7 +57,7 @@ |
||
| 57 | 57 | |
| 58 | 58 | /** |
| 59 | 59 | * @param string $globalRouteCondition |
| 60 | - * @param mixed $default |
|
| 60 | + * @param boolean $default |
|
| 61 | 61 | * @return mixed |
| 62 | 62 | */ |
| 63 | 63 | private function getGlobalRouteCondition($globalRouteCondition, $default) |
@@ -18,197 +18,197 @@ |
||
| 18 | 18 | class RequestTypeContextDetector |
| 19 | 19 | { |
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @var RequestTypeContextFactoryInterface $factory |
|
| 23 | - */ |
|
| 24 | - private $factory; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * @var RequestInterface $request |
|
| 28 | - */ |
|
| 29 | - private $request; |
|
| 30 | - |
|
| 31 | - /** |
|
| 32 | - * @var array $globalRouteConditions |
|
| 33 | - */ |
|
| 34 | - private $globalRouteConditions; |
|
| 35 | - |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * RequestTypeContextDetector constructor. |
|
| 39 | - * |
|
| 40 | - * @param RequestInterface $request |
|
| 41 | - * @param RequestTypeContextFactoryInterface $factory |
|
| 42 | - * @param array $globalRouteConditions an array for injecting values that would |
|
| 43 | - * otherwise be defined as global constants |
|
| 44 | - * or other global variables for the current |
|
| 45 | - * request route such as DOING_AJAX |
|
| 46 | - */ |
|
| 47 | - public function __construct( |
|
| 48 | - RequestInterface $request, |
|
| 49 | - RequestTypeContextFactoryInterface $factory, |
|
| 50 | - array $globalRouteConditions = array() |
|
| 51 | - ) { |
|
| 52 | - $this->request = $request; |
|
| 53 | - $this->factory = $factory; |
|
| 54 | - $this->globalRouteConditions = $globalRouteConditions; |
|
| 55 | - } |
|
| 56 | - |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * @param string $globalRouteCondition |
|
| 60 | - * @param mixed $default |
|
| 61 | - * @return mixed |
|
| 62 | - */ |
|
| 63 | - private function getGlobalRouteCondition($globalRouteCondition, $default) |
|
| 64 | - { |
|
| 65 | - return isset($this->globalRouteConditions[ $globalRouteCondition ]) |
|
| 66 | - ? $this->globalRouteConditions[ $globalRouteCondition ] |
|
| 67 | - : $default; |
|
| 68 | - } |
|
| 69 | - |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * @return RequestTypeContext |
|
| 73 | - * @throws InvalidArgumentException |
|
| 74 | - */ |
|
| 75 | - public function detectRequestTypeContext() |
|
| 76 | - { |
|
| 77 | - // Detect error scrapes |
|
| 78 | - if ($this->request->getRequestParam('wp_scrape_key') !== null |
|
| 79 | - && $this->request->getRequestParam('wp_scrape_nonce') !== null |
|
| 80 | - ) { |
|
| 81 | - return $this->factory->create(RequestTypeContext::WP_SCRAPE); |
|
| 82 | - } |
|
| 83 | - // Detect EE REST API |
|
| 84 | - if ($this->isEspressoRestApiRequest()) { |
|
| 85 | - return $this->factory->create(RequestTypeContext::API); |
|
| 86 | - // Detect WP REST API |
|
| 87 | - } |
|
| 88 | - if ($this->isWordPressRestApiRequest()) { |
|
| 89 | - return $this->factory->create(RequestTypeContext::WP_API); |
|
| 90 | - } |
|
| 91 | - // Detect EE GraphQL |
|
| 92 | - if ($this->isEspressoGraphQLRequest()) { |
|
| 93 | - return $this->factory->create(RequestTypeContext::GQL); |
|
| 94 | - } |
|
| 95 | - // Detect AJAX |
|
| 96 | - if ($this->getGlobalRouteCondition('DOING_AJAX', false)) { |
|
| 97 | - if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 98 | - return $this->factory->create(RequestTypeContext::AJAX_FRONT); |
|
| 99 | - } |
|
| 100 | - if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 101 | - return $this->factory->create(RequestTypeContext::AJAX_ADMIN); |
|
| 102 | - } |
|
| 103 | - if ($this->request->getRequestParam('action') === 'heartbeat') { |
|
| 104 | - return $this->factory->create(RequestTypeContext::AJAX_HEARTBEAT); |
|
| 105 | - } |
|
| 106 | - return $this->factory->create(RequestTypeContext::AJAX_OTHER); |
|
| 107 | - } |
|
| 108 | - // Detect WP_Cron |
|
| 109 | - if ($this->isCronRequest()) { |
|
| 110 | - return $this->factory->create(RequestTypeContext::CRON); |
|
| 111 | - } |
|
| 112 | - // Detect command line requests |
|
| 113 | - if ($this->getGlobalRouteCondition('WP_CLI', false)) { |
|
| 114 | - return $this->factory->create(RequestTypeContext::CLI); |
|
| 115 | - } |
|
| 116 | - // detect WordPress admin (ie: "Dashboard") |
|
| 117 | - if ($this->getGlobalRouteCondition('is_admin', false)) { |
|
| 118 | - return $this->factory->create(RequestTypeContext::ADMIN); |
|
| 119 | - } |
|
| 120 | - // Detect iFrames |
|
| 121 | - if ($this->isIframeRoute()) { |
|
| 122 | - return $this->factory->create(RequestTypeContext::IFRAME); |
|
| 123 | - } |
|
| 124 | - // Detect Feeds |
|
| 125 | - if ($this->isFeedRequest()) { |
|
| 126 | - return $this->factory->create(RequestTypeContext::FEED); |
|
| 127 | - } |
|
| 128 | - // and by process of elimination... |
|
| 129 | - return $this->factory->create(RequestTypeContext::FRONTEND); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - |
|
| 133 | - /** |
|
| 134 | - * @return bool |
|
| 135 | - */ |
|
| 136 | - private function isEspressoRestApiRequest() |
|
| 137 | - { |
|
| 138 | - // Check for URLs like http://mysite.com/?rest_route=/ee... and http://mysite.com/wp-json/ee/... |
|
| 139 | - return strpos( |
|
| 140 | - $this->request->getRequestParam('rest_route', false), |
|
| 141 | - '/' . Domain::API_NAMESPACE |
|
| 142 | - ) === 0 |
|
| 143 | - || $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE); |
|
| 144 | - } |
|
| 145 | - |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * @return bool |
|
| 149 | - */ |
|
| 150 | - private function isEspressoGraphQLRequest() |
|
| 151 | - { |
|
| 152 | - // Check for URLs like https://mysite.com/graphql |
|
| 153 | - return $this->uriPathMatches(RequestTypeContext::GQL); |
|
| 154 | - } |
|
| 155 | - |
|
| 156 | - |
|
| 157 | - |
|
| 158 | - /** |
|
| 159 | - * @return bool |
|
| 160 | - */ |
|
| 161 | - private function isWordPressRestApiRequest() |
|
| 162 | - { |
|
| 163 | - // Check for URLs like http://mysite.com/?rest_route=/.. and http://mysite.com/wp-json/... |
|
| 164 | - return $this->request->getRequestParam('rest_route', false) |
|
| 165 | - || $this->uriPathMatches(trim(rest_get_url_prefix(), '/')); |
|
| 166 | - } |
|
| 167 | - |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * @return bool |
|
| 171 | - */ |
|
| 172 | - private function isCronRequest() |
|
| 173 | - { |
|
| 174 | - return $this->uriPathMatches('wp-cron.php'); |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - |
|
| 178 | - /** |
|
| 179 | - * @return bool |
|
| 180 | - */ |
|
| 181 | - private function isFeedRequest() |
|
| 182 | - { |
|
| 183 | - return $this->uriPathMatches('feed'); |
|
| 184 | - } |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - /** |
|
| 188 | - * @param string $component |
|
| 189 | - * @return bool |
|
| 190 | - */ |
|
| 191 | - private function uriPathMatches($component) |
|
| 192 | - { |
|
| 193 | - $request_uri = $this->request->requestUri(true); |
|
| 194 | - $parts = explode('?', $request_uri); |
|
| 195 | - $path = trim(reset($parts), '/'); |
|
| 196 | - return strpos($path, $component) === 0; |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * @return bool |
|
| 202 | - */ |
|
| 203 | - private function isIframeRoute() |
|
| 204 | - { |
|
| 205 | - $is_iframe_route = apply_filters( |
|
| 206 | - 'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute', |
|
| 207 | - $this->request->getRequestParam('event_list', '') === 'iframe' |
|
| 208 | - || $this->request->getRequestParam('ticket_selector', '') === 'iframe' |
|
| 209 | - || $this->request->getRequestParam('calendar', '') === 'iframe', |
|
| 210 | - $this |
|
| 211 | - ); |
|
| 212 | - return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN); |
|
| 213 | - } |
|
| 21 | + /** |
|
| 22 | + * @var RequestTypeContextFactoryInterface $factory |
|
| 23 | + */ |
|
| 24 | + private $factory; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * @var RequestInterface $request |
|
| 28 | + */ |
|
| 29 | + private $request; |
|
| 30 | + |
|
| 31 | + /** |
|
| 32 | + * @var array $globalRouteConditions |
|
| 33 | + */ |
|
| 34 | + private $globalRouteConditions; |
|
| 35 | + |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * RequestTypeContextDetector constructor. |
|
| 39 | + * |
|
| 40 | + * @param RequestInterface $request |
|
| 41 | + * @param RequestTypeContextFactoryInterface $factory |
|
| 42 | + * @param array $globalRouteConditions an array for injecting values that would |
|
| 43 | + * otherwise be defined as global constants |
|
| 44 | + * or other global variables for the current |
|
| 45 | + * request route such as DOING_AJAX |
|
| 46 | + */ |
|
| 47 | + public function __construct( |
|
| 48 | + RequestInterface $request, |
|
| 49 | + RequestTypeContextFactoryInterface $factory, |
|
| 50 | + array $globalRouteConditions = array() |
|
| 51 | + ) { |
|
| 52 | + $this->request = $request; |
|
| 53 | + $this->factory = $factory; |
|
| 54 | + $this->globalRouteConditions = $globalRouteConditions; |
|
| 55 | + } |
|
| 56 | + |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * @param string $globalRouteCondition |
|
| 60 | + * @param mixed $default |
|
| 61 | + * @return mixed |
|
| 62 | + */ |
|
| 63 | + private function getGlobalRouteCondition($globalRouteCondition, $default) |
|
| 64 | + { |
|
| 65 | + return isset($this->globalRouteConditions[ $globalRouteCondition ]) |
|
| 66 | + ? $this->globalRouteConditions[ $globalRouteCondition ] |
|
| 67 | + : $default; |
|
| 68 | + } |
|
| 69 | + |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * @return RequestTypeContext |
|
| 73 | + * @throws InvalidArgumentException |
|
| 74 | + */ |
|
| 75 | + public function detectRequestTypeContext() |
|
| 76 | + { |
|
| 77 | + // Detect error scrapes |
|
| 78 | + if ($this->request->getRequestParam('wp_scrape_key') !== null |
|
| 79 | + && $this->request->getRequestParam('wp_scrape_nonce') !== null |
|
| 80 | + ) { |
|
| 81 | + return $this->factory->create(RequestTypeContext::WP_SCRAPE); |
|
| 82 | + } |
|
| 83 | + // Detect EE REST API |
|
| 84 | + if ($this->isEspressoRestApiRequest()) { |
|
| 85 | + return $this->factory->create(RequestTypeContext::API); |
|
| 86 | + // Detect WP REST API |
|
| 87 | + } |
|
| 88 | + if ($this->isWordPressRestApiRequest()) { |
|
| 89 | + return $this->factory->create(RequestTypeContext::WP_API); |
|
| 90 | + } |
|
| 91 | + // Detect EE GraphQL |
|
| 92 | + if ($this->isEspressoGraphQLRequest()) { |
|
| 93 | + return $this->factory->create(RequestTypeContext::GQL); |
|
| 94 | + } |
|
| 95 | + // Detect AJAX |
|
| 96 | + if ($this->getGlobalRouteCondition('DOING_AJAX', false)) { |
|
| 97 | + if (filter_var($this->request->getRequestParam('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 98 | + return $this->factory->create(RequestTypeContext::AJAX_FRONT); |
|
| 99 | + } |
|
| 100 | + if (filter_var($this->request->getRequestParam('ee_admin_ajax'), FILTER_VALIDATE_BOOLEAN)) { |
|
| 101 | + return $this->factory->create(RequestTypeContext::AJAX_ADMIN); |
|
| 102 | + } |
|
| 103 | + if ($this->request->getRequestParam('action') === 'heartbeat') { |
|
| 104 | + return $this->factory->create(RequestTypeContext::AJAX_HEARTBEAT); |
|
| 105 | + } |
|
| 106 | + return $this->factory->create(RequestTypeContext::AJAX_OTHER); |
|
| 107 | + } |
|
| 108 | + // Detect WP_Cron |
|
| 109 | + if ($this->isCronRequest()) { |
|
| 110 | + return $this->factory->create(RequestTypeContext::CRON); |
|
| 111 | + } |
|
| 112 | + // Detect command line requests |
|
| 113 | + if ($this->getGlobalRouteCondition('WP_CLI', false)) { |
|
| 114 | + return $this->factory->create(RequestTypeContext::CLI); |
|
| 115 | + } |
|
| 116 | + // detect WordPress admin (ie: "Dashboard") |
|
| 117 | + if ($this->getGlobalRouteCondition('is_admin', false)) { |
|
| 118 | + return $this->factory->create(RequestTypeContext::ADMIN); |
|
| 119 | + } |
|
| 120 | + // Detect iFrames |
|
| 121 | + if ($this->isIframeRoute()) { |
|
| 122 | + return $this->factory->create(RequestTypeContext::IFRAME); |
|
| 123 | + } |
|
| 124 | + // Detect Feeds |
|
| 125 | + if ($this->isFeedRequest()) { |
|
| 126 | + return $this->factory->create(RequestTypeContext::FEED); |
|
| 127 | + } |
|
| 128 | + // and by process of elimination... |
|
| 129 | + return $this->factory->create(RequestTypeContext::FRONTEND); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + |
|
| 133 | + /** |
|
| 134 | + * @return bool |
|
| 135 | + */ |
|
| 136 | + private function isEspressoRestApiRequest() |
|
| 137 | + { |
|
| 138 | + // Check for URLs like http://mysite.com/?rest_route=/ee... and http://mysite.com/wp-json/ee/... |
|
| 139 | + return strpos( |
|
| 140 | + $this->request->getRequestParam('rest_route', false), |
|
| 141 | + '/' . Domain::API_NAMESPACE |
|
| 142 | + ) === 0 |
|
| 143 | + || $this->uriPathMatches(trim(rest_get_url_prefix(), '/') . '/' . Domain::API_NAMESPACE); |
|
| 144 | + } |
|
| 145 | + |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * @return bool |
|
| 149 | + */ |
|
| 150 | + private function isEspressoGraphQLRequest() |
|
| 151 | + { |
|
| 152 | + // Check for URLs like https://mysite.com/graphql |
|
| 153 | + return $this->uriPathMatches(RequestTypeContext::GQL); |
|
| 154 | + } |
|
| 155 | + |
|
| 156 | + |
|
| 157 | + |
|
| 158 | + /** |
|
| 159 | + * @return bool |
|
| 160 | + */ |
|
| 161 | + private function isWordPressRestApiRequest() |
|
| 162 | + { |
|
| 163 | + // Check for URLs like http://mysite.com/?rest_route=/.. and http://mysite.com/wp-json/... |
|
| 164 | + return $this->request->getRequestParam('rest_route', false) |
|
| 165 | + || $this->uriPathMatches(trim(rest_get_url_prefix(), '/')); |
|
| 166 | + } |
|
| 167 | + |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * @return bool |
|
| 171 | + */ |
|
| 172 | + private function isCronRequest() |
|
| 173 | + { |
|
| 174 | + return $this->uriPathMatches('wp-cron.php'); |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + |
|
| 178 | + /** |
|
| 179 | + * @return bool |
|
| 180 | + */ |
|
| 181 | + private function isFeedRequest() |
|
| 182 | + { |
|
| 183 | + return $this->uriPathMatches('feed'); |
|
| 184 | + } |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + /** |
|
| 188 | + * @param string $component |
|
| 189 | + * @return bool |
|
| 190 | + */ |
|
| 191 | + private function uriPathMatches($component) |
|
| 192 | + { |
|
| 193 | + $request_uri = $this->request->requestUri(true); |
|
| 194 | + $parts = explode('?', $request_uri); |
|
| 195 | + $path = trim(reset($parts), '/'); |
|
| 196 | + return strpos($path, $component) === 0; |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * @return bool |
|
| 202 | + */ |
|
| 203 | + private function isIframeRoute() |
|
| 204 | + { |
|
| 205 | + $is_iframe_route = apply_filters( |
|
| 206 | + 'FHEE__EventEspresso_core_domain_services_contexts_RequestTypeContextDetector__isIframeRoute', |
|
| 207 | + $this->request->getRequestParam('event_list', '') === 'iframe' |
|
| 208 | + || $this->request->getRequestParam('ticket_selector', '') === 'iframe' |
|
| 209 | + || $this->request->getRequestParam('calendar', '') === 'iframe', |
|
| 210 | + $this |
|
| 211 | + ); |
|
| 212 | + return filter_var($is_iframe_route, FILTER_VALIDATE_BOOLEAN); |
|
| 213 | + } |
|
| 214 | 214 | } |
@@ -16,7 +16,6 @@ |
||
| 16 | 16 | use EventEspresso\core\services\loaders\LoaderInterface; |
| 17 | 17 | use EventEspresso\core\services\request\RequestInterface; |
| 18 | 18 | use EventEspresso\core\services\route_match\RouteHandler; |
| 19 | -use EventEspresso\core\services\route_match\RouteMatchSpecificationManager; |
|
| 20 | 19 | |
| 21 | 20 | /** |
| 22 | 21 | * EE_System |
@@ -29,1253 +29,1253 @@ |
||
| 29 | 29 | final class EE_System implements ResettableInterface |
| 30 | 30 | { |
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
| 34 | - * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
| 35 | - */ |
|
| 36 | - const req_type_normal = 0; |
|
| 37 | - |
|
| 38 | - /** |
|
| 39 | - * Indicates this is a brand new installation of EE so we should install |
|
| 40 | - * tables and default data etc |
|
| 41 | - */ |
|
| 42 | - const req_type_new_activation = 1; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
| 46 | - * and we just exited maintenance mode). We MUST check the database is setup properly |
|
| 47 | - * and that default data is setup too |
|
| 48 | - */ |
|
| 49 | - const req_type_reactivation = 2; |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * indicates that EE has been upgraded since its previous request. |
|
| 53 | - * We may have data migration scripts to call and will want to trigger maintenance mode |
|
| 54 | - */ |
|
| 55 | - const req_type_upgrade = 3; |
|
| 56 | - |
|
| 57 | - /** |
|
| 58 | - * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
| 59 | - */ |
|
| 60 | - const req_type_downgrade = 4; |
|
| 61 | - |
|
| 62 | - /** |
|
| 63 | - * @deprecated since version 4.6.0.dev.006 |
|
| 64 | - * Now whenever a new_activation is detected the request type is still just |
|
| 65 | - * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
| 66 | - * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
| 67 | - * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
| 68 | - * (Specifically, when the migration manager indicates migrations are finished |
|
| 69 | - * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
| 70 | - */ |
|
| 71 | - const req_type_activation_but_not_installed = 5; |
|
| 72 | - |
|
| 73 | - /** |
|
| 74 | - * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
| 75 | - */ |
|
| 76 | - const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * @var EE_System $_instance |
|
| 80 | - */ |
|
| 81 | - private static $_instance; |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * @var EE_Registry $registry |
|
| 85 | - */ |
|
| 86 | - private $registry; |
|
| 87 | - |
|
| 88 | - /** |
|
| 89 | - * @var LoaderInterface $loader |
|
| 90 | - */ |
|
| 91 | - private $loader; |
|
| 92 | - |
|
| 93 | - /** |
|
| 94 | - * @var EE_Capabilities $capabilities |
|
| 95 | - */ |
|
| 96 | - private $capabilities; |
|
| 97 | - |
|
| 98 | - /** |
|
| 99 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
| 100 | - */ |
|
| 101 | - private $maintenance_mode; |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @var RequestInterface $request |
|
| 105 | - */ |
|
| 106 | - private $request; |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
| 110 | - * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
| 111 | - * |
|
| 112 | - * @var int $_req_type |
|
| 113 | - */ |
|
| 114 | - private $_req_type; |
|
| 115 | - |
|
| 116 | - |
|
| 117 | - /** |
|
| 118 | - * @var RouteHandler $router |
|
| 119 | - */ |
|
| 120 | - private $router; |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * Whether or not there was a non-micro version change in EE core version during this request |
|
| 124 | - * |
|
| 125 | - * @var boolean $_major_version_change |
|
| 126 | - */ |
|
| 127 | - private $_major_version_change = false; |
|
| 128 | - |
|
| 129 | - /** |
|
| 130 | - * A Context DTO dedicated solely to identifying the current request type. |
|
| 131 | - * |
|
| 132 | - * @var RequestTypeContextCheckerInterface $request_type |
|
| 133 | - */ |
|
| 134 | - private $request_type; |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @singleton method used to instantiate class object |
|
| 139 | - * @param EE_Registry|null $registry |
|
| 140 | - * @param LoaderInterface|null $loader |
|
| 141 | - * @param RequestInterface|null $request |
|
| 142 | - * @param EE_Maintenance_Mode|null $maintenance_mode |
|
| 143 | - * @return EE_System |
|
| 144 | - */ |
|
| 145 | - public static function instance( |
|
| 146 | - EE_Registry $registry = null, |
|
| 147 | - LoaderInterface $loader = null, |
|
| 148 | - RequestInterface $request = null, |
|
| 149 | - EE_Maintenance_Mode $maintenance_mode = null |
|
| 150 | - ) { |
|
| 151 | - // check if class object is instantiated |
|
| 152 | - if (! self::$_instance instanceof EE_System) { |
|
| 153 | - self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
| 154 | - } |
|
| 155 | - return self::$_instance; |
|
| 156 | - } |
|
| 157 | - |
|
| 158 | - |
|
| 159 | - /** |
|
| 160 | - * resets the instance and returns it |
|
| 161 | - * |
|
| 162 | - * @return EE_System |
|
| 163 | - */ |
|
| 164 | - public static function reset() |
|
| 165 | - { |
|
| 166 | - self::$_instance->_req_type = null; |
|
| 167 | - // make sure none of the old hooks are left hanging around |
|
| 168 | - remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 169 | - // we need to reset the migration manager in order for it to detect DMSs properly |
|
| 170 | - EE_Data_Migration_Manager::reset(); |
|
| 171 | - self::instance()->detect_activations_or_upgrades(); |
|
| 172 | - self::instance()->perform_activations_upgrades_and_migrations(); |
|
| 173 | - return self::instance(); |
|
| 174 | - } |
|
| 175 | - |
|
| 176 | - |
|
| 177 | - /** |
|
| 178 | - * sets hooks for running rest of system |
|
| 179 | - * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 180 | - * starting EE Addons from any other point may lead to problems |
|
| 181 | - * |
|
| 182 | - * @param EE_Registry $registry |
|
| 183 | - * @param LoaderInterface $loader |
|
| 184 | - * @param RequestInterface $request |
|
| 185 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
| 186 | - */ |
|
| 187 | - private function __construct( |
|
| 188 | - EE_Registry $registry, |
|
| 189 | - LoaderInterface $loader, |
|
| 190 | - RequestInterface $request, |
|
| 191 | - EE_Maintenance_Mode $maintenance_mode |
|
| 192 | - ) { |
|
| 193 | - $this->registry = $registry; |
|
| 194 | - $this->loader = $loader; |
|
| 195 | - $this->request = $request; |
|
| 196 | - $this->maintenance_mode = $maintenance_mode; |
|
| 197 | - do_action('AHEE__EE_System__construct__begin', $this); |
|
| 198 | - add_action( |
|
| 199 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 200 | - array($this, 'loadCapabilities'), |
|
| 201 | - 5 |
|
| 202 | - ); |
|
| 203 | - add_action( |
|
| 204 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 205 | - array($this, 'loadCommandBus'), |
|
| 206 | - 7 |
|
| 207 | - ); |
|
| 208 | - add_action( |
|
| 209 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 210 | - array($this, 'loadPluginApi'), |
|
| 211 | - 9 |
|
| 212 | - ); |
|
| 213 | - // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
| 214 | - add_action( |
|
| 215 | - 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 216 | - array($this, 'load_espresso_addons') |
|
| 217 | - ); |
|
| 218 | - // when an ee addon is activated, we want to call the core hook(s) again |
|
| 219 | - // because the newly-activated addon didn't get a chance to run at all |
|
| 220 | - add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
| 221 | - // detect whether install or upgrade |
|
| 222 | - add_action( |
|
| 223 | - 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
| 224 | - array($this, 'detect_activations_or_upgrades'), |
|
| 225 | - 3 |
|
| 226 | - ); |
|
| 227 | - // load EE_Config, EE_Textdomain, etc |
|
| 228 | - add_action( |
|
| 229 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 230 | - array($this, 'load_core_configuration'), |
|
| 231 | - 5 |
|
| 232 | - ); |
|
| 233 | - // load specifications for matching routes to current request |
|
| 234 | - add_action( |
|
| 235 | - 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 236 | - array($this, 'loadRouteMatchSpecifications') |
|
| 237 | - ); |
|
| 238 | - // load EE_Config, EE_Textdomain, etc |
|
| 239 | - add_action( |
|
| 240 | - 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
| 241 | - array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 242 | - 7 |
|
| 243 | - ); |
|
| 244 | - // you wanna get going? I wanna get going... let's get going! |
|
| 245 | - add_action( |
|
| 246 | - 'AHEE__EE_Bootstrap__brew_espresso', |
|
| 247 | - array($this, 'brew_espresso'), |
|
| 248 | - 9 |
|
| 249 | - ); |
|
| 250 | - // other housekeeping |
|
| 251 | - // exclude EE critical pages from wp_list_pages |
|
| 252 | - add_filter( |
|
| 253 | - 'wp_list_pages_excludes', |
|
| 254 | - array($this, 'remove_pages_from_wp_list_pages'), |
|
| 255 | - 10 |
|
| 256 | - ); |
|
| 257 | - // ALL EE Addons should use the following hook point to attach their initial setup too |
|
| 258 | - // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
| 259 | - do_action('AHEE__EE_System__construct__complete', $this); |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * load and setup EE_Capabilities |
|
| 265 | - * |
|
| 266 | - * @return void |
|
| 267 | - */ |
|
| 268 | - public function loadCapabilities() |
|
| 269 | - { |
|
| 270 | - $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
| 271 | - add_action( |
|
| 272 | - 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
| 273 | - function () { |
|
| 274 | - LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 275 | - } |
|
| 276 | - ); |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * create and cache the CommandBus, and also add middleware |
|
| 282 | - * The CapChecker middleware requires the use of EE_Capabilities |
|
| 283 | - * which is why we need to load the CommandBus after Caps are set up |
|
| 284 | - * |
|
| 285 | - * @return void |
|
| 286 | - */ |
|
| 287 | - public function loadCommandBus() |
|
| 288 | - { |
|
| 289 | - $this->loader->getShared( |
|
| 290 | - 'CommandBusInterface', |
|
| 291 | - array( |
|
| 292 | - null, |
|
| 293 | - apply_filters( |
|
| 294 | - 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 295 | - array( |
|
| 296 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
| 297 | - $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
| 298 | - ) |
|
| 299 | - ), |
|
| 300 | - ) |
|
| 301 | - ); |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - |
|
| 305 | - /** |
|
| 306 | - * @return void |
|
| 307 | - * @throws EE_Error |
|
| 308 | - */ |
|
| 309 | - public function loadPluginApi() |
|
| 310 | - { |
|
| 311 | - // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
| 312 | - // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
| 313 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 314 | - $this->loader->getShared('EE_Request_Handler'); |
|
| 315 | - } |
|
| 316 | - |
|
| 317 | - |
|
| 318 | - /** |
|
| 319 | - * @param string $addon_name |
|
| 320 | - * @param string $version_constant |
|
| 321 | - * @param string $min_version_required |
|
| 322 | - * @param string $load_callback |
|
| 323 | - * @param string $plugin_file_constant |
|
| 324 | - * @return void |
|
| 325 | - */ |
|
| 326 | - private function deactivateIncompatibleAddon( |
|
| 327 | - $addon_name, |
|
| 328 | - $version_constant, |
|
| 329 | - $min_version_required, |
|
| 330 | - $load_callback, |
|
| 331 | - $plugin_file_constant |
|
| 332 | - ) { |
|
| 333 | - if (! defined($version_constant)) { |
|
| 334 | - return; |
|
| 335 | - } |
|
| 336 | - $addon_version = constant($version_constant); |
|
| 337 | - if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
| 338 | - remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
| 339 | - if (! function_exists('deactivate_plugins')) { |
|
| 340 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 341 | - } |
|
| 342 | - deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
| 343 | - unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
|
| 344 | - EE_Error::add_error( |
|
| 345 | - sprintf( |
|
| 346 | - esc_html__( |
|
| 347 | - 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
| 348 | - 'event_espresso' |
|
| 349 | - ), |
|
| 350 | - $addon_name, |
|
| 351 | - $min_version_required |
|
| 352 | - ), |
|
| 353 | - __FILE__, |
|
| 354 | - __FUNCTION__ . "({$addon_name})", |
|
| 355 | - __LINE__ |
|
| 356 | - ); |
|
| 357 | - EE_Error::get_notices(false, true); |
|
| 358 | - } |
|
| 359 | - } |
|
| 360 | - |
|
| 361 | - |
|
| 362 | - /** |
|
| 363 | - * load_espresso_addons |
|
| 364 | - * allow addons to load first so that they can set hooks for running DMS's, etc |
|
| 365 | - * this is hooked into both: |
|
| 366 | - * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 367 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 368 | - * and the WP 'activate_plugin' hook point |
|
| 369 | - * |
|
| 370 | - * @access public |
|
| 371 | - * @return void |
|
| 372 | - */ |
|
| 373 | - public function load_espresso_addons() |
|
| 374 | - { |
|
| 375 | - $this->deactivateIncompatibleAddon( |
|
| 376 | - 'Wait Lists', |
|
| 377 | - 'EE_WAIT_LISTS_VERSION', |
|
| 378 | - '1.0.0.beta.074', |
|
| 379 | - 'load_espresso_wait_lists', |
|
| 380 | - 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
| 381 | - ); |
|
| 382 | - $this->deactivateIncompatibleAddon( |
|
| 383 | - 'Automated Upcoming Event Notifications', |
|
| 384 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
| 385 | - '1.0.0.beta.091', |
|
| 386 | - 'load_espresso_automated_upcoming_event_notification', |
|
| 387 | - 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
| 388 | - ); |
|
| 389 | - do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 390 | - // if the WP API basic auth plugin isn't already loaded, load it now. |
|
| 391 | - // We want it for mobile apps. Just include the entire plugin |
|
| 392 | - // also, don't load the basic auth when a plugin is getting activated, because |
|
| 393 | - // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
| 394 | - // and causes a fatal error |
|
| 395 | - if (($this->request->isWordPressApi() || $this->request->isApi()) |
|
| 396 | - && $this->request->getRequestParam('activate') !== 'true' |
|
| 397 | - && ! function_exists('json_basic_auth_handler') |
|
| 398 | - && ! function_exists('json_basic_auth_error') |
|
| 399 | - && ! in_array( |
|
| 400 | - $this->request->getRequestParam('action'), |
|
| 401 | - array('activate', 'activate-selected'), |
|
| 402 | - true |
|
| 403 | - ) |
|
| 404 | - ) { |
|
| 405 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
| 406 | - } |
|
| 407 | - do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
| 408 | - } |
|
| 409 | - |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * detect_activations_or_upgrades |
|
| 413 | - * Checks for activation or upgrade of core first; |
|
| 414 | - * then also checks if any registered addons have been activated or upgraded |
|
| 415 | - * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
| 416 | - * which runs during the WP 'plugins_loaded' action at priority 3 |
|
| 417 | - * |
|
| 418 | - * @access public |
|
| 419 | - * @return void |
|
| 420 | - */ |
|
| 421 | - public function detect_activations_or_upgrades() |
|
| 422 | - { |
|
| 423 | - // first off: let's make sure to handle core |
|
| 424 | - $this->detect_if_activation_or_upgrade(); |
|
| 425 | - foreach ($this->registry->addons as $addon) { |
|
| 426 | - if ($addon instanceof EE_Addon) { |
|
| 427 | - // detect teh request type for that addon |
|
| 428 | - $addon->detect_activation_or_upgrade(); |
|
| 429 | - } |
|
| 430 | - } |
|
| 431 | - } |
|
| 432 | - |
|
| 433 | - |
|
| 434 | - /** |
|
| 435 | - * detect_if_activation_or_upgrade |
|
| 436 | - * Takes care of detecting whether this is a brand new install or code upgrade, |
|
| 437 | - * and either setting up the DB or setting up maintenance mode etc. |
|
| 438 | - * |
|
| 439 | - * @access public |
|
| 440 | - * @return void |
|
| 441 | - */ |
|
| 442 | - public function detect_if_activation_or_upgrade() |
|
| 443 | - { |
|
| 444 | - do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
| 445 | - // check if db has been updated, or if its a brand-new installation |
|
| 446 | - $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
| 447 | - $request_type = $this->detect_req_type($espresso_db_update); |
|
| 448 | - // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
| 449 | - switch ($request_type) { |
|
| 450 | - case EE_System::req_type_new_activation: |
|
| 451 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
| 452 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 453 | - break; |
|
| 454 | - case EE_System::req_type_reactivation: |
|
| 455 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
| 456 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 457 | - break; |
|
| 458 | - case EE_System::req_type_upgrade: |
|
| 459 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
| 460 | - // migrations may be required now that we've upgraded |
|
| 461 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 462 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 463 | - break; |
|
| 464 | - case EE_System::req_type_downgrade: |
|
| 465 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
| 466 | - // its possible migrations are no longer required |
|
| 467 | - $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 468 | - $this->_handle_core_version_change($espresso_db_update); |
|
| 469 | - break; |
|
| 470 | - case EE_System::req_type_normal: |
|
| 471 | - default: |
|
| 472 | - break; |
|
| 473 | - } |
|
| 474 | - do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
| 475 | - } |
|
| 476 | - |
|
| 477 | - |
|
| 478 | - /** |
|
| 479 | - * Updates the list of installed versions and sets hooks for |
|
| 480 | - * initializing the database later during the request |
|
| 481 | - * |
|
| 482 | - * @param array $espresso_db_update |
|
| 483 | - */ |
|
| 484 | - private function _handle_core_version_change($espresso_db_update) |
|
| 485 | - { |
|
| 486 | - $this->update_list_of_installed_versions($espresso_db_update); |
|
| 487 | - // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
| 488 | - add_action( |
|
| 489 | - 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 490 | - array($this, 'initialize_db_if_no_migrations_required') |
|
| 491 | - ); |
|
| 492 | - } |
|
| 493 | - |
|
| 494 | - |
|
| 495 | - /** |
|
| 496 | - * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
| 497 | - * information about what versions of EE have been installed and activated, |
|
| 498 | - * NOT necessarily the state of the database |
|
| 499 | - * |
|
| 500 | - * @param mixed $espresso_db_update the value of the WordPress option. |
|
| 501 | - * If not supplied, fetches it from the options table |
|
| 502 | - * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
| 503 | - */ |
|
| 504 | - private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
| 505 | - { |
|
| 506 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
| 507 | - if (! $espresso_db_update) { |
|
| 508 | - $espresso_db_update = get_option('espresso_db_update'); |
|
| 509 | - } |
|
| 510 | - // check that option is an array |
|
| 511 | - if (! is_array($espresso_db_update)) { |
|
| 512 | - // if option is FALSE, then it never existed |
|
| 513 | - if ($espresso_db_update === false) { |
|
| 514 | - // make $espresso_db_update an array and save option with autoload OFF |
|
| 515 | - $espresso_db_update = array(); |
|
| 516 | - add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
| 517 | - } else { |
|
| 518 | - // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
| 519 | - $espresso_db_update = array($espresso_db_update => array()); |
|
| 520 | - update_option('espresso_db_update', $espresso_db_update); |
|
| 521 | - } |
|
| 522 | - } else { |
|
| 523 | - $corrected_db_update = array(); |
|
| 524 | - // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
| 525 | - foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
| 526 | - if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
| 527 | - // the key is an int, and the value IS NOT an array |
|
| 528 | - // so it must be numerically-indexed, where values are versions installed... |
|
| 529 | - // fix it! |
|
| 530 | - $version_string = $should_be_array; |
|
| 531 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
| 532 | - } else { |
|
| 533 | - // ok it checks out |
|
| 534 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
| 535 | - } |
|
| 536 | - } |
|
| 537 | - $espresso_db_update = $corrected_db_update; |
|
| 538 | - update_option('espresso_db_update', $espresso_db_update); |
|
| 539 | - } |
|
| 540 | - do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
| 541 | - return $espresso_db_update; |
|
| 542 | - } |
|
| 543 | - |
|
| 544 | - |
|
| 545 | - /** |
|
| 546 | - * Does the traditional work of setting up the plugin's database and adding default data. |
|
| 547 | - * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
| 548 | - * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
| 549 | - * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
| 550 | - * so that it will be done when migrations are finished |
|
| 551 | - * |
|
| 552 | - * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
| 553 | - * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
| 554 | - * This is a resource-intensive job |
|
| 555 | - * so we prefer to only do it when necessary |
|
| 556 | - * @return void |
|
| 557 | - * @throws EE_Error |
|
| 558 | - */ |
|
| 559 | - public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
| 560 | - { |
|
| 561 | - $request_type = $this->detect_req_type(); |
|
| 562 | - // only initialize system if we're not in maintenance mode. |
|
| 563 | - if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 564 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
| 565 | - $rewrite_rules = $this->loader->getShared( |
|
| 566 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
| 567 | - ); |
|
| 568 | - $rewrite_rules->flush(); |
|
| 569 | - if ($verify_schema) { |
|
| 570 | - EEH_Activation::initialize_db_and_folders(); |
|
| 571 | - } |
|
| 572 | - EEH_Activation::initialize_db_content(); |
|
| 573 | - EEH_Activation::system_initialization(); |
|
| 574 | - if ($initialize_addons_too) { |
|
| 575 | - $this->initialize_addons(); |
|
| 576 | - } |
|
| 577 | - } else { |
|
| 578 | - EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
| 579 | - } |
|
| 580 | - if ($request_type === EE_System::req_type_new_activation |
|
| 581 | - || $request_type === EE_System::req_type_reactivation |
|
| 582 | - || ( |
|
| 583 | - $request_type === EE_System::req_type_upgrade |
|
| 584 | - && $this->is_major_version_change() |
|
| 585 | - ) |
|
| 586 | - ) { |
|
| 587 | - add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
| 588 | - } |
|
| 589 | - } |
|
| 590 | - |
|
| 591 | - |
|
| 592 | - /** |
|
| 593 | - * Initializes the db for all registered addons |
|
| 594 | - * |
|
| 595 | - * @throws EE_Error |
|
| 596 | - */ |
|
| 597 | - public function initialize_addons() |
|
| 598 | - { |
|
| 599 | - // foreach registered addon, make sure its db is up-to-date too |
|
| 600 | - foreach ($this->registry->addons as $addon) { |
|
| 601 | - if ($addon instanceof EE_Addon) { |
|
| 602 | - $addon->initialize_db_if_no_migrations_required(); |
|
| 603 | - } |
|
| 604 | - } |
|
| 605 | - } |
|
| 606 | - |
|
| 607 | - |
|
| 608 | - /** |
|
| 609 | - * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
| 610 | - * |
|
| 611 | - * @param array $version_history |
|
| 612 | - * @param string $current_version_to_add version to be added to the version history |
|
| 613 | - * @return boolean success as to whether or not this option was changed |
|
| 614 | - */ |
|
| 615 | - public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 616 | - { |
|
| 617 | - if (! $version_history) { |
|
| 618 | - $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
| 619 | - } |
|
| 620 | - if ($current_version_to_add === null) { |
|
| 621 | - $current_version_to_add = espresso_version(); |
|
| 622 | - } |
|
| 623 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
| 624 | - // re-save |
|
| 625 | - return update_option('espresso_db_update', $version_history); |
|
| 626 | - } |
|
| 627 | - |
|
| 628 | - |
|
| 629 | - /** |
|
| 630 | - * Detects if the current version indicated in the has existed in the list of |
|
| 631 | - * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
| 632 | - * |
|
| 633 | - * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
| 634 | - * If not supplied, fetches it from the options table. |
|
| 635 | - * Also, caches its result so later parts of the code can also know whether |
|
| 636 | - * there's been an update or not. This way we can add the current version to |
|
| 637 | - * espresso_db_update, but still know if this is a new install or not |
|
| 638 | - * @return int one of the constants on EE_System::req_type_ |
|
| 639 | - */ |
|
| 640 | - public function detect_req_type($espresso_db_update = null) |
|
| 641 | - { |
|
| 642 | - if ($this->_req_type === null) { |
|
| 643 | - $espresso_db_update = ! empty($espresso_db_update) |
|
| 644 | - ? $espresso_db_update |
|
| 645 | - : $this->fix_espresso_db_upgrade_option(); |
|
| 646 | - $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
| 647 | - $espresso_db_update, |
|
| 648 | - 'ee_espresso_activation', |
|
| 649 | - espresso_version() |
|
| 650 | - ); |
|
| 651 | - $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
| 652 | - $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
| 653 | - } |
|
| 654 | - return $this->_req_type; |
|
| 655 | - } |
|
| 656 | - |
|
| 657 | - |
|
| 658 | - /** |
|
| 659 | - * Returns whether or not there was a non-micro version change (ie, change in either |
|
| 660 | - * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
| 661 | - * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
| 662 | - * |
|
| 663 | - * @param $activation_history |
|
| 664 | - * @return bool |
|
| 665 | - */ |
|
| 666 | - private function _detect_major_version_change($activation_history) |
|
| 667 | - { |
|
| 668 | - $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
| 669 | - $previous_version_parts = explode('.', $previous_version); |
|
| 670 | - $current_version_parts = explode('.', espresso_version()); |
|
| 671 | - return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
| 672 | - && ( |
|
| 673 | - $previous_version_parts[0] !== $current_version_parts[0] |
|
| 674 | - || $previous_version_parts[1] !== $current_version_parts[1] |
|
| 675 | - ); |
|
| 676 | - } |
|
| 677 | - |
|
| 678 | - |
|
| 679 | - /** |
|
| 680 | - * Returns true if either the major or minor version of EE changed during this request. |
|
| 681 | - * 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 |
|
| 682 | - * |
|
| 683 | - * @return bool |
|
| 684 | - */ |
|
| 685 | - public function is_major_version_change() |
|
| 686 | - { |
|
| 687 | - return $this->_major_version_change; |
|
| 688 | - } |
|
| 689 | - |
|
| 690 | - |
|
| 691 | - /** |
|
| 692 | - * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
| 693 | - * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
| 694 | - * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
| 695 | - * just activated to (for core that will always be espresso_version()) |
|
| 696 | - * |
|
| 697 | - * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
| 698 | - * ee plugin. for core that's 'espresso_db_update' |
|
| 699 | - * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
| 700 | - * indicate that this plugin was just activated |
|
| 701 | - * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
| 702 | - * espresso_version()) |
|
| 703 | - * @return int one of the constants on EE_System::req_type_* |
|
| 704 | - */ |
|
| 705 | - public static function detect_req_type_given_activation_history( |
|
| 706 | - $activation_history_for_addon, |
|
| 707 | - $activation_indicator_option_name, |
|
| 708 | - $version_to_upgrade_to |
|
| 709 | - ) { |
|
| 710 | - $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
| 711 | - if ($activation_history_for_addon) { |
|
| 712 | - // it exists, so this isn't a completely new install |
|
| 713 | - // check if this version already in that list of previously installed versions |
|
| 714 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
| 715 | - // it a version we haven't seen before |
|
| 716 | - if ($version_is_higher === 1) { |
|
| 717 | - $req_type = EE_System::req_type_upgrade; |
|
| 718 | - } else { |
|
| 719 | - $req_type = EE_System::req_type_downgrade; |
|
| 720 | - } |
|
| 721 | - delete_option($activation_indicator_option_name); |
|
| 722 | - } else { |
|
| 723 | - // its not an update. maybe a reactivation? |
|
| 724 | - if (get_option($activation_indicator_option_name, false)) { |
|
| 725 | - if ($version_is_higher === -1) { |
|
| 726 | - $req_type = EE_System::req_type_downgrade; |
|
| 727 | - } elseif ($version_is_higher === 0) { |
|
| 728 | - // we've seen this version before, but it's an activation. must be a reactivation |
|
| 729 | - $req_type = EE_System::req_type_reactivation; |
|
| 730 | - } else {// $version_is_higher === 1 |
|
| 731 | - $req_type = EE_System::req_type_upgrade; |
|
| 732 | - } |
|
| 733 | - delete_option($activation_indicator_option_name); |
|
| 734 | - } else { |
|
| 735 | - // we've seen this version before and the activation indicate doesn't show it was just activated |
|
| 736 | - if ($version_is_higher === -1) { |
|
| 737 | - $req_type = EE_System::req_type_downgrade; |
|
| 738 | - } elseif ($version_is_higher === 0) { |
|
| 739 | - // we've seen this version before and it's not an activation. its normal request |
|
| 740 | - $req_type = EE_System::req_type_normal; |
|
| 741 | - } else {// $version_is_higher === 1 |
|
| 742 | - $req_type = EE_System::req_type_upgrade; |
|
| 743 | - } |
|
| 744 | - } |
|
| 745 | - } |
|
| 746 | - } else { |
|
| 747 | - // brand new install |
|
| 748 | - $req_type = EE_System::req_type_new_activation; |
|
| 749 | - delete_option($activation_indicator_option_name); |
|
| 750 | - } |
|
| 751 | - return $req_type; |
|
| 752 | - } |
|
| 753 | - |
|
| 754 | - |
|
| 755 | - /** |
|
| 756 | - * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
| 757 | - * the $activation_history_for_addon |
|
| 758 | - * |
|
| 759 | - * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
| 760 | - * sometimes containing 'unknown-date' |
|
| 761 | - * @param string $version_to_upgrade_to (current version) |
|
| 762 | - * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
| 763 | - * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
| 764 | - * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
| 765 | - * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
| 766 | - */ |
|
| 767 | - private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
| 768 | - { |
|
| 769 | - // find the most recently-activated version |
|
| 770 | - $most_recently_active_version = |
|
| 771 | - EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
| 772 | - return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
| 773 | - } |
|
| 774 | - |
|
| 775 | - |
|
| 776 | - /** |
|
| 777 | - * Gets the most recently active version listed in the activation history, |
|
| 778 | - * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
| 779 | - * |
|
| 780 | - * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
| 781 | - * sometimes containing 'unknown-date' |
|
| 782 | - * @return string |
|
| 783 | - */ |
|
| 784 | - private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
| 785 | - { |
|
| 786 | - $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
| 787 | - $most_recently_active_version = '0.0.0.dev.000'; |
|
| 788 | - if (is_array($activation_history)) { |
|
| 789 | - foreach ($activation_history as $version => $times_activated) { |
|
| 790 | - // check there is a record of when this version was activated. Otherwise, |
|
| 791 | - // mark it as unknown |
|
| 792 | - if (! $times_activated) { |
|
| 793 | - $times_activated = array('unknown-date'); |
|
| 794 | - } |
|
| 795 | - if (is_string($times_activated)) { |
|
| 796 | - $times_activated = array($times_activated); |
|
| 797 | - } |
|
| 798 | - foreach ($times_activated as $an_activation) { |
|
| 799 | - if ($an_activation !== 'unknown-date' |
|
| 800 | - && $an_activation |
|
| 801 | - > $most_recently_active_version_activation) { |
|
| 802 | - $most_recently_active_version = $version; |
|
| 803 | - $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
| 804 | - ? '1970-01-01 00:00:00' |
|
| 805 | - : $an_activation; |
|
| 806 | - } |
|
| 807 | - } |
|
| 808 | - } |
|
| 809 | - } |
|
| 810 | - return $most_recently_active_version; |
|
| 811 | - } |
|
| 812 | - |
|
| 813 | - |
|
| 814 | - /** |
|
| 815 | - * This redirects to the about EE page after activation |
|
| 816 | - * |
|
| 817 | - * @return void |
|
| 818 | - */ |
|
| 819 | - public function redirect_to_about_ee() |
|
| 820 | - { |
|
| 821 | - $notices = EE_Error::get_notices(false); |
|
| 822 | - // if current user is an admin and it's not an ajax or rest request |
|
| 823 | - if (! isset($notices['errors']) |
|
| 824 | - && $this->request->isAdmin() |
|
| 825 | - && apply_filters( |
|
| 826 | - 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
| 827 | - $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
| 828 | - ) |
|
| 829 | - ) { |
|
| 830 | - $query_params = array('page' => 'espresso_about'); |
|
| 831 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
| 832 | - $query_params['new_activation'] = true; |
|
| 833 | - } |
|
| 834 | - if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
| 835 | - $query_params['reactivation'] = true; |
|
| 836 | - } |
|
| 837 | - $url = add_query_arg($query_params, admin_url('admin.php')); |
|
| 838 | - wp_safe_redirect($url); |
|
| 839 | - exit(); |
|
| 840 | - } |
|
| 841 | - } |
|
| 842 | - |
|
| 843 | - |
|
| 844 | - /** |
|
| 845 | - * load_core_configuration |
|
| 846 | - * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 847 | - * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 848 | - * |
|
| 849 | - * @return void |
|
| 850 | - * @throws ReflectionException |
|
| 851 | - * @throws Exception |
|
| 852 | - */ |
|
| 853 | - public function load_core_configuration() |
|
| 854 | - { |
|
| 855 | - do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 856 | - $this->loader->getShared('EE_Load_Textdomain'); |
|
| 857 | - // load textdomain |
|
| 858 | - EE_Load_Textdomain::load_textdomain(); |
|
| 859 | - // load caf stuff a chance to play during the activation process too. |
|
| 860 | - $this->_maybe_brew_regular(); |
|
| 861 | - // load and setup EE_Config and EE_Network_Config |
|
| 862 | - $config = $this->loader->getShared('EE_Config'); |
|
| 863 | - $this->loader->getShared('EE_Network_Config'); |
|
| 864 | - // setup autoloaders |
|
| 865 | - // enable logging? |
|
| 866 | - if ($config->admin->use_remote_logging) { |
|
| 867 | - $this->loader->getShared('EE_Log'); |
|
| 868 | - } |
|
| 869 | - // check for activation errors |
|
| 870 | - $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
| 871 | - if ($activation_errors) { |
|
| 872 | - EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 873 | - update_option('ee_plugin_activation_errors', false); |
|
| 874 | - } |
|
| 875 | - // get model names |
|
| 876 | - $this->_parse_model_names(); |
|
| 877 | - // configure custom post type definitions |
|
| 878 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
| 879 | - $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
| 880 | - do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 881 | - } |
|
| 882 | - |
|
| 883 | - |
|
| 884 | - /** |
|
| 885 | - * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
| 886 | - * |
|
| 887 | - * @return void |
|
| 888 | - * @throws ReflectionException |
|
| 889 | - */ |
|
| 890 | - private function _parse_model_names() |
|
| 891 | - { |
|
| 892 | - // get all the files in the EE_MODELS folder that end in .model.php |
|
| 893 | - $models = glob(EE_MODELS . '*.model.php'); |
|
| 894 | - $model_names = array(); |
|
| 895 | - $non_abstract_db_models = array(); |
|
| 896 | - foreach ($models as $model) { |
|
| 897 | - // get model classname |
|
| 898 | - $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 899 | - $short_name = str_replace('EEM_', '', $classname); |
|
| 900 | - $reflectionClass = new ReflectionClass($classname); |
|
| 901 | - if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 902 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
| 903 | - } |
|
| 904 | - $model_names[ $short_name ] = $classname; |
|
| 905 | - } |
|
| 906 | - $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 907 | - $this->registry->non_abstract_db_models = apply_filters( |
|
| 908 | - 'FHEE__EE_System__parse_implemented_model_names', |
|
| 909 | - $non_abstract_db_models |
|
| 910 | - ); |
|
| 911 | - } |
|
| 912 | - |
|
| 913 | - |
|
| 914 | - /** |
|
| 915 | - * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
| 916 | - * that need to be setup before our EE_System launches. |
|
| 917 | - * |
|
| 918 | - * @return void |
|
| 919 | - * @throws DomainException |
|
| 920 | - * @throws InvalidArgumentException |
|
| 921 | - * @throws InvalidDataTypeException |
|
| 922 | - * @throws InvalidInterfaceException |
|
| 923 | - * @throws InvalidClassException |
|
| 924 | - * @throws InvalidFilePathException |
|
| 925 | - */ |
|
| 926 | - private function _maybe_brew_regular() |
|
| 927 | - { |
|
| 928 | - /** @var Domain $domain */ |
|
| 929 | - $domain = DomainFactory::getShared( |
|
| 930 | - new FullyQualifiedName( |
|
| 931 | - 'EventEspresso\core\domain\Domain' |
|
| 932 | - ), |
|
| 933 | - array( |
|
| 934 | - new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
| 935 | - Version::fromString(espresso_version()), |
|
| 936 | - ) |
|
| 937 | - ); |
|
| 938 | - if ($domain->isCaffeinated()) { |
|
| 939 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 940 | - } |
|
| 941 | - } |
|
| 942 | - |
|
| 943 | - |
|
| 944 | - /** |
|
| 945 | - * @since 4.9.71.p |
|
| 946 | - * @throws Exception |
|
| 947 | - */ |
|
| 948 | - public function loadRouteMatchSpecifications() |
|
| 949 | - { |
|
| 950 | - try { |
|
| 951 | - $this->router = $this->loader->getShared('EventEspresso\core\services\route_match\RouteHandler'); |
|
| 952 | - } catch (Exception $exception) { |
|
| 953 | - new ExceptionStackTraceDisplay($exception); |
|
| 954 | - } |
|
| 955 | - do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
| 956 | - } |
|
| 957 | - |
|
| 958 | - |
|
| 959 | - /** |
|
| 960 | - * register_shortcodes_modules_and_widgets |
|
| 961 | - * generate lists of shortcodes and modules, then verify paths and classes |
|
| 962 | - * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
| 963 | - * which runs during the WP 'plugins_loaded' action at priority 7 |
|
| 964 | - * |
|
| 965 | - * @access public |
|
| 966 | - * @return void |
|
| 967 | - * @throws Exception |
|
| 968 | - */ |
|
| 969 | - public function register_shortcodes_modules_and_widgets() |
|
| 970 | - { |
|
| 971 | - $this->router->handleShortcodesRequest(); |
|
| 972 | - do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 973 | - // check for addons using old hook point |
|
| 974 | - if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 975 | - $this->_incompatible_addon_error(); |
|
| 976 | - } |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - |
|
| 980 | - /** |
|
| 981 | - * _incompatible_addon_error |
|
| 982 | - * |
|
| 983 | - * @access public |
|
| 984 | - * @return void |
|
| 985 | - */ |
|
| 986 | - private function _incompatible_addon_error() |
|
| 987 | - { |
|
| 988 | - // get array of classes hooking into here |
|
| 989 | - $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
| 990 | - 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
| 991 | - ); |
|
| 992 | - if (! empty($class_names)) { |
|
| 993 | - $msg = __( |
|
| 994 | - 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
| 995 | - 'event_espresso' |
|
| 996 | - ); |
|
| 997 | - $msg .= '<ul>'; |
|
| 998 | - foreach ($class_names as $class_name) { |
|
| 999 | - $msg .= '<li><b>Event Espresso - ' |
|
| 1000 | - . str_replace( |
|
| 1001 | - array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
| 1002 | - '', |
|
| 1003 | - $class_name |
|
| 1004 | - ) . '</b></li>'; |
|
| 1005 | - } |
|
| 1006 | - $msg .= '</ul>'; |
|
| 1007 | - $msg .= __( |
|
| 1008 | - 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
| 1009 | - 'event_espresso' |
|
| 1010 | - ); |
|
| 1011 | - // save list of incompatible addons to wp-options for later use |
|
| 1012 | - add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 1013 | - if (is_admin()) { |
|
| 1014 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1015 | - } |
|
| 1016 | - } |
|
| 1017 | - } |
|
| 1018 | - |
|
| 1019 | - |
|
| 1020 | - /** |
|
| 1021 | - * brew_espresso |
|
| 1022 | - * begins the process of setting hooks for initializing EE in the correct order |
|
| 1023 | - * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
| 1024 | - * which runs during the WP 'plugins_loaded' action at priority 9 |
|
| 1025 | - * |
|
| 1026 | - * @return void |
|
| 1027 | - * @throws Exception |
|
| 1028 | - */ |
|
| 1029 | - public function brew_espresso() |
|
| 1030 | - { |
|
| 1031 | - do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 1032 | - // load some final core systems |
|
| 1033 | - add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 1034 | - add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
| 1035 | - add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 1036 | - add_action('init', array($this, 'load_controllers'), 7); |
|
| 1037 | - add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 1038 | - add_action('init', array($this, 'initialize'), 10); |
|
| 1039 | - add_action('init', array($this, 'initialize_last'), 100); |
|
| 1040 | - $this->router->handlePueRequest(); |
|
| 1041 | - $this->router->handleGQLRequest(); |
|
| 1042 | - do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 1043 | - } |
|
| 1044 | - |
|
| 1045 | - |
|
| 1046 | - /** |
|
| 1047 | - * set_hooks_for_core |
|
| 1048 | - * |
|
| 1049 | - * @access public |
|
| 1050 | - * @return void |
|
| 1051 | - * @throws EE_Error |
|
| 1052 | - */ |
|
| 1053 | - public function set_hooks_for_core() |
|
| 1054 | - { |
|
| 1055 | - $this->_deactivate_incompatible_addons(); |
|
| 1056 | - do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 1057 | - $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
| 1058 | - // caps need to be initialized on every request so that capability maps are set. |
|
| 1059 | - // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
| 1060 | - $this->registry->CAP->init_caps(); |
|
| 1061 | - } |
|
| 1062 | - |
|
| 1063 | - |
|
| 1064 | - /** |
|
| 1065 | - * Using the information gathered in EE_System::_incompatible_addon_error, |
|
| 1066 | - * deactivates any addons considered incompatible with the current version of EE |
|
| 1067 | - */ |
|
| 1068 | - private function _deactivate_incompatible_addons() |
|
| 1069 | - { |
|
| 1070 | - $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
| 1071 | - if (! empty($incompatible_addons)) { |
|
| 1072 | - $active_plugins = get_option('active_plugins', array()); |
|
| 1073 | - foreach ($active_plugins as $active_plugin) { |
|
| 1074 | - foreach ($incompatible_addons as $incompatible_addon) { |
|
| 1075 | - if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
| 1076 | - unset($_GET['activate']); |
|
| 1077 | - espresso_deactivate_plugin($active_plugin); |
|
| 1078 | - } |
|
| 1079 | - } |
|
| 1080 | - } |
|
| 1081 | - } |
|
| 1082 | - } |
|
| 1083 | - |
|
| 1084 | - |
|
| 1085 | - /** |
|
| 1086 | - * perform_activations_upgrades_and_migrations |
|
| 1087 | - * |
|
| 1088 | - * @access public |
|
| 1089 | - * @return void |
|
| 1090 | - */ |
|
| 1091 | - public function perform_activations_upgrades_and_migrations() |
|
| 1092 | - { |
|
| 1093 | - do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 1094 | - } |
|
| 1095 | - |
|
| 1096 | - |
|
| 1097 | - /** |
|
| 1098 | - * @return void |
|
| 1099 | - * @throws DomainException |
|
| 1100 | - */ |
|
| 1101 | - public function load_CPTs_and_session() |
|
| 1102 | - { |
|
| 1103 | - do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 1104 | - /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */ |
|
| 1105 | - $register_custom_taxonomies = $this->loader->getShared( |
|
| 1106 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
| 1107 | - ); |
|
| 1108 | - $register_custom_taxonomies->registerCustomTaxonomies(); |
|
| 1109 | - /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */ |
|
| 1110 | - $register_custom_post_types = $this->loader->getShared( |
|
| 1111 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
| 1112 | - ); |
|
| 1113 | - $register_custom_post_types->registerCustomPostTypes(); |
|
| 1114 | - /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */ |
|
| 1115 | - $register_custom_taxonomy_terms = $this->loader->getShared( |
|
| 1116 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
| 1117 | - ); |
|
| 1118 | - $register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
| 1119 | - // load legacy Custom Post Types and Taxonomies |
|
| 1120 | - $this->loader->getShared('EE_Register_CPTs'); |
|
| 1121 | - do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 1122 | - } |
|
| 1123 | - |
|
| 1124 | - |
|
| 1125 | - /** |
|
| 1126 | - * load_controllers |
|
| 1127 | - * this is the best place to load any additional controllers that needs access to EE core. |
|
| 1128 | - * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
| 1129 | - * time |
|
| 1130 | - * |
|
| 1131 | - * @access public |
|
| 1132 | - * @return void |
|
| 1133 | - * @throws Exception |
|
| 1134 | - */ |
|
| 1135 | - public function load_controllers() |
|
| 1136 | - { |
|
| 1137 | - do_action('AHEE__EE_System__load_controllers__start'); |
|
| 1138 | - // let's get it started |
|
| 1139 | - $this->router->handleControllerRequest(); |
|
| 1140 | - do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 1141 | - } |
|
| 1142 | - |
|
| 1143 | - |
|
| 1144 | - /** |
|
| 1145 | - * core_loaded_and_ready |
|
| 1146 | - * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
| 1147 | - * |
|
| 1148 | - * @access public |
|
| 1149 | - * @return void |
|
| 1150 | - * @throws Exception |
|
| 1151 | - */ |
|
| 1152 | - public function core_loaded_and_ready() |
|
| 1153 | - { |
|
| 1154 | - $this->router->handleAssetManagerRequest(); |
|
| 1155 | - $this->router->handleSessionRequest(); |
|
| 1156 | - // integrate WP_Query with the EE models |
|
| 1157 | - $this->loader->getShared('EE_CPT_Strategy'); |
|
| 1158 | - do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 1159 | - // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
| 1160 | - // builders require these even on the front-end |
|
| 1161 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
| 1162 | - do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 1163 | - } |
|
| 1164 | - |
|
| 1165 | - |
|
| 1166 | - /** |
|
| 1167 | - * initialize |
|
| 1168 | - * this is the best place to begin initializing client code |
|
| 1169 | - * |
|
| 1170 | - * @access public |
|
| 1171 | - * @return void |
|
| 1172 | - */ |
|
| 1173 | - public function initialize() |
|
| 1174 | - { |
|
| 1175 | - do_action('AHEE__EE_System__initialize'); |
|
| 1176 | - } |
|
| 1177 | - |
|
| 1178 | - |
|
| 1179 | - /** |
|
| 1180 | - * initialize_last |
|
| 1181 | - * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
| 1182 | - * initialize has done so |
|
| 1183 | - * |
|
| 1184 | - * @access public |
|
| 1185 | - * @return void |
|
| 1186 | - * @throws Exception |
|
| 1187 | - */ |
|
| 1188 | - public function initialize_last() |
|
| 1189 | - { |
|
| 1190 | - do_action('AHEE__EE_System__initialize_last'); |
|
| 1191 | - /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
| 1192 | - $rewrite_rules = $this->loader->getShared( |
|
| 1193 | - 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
| 1194 | - ); |
|
| 1195 | - $rewrite_rules->flushRewriteRules(); |
|
| 1196 | - add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
| 1197 | - $this->router->handlePersonalDataRequest(); |
|
| 1198 | - } |
|
| 1199 | - |
|
| 1200 | - |
|
| 1201 | - /** |
|
| 1202 | - * @return void |
|
| 1203 | - */ |
|
| 1204 | - public function addEspressoToolbar() |
|
| 1205 | - { |
|
| 1206 | - $this->loader->getShared( |
|
| 1207 | - 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
| 1208 | - array($this->registry->CAP) |
|
| 1209 | - ); |
|
| 1210 | - } |
|
| 1211 | - |
|
| 1212 | - |
|
| 1213 | - /** |
|
| 1214 | - * do_not_cache |
|
| 1215 | - * sets no cache headers and defines no cache constants for WP plugins |
|
| 1216 | - * |
|
| 1217 | - * @access public |
|
| 1218 | - * @return void |
|
| 1219 | - */ |
|
| 1220 | - public static function do_not_cache() |
|
| 1221 | - { |
|
| 1222 | - // set no cache constants |
|
| 1223 | - if (! defined('DONOTCACHEPAGE')) { |
|
| 1224 | - define('DONOTCACHEPAGE', true); |
|
| 1225 | - } |
|
| 1226 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
| 1227 | - define('DONOTCACHCEOBJECT', true); |
|
| 1228 | - } |
|
| 1229 | - if (! defined('DONOTCACHEDB')) { |
|
| 1230 | - define('DONOTCACHEDB', true); |
|
| 1231 | - } |
|
| 1232 | - // add no cache headers |
|
| 1233 | - add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 1234 | - // plus a little extra for nginx and Google Chrome |
|
| 1235 | - add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 1236 | - // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
| 1237 | - remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 1238 | - } |
|
| 1239 | - |
|
| 1240 | - |
|
| 1241 | - /** |
|
| 1242 | - * extra_nocache_headers |
|
| 1243 | - * |
|
| 1244 | - * @access public |
|
| 1245 | - * @param $headers |
|
| 1246 | - * @return array |
|
| 1247 | - */ |
|
| 1248 | - public static function extra_nocache_headers($headers) |
|
| 1249 | - { |
|
| 1250 | - // for NGINX |
|
| 1251 | - $headers['X-Accel-Expires'] = 0; |
|
| 1252 | - // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
| 1253 | - $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
| 1254 | - return $headers; |
|
| 1255 | - } |
|
| 1256 | - |
|
| 1257 | - |
|
| 1258 | - /** |
|
| 1259 | - * nocache_headers |
|
| 1260 | - * |
|
| 1261 | - * @access public |
|
| 1262 | - * @return void |
|
| 1263 | - */ |
|
| 1264 | - public static function nocache_headers() |
|
| 1265 | - { |
|
| 1266 | - nocache_headers(); |
|
| 1267 | - } |
|
| 1268 | - |
|
| 1269 | - |
|
| 1270 | - /** |
|
| 1271 | - * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
| 1272 | - * never returned with the function. |
|
| 1273 | - * |
|
| 1274 | - * @param array $exclude_array any existing pages being excluded are in this array. |
|
| 1275 | - * @return array |
|
| 1276 | - */ |
|
| 1277 | - public function remove_pages_from_wp_list_pages($exclude_array) |
|
| 1278 | - { |
|
| 1279 | - return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 1280 | - } |
|
| 32 | + /** |
|
| 33 | + * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation. |
|
| 34 | + * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc |
|
| 35 | + */ |
|
| 36 | + const req_type_normal = 0; |
|
| 37 | + |
|
| 38 | + /** |
|
| 39 | + * Indicates this is a brand new installation of EE so we should install |
|
| 40 | + * tables and default data etc |
|
| 41 | + */ |
|
| 42 | + const req_type_new_activation = 1; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * we've detected that EE has been reactivated (or EE was activated during maintenance mode, |
|
| 46 | + * and we just exited maintenance mode). We MUST check the database is setup properly |
|
| 47 | + * and that default data is setup too |
|
| 48 | + */ |
|
| 49 | + const req_type_reactivation = 2; |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * indicates that EE has been upgraded since its previous request. |
|
| 53 | + * We may have data migration scripts to call and will want to trigger maintenance mode |
|
| 54 | + */ |
|
| 55 | + const req_type_upgrade = 3; |
|
| 56 | + |
|
| 57 | + /** |
|
| 58 | + * TODO will detect that EE has been DOWNGRADED. We probably don't want to run in this case... |
|
| 59 | + */ |
|
| 60 | + const req_type_downgrade = 4; |
|
| 61 | + |
|
| 62 | + /** |
|
| 63 | + * @deprecated since version 4.6.0.dev.006 |
|
| 64 | + * Now whenever a new_activation is detected the request type is still just |
|
| 65 | + * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode |
|
| 66 | + * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required |
|
| 67 | + * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode. |
|
| 68 | + * (Specifically, when the migration manager indicates migrations are finished |
|
| 69 | + * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called) |
|
| 70 | + */ |
|
| 71 | + const req_type_activation_but_not_installed = 5; |
|
| 72 | + |
|
| 73 | + /** |
|
| 74 | + * option prefix for recording the activation history (like core's "espresso_db_update") of addons |
|
| 75 | + */ |
|
| 76 | + const addon_activation_history_option_prefix = 'ee_addon_activation_history_'; |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * @var EE_System $_instance |
|
| 80 | + */ |
|
| 81 | + private static $_instance; |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * @var EE_Registry $registry |
|
| 85 | + */ |
|
| 86 | + private $registry; |
|
| 87 | + |
|
| 88 | + /** |
|
| 89 | + * @var LoaderInterface $loader |
|
| 90 | + */ |
|
| 91 | + private $loader; |
|
| 92 | + |
|
| 93 | + /** |
|
| 94 | + * @var EE_Capabilities $capabilities |
|
| 95 | + */ |
|
| 96 | + private $capabilities; |
|
| 97 | + |
|
| 98 | + /** |
|
| 99 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
| 100 | + */ |
|
| 101 | + private $maintenance_mode; |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @var RequestInterface $request |
|
| 105 | + */ |
|
| 106 | + private $request; |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*. |
|
| 110 | + * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request. |
|
| 111 | + * |
|
| 112 | + * @var int $_req_type |
|
| 113 | + */ |
|
| 114 | + private $_req_type; |
|
| 115 | + |
|
| 116 | + |
|
| 117 | + /** |
|
| 118 | + * @var RouteHandler $router |
|
| 119 | + */ |
|
| 120 | + private $router; |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * Whether or not there was a non-micro version change in EE core version during this request |
|
| 124 | + * |
|
| 125 | + * @var boolean $_major_version_change |
|
| 126 | + */ |
|
| 127 | + private $_major_version_change = false; |
|
| 128 | + |
|
| 129 | + /** |
|
| 130 | + * A Context DTO dedicated solely to identifying the current request type. |
|
| 131 | + * |
|
| 132 | + * @var RequestTypeContextCheckerInterface $request_type |
|
| 133 | + */ |
|
| 134 | + private $request_type; |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @singleton method used to instantiate class object |
|
| 139 | + * @param EE_Registry|null $registry |
|
| 140 | + * @param LoaderInterface|null $loader |
|
| 141 | + * @param RequestInterface|null $request |
|
| 142 | + * @param EE_Maintenance_Mode|null $maintenance_mode |
|
| 143 | + * @return EE_System |
|
| 144 | + */ |
|
| 145 | + public static function instance( |
|
| 146 | + EE_Registry $registry = null, |
|
| 147 | + LoaderInterface $loader = null, |
|
| 148 | + RequestInterface $request = null, |
|
| 149 | + EE_Maintenance_Mode $maintenance_mode = null |
|
| 150 | + ) { |
|
| 151 | + // check if class object is instantiated |
|
| 152 | + if (! self::$_instance instanceof EE_System) { |
|
| 153 | + self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
|
| 154 | + } |
|
| 155 | + return self::$_instance; |
|
| 156 | + } |
|
| 157 | + |
|
| 158 | + |
|
| 159 | + /** |
|
| 160 | + * resets the instance and returns it |
|
| 161 | + * |
|
| 162 | + * @return EE_System |
|
| 163 | + */ |
|
| 164 | + public static function reset() |
|
| 165 | + { |
|
| 166 | + self::$_instance->_req_type = null; |
|
| 167 | + // make sure none of the old hooks are left hanging around |
|
| 168 | + remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 169 | + // we need to reset the migration manager in order for it to detect DMSs properly |
|
| 170 | + EE_Data_Migration_Manager::reset(); |
|
| 171 | + self::instance()->detect_activations_or_upgrades(); |
|
| 172 | + self::instance()->perform_activations_upgrades_and_migrations(); |
|
| 173 | + return self::instance(); |
|
| 174 | + } |
|
| 175 | + |
|
| 176 | + |
|
| 177 | + /** |
|
| 178 | + * sets hooks for running rest of system |
|
| 179 | + * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point |
|
| 180 | + * starting EE Addons from any other point may lead to problems |
|
| 181 | + * |
|
| 182 | + * @param EE_Registry $registry |
|
| 183 | + * @param LoaderInterface $loader |
|
| 184 | + * @param RequestInterface $request |
|
| 185 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
| 186 | + */ |
|
| 187 | + private function __construct( |
|
| 188 | + EE_Registry $registry, |
|
| 189 | + LoaderInterface $loader, |
|
| 190 | + RequestInterface $request, |
|
| 191 | + EE_Maintenance_Mode $maintenance_mode |
|
| 192 | + ) { |
|
| 193 | + $this->registry = $registry; |
|
| 194 | + $this->loader = $loader; |
|
| 195 | + $this->request = $request; |
|
| 196 | + $this->maintenance_mode = $maintenance_mode; |
|
| 197 | + do_action('AHEE__EE_System__construct__begin', $this); |
|
| 198 | + add_action( |
|
| 199 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 200 | + array($this, 'loadCapabilities'), |
|
| 201 | + 5 |
|
| 202 | + ); |
|
| 203 | + add_action( |
|
| 204 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 205 | + array($this, 'loadCommandBus'), |
|
| 206 | + 7 |
|
| 207 | + ); |
|
| 208 | + add_action( |
|
| 209 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 210 | + array($this, 'loadPluginApi'), |
|
| 211 | + 9 |
|
| 212 | + ); |
|
| 213 | + // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc |
|
| 214 | + add_action( |
|
| 215 | + 'AHEE__EE_Bootstrap__load_espresso_addons', |
|
| 216 | + array($this, 'load_espresso_addons') |
|
| 217 | + ); |
|
| 218 | + // when an ee addon is activated, we want to call the core hook(s) again |
|
| 219 | + // because the newly-activated addon didn't get a chance to run at all |
|
| 220 | + add_action('activate_plugin', array($this, 'load_espresso_addons'), 1); |
|
| 221 | + // detect whether install or upgrade |
|
| 222 | + add_action( |
|
| 223 | + 'AHEE__EE_Bootstrap__detect_activations_or_upgrades', |
|
| 224 | + array($this, 'detect_activations_or_upgrades'), |
|
| 225 | + 3 |
|
| 226 | + ); |
|
| 227 | + // load EE_Config, EE_Textdomain, etc |
|
| 228 | + add_action( |
|
| 229 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 230 | + array($this, 'load_core_configuration'), |
|
| 231 | + 5 |
|
| 232 | + ); |
|
| 233 | + // load specifications for matching routes to current request |
|
| 234 | + add_action( |
|
| 235 | + 'AHEE__EE_Bootstrap__load_core_configuration', |
|
| 236 | + array($this, 'loadRouteMatchSpecifications') |
|
| 237 | + ); |
|
| 238 | + // load EE_Config, EE_Textdomain, etc |
|
| 239 | + add_action( |
|
| 240 | + 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets', |
|
| 241 | + array($this, 'register_shortcodes_modules_and_widgets'), |
|
| 242 | + 7 |
|
| 243 | + ); |
|
| 244 | + // you wanna get going? I wanna get going... let's get going! |
|
| 245 | + add_action( |
|
| 246 | + 'AHEE__EE_Bootstrap__brew_espresso', |
|
| 247 | + array($this, 'brew_espresso'), |
|
| 248 | + 9 |
|
| 249 | + ); |
|
| 250 | + // other housekeeping |
|
| 251 | + // exclude EE critical pages from wp_list_pages |
|
| 252 | + add_filter( |
|
| 253 | + 'wp_list_pages_excludes', |
|
| 254 | + array($this, 'remove_pages_from_wp_list_pages'), |
|
| 255 | + 10 |
|
| 256 | + ); |
|
| 257 | + // ALL EE Addons should use the following hook point to attach their initial setup too |
|
| 258 | + // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads |
|
| 259 | + do_action('AHEE__EE_System__construct__complete', $this); |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * load and setup EE_Capabilities |
|
| 265 | + * |
|
| 266 | + * @return void |
|
| 267 | + */ |
|
| 268 | + public function loadCapabilities() |
|
| 269 | + { |
|
| 270 | + $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
|
| 271 | + add_action( |
|
| 272 | + 'AHEE__EE_Capabilities__init_caps__before_initialization', |
|
| 273 | + function () { |
|
| 274 | + LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
|
| 275 | + } |
|
| 276 | + ); |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * create and cache the CommandBus, and also add middleware |
|
| 282 | + * The CapChecker middleware requires the use of EE_Capabilities |
|
| 283 | + * which is why we need to load the CommandBus after Caps are set up |
|
| 284 | + * |
|
| 285 | + * @return void |
|
| 286 | + */ |
|
| 287 | + public function loadCommandBus() |
|
| 288 | + { |
|
| 289 | + $this->loader->getShared( |
|
| 290 | + 'CommandBusInterface', |
|
| 291 | + array( |
|
| 292 | + null, |
|
| 293 | + apply_filters( |
|
| 294 | + 'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware', |
|
| 295 | + array( |
|
| 296 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'), |
|
| 297 | + $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'), |
|
| 298 | + ) |
|
| 299 | + ), |
|
| 300 | + ) |
|
| 301 | + ); |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + |
|
| 305 | + /** |
|
| 306 | + * @return void |
|
| 307 | + * @throws EE_Error |
|
| 308 | + */ |
|
| 309 | + public function loadPluginApi() |
|
| 310 | + { |
|
| 311 | + // set autoloaders for all of the classes implementing EEI_Plugin_API |
|
| 312 | + // which provide helpers for EE plugin authors to more easily register certain components with EE. |
|
| 313 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 314 | + $this->loader->getShared('EE_Request_Handler'); |
|
| 315 | + } |
|
| 316 | + |
|
| 317 | + |
|
| 318 | + /** |
|
| 319 | + * @param string $addon_name |
|
| 320 | + * @param string $version_constant |
|
| 321 | + * @param string $min_version_required |
|
| 322 | + * @param string $load_callback |
|
| 323 | + * @param string $plugin_file_constant |
|
| 324 | + * @return void |
|
| 325 | + */ |
|
| 326 | + private function deactivateIncompatibleAddon( |
|
| 327 | + $addon_name, |
|
| 328 | + $version_constant, |
|
| 329 | + $min_version_required, |
|
| 330 | + $load_callback, |
|
| 331 | + $plugin_file_constant |
|
| 332 | + ) { |
|
| 333 | + if (! defined($version_constant)) { |
|
| 334 | + return; |
|
| 335 | + } |
|
| 336 | + $addon_version = constant($version_constant); |
|
| 337 | + if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
|
| 338 | + remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
|
| 339 | + if (! function_exists('deactivate_plugins')) { |
|
| 340 | + require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 341 | + } |
|
| 342 | + deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
|
| 343 | + unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
|
| 344 | + EE_Error::add_error( |
|
| 345 | + sprintf( |
|
| 346 | + esc_html__( |
|
| 347 | + 'We\'re sorry, but the Event Espresso %1$s addon was deactivated because version %2$s or higher is required with this version of Event Espresso core.', |
|
| 348 | + 'event_espresso' |
|
| 349 | + ), |
|
| 350 | + $addon_name, |
|
| 351 | + $min_version_required |
|
| 352 | + ), |
|
| 353 | + __FILE__, |
|
| 354 | + __FUNCTION__ . "({$addon_name})", |
|
| 355 | + __LINE__ |
|
| 356 | + ); |
|
| 357 | + EE_Error::get_notices(false, true); |
|
| 358 | + } |
|
| 359 | + } |
|
| 360 | + |
|
| 361 | + |
|
| 362 | + /** |
|
| 363 | + * load_espresso_addons |
|
| 364 | + * allow addons to load first so that they can set hooks for running DMS's, etc |
|
| 365 | + * this is hooked into both: |
|
| 366 | + * 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 367 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 368 | + * and the WP 'activate_plugin' hook point |
|
| 369 | + * |
|
| 370 | + * @access public |
|
| 371 | + * @return void |
|
| 372 | + */ |
|
| 373 | + public function load_espresso_addons() |
|
| 374 | + { |
|
| 375 | + $this->deactivateIncompatibleAddon( |
|
| 376 | + 'Wait Lists', |
|
| 377 | + 'EE_WAIT_LISTS_VERSION', |
|
| 378 | + '1.0.0.beta.074', |
|
| 379 | + 'load_espresso_wait_lists', |
|
| 380 | + 'EE_WAIT_LISTS_PLUGIN_FILE' |
|
| 381 | + ); |
|
| 382 | + $this->deactivateIncompatibleAddon( |
|
| 383 | + 'Automated Upcoming Event Notifications', |
|
| 384 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION', |
|
| 385 | + '1.0.0.beta.091', |
|
| 386 | + 'load_espresso_automated_upcoming_event_notification', |
|
| 387 | + 'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE' |
|
| 388 | + ); |
|
| 389 | + do_action('AHEE__EE_System__load_espresso_addons'); |
|
| 390 | + // if the WP API basic auth plugin isn't already loaded, load it now. |
|
| 391 | + // We want it for mobile apps. Just include the entire plugin |
|
| 392 | + // also, don't load the basic auth when a plugin is getting activated, because |
|
| 393 | + // it could be the basic auth plugin, and it doesn't check if its methods are already defined |
|
| 394 | + // and causes a fatal error |
|
| 395 | + if (($this->request->isWordPressApi() || $this->request->isApi()) |
|
| 396 | + && $this->request->getRequestParam('activate') !== 'true' |
|
| 397 | + && ! function_exists('json_basic_auth_handler') |
|
| 398 | + && ! function_exists('json_basic_auth_error') |
|
| 399 | + && ! in_array( |
|
| 400 | + $this->request->getRequestParam('action'), |
|
| 401 | + array('activate', 'activate-selected'), |
|
| 402 | + true |
|
| 403 | + ) |
|
| 404 | + ) { |
|
| 405 | + include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
| 406 | + } |
|
| 407 | + do_action('AHEE__EE_System__load_espresso_addons__complete'); |
|
| 408 | + } |
|
| 409 | + |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * detect_activations_or_upgrades |
|
| 413 | + * Checks for activation or upgrade of core first; |
|
| 414 | + * then also checks if any registered addons have been activated or upgraded |
|
| 415 | + * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades' |
|
| 416 | + * which runs during the WP 'plugins_loaded' action at priority 3 |
|
| 417 | + * |
|
| 418 | + * @access public |
|
| 419 | + * @return void |
|
| 420 | + */ |
|
| 421 | + public function detect_activations_or_upgrades() |
|
| 422 | + { |
|
| 423 | + // first off: let's make sure to handle core |
|
| 424 | + $this->detect_if_activation_or_upgrade(); |
|
| 425 | + foreach ($this->registry->addons as $addon) { |
|
| 426 | + if ($addon instanceof EE_Addon) { |
|
| 427 | + // detect teh request type for that addon |
|
| 428 | + $addon->detect_activation_or_upgrade(); |
|
| 429 | + } |
|
| 430 | + } |
|
| 431 | + } |
|
| 432 | + |
|
| 433 | + |
|
| 434 | + /** |
|
| 435 | + * detect_if_activation_or_upgrade |
|
| 436 | + * Takes care of detecting whether this is a brand new install or code upgrade, |
|
| 437 | + * and either setting up the DB or setting up maintenance mode etc. |
|
| 438 | + * |
|
| 439 | + * @access public |
|
| 440 | + * @return void |
|
| 441 | + */ |
|
| 442 | + public function detect_if_activation_or_upgrade() |
|
| 443 | + { |
|
| 444 | + do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin'); |
|
| 445 | + // check if db has been updated, or if its a brand-new installation |
|
| 446 | + $espresso_db_update = $this->fix_espresso_db_upgrade_option(); |
|
| 447 | + $request_type = $this->detect_req_type($espresso_db_update); |
|
| 448 | + // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ ); |
|
| 449 | + switch ($request_type) { |
|
| 450 | + case EE_System::req_type_new_activation: |
|
| 451 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation'); |
|
| 452 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 453 | + break; |
|
| 454 | + case EE_System::req_type_reactivation: |
|
| 455 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation'); |
|
| 456 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 457 | + break; |
|
| 458 | + case EE_System::req_type_upgrade: |
|
| 459 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade'); |
|
| 460 | + // migrations may be required now that we've upgraded |
|
| 461 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 462 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 463 | + break; |
|
| 464 | + case EE_System::req_type_downgrade: |
|
| 465 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade'); |
|
| 466 | + // its possible migrations are no longer required |
|
| 467 | + $this->maintenance_mode->set_maintenance_mode_if_db_old(); |
|
| 468 | + $this->_handle_core_version_change($espresso_db_update); |
|
| 469 | + break; |
|
| 470 | + case EE_System::req_type_normal: |
|
| 471 | + default: |
|
| 472 | + break; |
|
| 473 | + } |
|
| 474 | + do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete'); |
|
| 475 | + } |
|
| 476 | + |
|
| 477 | + |
|
| 478 | + /** |
|
| 479 | + * Updates the list of installed versions and sets hooks for |
|
| 480 | + * initializing the database later during the request |
|
| 481 | + * |
|
| 482 | + * @param array $espresso_db_update |
|
| 483 | + */ |
|
| 484 | + private function _handle_core_version_change($espresso_db_update) |
|
| 485 | + { |
|
| 486 | + $this->update_list_of_installed_versions($espresso_db_update); |
|
| 487 | + // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course) |
|
| 488 | + add_action( |
|
| 489 | + 'AHEE__EE_System__perform_activations_upgrades_and_migrations', |
|
| 490 | + array($this, 'initialize_db_if_no_migrations_required') |
|
| 491 | + ); |
|
| 492 | + } |
|
| 493 | + |
|
| 494 | + |
|
| 495 | + /** |
|
| 496 | + * standardizes the wp option 'espresso_db_upgrade' which actually stores |
|
| 497 | + * information about what versions of EE have been installed and activated, |
|
| 498 | + * NOT necessarily the state of the database |
|
| 499 | + * |
|
| 500 | + * @param mixed $espresso_db_update the value of the WordPress option. |
|
| 501 | + * If not supplied, fetches it from the options table |
|
| 502 | + * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction |
|
| 503 | + */ |
|
| 504 | + private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
|
| 505 | + { |
|
| 506 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
|
| 507 | + if (! $espresso_db_update) { |
|
| 508 | + $espresso_db_update = get_option('espresso_db_update'); |
|
| 509 | + } |
|
| 510 | + // check that option is an array |
|
| 511 | + if (! is_array($espresso_db_update)) { |
|
| 512 | + // if option is FALSE, then it never existed |
|
| 513 | + if ($espresso_db_update === false) { |
|
| 514 | + // make $espresso_db_update an array and save option with autoload OFF |
|
| 515 | + $espresso_db_update = array(); |
|
| 516 | + add_option('espresso_db_update', $espresso_db_update, '', 'no'); |
|
| 517 | + } else { |
|
| 518 | + // option is NOT FALSE but also is NOT an array, so make it an array and save it |
|
| 519 | + $espresso_db_update = array($espresso_db_update => array()); |
|
| 520 | + update_option('espresso_db_update', $espresso_db_update); |
|
| 521 | + } |
|
| 522 | + } else { |
|
| 523 | + $corrected_db_update = array(); |
|
| 524 | + // if IS an array, but is it an array where KEYS are version numbers, and values are arrays? |
|
| 525 | + foreach ($espresso_db_update as $should_be_version_string => $should_be_array) { |
|
| 526 | + if (is_int($should_be_version_string) && ! is_array($should_be_array)) { |
|
| 527 | + // the key is an int, and the value IS NOT an array |
|
| 528 | + // so it must be numerically-indexed, where values are versions installed... |
|
| 529 | + // fix it! |
|
| 530 | + $version_string = $should_be_array; |
|
| 531 | + $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
| 532 | + } else { |
|
| 533 | + // ok it checks out |
|
| 534 | + $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
| 535 | + } |
|
| 536 | + } |
|
| 537 | + $espresso_db_update = $corrected_db_update; |
|
| 538 | + update_option('espresso_db_update', $espresso_db_update); |
|
| 539 | + } |
|
| 540 | + do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update); |
|
| 541 | + return $espresso_db_update; |
|
| 542 | + } |
|
| 543 | + |
|
| 544 | + |
|
| 545 | + /** |
|
| 546 | + * Does the traditional work of setting up the plugin's database and adding default data. |
|
| 547 | + * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade. |
|
| 548 | + * NOTE: if we're in maintenance mode (which would be the case if we detect there are data |
|
| 549 | + * migration scripts that need to be run and a version change happens), enqueues core for database initialization, |
|
| 550 | + * so that it will be done when migrations are finished |
|
| 551 | + * |
|
| 552 | + * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too; |
|
| 553 | + * @param boolean $verify_schema if true will re-check the database tables have the correct schema. |
|
| 554 | + * This is a resource-intensive job |
|
| 555 | + * so we prefer to only do it when necessary |
|
| 556 | + * @return void |
|
| 557 | + * @throws EE_Error |
|
| 558 | + */ |
|
| 559 | + public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true) |
|
| 560 | + { |
|
| 561 | + $request_type = $this->detect_req_type(); |
|
| 562 | + // only initialize system if we're not in maintenance mode. |
|
| 563 | + if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) { |
|
| 564 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
| 565 | + $rewrite_rules = $this->loader->getShared( |
|
| 566 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
| 567 | + ); |
|
| 568 | + $rewrite_rules->flush(); |
|
| 569 | + if ($verify_schema) { |
|
| 570 | + EEH_Activation::initialize_db_and_folders(); |
|
| 571 | + } |
|
| 572 | + EEH_Activation::initialize_db_content(); |
|
| 573 | + EEH_Activation::system_initialization(); |
|
| 574 | + if ($initialize_addons_too) { |
|
| 575 | + $this->initialize_addons(); |
|
| 576 | + } |
|
| 577 | + } else { |
|
| 578 | + EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core'); |
|
| 579 | + } |
|
| 580 | + if ($request_type === EE_System::req_type_new_activation |
|
| 581 | + || $request_type === EE_System::req_type_reactivation |
|
| 582 | + || ( |
|
| 583 | + $request_type === EE_System::req_type_upgrade |
|
| 584 | + && $this->is_major_version_change() |
|
| 585 | + ) |
|
| 586 | + ) { |
|
| 587 | + add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9); |
|
| 588 | + } |
|
| 589 | + } |
|
| 590 | + |
|
| 591 | + |
|
| 592 | + /** |
|
| 593 | + * Initializes the db for all registered addons |
|
| 594 | + * |
|
| 595 | + * @throws EE_Error |
|
| 596 | + */ |
|
| 597 | + public function initialize_addons() |
|
| 598 | + { |
|
| 599 | + // foreach registered addon, make sure its db is up-to-date too |
|
| 600 | + foreach ($this->registry->addons as $addon) { |
|
| 601 | + if ($addon instanceof EE_Addon) { |
|
| 602 | + $addon->initialize_db_if_no_migrations_required(); |
|
| 603 | + } |
|
| 604 | + } |
|
| 605 | + } |
|
| 606 | + |
|
| 607 | + |
|
| 608 | + /** |
|
| 609 | + * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed. |
|
| 610 | + * |
|
| 611 | + * @param array $version_history |
|
| 612 | + * @param string $current_version_to_add version to be added to the version history |
|
| 613 | + * @return boolean success as to whether or not this option was changed |
|
| 614 | + */ |
|
| 615 | + public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
|
| 616 | + { |
|
| 617 | + if (! $version_history) { |
|
| 618 | + $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
|
| 619 | + } |
|
| 620 | + if ($current_version_to_add === null) { |
|
| 621 | + $current_version_to_add = espresso_version(); |
|
| 622 | + } |
|
| 623 | + $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
| 624 | + // re-save |
|
| 625 | + return update_option('espresso_db_update', $version_history); |
|
| 626 | + } |
|
| 627 | + |
|
| 628 | + |
|
| 629 | + /** |
|
| 630 | + * Detects if the current version indicated in the has existed in the list of |
|
| 631 | + * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect) |
|
| 632 | + * |
|
| 633 | + * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'. |
|
| 634 | + * If not supplied, fetches it from the options table. |
|
| 635 | + * Also, caches its result so later parts of the code can also know whether |
|
| 636 | + * there's been an update or not. This way we can add the current version to |
|
| 637 | + * espresso_db_update, but still know if this is a new install or not |
|
| 638 | + * @return int one of the constants on EE_System::req_type_ |
|
| 639 | + */ |
|
| 640 | + public function detect_req_type($espresso_db_update = null) |
|
| 641 | + { |
|
| 642 | + if ($this->_req_type === null) { |
|
| 643 | + $espresso_db_update = ! empty($espresso_db_update) |
|
| 644 | + ? $espresso_db_update |
|
| 645 | + : $this->fix_espresso_db_upgrade_option(); |
|
| 646 | + $this->_req_type = EE_System::detect_req_type_given_activation_history( |
|
| 647 | + $espresso_db_update, |
|
| 648 | + 'ee_espresso_activation', |
|
| 649 | + espresso_version() |
|
| 650 | + ); |
|
| 651 | + $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update); |
|
| 652 | + $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal); |
|
| 653 | + } |
|
| 654 | + return $this->_req_type; |
|
| 655 | + } |
|
| 656 | + |
|
| 657 | + |
|
| 658 | + /** |
|
| 659 | + * Returns whether or not there was a non-micro version change (ie, change in either |
|
| 660 | + * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000, |
|
| 661 | + * but not 4.9.0.rc.0001 to 4.9.1.rc.0001 |
|
| 662 | + * |
|
| 663 | + * @param $activation_history |
|
| 664 | + * @return bool |
|
| 665 | + */ |
|
| 666 | + private function _detect_major_version_change($activation_history) |
|
| 667 | + { |
|
| 668 | + $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history); |
|
| 669 | + $previous_version_parts = explode('.', $previous_version); |
|
| 670 | + $current_version_parts = explode('.', espresso_version()); |
|
| 671 | + return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1]) |
|
| 672 | + && ( |
|
| 673 | + $previous_version_parts[0] !== $current_version_parts[0] |
|
| 674 | + || $previous_version_parts[1] !== $current_version_parts[1] |
|
| 675 | + ); |
|
| 676 | + } |
|
| 677 | + |
|
| 678 | + |
|
| 679 | + /** |
|
| 680 | + * Returns true if either the major or minor version of EE changed during this request. |
|
| 681 | + * 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 |
|
| 682 | + * |
|
| 683 | + * @return bool |
|
| 684 | + */ |
|
| 685 | + public function is_major_version_change() |
|
| 686 | + { |
|
| 687 | + return $this->_major_version_change; |
|
| 688 | + } |
|
| 689 | + |
|
| 690 | + |
|
| 691 | + /** |
|
| 692 | + * Determines the request type for any ee addon, given three piece of info: the current array of activation |
|
| 693 | + * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily |
|
| 694 | + * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was |
|
| 695 | + * just activated to (for core that will always be espresso_version()) |
|
| 696 | + * |
|
| 697 | + * @param array $activation_history_for_addon the option's value which stores the activation history for this |
|
| 698 | + * ee plugin. for core that's 'espresso_db_update' |
|
| 699 | + * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to |
|
| 700 | + * indicate that this plugin was just activated |
|
| 701 | + * @param string $version_to_upgrade_to the version that was just upgraded to (for core that will be |
|
| 702 | + * espresso_version()) |
|
| 703 | + * @return int one of the constants on EE_System::req_type_* |
|
| 704 | + */ |
|
| 705 | + public static function detect_req_type_given_activation_history( |
|
| 706 | + $activation_history_for_addon, |
|
| 707 | + $activation_indicator_option_name, |
|
| 708 | + $version_to_upgrade_to |
|
| 709 | + ) { |
|
| 710 | + $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to); |
|
| 711 | + if ($activation_history_for_addon) { |
|
| 712 | + // it exists, so this isn't a completely new install |
|
| 713 | + // check if this version already in that list of previously installed versions |
|
| 714 | + if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
| 715 | + // it a version we haven't seen before |
|
| 716 | + if ($version_is_higher === 1) { |
|
| 717 | + $req_type = EE_System::req_type_upgrade; |
|
| 718 | + } else { |
|
| 719 | + $req_type = EE_System::req_type_downgrade; |
|
| 720 | + } |
|
| 721 | + delete_option($activation_indicator_option_name); |
|
| 722 | + } else { |
|
| 723 | + // its not an update. maybe a reactivation? |
|
| 724 | + if (get_option($activation_indicator_option_name, false)) { |
|
| 725 | + if ($version_is_higher === -1) { |
|
| 726 | + $req_type = EE_System::req_type_downgrade; |
|
| 727 | + } elseif ($version_is_higher === 0) { |
|
| 728 | + // we've seen this version before, but it's an activation. must be a reactivation |
|
| 729 | + $req_type = EE_System::req_type_reactivation; |
|
| 730 | + } else {// $version_is_higher === 1 |
|
| 731 | + $req_type = EE_System::req_type_upgrade; |
|
| 732 | + } |
|
| 733 | + delete_option($activation_indicator_option_name); |
|
| 734 | + } else { |
|
| 735 | + // we've seen this version before and the activation indicate doesn't show it was just activated |
|
| 736 | + if ($version_is_higher === -1) { |
|
| 737 | + $req_type = EE_System::req_type_downgrade; |
|
| 738 | + } elseif ($version_is_higher === 0) { |
|
| 739 | + // we've seen this version before and it's not an activation. its normal request |
|
| 740 | + $req_type = EE_System::req_type_normal; |
|
| 741 | + } else {// $version_is_higher === 1 |
|
| 742 | + $req_type = EE_System::req_type_upgrade; |
|
| 743 | + } |
|
| 744 | + } |
|
| 745 | + } |
|
| 746 | + } else { |
|
| 747 | + // brand new install |
|
| 748 | + $req_type = EE_System::req_type_new_activation; |
|
| 749 | + delete_option($activation_indicator_option_name); |
|
| 750 | + } |
|
| 751 | + return $req_type; |
|
| 752 | + } |
|
| 753 | + |
|
| 754 | + |
|
| 755 | + /** |
|
| 756 | + * Detects if the $version_to_upgrade_to is higher than the most recent version in |
|
| 757 | + * the $activation_history_for_addon |
|
| 758 | + * |
|
| 759 | + * @param array $activation_history_for_addon (keys are versions, values are arrays of times activated, |
|
| 760 | + * sometimes containing 'unknown-date' |
|
| 761 | + * @param string $version_to_upgrade_to (current version) |
|
| 762 | + * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ). |
|
| 763 | + * ie, -1 if $version_to_upgrade_to is LOWER (downgrade); |
|
| 764 | + * 0 if $version_to_upgrade_to MATCHES (reactivation or normal request); |
|
| 765 | + * 1 if $version_to_upgrade_to is HIGHER (upgrade) ; |
|
| 766 | + */ |
|
| 767 | + private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to) |
|
| 768 | + { |
|
| 769 | + // find the most recently-activated version |
|
| 770 | + $most_recently_active_version = |
|
| 771 | + EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon); |
|
| 772 | + return version_compare($version_to_upgrade_to, $most_recently_active_version); |
|
| 773 | + } |
|
| 774 | + |
|
| 775 | + |
|
| 776 | + /** |
|
| 777 | + * Gets the most recently active version listed in the activation history, |
|
| 778 | + * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'. |
|
| 779 | + * |
|
| 780 | + * @param array $activation_history (keys are versions, values are arrays of times activated, |
|
| 781 | + * sometimes containing 'unknown-date' |
|
| 782 | + * @return string |
|
| 783 | + */ |
|
| 784 | + private static function _get_most_recently_active_version_from_activation_history($activation_history) |
|
| 785 | + { |
|
| 786 | + $most_recently_active_version_activation = '1970-01-01 00:00:00'; |
|
| 787 | + $most_recently_active_version = '0.0.0.dev.000'; |
|
| 788 | + if (is_array($activation_history)) { |
|
| 789 | + foreach ($activation_history as $version => $times_activated) { |
|
| 790 | + // check there is a record of when this version was activated. Otherwise, |
|
| 791 | + // mark it as unknown |
|
| 792 | + if (! $times_activated) { |
|
| 793 | + $times_activated = array('unknown-date'); |
|
| 794 | + } |
|
| 795 | + if (is_string($times_activated)) { |
|
| 796 | + $times_activated = array($times_activated); |
|
| 797 | + } |
|
| 798 | + foreach ($times_activated as $an_activation) { |
|
| 799 | + if ($an_activation !== 'unknown-date' |
|
| 800 | + && $an_activation |
|
| 801 | + > $most_recently_active_version_activation) { |
|
| 802 | + $most_recently_active_version = $version; |
|
| 803 | + $most_recently_active_version_activation = $an_activation === 'unknown-date' |
|
| 804 | + ? '1970-01-01 00:00:00' |
|
| 805 | + : $an_activation; |
|
| 806 | + } |
|
| 807 | + } |
|
| 808 | + } |
|
| 809 | + } |
|
| 810 | + return $most_recently_active_version; |
|
| 811 | + } |
|
| 812 | + |
|
| 813 | + |
|
| 814 | + /** |
|
| 815 | + * This redirects to the about EE page after activation |
|
| 816 | + * |
|
| 817 | + * @return void |
|
| 818 | + */ |
|
| 819 | + public function redirect_to_about_ee() |
|
| 820 | + { |
|
| 821 | + $notices = EE_Error::get_notices(false); |
|
| 822 | + // if current user is an admin and it's not an ajax or rest request |
|
| 823 | + if (! isset($notices['errors']) |
|
| 824 | + && $this->request->isAdmin() |
|
| 825 | + && apply_filters( |
|
| 826 | + 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
|
| 827 | + $this->capabilities->current_user_can('manage_options', 'espresso_about_default') |
|
| 828 | + ) |
|
| 829 | + ) { |
|
| 830 | + $query_params = array('page' => 'espresso_about'); |
|
| 831 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) { |
|
| 832 | + $query_params['new_activation'] = true; |
|
| 833 | + } |
|
| 834 | + if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) { |
|
| 835 | + $query_params['reactivation'] = true; |
|
| 836 | + } |
|
| 837 | + $url = add_query_arg($query_params, admin_url('admin.php')); |
|
| 838 | + wp_safe_redirect($url); |
|
| 839 | + exit(); |
|
| 840 | + } |
|
| 841 | + } |
|
| 842 | + |
|
| 843 | + |
|
| 844 | + /** |
|
| 845 | + * load_core_configuration |
|
| 846 | + * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration' |
|
| 847 | + * which runs during the WP 'plugins_loaded' action at priority 5 |
|
| 848 | + * |
|
| 849 | + * @return void |
|
| 850 | + * @throws ReflectionException |
|
| 851 | + * @throws Exception |
|
| 852 | + */ |
|
| 853 | + public function load_core_configuration() |
|
| 854 | + { |
|
| 855 | + do_action('AHEE__EE_System__load_core_configuration__begin', $this); |
|
| 856 | + $this->loader->getShared('EE_Load_Textdomain'); |
|
| 857 | + // load textdomain |
|
| 858 | + EE_Load_Textdomain::load_textdomain(); |
|
| 859 | + // load caf stuff a chance to play during the activation process too. |
|
| 860 | + $this->_maybe_brew_regular(); |
|
| 861 | + // load and setup EE_Config and EE_Network_Config |
|
| 862 | + $config = $this->loader->getShared('EE_Config'); |
|
| 863 | + $this->loader->getShared('EE_Network_Config'); |
|
| 864 | + // setup autoloaders |
|
| 865 | + // enable logging? |
|
| 866 | + if ($config->admin->use_remote_logging) { |
|
| 867 | + $this->loader->getShared('EE_Log'); |
|
| 868 | + } |
|
| 869 | + // check for activation errors |
|
| 870 | + $activation_errors = get_option('ee_plugin_activation_errors', false); |
|
| 871 | + if ($activation_errors) { |
|
| 872 | + EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__); |
|
| 873 | + update_option('ee_plugin_activation_errors', false); |
|
| 874 | + } |
|
| 875 | + // get model names |
|
| 876 | + $this->_parse_model_names(); |
|
| 877 | + // configure custom post type definitions |
|
| 878 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions'); |
|
| 879 | + $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'); |
|
| 880 | + do_action('AHEE__EE_System__load_core_configuration__complete', $this); |
|
| 881 | + } |
|
| 882 | + |
|
| 883 | + |
|
| 884 | + /** |
|
| 885 | + * cycles through all of the models/*.model.php files, and assembles an array of model names |
|
| 886 | + * |
|
| 887 | + * @return void |
|
| 888 | + * @throws ReflectionException |
|
| 889 | + */ |
|
| 890 | + private function _parse_model_names() |
|
| 891 | + { |
|
| 892 | + // get all the files in the EE_MODELS folder that end in .model.php |
|
| 893 | + $models = glob(EE_MODELS . '*.model.php'); |
|
| 894 | + $model_names = array(); |
|
| 895 | + $non_abstract_db_models = array(); |
|
| 896 | + foreach ($models as $model) { |
|
| 897 | + // get model classname |
|
| 898 | + $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model); |
|
| 899 | + $short_name = str_replace('EEM_', '', $classname); |
|
| 900 | + $reflectionClass = new ReflectionClass($classname); |
|
| 901 | + if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
|
| 902 | + $non_abstract_db_models[ $short_name ] = $classname; |
|
| 903 | + } |
|
| 904 | + $model_names[ $short_name ] = $classname; |
|
| 905 | + } |
|
| 906 | + $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
|
| 907 | + $this->registry->non_abstract_db_models = apply_filters( |
|
| 908 | + 'FHEE__EE_System__parse_implemented_model_names', |
|
| 909 | + $non_abstract_db_models |
|
| 910 | + ); |
|
| 911 | + } |
|
| 912 | + |
|
| 913 | + |
|
| 914 | + /** |
|
| 915 | + * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks |
|
| 916 | + * that need to be setup before our EE_System launches. |
|
| 917 | + * |
|
| 918 | + * @return void |
|
| 919 | + * @throws DomainException |
|
| 920 | + * @throws InvalidArgumentException |
|
| 921 | + * @throws InvalidDataTypeException |
|
| 922 | + * @throws InvalidInterfaceException |
|
| 923 | + * @throws InvalidClassException |
|
| 924 | + * @throws InvalidFilePathException |
|
| 925 | + */ |
|
| 926 | + private function _maybe_brew_regular() |
|
| 927 | + { |
|
| 928 | + /** @var Domain $domain */ |
|
| 929 | + $domain = DomainFactory::getShared( |
|
| 930 | + new FullyQualifiedName( |
|
| 931 | + 'EventEspresso\core\domain\Domain' |
|
| 932 | + ), |
|
| 933 | + array( |
|
| 934 | + new FilePath(EVENT_ESPRESSO_MAIN_FILE), |
|
| 935 | + Version::fromString(espresso_version()), |
|
| 936 | + ) |
|
| 937 | + ); |
|
| 938 | + if ($domain->isCaffeinated()) { |
|
| 939 | + require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 940 | + } |
|
| 941 | + } |
|
| 942 | + |
|
| 943 | + |
|
| 944 | + /** |
|
| 945 | + * @since 4.9.71.p |
|
| 946 | + * @throws Exception |
|
| 947 | + */ |
|
| 948 | + public function loadRouteMatchSpecifications() |
|
| 949 | + { |
|
| 950 | + try { |
|
| 951 | + $this->router = $this->loader->getShared('EventEspresso\core\services\route_match\RouteHandler'); |
|
| 952 | + } catch (Exception $exception) { |
|
| 953 | + new ExceptionStackTraceDisplay($exception); |
|
| 954 | + } |
|
| 955 | + do_action('AHEE__EE_System__loadRouteMatchSpecifications'); |
|
| 956 | + } |
|
| 957 | + |
|
| 958 | + |
|
| 959 | + /** |
|
| 960 | + * register_shortcodes_modules_and_widgets |
|
| 961 | + * generate lists of shortcodes and modules, then verify paths and classes |
|
| 962 | + * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets' |
|
| 963 | + * which runs during the WP 'plugins_loaded' action at priority 7 |
|
| 964 | + * |
|
| 965 | + * @access public |
|
| 966 | + * @return void |
|
| 967 | + * @throws Exception |
|
| 968 | + */ |
|
| 969 | + public function register_shortcodes_modules_and_widgets() |
|
| 970 | + { |
|
| 971 | + $this->router->handleShortcodesRequest(); |
|
| 972 | + do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets'); |
|
| 973 | + // check for addons using old hook point |
|
| 974 | + if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) { |
|
| 975 | + $this->_incompatible_addon_error(); |
|
| 976 | + } |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + |
|
| 980 | + /** |
|
| 981 | + * _incompatible_addon_error |
|
| 982 | + * |
|
| 983 | + * @access public |
|
| 984 | + * @return void |
|
| 985 | + */ |
|
| 986 | + private function _incompatible_addon_error() |
|
| 987 | + { |
|
| 988 | + // get array of classes hooking into here |
|
| 989 | + $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
|
| 990 | + 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
|
| 991 | + ); |
|
| 992 | + if (! empty($class_names)) { |
|
| 993 | + $msg = __( |
|
| 994 | + 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
|
| 995 | + 'event_espresso' |
|
| 996 | + ); |
|
| 997 | + $msg .= '<ul>'; |
|
| 998 | + foreach ($class_names as $class_name) { |
|
| 999 | + $msg .= '<li><b>Event Espresso - ' |
|
| 1000 | + . str_replace( |
|
| 1001 | + array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
|
| 1002 | + '', |
|
| 1003 | + $class_name |
|
| 1004 | + ) . '</b></li>'; |
|
| 1005 | + } |
|
| 1006 | + $msg .= '</ul>'; |
|
| 1007 | + $msg .= __( |
|
| 1008 | + 'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.', |
|
| 1009 | + 'event_espresso' |
|
| 1010 | + ); |
|
| 1011 | + // save list of incompatible addons to wp-options for later use |
|
| 1012 | + add_option('ee_incompatible_addons', $class_names, '', 'no'); |
|
| 1013 | + if (is_admin()) { |
|
| 1014 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
| 1015 | + } |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + |
|
| 1019 | + |
|
| 1020 | + /** |
|
| 1021 | + * brew_espresso |
|
| 1022 | + * begins the process of setting hooks for initializing EE in the correct order |
|
| 1023 | + * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point |
|
| 1024 | + * which runs during the WP 'plugins_loaded' action at priority 9 |
|
| 1025 | + * |
|
| 1026 | + * @return void |
|
| 1027 | + * @throws Exception |
|
| 1028 | + */ |
|
| 1029 | + public function brew_espresso() |
|
| 1030 | + { |
|
| 1031 | + do_action('AHEE__EE_System__brew_espresso__begin', $this); |
|
| 1032 | + // load some final core systems |
|
| 1033 | + add_action('init', array($this, 'set_hooks_for_core'), 1); |
|
| 1034 | + add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3); |
|
| 1035 | + add_action('init', array($this, 'load_CPTs_and_session'), 5); |
|
| 1036 | + add_action('init', array($this, 'load_controllers'), 7); |
|
| 1037 | + add_action('init', array($this, 'core_loaded_and_ready'), 9); |
|
| 1038 | + add_action('init', array($this, 'initialize'), 10); |
|
| 1039 | + add_action('init', array($this, 'initialize_last'), 100); |
|
| 1040 | + $this->router->handlePueRequest(); |
|
| 1041 | + $this->router->handleGQLRequest(); |
|
| 1042 | + do_action('AHEE__EE_System__brew_espresso__complete', $this); |
|
| 1043 | + } |
|
| 1044 | + |
|
| 1045 | + |
|
| 1046 | + /** |
|
| 1047 | + * set_hooks_for_core |
|
| 1048 | + * |
|
| 1049 | + * @access public |
|
| 1050 | + * @return void |
|
| 1051 | + * @throws EE_Error |
|
| 1052 | + */ |
|
| 1053 | + public function set_hooks_for_core() |
|
| 1054 | + { |
|
| 1055 | + $this->_deactivate_incompatible_addons(); |
|
| 1056 | + do_action('AHEE__EE_System__set_hooks_for_core'); |
|
| 1057 | + $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan'); |
|
| 1058 | + // caps need to be initialized on every request so that capability maps are set. |
|
| 1059 | + // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674 |
|
| 1060 | + $this->registry->CAP->init_caps(); |
|
| 1061 | + } |
|
| 1062 | + |
|
| 1063 | + |
|
| 1064 | + /** |
|
| 1065 | + * Using the information gathered in EE_System::_incompatible_addon_error, |
|
| 1066 | + * deactivates any addons considered incompatible with the current version of EE |
|
| 1067 | + */ |
|
| 1068 | + private function _deactivate_incompatible_addons() |
|
| 1069 | + { |
|
| 1070 | + $incompatible_addons = get_option('ee_incompatible_addons', array()); |
|
| 1071 | + if (! empty($incompatible_addons)) { |
|
| 1072 | + $active_plugins = get_option('active_plugins', array()); |
|
| 1073 | + foreach ($active_plugins as $active_plugin) { |
|
| 1074 | + foreach ($incompatible_addons as $incompatible_addon) { |
|
| 1075 | + if (strpos($active_plugin, $incompatible_addon) !== false) { |
|
| 1076 | + unset($_GET['activate']); |
|
| 1077 | + espresso_deactivate_plugin($active_plugin); |
|
| 1078 | + } |
|
| 1079 | + } |
|
| 1080 | + } |
|
| 1081 | + } |
|
| 1082 | + } |
|
| 1083 | + |
|
| 1084 | + |
|
| 1085 | + /** |
|
| 1086 | + * perform_activations_upgrades_and_migrations |
|
| 1087 | + * |
|
| 1088 | + * @access public |
|
| 1089 | + * @return void |
|
| 1090 | + */ |
|
| 1091 | + public function perform_activations_upgrades_and_migrations() |
|
| 1092 | + { |
|
| 1093 | + do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations'); |
|
| 1094 | + } |
|
| 1095 | + |
|
| 1096 | + |
|
| 1097 | + /** |
|
| 1098 | + * @return void |
|
| 1099 | + * @throws DomainException |
|
| 1100 | + */ |
|
| 1101 | + public function load_CPTs_and_session() |
|
| 1102 | + { |
|
| 1103 | + do_action('AHEE__EE_System__load_CPTs_and_session__start'); |
|
| 1104 | + /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */ |
|
| 1105 | + $register_custom_taxonomies = $this->loader->getShared( |
|
| 1106 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' |
|
| 1107 | + ); |
|
| 1108 | + $register_custom_taxonomies->registerCustomTaxonomies(); |
|
| 1109 | + /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */ |
|
| 1110 | + $register_custom_post_types = $this->loader->getShared( |
|
| 1111 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' |
|
| 1112 | + ); |
|
| 1113 | + $register_custom_post_types->registerCustomPostTypes(); |
|
| 1114 | + /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */ |
|
| 1115 | + $register_custom_taxonomy_terms = $this->loader->getShared( |
|
| 1116 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms' |
|
| 1117 | + ); |
|
| 1118 | + $register_custom_taxonomy_terms->registerCustomTaxonomyTerms(); |
|
| 1119 | + // load legacy Custom Post Types and Taxonomies |
|
| 1120 | + $this->loader->getShared('EE_Register_CPTs'); |
|
| 1121 | + do_action('AHEE__EE_System__load_CPTs_and_session__complete'); |
|
| 1122 | + } |
|
| 1123 | + |
|
| 1124 | + |
|
| 1125 | + /** |
|
| 1126 | + * load_controllers |
|
| 1127 | + * this is the best place to load any additional controllers that needs access to EE core. |
|
| 1128 | + * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this |
|
| 1129 | + * time |
|
| 1130 | + * |
|
| 1131 | + * @access public |
|
| 1132 | + * @return void |
|
| 1133 | + * @throws Exception |
|
| 1134 | + */ |
|
| 1135 | + public function load_controllers() |
|
| 1136 | + { |
|
| 1137 | + do_action('AHEE__EE_System__load_controllers__start'); |
|
| 1138 | + // let's get it started |
|
| 1139 | + $this->router->handleControllerRequest(); |
|
| 1140 | + do_action('AHEE__EE_System__load_controllers__complete'); |
|
| 1141 | + } |
|
| 1142 | + |
|
| 1143 | + |
|
| 1144 | + /** |
|
| 1145 | + * core_loaded_and_ready |
|
| 1146 | + * all of the basic EE core should be loaded at this point and available regardless of M-Mode |
|
| 1147 | + * |
|
| 1148 | + * @access public |
|
| 1149 | + * @return void |
|
| 1150 | + * @throws Exception |
|
| 1151 | + */ |
|
| 1152 | + public function core_loaded_and_ready() |
|
| 1153 | + { |
|
| 1154 | + $this->router->handleAssetManagerRequest(); |
|
| 1155 | + $this->router->handleSessionRequest(); |
|
| 1156 | + // integrate WP_Query with the EE models |
|
| 1157 | + $this->loader->getShared('EE_CPT_Strategy'); |
|
| 1158 | + do_action('AHEE__EE_System__core_loaded_and_ready'); |
|
| 1159 | + // always load template tags, because it's faster than checking if it's a front-end request, and many page |
|
| 1160 | + // builders require these even on the front-end |
|
| 1161 | + require_once EE_PUBLIC . 'template_tags.php'; |
|
| 1162 | + do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
|
| 1163 | + } |
|
| 1164 | + |
|
| 1165 | + |
|
| 1166 | + /** |
|
| 1167 | + * initialize |
|
| 1168 | + * this is the best place to begin initializing client code |
|
| 1169 | + * |
|
| 1170 | + * @access public |
|
| 1171 | + * @return void |
|
| 1172 | + */ |
|
| 1173 | + public function initialize() |
|
| 1174 | + { |
|
| 1175 | + do_action('AHEE__EE_System__initialize'); |
|
| 1176 | + } |
|
| 1177 | + |
|
| 1178 | + |
|
| 1179 | + /** |
|
| 1180 | + * initialize_last |
|
| 1181 | + * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to |
|
| 1182 | + * initialize has done so |
|
| 1183 | + * |
|
| 1184 | + * @access public |
|
| 1185 | + * @return void |
|
| 1186 | + * @throws Exception |
|
| 1187 | + */ |
|
| 1188 | + public function initialize_last() |
|
| 1189 | + { |
|
| 1190 | + do_action('AHEE__EE_System__initialize_last'); |
|
| 1191 | + /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */ |
|
| 1192 | + $rewrite_rules = $this->loader->getShared( |
|
| 1193 | + 'EventEspresso\core\domain\services\custom_post_types\RewriteRules' |
|
| 1194 | + ); |
|
| 1195 | + $rewrite_rules->flushRewriteRules(); |
|
| 1196 | + add_action('admin_bar_init', array($this, 'addEspressoToolbar')); |
|
| 1197 | + $this->router->handlePersonalDataRequest(); |
|
| 1198 | + } |
|
| 1199 | + |
|
| 1200 | + |
|
| 1201 | + /** |
|
| 1202 | + * @return void |
|
| 1203 | + */ |
|
| 1204 | + public function addEspressoToolbar() |
|
| 1205 | + { |
|
| 1206 | + $this->loader->getShared( |
|
| 1207 | + 'EventEspresso\core\domain\services\admin\AdminToolBar', |
|
| 1208 | + array($this->registry->CAP) |
|
| 1209 | + ); |
|
| 1210 | + } |
|
| 1211 | + |
|
| 1212 | + |
|
| 1213 | + /** |
|
| 1214 | + * do_not_cache |
|
| 1215 | + * sets no cache headers and defines no cache constants for WP plugins |
|
| 1216 | + * |
|
| 1217 | + * @access public |
|
| 1218 | + * @return void |
|
| 1219 | + */ |
|
| 1220 | + public static function do_not_cache() |
|
| 1221 | + { |
|
| 1222 | + // set no cache constants |
|
| 1223 | + if (! defined('DONOTCACHEPAGE')) { |
|
| 1224 | + define('DONOTCACHEPAGE', true); |
|
| 1225 | + } |
|
| 1226 | + if (! defined('DONOTCACHCEOBJECT')) { |
|
| 1227 | + define('DONOTCACHCEOBJECT', true); |
|
| 1228 | + } |
|
| 1229 | + if (! defined('DONOTCACHEDB')) { |
|
| 1230 | + define('DONOTCACHEDB', true); |
|
| 1231 | + } |
|
| 1232 | + // add no cache headers |
|
| 1233 | + add_action('send_headers', array('EE_System', 'nocache_headers'), 10); |
|
| 1234 | + // plus a little extra for nginx and Google Chrome |
|
| 1235 | + add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1); |
|
| 1236 | + // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process |
|
| 1237 | + remove_action('wp_head', 'adjacent_posts_rel_link_wp_head'); |
|
| 1238 | + } |
|
| 1239 | + |
|
| 1240 | + |
|
| 1241 | + /** |
|
| 1242 | + * extra_nocache_headers |
|
| 1243 | + * |
|
| 1244 | + * @access public |
|
| 1245 | + * @param $headers |
|
| 1246 | + * @return array |
|
| 1247 | + */ |
|
| 1248 | + public static function extra_nocache_headers($headers) |
|
| 1249 | + { |
|
| 1250 | + // for NGINX |
|
| 1251 | + $headers['X-Accel-Expires'] = 0; |
|
| 1252 | + // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store" |
|
| 1253 | + $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0'; |
|
| 1254 | + return $headers; |
|
| 1255 | + } |
|
| 1256 | + |
|
| 1257 | + |
|
| 1258 | + /** |
|
| 1259 | + * nocache_headers |
|
| 1260 | + * |
|
| 1261 | + * @access public |
|
| 1262 | + * @return void |
|
| 1263 | + */ |
|
| 1264 | + public static function nocache_headers() |
|
| 1265 | + { |
|
| 1266 | + nocache_headers(); |
|
| 1267 | + } |
|
| 1268 | + |
|
| 1269 | + |
|
| 1270 | + /** |
|
| 1271 | + * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are |
|
| 1272 | + * never returned with the function. |
|
| 1273 | + * |
|
| 1274 | + * @param array $exclude_array any existing pages being excluded are in this array. |
|
| 1275 | + * @return array |
|
| 1276 | + */ |
|
| 1277 | + public function remove_pages_from_wp_list_pages($exclude_array) |
|
| 1278 | + { |
|
| 1279 | + return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array()); |
|
| 1280 | + } |
|
| 1281 | 1281 | } |
@@ -149,7 +149,7 @@ discard block |
||
| 149 | 149 | EE_Maintenance_Mode $maintenance_mode = null |
| 150 | 150 | ) { |
| 151 | 151 | // check if class object is instantiated |
| 152 | - if (! self::$_instance instanceof EE_System) { |
|
| 152 | + if ( ! self::$_instance instanceof EE_System) { |
|
| 153 | 153 | self::$_instance = new self($registry, $loader, $request, $maintenance_mode); |
| 154 | 154 | } |
| 155 | 155 | return self::$_instance; |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | $this->capabilities = $this->loader->getShared('EE_Capabilities'); |
| 271 | 271 | add_action( |
| 272 | 272 | 'AHEE__EE_Capabilities__init_caps__before_initialization', |
| 273 | - function () { |
|
| 273 | + function() { |
|
| 274 | 274 | LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager'); |
| 275 | 275 | } |
| 276 | 276 | ); |
@@ -310,7 +310,7 @@ discard block |
||
| 310 | 310 | { |
| 311 | 311 | // set autoloaders for all of the classes implementing EEI_Plugin_API |
| 312 | 312 | // which provide helpers for EE plugin authors to more easily register certain components with EE. |
| 313 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api'); |
|
| 313 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api'); |
|
| 314 | 314 | $this->loader->getShared('EE_Request_Handler'); |
| 315 | 315 | } |
| 316 | 316 | |
@@ -330,14 +330,14 @@ discard block |
||
| 330 | 330 | $load_callback, |
| 331 | 331 | $plugin_file_constant |
| 332 | 332 | ) { |
| 333 | - if (! defined($version_constant)) { |
|
| 333 | + if ( ! defined($version_constant)) { |
|
| 334 | 334 | return; |
| 335 | 335 | } |
| 336 | 336 | $addon_version = constant($version_constant); |
| 337 | 337 | if ($addon_version && version_compare($addon_version, $min_version_required, '<')) { |
| 338 | 338 | remove_action('AHEE__EE_System__load_espresso_addons', $load_callback); |
| 339 | - if (! function_exists('deactivate_plugins')) { |
|
| 340 | - require_once ABSPATH . 'wp-admin/includes/plugin.php'; |
|
| 339 | + if ( ! function_exists('deactivate_plugins')) { |
|
| 340 | + require_once ABSPATH.'wp-admin/includes/plugin.php'; |
|
| 341 | 341 | } |
| 342 | 342 | deactivate_plugins(plugin_basename(constant($plugin_file_constant))); |
| 343 | 343 | unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']); |
@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | $min_version_required |
| 352 | 352 | ), |
| 353 | 353 | __FILE__, |
| 354 | - __FUNCTION__ . "({$addon_name})", |
|
| 354 | + __FUNCTION__."({$addon_name})", |
|
| 355 | 355 | __LINE__ |
| 356 | 356 | ); |
| 357 | 357 | EE_Error::get_notices(false, true); |
@@ -402,7 +402,7 @@ discard block |
||
| 402 | 402 | true |
| 403 | 403 | ) |
| 404 | 404 | ) { |
| 405 | - include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php'; |
|
| 405 | + include_once EE_THIRD_PARTY.'wp-api-basic-auth/basic-auth.php'; |
|
| 406 | 406 | } |
| 407 | 407 | do_action('AHEE__EE_System__load_espresso_addons__complete'); |
| 408 | 408 | } |
@@ -504,11 +504,11 @@ discard block |
||
| 504 | 504 | private function fix_espresso_db_upgrade_option($espresso_db_update = null) |
| 505 | 505 | { |
| 506 | 506 | do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update); |
| 507 | - if (! $espresso_db_update) { |
|
| 507 | + if ( ! $espresso_db_update) { |
|
| 508 | 508 | $espresso_db_update = get_option('espresso_db_update'); |
| 509 | 509 | } |
| 510 | 510 | // check that option is an array |
| 511 | - if (! is_array($espresso_db_update)) { |
|
| 511 | + if ( ! is_array($espresso_db_update)) { |
|
| 512 | 512 | // if option is FALSE, then it never existed |
| 513 | 513 | if ($espresso_db_update === false) { |
| 514 | 514 | // make $espresso_db_update an array and save option with autoload OFF |
@@ -528,10 +528,10 @@ discard block |
||
| 528 | 528 | // so it must be numerically-indexed, where values are versions installed... |
| 529 | 529 | // fix it! |
| 530 | 530 | $version_string = $should_be_array; |
| 531 | - $corrected_db_update[ $version_string ] = array('unknown-date'); |
|
| 531 | + $corrected_db_update[$version_string] = array('unknown-date'); |
|
| 532 | 532 | } else { |
| 533 | 533 | // ok it checks out |
| 534 | - $corrected_db_update[ $should_be_version_string ] = $should_be_array; |
|
| 534 | + $corrected_db_update[$should_be_version_string] = $should_be_array; |
|
| 535 | 535 | } |
| 536 | 536 | } |
| 537 | 537 | $espresso_db_update = $corrected_db_update; |
@@ -614,13 +614,13 @@ discard block |
||
| 614 | 614 | */ |
| 615 | 615 | public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null) |
| 616 | 616 | { |
| 617 | - if (! $version_history) { |
|
| 617 | + if ( ! $version_history) { |
|
| 618 | 618 | $version_history = $this->fix_espresso_db_upgrade_option($version_history); |
| 619 | 619 | } |
| 620 | 620 | if ($current_version_to_add === null) { |
| 621 | 621 | $current_version_to_add = espresso_version(); |
| 622 | 622 | } |
| 623 | - $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time()); |
|
| 623 | + $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time()); |
|
| 624 | 624 | // re-save |
| 625 | 625 | return update_option('espresso_db_update', $version_history); |
| 626 | 626 | } |
@@ -711,7 +711,7 @@ discard block |
||
| 711 | 711 | if ($activation_history_for_addon) { |
| 712 | 712 | // it exists, so this isn't a completely new install |
| 713 | 713 | // check if this version already in that list of previously installed versions |
| 714 | - if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) { |
|
| 714 | + if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) { |
|
| 715 | 715 | // it a version we haven't seen before |
| 716 | 716 | if ($version_is_higher === 1) { |
| 717 | 717 | $req_type = EE_System::req_type_upgrade; |
@@ -789,7 +789,7 @@ discard block |
||
| 789 | 789 | foreach ($activation_history as $version => $times_activated) { |
| 790 | 790 | // check there is a record of when this version was activated. Otherwise, |
| 791 | 791 | // mark it as unknown |
| 792 | - if (! $times_activated) { |
|
| 792 | + if ( ! $times_activated) { |
|
| 793 | 793 | $times_activated = array('unknown-date'); |
| 794 | 794 | } |
| 795 | 795 | if (is_string($times_activated)) { |
@@ -820,7 +820,7 @@ discard block |
||
| 820 | 820 | { |
| 821 | 821 | $notices = EE_Error::get_notices(false); |
| 822 | 822 | // if current user is an admin and it's not an ajax or rest request |
| 823 | - if (! isset($notices['errors']) |
|
| 823 | + if ( ! isset($notices['errors']) |
|
| 824 | 824 | && $this->request->isAdmin() |
| 825 | 825 | && apply_filters( |
| 826 | 826 | 'FHEE__EE_System__redirect_to_about_ee__do_redirect', |
@@ -890,7 +890,7 @@ discard block |
||
| 890 | 890 | private function _parse_model_names() |
| 891 | 891 | { |
| 892 | 892 | // get all the files in the EE_MODELS folder that end in .model.php |
| 893 | - $models = glob(EE_MODELS . '*.model.php'); |
|
| 893 | + $models = glob(EE_MODELS.'*.model.php'); |
|
| 894 | 894 | $model_names = array(); |
| 895 | 895 | $non_abstract_db_models = array(); |
| 896 | 896 | foreach ($models as $model) { |
@@ -899,9 +899,9 @@ discard block |
||
| 899 | 899 | $short_name = str_replace('EEM_', '', $classname); |
| 900 | 900 | $reflectionClass = new ReflectionClass($classname); |
| 901 | 901 | if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) { |
| 902 | - $non_abstract_db_models[ $short_name ] = $classname; |
|
| 902 | + $non_abstract_db_models[$short_name] = $classname; |
|
| 903 | 903 | } |
| 904 | - $model_names[ $short_name ] = $classname; |
|
| 904 | + $model_names[$short_name] = $classname; |
|
| 905 | 905 | } |
| 906 | 906 | $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names); |
| 907 | 907 | $this->registry->non_abstract_db_models = apply_filters( |
@@ -936,7 +936,7 @@ discard block |
||
| 936 | 936 | ) |
| 937 | 937 | ); |
| 938 | 938 | if ($domain->isCaffeinated()) { |
| 939 | - require_once EE_CAFF_PATH . 'brewing_regular.php'; |
|
| 939 | + require_once EE_CAFF_PATH.'brewing_regular.php'; |
|
| 940 | 940 | } |
| 941 | 941 | } |
| 942 | 942 | |
@@ -989,7 +989,7 @@ discard block |
||
| 989 | 989 | $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook( |
| 990 | 990 | 'AHEE__EE_System__register_shortcodes_modules_and_addons' |
| 991 | 991 | ); |
| 992 | - if (! empty($class_names)) { |
|
| 992 | + if ( ! empty($class_names)) { |
|
| 993 | 993 | $msg = __( |
| 994 | 994 | 'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:', |
| 995 | 995 | 'event_espresso' |
@@ -1001,7 +1001,7 @@ discard block |
||
| 1001 | 1001 | array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), |
| 1002 | 1002 | '', |
| 1003 | 1003 | $class_name |
| 1004 | - ) . '</b></li>'; |
|
| 1004 | + ).'</b></li>'; |
|
| 1005 | 1005 | } |
| 1006 | 1006 | $msg .= '</ul>'; |
| 1007 | 1007 | $msg .= __( |
@@ -1068,7 +1068,7 @@ discard block |
||
| 1068 | 1068 | private function _deactivate_incompatible_addons() |
| 1069 | 1069 | { |
| 1070 | 1070 | $incompatible_addons = get_option('ee_incompatible_addons', array()); |
| 1071 | - if (! empty($incompatible_addons)) { |
|
| 1071 | + if ( ! empty($incompatible_addons)) { |
|
| 1072 | 1072 | $active_plugins = get_option('active_plugins', array()); |
| 1073 | 1073 | foreach ($active_plugins as $active_plugin) { |
| 1074 | 1074 | foreach ($incompatible_addons as $incompatible_addon) { |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | do_action('AHEE__EE_System__core_loaded_and_ready'); |
| 1159 | 1159 | // always load template tags, because it's faster than checking if it's a front-end request, and many page |
| 1160 | 1160 | // builders require these even on the front-end |
| 1161 | - require_once EE_PUBLIC . 'template_tags.php'; |
|
| 1161 | + require_once EE_PUBLIC.'template_tags.php'; |
|
| 1162 | 1162 | do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons'); |
| 1163 | 1163 | } |
| 1164 | 1164 | |
@@ -1220,13 +1220,13 @@ discard block |
||
| 1220 | 1220 | public static function do_not_cache() |
| 1221 | 1221 | { |
| 1222 | 1222 | // set no cache constants |
| 1223 | - if (! defined('DONOTCACHEPAGE')) { |
|
| 1223 | + if ( ! defined('DONOTCACHEPAGE')) { |
|
| 1224 | 1224 | define('DONOTCACHEPAGE', true); |
| 1225 | 1225 | } |
| 1226 | - if (! defined('DONOTCACHCEOBJECT')) { |
|
| 1226 | + if ( ! defined('DONOTCACHCEOBJECT')) { |
|
| 1227 | 1227 | define('DONOTCACHCEOBJECT', true); |
| 1228 | 1228 | } |
| 1229 | - if (! defined('DONOTCACHEDB')) { |
|
| 1229 | + if ( ! defined('DONOTCACHEDB')) { |
|
| 1230 | 1230 | define('DONOTCACHEDB', true); |
| 1231 | 1231 | } |
| 1232 | 1232 | // add no cache headers |
@@ -16,1105 +16,1105 @@ discard block |
||
| 16 | 16 | class EED_Events_Archive extends EED_Module |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - const EVENT_DETAILS_PRIORITY = 100; |
|
| 20 | - |
|
| 21 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
| 22 | - |
|
| 23 | - const EVENT_TICKETS_PRIORITY = 120; |
|
| 24 | - |
|
| 25 | - const EVENT_VENUES_PRIORITY = 130; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - public static $espresso_event_list_ID = 0; |
|
| 29 | - |
|
| 30 | - public static $espresso_grid_event_lists = array(); |
|
| 31 | - |
|
| 32 | - /** |
|
| 33 | - * @type bool $using_get_the_excerpt |
|
| 34 | - */ |
|
| 35 | - protected static $using_get_the_excerpt = false; |
|
| 36 | - |
|
| 37 | - /** |
|
| 38 | - * Used to flag when the event list is being called from an external iframe. |
|
| 39 | - * |
|
| 40 | - * @var bool $iframe |
|
| 41 | - */ |
|
| 42 | - protected static $iframe = false; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * @var EventListIframeEmbedButton $_iframe_embed_button |
|
| 46 | - */ |
|
| 47 | - private static $_iframe_embed_button; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * @type EE_Template_Part_Manager $template_parts |
|
| 51 | - */ |
|
| 52 | - protected $template_parts; |
|
| 53 | - |
|
| 54 | - |
|
| 55 | - /** |
|
| 56 | - * @return EED_Events_Archive |
|
| 57 | - */ |
|
| 58 | - public static function instance() |
|
| 59 | - { |
|
| 60 | - return parent::get_instance(__CLASS__); |
|
| 61 | - } |
|
| 62 | - |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 66 | - * |
|
| 67 | - * @return void |
|
| 68 | - * @throws InvalidArgumentException |
|
| 69 | - * @throws InvalidDataTypeException |
|
| 70 | - * @throws InvalidInterfaceException |
|
| 71 | - */ |
|
| 72 | - public static function set_hooks() |
|
| 73 | - { |
|
| 74 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
| 75 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
| 76 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
| 77 | - ); |
|
| 78 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
| 79 | - EE_Config::register_route( |
|
| 80 | - $custom_post_types['espresso_events']['plural_slug'], |
|
| 81 | - 'Events_Archive', |
|
| 82 | - 'run' |
|
| 83 | - ); |
|
| 84 | - EE_Config::register_route( |
|
| 85 | - 'event_list', |
|
| 86 | - 'Events_Archive', |
|
| 87 | - 'event_list' |
|
| 88 | - ); |
|
| 89 | - EE_Config::register_route( |
|
| 90 | - 'iframe', |
|
| 91 | - 'Events_Archive', |
|
| 92 | - 'event_list_iframe', |
|
| 93 | - 'event_list' |
|
| 94 | - ); |
|
| 95 | - add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 96 | - } |
|
| 97 | - |
|
| 98 | - |
|
| 99 | - /** |
|
| 100 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 101 | - * |
|
| 102 | - * @access public |
|
| 103 | - * @return void |
|
| 104 | - */ |
|
| 105 | - public static function set_hooks_admin() |
|
| 106 | - { |
|
| 107 | - add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 108 | - // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
| 109 | - // to load assets for "espresso_events" page on the "default" route (action) |
|
| 110 | - add_action( |
|
| 111 | - 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
| 112 | - array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
| 113 | - 10 |
|
| 114 | - ); |
|
| 115 | - } |
|
| 116 | - |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * set_definitions |
|
| 120 | - * |
|
| 121 | - * @access public |
|
| 122 | - * @return void |
|
| 123 | - */ |
|
| 124 | - public static function set_definitions() |
|
| 125 | - { |
|
| 126 | - define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 127 | - define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
| 128 | - } |
|
| 129 | - |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * set up EE_Events_Archive_Config |
|
| 133 | - */ |
|
| 134 | - protected function set_config() |
|
| 135 | - { |
|
| 136 | - $this->set_config_section('template_settings'); |
|
| 137 | - $this->set_config_class('EE_Events_Archive_Config'); |
|
| 138 | - $this->set_config_name('EED_Events_Archive'); |
|
| 139 | - } |
|
| 140 | - |
|
| 141 | - |
|
| 142 | - /** |
|
| 143 | - * @return EventListIframeEmbedButton |
|
| 144 | - */ |
|
| 145 | - public static function get_iframe_embed_button() |
|
| 146 | - { |
|
| 147 | - if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
| 148 | - self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
| 149 | - } |
|
| 150 | - return self::$_iframe_embed_button; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - |
|
| 154 | - /** |
|
| 155 | - * event_list_iframe_embed_button |
|
| 156 | - * |
|
| 157 | - * @return void |
|
| 158 | - * @throws EE_Error |
|
| 159 | - */ |
|
| 160 | - public static function event_list_iframe_embed_button() |
|
| 161 | - { |
|
| 162 | - $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button(); |
|
| 163 | - $iframe_embed_button->addEmbedButton(); |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - |
|
| 167 | - /** |
|
| 168 | - * initialize_template_parts |
|
| 169 | - * |
|
| 170 | - * @access public |
|
| 171 | - * @param EE_Events_Archive_Config $config |
|
| 172 | - * @return EE_Template_Part_Manager |
|
| 173 | - * @throws EE_Error |
|
| 174 | - */ |
|
| 175 | - public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
| 176 | - { |
|
| 177 | - $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
| 178 | - EEH_Autoloader::register_template_part_autoloaders(); |
|
| 179 | - $template_parts = new EE_Template_Part_Manager(); |
|
| 180 | - $template_parts->add_template_part( |
|
| 181 | - 'tickets', |
|
| 182 | - __('Ticket Selector', 'event_espresso'), |
|
| 183 | - 'content-espresso_events-tickets.php', |
|
| 184 | - $config->display_order_tickets |
|
| 185 | - ); |
|
| 186 | - $template_parts->add_template_part( |
|
| 187 | - 'datetimes', |
|
| 188 | - __('Dates and Times', 'event_espresso'), |
|
| 189 | - 'content-espresso_events-datetimes.php', |
|
| 190 | - $config->display_order_datetimes |
|
| 191 | - ); |
|
| 192 | - $template_parts->add_template_part( |
|
| 193 | - 'event', |
|
| 194 | - __('Event Description', 'event_espresso'), |
|
| 195 | - 'content-espresso_events-details.php', |
|
| 196 | - $config->display_order_event |
|
| 197 | - ); |
|
| 198 | - $template_parts->add_template_part( |
|
| 199 | - 'venue', |
|
| 200 | - __('Venue Information', 'event_espresso'), |
|
| 201 | - 'content-espresso_events-venues.php', |
|
| 202 | - $config->display_order_venue |
|
| 203 | - ); |
|
| 204 | - do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
| 205 | - return $template_parts; |
|
| 206 | - } |
|
| 207 | - |
|
| 208 | - |
|
| 209 | - /** |
|
| 210 | - * run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the |
|
| 211 | - * incoming request |
|
| 212 | - * |
|
| 213 | - * @access public |
|
| 214 | - * @param WP $WP |
|
| 215 | - * @return void |
|
| 216 | - */ |
|
| 217 | - public function run($WP) |
|
| 218 | - { |
|
| 219 | - do_action('AHEE__EED_Events_Archive__before_run'); |
|
| 220 | - // ensure valid EE_Events_Archive_Config() object exists |
|
| 221 | - $this->set_config(); |
|
| 222 | - /** @type EE_Events_Archive_Config $config */ |
|
| 223 | - $config = $this->config(); |
|
| 224 | - // load other required components |
|
| 225 | - $this->load_event_list_assets(); |
|
| 226 | - // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
| 227 | - // add query filters |
|
| 228 | - EEH_Event_Query::add_query_filters(); |
|
| 229 | - // set params that will get used by the filters |
|
| 230 | - EEH_Event_Query::set_query_params( |
|
| 231 | - '', // month |
|
| 232 | - '', // category |
|
| 233 | - $config->display_expired_events, // show_expired |
|
| 234 | - 'start_date', // orderby |
|
| 235 | - 'ASC' // sort |
|
| 236 | - ); |
|
| 237 | - // check what template is loaded |
|
| 238 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 239 | - } |
|
| 240 | - |
|
| 241 | - |
|
| 242 | - /** |
|
| 243 | - * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
| 244 | - * |
|
| 245 | - * @return void |
|
| 246 | - */ |
|
| 247 | - public function event_list() |
|
| 248 | - { |
|
| 249 | - // ensure valid EE_Events_Archive_Config() object exists |
|
| 250 | - $this->set_config(); |
|
| 251 | - // load other required components |
|
| 252 | - $this->load_event_list_assets(); |
|
| 253 | - } |
|
| 254 | - |
|
| 255 | - |
|
| 256 | - /** |
|
| 257 | - * @access public |
|
| 258 | - * @return void |
|
| 259 | - * @throws EE_Error |
|
| 260 | - * @throws DomainException |
|
| 261 | - */ |
|
| 262 | - public function event_list_iframe() |
|
| 263 | - { |
|
| 264 | - EED_Events_Archive::$iframe = true; |
|
| 265 | - $event_list_iframe = new EventsArchiveIframe($this); |
|
| 266 | - $event_list_iframe->display(); |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * @access public |
|
| 272 | - * @return string |
|
| 273 | - */ |
|
| 274 | - public static function is_iframe() |
|
| 275 | - { |
|
| 276 | - return EED_Events_Archive::$iframe; |
|
| 277 | - } |
|
| 278 | - |
|
| 279 | - |
|
| 280 | - /** |
|
| 281 | - * @access public |
|
| 282 | - * @return string |
|
| 283 | - */ |
|
| 284 | - public static function link_target() |
|
| 285 | - { |
|
| 286 | - return EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
| 287 | - } |
|
| 288 | - |
|
| 289 | - |
|
| 290 | - /** |
|
| 291 | - * template_include |
|
| 292 | - * |
|
| 293 | - * @access public |
|
| 294 | - * @param string $template |
|
| 295 | - * @return string |
|
| 296 | - */ |
|
| 297 | - public function template_include($template = '') |
|
| 298 | - { |
|
| 299 | - // don't add content filter for dedicated EE child themes or private posts |
|
| 300 | - if (! EEH_Template::is_espresso_theme()) { |
|
| 301 | - /** @type EE_Events_Archive_Config $config */ |
|
| 302 | - $config = $this->config(); |
|
| 303 | - // add status banner ? |
|
| 304 | - if ($config->display_status_banner) { |
|
| 305 | - add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
| 306 | - } |
|
| 307 | - // if NOT a custom template |
|
| 308 | - if (apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
| 309 | - || EE_Registry::instance() |
|
| 310 | - ->load_core('Front_Controller') |
|
| 311 | - ->get_selected_template() !== 'archive-espresso_events.php' |
|
| 312 | - ) { |
|
| 313 | - // don't display entry meta because the existing theme will take care of that |
|
| 314 | - add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
| 315 | - // load functions.php file for the theme (loaded by WP if using child theme) |
|
| 316 | - EEH_Template::load_espresso_theme_functions(); |
|
| 317 | - // because we don't know if the theme is using the_excerpt() |
|
| 318 | - add_filter( |
|
| 319 | - 'the_excerpt', |
|
| 320 | - array('EED_Events_Archive', 'event_details'), |
|
| 321 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 322 | - ); |
|
| 323 | - // or the_content |
|
| 324 | - add_filter( |
|
| 325 | - 'the_content', |
|
| 326 | - array('EED_Events_Archive', 'event_details'), |
|
| 327 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 328 | - ); |
|
| 329 | - // and just in case they are running get_the_excerpt() which DESTROYS things |
|
| 330 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 331 | - // don't display entry meta because the existing theme will take care of that |
|
| 332 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 333 | - } |
|
| 334 | - } |
|
| 335 | - return $template; |
|
| 336 | - } |
|
| 337 | - |
|
| 338 | - |
|
| 339 | - /** |
|
| 340 | - * get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters |
|
| 341 | - * on the_content() |
|
| 342 | - * |
|
| 343 | - * @access public |
|
| 344 | - * @param string $excerpt |
|
| 345 | - * @return string |
|
| 346 | - */ |
|
| 347 | - public static function get_the_excerpt($excerpt = '') |
|
| 348 | - { |
|
| 349 | - if (post_password_required()) { |
|
| 350 | - return $excerpt; |
|
| 351 | - } |
|
| 352 | - if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
| 353 | - remove_filter( |
|
| 354 | - 'the_excerpt', |
|
| 355 | - array('EED_Events_Archive', 'event_details'), |
|
| 356 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 357 | - ); |
|
| 358 | - remove_filter( |
|
| 359 | - 'the_content', |
|
| 360 | - array('EED_Events_Archive', 'event_details'), |
|
| 361 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 362 | - ); |
|
| 363 | - $excerpt = EED_Events_Archive::event_details($excerpt); |
|
| 364 | - } else { |
|
| 365 | - EED_Events_Archive::$using_get_the_excerpt = true; |
|
| 366 | - add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
| 367 | - } |
|
| 368 | - return $excerpt; |
|
| 369 | - } |
|
| 370 | - |
|
| 371 | - |
|
| 372 | - /** |
|
| 373 | - * end_get_the_excerpt |
|
| 374 | - * |
|
| 375 | - * @access public |
|
| 376 | - * @param string $text |
|
| 377 | - * @return string |
|
| 378 | - */ |
|
| 379 | - public static function end_get_the_excerpt($text = '') |
|
| 380 | - { |
|
| 381 | - EED_Events_Archive::$using_get_the_excerpt = false; |
|
| 382 | - return $text; |
|
| 383 | - } |
|
| 384 | - |
|
| 385 | - |
|
| 386 | - /** |
|
| 387 | - * the_title |
|
| 388 | - * |
|
| 389 | - * @access public |
|
| 390 | - * @param string $title |
|
| 391 | - * @param string $id |
|
| 392 | - * @return string |
|
| 393 | - */ |
|
| 394 | - public static function the_title($title = '', $id = '') |
|
| 395 | - { |
|
| 396 | - global $post; |
|
| 397 | - if ($post instanceof WP_Post) { |
|
| 398 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
| 399 | - } |
|
| 400 | - return $title; |
|
| 401 | - } |
|
| 402 | - |
|
| 403 | - |
|
| 404 | - /** |
|
| 405 | - * event_details |
|
| 406 | - * |
|
| 407 | - * @access public |
|
| 408 | - * @param string $content |
|
| 409 | - * @return string |
|
| 410 | - */ |
|
| 411 | - public static function event_details($content) |
|
| 412 | - { |
|
| 413 | - global $post; |
|
| 414 | - static $current_post_ID = 0; |
|
| 415 | - if ($current_post_ID !== $post->ID |
|
| 416 | - && $post->post_type === 'espresso_events' |
|
| 417 | - && ! EED_Events_Archive::$using_get_the_excerpt |
|
| 418 | - && ! post_password_required() |
|
| 419 | - && ( |
|
| 420 | - apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
| 421 | - || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
| 422 | - ) |
|
| 423 | - ) { |
|
| 424 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 425 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 426 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 427 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 428 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 429 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
| 430 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 431 | - if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
| 432 | - $content = EED_Events_Archive::use_sortable_display_order(); |
|
| 433 | - } else { |
|
| 434 | - $content = EED_Events_Archive::use_filterable_display_order(); |
|
| 435 | - } |
|
| 436 | - } |
|
| 437 | - return $content; |
|
| 438 | - } |
|
| 439 | - |
|
| 440 | - |
|
| 441 | - /** |
|
| 442 | - * use_sortable_display_order |
|
| 443 | - * |
|
| 444 | - * @access protected |
|
| 445 | - * @return string |
|
| 446 | - */ |
|
| 447 | - protected static function use_sortable_display_order() |
|
| 448 | - { |
|
| 449 | - // no further password checks required atm |
|
| 450 | - add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
| 451 | - // we need to first remove this callback from being applied to the_content() or the_excerpt() |
|
| 452 | - // (otherwise it will recurse and blow up the interweb) |
|
| 453 | - remove_filter( |
|
| 454 | - 'the_excerpt', |
|
| 455 | - array('EED_Events_Archive', 'event_details'), |
|
| 456 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 457 | - ); |
|
| 458 | - remove_filter( |
|
| 459 | - 'the_content', |
|
| 460 | - array('EED_Events_Archive', 'event_details'), |
|
| 461 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 462 | - ); |
|
| 463 | - remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 464 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
| 465 | - EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
| 466 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 467 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
| 468 | - // re-add our main filters (or else the next event won't have them) |
|
| 469 | - add_filter( |
|
| 470 | - 'the_excerpt', |
|
| 471 | - array('EED_Events_Archive', 'event_details'), |
|
| 472 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 473 | - ); |
|
| 474 | - add_filter( |
|
| 475 | - 'the_content', |
|
| 476 | - array('EED_Events_Archive', 'event_details'), |
|
| 477 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 478 | - ); |
|
| 479 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 480 | - remove_filter( |
|
| 481 | - 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
| 482 | - '__return_true' |
|
| 483 | - ); |
|
| 484 | - return $content; |
|
| 485 | - } |
|
| 486 | - |
|
| 487 | - |
|
| 488 | - /** |
|
| 489 | - * use_filterable_display_order |
|
| 490 | - * |
|
| 491 | - * @access protected |
|
| 492 | - * @return string |
|
| 493 | - */ |
|
| 494 | - protected static function use_filterable_display_order() |
|
| 495 | - { |
|
| 496 | - // we need to first remove this callback from being applied to the_content() |
|
| 497 | - // (otherwise it will recurse and blow up the interweb) |
|
| 498 | - remove_filter( |
|
| 499 | - 'the_excerpt', |
|
| 500 | - array('EED_Events_Archive', 'event_details'), |
|
| 501 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 502 | - ); |
|
| 503 | - remove_filter( |
|
| 504 | - 'the_content', |
|
| 505 | - array('EED_Events_Archive', 'event_details'), |
|
| 506 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 507 | - ); |
|
| 508 | - remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 509 | - // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
| 510 | - EED_Events_Archive::_add_additional_excerpt_filters(); |
|
| 511 | - EED_Events_Archive::_add_additional_content_filters(); |
|
| 512 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
| 513 | - // now load our template |
|
| 514 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 515 | - // re-add our main filters (or else the next event won't have them) |
|
| 516 | - add_filter( |
|
| 517 | - 'the_excerpt', |
|
| 518 | - array('EED_Events_Archive', 'event_details'), |
|
| 519 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 520 | - ); |
|
| 521 | - add_filter( |
|
| 522 | - 'the_content', |
|
| 523 | - array('EED_Events_Archive', 'event_details'), |
|
| 524 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 525 | - ); |
|
| 526 | - add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 527 | - // but remove the other filters so that they don't get applied to the next post |
|
| 528 | - EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
| 529 | - do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
| 530 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 531 | - // return ! empty( $template ) ? $template : $content; |
|
| 532 | - return $content; |
|
| 533 | - } |
|
| 534 | - |
|
| 535 | - |
|
| 536 | - /** |
|
| 537 | - * event_datetimes - adds datetimes ABOVE content |
|
| 538 | - * |
|
| 539 | - * @access public |
|
| 540 | - * @param string $content |
|
| 541 | - * @return string |
|
| 542 | - */ |
|
| 543 | - public static function event_datetimes($content) |
|
| 544 | - { |
|
| 545 | - if (post_password_required()) { |
|
| 546 | - return $content; |
|
| 547 | - } |
|
| 548 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 549 | - } |
|
| 550 | - |
|
| 551 | - |
|
| 552 | - /** |
|
| 553 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 554 | - * |
|
| 555 | - * @access public |
|
| 556 | - * @param string $content |
|
| 557 | - * @return string |
|
| 558 | - */ |
|
| 559 | - public static function event_tickets($content) |
|
| 560 | - { |
|
| 561 | - if (post_password_required()) { |
|
| 562 | - return $content; |
|
| 563 | - } |
|
| 564 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 565 | - } |
|
| 566 | - |
|
| 567 | - |
|
| 568 | - /** |
|
| 569 | - * event_venues - adds venues BELOW content |
|
| 570 | - * |
|
| 571 | - * @access public |
|
| 572 | - * @param string $content |
|
| 573 | - * @return string |
|
| 574 | - */ |
|
| 575 | - public static function event_venue($content) |
|
| 576 | - { |
|
| 577 | - return EED_Events_Archive::event_venues($content); |
|
| 578 | - } |
|
| 579 | - |
|
| 580 | - |
|
| 581 | - /** |
|
| 582 | - * event_venues - adds venues BELOW content |
|
| 583 | - * |
|
| 584 | - * @access public |
|
| 585 | - * @param string $content |
|
| 586 | - * @return string |
|
| 587 | - */ |
|
| 588 | - public static function event_venues($content) |
|
| 589 | - { |
|
| 590 | - if (post_password_required()) { |
|
| 591 | - return $content; |
|
| 592 | - } |
|
| 593 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 594 | - } |
|
| 595 | - |
|
| 596 | - |
|
| 597 | - /** |
|
| 598 | - * _add_additional_content_filters |
|
| 599 | - * |
|
| 600 | - * @access private |
|
| 601 | - * @return void |
|
| 602 | - */ |
|
| 603 | - private static function _add_additional_excerpt_filters() |
|
| 604 | - { |
|
| 605 | - add_filter( |
|
| 606 | - 'the_excerpt', |
|
| 607 | - array('EED_Events_Archive', 'event_datetimes'), |
|
| 608 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 609 | - ); |
|
| 610 | - add_filter( |
|
| 611 | - 'the_excerpt', |
|
| 612 | - array('EED_Events_Archive', 'event_tickets'), |
|
| 613 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 614 | - ); |
|
| 615 | - add_filter( |
|
| 616 | - 'the_excerpt', |
|
| 617 | - array('EED_Events_Archive', 'event_venues'), |
|
| 618 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 619 | - ); |
|
| 620 | - } |
|
| 621 | - |
|
| 622 | - |
|
| 623 | - /** |
|
| 624 | - * _add_additional_content_filters |
|
| 625 | - * |
|
| 626 | - * @access private |
|
| 627 | - * @return void |
|
| 628 | - */ |
|
| 629 | - private static function _add_additional_content_filters() |
|
| 630 | - { |
|
| 631 | - add_filter( |
|
| 632 | - 'the_content', |
|
| 633 | - array('EED_Events_Archive', 'event_datetimes'), |
|
| 634 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 635 | - ); |
|
| 636 | - add_filter( |
|
| 637 | - 'the_content', |
|
| 638 | - array('EED_Events_Archive', 'event_tickets'), |
|
| 639 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 640 | - ); |
|
| 641 | - add_filter( |
|
| 642 | - 'the_content', |
|
| 643 | - array('EED_Events_Archive', 'event_venues'), |
|
| 644 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 645 | - ); |
|
| 646 | - } |
|
| 647 | - |
|
| 648 | - |
|
| 649 | - /** |
|
| 650 | - * _remove_additional_events_archive_filters |
|
| 651 | - * |
|
| 652 | - * @access private |
|
| 653 | - * @return void |
|
| 654 | - */ |
|
| 655 | - private static function _remove_additional_events_archive_filters() |
|
| 656 | - { |
|
| 657 | - remove_filter( |
|
| 658 | - 'the_excerpt', |
|
| 659 | - array('EED_Events_Archive', 'event_datetimes'), |
|
| 660 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 661 | - ); |
|
| 662 | - remove_filter( |
|
| 663 | - 'the_excerpt', |
|
| 664 | - array('EED_Events_Archive', 'event_tickets'), |
|
| 665 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 666 | - ); |
|
| 667 | - remove_filter( |
|
| 668 | - 'the_excerpt', |
|
| 669 | - array('EED_Events_Archive', 'event_venues'), |
|
| 670 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 671 | - ); |
|
| 672 | - remove_filter( |
|
| 673 | - 'the_content', |
|
| 674 | - array('EED_Events_Archive', 'event_datetimes'), |
|
| 675 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 676 | - ); |
|
| 677 | - remove_filter( |
|
| 678 | - 'the_content', |
|
| 679 | - array('EED_Events_Archive', 'event_tickets'), |
|
| 680 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 681 | - ); |
|
| 682 | - remove_filter( |
|
| 683 | - 'the_content', |
|
| 684 | - array('EED_Events_Archive', 'event_venues'), |
|
| 685 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 686 | - ); |
|
| 687 | - } |
|
| 688 | - |
|
| 689 | - |
|
| 690 | - /** |
|
| 691 | - * remove_all_events_archive_filters |
|
| 692 | - * |
|
| 693 | - * @access public |
|
| 694 | - * @return void |
|
| 695 | - */ |
|
| 696 | - public static function remove_all_events_archive_filters() |
|
| 697 | - { |
|
| 698 | - // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
| 699 | - remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
| 700 | - remove_filter( |
|
| 701 | - 'the_excerpt', |
|
| 702 | - array('EED_Events_Archive', 'event_details'), |
|
| 703 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 704 | - ); |
|
| 705 | - remove_filter( |
|
| 706 | - 'the_excerpt', |
|
| 707 | - array('EED_Events_Archive', 'event_datetimes'), |
|
| 708 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 709 | - ); |
|
| 710 | - remove_filter( |
|
| 711 | - 'the_excerpt', |
|
| 712 | - array('EED_Events_Archive', 'event_tickets'), |
|
| 713 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 714 | - ); |
|
| 715 | - remove_filter( |
|
| 716 | - 'the_excerpt', |
|
| 717 | - array('EED_Events_Archive', 'event_venues'), |
|
| 718 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 719 | - ); |
|
| 720 | - remove_filter( |
|
| 721 | - 'the_content', |
|
| 722 | - array('EED_Events_Archive', 'event_details'), |
|
| 723 | - EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 724 | - ); |
|
| 725 | - remove_filter( |
|
| 726 | - 'the_content', |
|
| 727 | - array('EED_Events_Archive', 'event_datetimes'), |
|
| 728 | - EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 729 | - ); |
|
| 730 | - remove_filter( |
|
| 731 | - 'the_content', |
|
| 732 | - array('EED_Events_Archive', 'event_tickets'), |
|
| 733 | - EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 734 | - ); |
|
| 735 | - remove_filter( |
|
| 736 | - 'the_content', |
|
| 737 | - array('EED_Events_Archive', 'event_venues'), |
|
| 738 | - EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 739 | - ); |
|
| 740 | - // don't display entry meta because the existing theme will take care of that |
|
| 741 | - remove_filter( |
|
| 742 | - 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
| 743 | - '__return_false' |
|
| 744 | - ); |
|
| 745 | - } |
|
| 746 | - |
|
| 747 | - |
|
| 748 | - /** |
|
| 749 | - * load_event_list_assets |
|
| 750 | - * |
|
| 751 | - * @access public |
|
| 752 | - * @return void |
|
| 753 | - */ |
|
| 754 | - public function load_event_list_assets() |
|
| 755 | - { |
|
| 756 | - do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
| 757 | - add_filter('FHEE_load_EE_Session', '__return_true'); |
|
| 758 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 759 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 760 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 761 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 762 | - } |
|
| 763 | - } |
|
| 764 | - |
|
| 765 | - |
|
| 766 | - /** |
|
| 767 | - * wp_enqueue_scripts |
|
| 768 | - * |
|
| 769 | - * @access public |
|
| 770 | - * @return void |
|
| 771 | - * @throws EE_Error |
|
| 772 | - */ |
|
| 773 | - public function wp_enqueue_scripts() |
|
| 774 | - { |
|
| 775 | - // get some style |
|
| 776 | - if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
| 777 | - // first check uploads folder |
|
| 778 | - if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
| 779 | - wp_register_style( |
|
| 780 | - $this->theme, |
|
| 781 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
| 782 | - array('dashicons', 'espresso_default') |
|
| 783 | - ); |
|
| 784 | - } else { |
|
| 785 | - } |
|
| 786 | - wp_enqueue_style($this->theme); |
|
| 787 | - } |
|
| 788 | - } |
|
| 789 | - |
|
| 790 | - |
|
| 791 | - /** |
|
| 792 | - * template_settings_form |
|
| 793 | - * |
|
| 794 | - * @access public |
|
| 795 | - * @static |
|
| 796 | - * @return string |
|
| 797 | - */ |
|
| 798 | - public static function template_settings_form() |
|
| 799 | - { |
|
| 800 | - $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
| 801 | - $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) |
|
| 802 | - ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
| 803 | - $template_settings->EED_Events_Archive = apply_filters( |
|
| 804 | - 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
| 805 | - $template_settings->EED_Events_Archive |
|
| 806 | - ); |
|
| 807 | - $events_archive_settings = array( |
|
| 808 | - 'display_status_banner' => 0, |
|
| 809 | - 'display_description' => 1, |
|
| 810 | - 'display_ticket_selector' => 0, |
|
| 811 | - 'display_datetimes' => 1, |
|
| 812 | - 'display_venue' => 0, |
|
| 813 | - 'display_expired_events' => 0, |
|
| 814 | - ); |
|
| 815 | - $events_archive_settings = array_merge( |
|
| 816 | - $events_archive_settings, |
|
| 817 | - (array) $template_settings->EED_Events_Archive |
|
| 818 | - ); |
|
| 819 | - EEH_Template::display_template( |
|
| 820 | - EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
| 821 | - $events_archive_settings |
|
| 822 | - ); |
|
| 823 | - } |
|
| 824 | - |
|
| 825 | - |
|
| 826 | - /** |
|
| 827 | - * update_template_settings |
|
| 828 | - * |
|
| 829 | - * @access public |
|
| 830 | - * @param EE_Template_Config $CFG |
|
| 831 | - * @param EE_Request_Handler $REQ |
|
| 832 | - * @return EE_Template_Config |
|
| 833 | - */ |
|
| 834 | - public static function update_template_settings($CFG, $REQ) |
|
| 835 | - { |
|
| 836 | - $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
| 837 | - // unless we are resetting the config... |
|
| 838 | - if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
| 839 | - || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
| 840 | - ) { |
|
| 841 | - $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
| 842 | - ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
| 843 | - $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
| 844 | - ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
| 845 | - $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
| 846 | - ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
| 847 | - $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint( |
|
| 848 | - $REQ['EED_Events_Archive_display_datetimes'] |
|
| 849 | - ) : 1; |
|
| 850 | - $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint( |
|
| 851 | - $REQ['EED_Events_Archive_display_venue'] |
|
| 852 | - ) : 0; |
|
| 853 | - $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
| 854 | - ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
| 855 | - } |
|
| 856 | - return $CFG; |
|
| 857 | - } |
|
| 858 | - |
|
| 859 | - |
|
| 860 | - /** |
|
| 861 | - * event_list_css |
|
| 862 | - * |
|
| 863 | - * @access public |
|
| 864 | - * @param string $extra_class |
|
| 865 | - * @return string |
|
| 866 | - */ |
|
| 867 | - public static function event_list_css($extra_class = '') |
|
| 868 | - { |
|
| 869 | - $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
| 870 | - $event_list_css[] = 'espresso-event-list-event'; |
|
| 871 | - return implode(' ', $event_list_css); |
|
| 872 | - } |
|
| 873 | - |
|
| 874 | - |
|
| 875 | - /** |
|
| 876 | - * event_categories |
|
| 877 | - * |
|
| 878 | - * @access public |
|
| 879 | - * @return array |
|
| 880 | - */ |
|
| 881 | - public static function event_categories() |
|
| 882 | - { |
|
| 883 | - return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
| 884 | - } |
|
| 885 | - |
|
| 886 | - |
|
| 887 | - /** |
|
| 888 | - * display_description |
|
| 889 | - * |
|
| 890 | - * @access public |
|
| 891 | - * @param $value |
|
| 892 | - * @return bool |
|
| 893 | - */ |
|
| 894 | - public static function display_description($value) |
|
| 895 | - { |
|
| 896 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 897 | - $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
| 898 | - return $display_description === $value ? true : false; |
|
| 899 | - } |
|
| 900 | - |
|
| 901 | - |
|
| 902 | - /** |
|
| 903 | - * display_ticket_selector |
|
| 904 | - * |
|
| 905 | - * @access public |
|
| 906 | - * @return bool |
|
| 907 | - */ |
|
| 908 | - public static function display_ticket_selector() |
|
| 909 | - { |
|
| 910 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 911 | - return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false; |
|
| 912 | - } |
|
| 913 | - |
|
| 914 | - |
|
| 915 | - /** |
|
| 916 | - * display_venue |
|
| 917 | - * |
|
| 918 | - * @access public |
|
| 919 | - * @return bool |
|
| 920 | - */ |
|
| 921 | - public static function display_venue() |
|
| 922 | - { |
|
| 923 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 924 | - return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false; |
|
| 925 | - } |
|
| 926 | - |
|
| 927 | - |
|
| 928 | - /** |
|
| 929 | - * display_datetimes |
|
| 930 | - * |
|
| 931 | - * @access public |
|
| 932 | - * @return bool |
|
| 933 | - */ |
|
| 934 | - public static function display_datetimes() |
|
| 935 | - { |
|
| 936 | - $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 937 | - return isset($config->display_datetimes) && $config->display_datetimes ? true : false; |
|
| 938 | - } |
|
| 939 | - |
|
| 940 | - |
|
| 941 | - /** |
|
| 942 | - * event_list_title |
|
| 943 | - * |
|
| 944 | - * @access public |
|
| 945 | - * @return string |
|
| 946 | - */ |
|
| 947 | - public static function event_list_title() |
|
| 948 | - { |
|
| 949 | - return apply_filters( |
|
| 950 | - 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
| 951 | - __('Upcoming Events', 'event_espresso') |
|
| 952 | - ); |
|
| 953 | - } |
|
| 954 | - |
|
| 955 | - |
|
| 956 | - // GRAVEYARD |
|
| 957 | - |
|
| 958 | - |
|
| 959 | - /** |
|
| 960 | - * @since 4.4.0 |
|
| 961 | - */ |
|
| 962 | - public static function _doing_it_wrong_notice($function = '') |
|
| 963 | - { |
|
| 964 | - EE_Error::doing_it_wrong( |
|
| 965 | - __FUNCTION__, |
|
| 966 | - sprintf( |
|
| 967 | - __( |
|
| 968 | - 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', |
|
| 969 | - 'event_espresso' |
|
| 970 | - ), |
|
| 971 | - $function, |
|
| 972 | - '<br />', |
|
| 973 | - '4.6.0' |
|
| 974 | - ), |
|
| 975 | - '4.4.0' |
|
| 976 | - ); |
|
| 977 | - } |
|
| 978 | - |
|
| 979 | - |
|
| 980 | - /** |
|
| 981 | - * @deprecated |
|
| 982 | - * @since 4.4.0 |
|
| 983 | - */ |
|
| 984 | - public function get_post_data() |
|
| 985 | - { |
|
| 986 | - EEH_Event_Query::set_query_params(); |
|
| 987 | - } |
|
| 988 | - |
|
| 989 | - |
|
| 990 | - /** |
|
| 991 | - * @throws EE_Error |
|
| 992 | - * @since 4.4.0 |
|
| 993 | - * @deprecated |
|
| 994 | - */ |
|
| 995 | - public function posts_fields($SQL, WP_Query $wp_query) |
|
| 996 | - { |
|
| 997 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 998 | - return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
| 999 | - } |
|
| 1000 | - |
|
| 1001 | - |
|
| 1002 | - /** |
|
| 1003 | - * @throws EE_Error |
|
| 1004 | - * @since 4.4.0 |
|
| 1005 | - * @deprecated |
|
| 1006 | - */ |
|
| 1007 | - public static function posts_fields_sql_for_orderby($orderby_params = array()) |
|
| 1008 | - { |
|
| 1009 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1010 | - return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
| 1011 | - } |
|
| 1012 | - |
|
| 1013 | - |
|
| 1014 | - /** |
|
| 1015 | - * @throws EE_Error |
|
| 1016 | - * @since 4.4.0 |
|
| 1017 | - * @deprecated |
|
| 1018 | - */ |
|
| 1019 | - public function posts_join($SQL, WP_Query $wp_query) |
|
| 1020 | - { |
|
| 1021 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1022 | - return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
| 1023 | - } |
|
| 1024 | - |
|
| 1025 | - |
|
| 1026 | - /** |
|
| 1027 | - * @deprecated |
|
| 1028 | - * @since 4.4.0 |
|
| 1029 | - */ |
|
| 1030 | - public static function posts_join_sql_for_terms($join_terms = null) |
|
| 1031 | - { |
|
| 1032 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1033 | - return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
| 1034 | - } |
|
| 1035 | - |
|
| 1036 | - |
|
| 1037 | - /** |
|
| 1038 | - * @throws EE_Error |
|
| 1039 | - * @since 4.4.0 |
|
| 1040 | - * @deprecated |
|
| 1041 | - */ |
|
| 1042 | - public static function posts_join_for_orderby($orderby_params = array()) |
|
| 1043 | - { |
|
| 1044 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1045 | - return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
| 1046 | - } |
|
| 1047 | - |
|
| 1048 | - |
|
| 1049 | - /** |
|
| 1050 | - * @throws EE_Error |
|
| 1051 | - * @since 4.4.0 |
|
| 1052 | - * @deprecated |
|
| 1053 | - */ |
|
| 1054 | - public function posts_where($SQL, WP_Query $wp_query) |
|
| 1055 | - { |
|
| 1056 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1057 | - return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
| 1058 | - } |
|
| 1059 | - |
|
| 1060 | - |
|
| 1061 | - /** |
|
| 1062 | - * @throws EE_Error |
|
| 1063 | - * @since 4.4.0 |
|
| 1064 | - * @deprecated |
|
| 1065 | - */ |
|
| 1066 | - public static function posts_where_sql_for_show_expired($show_expired = false) |
|
| 1067 | - { |
|
| 1068 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1069 | - return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
| 1070 | - } |
|
| 1071 | - |
|
| 1072 | - |
|
| 1073 | - /** |
|
| 1074 | - * @deprecated |
|
| 1075 | - * @since 4.4.0 |
|
| 1076 | - */ |
|
| 1077 | - public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
| 1078 | - { |
|
| 1079 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1080 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
| 1081 | - } |
|
| 1082 | - |
|
| 1083 | - |
|
| 1084 | - /** |
|
| 1085 | - * @throws EE_Error |
|
| 1086 | - * @since 4.4.0 |
|
| 1087 | - * @deprecated |
|
| 1088 | - */ |
|
| 1089 | - public static function posts_where_sql_for_event_list_month($month = null) |
|
| 1090 | - { |
|
| 1091 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1092 | - return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
| 1093 | - } |
|
| 1094 | - |
|
| 1095 | - |
|
| 1096 | - /** |
|
| 1097 | - * @throws EE_Error |
|
| 1098 | - * @since 4.4.0 |
|
| 1099 | - * @deprecated |
|
| 1100 | - */ |
|
| 1101 | - public function posts_orderby($SQL, WP_Query $wp_query) |
|
| 1102 | - { |
|
| 1103 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1104 | - return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
| 1105 | - } |
|
| 1106 | - |
|
| 1107 | - |
|
| 1108 | - /** |
|
| 1109 | - * @throws EE_Error |
|
| 1110 | - * @since 4.4.0 |
|
| 1111 | - * @deprecated |
|
| 1112 | - */ |
|
| 1113 | - public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
| 1114 | - { |
|
| 1115 | - EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1116 | - return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
| 1117 | - } |
|
| 19 | + const EVENT_DETAILS_PRIORITY = 100; |
|
| 20 | + |
|
| 21 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
| 22 | + |
|
| 23 | + const EVENT_TICKETS_PRIORITY = 120; |
|
| 24 | + |
|
| 25 | + const EVENT_VENUES_PRIORITY = 130; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + public static $espresso_event_list_ID = 0; |
|
| 29 | + |
|
| 30 | + public static $espresso_grid_event_lists = array(); |
|
| 31 | + |
|
| 32 | + /** |
|
| 33 | + * @type bool $using_get_the_excerpt |
|
| 34 | + */ |
|
| 35 | + protected static $using_get_the_excerpt = false; |
|
| 36 | + |
|
| 37 | + /** |
|
| 38 | + * Used to flag when the event list is being called from an external iframe. |
|
| 39 | + * |
|
| 40 | + * @var bool $iframe |
|
| 41 | + */ |
|
| 42 | + protected static $iframe = false; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * @var EventListIframeEmbedButton $_iframe_embed_button |
|
| 46 | + */ |
|
| 47 | + private static $_iframe_embed_button; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * @type EE_Template_Part_Manager $template_parts |
|
| 51 | + */ |
|
| 52 | + protected $template_parts; |
|
| 53 | + |
|
| 54 | + |
|
| 55 | + /** |
|
| 56 | + * @return EED_Events_Archive |
|
| 57 | + */ |
|
| 58 | + public static function instance() |
|
| 59 | + { |
|
| 60 | + return parent::get_instance(__CLASS__); |
|
| 61 | + } |
|
| 62 | + |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 66 | + * |
|
| 67 | + * @return void |
|
| 68 | + * @throws InvalidArgumentException |
|
| 69 | + * @throws InvalidDataTypeException |
|
| 70 | + * @throws InvalidInterfaceException |
|
| 71 | + */ |
|
| 72 | + public static function set_hooks() |
|
| 73 | + { |
|
| 74 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
| 75 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
| 76 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
| 77 | + ); |
|
| 78 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
| 79 | + EE_Config::register_route( |
|
| 80 | + $custom_post_types['espresso_events']['plural_slug'], |
|
| 81 | + 'Events_Archive', |
|
| 82 | + 'run' |
|
| 83 | + ); |
|
| 84 | + EE_Config::register_route( |
|
| 85 | + 'event_list', |
|
| 86 | + 'Events_Archive', |
|
| 87 | + 'event_list' |
|
| 88 | + ); |
|
| 89 | + EE_Config::register_route( |
|
| 90 | + 'iframe', |
|
| 91 | + 'Events_Archive', |
|
| 92 | + 'event_list_iframe', |
|
| 93 | + 'event_list' |
|
| 94 | + ); |
|
| 95 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 96 | + } |
|
| 97 | + |
|
| 98 | + |
|
| 99 | + /** |
|
| 100 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 101 | + * |
|
| 102 | + * @access public |
|
| 103 | + * @return void |
|
| 104 | + */ |
|
| 105 | + public static function set_hooks_admin() |
|
| 106 | + { |
|
| 107 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
| 108 | + // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
|
| 109 | + // to load assets for "espresso_events" page on the "default" route (action) |
|
| 110 | + add_action( |
|
| 111 | + 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
|
| 112 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
| 113 | + 10 |
|
| 114 | + ); |
|
| 115 | + } |
|
| 116 | + |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * set_definitions |
|
| 120 | + * |
|
| 121 | + * @access public |
|
| 122 | + * @return void |
|
| 123 | + */ |
|
| 124 | + public static function set_definitions() |
|
| 125 | + { |
|
| 126 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 127 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', '/', plugin_dir_path(__FILE__)) . 'templates/'); |
|
| 128 | + } |
|
| 129 | + |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * set up EE_Events_Archive_Config |
|
| 133 | + */ |
|
| 134 | + protected function set_config() |
|
| 135 | + { |
|
| 136 | + $this->set_config_section('template_settings'); |
|
| 137 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
| 138 | + $this->set_config_name('EED_Events_Archive'); |
|
| 139 | + } |
|
| 140 | + |
|
| 141 | + |
|
| 142 | + /** |
|
| 143 | + * @return EventListIframeEmbedButton |
|
| 144 | + */ |
|
| 145 | + public static function get_iframe_embed_button() |
|
| 146 | + { |
|
| 147 | + if (! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
| 148 | + self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
|
| 149 | + } |
|
| 150 | + return self::$_iframe_embed_button; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + |
|
| 154 | + /** |
|
| 155 | + * event_list_iframe_embed_button |
|
| 156 | + * |
|
| 157 | + * @return void |
|
| 158 | + * @throws EE_Error |
|
| 159 | + */ |
|
| 160 | + public static function event_list_iframe_embed_button() |
|
| 161 | + { |
|
| 162 | + $iframe_embed_button = EED_Events_Archive::get_iframe_embed_button(); |
|
| 163 | + $iframe_embed_button->addEmbedButton(); |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + |
|
| 167 | + /** |
|
| 168 | + * initialize_template_parts |
|
| 169 | + * |
|
| 170 | + * @access public |
|
| 171 | + * @param EE_Events_Archive_Config $config |
|
| 172 | + * @return EE_Template_Part_Manager |
|
| 173 | + * @throws EE_Error |
|
| 174 | + */ |
|
| 175 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) |
|
| 176 | + { |
|
| 177 | + $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
|
| 178 | + EEH_Autoloader::register_template_part_autoloaders(); |
|
| 179 | + $template_parts = new EE_Template_Part_Manager(); |
|
| 180 | + $template_parts->add_template_part( |
|
| 181 | + 'tickets', |
|
| 182 | + __('Ticket Selector', 'event_espresso'), |
|
| 183 | + 'content-espresso_events-tickets.php', |
|
| 184 | + $config->display_order_tickets |
|
| 185 | + ); |
|
| 186 | + $template_parts->add_template_part( |
|
| 187 | + 'datetimes', |
|
| 188 | + __('Dates and Times', 'event_espresso'), |
|
| 189 | + 'content-espresso_events-datetimes.php', |
|
| 190 | + $config->display_order_datetimes |
|
| 191 | + ); |
|
| 192 | + $template_parts->add_template_part( |
|
| 193 | + 'event', |
|
| 194 | + __('Event Description', 'event_espresso'), |
|
| 195 | + 'content-espresso_events-details.php', |
|
| 196 | + $config->display_order_event |
|
| 197 | + ); |
|
| 198 | + $template_parts->add_template_part( |
|
| 199 | + 'venue', |
|
| 200 | + __('Venue Information', 'event_espresso'), |
|
| 201 | + 'content-espresso_events-venues.php', |
|
| 202 | + $config->display_order_venue |
|
| 203 | + ); |
|
| 204 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
| 205 | + return $template_parts; |
|
| 206 | + } |
|
| 207 | + |
|
| 208 | + |
|
| 209 | + /** |
|
| 210 | + * run - initial module setup - this gets called by the EE_Front_Controller if the module route is found in the |
|
| 211 | + * incoming request |
|
| 212 | + * |
|
| 213 | + * @access public |
|
| 214 | + * @param WP $WP |
|
| 215 | + * @return void |
|
| 216 | + */ |
|
| 217 | + public function run($WP) |
|
| 218 | + { |
|
| 219 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
| 220 | + // ensure valid EE_Events_Archive_Config() object exists |
|
| 221 | + $this->set_config(); |
|
| 222 | + /** @type EE_Events_Archive_Config $config */ |
|
| 223 | + $config = $this->config(); |
|
| 224 | + // load other required components |
|
| 225 | + $this->load_event_list_assets(); |
|
| 226 | + // filter the WP posts_join, posts_where, and posts_orderby SQL clauses |
|
| 227 | + // add query filters |
|
| 228 | + EEH_Event_Query::add_query_filters(); |
|
| 229 | + // set params that will get used by the filters |
|
| 230 | + EEH_Event_Query::set_query_params( |
|
| 231 | + '', // month |
|
| 232 | + '', // category |
|
| 233 | + $config->display_expired_events, // show_expired |
|
| 234 | + 'start_date', // orderby |
|
| 235 | + 'ASC' // sort |
|
| 236 | + ); |
|
| 237 | + // check what template is loaded |
|
| 238 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 239 | + } |
|
| 240 | + |
|
| 241 | + |
|
| 242 | + /** |
|
| 243 | + * most likely called by the ESPRESSO_EVENTS shortcode which uses this module to do some of it's lifting |
|
| 244 | + * |
|
| 245 | + * @return void |
|
| 246 | + */ |
|
| 247 | + public function event_list() |
|
| 248 | + { |
|
| 249 | + // ensure valid EE_Events_Archive_Config() object exists |
|
| 250 | + $this->set_config(); |
|
| 251 | + // load other required components |
|
| 252 | + $this->load_event_list_assets(); |
|
| 253 | + } |
|
| 254 | + |
|
| 255 | + |
|
| 256 | + /** |
|
| 257 | + * @access public |
|
| 258 | + * @return void |
|
| 259 | + * @throws EE_Error |
|
| 260 | + * @throws DomainException |
|
| 261 | + */ |
|
| 262 | + public function event_list_iframe() |
|
| 263 | + { |
|
| 264 | + EED_Events_Archive::$iframe = true; |
|
| 265 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
| 266 | + $event_list_iframe->display(); |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * @access public |
|
| 272 | + * @return string |
|
| 273 | + */ |
|
| 274 | + public static function is_iframe() |
|
| 275 | + { |
|
| 276 | + return EED_Events_Archive::$iframe; |
|
| 277 | + } |
|
| 278 | + |
|
| 279 | + |
|
| 280 | + /** |
|
| 281 | + * @access public |
|
| 282 | + * @return string |
|
| 283 | + */ |
|
| 284 | + public static function link_target() |
|
| 285 | + { |
|
| 286 | + return EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
| 287 | + } |
|
| 288 | + |
|
| 289 | + |
|
| 290 | + /** |
|
| 291 | + * template_include |
|
| 292 | + * |
|
| 293 | + * @access public |
|
| 294 | + * @param string $template |
|
| 295 | + * @return string |
|
| 296 | + */ |
|
| 297 | + public function template_include($template = '') |
|
| 298 | + { |
|
| 299 | + // don't add content filter for dedicated EE child themes or private posts |
|
| 300 | + if (! EEH_Template::is_espresso_theme()) { |
|
| 301 | + /** @type EE_Events_Archive_Config $config */ |
|
| 302 | + $config = $this->config(); |
|
| 303 | + // add status banner ? |
|
| 304 | + if ($config->display_status_banner) { |
|
| 305 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
| 306 | + } |
|
| 307 | + // if NOT a custom template |
|
| 308 | + if (apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', false) |
|
| 309 | + || EE_Registry::instance() |
|
| 310 | + ->load_core('Front_Controller') |
|
| 311 | + ->get_selected_template() !== 'archive-espresso_events.php' |
|
| 312 | + ) { |
|
| 313 | + // don't display entry meta because the existing theme will take care of that |
|
| 314 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
| 315 | + // load functions.php file for the theme (loaded by WP if using child theme) |
|
| 316 | + EEH_Template::load_espresso_theme_functions(); |
|
| 317 | + // because we don't know if the theme is using the_excerpt() |
|
| 318 | + add_filter( |
|
| 319 | + 'the_excerpt', |
|
| 320 | + array('EED_Events_Archive', 'event_details'), |
|
| 321 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 322 | + ); |
|
| 323 | + // or the_content |
|
| 324 | + add_filter( |
|
| 325 | + 'the_content', |
|
| 326 | + array('EED_Events_Archive', 'event_details'), |
|
| 327 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 328 | + ); |
|
| 329 | + // and just in case they are running get_the_excerpt() which DESTROYS things |
|
| 330 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 331 | + // don't display entry meta because the existing theme will take care of that |
|
| 332 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 333 | + } |
|
| 334 | + } |
|
| 335 | + return $template; |
|
| 336 | + } |
|
| 337 | + |
|
| 338 | + |
|
| 339 | + /** |
|
| 340 | + * get_the_excerpt - kinda hacky, but if a theme is using get_the_excerpt(), then we need to remove our filters |
|
| 341 | + * on the_content() |
|
| 342 | + * |
|
| 343 | + * @access public |
|
| 344 | + * @param string $excerpt |
|
| 345 | + * @return string |
|
| 346 | + */ |
|
| 347 | + public static function get_the_excerpt($excerpt = '') |
|
| 348 | + { |
|
| 349 | + if (post_password_required()) { |
|
| 350 | + return $excerpt; |
|
| 351 | + } |
|
| 352 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
| 353 | + remove_filter( |
|
| 354 | + 'the_excerpt', |
|
| 355 | + array('EED_Events_Archive', 'event_details'), |
|
| 356 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 357 | + ); |
|
| 358 | + remove_filter( |
|
| 359 | + 'the_content', |
|
| 360 | + array('EED_Events_Archive', 'event_details'), |
|
| 361 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 362 | + ); |
|
| 363 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
| 364 | + } else { |
|
| 365 | + EED_Events_Archive::$using_get_the_excerpt = true; |
|
| 366 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
| 367 | + } |
|
| 368 | + return $excerpt; |
|
| 369 | + } |
|
| 370 | + |
|
| 371 | + |
|
| 372 | + /** |
|
| 373 | + * end_get_the_excerpt |
|
| 374 | + * |
|
| 375 | + * @access public |
|
| 376 | + * @param string $text |
|
| 377 | + * @return string |
|
| 378 | + */ |
|
| 379 | + public static function end_get_the_excerpt($text = '') |
|
| 380 | + { |
|
| 381 | + EED_Events_Archive::$using_get_the_excerpt = false; |
|
| 382 | + return $text; |
|
| 383 | + } |
|
| 384 | + |
|
| 385 | + |
|
| 386 | + /** |
|
| 387 | + * the_title |
|
| 388 | + * |
|
| 389 | + * @access public |
|
| 390 | + * @param string $title |
|
| 391 | + * @param string $id |
|
| 392 | + * @return string |
|
| 393 | + */ |
|
| 394 | + public static function the_title($title = '', $id = '') |
|
| 395 | + { |
|
| 396 | + global $post; |
|
| 397 | + if ($post instanceof WP_Post) { |
|
| 398 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID) . $title : $title; |
|
| 399 | + } |
|
| 400 | + return $title; |
|
| 401 | + } |
|
| 402 | + |
|
| 403 | + |
|
| 404 | + /** |
|
| 405 | + * event_details |
|
| 406 | + * |
|
| 407 | + * @access public |
|
| 408 | + * @param string $content |
|
| 409 | + * @return string |
|
| 410 | + */ |
|
| 411 | + public static function event_details($content) |
|
| 412 | + { |
|
| 413 | + global $post; |
|
| 414 | + static $current_post_ID = 0; |
|
| 415 | + if ($current_post_ID !== $post->ID |
|
| 416 | + && $post->post_type === 'espresso_events' |
|
| 417 | + && ! EED_Events_Archive::$using_get_the_excerpt |
|
| 418 | + && ! post_password_required() |
|
| 419 | + && ( |
|
| 420 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
| 421 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
| 422 | + ) |
|
| 423 | + ) { |
|
| 424 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 425 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 426 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 427 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 428 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 429 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
| 430 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 431 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
| 432 | + $content = EED_Events_Archive::use_sortable_display_order(); |
|
| 433 | + } else { |
|
| 434 | + $content = EED_Events_Archive::use_filterable_display_order(); |
|
| 435 | + } |
|
| 436 | + } |
|
| 437 | + return $content; |
|
| 438 | + } |
|
| 439 | + |
|
| 440 | + |
|
| 441 | + /** |
|
| 442 | + * use_sortable_display_order |
|
| 443 | + * |
|
| 444 | + * @access protected |
|
| 445 | + * @return string |
|
| 446 | + */ |
|
| 447 | + protected static function use_sortable_display_order() |
|
| 448 | + { |
|
| 449 | + // no further password checks required atm |
|
| 450 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
| 451 | + // we need to first remove this callback from being applied to the_content() or the_excerpt() |
|
| 452 | + // (otherwise it will recurse and blow up the interweb) |
|
| 453 | + remove_filter( |
|
| 454 | + 'the_excerpt', |
|
| 455 | + array('EED_Events_Archive', 'event_details'), |
|
| 456 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 457 | + ); |
|
| 458 | + remove_filter( |
|
| 459 | + 'the_content', |
|
| 460 | + array('EED_Events_Archive', 'event_details'), |
|
| 461 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 462 | + ); |
|
| 463 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 464 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
| 465 | + EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
|
| 466 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 467 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
| 468 | + // re-add our main filters (or else the next event won't have them) |
|
| 469 | + add_filter( |
|
| 470 | + 'the_excerpt', |
|
| 471 | + array('EED_Events_Archive', 'event_details'), |
|
| 472 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 473 | + ); |
|
| 474 | + add_filter( |
|
| 475 | + 'the_content', |
|
| 476 | + array('EED_Events_Archive', 'event_details'), |
|
| 477 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 478 | + ); |
|
| 479 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 480 | + remove_filter( |
|
| 481 | + 'FHEE__EED_Events_Archive__event_details__no_post_password_required', |
|
| 482 | + '__return_true' |
|
| 483 | + ); |
|
| 484 | + return $content; |
|
| 485 | + } |
|
| 486 | + |
|
| 487 | + |
|
| 488 | + /** |
|
| 489 | + * use_filterable_display_order |
|
| 490 | + * |
|
| 491 | + * @access protected |
|
| 492 | + * @return string |
|
| 493 | + */ |
|
| 494 | + protected static function use_filterable_display_order() |
|
| 495 | + { |
|
| 496 | + // we need to first remove this callback from being applied to the_content() |
|
| 497 | + // (otherwise it will recurse and blow up the interweb) |
|
| 498 | + remove_filter( |
|
| 499 | + 'the_excerpt', |
|
| 500 | + array('EED_Events_Archive', 'event_details'), |
|
| 501 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 502 | + ); |
|
| 503 | + remove_filter( |
|
| 504 | + 'the_content', |
|
| 505 | + array('EED_Events_Archive', 'event_details'), |
|
| 506 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 507 | + ); |
|
| 508 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
| 509 | + // now add additional content depending on whether event is using the_excerpt() or the_content() |
|
| 510 | + EED_Events_Archive::_add_additional_excerpt_filters(); |
|
| 511 | + EED_Events_Archive::_add_additional_content_filters(); |
|
| 512 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
| 513 | + // now load our template |
|
| 514 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 515 | + // re-add our main filters (or else the next event won't have them) |
|
| 516 | + add_filter( |
|
| 517 | + 'the_excerpt', |
|
| 518 | + array('EED_Events_Archive', 'event_details'), |
|
| 519 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 520 | + ); |
|
| 521 | + add_filter( |
|
| 522 | + 'the_content', |
|
| 523 | + array('EED_Events_Archive', 'event_details'), |
|
| 524 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 525 | + ); |
|
| 526 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
| 527 | + // but remove the other filters so that they don't get applied to the next post |
|
| 528 | + EED_Events_Archive::_remove_additional_events_archive_filters(); |
|
| 529 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
| 530 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 531 | + // return ! empty( $template ) ? $template : $content; |
|
| 532 | + return $content; |
|
| 533 | + } |
|
| 534 | + |
|
| 535 | + |
|
| 536 | + /** |
|
| 537 | + * event_datetimes - adds datetimes ABOVE content |
|
| 538 | + * |
|
| 539 | + * @access public |
|
| 540 | + * @param string $content |
|
| 541 | + * @return string |
|
| 542 | + */ |
|
| 543 | + public static function event_datetimes($content) |
|
| 544 | + { |
|
| 545 | + if (post_password_required()) { |
|
| 546 | + return $content; |
|
| 547 | + } |
|
| 548 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 549 | + } |
|
| 550 | + |
|
| 551 | + |
|
| 552 | + /** |
|
| 553 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 554 | + * |
|
| 555 | + * @access public |
|
| 556 | + * @param string $content |
|
| 557 | + * @return string |
|
| 558 | + */ |
|
| 559 | + public static function event_tickets($content) |
|
| 560 | + { |
|
| 561 | + if (post_password_required()) { |
|
| 562 | + return $content; |
|
| 563 | + } |
|
| 564 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 565 | + } |
|
| 566 | + |
|
| 567 | + |
|
| 568 | + /** |
|
| 569 | + * event_venues - adds venues BELOW content |
|
| 570 | + * |
|
| 571 | + * @access public |
|
| 572 | + * @param string $content |
|
| 573 | + * @return string |
|
| 574 | + */ |
|
| 575 | + public static function event_venue($content) |
|
| 576 | + { |
|
| 577 | + return EED_Events_Archive::event_venues($content); |
|
| 578 | + } |
|
| 579 | + |
|
| 580 | + |
|
| 581 | + /** |
|
| 582 | + * event_venues - adds venues BELOW content |
|
| 583 | + * |
|
| 584 | + * @access public |
|
| 585 | + * @param string $content |
|
| 586 | + * @return string |
|
| 587 | + */ |
|
| 588 | + public static function event_venues($content) |
|
| 589 | + { |
|
| 590 | + if (post_password_required()) { |
|
| 591 | + return $content; |
|
| 592 | + } |
|
| 593 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 594 | + } |
|
| 595 | + |
|
| 596 | + |
|
| 597 | + /** |
|
| 598 | + * _add_additional_content_filters |
|
| 599 | + * |
|
| 600 | + * @access private |
|
| 601 | + * @return void |
|
| 602 | + */ |
|
| 603 | + private static function _add_additional_excerpt_filters() |
|
| 604 | + { |
|
| 605 | + add_filter( |
|
| 606 | + 'the_excerpt', |
|
| 607 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 608 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 609 | + ); |
|
| 610 | + add_filter( |
|
| 611 | + 'the_excerpt', |
|
| 612 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 613 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 614 | + ); |
|
| 615 | + add_filter( |
|
| 616 | + 'the_excerpt', |
|
| 617 | + array('EED_Events_Archive', 'event_venues'), |
|
| 618 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 619 | + ); |
|
| 620 | + } |
|
| 621 | + |
|
| 622 | + |
|
| 623 | + /** |
|
| 624 | + * _add_additional_content_filters |
|
| 625 | + * |
|
| 626 | + * @access private |
|
| 627 | + * @return void |
|
| 628 | + */ |
|
| 629 | + private static function _add_additional_content_filters() |
|
| 630 | + { |
|
| 631 | + add_filter( |
|
| 632 | + 'the_content', |
|
| 633 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 634 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 635 | + ); |
|
| 636 | + add_filter( |
|
| 637 | + 'the_content', |
|
| 638 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 639 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 640 | + ); |
|
| 641 | + add_filter( |
|
| 642 | + 'the_content', |
|
| 643 | + array('EED_Events_Archive', 'event_venues'), |
|
| 644 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 645 | + ); |
|
| 646 | + } |
|
| 647 | + |
|
| 648 | + |
|
| 649 | + /** |
|
| 650 | + * _remove_additional_events_archive_filters |
|
| 651 | + * |
|
| 652 | + * @access private |
|
| 653 | + * @return void |
|
| 654 | + */ |
|
| 655 | + private static function _remove_additional_events_archive_filters() |
|
| 656 | + { |
|
| 657 | + remove_filter( |
|
| 658 | + 'the_excerpt', |
|
| 659 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 660 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 661 | + ); |
|
| 662 | + remove_filter( |
|
| 663 | + 'the_excerpt', |
|
| 664 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 665 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 666 | + ); |
|
| 667 | + remove_filter( |
|
| 668 | + 'the_excerpt', |
|
| 669 | + array('EED_Events_Archive', 'event_venues'), |
|
| 670 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 671 | + ); |
|
| 672 | + remove_filter( |
|
| 673 | + 'the_content', |
|
| 674 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 675 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 676 | + ); |
|
| 677 | + remove_filter( |
|
| 678 | + 'the_content', |
|
| 679 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 680 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 681 | + ); |
|
| 682 | + remove_filter( |
|
| 683 | + 'the_content', |
|
| 684 | + array('EED_Events_Archive', 'event_venues'), |
|
| 685 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 686 | + ); |
|
| 687 | + } |
|
| 688 | + |
|
| 689 | + |
|
| 690 | + /** |
|
| 691 | + * remove_all_events_archive_filters |
|
| 692 | + * |
|
| 693 | + * @access public |
|
| 694 | + * @return void |
|
| 695 | + */ |
|
| 696 | + public static function remove_all_events_archive_filters() |
|
| 697 | + { |
|
| 698 | + // remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
| 699 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 1); |
|
| 700 | + remove_filter( |
|
| 701 | + 'the_excerpt', |
|
| 702 | + array('EED_Events_Archive', 'event_details'), |
|
| 703 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 704 | + ); |
|
| 705 | + remove_filter( |
|
| 706 | + 'the_excerpt', |
|
| 707 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 708 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 709 | + ); |
|
| 710 | + remove_filter( |
|
| 711 | + 'the_excerpt', |
|
| 712 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 713 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 714 | + ); |
|
| 715 | + remove_filter( |
|
| 716 | + 'the_excerpt', |
|
| 717 | + array('EED_Events_Archive', 'event_venues'), |
|
| 718 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 719 | + ); |
|
| 720 | + remove_filter( |
|
| 721 | + 'the_content', |
|
| 722 | + array('EED_Events_Archive', 'event_details'), |
|
| 723 | + EED_Events_Archive::EVENT_DETAILS_PRIORITY |
|
| 724 | + ); |
|
| 725 | + remove_filter( |
|
| 726 | + 'the_content', |
|
| 727 | + array('EED_Events_Archive', 'event_datetimes'), |
|
| 728 | + EED_Events_Archive::EVENT_DATETIMES_PRIORITY |
|
| 729 | + ); |
|
| 730 | + remove_filter( |
|
| 731 | + 'the_content', |
|
| 732 | + array('EED_Events_Archive', 'event_tickets'), |
|
| 733 | + EED_Events_Archive::EVENT_TICKETS_PRIORITY |
|
| 734 | + ); |
|
| 735 | + remove_filter( |
|
| 736 | + 'the_content', |
|
| 737 | + array('EED_Events_Archive', 'event_venues'), |
|
| 738 | + EED_Events_Archive::EVENT_VENUES_PRIORITY |
|
| 739 | + ); |
|
| 740 | + // don't display entry meta because the existing theme will take care of that |
|
| 741 | + remove_filter( |
|
| 742 | + 'FHEE__content_espresso_events_details_template__display_entry_meta', |
|
| 743 | + '__return_false' |
|
| 744 | + ); |
|
| 745 | + } |
|
| 746 | + |
|
| 747 | + |
|
| 748 | + /** |
|
| 749 | + * load_event_list_assets |
|
| 750 | + * |
|
| 751 | + * @access public |
|
| 752 | + * @return void |
|
| 753 | + */ |
|
| 754 | + public function load_event_list_assets() |
|
| 755 | + { |
|
| 756 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
| 757 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
| 758 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 759 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 760 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 761 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 762 | + } |
|
| 763 | + } |
|
| 764 | + |
|
| 765 | + |
|
| 766 | + /** |
|
| 767 | + * wp_enqueue_scripts |
|
| 768 | + * |
|
| 769 | + * @access public |
|
| 770 | + * @return void |
|
| 771 | + * @throws EE_Error |
|
| 772 | + */ |
|
| 773 | + public function wp_enqueue_scripts() |
|
| 774 | + { |
|
| 775 | + // get some style |
|
| 776 | + if (apply_filters('FHEE_enable_default_espresso_css', false)) { |
|
| 777 | + // first check uploads folder |
|
| 778 | + if (EEH_File::is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
| 779 | + wp_register_style( |
|
| 780 | + $this->theme, |
|
| 781 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
| 782 | + array('dashicons', 'espresso_default') |
|
| 783 | + ); |
|
| 784 | + } else { |
|
| 785 | + } |
|
| 786 | + wp_enqueue_style($this->theme); |
|
| 787 | + } |
|
| 788 | + } |
|
| 789 | + |
|
| 790 | + |
|
| 791 | + /** |
|
| 792 | + * template_settings_form |
|
| 793 | + * |
|
| 794 | + * @access public |
|
| 795 | + * @static |
|
| 796 | + * @return string |
|
| 797 | + */ |
|
| 798 | + public static function template_settings_form() |
|
| 799 | + { |
|
| 800 | + $template_settings = EE_Registry::instance()->CFG->template_settings; |
|
| 801 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) |
|
| 802 | + ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
| 803 | + $template_settings->EED_Events_Archive = apply_filters( |
|
| 804 | + 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', |
|
| 805 | + $template_settings->EED_Events_Archive |
|
| 806 | + ); |
|
| 807 | + $events_archive_settings = array( |
|
| 808 | + 'display_status_banner' => 0, |
|
| 809 | + 'display_description' => 1, |
|
| 810 | + 'display_ticket_selector' => 0, |
|
| 811 | + 'display_datetimes' => 1, |
|
| 812 | + 'display_venue' => 0, |
|
| 813 | + 'display_expired_events' => 0, |
|
| 814 | + ); |
|
| 815 | + $events_archive_settings = array_merge( |
|
| 816 | + $events_archive_settings, |
|
| 817 | + (array) $template_settings->EED_Events_Archive |
|
| 818 | + ); |
|
| 819 | + EEH_Template::display_template( |
|
| 820 | + EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', |
|
| 821 | + $events_archive_settings |
|
| 822 | + ); |
|
| 823 | + } |
|
| 824 | + |
|
| 825 | + |
|
| 826 | + /** |
|
| 827 | + * update_template_settings |
|
| 828 | + * |
|
| 829 | + * @access public |
|
| 830 | + * @param EE_Template_Config $CFG |
|
| 831 | + * @param EE_Request_Handler $REQ |
|
| 832 | + * @return EE_Template_Config |
|
| 833 | + */ |
|
| 834 | + public static function update_template_settings($CFG, $REQ) |
|
| 835 | + { |
|
| 836 | + $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
|
| 837 | + // unless we are resetting the config... |
|
| 838 | + if (! isset($REQ['EED_Events_Archive_reset_event_list_settings']) |
|
| 839 | + || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1 |
|
| 840 | + ) { |
|
| 841 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) |
|
| 842 | + ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
| 843 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) |
|
| 844 | + ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
| 845 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) |
|
| 846 | + ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
| 847 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint( |
|
| 848 | + $REQ['EED_Events_Archive_display_datetimes'] |
|
| 849 | + ) : 1; |
|
| 850 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint( |
|
| 851 | + $REQ['EED_Events_Archive_display_venue'] |
|
| 852 | + ) : 0; |
|
| 853 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) |
|
| 854 | + ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; |
|
| 855 | + } |
|
| 856 | + return $CFG; |
|
| 857 | + } |
|
| 858 | + |
|
| 859 | + |
|
| 860 | + /** |
|
| 861 | + * event_list_css |
|
| 862 | + * |
|
| 863 | + * @access public |
|
| 864 | + * @param string $extra_class |
|
| 865 | + * @return string |
|
| 866 | + */ |
|
| 867 | + public static function event_list_css($extra_class = '') |
|
| 868 | + { |
|
| 869 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
| 870 | + $event_list_css[] = 'espresso-event-list-event'; |
|
| 871 | + return implode(' ', $event_list_css); |
|
| 872 | + } |
|
| 873 | + |
|
| 874 | + |
|
| 875 | + /** |
|
| 876 | + * event_categories |
|
| 877 | + * |
|
| 878 | + * @access public |
|
| 879 | + * @return array |
|
| 880 | + */ |
|
| 881 | + public static function event_categories() |
|
| 882 | + { |
|
| 883 | + return EE_Registry::instance()->load_model('Term')->get_all_ee_categories(); |
|
| 884 | + } |
|
| 885 | + |
|
| 886 | + |
|
| 887 | + /** |
|
| 888 | + * display_description |
|
| 889 | + * |
|
| 890 | + * @access public |
|
| 891 | + * @param $value |
|
| 892 | + * @return bool |
|
| 893 | + */ |
|
| 894 | + public static function display_description($value) |
|
| 895 | + { |
|
| 896 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 897 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
| 898 | + return $display_description === $value ? true : false; |
|
| 899 | + } |
|
| 900 | + |
|
| 901 | + |
|
| 902 | + /** |
|
| 903 | + * display_ticket_selector |
|
| 904 | + * |
|
| 905 | + * @access public |
|
| 906 | + * @return bool |
|
| 907 | + */ |
|
| 908 | + public static function display_ticket_selector() |
|
| 909 | + { |
|
| 910 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 911 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? true : false; |
|
| 912 | + } |
|
| 913 | + |
|
| 914 | + |
|
| 915 | + /** |
|
| 916 | + * display_venue |
|
| 917 | + * |
|
| 918 | + * @access public |
|
| 919 | + * @return bool |
|
| 920 | + */ |
|
| 921 | + public static function display_venue() |
|
| 922 | + { |
|
| 923 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 924 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? true : false; |
|
| 925 | + } |
|
| 926 | + |
|
| 927 | + |
|
| 928 | + /** |
|
| 929 | + * display_datetimes |
|
| 930 | + * |
|
| 931 | + * @access public |
|
| 932 | + * @return bool |
|
| 933 | + */ |
|
| 934 | + public static function display_datetimes() |
|
| 935 | + { |
|
| 936 | + $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
|
| 937 | + return isset($config->display_datetimes) && $config->display_datetimes ? true : false; |
|
| 938 | + } |
|
| 939 | + |
|
| 940 | + |
|
| 941 | + /** |
|
| 942 | + * event_list_title |
|
| 943 | + * |
|
| 944 | + * @access public |
|
| 945 | + * @return string |
|
| 946 | + */ |
|
| 947 | + public static function event_list_title() |
|
| 948 | + { |
|
| 949 | + return apply_filters( |
|
| 950 | + 'FHEE__archive_espresso_events_template__upcoming_events_h1', |
|
| 951 | + __('Upcoming Events', 'event_espresso') |
|
| 952 | + ); |
|
| 953 | + } |
|
| 954 | + |
|
| 955 | + |
|
| 956 | + // GRAVEYARD |
|
| 957 | + |
|
| 958 | + |
|
| 959 | + /** |
|
| 960 | + * @since 4.4.0 |
|
| 961 | + */ |
|
| 962 | + public static function _doing_it_wrong_notice($function = '') |
|
| 963 | + { |
|
| 964 | + EE_Error::doing_it_wrong( |
|
| 965 | + __FUNCTION__, |
|
| 966 | + sprintf( |
|
| 967 | + __( |
|
| 968 | + 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', |
|
| 969 | + 'event_espresso' |
|
| 970 | + ), |
|
| 971 | + $function, |
|
| 972 | + '<br />', |
|
| 973 | + '4.6.0' |
|
| 974 | + ), |
|
| 975 | + '4.4.0' |
|
| 976 | + ); |
|
| 977 | + } |
|
| 978 | + |
|
| 979 | + |
|
| 980 | + /** |
|
| 981 | + * @deprecated |
|
| 982 | + * @since 4.4.0 |
|
| 983 | + */ |
|
| 984 | + public function get_post_data() |
|
| 985 | + { |
|
| 986 | + EEH_Event_Query::set_query_params(); |
|
| 987 | + } |
|
| 988 | + |
|
| 989 | + |
|
| 990 | + /** |
|
| 991 | + * @throws EE_Error |
|
| 992 | + * @since 4.4.0 |
|
| 993 | + * @deprecated |
|
| 994 | + */ |
|
| 995 | + public function posts_fields($SQL, WP_Query $wp_query) |
|
| 996 | + { |
|
| 997 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 998 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
| 999 | + } |
|
| 1000 | + |
|
| 1001 | + |
|
| 1002 | + /** |
|
| 1003 | + * @throws EE_Error |
|
| 1004 | + * @since 4.4.0 |
|
| 1005 | + * @deprecated |
|
| 1006 | + */ |
|
| 1007 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) |
|
| 1008 | + { |
|
| 1009 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1010 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
| 1011 | + } |
|
| 1012 | + |
|
| 1013 | + |
|
| 1014 | + /** |
|
| 1015 | + * @throws EE_Error |
|
| 1016 | + * @since 4.4.0 |
|
| 1017 | + * @deprecated |
|
| 1018 | + */ |
|
| 1019 | + public function posts_join($SQL, WP_Query $wp_query) |
|
| 1020 | + { |
|
| 1021 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1022 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
| 1023 | + } |
|
| 1024 | + |
|
| 1025 | + |
|
| 1026 | + /** |
|
| 1027 | + * @deprecated |
|
| 1028 | + * @since 4.4.0 |
|
| 1029 | + */ |
|
| 1030 | + public static function posts_join_sql_for_terms($join_terms = null) |
|
| 1031 | + { |
|
| 1032 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1033 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
| 1034 | + } |
|
| 1035 | + |
|
| 1036 | + |
|
| 1037 | + /** |
|
| 1038 | + * @throws EE_Error |
|
| 1039 | + * @since 4.4.0 |
|
| 1040 | + * @deprecated |
|
| 1041 | + */ |
|
| 1042 | + public static function posts_join_for_orderby($orderby_params = array()) |
|
| 1043 | + { |
|
| 1044 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1045 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
| 1046 | + } |
|
| 1047 | + |
|
| 1048 | + |
|
| 1049 | + /** |
|
| 1050 | + * @throws EE_Error |
|
| 1051 | + * @since 4.4.0 |
|
| 1052 | + * @deprecated |
|
| 1053 | + */ |
|
| 1054 | + public function posts_where($SQL, WP_Query $wp_query) |
|
| 1055 | + { |
|
| 1056 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1057 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
| 1058 | + } |
|
| 1059 | + |
|
| 1060 | + |
|
| 1061 | + /** |
|
| 1062 | + * @throws EE_Error |
|
| 1063 | + * @since 4.4.0 |
|
| 1064 | + * @deprecated |
|
| 1065 | + */ |
|
| 1066 | + public static function posts_where_sql_for_show_expired($show_expired = false) |
|
| 1067 | + { |
|
| 1068 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1069 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
| 1070 | + } |
|
| 1071 | + |
|
| 1072 | + |
|
| 1073 | + /** |
|
| 1074 | + * @deprecated |
|
| 1075 | + * @since 4.4.0 |
|
| 1076 | + */ |
|
| 1077 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = null) |
|
| 1078 | + { |
|
| 1079 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1080 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
| 1081 | + } |
|
| 1082 | + |
|
| 1083 | + |
|
| 1084 | + /** |
|
| 1085 | + * @throws EE_Error |
|
| 1086 | + * @since 4.4.0 |
|
| 1087 | + * @deprecated |
|
| 1088 | + */ |
|
| 1089 | + public static function posts_where_sql_for_event_list_month($month = null) |
|
| 1090 | + { |
|
| 1091 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1092 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
| 1093 | + } |
|
| 1094 | + |
|
| 1095 | + |
|
| 1096 | + /** |
|
| 1097 | + * @throws EE_Error |
|
| 1098 | + * @since 4.4.0 |
|
| 1099 | + * @deprecated |
|
| 1100 | + */ |
|
| 1101 | + public function posts_orderby($SQL, WP_Query $wp_query) |
|
| 1102 | + { |
|
| 1103 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1104 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
| 1105 | + } |
|
| 1106 | + |
|
| 1107 | + |
|
| 1108 | + /** |
|
| 1109 | + * @throws EE_Error |
|
| 1110 | + * @since 4.4.0 |
|
| 1111 | + * @deprecated |
|
| 1112 | + */ |
|
| 1113 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') |
|
| 1114 | + { |
|
| 1115 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
| 1116 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
| 1117 | + } |
|
| 1118 | 1118 | } |
| 1119 | 1119 | |
| 1120 | 1120 | |
@@ -1123,9 +1123,9 @@ discard block |
||
| 1123 | 1123 | */ |
| 1124 | 1124 | function espresso_get_event_list_ID() |
| 1125 | 1125 | { |
| 1126 | - EED_Events_Archive::$espresso_event_list_ID++; |
|
| 1127 | - EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
| 1128 | - return EED_Events_Archive::$espresso_event_list_ID; |
|
| 1126 | + EED_Events_Archive::$espresso_event_list_ID++; |
|
| 1127 | + EED_Events_Archive::$espresso_grid_event_lists[] = EED_Events_Archive::$espresso_event_list_ID; |
|
| 1128 | + return EED_Events_Archive::$espresso_event_list_ID; |
|
| 1129 | 1129 | } |
| 1130 | 1130 | |
| 1131 | 1131 | /** |
@@ -1133,7 +1133,7 @@ discard block |
||
| 1133 | 1133 | */ |
| 1134 | 1134 | function espresso_event_list_title() |
| 1135 | 1135 | { |
| 1136 | - return EED_Events_Archive::event_list_title(); |
|
| 1136 | + return EED_Events_Archive::event_list_title(); |
|
| 1137 | 1137 | } |
| 1138 | 1138 | |
| 1139 | 1139 | /** |
@@ -1142,7 +1142,7 @@ discard block |
||
| 1142 | 1142 | */ |
| 1143 | 1143 | function espresso_event_list_css($extra_class = '') |
| 1144 | 1144 | { |
| 1145 | - return EED_Events_Archive::event_list_css($extra_class); |
|
| 1145 | + return EED_Events_Archive::event_list_css($extra_class); |
|
| 1146 | 1146 | } |
| 1147 | 1147 | |
| 1148 | 1148 | /** |
@@ -1150,7 +1150,7 @@ discard block |
||
| 1150 | 1150 | */ |
| 1151 | 1151 | function espresso_get_event_categories() |
| 1152 | 1152 | { |
| 1153 | - return EED_Events_Archive::event_categories(); |
|
| 1153 | + return EED_Events_Archive::event_categories(); |
|
| 1154 | 1154 | } |
| 1155 | 1155 | |
| 1156 | 1156 | /** |
@@ -1158,7 +1158,7 @@ discard block |
||
| 1158 | 1158 | */ |
| 1159 | 1159 | function espresso_display_full_description_in_event_list() |
| 1160 | 1160 | { |
| 1161 | - return EED_Events_Archive::display_description(2); |
|
| 1161 | + return EED_Events_Archive::display_description(2); |
|
| 1162 | 1162 | } |
| 1163 | 1163 | |
| 1164 | 1164 | /** |
@@ -1166,7 +1166,7 @@ discard block |
||
| 1166 | 1166 | */ |
| 1167 | 1167 | function espresso_display_excerpt_in_event_list() |
| 1168 | 1168 | { |
| 1169 | - return EED_Events_Archive::display_description(1); |
|
| 1169 | + return EED_Events_Archive::display_description(1); |
|
| 1170 | 1170 | } |
| 1171 | 1171 | |
| 1172 | 1172 | /** |
@@ -1174,7 +1174,7 @@ discard block |
||
| 1174 | 1174 | */ |
| 1175 | 1175 | function espresso_display_ticket_selector_in_event_list() |
| 1176 | 1176 | { |
| 1177 | - return EED_Events_Archive::display_ticket_selector(); |
|
| 1177 | + return EED_Events_Archive::display_ticket_selector(); |
|
| 1178 | 1178 | } |
| 1179 | 1179 | |
| 1180 | 1180 | /** |
@@ -1182,7 +1182,7 @@ discard block |
||
| 1182 | 1182 | */ |
| 1183 | 1183 | function espresso_display_venue_in_event_list() |
| 1184 | 1184 | { |
| 1185 | - return EED_Events_Archive::display_venue(); |
|
| 1185 | + return EED_Events_Archive::display_venue(); |
|
| 1186 | 1186 | } |
| 1187 | 1187 | |
| 1188 | 1188 | /** |
@@ -1190,5 +1190,5 @@ discard block |
||
| 1190 | 1190 | */ |
| 1191 | 1191 | function espresso_display_datetimes_in_event_list() |
| 1192 | 1192 | { |
| 1193 | - return EED_Events_Archive::display_datetimes(); |
|
| 1193 | + return EED_Events_Archive::display_datetimes(); |
|
| 1194 | 1194 | } |
@@ -14,473 +14,473 @@ discard block |
||
| 14 | 14 | class EED_Event_Single extends EED_Module |
| 15 | 15 | { |
| 16 | 16 | |
| 17 | - const EVENT_DETAILS_PRIORITY = 100; |
|
| 18 | - const EVENT_DATETIMES_PRIORITY = 110; |
|
| 19 | - const EVENT_TICKETS_PRIORITY = 120; |
|
| 20 | - const EVENT_VENUES_PRIORITY = 130; |
|
| 21 | - |
|
| 22 | - /** |
|
| 23 | - * @type bool $using_get_the_excerpt |
|
| 24 | - */ |
|
| 25 | - protected static $using_get_the_excerpt = false; |
|
| 26 | - |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * @type EE_Template_Part_Manager $template_parts |
|
| 30 | - */ |
|
| 31 | - protected $template_parts; |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @return EED_Module|EED_Event_Single |
|
| 36 | - */ |
|
| 37 | - public static function instance() |
|
| 38 | - { |
|
| 39 | - return parent::get_instance(__CLASS__); |
|
| 40 | - } |
|
| 41 | - |
|
| 42 | - |
|
| 43 | - /** |
|
| 44 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
| 45 | - * |
|
| 46 | - * @return void |
|
| 47 | - * @throws InvalidArgumentException |
|
| 48 | - * @throws InvalidDataTypeException |
|
| 49 | - * @throws InvalidInterfaceException |
|
| 50 | - */ |
|
| 51 | - public static function set_hooks() |
|
| 52 | - { |
|
| 53 | - add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 54 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 55 | - /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
| 56 | - $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
| 57 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
| 58 | - ); |
|
| 59 | - $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
| 60 | - EE_Config::register_route( |
|
| 61 | - $custom_post_types['espresso_events']['singular_slug'], |
|
| 62 | - 'Event_Single', |
|
| 63 | - 'run' |
|
| 64 | - ); |
|
| 65 | - } |
|
| 66 | - |
|
| 67 | - /** |
|
| 68 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 69 | - * |
|
| 70 | - * @return void |
|
| 71 | - */ |
|
| 72 | - public static function set_hooks_admin() |
|
| 73 | - { |
|
| 74 | - add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * set_definitions |
|
| 80 | - * |
|
| 81 | - * @static |
|
| 82 | - * @return void |
|
| 83 | - */ |
|
| 84 | - public static function set_definitions() |
|
| 85 | - { |
|
| 86 | - define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 87 | - define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
| 88 | - } |
|
| 89 | - |
|
| 90 | - |
|
| 91 | - /** |
|
| 92 | - * set_config |
|
| 93 | - * |
|
| 94 | - * @void |
|
| 95 | - */ |
|
| 96 | - protected function set_config() |
|
| 97 | - { |
|
| 98 | - $this->set_config_section('template_settings'); |
|
| 99 | - $this->set_config_class('EE_Event_Single_Config'); |
|
| 100 | - $this->set_config_name('EED_Event_Single'); |
|
| 101 | - } |
|
| 102 | - |
|
| 103 | - |
|
| 104 | - /** |
|
| 105 | - * initialize_template_parts |
|
| 106 | - * |
|
| 107 | - * @param EE_Config_Base|EE_Event_Single_Config $config |
|
| 108 | - * @return EE_Template_Part_Manager |
|
| 109 | - * @throws EE_Error |
|
| 110 | - */ |
|
| 111 | - public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
| 112 | - { |
|
| 113 | - /** @type EE_Event_Single_Config $config */ |
|
| 114 | - $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
| 115 | - EEH_Autoloader::register_template_part_autoloaders(); |
|
| 116 | - $template_parts = new EE_Template_Part_Manager(); |
|
| 117 | - $template_parts->add_template_part( |
|
| 118 | - 'tickets', |
|
| 119 | - __('Ticket Selector', 'event_espresso'), |
|
| 120 | - 'content-espresso_events-tickets.php', |
|
| 121 | - $config->display_order_tickets |
|
| 122 | - ); |
|
| 123 | - $template_parts->add_template_part( |
|
| 124 | - 'datetimes', |
|
| 125 | - __('Dates and Times', 'event_espresso'), |
|
| 126 | - 'content-espresso_events-datetimes.php', |
|
| 127 | - $config->display_order_datetimes |
|
| 128 | - ); |
|
| 129 | - $template_parts->add_template_part( |
|
| 130 | - 'event', |
|
| 131 | - __('Event Description', 'event_espresso'), |
|
| 132 | - 'content-espresso_events-details.php', |
|
| 133 | - $config->display_order_event |
|
| 134 | - ); |
|
| 135 | - $template_parts->add_template_part( |
|
| 136 | - 'venue', |
|
| 137 | - __('Venue Information', 'event_espresso'), |
|
| 138 | - 'content-espresso_events-venues.php', |
|
| 139 | - $config->display_order_venue |
|
| 140 | - ); |
|
| 141 | - do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 142 | - return $template_parts; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * run - initial module setup |
|
| 148 | - * |
|
| 149 | - * @param WP $WP |
|
| 150 | - * @return void |
|
| 151 | - */ |
|
| 152 | - public function run($WP) |
|
| 153 | - { |
|
| 154 | - // ensure valid EE_Events_Single_Config() object exists |
|
| 155 | - $this->set_config(); |
|
| 156 | - // check what template is loaded |
|
| 157 | - add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 158 | - add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 159 | - // load css |
|
| 160 | - add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * template_include |
|
| 166 | - * |
|
| 167 | - * @param string $template |
|
| 168 | - * @return string |
|
| 169 | - */ |
|
| 170 | - public function template_include($template) |
|
| 171 | - { |
|
| 172 | - global $post; |
|
| 173 | - /** @type EE_Event_Single_Config $config */ |
|
| 174 | - $config = $this->config(); |
|
| 175 | - if ($config->display_status_banner_single) { |
|
| 176 | - add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 177 | - } |
|
| 178 | - // not a custom template? |
|
| 179 | - if (! post_password_required($post) |
|
| 180 | - && ( |
|
| 181 | - apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 182 | - || EE_Registry::instance() |
|
| 183 | - ->load_core('Front_Controller') |
|
| 184 | - ->get_selected_template() !== 'single-espresso_events.php' |
|
| 185 | - ) |
|
| 186 | - |
|
| 187 | - ) { |
|
| 188 | - EEH_Template::load_espresso_theme_functions(); |
|
| 189 | - // then add extra event data via hooks |
|
| 190 | - add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 191 | - add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 192 | - add_filter( |
|
| 193 | - 'the_content', |
|
| 194 | - array('EED_Event_Single', 'event_details'), |
|
| 195 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 196 | - ); |
|
| 197 | - add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 198 | - // don't display entry meta because the existing theme will take car of that |
|
| 199 | - add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 200 | - } |
|
| 201 | - return $template; |
|
| 202 | - } |
|
| 203 | - |
|
| 204 | - |
|
| 205 | - /** |
|
| 206 | - * loop_start |
|
| 207 | - * |
|
| 208 | - * @param array $wp_query_array an array containing the WP_Query object |
|
| 209 | - * @return void |
|
| 210 | - */ |
|
| 211 | - public static function loop_start($wp_query_array) |
|
| 212 | - { |
|
| 213 | - global $post; |
|
| 214 | - do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 215 | - } |
|
| 216 | - |
|
| 217 | - |
|
| 218 | - /** |
|
| 219 | - * the_title |
|
| 220 | - * |
|
| 221 | - * @param string $title |
|
| 222 | - * @param int $id |
|
| 223 | - * @return string |
|
| 224 | - */ |
|
| 225 | - public static function the_title($title = '', $id = 0) |
|
| 226 | - { |
|
| 227 | - global $post; |
|
| 228 | - return in_the_loop() && $post->ID === (int) $id |
|
| 229 | - ? espresso_event_status_banner($post->ID) . $title |
|
| 230 | - : $title; |
|
| 231 | - } |
|
| 232 | - |
|
| 233 | - |
|
| 234 | - /** |
|
| 235 | - * get_the_excerpt |
|
| 236 | - * kinda hacky, but if a theme is using get_the_excerpt(), |
|
| 237 | - * then we need to remove our filters on the_content() |
|
| 238 | - * |
|
| 239 | - * @param string $excerpt |
|
| 240 | - * @return string |
|
| 241 | - */ |
|
| 242 | - public static function get_the_excerpt($excerpt = '') |
|
| 243 | - { |
|
| 244 | - EED_Event_Single::$using_get_the_excerpt = true; |
|
| 245 | - add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 246 | - return $excerpt; |
|
| 247 | - } |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * end_get_the_excerpt |
|
| 252 | - * |
|
| 253 | - * @param string $text |
|
| 254 | - * @return string |
|
| 255 | - */ |
|
| 256 | - public static function end_get_the_excerpt($text = '') |
|
| 257 | - { |
|
| 258 | - EED_Event_Single::$using_get_the_excerpt = false; |
|
| 259 | - return $text; |
|
| 260 | - } |
|
| 261 | - |
|
| 262 | - |
|
| 263 | - /** |
|
| 264 | - * event_details |
|
| 265 | - * |
|
| 266 | - * @param string $content |
|
| 267 | - * @return string |
|
| 268 | - */ |
|
| 269 | - public static function event_details($content) |
|
| 270 | - { |
|
| 271 | - global $post; |
|
| 272 | - static $current_post_ID = 0; |
|
| 273 | - if ($current_post_ID !== $post->ID |
|
| 274 | - && $post->post_type === 'espresso_events' |
|
| 275 | - && ! EED_Event_Single::$using_get_the_excerpt |
|
| 276 | - && ! post_password_required() |
|
| 277 | - ) { |
|
| 278 | - // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 279 | - // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 280 | - // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 281 | - // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 282 | - // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 283 | - // so the following allows this filter to be applied multiple times, but only once for real |
|
| 284 | - $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 285 | - if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 286 | - // we need to first remove this callback from being applied to the_content() |
|
| 287 | - // (otherwise it will recurse and blow up the interweb) |
|
| 288 | - remove_filter( |
|
| 289 | - 'the_content', |
|
| 290 | - array('EED_Event_Single', 'event_details'), |
|
| 291 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 292 | - ); |
|
| 293 | - EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts( |
|
| 294 | - ); |
|
| 295 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 296 | - $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 297 | - add_filter( |
|
| 298 | - 'the_content', |
|
| 299 | - array('EED_Event_Single', 'event_details'), |
|
| 300 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 301 | - ); |
|
| 302 | - } else { |
|
| 303 | - $content = EED_Event_Single::use_filterable_display_order(); |
|
| 304 | - } |
|
| 305 | - } |
|
| 306 | - return $content; |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - |
|
| 310 | - /** |
|
| 311 | - * use_filterable_display_order |
|
| 312 | - * |
|
| 313 | - * @return string |
|
| 314 | - */ |
|
| 315 | - protected static function use_filterable_display_order() |
|
| 316 | - { |
|
| 317 | - // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
| 318 | - // it uses the_content() for displaying the $post->post_content |
|
| 319 | - // so in order to load a template that uses the_content() |
|
| 320 | - // from within a callback being used to filter the_content(), |
|
| 321 | - // we need to first remove this callback from being applied to the_content() |
|
| 322 | - // (otherwise it will recurse and blow up the interweb) |
|
| 323 | - remove_filter( |
|
| 324 | - 'the_content', |
|
| 325 | - array('EED_Event_Single', 'event_details'), |
|
| 326 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 327 | - ); |
|
| 328 | - // now add additional content |
|
| 329 | - add_filter( |
|
| 330 | - 'the_content', |
|
| 331 | - array('EED_Event_Single', 'event_datetimes'), |
|
| 332 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
| 333 | - 1 |
|
| 334 | - ); |
|
| 335 | - add_filter( |
|
| 336 | - 'the_content', |
|
| 337 | - array('EED_Event_Single', 'event_tickets'), |
|
| 338 | - EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
| 339 | - 1 |
|
| 340 | - ); |
|
| 341 | - add_filter( |
|
| 342 | - 'the_content', |
|
| 343 | - array('EED_Event_Single', 'event_venues'), |
|
| 344 | - EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
| 345 | - 1 |
|
| 346 | - ); |
|
| 347 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 348 | - // now load our template |
|
| 349 | - $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 350 | - // now add our filter back in, plus some others |
|
| 351 | - add_filter( |
|
| 352 | - 'the_content', |
|
| 353 | - array('EED_Event_Single', 'event_details'), |
|
| 354 | - EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 355 | - ); |
|
| 356 | - remove_filter( |
|
| 357 | - 'the_content', |
|
| 358 | - array('EED_Event_Single', 'event_datetimes'), |
|
| 359 | - EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
| 360 | - ); |
|
| 361 | - remove_filter( |
|
| 362 | - 'the_content', |
|
| 363 | - array('EED_Event_Single', 'event_tickets'), |
|
| 364 | - EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
| 365 | - ); |
|
| 366 | - remove_filter( |
|
| 367 | - 'the_content', |
|
| 368 | - array('EED_Event_Single', 'event_venues'), |
|
| 369 | - EED_Event_Single::EVENT_VENUES_PRIORITY |
|
| 370 | - ); |
|
| 371 | - do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
| 372 | - // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 373 | - return $content; |
|
| 374 | - } |
|
| 375 | - |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * event_datetimes - adds datetimes ABOVE content |
|
| 379 | - * |
|
| 380 | - * @param string $content |
|
| 381 | - * @return string |
|
| 382 | - */ |
|
| 383 | - public static function event_datetimes($content) |
|
| 384 | - { |
|
| 385 | - return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 386 | - } |
|
| 387 | - |
|
| 388 | - |
|
| 389 | - /** |
|
| 390 | - * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 391 | - * |
|
| 392 | - * @param string $content |
|
| 393 | - * @return string |
|
| 394 | - */ |
|
| 395 | - public static function event_tickets($content) |
|
| 396 | - { |
|
| 397 | - return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - /** |
|
| 402 | - * event_venues |
|
| 403 | - * |
|
| 404 | - * @param string $content |
|
| 405 | - * @return string |
|
| 406 | - */ |
|
| 407 | - public static function event_venue($content) |
|
| 408 | - { |
|
| 409 | - return EED_Event_Single::event_venues($content); |
|
| 410 | - } |
|
| 411 | - |
|
| 412 | - |
|
| 413 | - /** |
|
| 414 | - * event_venues - adds venues BELOW content |
|
| 415 | - * |
|
| 416 | - * @param string $content |
|
| 417 | - * @return string |
|
| 418 | - */ |
|
| 419 | - public static function event_venues($content) |
|
| 420 | - { |
|
| 421 | - return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 422 | - } |
|
| 423 | - |
|
| 424 | - |
|
| 425 | - /** |
|
| 426 | - * loop_end |
|
| 427 | - * |
|
| 428 | - * @param array $wp_query_array an array containing the WP_Query object |
|
| 429 | - * @return void |
|
| 430 | - */ |
|
| 431 | - public static function loop_end($wp_query_array) |
|
| 432 | - { |
|
| 433 | - global $post; |
|
| 434 | - do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 435 | - } |
|
| 436 | - |
|
| 437 | - |
|
| 438 | - /** |
|
| 439 | - * wp_enqueue_scripts |
|
| 440 | - * |
|
| 441 | - * @return void |
|
| 442 | - */ |
|
| 443 | - public function wp_enqueue_scripts() |
|
| 444 | - { |
|
| 445 | - // get some style |
|
| 446 | - if (apply_filters('FHEE_enable_default_espresso_css', true) |
|
| 447 | - && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true) |
|
| 448 | - ) { |
|
| 449 | - // first check uploads folder |
|
| 450 | - if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
| 451 | - wp_register_style( |
|
| 452 | - $this->theme, |
|
| 453 | - get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
| 454 | - array('dashicons', 'espresso_default') |
|
| 455 | - ); |
|
| 456 | - } else { |
|
| 457 | - wp_register_style( |
|
| 458 | - $this->theme, |
|
| 459 | - EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
| 460 | - array('dashicons', 'espresso_default') |
|
| 461 | - ); |
|
| 462 | - } |
|
| 463 | - wp_enqueue_script($this->theme); |
|
| 464 | - if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 465 | - add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 466 | - } |
|
| 467 | - } |
|
| 468 | - } |
|
| 469 | - |
|
| 470 | - |
|
| 471 | - /** |
|
| 472 | - * display_venue |
|
| 473 | - * |
|
| 474 | - * @return bool |
|
| 475 | - */ |
|
| 476 | - public static function display_venue() |
|
| 477 | - { |
|
| 478 | - /** @type EE_Event_Single_Config $config */ |
|
| 479 | - $config = EED_Event_Single::instance()->config(); |
|
| 480 | - $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
| 481 | - $venue_name = EEH_Venue_View::venue_name(); |
|
| 482 | - return $display_venue && ! empty($venue_name); |
|
| 483 | - } |
|
| 17 | + const EVENT_DETAILS_PRIORITY = 100; |
|
| 18 | + const EVENT_DATETIMES_PRIORITY = 110; |
|
| 19 | + const EVENT_TICKETS_PRIORITY = 120; |
|
| 20 | + const EVENT_VENUES_PRIORITY = 130; |
|
| 21 | + |
|
| 22 | + /** |
|
| 23 | + * @type bool $using_get_the_excerpt |
|
| 24 | + */ |
|
| 25 | + protected static $using_get_the_excerpt = false; |
|
| 26 | + |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * @type EE_Template_Part_Manager $template_parts |
|
| 30 | + */ |
|
| 31 | + protected $template_parts; |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @return EED_Module|EED_Event_Single |
|
| 36 | + */ |
|
| 37 | + public static function instance() |
|
| 38 | + { |
|
| 39 | + return parent::get_instance(__CLASS__); |
|
| 40 | + } |
|
| 41 | + |
|
| 42 | + |
|
| 43 | + /** |
|
| 44 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
| 45 | + * |
|
| 46 | + * @return void |
|
| 47 | + * @throws InvalidArgumentException |
|
| 48 | + * @throws InvalidDataTypeException |
|
| 49 | + * @throws InvalidInterfaceException |
|
| 50 | + */ |
|
| 51 | + public static function set_hooks() |
|
| 52 | + { |
|
| 53 | + add_filter('FHEE_run_EE_wp', '__return_true'); |
|
| 54 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 55 | + /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_type_definitions */ |
|
| 56 | + $custom_post_type_definitions = LoaderFactory::getLoader()->getShared( |
|
| 57 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' |
|
| 58 | + ); |
|
| 59 | + $custom_post_types = $custom_post_type_definitions->getDefinitions(); |
|
| 60 | + EE_Config::register_route( |
|
| 61 | + $custom_post_types['espresso_events']['singular_slug'], |
|
| 62 | + 'Event_Single', |
|
| 63 | + 'run' |
|
| 64 | + ); |
|
| 65 | + } |
|
| 66 | + |
|
| 67 | + /** |
|
| 68 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
| 69 | + * |
|
| 70 | + * @return void |
|
| 71 | + */ |
|
| 72 | + public static function set_hooks_admin() |
|
| 73 | + { |
|
| 74 | + add_action('wp_loaded', array('EED_Event_Single', 'set_definitions'), 2); |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * set_definitions |
|
| 80 | + * |
|
| 81 | + * @static |
|
| 82 | + * @return void |
|
| 83 | + */ |
|
| 84 | + public static function set_definitions() |
|
| 85 | + { |
|
| 86 | + define('EVENT_SINGLE_ASSETS_URL', plugin_dir_url(__FILE__) . 'assets/'); |
|
| 87 | + define('EVENT_SINGLE_TEMPLATES_PATH', plugin_dir_path(__FILE__) . 'templates/'); |
|
| 88 | + } |
|
| 89 | + |
|
| 90 | + |
|
| 91 | + /** |
|
| 92 | + * set_config |
|
| 93 | + * |
|
| 94 | + * @void |
|
| 95 | + */ |
|
| 96 | + protected function set_config() |
|
| 97 | + { |
|
| 98 | + $this->set_config_section('template_settings'); |
|
| 99 | + $this->set_config_class('EE_Event_Single_Config'); |
|
| 100 | + $this->set_config_name('EED_Event_Single'); |
|
| 101 | + } |
|
| 102 | + |
|
| 103 | + |
|
| 104 | + /** |
|
| 105 | + * initialize_template_parts |
|
| 106 | + * |
|
| 107 | + * @param EE_Config_Base|EE_Event_Single_Config $config |
|
| 108 | + * @return EE_Template_Part_Manager |
|
| 109 | + * @throws EE_Error |
|
| 110 | + */ |
|
| 111 | + public function initialize_template_parts(EE_Event_Single_Config $config = null) |
|
| 112 | + { |
|
| 113 | + /** @type EE_Event_Single_Config $config */ |
|
| 114 | + $config = $config instanceof EE_Event_Single_Config ? $config : $this->config(); |
|
| 115 | + EEH_Autoloader::register_template_part_autoloaders(); |
|
| 116 | + $template_parts = new EE_Template_Part_Manager(); |
|
| 117 | + $template_parts->add_template_part( |
|
| 118 | + 'tickets', |
|
| 119 | + __('Ticket Selector', 'event_espresso'), |
|
| 120 | + 'content-espresso_events-tickets.php', |
|
| 121 | + $config->display_order_tickets |
|
| 122 | + ); |
|
| 123 | + $template_parts->add_template_part( |
|
| 124 | + 'datetimes', |
|
| 125 | + __('Dates and Times', 'event_espresso'), |
|
| 126 | + 'content-espresso_events-datetimes.php', |
|
| 127 | + $config->display_order_datetimes |
|
| 128 | + ); |
|
| 129 | + $template_parts->add_template_part( |
|
| 130 | + 'event', |
|
| 131 | + __('Event Description', 'event_espresso'), |
|
| 132 | + 'content-espresso_events-details.php', |
|
| 133 | + $config->display_order_event |
|
| 134 | + ); |
|
| 135 | + $template_parts->add_template_part( |
|
| 136 | + 'venue', |
|
| 137 | + __('Venue Information', 'event_espresso'), |
|
| 138 | + 'content-espresso_events-venues.php', |
|
| 139 | + $config->display_order_venue |
|
| 140 | + ); |
|
| 141 | + do_action('AHEE__EED_Event_Single__initialize_template_parts', $template_parts); |
|
| 142 | + return $template_parts; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * run - initial module setup |
|
| 148 | + * |
|
| 149 | + * @param WP $WP |
|
| 150 | + * @return void |
|
| 151 | + */ |
|
| 152 | + public function run($WP) |
|
| 153 | + { |
|
| 154 | + // ensure valid EE_Events_Single_Config() object exists |
|
| 155 | + $this->set_config(); |
|
| 156 | + // check what template is loaded |
|
| 157 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
| 158 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
| 159 | + // load css |
|
| 160 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * template_include |
|
| 166 | + * |
|
| 167 | + * @param string $template |
|
| 168 | + * @return string |
|
| 169 | + */ |
|
| 170 | + public function template_include($template) |
|
| 171 | + { |
|
| 172 | + global $post; |
|
| 173 | + /** @type EE_Event_Single_Config $config */ |
|
| 174 | + $config = $this->config(); |
|
| 175 | + if ($config->display_status_banner_single) { |
|
| 176 | + add_filter('the_title', array('EED_Event_Single', 'the_title'), 100, 2); |
|
| 177 | + } |
|
| 178 | + // not a custom template? |
|
| 179 | + if (! post_password_required($post) |
|
| 180 | + && ( |
|
| 181 | + apply_filters('FHEE__EED_Event_Single__template_include__allow_custom_selected_template', false) |
|
| 182 | + || EE_Registry::instance() |
|
| 183 | + ->load_core('Front_Controller') |
|
| 184 | + ->get_selected_template() !== 'single-espresso_events.php' |
|
| 185 | + ) |
|
| 186 | + |
|
| 187 | + ) { |
|
| 188 | + EEH_Template::load_espresso_theme_functions(); |
|
| 189 | + // then add extra event data via hooks |
|
| 190 | + add_action('loop_start', array('EED_Event_Single', 'loop_start')); |
|
| 191 | + add_filter('get_the_excerpt', array('EED_Event_Single', 'get_the_excerpt'), 1, 1); |
|
| 192 | + add_filter( |
|
| 193 | + 'the_content', |
|
| 194 | + array('EED_Event_Single', 'event_details'), |
|
| 195 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 196 | + ); |
|
| 197 | + add_action('loop_end', array('EED_Event_Single', 'loop_end')); |
|
| 198 | + // don't display entry meta because the existing theme will take car of that |
|
| 199 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
| 200 | + } |
|
| 201 | + return $template; |
|
| 202 | + } |
|
| 203 | + |
|
| 204 | + |
|
| 205 | + /** |
|
| 206 | + * loop_start |
|
| 207 | + * |
|
| 208 | + * @param array $wp_query_array an array containing the WP_Query object |
|
| 209 | + * @return void |
|
| 210 | + */ |
|
| 211 | + public static function loop_start($wp_query_array) |
|
| 212 | + { |
|
| 213 | + global $post; |
|
| 214 | + do_action('AHEE_event_details_before_post', $post, $wp_query_array); |
|
| 215 | + } |
|
| 216 | + |
|
| 217 | + |
|
| 218 | + /** |
|
| 219 | + * the_title |
|
| 220 | + * |
|
| 221 | + * @param string $title |
|
| 222 | + * @param int $id |
|
| 223 | + * @return string |
|
| 224 | + */ |
|
| 225 | + public static function the_title($title = '', $id = 0) |
|
| 226 | + { |
|
| 227 | + global $post; |
|
| 228 | + return in_the_loop() && $post->ID === (int) $id |
|
| 229 | + ? espresso_event_status_banner($post->ID) . $title |
|
| 230 | + : $title; |
|
| 231 | + } |
|
| 232 | + |
|
| 233 | + |
|
| 234 | + /** |
|
| 235 | + * get_the_excerpt |
|
| 236 | + * kinda hacky, but if a theme is using get_the_excerpt(), |
|
| 237 | + * then we need to remove our filters on the_content() |
|
| 238 | + * |
|
| 239 | + * @param string $excerpt |
|
| 240 | + * @return string |
|
| 241 | + */ |
|
| 242 | + public static function get_the_excerpt($excerpt = '') |
|
| 243 | + { |
|
| 244 | + EED_Event_Single::$using_get_the_excerpt = true; |
|
| 245 | + add_filter('wp_trim_excerpt', array('EED_Event_Single', 'end_get_the_excerpt'), 999, 1); |
|
| 246 | + return $excerpt; |
|
| 247 | + } |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * end_get_the_excerpt |
|
| 252 | + * |
|
| 253 | + * @param string $text |
|
| 254 | + * @return string |
|
| 255 | + */ |
|
| 256 | + public static function end_get_the_excerpt($text = '') |
|
| 257 | + { |
|
| 258 | + EED_Event_Single::$using_get_the_excerpt = false; |
|
| 259 | + return $text; |
|
| 260 | + } |
|
| 261 | + |
|
| 262 | + |
|
| 263 | + /** |
|
| 264 | + * event_details |
|
| 265 | + * |
|
| 266 | + * @param string $content |
|
| 267 | + * @return string |
|
| 268 | + */ |
|
| 269 | + public static function event_details($content) |
|
| 270 | + { |
|
| 271 | + global $post; |
|
| 272 | + static $current_post_ID = 0; |
|
| 273 | + if ($current_post_ID !== $post->ID |
|
| 274 | + && $post->post_type === 'espresso_events' |
|
| 275 | + && ! EED_Event_Single::$using_get_the_excerpt |
|
| 276 | + && ! post_password_required() |
|
| 277 | + ) { |
|
| 278 | + // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
|
| 279 | + // Reason being is that some plugins, like Yoast, need to run through a copy of the loop early |
|
| 280 | + // BEFORE headers are sent in order to examine the post content and generate content for the HTML header. |
|
| 281 | + // We want to allow those plugins to still do their thing and have access to our content, but depending on |
|
| 282 | + // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
|
| 283 | + // so the following allows this filter to be applied multiple times, but only once for real |
|
| 284 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
| 285 | + if (EE_Registry::instance()->CFG->template_settings->EED_Event_Single->use_sortable_display_order) { |
|
| 286 | + // we need to first remove this callback from being applied to the_content() |
|
| 287 | + // (otherwise it will recurse and blow up the interweb) |
|
| 288 | + remove_filter( |
|
| 289 | + 'the_content', |
|
| 290 | + array('EED_Event_Single', 'event_details'), |
|
| 291 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 292 | + ); |
|
| 293 | + EED_Event_Single::instance()->template_parts = EED_Event_Single::instance()->initialize_template_parts( |
|
| 294 | + ); |
|
| 295 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 296 | + $content = EED_Event_Single::instance()->template_parts->apply_template_part_filters($content); |
|
| 297 | + add_filter( |
|
| 298 | + 'the_content', |
|
| 299 | + array('EED_Event_Single', 'event_details'), |
|
| 300 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 301 | + ); |
|
| 302 | + } else { |
|
| 303 | + $content = EED_Event_Single::use_filterable_display_order(); |
|
| 304 | + } |
|
| 305 | + } |
|
| 306 | + return $content; |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + |
|
| 310 | + /** |
|
| 311 | + * use_filterable_display_order |
|
| 312 | + * |
|
| 313 | + * @return string |
|
| 314 | + */ |
|
| 315 | + protected static function use_filterable_display_order() |
|
| 316 | + { |
|
| 317 | + // since the 'content-espresso_events-details.php' template might be used directly from within a theme, |
|
| 318 | + // it uses the_content() for displaying the $post->post_content |
|
| 319 | + // so in order to load a template that uses the_content() |
|
| 320 | + // from within a callback being used to filter the_content(), |
|
| 321 | + // we need to first remove this callback from being applied to the_content() |
|
| 322 | + // (otherwise it will recurse and blow up the interweb) |
|
| 323 | + remove_filter( |
|
| 324 | + 'the_content', |
|
| 325 | + array('EED_Event_Single', 'event_details'), |
|
| 326 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 327 | + ); |
|
| 328 | + // now add additional content |
|
| 329 | + add_filter( |
|
| 330 | + 'the_content', |
|
| 331 | + array('EED_Event_Single', 'event_datetimes'), |
|
| 332 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY, |
|
| 333 | + 1 |
|
| 334 | + ); |
|
| 335 | + add_filter( |
|
| 336 | + 'the_content', |
|
| 337 | + array('EED_Event_Single', 'event_tickets'), |
|
| 338 | + EED_Event_Single::EVENT_TICKETS_PRIORITY, |
|
| 339 | + 1 |
|
| 340 | + ); |
|
| 341 | + add_filter( |
|
| 342 | + 'the_content', |
|
| 343 | + array('EED_Event_Single', 'event_venues'), |
|
| 344 | + EED_Event_Single::EVENT_VENUES_PRIORITY, |
|
| 345 | + 1 |
|
| 346 | + ); |
|
| 347 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_add_filters'); |
|
| 348 | + // now load our template |
|
| 349 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
| 350 | + // now add our filter back in, plus some others |
|
| 351 | + add_filter( |
|
| 352 | + 'the_content', |
|
| 353 | + array('EED_Event_Single', 'event_details'), |
|
| 354 | + EED_Event_Single::EVENT_DETAILS_PRIORITY |
|
| 355 | + ); |
|
| 356 | + remove_filter( |
|
| 357 | + 'the_content', |
|
| 358 | + array('EED_Event_Single', 'event_datetimes'), |
|
| 359 | + EED_Event_Single::EVENT_DATETIMES_PRIORITY |
|
| 360 | + ); |
|
| 361 | + remove_filter( |
|
| 362 | + 'the_content', |
|
| 363 | + array('EED_Event_Single', 'event_tickets'), |
|
| 364 | + EED_Event_Single::EVENT_TICKETS_PRIORITY |
|
| 365 | + ); |
|
| 366 | + remove_filter( |
|
| 367 | + 'the_content', |
|
| 368 | + array('EED_Event_Single', 'event_venues'), |
|
| 369 | + EED_Event_Single::EVENT_VENUES_PRIORITY |
|
| 370 | + ); |
|
| 371 | + do_action('AHEE__EED_Event_Single__use_filterable_display_order__after_remove_filters'); |
|
| 372 | + // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
|
| 373 | + return $content; |
|
| 374 | + } |
|
| 375 | + |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * event_datetimes - adds datetimes ABOVE content |
|
| 379 | + * |
|
| 380 | + * @param string $content |
|
| 381 | + * @return string |
|
| 382 | + */ |
|
| 383 | + public static function event_datetimes($content) |
|
| 384 | + { |
|
| 385 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php') . $content; |
|
| 386 | + } |
|
| 387 | + |
|
| 388 | + |
|
| 389 | + /** |
|
| 390 | + * event_tickets - adds tickets ABOVE content (which includes datetimes) |
|
| 391 | + * |
|
| 392 | + * @param string $content |
|
| 393 | + * @return string |
|
| 394 | + */ |
|
| 395 | + public static function event_tickets($content) |
|
| 396 | + { |
|
| 397 | + return EEH_Template::locate_template('content-espresso_events-tickets.php') . $content; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * event_venues |
|
| 403 | + * |
|
| 404 | + * @param string $content |
|
| 405 | + * @return string |
|
| 406 | + */ |
|
| 407 | + public static function event_venue($content) |
|
| 408 | + { |
|
| 409 | + return EED_Event_Single::event_venues($content); |
|
| 410 | + } |
|
| 411 | + |
|
| 412 | + |
|
| 413 | + /** |
|
| 414 | + * event_venues - adds venues BELOW content |
|
| 415 | + * |
|
| 416 | + * @param string $content |
|
| 417 | + * @return string |
|
| 418 | + */ |
|
| 419 | + public static function event_venues($content) |
|
| 420 | + { |
|
| 421 | + return $content . EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
| 422 | + } |
|
| 423 | + |
|
| 424 | + |
|
| 425 | + /** |
|
| 426 | + * loop_end |
|
| 427 | + * |
|
| 428 | + * @param array $wp_query_array an array containing the WP_Query object |
|
| 429 | + * @return void |
|
| 430 | + */ |
|
| 431 | + public static function loop_end($wp_query_array) |
|
| 432 | + { |
|
| 433 | + global $post; |
|
| 434 | + do_action('AHEE_event_details_after_post', $post, $wp_query_array); |
|
| 435 | + } |
|
| 436 | + |
|
| 437 | + |
|
| 438 | + /** |
|
| 439 | + * wp_enqueue_scripts |
|
| 440 | + * |
|
| 441 | + * @return void |
|
| 442 | + */ |
|
| 443 | + public function wp_enqueue_scripts() |
|
| 444 | + { |
|
| 445 | + // get some style |
|
| 446 | + if (apply_filters('FHEE_enable_default_espresso_css', true) |
|
| 447 | + && apply_filters('FHEE__EED_Event_Single__wp_enqueue_scripts__enable_css', true) |
|
| 448 | + ) { |
|
| 449 | + // first check uploads folder |
|
| 450 | + if (is_readable(get_stylesheet_directory() . $this->theme . '/style.css')) { |
|
| 451 | + wp_register_style( |
|
| 452 | + $this->theme, |
|
| 453 | + get_stylesheet_directory_uri() . $this->theme . '/style.css', |
|
| 454 | + array('dashicons', 'espresso_default') |
|
| 455 | + ); |
|
| 456 | + } else { |
|
| 457 | + wp_register_style( |
|
| 458 | + $this->theme, |
|
| 459 | + EE_TEMPLATES_URL . $this->theme . '/style.css', |
|
| 460 | + array('dashicons', 'espresso_default') |
|
| 461 | + ); |
|
| 462 | + } |
|
| 463 | + wp_enqueue_script($this->theme); |
|
| 464 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
| 465 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
| 466 | + } |
|
| 467 | + } |
|
| 468 | + } |
|
| 469 | + |
|
| 470 | + |
|
| 471 | + /** |
|
| 472 | + * display_venue |
|
| 473 | + * |
|
| 474 | + * @return bool |
|
| 475 | + */ |
|
| 476 | + public static function display_venue() |
|
| 477 | + { |
|
| 478 | + /** @type EE_Event_Single_Config $config */ |
|
| 479 | + $config = EED_Event_Single::instance()->config(); |
|
| 480 | + $display_venue = $config->display_venue === null ? true : $config->display_venue; |
|
| 481 | + $venue_name = EEH_Venue_View::venue_name(); |
|
| 482 | + return $display_venue && ! empty($venue_name); |
|
| 483 | + } |
|
| 484 | 484 | } |
| 485 | 485 | |
| 486 | 486 | |
@@ -492,5 +492,5 @@ discard block |
||
| 492 | 492 | */ |
| 493 | 493 | function espresso_display_venue_in_event_details() |
| 494 | 494 | { |
| 495 | - return EED_Event_Single::display_venue(); |
|
| 495 | + return EED_Event_Single::display_venue(); |
|
| 496 | 496 | } |
@@ -17,295 +17,295 @@ |
||
| 17 | 17 | { |
| 18 | 18 | |
| 19 | 19 | |
| 20 | - /** |
|
| 21 | - * instance of the EE_System object |
|
| 22 | - * |
|
| 23 | - * @var $_instance |
|
| 24 | - * @access private |
|
| 25 | - */ |
|
| 26 | - private static $_instance = null; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * $_autoloaders |
|
| 30 | - * @var array $_autoloaders |
|
| 31 | - * @access private |
|
| 32 | - */ |
|
| 33 | - private static $_autoloaders; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * set to "paths" to display autoloader class => path mappings |
|
| 37 | - * set to "times" to display autoloader loading times |
|
| 38 | - * set to "all" to display both |
|
| 39 | - * |
|
| 40 | - * @var string $debug |
|
| 41 | - * @access private |
|
| 42 | - */ |
|
| 43 | - public static $debug = false; |
|
| 44 | - |
|
| 45 | - |
|
| 46 | - /** |
|
| 47 | - * class constructor |
|
| 48 | - * |
|
| 49 | - * @access private |
|
| 50 | - * @throws EE_Error |
|
| 51 | - */ |
|
| 52 | - private function __construct() |
|
| 53 | - { |
|
| 54 | - if (EEH_Autoloader::$_autoloaders === null) { |
|
| 55 | - EEH_Autoloader::$_autoloaders = array(); |
|
| 56 | - $this->_register_custom_autoloaders(); |
|
| 57 | - spl_autoload_register(array( $this, 'espresso_autoloader' )); |
|
| 58 | - } |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * @access public |
|
| 65 | - * @return EEH_Autoloader |
|
| 66 | - */ |
|
| 67 | - public static function instance() |
|
| 68 | - { |
|
| 69 | - // check if class object is instantiated |
|
| 70 | - if (! EEH_Autoloader::$_instance instanceof EEH_Autoloader) { |
|
| 71 | - EEH_Autoloader::$_instance = new EEH_Autoloader(); |
|
| 72 | - } |
|
| 73 | - return EEH_Autoloader::$_instance; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - /** |
|
| 79 | - * espresso_autoloader |
|
| 80 | - * |
|
| 81 | - * @access public |
|
| 82 | - * @param $class_name |
|
| 83 | - * @internal param $className |
|
| 84 | - * @internal param string $class_name - simple class name ie: session |
|
| 85 | - * @return void |
|
| 86 | - */ |
|
| 87 | - public static function espresso_autoloader($class_name) |
|
| 88 | - { |
|
| 89 | - if (isset(EEH_Autoloader::$_autoloaders[ $class_name ])) { |
|
| 90 | - require_once(EEH_Autoloader::$_autoloaders[ $class_name ]); |
|
| 91 | - } |
|
| 92 | - } |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - |
|
| 96 | - /** |
|
| 97 | - * register_autoloader |
|
| 98 | - * |
|
| 99 | - * @access public |
|
| 100 | - * @param array | string $class_paths - array of key => value pairings between class names and paths |
|
| 101 | - * @param bool $read_check true if we need to check whether the file is readable or not. |
|
| 102 | - * @param bool $debug **deprecated** |
|
| 103 | - * @throws EE_Error |
|
| 104 | - */ |
|
| 105 | - public static function register_autoloader($class_paths, $read_check = true, $debug = false) |
|
| 106 | - { |
|
| 107 | - $class_paths = is_array($class_paths) ? $class_paths : array( $class_paths ); |
|
| 108 | - foreach ($class_paths as $class => $path) { |
|
| 109 | - // skip all files that are not PHP |
|
| 110 | - if (substr($path, strlen($path) - 3) !== 'php') { |
|
| 111 | - continue; |
|
| 112 | - } |
|
| 113 | - // don't give up! you gotta... |
|
| 114 | - // get some class |
|
| 115 | - if (empty($class)) { |
|
| 116 | - throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
| 117 | - } |
|
| 118 | - // one day you will find the path young grasshopper |
|
| 119 | - if (empty($path)) { |
|
| 120 | - throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
| 121 | - } |
|
| 122 | - // is file readable ? |
|
| 123 | - if ($read_check && ! is_readable($path)) { |
|
| 124 | - throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
| 125 | - } |
|
| 126 | - if (! isset(EEH_Autoloader::$_autoloaders[ $class ])) { |
|
| 127 | - EEH_Autoloader::$_autoloaders[ $class ] = str_replace(array( '/', '\\' ), '/', $path); |
|
| 128 | - if (EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug )) { |
|
| 129 | - EEH_Debug_Tools::printr(EEH_Autoloader::$_autoloaders[ $class ], $class, __FILE__, __LINE__); |
|
| 130 | - } |
|
| 131 | - } |
|
| 132 | - } |
|
| 133 | - } |
|
| 134 | - |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - |
|
| 138 | - /** |
|
| 139 | - * get_autoloaders |
|
| 140 | - * |
|
| 141 | - * @access public |
|
| 142 | - * @return array |
|
| 143 | - */ |
|
| 144 | - public static function get_autoloaders() |
|
| 145 | - { |
|
| 146 | - return EEH_Autoloader::$_autoloaders; |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - |
|
| 150 | - /** |
|
| 151 | - * register core, model and class 'autoloaders' |
|
| 152 | - * |
|
| 153 | - * @access private |
|
| 154 | - * @return void |
|
| 155 | - * @throws EE_Error |
|
| 156 | - */ |
|
| 157 | - private function _register_custom_autoloaders() |
|
| 158 | - { |
|
| 159 | - EEH_Autoloader::$debug = ''; |
|
| 160 | - EEH_Autoloader::register_helpers_autoloaders(); |
|
| 161 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces'); |
|
| 162 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
| 163 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
| 164 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
| 165 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
| 166 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
| 167 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'messages'); |
|
| 168 | - if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 169 | - Benchmark::displayResults(); |
|
| 170 | - } |
|
| 171 | - } |
|
| 172 | - |
|
| 173 | - |
|
| 174 | - /** |
|
| 175 | - * register core, model and class 'autoloaders' |
|
| 176 | - * |
|
| 177 | - * @access public |
|
| 178 | - * @throws EE_Error |
|
| 179 | - */ |
|
| 180 | - public static function register_helpers_autoloaders() |
|
| 181 | - { |
|
| 182 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
| 183 | - } |
|
| 184 | - |
|
| 185 | - |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * register core, model and class 'autoloaders' |
|
| 190 | - * |
|
| 191 | - * @access public |
|
| 192 | - * @return void |
|
| 193 | - */ |
|
| 194 | - public static function register_form_sections_autoloaders() |
|
| 195 | - { |
|
| 196 | - // EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
| 197 | - } |
|
| 198 | - |
|
| 199 | - |
|
| 200 | - /** |
|
| 201 | - * register core, model and class 'autoloaders' |
|
| 202 | - * |
|
| 203 | - * @access public |
|
| 204 | - * @return void |
|
| 205 | - * @throws EE_Error |
|
| 206 | - */ |
|
| 207 | - public static function register_line_item_display_autoloaders() |
|
| 208 | - { |
|
| 209 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_display', true); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * register core, model and class 'autoloaders' |
|
| 215 | - * |
|
| 216 | - * @access public |
|
| 217 | - * @return void |
|
| 218 | - * @throws EE_Error |
|
| 219 | - */ |
|
| 220 | - public static function register_line_item_filter_autoloaders() |
|
| 221 | - { |
|
| 222 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_filters', true); |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - |
|
| 226 | - /** |
|
| 227 | - * register template part 'autoloaders' |
|
| 228 | - * |
|
| 229 | - * @access public |
|
| 230 | - * @return void |
|
| 231 | - * @throws EE_Error |
|
| 232 | - */ |
|
| 233 | - public static function register_template_part_autoloaders() |
|
| 234 | - { |
|
| 235 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'template_parts', true); |
|
| 236 | - } |
|
| 237 | - |
|
| 238 | - |
|
| 239 | - /** |
|
| 240 | - * @return void |
|
| 241 | - * @throws EE_Error |
|
| 242 | - */ |
|
| 243 | - public static function register_business_classes() |
|
| 244 | - { |
|
| 245 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'business'); |
|
| 246 | - } |
|
| 247 | - |
|
| 248 | - |
|
| 249 | - |
|
| 250 | - /** |
|
| 251 | - * Assumes all the files in this folder have the normal naming scheme (namely that their classname |
|
| 252 | - * is the file's name, plus ".whatever.php".) and adds each of them to the autoloader list. |
|
| 253 | - * If that's not the case, you'll need to improve this function or just use EEH_File::get_classname_from_filepath_with_standard_filename() directly. |
|
| 254 | - * Yes this has to scan the directory for files, but it only does it once -- not on EACH |
|
| 255 | - * time the autoloader is used |
|
| 256 | - * |
|
| 257 | - * @param string $folder name, with or without trailing /, doesn't matter |
|
| 258 | - * @param bool $recursive |
|
| 259 | - * @param bool $debug **deprecated** |
|
| 260 | - * @throws EE_Error |
|
| 261 | - */ |
|
| 262 | - public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) |
|
| 263 | - { |
|
| 264 | - if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug) { |
|
| 265 | - Benchmark::startTimer(basename($folder)); |
|
| 266 | - } |
|
| 267 | - // make sure last char is a / |
|
| 268 | - $folder .= $folder[ strlen($folder)-1 ] !== '/' ? '/' : ''; |
|
| 269 | - $class_to_filepath_map = array(); |
|
| 270 | - $exclude = array( 'index' ); |
|
| 271 | - // get all the files in that folder that end in php |
|
| 272 | - $filepaths = glob($folder.'*'); |
|
| 273 | - |
|
| 274 | - if (empty($filepaths)) { |
|
| 275 | - return; |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - foreach ($filepaths as $filepath) { |
|
| 279 | - if (substr($filepath, -4, 4) === '.php') { |
|
| 280 | - $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
| 281 | - if (! in_array($class_name, $exclude)) { |
|
| 282 | - $class_to_filepath_map [ $class_name ] = $filepath; |
|
| 283 | - } |
|
| 284 | - } elseif ($recursive) { |
|
| 285 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug); |
|
| 286 | - } |
|
| 287 | - } |
|
| 288 | - // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
|
| 289 | - EEH_Autoloader::register_autoloader($class_to_filepath_map, false, $debug); |
|
| 290 | - if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 291 | - Benchmark::stopTimer(basename($folder)); |
|
| 292 | - } |
|
| 293 | - } |
|
| 294 | - |
|
| 295 | - |
|
| 296 | - |
|
| 297 | - /** |
|
| 298 | - * add_alias |
|
| 299 | - * register additional autoloader based on variation of the classname for an existing autoloader |
|
| 300 | - * |
|
| 301 | - * @access public |
|
| 302 | - * @param string $class_name - simple class name ie: EE_Session |
|
| 303 | - * @param string $alias - variation on class name ie: EE_session, session, etc |
|
| 304 | - */ |
|
| 305 | - public static function add_alias($class_name, $alias) |
|
| 306 | - { |
|
| 307 | - if (isset(EEH_Autoloader::$_autoloaders[ $class_name ])) { |
|
| 308 | - EEH_Autoloader::$_autoloaders[ $alias ] = EEH_Autoloader::$_autoloaders[ $class_name ]; |
|
| 309 | - } |
|
| 310 | - } |
|
| 20 | + /** |
|
| 21 | + * instance of the EE_System object |
|
| 22 | + * |
|
| 23 | + * @var $_instance |
|
| 24 | + * @access private |
|
| 25 | + */ |
|
| 26 | + private static $_instance = null; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * $_autoloaders |
|
| 30 | + * @var array $_autoloaders |
|
| 31 | + * @access private |
|
| 32 | + */ |
|
| 33 | + private static $_autoloaders; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * set to "paths" to display autoloader class => path mappings |
|
| 37 | + * set to "times" to display autoloader loading times |
|
| 38 | + * set to "all" to display both |
|
| 39 | + * |
|
| 40 | + * @var string $debug |
|
| 41 | + * @access private |
|
| 42 | + */ |
|
| 43 | + public static $debug = false; |
|
| 44 | + |
|
| 45 | + |
|
| 46 | + /** |
|
| 47 | + * class constructor |
|
| 48 | + * |
|
| 49 | + * @access private |
|
| 50 | + * @throws EE_Error |
|
| 51 | + */ |
|
| 52 | + private function __construct() |
|
| 53 | + { |
|
| 54 | + if (EEH_Autoloader::$_autoloaders === null) { |
|
| 55 | + EEH_Autoloader::$_autoloaders = array(); |
|
| 56 | + $this->_register_custom_autoloaders(); |
|
| 57 | + spl_autoload_register(array( $this, 'espresso_autoloader' )); |
|
| 58 | + } |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * @access public |
|
| 65 | + * @return EEH_Autoloader |
|
| 66 | + */ |
|
| 67 | + public static function instance() |
|
| 68 | + { |
|
| 69 | + // check if class object is instantiated |
|
| 70 | + if (! EEH_Autoloader::$_instance instanceof EEH_Autoloader) { |
|
| 71 | + EEH_Autoloader::$_instance = new EEH_Autoloader(); |
|
| 72 | + } |
|
| 73 | + return EEH_Autoloader::$_instance; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + /** |
|
| 79 | + * espresso_autoloader |
|
| 80 | + * |
|
| 81 | + * @access public |
|
| 82 | + * @param $class_name |
|
| 83 | + * @internal param $className |
|
| 84 | + * @internal param string $class_name - simple class name ie: session |
|
| 85 | + * @return void |
|
| 86 | + */ |
|
| 87 | + public static function espresso_autoloader($class_name) |
|
| 88 | + { |
|
| 89 | + if (isset(EEH_Autoloader::$_autoloaders[ $class_name ])) { |
|
| 90 | + require_once(EEH_Autoloader::$_autoloaders[ $class_name ]); |
|
| 91 | + } |
|
| 92 | + } |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + |
|
| 96 | + /** |
|
| 97 | + * register_autoloader |
|
| 98 | + * |
|
| 99 | + * @access public |
|
| 100 | + * @param array | string $class_paths - array of key => value pairings between class names and paths |
|
| 101 | + * @param bool $read_check true if we need to check whether the file is readable or not. |
|
| 102 | + * @param bool $debug **deprecated** |
|
| 103 | + * @throws EE_Error |
|
| 104 | + */ |
|
| 105 | + public static function register_autoloader($class_paths, $read_check = true, $debug = false) |
|
| 106 | + { |
|
| 107 | + $class_paths = is_array($class_paths) ? $class_paths : array( $class_paths ); |
|
| 108 | + foreach ($class_paths as $class => $path) { |
|
| 109 | + // skip all files that are not PHP |
|
| 110 | + if (substr($path, strlen($path) - 3) !== 'php') { |
|
| 111 | + continue; |
|
| 112 | + } |
|
| 113 | + // don't give up! you gotta... |
|
| 114 | + // get some class |
|
| 115 | + if (empty($class)) { |
|
| 116 | + throw new EE_Error(sprintf(__('No Class name was specified while registering an autoloader for the following path: %s.', 'event_espresso'), $path)); |
|
| 117 | + } |
|
| 118 | + // one day you will find the path young grasshopper |
|
| 119 | + if (empty($path)) { |
|
| 120 | + throw new EE_Error(sprintf(__('No path was specified while registering an autoloader for the %s class.', 'event_espresso'), $class)); |
|
| 121 | + } |
|
| 122 | + // is file readable ? |
|
| 123 | + if ($read_check && ! is_readable($path)) { |
|
| 124 | + throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
|
| 125 | + } |
|
| 126 | + if (! isset(EEH_Autoloader::$_autoloaders[ $class ])) { |
|
| 127 | + EEH_Autoloader::$_autoloaders[ $class ] = str_replace(array( '/', '\\' ), '/', $path); |
|
| 128 | + if (EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug )) { |
|
| 129 | + EEH_Debug_Tools::printr(EEH_Autoloader::$_autoloaders[ $class ], $class, __FILE__, __LINE__); |
|
| 130 | + } |
|
| 131 | + } |
|
| 132 | + } |
|
| 133 | + } |
|
| 134 | + |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + |
|
| 138 | + /** |
|
| 139 | + * get_autoloaders |
|
| 140 | + * |
|
| 141 | + * @access public |
|
| 142 | + * @return array |
|
| 143 | + */ |
|
| 144 | + public static function get_autoloaders() |
|
| 145 | + { |
|
| 146 | + return EEH_Autoloader::$_autoloaders; |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + |
|
| 150 | + /** |
|
| 151 | + * register core, model and class 'autoloaders' |
|
| 152 | + * |
|
| 153 | + * @access private |
|
| 154 | + * @return void |
|
| 155 | + * @throws EE_Error |
|
| 156 | + */ |
|
| 157 | + private function _register_custom_autoloaders() |
|
| 158 | + { |
|
| 159 | + EEH_Autoloader::$debug = ''; |
|
| 160 | + EEH_Autoloader::register_helpers_autoloaders(); |
|
| 161 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces'); |
|
| 162 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
|
| 163 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
|
| 164 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
|
| 165 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
|
| 166 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
|
| 167 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'messages'); |
|
| 168 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 169 | + Benchmark::displayResults(); |
|
| 170 | + } |
|
| 171 | + } |
|
| 172 | + |
|
| 173 | + |
|
| 174 | + /** |
|
| 175 | + * register core, model and class 'autoloaders' |
|
| 176 | + * |
|
| 177 | + * @access public |
|
| 178 | + * @throws EE_Error |
|
| 179 | + */ |
|
| 180 | + public static function register_helpers_autoloaders() |
|
| 181 | + { |
|
| 182 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_HELPERS); |
|
| 183 | + } |
|
| 184 | + |
|
| 185 | + |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * register core, model and class 'autoloaders' |
|
| 190 | + * |
|
| 191 | + * @access public |
|
| 192 | + * @return void |
|
| 193 | + */ |
|
| 194 | + public static function register_form_sections_autoloaders() |
|
| 195 | + { |
|
| 196 | + // EEH_Autoloader::register_autoloaders_for_each_file_in_folder( EE_FORM_SECTIONS, true ); |
|
| 197 | + } |
|
| 198 | + |
|
| 199 | + |
|
| 200 | + /** |
|
| 201 | + * register core, model and class 'autoloaders' |
|
| 202 | + * |
|
| 203 | + * @access public |
|
| 204 | + * @return void |
|
| 205 | + * @throws EE_Error |
|
| 206 | + */ |
|
| 207 | + public static function register_line_item_display_autoloaders() |
|
| 208 | + { |
|
| 209 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_display', true); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * register core, model and class 'autoloaders' |
|
| 215 | + * |
|
| 216 | + * @access public |
|
| 217 | + * @return void |
|
| 218 | + * @throws EE_Error |
|
| 219 | + */ |
|
| 220 | + public static function register_line_item_filter_autoloaders() |
|
| 221 | + { |
|
| 222 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_filters', true); |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + |
|
| 226 | + /** |
|
| 227 | + * register template part 'autoloaders' |
|
| 228 | + * |
|
| 229 | + * @access public |
|
| 230 | + * @return void |
|
| 231 | + * @throws EE_Error |
|
| 232 | + */ |
|
| 233 | + public static function register_template_part_autoloaders() |
|
| 234 | + { |
|
| 235 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'template_parts', true); |
|
| 236 | + } |
|
| 237 | + |
|
| 238 | + |
|
| 239 | + /** |
|
| 240 | + * @return void |
|
| 241 | + * @throws EE_Error |
|
| 242 | + */ |
|
| 243 | + public static function register_business_classes() |
|
| 244 | + { |
|
| 245 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'business'); |
|
| 246 | + } |
|
| 247 | + |
|
| 248 | + |
|
| 249 | + |
|
| 250 | + /** |
|
| 251 | + * Assumes all the files in this folder have the normal naming scheme (namely that their classname |
|
| 252 | + * is the file's name, plus ".whatever.php".) and adds each of them to the autoloader list. |
|
| 253 | + * If that's not the case, you'll need to improve this function or just use EEH_File::get_classname_from_filepath_with_standard_filename() directly. |
|
| 254 | + * Yes this has to scan the directory for files, but it only does it once -- not on EACH |
|
| 255 | + * time the autoloader is used |
|
| 256 | + * |
|
| 257 | + * @param string $folder name, with or without trailing /, doesn't matter |
|
| 258 | + * @param bool $recursive |
|
| 259 | + * @param bool $debug **deprecated** |
|
| 260 | + * @throws EE_Error |
|
| 261 | + */ |
|
| 262 | + public static function register_autoloaders_for_each_file_in_folder($folder, $recursive = false, $debug = false) |
|
| 263 | + { |
|
| 264 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all' || $debug) { |
|
| 265 | + Benchmark::startTimer(basename($folder)); |
|
| 266 | + } |
|
| 267 | + // make sure last char is a / |
|
| 268 | + $folder .= $folder[ strlen($folder)-1 ] !== '/' ? '/' : ''; |
|
| 269 | + $class_to_filepath_map = array(); |
|
| 270 | + $exclude = array( 'index' ); |
|
| 271 | + // get all the files in that folder that end in php |
|
| 272 | + $filepaths = glob($folder.'*'); |
|
| 273 | + |
|
| 274 | + if (empty($filepaths)) { |
|
| 275 | + return; |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + foreach ($filepaths as $filepath) { |
|
| 279 | + if (substr($filepath, -4, 4) === '.php') { |
|
| 280 | + $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
|
| 281 | + if (! in_array($class_name, $exclude)) { |
|
| 282 | + $class_to_filepath_map [ $class_name ] = $filepath; |
|
| 283 | + } |
|
| 284 | + } elseif ($recursive) { |
|
| 285 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug); |
|
| 286 | + } |
|
| 287 | + } |
|
| 288 | + // we remove the necessity to do a is_readable() check via the $read_check flag because glob by nature will not return non_readable files/directories. |
|
| 289 | + EEH_Autoloader::register_autoloader($class_to_filepath_map, false, $debug); |
|
| 290 | + if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
|
| 291 | + Benchmark::stopTimer(basename($folder)); |
|
| 292 | + } |
|
| 293 | + } |
|
| 294 | + |
|
| 295 | + |
|
| 296 | + |
|
| 297 | + /** |
|
| 298 | + * add_alias |
|
| 299 | + * register additional autoloader based on variation of the classname for an existing autoloader |
|
| 300 | + * |
|
| 301 | + * @access public |
|
| 302 | + * @param string $class_name - simple class name ie: EE_Session |
|
| 303 | + * @param string $alias - variation on class name ie: EE_session, session, etc |
|
| 304 | + */ |
|
| 305 | + public static function add_alias($class_name, $alias) |
|
| 306 | + { |
|
| 307 | + if (isset(EEH_Autoloader::$_autoloaders[ $class_name ])) { |
|
| 308 | + EEH_Autoloader::$_autoloaders[ $alias ] = EEH_Autoloader::$_autoloaders[ $class_name ]; |
|
| 309 | + } |
|
| 310 | + } |
|
| 311 | 311 | } |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | if (EEH_Autoloader::$_autoloaders === null) { |
| 55 | 55 | EEH_Autoloader::$_autoloaders = array(); |
| 56 | 56 | $this->_register_custom_autoloaders(); |
| 57 | - spl_autoload_register(array( $this, 'espresso_autoloader' )); |
|
| 57 | + spl_autoload_register(array($this, 'espresso_autoloader')); |
|
| 58 | 58 | } |
| 59 | 59 | } |
| 60 | 60 | |
@@ -67,7 +67,7 @@ discard block |
||
| 67 | 67 | public static function instance() |
| 68 | 68 | { |
| 69 | 69 | // check if class object is instantiated |
| 70 | - if (! EEH_Autoloader::$_instance instanceof EEH_Autoloader) { |
|
| 70 | + if ( ! EEH_Autoloader::$_instance instanceof EEH_Autoloader) { |
|
| 71 | 71 | EEH_Autoloader::$_instance = new EEH_Autoloader(); |
| 72 | 72 | } |
| 73 | 73 | return EEH_Autoloader::$_instance; |
@@ -86,8 +86,8 @@ discard block |
||
| 86 | 86 | */ |
| 87 | 87 | public static function espresso_autoloader($class_name) |
| 88 | 88 | { |
| 89 | - if (isset(EEH_Autoloader::$_autoloaders[ $class_name ])) { |
|
| 90 | - require_once(EEH_Autoloader::$_autoloaders[ $class_name ]); |
|
| 89 | + if (isset(EEH_Autoloader::$_autoloaders[$class_name])) { |
|
| 90 | + require_once(EEH_Autoloader::$_autoloaders[$class_name]); |
|
| 91 | 91 | } |
| 92 | 92 | } |
| 93 | 93 | |
@@ -104,7 +104,7 @@ discard block |
||
| 104 | 104 | */ |
| 105 | 105 | public static function register_autoloader($class_paths, $read_check = true, $debug = false) |
| 106 | 106 | { |
| 107 | - $class_paths = is_array($class_paths) ? $class_paths : array( $class_paths ); |
|
| 107 | + $class_paths = is_array($class_paths) ? $class_paths : array($class_paths); |
|
| 108 | 108 | foreach ($class_paths as $class => $path) { |
| 109 | 109 | // skip all files that are not PHP |
| 110 | 110 | if (substr($path, strlen($path) - 3) !== 'php') { |
@@ -123,10 +123,10 @@ discard block |
||
| 123 | 123 | if ($read_check && ! is_readable($path)) { |
| 124 | 124 | throw new EE_Error(sprintf(__('The file for the %s class could not be found or is not readable due to file permissions. Please ensure the following path is correct: %s', 'event_espresso'), $class, $path)); |
| 125 | 125 | } |
| 126 | - if (! isset(EEH_Autoloader::$_autoloaders[ $class ])) { |
|
| 127 | - EEH_Autoloader::$_autoloaders[ $class ] = str_replace(array( '/', '\\' ), '/', $path); |
|
| 128 | - if (EE_DEBUG && ( EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug )) { |
|
| 129 | - EEH_Debug_Tools::printr(EEH_Autoloader::$_autoloaders[ $class ], $class, __FILE__, __LINE__); |
|
| 126 | + if ( ! isset(EEH_Autoloader::$_autoloaders[$class])) { |
|
| 127 | + EEH_Autoloader::$_autoloaders[$class] = str_replace(array('/', '\\'), '/', $path); |
|
| 128 | + if (EE_DEBUG && (EEH_Autoloader::$debug === 'paths' || EEH_Autoloader::$debug === 'all' || $debug)) { |
|
| 129 | + EEH_Debug_Tools::printr(EEH_Autoloader::$_autoloaders[$class], $class, __FILE__, __LINE__); |
|
| 130 | 130 | } |
| 131 | 131 | } |
| 132 | 132 | } |
@@ -158,13 +158,13 @@ discard block |
||
| 158 | 158 | { |
| 159 | 159 | EEH_Autoloader::$debug = ''; |
| 160 | 160 | EEH_Autoloader::register_helpers_autoloaders(); |
| 161 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'interfaces'); |
|
| 161 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'interfaces'); |
|
| 162 | 162 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE); |
| 163 | 163 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_INTERFACES, true); |
| 164 | 164 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_MODELS, true); |
| 165 | 165 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CLASSES); |
| 166 | 166 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_FORM_SECTIONS, true); |
| 167 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'messages'); |
|
| 167 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'messages'); |
|
| 168 | 168 | if (EEH_Autoloader::$debug === 'times' || EEH_Autoloader::$debug === 'all') { |
| 169 | 169 | Benchmark::displayResults(); |
| 170 | 170 | } |
@@ -206,7 +206,7 @@ discard block |
||
| 206 | 206 | */ |
| 207 | 207 | public static function register_line_item_display_autoloaders() |
| 208 | 208 | { |
| 209 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_display', true); |
|
| 209 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_display', true); |
|
| 210 | 210 | } |
| 211 | 211 | |
| 212 | 212 | |
@@ -219,7 +219,7 @@ discard block |
||
| 219 | 219 | */ |
| 220 | 220 | public static function register_line_item_filter_autoloaders() |
| 221 | 221 | { |
| 222 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'line_item_filters', true); |
|
| 222 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'line_item_filters', true); |
|
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | */ |
| 233 | 233 | public static function register_template_part_autoloaders() |
| 234 | 234 | { |
| 235 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'template_parts', true); |
|
| 235 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'template_parts', true); |
|
| 236 | 236 | } |
| 237 | 237 | |
| 238 | 238 | |
@@ -242,7 +242,7 @@ discard block |
||
| 242 | 242 | */ |
| 243 | 243 | public static function register_business_classes() |
| 244 | 244 | { |
| 245 | - EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE . 'business'); |
|
| 245 | + EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_CORE.'business'); |
|
| 246 | 246 | } |
| 247 | 247 | |
| 248 | 248 | |
@@ -265,9 +265,9 @@ discard block |
||
| 265 | 265 | Benchmark::startTimer(basename($folder)); |
| 266 | 266 | } |
| 267 | 267 | // make sure last char is a / |
| 268 | - $folder .= $folder[ strlen($folder)-1 ] !== '/' ? '/' : ''; |
|
| 268 | + $folder .= $folder[strlen($folder) - 1] !== '/' ? '/' : ''; |
|
| 269 | 269 | $class_to_filepath_map = array(); |
| 270 | - $exclude = array( 'index' ); |
|
| 270 | + $exclude = array('index'); |
|
| 271 | 271 | // get all the files in that folder that end in php |
| 272 | 272 | $filepaths = glob($folder.'*'); |
| 273 | 273 | |
@@ -278,8 +278,8 @@ discard block |
||
| 278 | 278 | foreach ($filepaths as $filepath) { |
| 279 | 279 | if (substr($filepath, -4, 4) === '.php') { |
| 280 | 280 | $class_name = EEH_File::get_classname_from_filepath_with_standard_filename($filepath); |
| 281 | - if (! in_array($class_name, $exclude)) { |
|
| 282 | - $class_to_filepath_map [ $class_name ] = $filepath; |
|
| 281 | + if ( ! in_array($class_name, $exclude)) { |
|
| 282 | + $class_to_filepath_map [$class_name] = $filepath; |
|
| 283 | 283 | } |
| 284 | 284 | } elseif ($recursive) { |
| 285 | 285 | EEH_Autoloader::register_autoloaders_for_each_file_in_folder($filepath, $recursive, $debug); |
@@ -304,8 +304,8 @@ discard block |
||
| 304 | 304 | */ |
| 305 | 305 | public static function add_alias($class_name, $alias) |
| 306 | 306 | { |
| 307 | - if (isset(EEH_Autoloader::$_autoloaders[ $class_name ])) { |
|
| 308 | - EEH_Autoloader::$_autoloaders[ $alias ] = EEH_Autoloader::$_autoloaders[ $class_name ]; |
|
| 307 | + if (isset(EEH_Autoloader::$_autoloaders[$class_name])) { |
|
| 308 | + EEH_Autoloader::$_autoloaders[$alias] = EEH_Autoloader::$_autoloaders[$class_name]; |
|
| 309 | 309 | } |
| 310 | 310 | } |
| 311 | 311 | } |
@@ -69,7 +69,7 @@ discard block |
||
| 69 | 69 | public function handleAssetManagerRequest() |
| 70 | 70 | { |
| 71 | 71 | try { |
| 72 | - if (! $this->request->isAdmin() |
|
| 72 | + if ( ! $this->request->isAdmin() |
|
| 73 | 73 | && ! $this->request->isFrontend() |
| 74 | 74 | && ! $this->request->isIframe() |
| 75 | 75 | && ! $this->request->isWordPressApi() |
@@ -129,7 +129,7 @@ discard block |
||
| 129 | 129 | private function handleAdminRequest() |
| 130 | 130 | { |
| 131 | 131 | try { |
| 132 | - if (! $this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
| 132 | + if ( ! $this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
| 133 | 133 | return; |
| 134 | 134 | } |
| 135 | 135 | do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
@@ -193,11 +193,11 @@ discard block |
||
| 193 | 193 | public function handleGQLRequest() |
| 194 | 194 | { |
| 195 | 195 | try { |
| 196 | - if (! $this->isGQLRequest()) { |
|
| 196 | + if ( ! $this->isGQLRequest()) { |
|
| 197 | 197 | return; |
| 198 | 198 | } |
| 199 | - if (! class_exists('WPGraphQL')) { |
|
| 200 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 199 | + if ( ! class_exists('WPGraphQL')) { |
|
| 200 | + require_once EE_THIRD_PARTY.'wp-graphql/wp-graphql.php'; |
|
| 201 | 201 | } |
| 202 | 202 | // load handler for EE GraphQL requests |
| 203 | 203 | $graphQL_manager = $this->loader->getShared( |
@@ -218,7 +218,7 @@ discard block |
||
| 218 | 218 | { |
| 219 | 219 | try { |
| 220 | 220 | // don't load frontend if M-Mode is active or request is not browser HTTP |
| 221 | - if (! $this->request->isAdmin() |
|
| 221 | + if ( ! $this->request->isAdmin() |
|
| 222 | 222 | || ! $this->request->isAjax() |
| 223 | 223 | || ! $this->maintenance_mode->models_can_query() |
| 224 | 224 | ) { |
@@ -257,7 +257,7 @@ discard block |
||
| 257 | 257 | public function handleSessionRequest() |
| 258 | 258 | { |
| 259 | 259 | try { |
| 260 | - if (! $this->request->isAdmin() && ! $this->request->isEeAjax() && ! $this->request->isFrontend()) { |
|
| 260 | + if ( ! $this->request->isAdmin() && ! $this->request->isEeAjax() && ! $this->request->isFrontend()) { |
|
| 261 | 261 | return; |
| 262 | 262 | } |
| 263 | 263 | $this->loader->getShared('EE_Session'); |
@@ -274,7 +274,7 @@ discard block |
||
| 274 | 274 | public function handleShortcodesRequest() |
| 275 | 275 | { |
| 276 | 276 | try { |
| 277 | - if (! $this->request->isFrontend() && ! $this->request->isIframe() && ! $this->request->isAjax()) { |
|
| 277 | + if ( ! $this->request->isFrontend() && ! $this->request->isIframe() && ! $this->request->isAjax()) { |
|
| 278 | 278 | return; |
| 279 | 279 | } |
| 280 | 280 | // load, register, and add shortcodes the new way |
@@ -298,7 +298,7 @@ discard block |
||
| 298 | 298 | public function handleWordPressHeartbeatRequest() |
| 299 | 299 | { |
| 300 | 300 | try { |
| 301 | - if (! $this->request->isWordPressHeartbeat()) { |
|
| 301 | + if ( ! $this->request->isWordPressHeartbeat()) { |
|
| 302 | 302 | return; |
| 303 | 303 | } |
| 304 | 304 | $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
@@ -315,7 +315,7 @@ discard block |
||
| 315 | 315 | public function handleWordPressPluginsPage() |
| 316 | 316 | { |
| 317 | 317 | try { |
| 318 | - if (! $this->request->isAdmin() |
|
| 318 | + if ( ! $this->request->isAdmin() |
|
| 319 | 319 | || ! $this->route_manager->routeMatchesCurrentRequest( |
| 320 | 320 | 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPluginsPage' |
| 321 | 321 | ) |
@@ -21,319 +21,319 @@ |
||
| 21 | 21 | class RouteHandler |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * @var LoaderInterface |
|
| 26 | - */ |
|
| 27 | - private $loader; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * @var EE_Maintenance_Mode $maintenance_mode |
|
| 31 | - */ |
|
| 32 | - private $maintenance_mode; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * @var RequestInterface $request |
|
| 36 | - */ |
|
| 37 | - private $request; |
|
| 38 | - |
|
| 39 | - /** |
|
| 40 | - * @var RouteMatchSpecificationManager $route_manager |
|
| 41 | - */ |
|
| 42 | - private $route_manager; |
|
| 43 | - |
|
| 44 | - /** |
|
| 45 | - * AdminRouter constructor. |
|
| 46 | - * |
|
| 47 | - * @param LoaderInterface $loader |
|
| 48 | - * @param EE_Maintenance_Mode $maintenance_mode |
|
| 49 | - * @param RequestInterface $request |
|
| 50 | - * @param RouteMatchSpecificationManager $route_manager |
|
| 51 | - */ |
|
| 52 | - public function __construct( |
|
| 53 | - LoaderInterface $loader, |
|
| 54 | - EE_Maintenance_Mode $maintenance_mode, |
|
| 55 | - RequestInterface $request, |
|
| 56 | - RouteMatchSpecificationManager $route_manager |
|
| 57 | - ) { |
|
| 58 | - $this->loader = $loader; |
|
| 59 | - $this->maintenance_mode = $maintenance_mode; |
|
| 60 | - $this->request = $request; |
|
| 61 | - $this->route_manager = $route_manager; |
|
| 62 | - } |
|
| 63 | - |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * @throws Exception |
|
| 67 | - * @since $VID:$ |
|
| 68 | - */ |
|
| 69 | - public function handleAssetManagerRequest() |
|
| 70 | - { |
|
| 71 | - try { |
|
| 72 | - if (! $this->request->isAdmin() |
|
| 73 | - && ! $this->request->isFrontend() |
|
| 74 | - && ! $this->request->isIframe() |
|
| 75 | - && ! $this->request->isWordPressApi() |
|
| 76 | - ) { |
|
| 77 | - return; |
|
| 78 | - } |
|
| 79 | - $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 80 | - $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
| 81 | - if ($this->canLoadBlocks()) { |
|
| 82 | - $this->loader->getShared( |
|
| 83 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
| 84 | - ); |
|
| 85 | - } |
|
| 86 | - } catch (Exception $exception) { |
|
| 87 | - new ExceptionStackTraceDisplay($exception); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - /** |
|
| 93 | - * Return whether blocks can be registered/loaded or not. |
|
| 94 | - * |
|
| 95 | - * @return bool |
|
| 96 | - * @since $VID:$ |
|
| 97 | - */ |
|
| 98 | - private function canLoadBlocks() |
|
| 99 | - { |
|
| 100 | - return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
| 101 | - && function_exists('register_block_type') |
|
| 102 | - // don't load blocks if in the Divi page builder editor context |
|
| 103 | - // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
| 104 | - && ! $this->request->getRequestParam('et_fb', false); |
|
| 105 | - } |
|
| 106 | - |
|
| 107 | - |
|
| 108 | - /** |
|
| 109 | - * @throws Exception |
|
| 110 | - * @since $VID:$ |
|
| 111 | - */ |
|
| 112 | - public function handleControllerRequest() |
|
| 113 | - { |
|
| 114 | - try { |
|
| 115 | - $this->handleAdminRequest(); |
|
| 116 | - $this->handleFrontendRequest(); |
|
| 117 | - $this->handleWordPressHeartbeatRequest(); |
|
| 118 | - $this->handleWordPressPluginsPage(); |
|
| 119 | - } catch (Exception $exception) { |
|
| 120 | - new ExceptionStackTraceDisplay($exception); |
|
| 121 | - } |
|
| 122 | - } |
|
| 123 | - |
|
| 124 | - |
|
| 125 | - /** |
|
| 126 | - * @throws Exception |
|
| 127 | - * @since $VID:$ |
|
| 128 | - */ |
|
| 129 | - private function handleAdminRequest() |
|
| 130 | - { |
|
| 131 | - try { |
|
| 132 | - if (! $this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
| 133 | - return; |
|
| 134 | - } |
|
| 135 | - do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 136 | - $this->loader->getShared('EE_Admin'); |
|
| 137 | - |
|
| 138 | - EE_Dependency_Map::register_dependencies( |
|
| 139 | - 'EventEspresso\core\domain\services\assets\EspressoAdminAssetManager', |
|
| 140 | - [ |
|
| 141 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 142 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 143 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 144 | - ] |
|
| 145 | - ); |
|
| 146 | - $this->loader->getShared('EventEspresso\core\domain\services\assets\EspressoAdminAssetManager'); |
|
| 147 | - } catch (Exception $exception) { |
|
| 148 | - new ExceptionStackTraceDisplay($exception); |
|
| 149 | - } |
|
| 150 | - } |
|
| 151 | - |
|
| 152 | - |
|
| 153 | - /** |
|
| 154 | - * @throws Exception |
|
| 155 | - * @since $VID:$ |
|
| 156 | - */ |
|
| 157 | - private function handleFrontendRequest() |
|
| 158 | - { |
|
| 159 | - try { |
|
| 160 | - // don't load frontend if M-Mode is active or request is not browser HTTP |
|
| 161 | - if ($this->maintenance_mode->level() || ! $this->request->isFrontend() || ! $this->request->isFrontAjax()) { |
|
| 162 | - return; |
|
| 163 | - } |
|
| 164 | - do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 165 | - $this->loader->getShared('EE_Front_Controller'); |
|
| 166 | - } catch (Exception $exception) { |
|
| 167 | - new ExceptionStackTraceDisplay($exception); |
|
| 168 | - } |
|
| 169 | - } |
|
| 170 | - |
|
| 171 | - |
|
| 172 | - /** |
|
| 173 | - * @return bool |
|
| 174 | - * @since $VID:$ |
|
| 175 | - */ |
|
| 176 | - private function isGQLRequest() |
|
| 177 | - { |
|
| 178 | - return PHP_VERSION_ID > 70000 |
|
| 179 | - && ( |
|
| 180 | - $this->request->isGQL() |
|
| 181 | - || $this->request->isUnitTesting() |
|
| 182 | - || $this->route_manager->routeMatchesCurrentRequest( |
|
| 183 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoEventEditor' |
|
| 184 | - ) |
|
| 185 | - ); |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - |
|
| 189 | - /** |
|
| 190 | - * @throws Exception |
|
| 191 | - * @since $VID:$ |
|
| 192 | - */ |
|
| 193 | - public function handleGQLRequest() |
|
| 194 | - { |
|
| 195 | - try { |
|
| 196 | - if (! $this->isGQLRequest()) { |
|
| 197 | - return; |
|
| 198 | - } |
|
| 199 | - if (! class_exists('WPGraphQL')) { |
|
| 200 | - require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 201 | - } |
|
| 202 | - // load handler for EE GraphQL requests |
|
| 203 | - $graphQL_manager = $this->loader->getShared( |
|
| 204 | - 'EventEspresso\core\services\graphql\GraphQLManager' |
|
| 205 | - ); |
|
| 206 | - $graphQL_manager->init(); |
|
| 207 | - } catch (Exception $exception) { |
|
| 208 | - new ExceptionStackTraceDisplay($exception); |
|
| 209 | - } |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - |
|
| 213 | - /** |
|
| 214 | - * @throws Exception |
|
| 215 | - * @since $VID:$ |
|
| 216 | - */ |
|
| 217 | - public function handlePersonalDataRequest() |
|
| 218 | - { |
|
| 219 | - try { |
|
| 220 | - // don't load frontend if M-Mode is active or request is not browser HTTP |
|
| 221 | - if (! $this->request->isAdmin() |
|
| 222 | - || ! $this->request->isAjax() |
|
| 223 | - || ! $this->maintenance_mode->models_can_query() |
|
| 224 | - ) { |
|
| 225 | - return; |
|
| 226 | - } |
|
| 227 | - $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
| 228 | - $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
| 229 | - } catch (Exception $exception) { |
|
| 230 | - new ExceptionStackTraceDisplay($exception); |
|
| 231 | - } |
|
| 232 | - } |
|
| 233 | - |
|
| 234 | - |
|
| 235 | - /** |
|
| 236 | - * @throws Exception |
|
| 237 | - * @since $VID:$ |
|
| 238 | - */ |
|
| 239 | - public function handlePueRequest() |
|
| 240 | - { |
|
| 241 | - try { |
|
| 242 | - if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 243 | - // pew pew pew |
|
| 244 | - $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService'); |
|
| 245 | - do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 246 | - } |
|
| 247 | - } catch (Exception $exception) { |
|
| 248 | - new ExceptionStackTraceDisplay($exception); |
|
| 249 | - } |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - /** |
|
| 254 | - * @throws Exception |
|
| 255 | - * @since $VID:$ |
|
| 256 | - */ |
|
| 257 | - public function handleSessionRequest() |
|
| 258 | - { |
|
| 259 | - try { |
|
| 260 | - if (! $this->request->isAdmin() && ! $this->request->isEeAjax() && ! $this->request->isFrontend()) { |
|
| 261 | - return; |
|
| 262 | - } |
|
| 263 | - $this->loader->getShared('EE_Session'); |
|
| 264 | - } catch (Exception $exception) { |
|
| 265 | - new ExceptionStackTraceDisplay($exception); |
|
| 266 | - } |
|
| 267 | - } |
|
| 268 | - |
|
| 269 | - |
|
| 270 | - /** |
|
| 271 | - * @throws Exception |
|
| 272 | - * @since $VID:$ |
|
| 273 | - */ |
|
| 274 | - public function handleShortcodesRequest() |
|
| 275 | - { |
|
| 276 | - try { |
|
| 277 | - if (! $this->request->isFrontend() && ! $this->request->isIframe() && ! $this->request->isAjax()) { |
|
| 278 | - return; |
|
| 279 | - } |
|
| 280 | - // load, register, and add shortcodes the new way |
|
| 281 | - $this->loader->getShared( |
|
| 282 | - 'EventEspresso\core\services\shortcodes\ShortcodesManager', |
|
| 283 | - [ |
|
| 284 | - // and the old way, but we'll put it under control of the new system |
|
| 285 | - EE_Config::getLegacyShortcodesManager(), |
|
| 286 | - ] |
|
| 287 | - ); |
|
| 288 | - } catch (Exception $exception) { |
|
| 289 | - new ExceptionStackTraceDisplay($exception); |
|
| 290 | - } |
|
| 291 | - } |
|
| 292 | - |
|
| 293 | - |
|
| 294 | - /** |
|
| 295 | - * @throws Exception |
|
| 296 | - * @since $VID:$ |
|
| 297 | - */ |
|
| 298 | - public function handleWordPressHeartbeatRequest() |
|
| 299 | - { |
|
| 300 | - try { |
|
| 301 | - if (! $this->request->isWordPressHeartbeat()) { |
|
| 302 | - return; |
|
| 303 | - } |
|
| 304 | - $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
| 305 | - } catch (Exception $exception) { |
|
| 306 | - new ExceptionStackTraceDisplay($exception); |
|
| 307 | - } |
|
| 308 | - } |
|
| 309 | - |
|
| 310 | - |
|
| 311 | - /** |
|
| 312 | - * @throws Exception |
|
| 313 | - * @since $VID:$ |
|
| 314 | - */ |
|
| 315 | - public function handleWordPressPluginsPage() |
|
| 316 | - { |
|
| 317 | - try { |
|
| 318 | - if (! $this->request->isAdmin() |
|
| 319 | - || ! $this->route_manager->routeMatchesCurrentRequest( |
|
| 320 | - 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPluginsPage' |
|
| 321 | - ) |
|
| 322 | - ) { |
|
| 323 | - return; |
|
| 324 | - } |
|
| 325 | - EE_Dependency_Map::register_dependencies( |
|
| 326 | - 'EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager', |
|
| 327 | - [ |
|
| 328 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 329 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 330 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 331 | - 'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache, |
|
| 332 | - ] |
|
| 333 | - ); |
|
| 334 | - $this->loader->getShared('EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager'); |
|
| 335 | - } catch (Exception $exception) { |
|
| 336 | - new ExceptionStackTraceDisplay($exception); |
|
| 337 | - } |
|
| 338 | - } |
|
| 24 | + /** |
|
| 25 | + * @var LoaderInterface |
|
| 26 | + */ |
|
| 27 | + private $loader; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * @var EE_Maintenance_Mode $maintenance_mode |
|
| 31 | + */ |
|
| 32 | + private $maintenance_mode; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * @var RequestInterface $request |
|
| 36 | + */ |
|
| 37 | + private $request; |
|
| 38 | + |
|
| 39 | + /** |
|
| 40 | + * @var RouteMatchSpecificationManager $route_manager |
|
| 41 | + */ |
|
| 42 | + private $route_manager; |
|
| 43 | + |
|
| 44 | + /** |
|
| 45 | + * AdminRouter constructor. |
|
| 46 | + * |
|
| 47 | + * @param LoaderInterface $loader |
|
| 48 | + * @param EE_Maintenance_Mode $maintenance_mode |
|
| 49 | + * @param RequestInterface $request |
|
| 50 | + * @param RouteMatchSpecificationManager $route_manager |
|
| 51 | + */ |
|
| 52 | + public function __construct( |
|
| 53 | + LoaderInterface $loader, |
|
| 54 | + EE_Maintenance_Mode $maintenance_mode, |
|
| 55 | + RequestInterface $request, |
|
| 56 | + RouteMatchSpecificationManager $route_manager |
|
| 57 | + ) { |
|
| 58 | + $this->loader = $loader; |
|
| 59 | + $this->maintenance_mode = $maintenance_mode; |
|
| 60 | + $this->request = $request; |
|
| 61 | + $this->route_manager = $route_manager; |
|
| 62 | + } |
|
| 63 | + |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * @throws Exception |
|
| 67 | + * @since $VID:$ |
|
| 68 | + */ |
|
| 69 | + public function handleAssetManagerRequest() |
|
| 70 | + { |
|
| 71 | + try { |
|
| 72 | + if (! $this->request->isAdmin() |
|
| 73 | + && ! $this->request->isFrontend() |
|
| 74 | + && ! $this->request->isIframe() |
|
| 75 | + && ! $this->request->isWordPressApi() |
|
| 76 | + ) { |
|
| 77 | + return; |
|
| 78 | + } |
|
| 79 | + $this->loader->getShared('EventEspresso\core\services\assets\Registry'); |
|
| 80 | + $this->loader->getShared('EventEspresso\core\domain\services\assets\CoreAssetManager'); |
|
| 81 | + if ($this->canLoadBlocks()) { |
|
| 82 | + $this->loader->getShared( |
|
| 83 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' |
|
| 84 | + ); |
|
| 85 | + } |
|
| 86 | + } catch (Exception $exception) { |
|
| 87 | + new ExceptionStackTraceDisplay($exception); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + /** |
|
| 93 | + * Return whether blocks can be registered/loaded or not. |
|
| 94 | + * |
|
| 95 | + * @return bool |
|
| 96 | + * @since $VID:$ |
|
| 97 | + */ |
|
| 98 | + private function canLoadBlocks() |
|
| 99 | + { |
|
| 100 | + return apply_filters('FHEE__EE_System__canLoadBlocks', true) |
|
| 101 | + && function_exists('register_block_type') |
|
| 102 | + // don't load blocks if in the Divi page builder editor context |
|
| 103 | + // @see https://github.com/eventespresso/event-espresso-core/issues/814 |
|
| 104 | + && ! $this->request->getRequestParam('et_fb', false); |
|
| 105 | + } |
|
| 106 | + |
|
| 107 | + |
|
| 108 | + /** |
|
| 109 | + * @throws Exception |
|
| 110 | + * @since $VID:$ |
|
| 111 | + */ |
|
| 112 | + public function handleControllerRequest() |
|
| 113 | + { |
|
| 114 | + try { |
|
| 115 | + $this->handleAdminRequest(); |
|
| 116 | + $this->handleFrontendRequest(); |
|
| 117 | + $this->handleWordPressHeartbeatRequest(); |
|
| 118 | + $this->handleWordPressPluginsPage(); |
|
| 119 | + } catch (Exception $exception) { |
|
| 120 | + new ExceptionStackTraceDisplay($exception); |
|
| 121 | + } |
|
| 122 | + } |
|
| 123 | + |
|
| 124 | + |
|
| 125 | + /** |
|
| 126 | + * @throws Exception |
|
| 127 | + * @since $VID:$ |
|
| 128 | + */ |
|
| 129 | + private function handleAdminRequest() |
|
| 130 | + { |
|
| 131 | + try { |
|
| 132 | + if (! $this->request->isAdmin() || $this->request->isAdminAjax()) { |
|
| 133 | + return; |
|
| 134 | + } |
|
| 135 | + do_action('AHEE__EE_System__load_controllers__load_admin_controllers'); |
|
| 136 | + $this->loader->getShared('EE_Admin'); |
|
| 137 | + |
|
| 138 | + EE_Dependency_Map::register_dependencies( |
|
| 139 | + 'EventEspresso\core\domain\services\assets\EspressoAdminAssetManager', |
|
| 140 | + [ |
|
| 141 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 142 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 143 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 144 | + ] |
|
| 145 | + ); |
|
| 146 | + $this->loader->getShared('EventEspresso\core\domain\services\assets\EspressoAdminAssetManager'); |
|
| 147 | + } catch (Exception $exception) { |
|
| 148 | + new ExceptionStackTraceDisplay($exception); |
|
| 149 | + } |
|
| 150 | + } |
|
| 151 | + |
|
| 152 | + |
|
| 153 | + /** |
|
| 154 | + * @throws Exception |
|
| 155 | + * @since $VID:$ |
|
| 156 | + */ |
|
| 157 | + private function handleFrontendRequest() |
|
| 158 | + { |
|
| 159 | + try { |
|
| 160 | + // don't load frontend if M-Mode is active or request is not browser HTTP |
|
| 161 | + if ($this->maintenance_mode->level() || ! $this->request->isFrontend() || ! $this->request->isFrontAjax()) { |
|
| 162 | + return; |
|
| 163 | + } |
|
| 164 | + do_action('AHEE__EE_System__load_controllers__load_front_controllers'); |
|
| 165 | + $this->loader->getShared('EE_Front_Controller'); |
|
| 166 | + } catch (Exception $exception) { |
|
| 167 | + new ExceptionStackTraceDisplay($exception); |
|
| 168 | + } |
|
| 169 | + } |
|
| 170 | + |
|
| 171 | + |
|
| 172 | + /** |
|
| 173 | + * @return bool |
|
| 174 | + * @since $VID:$ |
|
| 175 | + */ |
|
| 176 | + private function isGQLRequest() |
|
| 177 | + { |
|
| 178 | + return PHP_VERSION_ID > 70000 |
|
| 179 | + && ( |
|
| 180 | + $this->request->isGQL() |
|
| 181 | + || $this->request->isUnitTesting() |
|
| 182 | + || $this->route_manager->routeMatchesCurrentRequest( |
|
| 183 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin\EspressoEventEditor' |
|
| 184 | + ) |
|
| 185 | + ); |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + |
|
| 189 | + /** |
|
| 190 | + * @throws Exception |
|
| 191 | + * @since $VID:$ |
|
| 192 | + */ |
|
| 193 | + public function handleGQLRequest() |
|
| 194 | + { |
|
| 195 | + try { |
|
| 196 | + if (! $this->isGQLRequest()) { |
|
| 197 | + return; |
|
| 198 | + } |
|
| 199 | + if (! class_exists('WPGraphQL')) { |
|
| 200 | + require_once EE_THIRD_PARTY . 'wp-graphql/wp-graphql.php'; |
|
| 201 | + } |
|
| 202 | + // load handler for EE GraphQL requests |
|
| 203 | + $graphQL_manager = $this->loader->getShared( |
|
| 204 | + 'EventEspresso\core\services\graphql\GraphQLManager' |
|
| 205 | + ); |
|
| 206 | + $graphQL_manager->init(); |
|
| 207 | + } catch (Exception $exception) { |
|
| 208 | + new ExceptionStackTraceDisplay($exception); |
|
| 209 | + } |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + |
|
| 213 | + /** |
|
| 214 | + * @throws Exception |
|
| 215 | + * @since $VID:$ |
|
| 216 | + */ |
|
| 217 | + public function handlePersonalDataRequest() |
|
| 218 | + { |
|
| 219 | + try { |
|
| 220 | + // don't load frontend if M-Mode is active or request is not browser HTTP |
|
| 221 | + if (! $this->request->isAdmin() |
|
| 222 | + || ! $this->request->isAjax() |
|
| 223 | + || ! $this->maintenance_mode->models_can_query() |
|
| 224 | + ) { |
|
| 225 | + return; |
|
| 226 | + } |
|
| 227 | + $this->loader->getShared('EventEspresso\core\services\privacy\erasure\PersonalDataEraserManager'); |
|
| 228 | + $this->loader->getShared('EventEspresso\core\services\privacy\export\PersonalDataExporterManager'); |
|
| 229 | + } catch (Exception $exception) { |
|
| 230 | + new ExceptionStackTraceDisplay($exception); |
|
| 231 | + } |
|
| 232 | + } |
|
| 233 | + |
|
| 234 | + |
|
| 235 | + /** |
|
| 236 | + * @throws Exception |
|
| 237 | + * @since $VID:$ |
|
| 238 | + */ |
|
| 239 | + public function handlePueRequest() |
|
| 240 | + { |
|
| 241 | + try { |
|
| 242 | + if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) { |
|
| 243 | + // pew pew pew |
|
| 244 | + $this->loader->getShared('EventEspresso\core\services\licensing\LicenseService'); |
|
| 245 | + do_action('AHEE__EE_System__brew_espresso__after_pue_init'); |
|
| 246 | + } |
|
| 247 | + } catch (Exception $exception) { |
|
| 248 | + new ExceptionStackTraceDisplay($exception); |
|
| 249 | + } |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + /** |
|
| 254 | + * @throws Exception |
|
| 255 | + * @since $VID:$ |
|
| 256 | + */ |
|
| 257 | + public function handleSessionRequest() |
|
| 258 | + { |
|
| 259 | + try { |
|
| 260 | + if (! $this->request->isAdmin() && ! $this->request->isEeAjax() && ! $this->request->isFrontend()) { |
|
| 261 | + return; |
|
| 262 | + } |
|
| 263 | + $this->loader->getShared('EE_Session'); |
|
| 264 | + } catch (Exception $exception) { |
|
| 265 | + new ExceptionStackTraceDisplay($exception); |
|
| 266 | + } |
|
| 267 | + } |
|
| 268 | + |
|
| 269 | + |
|
| 270 | + /** |
|
| 271 | + * @throws Exception |
|
| 272 | + * @since $VID:$ |
|
| 273 | + */ |
|
| 274 | + public function handleShortcodesRequest() |
|
| 275 | + { |
|
| 276 | + try { |
|
| 277 | + if (! $this->request->isFrontend() && ! $this->request->isIframe() && ! $this->request->isAjax()) { |
|
| 278 | + return; |
|
| 279 | + } |
|
| 280 | + // load, register, and add shortcodes the new way |
|
| 281 | + $this->loader->getShared( |
|
| 282 | + 'EventEspresso\core\services\shortcodes\ShortcodesManager', |
|
| 283 | + [ |
|
| 284 | + // and the old way, but we'll put it under control of the new system |
|
| 285 | + EE_Config::getLegacyShortcodesManager(), |
|
| 286 | + ] |
|
| 287 | + ); |
|
| 288 | + } catch (Exception $exception) { |
|
| 289 | + new ExceptionStackTraceDisplay($exception); |
|
| 290 | + } |
|
| 291 | + } |
|
| 292 | + |
|
| 293 | + |
|
| 294 | + /** |
|
| 295 | + * @throws Exception |
|
| 296 | + * @since $VID:$ |
|
| 297 | + */ |
|
| 298 | + public function handleWordPressHeartbeatRequest() |
|
| 299 | + { |
|
| 300 | + try { |
|
| 301 | + if (! $this->request->isWordPressHeartbeat()) { |
|
| 302 | + return; |
|
| 303 | + } |
|
| 304 | + $this->loader->getShared('EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat'); |
|
| 305 | + } catch (Exception $exception) { |
|
| 306 | + new ExceptionStackTraceDisplay($exception); |
|
| 307 | + } |
|
| 308 | + } |
|
| 309 | + |
|
| 310 | + |
|
| 311 | + /** |
|
| 312 | + * @throws Exception |
|
| 313 | + * @since $VID:$ |
|
| 314 | + */ |
|
| 315 | + public function handleWordPressPluginsPage() |
|
| 316 | + { |
|
| 317 | + try { |
|
| 318 | + if (! $this->request->isAdmin() |
|
| 319 | + || ! $this->route_manager->routeMatchesCurrentRequest( |
|
| 320 | + 'EventEspresso\core\domain\entities\route_match\specifications\admin\WordPressPluginsPage' |
|
| 321 | + ) |
|
| 322 | + ) { |
|
| 323 | + return; |
|
| 324 | + } |
|
| 325 | + EE_Dependency_Map::register_dependencies( |
|
| 326 | + 'EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager', |
|
| 327 | + [ |
|
| 328 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 329 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 330 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 331 | + 'EventEspresso\core\domain\services\admin\ExitModal' => EE_Dependency_Map::load_from_cache, |
|
| 332 | + ] |
|
| 333 | + ); |
|
| 334 | + $this->loader->getShared('EventEspresso\core\domain\services\assets\WordpressPluginsPageAssetManager'); |
|
| 335 | + } catch (Exception $exception) { |
|
| 336 | + new ExceptionStackTraceDisplay($exception); |
|
| 337 | + } |
|
| 338 | + } |
|
| 339 | 339 | } |
@@ -21,1261 +21,1261 @@ |
||
| 21 | 21 | class EE_Dependency_Map |
| 22 | 22 | { |
| 23 | 23 | |
| 24 | - /** |
|
| 25 | - * This means that the requested class dependency is not present in the dependency map |
|
| 26 | - */ |
|
| 27 | - const not_registered = 0; |
|
| 28 | - |
|
| 29 | - /** |
|
| 30 | - * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 31 | - */ |
|
| 32 | - const load_new_object = 1; |
|
| 33 | - |
|
| 34 | - /** |
|
| 35 | - * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 36 | - * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 37 | - */ |
|
| 38 | - const load_from_cache = 2; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * When registering a dependency, |
|
| 42 | - * this indicates to keep any existing dependencies that already exist, |
|
| 43 | - * and simply discard any new dependencies declared in the incoming data |
|
| 44 | - */ |
|
| 45 | - const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * When registering a dependency, |
|
| 49 | - * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 50 | - */ |
|
| 51 | - const OVERWRITE_DEPENDENCIES = 1; |
|
| 52 | - |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * @type EE_Dependency_Map $_instance |
|
| 56 | - */ |
|
| 57 | - protected static $_instance; |
|
| 58 | - |
|
| 59 | - /** |
|
| 60 | - * @var ClassInterfaceCache $class_cache |
|
| 61 | - */ |
|
| 62 | - private $class_cache; |
|
| 63 | - |
|
| 64 | - /** |
|
| 65 | - * @type RequestInterface $request |
|
| 66 | - */ |
|
| 67 | - protected $request; |
|
| 68 | - |
|
| 69 | - /** |
|
| 70 | - * @type LegacyRequestInterface $legacy_request |
|
| 71 | - */ |
|
| 72 | - protected $legacy_request; |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @type ResponseInterface $response |
|
| 76 | - */ |
|
| 77 | - protected $response; |
|
| 78 | - |
|
| 79 | - /** |
|
| 80 | - * @type LoaderInterface $loader |
|
| 81 | - */ |
|
| 82 | - protected $loader; |
|
| 83 | - |
|
| 84 | - /** |
|
| 85 | - * @type array $_dependency_map |
|
| 86 | - */ |
|
| 87 | - protected $_dependency_map = array(); |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @type array $_class_loaders |
|
| 91 | - */ |
|
| 92 | - protected $_class_loaders = array(); |
|
| 93 | - |
|
| 94 | - |
|
| 95 | - /** |
|
| 96 | - * EE_Dependency_Map constructor. |
|
| 97 | - * |
|
| 98 | - * @param ClassInterfaceCache $class_cache |
|
| 99 | - */ |
|
| 100 | - protected function __construct(ClassInterfaceCache $class_cache) |
|
| 101 | - { |
|
| 102 | - $this->class_cache = $class_cache; |
|
| 103 | - do_action('EE_Dependency_Map____construct', $this); |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - |
|
| 107 | - /** |
|
| 108 | - * @return void |
|
| 109 | - * @throws EE_Error |
|
| 110 | - * @throws InvalidAliasException |
|
| 111 | - */ |
|
| 112 | - public function initialize() |
|
| 113 | - { |
|
| 114 | - $this->_register_core_dependencies(); |
|
| 115 | - $this->_register_core_class_loaders(); |
|
| 116 | - $this->_register_core_aliases(); |
|
| 117 | - } |
|
| 118 | - |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * @singleton method used to instantiate class object |
|
| 122 | - * @param ClassInterfaceCache|null $class_cache |
|
| 123 | - * @return EE_Dependency_Map |
|
| 124 | - */ |
|
| 125 | - public static function instance(ClassInterfaceCache $class_cache = null) |
|
| 126 | - { |
|
| 127 | - // check if class object is instantiated, and instantiated properly |
|
| 128 | - if (! self::$_instance instanceof EE_Dependency_Map |
|
| 129 | - && $class_cache instanceof ClassInterfaceCache |
|
| 130 | - ) { |
|
| 131 | - self::$_instance = new EE_Dependency_Map($class_cache); |
|
| 132 | - } |
|
| 133 | - return self::$_instance; |
|
| 134 | - } |
|
| 135 | - |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * @param RequestInterface $request |
|
| 139 | - */ |
|
| 140 | - public function setRequest(RequestInterface $request) |
|
| 141 | - { |
|
| 142 | - $this->request = $request; |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - |
|
| 146 | - /** |
|
| 147 | - * @param LegacyRequestInterface $legacy_request |
|
| 148 | - */ |
|
| 149 | - public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 150 | - { |
|
| 151 | - $this->legacy_request = $legacy_request; |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - |
|
| 155 | - /** |
|
| 156 | - * @param ResponseInterface $response |
|
| 157 | - */ |
|
| 158 | - public function setResponse(ResponseInterface $response) |
|
| 159 | - { |
|
| 160 | - $this->response = $response; |
|
| 161 | - } |
|
| 162 | - |
|
| 163 | - |
|
| 164 | - /** |
|
| 165 | - * @param LoaderInterface $loader |
|
| 166 | - */ |
|
| 167 | - public function setLoader(LoaderInterface $loader) |
|
| 168 | - { |
|
| 169 | - $this->loader = $loader; |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - |
|
| 173 | - /** |
|
| 174 | - * @param string $class |
|
| 175 | - * @param array $dependencies |
|
| 176 | - * @param int $overwrite |
|
| 177 | - * @return bool |
|
| 178 | - */ |
|
| 179 | - public static function register_dependencies( |
|
| 180 | - $class, |
|
| 181 | - array $dependencies, |
|
| 182 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 183 | - ) { |
|
| 184 | - return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 190 | - * to the class specified by the first parameter. |
|
| 191 | - * IMPORTANT !!! |
|
| 192 | - * The order of elements in the incoming $dependencies array MUST match |
|
| 193 | - * the order of the constructor parameters for the class in question. |
|
| 194 | - * This is especially important when overriding any existing dependencies that are registered. |
|
| 195 | - * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 196 | - * |
|
| 197 | - * @param string $class |
|
| 198 | - * @param array $dependencies |
|
| 199 | - * @param int $overwrite |
|
| 200 | - * @return bool |
|
| 201 | - */ |
|
| 202 | - public function registerDependencies( |
|
| 203 | - $class, |
|
| 204 | - array $dependencies, |
|
| 205 | - $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 206 | - ) { |
|
| 207 | - $class = trim($class, '\\'); |
|
| 208 | - $registered = false; |
|
| 209 | - if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 210 | - self::$_instance->_dependency_map[ $class ] = array(); |
|
| 211 | - } |
|
| 212 | - // we need to make sure that any aliases used when registering a dependency |
|
| 213 | - // get resolved to the correct class name |
|
| 214 | - foreach ($dependencies as $dependency => $load_source) { |
|
| 215 | - $alias = self::$_instance->getFqnForAlias($dependency); |
|
| 216 | - if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 217 | - || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 218 | - ) { |
|
| 219 | - unset($dependencies[ $dependency ]); |
|
| 220 | - $dependencies[ $alias ] = $load_source; |
|
| 221 | - $registered = true; |
|
| 222 | - } |
|
| 223 | - } |
|
| 224 | - // now add our two lists of dependencies together. |
|
| 225 | - // using Union (+=) favours the arrays in precedence from left to right, |
|
| 226 | - // so $dependencies is NOT overwritten because it is listed first |
|
| 227 | - // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 228 | - // Union is way faster than array_merge() but should be used with caution... |
|
| 229 | - // especially with numerically indexed arrays |
|
| 230 | - $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 231 | - // now we need to ensure that the resulting dependencies |
|
| 232 | - // array only has the entries that are required for the class |
|
| 233 | - // so first count how many dependencies were originally registered for the class |
|
| 234 | - $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 235 | - // if that count is non-zero (meaning dependencies were already registered) |
|
| 236 | - self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 237 | - // then truncate the final array to match that count |
|
| 238 | - ? array_slice($dependencies, 0, $dependency_count) |
|
| 239 | - // otherwise just take the incoming array because nothing previously existed |
|
| 240 | - : $dependencies; |
|
| 241 | - return $registered; |
|
| 242 | - } |
|
| 243 | - |
|
| 244 | - |
|
| 245 | - /** |
|
| 246 | - * @param string $class_name |
|
| 247 | - * @param string $loader |
|
| 248 | - * @return bool |
|
| 249 | - * @throws DomainException |
|
| 250 | - */ |
|
| 251 | - public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 252 | - { |
|
| 253 | - if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 254 | - throw new DomainException( |
|
| 255 | - esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 256 | - ); |
|
| 257 | - } |
|
| 258 | - // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 259 | - if (! is_callable($loader) |
|
| 260 | - && ( |
|
| 261 | - strpos($loader, 'load_') !== 0 |
|
| 262 | - || ! method_exists('EE_Registry', $loader) |
|
| 263 | - ) |
|
| 264 | - ) { |
|
| 265 | - throw new DomainException( |
|
| 266 | - sprintf( |
|
| 267 | - esc_html__( |
|
| 268 | - '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 269 | - 'event_espresso' |
|
| 270 | - ), |
|
| 271 | - $loader |
|
| 272 | - ) |
|
| 273 | - ); |
|
| 274 | - } |
|
| 275 | - $class_name = self::$_instance->getFqnForAlias($class_name); |
|
| 276 | - if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
| 277 | - self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 278 | - return true; |
|
| 279 | - } |
|
| 280 | - return false; |
|
| 281 | - } |
|
| 282 | - |
|
| 283 | - |
|
| 284 | - /** |
|
| 285 | - * @return array |
|
| 286 | - */ |
|
| 287 | - public function dependency_map() |
|
| 288 | - { |
|
| 289 | - return $this->_dependency_map; |
|
| 290 | - } |
|
| 291 | - |
|
| 292 | - |
|
| 293 | - /** |
|
| 294 | - * returns TRUE if dependency map contains a listing for the provided class name |
|
| 295 | - * |
|
| 296 | - * @param string $class_name |
|
| 297 | - * @return boolean |
|
| 298 | - */ |
|
| 299 | - public function has($class_name = '') |
|
| 300 | - { |
|
| 301 | - // all legacy models have the same dependencies |
|
| 302 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 303 | - $class_name = 'LEGACY_MODELS'; |
|
| 304 | - } |
|
| 305 | - return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
| 306 | - } |
|
| 307 | - |
|
| 308 | - |
|
| 309 | - /** |
|
| 310 | - * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 311 | - * |
|
| 312 | - * @param string $class_name |
|
| 313 | - * @param string $dependency |
|
| 314 | - * @return bool |
|
| 315 | - */ |
|
| 316 | - public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 317 | - { |
|
| 318 | - // all legacy models have the same dependencies |
|
| 319 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 320 | - $class_name = 'LEGACY_MODELS'; |
|
| 321 | - } |
|
| 322 | - $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 323 | - return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
| 324 | - ? true |
|
| 325 | - : false; |
|
| 326 | - } |
|
| 327 | - |
|
| 328 | - |
|
| 329 | - /** |
|
| 330 | - * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 331 | - * |
|
| 332 | - * @param string $class_name |
|
| 333 | - * @param string $dependency |
|
| 334 | - * @return int |
|
| 335 | - */ |
|
| 336 | - public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 337 | - { |
|
| 338 | - // all legacy models have the same dependencies |
|
| 339 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 340 | - $class_name = 'LEGACY_MODELS'; |
|
| 341 | - } |
|
| 342 | - $dependency = $this->getFqnForAlias($dependency); |
|
| 343 | - return $this->has_dependency_for_class($class_name, $dependency) |
|
| 344 | - ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 345 | - : EE_Dependency_Map::not_registered; |
|
| 346 | - } |
|
| 347 | - |
|
| 348 | - |
|
| 349 | - /** |
|
| 350 | - * @param string $class_name |
|
| 351 | - * @return string | Closure |
|
| 352 | - */ |
|
| 353 | - public function class_loader($class_name) |
|
| 354 | - { |
|
| 355 | - // all legacy models use load_model() |
|
| 356 | - if (strpos($class_name, 'EEM_') === 0) { |
|
| 357 | - return 'load_model'; |
|
| 358 | - } |
|
| 359 | - // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 360 | - // perform strpos() first to avoid loading regex every time we load a class |
|
| 361 | - if (strpos($class_name, 'EE_CPT_') === 0 |
|
| 362 | - && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 363 | - ) { |
|
| 364 | - return 'load_core'; |
|
| 365 | - } |
|
| 366 | - $class_name = $this->getFqnForAlias($class_name); |
|
| 367 | - return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - |
|
| 371 | - /** |
|
| 372 | - * @return array |
|
| 373 | - */ |
|
| 374 | - public function class_loaders() |
|
| 375 | - { |
|
| 376 | - return $this->_class_loaders; |
|
| 377 | - } |
|
| 378 | - |
|
| 379 | - |
|
| 380 | - /** |
|
| 381 | - * adds an alias for a classname |
|
| 382 | - * |
|
| 383 | - * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 384 | - * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 385 | - * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 386 | - * @throws InvalidAliasException |
|
| 387 | - */ |
|
| 388 | - public function add_alias($fqcn, $alias, $for_class = '') |
|
| 389 | - { |
|
| 390 | - $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 391 | - } |
|
| 392 | - |
|
| 393 | - |
|
| 394 | - /** |
|
| 395 | - * Returns TRUE if the provided fully qualified name IS an alias |
|
| 396 | - * WHY? |
|
| 397 | - * Because if a class is type hinting for a concretion, |
|
| 398 | - * then why would we need to find another class to supply it? |
|
| 399 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 400 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 401 | - * Don't go looking for some substitute. |
|
| 402 | - * Whereas if a class is type hinting for an interface... |
|
| 403 | - * then we need to find an actual class to use. |
|
| 404 | - * So the interface IS the alias for some other FQN, |
|
| 405 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 406 | - * represents some other class. |
|
| 407 | - * |
|
| 408 | - * @param string $fqn |
|
| 409 | - * @param string $for_class |
|
| 410 | - * @return bool |
|
| 411 | - */ |
|
| 412 | - public function isAlias($fqn = '', $for_class = '') |
|
| 413 | - { |
|
| 414 | - return $this->class_cache->isAlias($fqn, $for_class); |
|
| 415 | - } |
|
| 416 | - |
|
| 417 | - |
|
| 418 | - /** |
|
| 419 | - * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 420 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 421 | - * for example: |
|
| 422 | - * if the following two entries were added to the _aliases array: |
|
| 423 | - * array( |
|
| 424 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 425 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 426 | - * ) |
|
| 427 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 428 | - * to load an instance of 'some\namespace\classname' |
|
| 429 | - * |
|
| 430 | - * @param string $alias |
|
| 431 | - * @param string $for_class |
|
| 432 | - * @return string |
|
| 433 | - */ |
|
| 434 | - public function getFqnForAlias($alias = '', $for_class = '') |
|
| 435 | - { |
|
| 436 | - return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 437 | - } |
|
| 438 | - |
|
| 439 | - |
|
| 440 | - /** |
|
| 441 | - * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 442 | - * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 443 | - * This is done by using the following class constants: |
|
| 444 | - * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 445 | - * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 446 | - */ |
|
| 447 | - protected function _register_core_dependencies() |
|
| 448 | - { |
|
| 449 | - $this->_dependency_map = array( |
|
| 450 | - 'EE_Request_Handler' => array( |
|
| 451 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 452 | - ), |
|
| 453 | - 'EE_System' => array( |
|
| 454 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 455 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 456 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 457 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 458 | - ), |
|
| 459 | - 'EE_Session' => array( |
|
| 460 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 461 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 462 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 463 | - 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
| 464 | - 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 465 | - ), |
|
| 466 | - 'EE_Cart' => array( |
|
| 467 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 468 | - ), |
|
| 469 | - 'EE_Front_Controller' => array( |
|
| 470 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 471 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 472 | - 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
| 473 | - ), |
|
| 474 | - 'EE_Messenger_Collection_Loader' => array( |
|
| 475 | - 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 476 | - ), |
|
| 477 | - 'EE_Message_Type_Collection_Loader' => array( |
|
| 478 | - 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 479 | - ), |
|
| 480 | - 'EE_Message_Resource_Manager' => array( |
|
| 481 | - 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 482 | - 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 483 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 484 | - ), |
|
| 485 | - 'EE_Message_Factory' => array( |
|
| 486 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 487 | - ), |
|
| 488 | - 'EE_messages' => array( |
|
| 489 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 490 | - ), |
|
| 491 | - 'EE_Messages_Generator' => array( |
|
| 492 | - 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 493 | - 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 494 | - 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 495 | - 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 496 | - ), |
|
| 497 | - 'EE_Messages_Processor' => array( |
|
| 498 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 499 | - ), |
|
| 500 | - 'EE_Messages_Queue' => array( |
|
| 501 | - 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 502 | - ), |
|
| 503 | - 'EE_Messages_Template_Defaults' => array( |
|
| 504 | - 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 505 | - 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 506 | - ), |
|
| 507 | - 'EE_Message_To_Generate_From_Request' => array( |
|
| 508 | - 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 509 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 510 | - ), |
|
| 511 | - 'EventEspresso\core\services\commands\CommandBus' => array( |
|
| 512 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 513 | - ), |
|
| 514 | - 'EventEspresso\services\commands\CommandHandler' => array( |
|
| 515 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 516 | - 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 517 | - ), |
|
| 518 | - 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
| 519 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 520 | - ), |
|
| 521 | - 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
| 522 | - 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 523 | - 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 524 | - ), |
|
| 525 | - 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
| 526 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 527 | - ), |
|
| 528 | - 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
| 529 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 530 | - ), |
|
| 531 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
| 532 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 533 | - ), |
|
| 534 | - 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
| 535 | - 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 536 | - ), |
|
| 537 | - 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
| 538 | - 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 539 | - ), |
|
| 540 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
| 541 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 542 | - ), |
|
| 543 | - 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
| 544 | - 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 545 | - ), |
|
| 546 | - 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
| 547 | - 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 548 | - ), |
|
| 549 | - 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
| 550 | - 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 551 | - ), |
|
| 552 | - 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
| 553 | - 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 554 | - ), |
|
| 555 | - 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
| 556 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 557 | - ), |
|
| 558 | - 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
| 559 | - 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 560 | - ), |
|
| 561 | - 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
| 562 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 563 | - ), |
|
| 564 | - 'EventEspresso\core\services\database\TableManager' => array( |
|
| 565 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 566 | - ), |
|
| 567 | - 'EE_Data_Migration_Class_Base' => array( |
|
| 568 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 569 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 570 | - ), |
|
| 571 | - 'EE_DMS_Core_4_1_0' => array( |
|
| 572 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 573 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 574 | - ), |
|
| 575 | - 'EE_DMS_Core_4_2_0' => array( |
|
| 576 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 577 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 578 | - ), |
|
| 579 | - 'EE_DMS_Core_4_3_0' => array( |
|
| 580 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 581 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 582 | - ), |
|
| 583 | - 'EE_DMS_Core_4_4_0' => array( |
|
| 584 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 585 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 586 | - ), |
|
| 587 | - 'EE_DMS_Core_4_5_0' => array( |
|
| 588 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 589 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 590 | - ), |
|
| 591 | - 'EE_DMS_Core_4_6_0' => array( |
|
| 592 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 593 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 594 | - ), |
|
| 595 | - 'EE_DMS_Core_4_7_0' => array( |
|
| 596 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 597 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 598 | - ), |
|
| 599 | - 'EE_DMS_Core_4_8_0' => array( |
|
| 600 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 601 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 602 | - ), |
|
| 603 | - 'EE_DMS_Core_4_9_0' => array( |
|
| 604 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 605 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 606 | - ), |
|
| 607 | - 'EE_DMS_Core_4_10_0' => array( |
|
| 608 | - 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 609 | - 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 610 | - 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 611 | - ), |
|
| 612 | - 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
| 613 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 614 | - 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 615 | - array(), |
|
| 616 | - ), |
|
| 617 | - 'EventEspresso\core\services\assets\Registry' => array( |
|
| 618 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 619 | - 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
| 620 | - ), |
|
| 621 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
| 622 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 623 | - ), |
|
| 624 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
| 625 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 626 | - ), |
|
| 627 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
| 628 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 629 | - ), |
|
| 630 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
| 631 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 632 | - ), |
|
| 633 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
| 634 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 635 | - ), |
|
| 636 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
| 637 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 638 | - ), |
|
| 639 | - 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
| 640 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 641 | - ), |
|
| 642 | - 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
| 643 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 644 | - ), |
|
| 645 | - 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
| 646 | - 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 647 | - ), |
|
| 648 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
| 649 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 650 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 651 | - ), |
|
| 652 | - 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
| 653 | - null, |
|
| 654 | - 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 655 | - ), |
|
| 656 | - 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
| 657 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 658 | - ), |
|
| 659 | - 'LEGACY_MODELS' => array( |
|
| 660 | - null, |
|
| 661 | - 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 662 | - ), |
|
| 663 | - 'EE_Module_Request_Router' => array( |
|
| 664 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 665 | - ), |
|
| 666 | - 'EE_Registration_Processor' => array( |
|
| 667 | - 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 668 | - ), |
|
| 669 | - 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
| 670 | - null, |
|
| 671 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 672 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 673 | - ), |
|
| 674 | - 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
| 675 | - 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
| 676 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
| 677 | - ), |
|
| 678 | - 'EE_Admin_Transactions_List_Table' => array( |
|
| 679 | - null, |
|
| 680 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 681 | - ), |
|
| 682 | - 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
| 683 | - 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
| 684 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 685 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
| 686 | - ), |
|
| 687 | - 'EventEspresso\core\domain\services\pue\Config' => array( |
|
| 688 | - 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
| 689 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
| 690 | - ), |
|
| 691 | - 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
| 692 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
| 693 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 694 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 695 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 696 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 697 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
| 698 | - 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
| 699 | - ), |
|
| 700 | - 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
| 701 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 702 | - ), |
|
| 703 | - 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
| 704 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 705 | - ), |
|
| 706 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
| 707 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 708 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 709 | - ), |
|
| 710 | - 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
| 711 | - 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 712 | - ), |
|
| 713 | - 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
| 714 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 715 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 716 | - 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 717 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 718 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 719 | - ), |
|
| 720 | - 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
| 721 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 722 | - ), |
|
| 723 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
| 724 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 725 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 726 | - ), |
|
| 727 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
| 728 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 729 | - ), |
|
| 730 | - 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
| 731 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 732 | - ), |
|
| 733 | - 'EE_CPT_Strategy' => array( |
|
| 734 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 735 | - 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 736 | - ), |
|
| 737 | - 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
| 738 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 739 | - ), |
|
| 740 | - 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
| 741 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 742 | - 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 743 | - 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 744 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 745 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 746 | - ), |
|
| 747 | - 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
| 748 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
| 749 | - 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
| 750 | - ), |
|
| 751 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
| 752 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 753 | - ), |
|
| 754 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
| 755 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 756 | - 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
| 757 | - ), |
|
| 758 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
| 759 | - 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
| 760 | - ), |
|
| 761 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
| 762 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 763 | - ), |
|
| 764 | - 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
| 765 | - 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
| 766 | - ), |
|
| 767 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
| 768 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 769 | - ), |
|
| 770 | - 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
| 771 | - 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
| 772 | - 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
| 773 | - ), |
|
| 774 | - 'EventEspresso\core\CPTs\CptQueryModifier' => array( |
|
| 775 | - null, |
|
| 776 | - null, |
|
| 777 | - null, |
|
| 778 | - 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 779 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 780 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 781 | - ), |
|
| 782 | - 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array( |
|
| 783 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 784 | - 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
| 785 | - ), |
|
| 786 | - 'EventEspresso\core\services\editor\BlockRegistrationManager' => array( |
|
| 787 | - 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
| 788 | - 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
| 789 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
| 790 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 791 | - ), |
|
| 792 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array( |
|
| 793 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 794 | - 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 795 | - 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 796 | - ), |
|
| 797 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array( |
|
| 798 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 799 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 800 | - ), |
|
| 801 | - 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array( |
|
| 802 | - 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
| 803 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 804 | - 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
| 805 | - ), |
|
| 806 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array( |
|
| 807 | - 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 808 | - 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 809 | - 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 810 | - ), |
|
| 811 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array( |
|
| 812 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 813 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 814 | - ), |
|
| 815 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array( |
|
| 816 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 817 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 818 | - ), |
|
| 819 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array( |
|
| 820 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache |
|
| 821 | - ), |
|
| 822 | - 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array( |
|
| 823 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 824 | - ), |
|
| 825 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array( |
|
| 826 | - 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache |
|
| 827 | - ), |
|
| 828 | - 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array( |
|
| 829 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 830 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 831 | - ), |
|
| 832 | - 'EventEspresso\core\libraries\rest_api\calculations\Event' => array( |
|
| 833 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 834 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 835 | - ), |
|
| 836 | - 'EventEspresso\core\libraries\rest_api\calculations\Registration' => array( |
|
| 837 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 838 | - ), |
|
| 839 | - 'EventEspresso\core\services\session\SessionStartHandler' => array( |
|
| 840 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 841 | - ), |
|
| 842 | - 'EE_URL_Validation_Strategy' => array( |
|
| 843 | - null, |
|
| 844 | - null, |
|
| 845 | - 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
| 846 | - ), |
|
| 847 | - 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array( |
|
| 848 | - 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 849 | - 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
| 850 | - 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 851 | - 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 852 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
| 853 | - ), |
|
| 854 | - 'EventEspresso\core\services\address\CountrySubRegionDao' => array( |
|
| 855 | - 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
| 856 | - 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache |
|
| 857 | - ), |
|
| 858 | - 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array( |
|
| 859 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 860 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 861 | - ), |
|
| 862 | - 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array( |
|
| 863 | - 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 864 | - 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
| 865 | - ), |
|
| 866 | - 'EventEspresso\core\services\request\files\FilesDataHandler' => array( |
|
| 867 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 868 | - ), |
|
| 869 | - 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 870 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 871 | - ], |
|
| 872 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [ |
|
| 873 | - null, |
|
| 874 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 875 | - 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 876 | - ], |
|
| 877 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [ |
|
| 878 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 879 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 880 | - ], |
|
| 881 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [ |
|
| 882 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 883 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 884 | - ], |
|
| 885 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [ |
|
| 886 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 887 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 888 | - ], |
|
| 889 | - 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [ |
|
| 890 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 891 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 892 | - ], |
|
| 893 | - 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 894 | - 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 895 | - 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 896 | - 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 897 | - null |
|
| 898 | - ], |
|
| 899 | - 'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection' => [ |
|
| 900 | - 'EE_Admin_Config' => EE_Dependency_Map::load_from_cache |
|
| 901 | - ], |
|
| 902 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditor' => [ |
|
| 903 | - 'EE_Admin_Config' => EE_Dependency_Map::load_from_cache, |
|
| 904 | - 'EE_Event' => EE_Dependency_Map::not_registered, |
|
| 905 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\CurrentUser' => |
|
| 906 | - EE_Dependency_Map::not_registered, |
|
| 907 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => |
|
| 908 | - EE_Dependency_Map::load_from_cache, |
|
| 909 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\GeneralSettings' => |
|
| 910 | - EE_Dependency_Map::load_from_cache, |
|
| 911 | - 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 912 | - ], |
|
| 913 | - 'EventEspresso\core\services\graphql\GraphQLManager' => [ |
|
| 914 | - 'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
|
| 915 | - 'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
|
| 916 | - 'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
|
| 917 | - 'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
|
| 918 | - ], |
|
| 919 | - 'EventEspresso\core\services\graphql\TypesManager' => [ |
|
| 920 | - 'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
|
| 921 | - ], |
|
| 922 | - 'EventEspresso\core\services\graphql\InputsManager' => [ |
|
| 923 | - 'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
|
| 924 | - ], |
|
| 925 | - 'EventEspresso\core\services\graphql\EnumsManager' => [ |
|
| 926 | - 'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
|
| 927 | - ], |
|
| 928 | - 'EventEspresso\core\services\graphql\ConnectionsManager' => [ |
|
| 929 | - 'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
|
| 930 | - ], |
|
| 931 | - 'EventEspresso\core\domain\services\graphql\types\Datetime' => [ |
|
| 932 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 933 | - ], |
|
| 934 | - 'EventEspresso\core\domain\services\graphql\types\Attendee' => [ |
|
| 935 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 936 | - ], |
|
| 937 | - 'EventEspresso\core\domain\services\graphql\types\Event' => [ |
|
| 938 | - 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 939 | - ], |
|
| 940 | - 'EventEspresso\core\domain\services\graphql\types\Ticket' => [ |
|
| 941 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 942 | - ], |
|
| 943 | - 'EventEspresso\core\domain\services\graphql\types\Price' => [ |
|
| 944 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 945 | - ], |
|
| 946 | - 'EventEspresso\core\domain\services\graphql\types\PriceType' => [ |
|
| 947 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 948 | - ], |
|
| 949 | - 'EventEspresso\core\domain\services\graphql\types\Venue' => [ |
|
| 950 | - 'EEM_Venue' => EE_Dependency_Map::load_from_cache, |
|
| 951 | - ], |
|
| 952 | - 'EventEspresso\core\domain\services\graphql\types\State' => [ |
|
| 953 | - 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
| 954 | - ], |
|
| 955 | - 'EventEspresso\core\domain\services\graphql\types\Country' => [ |
|
| 956 | - 'EEM_Country' => EE_Dependency_Map::load_from_cache, |
|
| 957 | - ], |
|
| 958 | - 'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection' => [ |
|
| 959 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 960 | - ], |
|
| 961 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection' => [ |
|
| 962 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 963 | - ], |
|
| 964 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection' => [ |
|
| 965 | - 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 966 | - ], |
|
| 967 | - 'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection' => [ |
|
| 968 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 969 | - ], |
|
| 970 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection' => [ |
|
| 971 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 972 | - ], |
|
| 973 | - 'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection' => [ |
|
| 974 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 975 | - ], |
|
| 976 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection' => [ |
|
| 977 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 978 | - ], |
|
| 979 | - 'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection' => [ |
|
| 980 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 981 | - ], |
|
| 982 | - 'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection' => [ |
|
| 983 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 984 | - ], |
|
| 985 | - 'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection' => [ |
|
| 986 | - 'EEM_Venue' => EE_Dependency_Map::load_from_cache, |
|
| 987 | - ], |
|
| 988 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => [ |
|
| 989 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
| 990 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
| 991 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
| 992 | - 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
| 993 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
| 994 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
| 995 | - ], |
|
| 996 | - 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => [ |
|
| 997 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 998 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 999 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 1000 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 1001 | - ], |
|
| 1002 | - 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => [ |
|
| 1003 | - 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 1004 | - 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 1005 | - 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 1006 | - 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 1007 | - ], |
|
| 1008 | - 'EventEspresso\core\services\route_match\RouteHandler' => [ |
|
| 1009 | - 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 1010 | - 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 1011 | - 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 1012 | - 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
| 1013 | - ], |
|
| 1014 | - ); |
|
| 1015 | - } |
|
| 1016 | - |
|
| 1017 | - |
|
| 1018 | - /** |
|
| 1019 | - * Registers how core classes are loaded. |
|
| 1020 | - * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 1021 | - * 'EE_Request_Handler' => 'load_core' |
|
| 1022 | - * 'EE_Messages_Queue' => 'load_lib' |
|
| 1023 | - * 'EEH_Debug_Tools' => 'load_helper' |
|
| 1024 | - * or, if greater control is required, by providing a custom closure. For example: |
|
| 1025 | - * 'Some_Class' => function () { |
|
| 1026 | - * return new Some_Class(); |
|
| 1027 | - * }, |
|
| 1028 | - * This is required for instantiating dependencies |
|
| 1029 | - * where an interface has been type hinted in a class constructor. For example: |
|
| 1030 | - * 'Required_Interface' => function () { |
|
| 1031 | - * return new A_Class_That_Implements_Required_Interface(); |
|
| 1032 | - * }, |
|
| 1033 | - */ |
|
| 1034 | - protected function _register_core_class_loaders() |
|
| 1035 | - { |
|
| 1036 | - $this->_class_loaders = array( |
|
| 1037 | - // load_core |
|
| 1038 | - 'EE_Dependency_Map' => function () { |
|
| 1039 | - return $this; |
|
| 1040 | - }, |
|
| 1041 | - 'EE_Capabilities' => 'load_core', |
|
| 1042 | - 'EE_Encryption' => 'load_core', |
|
| 1043 | - 'EE_Front_Controller' => 'load_core', |
|
| 1044 | - 'EE_Module_Request_Router' => 'load_core', |
|
| 1045 | - 'EE_Registry' => 'load_core', |
|
| 1046 | - 'EE_Request' => function () { |
|
| 1047 | - return $this->legacy_request; |
|
| 1048 | - }, |
|
| 1049 | - 'EventEspresso\core\services\request\Request' => function () { |
|
| 1050 | - return $this->request; |
|
| 1051 | - }, |
|
| 1052 | - 'EventEspresso\core\services\request\Response' => function () { |
|
| 1053 | - return $this->response; |
|
| 1054 | - }, |
|
| 1055 | - 'EE_Base' => 'load_core', |
|
| 1056 | - 'EE_Request_Handler' => 'load_core', |
|
| 1057 | - 'EE_Session' => 'load_core', |
|
| 1058 | - 'EE_Cron_Tasks' => 'load_core', |
|
| 1059 | - 'EE_System' => 'load_core', |
|
| 1060 | - 'EE_Maintenance_Mode' => 'load_core', |
|
| 1061 | - 'EE_Register_CPTs' => 'load_core', |
|
| 1062 | - 'EE_Admin' => 'load_core', |
|
| 1063 | - 'EE_CPT_Strategy' => 'load_core', |
|
| 1064 | - // load_class |
|
| 1065 | - 'EE_Registration_Processor' => 'load_class', |
|
| 1066 | - // load_lib |
|
| 1067 | - 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 1068 | - 'EE_Message_Type_Collection' => 'load_lib', |
|
| 1069 | - 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 1070 | - 'EE_Messenger_Collection' => 'load_lib', |
|
| 1071 | - 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 1072 | - 'EE_Messages_Processor' => 'load_lib', |
|
| 1073 | - 'EE_Message_Repository' => 'load_lib', |
|
| 1074 | - 'EE_Messages_Queue' => 'load_lib', |
|
| 1075 | - 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 1076 | - 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 1077 | - 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 1078 | - 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 1079 | - 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 1080 | - 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 1081 | - 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 1082 | - 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 1083 | - 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 1084 | - 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 1085 | - 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 1086 | - 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 1087 | - 'EE_Messages_Generator' => static function () { |
|
| 1088 | - return EE_Registry::instance()->load_lib( |
|
| 1089 | - 'Messages_Generator', |
|
| 1090 | - array(), |
|
| 1091 | - false, |
|
| 1092 | - false |
|
| 1093 | - ); |
|
| 1094 | - }, |
|
| 1095 | - 'EE_Messages_Template_Defaults' => static function ($arguments = array()) { |
|
| 1096 | - return EE_Registry::instance()->load_lib( |
|
| 1097 | - 'Messages_Template_Defaults', |
|
| 1098 | - $arguments, |
|
| 1099 | - false, |
|
| 1100 | - false |
|
| 1101 | - ); |
|
| 1102 | - }, |
|
| 1103 | - // load_helper |
|
| 1104 | - 'EEH_Parse_Shortcodes' => static function () { |
|
| 1105 | - if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 1106 | - return new EEH_Parse_Shortcodes(); |
|
| 1107 | - } |
|
| 1108 | - return null; |
|
| 1109 | - }, |
|
| 1110 | - 'EE_Template_Config' => static function () { |
|
| 1111 | - return EE_Config::instance()->template_settings; |
|
| 1112 | - }, |
|
| 1113 | - 'EE_Currency_Config' => static function () { |
|
| 1114 | - return EE_Config::instance()->currency; |
|
| 1115 | - }, |
|
| 1116 | - 'EE_Registration_Config' => static function () { |
|
| 1117 | - return EE_Config::instance()->registration; |
|
| 1118 | - }, |
|
| 1119 | - 'EE_Core_Config' => static function () { |
|
| 1120 | - return EE_Config::instance()->core; |
|
| 1121 | - }, |
|
| 1122 | - 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 1123 | - return LoaderFactory::getLoader(); |
|
| 1124 | - }, |
|
| 1125 | - 'EE_Network_Config' => static function () { |
|
| 1126 | - return EE_Network_Config::instance(); |
|
| 1127 | - }, |
|
| 1128 | - 'EE_Config' => static function () { |
|
| 1129 | - return EE_Config::instance(); |
|
| 1130 | - }, |
|
| 1131 | - 'EventEspresso\core\domain\Domain' => static function () { |
|
| 1132 | - return DomainFactory::getEventEspressoCoreDomain(); |
|
| 1133 | - }, |
|
| 1134 | - 'EE_Admin_Config' => static function () { |
|
| 1135 | - return EE_Config::instance()->admin; |
|
| 1136 | - }, |
|
| 1137 | - 'EE_Organization_Config' => static function () { |
|
| 1138 | - return EE_Config::instance()->organization; |
|
| 1139 | - }, |
|
| 1140 | - 'EE_Network_Core_Config' => static function () { |
|
| 1141 | - return EE_Network_Config::instance()->core; |
|
| 1142 | - }, |
|
| 1143 | - 'EE_Environment_Config' => static function () { |
|
| 1144 | - return EE_Config::instance()->environment; |
|
| 1145 | - }, |
|
| 1146 | - 'EED_Core_Rest_Api' => static function () { |
|
| 1147 | - return EED_Core_Rest_Api::instance(); |
|
| 1148 | - }, |
|
| 1149 | - 'WP_REST_Server' => static function () { |
|
| 1150 | - return rest_get_server(); |
|
| 1151 | - }, |
|
| 1152 | - ); |
|
| 1153 | - } |
|
| 1154 | - |
|
| 1155 | - |
|
| 1156 | - /** |
|
| 1157 | - * can be used for supplying alternate names for classes, |
|
| 1158 | - * or for connecting interface names to instantiable classes |
|
| 1159 | - * |
|
| 1160 | - * @throws InvalidAliasException |
|
| 1161 | - */ |
|
| 1162 | - protected function _register_core_aliases() |
|
| 1163 | - { |
|
| 1164 | - $aliases = array( |
|
| 1165 | - 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 1166 | - 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 1167 | - 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 1168 | - 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 1169 | - 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 1170 | - 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 1171 | - 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1172 | - 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 1173 | - 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1174 | - 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 1175 | - 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1176 | - 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 1177 | - 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 1178 | - 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 1179 | - 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 1180 | - 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 1181 | - 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 1182 | - 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 1183 | - 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 1184 | - 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 1185 | - 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1186 | - 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 1187 | - 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1188 | - 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 1189 | - 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 1190 | - 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 1191 | - 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 1192 | - 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 1193 | - 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 1194 | - 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 1195 | - 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 1196 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 1197 | - 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 1198 | - 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 1199 | - 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 1200 | - 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 1201 | - 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 1202 | - 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 1203 | - ); |
|
| 1204 | - foreach ($aliases as $alias => $fqn) { |
|
| 1205 | - if (is_array($fqn)) { |
|
| 1206 | - foreach ($fqn as $class => $for_class) { |
|
| 1207 | - $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 1208 | - } |
|
| 1209 | - continue; |
|
| 1210 | - } |
|
| 1211 | - $this->class_cache->addAlias($fqn, $alias); |
|
| 1212 | - } |
|
| 1213 | - if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1214 | - $this->class_cache->addAlias( |
|
| 1215 | - 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 1216 | - 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 1217 | - ); |
|
| 1218 | - } |
|
| 1219 | - } |
|
| 1220 | - |
|
| 1221 | - |
|
| 1222 | - /** |
|
| 1223 | - * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 1224 | - * request Primarily used by unit tests. |
|
| 1225 | - */ |
|
| 1226 | - public function reset() |
|
| 1227 | - { |
|
| 1228 | - $this->_register_core_class_loaders(); |
|
| 1229 | - $this->_register_core_dependencies(); |
|
| 1230 | - } |
|
| 1231 | - |
|
| 1232 | - |
|
| 1233 | - /** |
|
| 1234 | - * PLZ NOTE: a better name for this method would be is_alias() |
|
| 1235 | - * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 1236 | - * WHY? |
|
| 1237 | - * Because if a class is type hinting for a concretion, |
|
| 1238 | - * then why would we need to find another class to supply it? |
|
| 1239 | - * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 1240 | - * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 1241 | - * Don't go looking for some substitute. |
|
| 1242 | - * Whereas if a class is type hinting for an interface... |
|
| 1243 | - * then we need to find an actual class to use. |
|
| 1244 | - * So the interface IS the alias for some other FQN, |
|
| 1245 | - * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 1246 | - * represents some other class. |
|
| 1247 | - * |
|
| 1248 | - * @deprecated 4.9.62.p |
|
| 1249 | - * @param string $fqn |
|
| 1250 | - * @param string $for_class |
|
| 1251 | - * @return bool |
|
| 1252 | - */ |
|
| 1253 | - public function has_alias($fqn = '', $for_class = '') |
|
| 1254 | - { |
|
| 1255 | - return $this->isAlias($fqn, $for_class); |
|
| 1256 | - } |
|
| 1257 | - |
|
| 1258 | - |
|
| 1259 | - /** |
|
| 1260 | - * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 1261 | - * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 1262 | - * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 1263 | - * for example: |
|
| 1264 | - * if the following two entries were added to the _aliases array: |
|
| 1265 | - * array( |
|
| 1266 | - * 'interface_alias' => 'some\namespace\interface' |
|
| 1267 | - * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 1268 | - * ) |
|
| 1269 | - * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1270 | - * to load an instance of 'some\namespace\classname' |
|
| 1271 | - * |
|
| 1272 | - * @deprecated 4.9.62.p |
|
| 1273 | - * @param string $alias |
|
| 1274 | - * @param string $for_class |
|
| 1275 | - * @return string |
|
| 1276 | - */ |
|
| 1277 | - public function get_alias($alias = '', $for_class = '') |
|
| 1278 | - { |
|
| 1279 | - return $this->getFqnForAlias($alias, $for_class); |
|
| 1280 | - } |
|
| 24 | + /** |
|
| 25 | + * This means that the requested class dependency is not present in the dependency map |
|
| 26 | + */ |
|
| 27 | + const not_registered = 0; |
|
| 28 | + |
|
| 29 | + /** |
|
| 30 | + * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class. |
|
| 31 | + */ |
|
| 32 | + const load_new_object = 1; |
|
| 33 | + |
|
| 34 | + /** |
|
| 35 | + * This instructs class loaders to return a previously instantiated and cached object for the requested class. |
|
| 36 | + * IF a previously instantiated object does not exist, a new one will be created and added to the cache. |
|
| 37 | + */ |
|
| 38 | + const load_from_cache = 2; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * When registering a dependency, |
|
| 42 | + * this indicates to keep any existing dependencies that already exist, |
|
| 43 | + * and simply discard any new dependencies declared in the incoming data |
|
| 44 | + */ |
|
| 45 | + const KEEP_EXISTING_DEPENDENCIES = 0; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * When registering a dependency, |
|
| 49 | + * this indicates to overwrite any existing dependencies that already exist using the incoming data |
|
| 50 | + */ |
|
| 51 | + const OVERWRITE_DEPENDENCIES = 1; |
|
| 52 | + |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * @type EE_Dependency_Map $_instance |
|
| 56 | + */ |
|
| 57 | + protected static $_instance; |
|
| 58 | + |
|
| 59 | + /** |
|
| 60 | + * @var ClassInterfaceCache $class_cache |
|
| 61 | + */ |
|
| 62 | + private $class_cache; |
|
| 63 | + |
|
| 64 | + /** |
|
| 65 | + * @type RequestInterface $request |
|
| 66 | + */ |
|
| 67 | + protected $request; |
|
| 68 | + |
|
| 69 | + /** |
|
| 70 | + * @type LegacyRequestInterface $legacy_request |
|
| 71 | + */ |
|
| 72 | + protected $legacy_request; |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @type ResponseInterface $response |
|
| 76 | + */ |
|
| 77 | + protected $response; |
|
| 78 | + |
|
| 79 | + /** |
|
| 80 | + * @type LoaderInterface $loader |
|
| 81 | + */ |
|
| 82 | + protected $loader; |
|
| 83 | + |
|
| 84 | + /** |
|
| 85 | + * @type array $_dependency_map |
|
| 86 | + */ |
|
| 87 | + protected $_dependency_map = array(); |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @type array $_class_loaders |
|
| 91 | + */ |
|
| 92 | + protected $_class_loaders = array(); |
|
| 93 | + |
|
| 94 | + |
|
| 95 | + /** |
|
| 96 | + * EE_Dependency_Map constructor. |
|
| 97 | + * |
|
| 98 | + * @param ClassInterfaceCache $class_cache |
|
| 99 | + */ |
|
| 100 | + protected function __construct(ClassInterfaceCache $class_cache) |
|
| 101 | + { |
|
| 102 | + $this->class_cache = $class_cache; |
|
| 103 | + do_action('EE_Dependency_Map____construct', $this); |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + |
|
| 107 | + /** |
|
| 108 | + * @return void |
|
| 109 | + * @throws EE_Error |
|
| 110 | + * @throws InvalidAliasException |
|
| 111 | + */ |
|
| 112 | + public function initialize() |
|
| 113 | + { |
|
| 114 | + $this->_register_core_dependencies(); |
|
| 115 | + $this->_register_core_class_loaders(); |
|
| 116 | + $this->_register_core_aliases(); |
|
| 117 | + } |
|
| 118 | + |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * @singleton method used to instantiate class object |
|
| 122 | + * @param ClassInterfaceCache|null $class_cache |
|
| 123 | + * @return EE_Dependency_Map |
|
| 124 | + */ |
|
| 125 | + public static function instance(ClassInterfaceCache $class_cache = null) |
|
| 126 | + { |
|
| 127 | + // check if class object is instantiated, and instantiated properly |
|
| 128 | + if (! self::$_instance instanceof EE_Dependency_Map |
|
| 129 | + && $class_cache instanceof ClassInterfaceCache |
|
| 130 | + ) { |
|
| 131 | + self::$_instance = new EE_Dependency_Map($class_cache); |
|
| 132 | + } |
|
| 133 | + return self::$_instance; |
|
| 134 | + } |
|
| 135 | + |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * @param RequestInterface $request |
|
| 139 | + */ |
|
| 140 | + public function setRequest(RequestInterface $request) |
|
| 141 | + { |
|
| 142 | + $this->request = $request; |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + |
|
| 146 | + /** |
|
| 147 | + * @param LegacyRequestInterface $legacy_request |
|
| 148 | + */ |
|
| 149 | + public function setLegacyRequest(LegacyRequestInterface $legacy_request) |
|
| 150 | + { |
|
| 151 | + $this->legacy_request = $legacy_request; |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + |
|
| 155 | + /** |
|
| 156 | + * @param ResponseInterface $response |
|
| 157 | + */ |
|
| 158 | + public function setResponse(ResponseInterface $response) |
|
| 159 | + { |
|
| 160 | + $this->response = $response; |
|
| 161 | + } |
|
| 162 | + |
|
| 163 | + |
|
| 164 | + /** |
|
| 165 | + * @param LoaderInterface $loader |
|
| 166 | + */ |
|
| 167 | + public function setLoader(LoaderInterface $loader) |
|
| 168 | + { |
|
| 169 | + $this->loader = $loader; |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + |
|
| 173 | + /** |
|
| 174 | + * @param string $class |
|
| 175 | + * @param array $dependencies |
|
| 176 | + * @param int $overwrite |
|
| 177 | + * @return bool |
|
| 178 | + */ |
|
| 179 | + public static function register_dependencies( |
|
| 180 | + $class, |
|
| 181 | + array $dependencies, |
|
| 182 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 183 | + ) { |
|
| 184 | + return self::$_instance->registerDependencies($class, $dependencies, $overwrite); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Assigns an array of class names and corresponding load sources (new or cached) |
|
| 190 | + * to the class specified by the first parameter. |
|
| 191 | + * IMPORTANT !!! |
|
| 192 | + * The order of elements in the incoming $dependencies array MUST match |
|
| 193 | + * the order of the constructor parameters for the class in question. |
|
| 194 | + * This is especially important when overriding any existing dependencies that are registered. |
|
| 195 | + * the third parameter controls whether any duplicate dependencies are overwritten or not. |
|
| 196 | + * |
|
| 197 | + * @param string $class |
|
| 198 | + * @param array $dependencies |
|
| 199 | + * @param int $overwrite |
|
| 200 | + * @return bool |
|
| 201 | + */ |
|
| 202 | + public function registerDependencies( |
|
| 203 | + $class, |
|
| 204 | + array $dependencies, |
|
| 205 | + $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES |
|
| 206 | + ) { |
|
| 207 | + $class = trim($class, '\\'); |
|
| 208 | + $registered = false; |
|
| 209 | + if (empty(self::$_instance->_dependency_map[ $class ])) { |
|
| 210 | + self::$_instance->_dependency_map[ $class ] = array(); |
|
| 211 | + } |
|
| 212 | + // we need to make sure that any aliases used when registering a dependency |
|
| 213 | + // get resolved to the correct class name |
|
| 214 | + foreach ($dependencies as $dependency => $load_source) { |
|
| 215 | + $alias = self::$_instance->getFqnForAlias($dependency); |
|
| 216 | + if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES |
|
| 217 | + || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ]) |
|
| 218 | + ) { |
|
| 219 | + unset($dependencies[ $dependency ]); |
|
| 220 | + $dependencies[ $alias ] = $load_source; |
|
| 221 | + $registered = true; |
|
| 222 | + } |
|
| 223 | + } |
|
| 224 | + // now add our two lists of dependencies together. |
|
| 225 | + // using Union (+=) favours the arrays in precedence from left to right, |
|
| 226 | + // so $dependencies is NOT overwritten because it is listed first |
|
| 227 | + // ie: with A = B + C, entries in B take precedence over duplicate entries in C |
|
| 228 | + // Union is way faster than array_merge() but should be used with caution... |
|
| 229 | + // especially with numerically indexed arrays |
|
| 230 | + $dependencies += self::$_instance->_dependency_map[ $class ]; |
|
| 231 | + // now we need to ensure that the resulting dependencies |
|
| 232 | + // array only has the entries that are required for the class |
|
| 233 | + // so first count how many dependencies were originally registered for the class |
|
| 234 | + $dependency_count = count(self::$_instance->_dependency_map[ $class ]); |
|
| 235 | + // if that count is non-zero (meaning dependencies were already registered) |
|
| 236 | + self::$_instance->_dependency_map[ $class ] = $dependency_count |
|
| 237 | + // then truncate the final array to match that count |
|
| 238 | + ? array_slice($dependencies, 0, $dependency_count) |
|
| 239 | + // otherwise just take the incoming array because nothing previously existed |
|
| 240 | + : $dependencies; |
|
| 241 | + return $registered; |
|
| 242 | + } |
|
| 243 | + |
|
| 244 | + |
|
| 245 | + /** |
|
| 246 | + * @param string $class_name |
|
| 247 | + * @param string $loader |
|
| 248 | + * @return bool |
|
| 249 | + * @throws DomainException |
|
| 250 | + */ |
|
| 251 | + public static function register_class_loader($class_name, $loader = 'load_core') |
|
| 252 | + { |
|
| 253 | + if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) { |
|
| 254 | + throw new DomainException( |
|
| 255 | + esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso') |
|
| 256 | + ); |
|
| 257 | + } |
|
| 258 | + // check that loader is callable or method starts with "load_" and exists in EE_Registry |
|
| 259 | + if (! is_callable($loader) |
|
| 260 | + && ( |
|
| 261 | + strpos($loader, 'load_') !== 0 |
|
| 262 | + || ! method_exists('EE_Registry', $loader) |
|
| 263 | + ) |
|
| 264 | + ) { |
|
| 265 | + throw new DomainException( |
|
| 266 | + sprintf( |
|
| 267 | + esc_html__( |
|
| 268 | + '"%1$s" is not a valid loader method on EE_Registry.', |
|
| 269 | + 'event_espresso' |
|
| 270 | + ), |
|
| 271 | + $loader |
|
| 272 | + ) |
|
| 273 | + ); |
|
| 274 | + } |
|
| 275 | + $class_name = self::$_instance->getFqnForAlias($class_name); |
|
| 276 | + if (! isset(self::$_instance->_class_loaders[ $class_name ])) { |
|
| 277 | + self::$_instance->_class_loaders[ $class_name ] = $loader; |
|
| 278 | + return true; |
|
| 279 | + } |
|
| 280 | + return false; |
|
| 281 | + } |
|
| 282 | + |
|
| 283 | + |
|
| 284 | + /** |
|
| 285 | + * @return array |
|
| 286 | + */ |
|
| 287 | + public function dependency_map() |
|
| 288 | + { |
|
| 289 | + return $this->_dependency_map; |
|
| 290 | + } |
|
| 291 | + |
|
| 292 | + |
|
| 293 | + /** |
|
| 294 | + * returns TRUE if dependency map contains a listing for the provided class name |
|
| 295 | + * |
|
| 296 | + * @param string $class_name |
|
| 297 | + * @return boolean |
|
| 298 | + */ |
|
| 299 | + public function has($class_name = '') |
|
| 300 | + { |
|
| 301 | + // all legacy models have the same dependencies |
|
| 302 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 303 | + $class_name = 'LEGACY_MODELS'; |
|
| 304 | + } |
|
| 305 | + return isset($this->_dependency_map[ $class_name ]) ? true : false; |
|
| 306 | + } |
|
| 307 | + |
|
| 308 | + |
|
| 309 | + /** |
|
| 310 | + * returns TRUE if dependency map contains a listing for the provided class name AND dependency |
|
| 311 | + * |
|
| 312 | + * @param string $class_name |
|
| 313 | + * @param string $dependency |
|
| 314 | + * @return bool |
|
| 315 | + */ |
|
| 316 | + public function has_dependency_for_class($class_name = '', $dependency = '') |
|
| 317 | + { |
|
| 318 | + // all legacy models have the same dependencies |
|
| 319 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 320 | + $class_name = 'LEGACY_MODELS'; |
|
| 321 | + } |
|
| 322 | + $dependency = $this->getFqnForAlias($dependency, $class_name); |
|
| 323 | + return isset($this->_dependency_map[ $class_name ][ $dependency ]) |
|
| 324 | + ? true |
|
| 325 | + : false; |
|
| 326 | + } |
|
| 327 | + |
|
| 328 | + |
|
| 329 | + /** |
|
| 330 | + * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned |
|
| 331 | + * |
|
| 332 | + * @param string $class_name |
|
| 333 | + * @param string $dependency |
|
| 334 | + * @return int |
|
| 335 | + */ |
|
| 336 | + public function loading_strategy_for_class_dependency($class_name = '', $dependency = '') |
|
| 337 | + { |
|
| 338 | + // all legacy models have the same dependencies |
|
| 339 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 340 | + $class_name = 'LEGACY_MODELS'; |
|
| 341 | + } |
|
| 342 | + $dependency = $this->getFqnForAlias($dependency); |
|
| 343 | + return $this->has_dependency_for_class($class_name, $dependency) |
|
| 344 | + ? $this->_dependency_map[ $class_name ][ $dependency ] |
|
| 345 | + : EE_Dependency_Map::not_registered; |
|
| 346 | + } |
|
| 347 | + |
|
| 348 | + |
|
| 349 | + /** |
|
| 350 | + * @param string $class_name |
|
| 351 | + * @return string | Closure |
|
| 352 | + */ |
|
| 353 | + public function class_loader($class_name) |
|
| 354 | + { |
|
| 355 | + // all legacy models use load_model() |
|
| 356 | + if (strpos($class_name, 'EEM_') === 0) { |
|
| 357 | + return 'load_model'; |
|
| 358 | + } |
|
| 359 | + // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc |
|
| 360 | + // perform strpos() first to avoid loading regex every time we load a class |
|
| 361 | + if (strpos($class_name, 'EE_CPT_') === 0 |
|
| 362 | + && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name) |
|
| 363 | + ) { |
|
| 364 | + return 'load_core'; |
|
| 365 | + } |
|
| 366 | + $class_name = $this->getFqnForAlias($class_name); |
|
| 367 | + return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : ''; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + |
|
| 371 | + /** |
|
| 372 | + * @return array |
|
| 373 | + */ |
|
| 374 | + public function class_loaders() |
|
| 375 | + { |
|
| 376 | + return $this->_class_loaders; |
|
| 377 | + } |
|
| 378 | + |
|
| 379 | + |
|
| 380 | + /** |
|
| 381 | + * adds an alias for a classname |
|
| 382 | + * |
|
| 383 | + * @param string $fqcn the class name that should be used (concrete class to replace interface) |
|
| 384 | + * @param string $alias the class name that would be type hinted for (abstract parent or interface) |
|
| 385 | + * @param string $for_class the class that has the dependency (is type hinting for the interface) |
|
| 386 | + * @throws InvalidAliasException |
|
| 387 | + */ |
|
| 388 | + public function add_alias($fqcn, $alias, $for_class = '') |
|
| 389 | + { |
|
| 390 | + $this->class_cache->addAlias($fqcn, $alias, $for_class); |
|
| 391 | + } |
|
| 392 | + |
|
| 393 | + |
|
| 394 | + /** |
|
| 395 | + * Returns TRUE if the provided fully qualified name IS an alias |
|
| 396 | + * WHY? |
|
| 397 | + * Because if a class is type hinting for a concretion, |
|
| 398 | + * then why would we need to find another class to supply it? |
|
| 399 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 400 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 401 | + * Don't go looking for some substitute. |
|
| 402 | + * Whereas if a class is type hinting for an interface... |
|
| 403 | + * then we need to find an actual class to use. |
|
| 404 | + * So the interface IS the alias for some other FQN, |
|
| 405 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 406 | + * represents some other class. |
|
| 407 | + * |
|
| 408 | + * @param string $fqn |
|
| 409 | + * @param string $for_class |
|
| 410 | + * @return bool |
|
| 411 | + */ |
|
| 412 | + public function isAlias($fqn = '', $for_class = '') |
|
| 413 | + { |
|
| 414 | + return $this->class_cache->isAlias($fqn, $for_class); |
|
| 415 | + } |
|
| 416 | + |
|
| 417 | + |
|
| 418 | + /** |
|
| 419 | + * Returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 420 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 421 | + * for example: |
|
| 422 | + * if the following two entries were added to the _aliases array: |
|
| 423 | + * array( |
|
| 424 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 425 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 426 | + * ) |
|
| 427 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 428 | + * to load an instance of 'some\namespace\classname' |
|
| 429 | + * |
|
| 430 | + * @param string $alias |
|
| 431 | + * @param string $for_class |
|
| 432 | + * @return string |
|
| 433 | + */ |
|
| 434 | + public function getFqnForAlias($alias = '', $for_class = '') |
|
| 435 | + { |
|
| 436 | + return (string) $this->class_cache->getFqnForAlias($alias, $for_class); |
|
| 437 | + } |
|
| 438 | + |
|
| 439 | + |
|
| 440 | + /** |
|
| 441 | + * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache, |
|
| 442 | + * if one exists, or whether a new object should be generated every time the requested class is loaded. |
|
| 443 | + * This is done by using the following class constants: |
|
| 444 | + * EE_Dependency_Map::load_from_cache - loads previously instantiated object |
|
| 445 | + * EE_Dependency_Map::load_new_object - generates a new object every time |
|
| 446 | + */ |
|
| 447 | + protected function _register_core_dependencies() |
|
| 448 | + { |
|
| 449 | + $this->_dependency_map = array( |
|
| 450 | + 'EE_Request_Handler' => array( |
|
| 451 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 452 | + ), |
|
| 453 | + 'EE_System' => array( |
|
| 454 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 455 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 456 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 457 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 458 | + ), |
|
| 459 | + 'EE_Session' => array( |
|
| 460 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 461 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 462 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 463 | + 'EventEspresso\core\services\session\SessionStartHandler' => EE_Dependency_Map::load_from_cache, |
|
| 464 | + 'EE_Encryption' => EE_Dependency_Map::load_from_cache, |
|
| 465 | + ), |
|
| 466 | + 'EE_Cart' => array( |
|
| 467 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 468 | + ), |
|
| 469 | + 'EE_Front_Controller' => array( |
|
| 470 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 471 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 472 | + 'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache, |
|
| 473 | + ), |
|
| 474 | + 'EE_Messenger_Collection_Loader' => array( |
|
| 475 | + 'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object, |
|
| 476 | + ), |
|
| 477 | + 'EE_Message_Type_Collection_Loader' => array( |
|
| 478 | + 'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object, |
|
| 479 | + ), |
|
| 480 | + 'EE_Message_Resource_Manager' => array( |
|
| 481 | + 'EE_Messenger_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 482 | + 'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object, |
|
| 483 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 484 | + ), |
|
| 485 | + 'EE_Message_Factory' => array( |
|
| 486 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 487 | + ), |
|
| 488 | + 'EE_messages' => array( |
|
| 489 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 490 | + ), |
|
| 491 | + 'EE_Messages_Generator' => array( |
|
| 492 | + 'EE_Messages_Queue' => EE_Dependency_Map::load_new_object, |
|
| 493 | + 'EE_Messages_Data_Handler_Collection' => EE_Dependency_Map::load_new_object, |
|
| 494 | + 'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object, |
|
| 495 | + 'EEH_Parse_Shortcodes' => EE_Dependency_Map::load_from_cache, |
|
| 496 | + ), |
|
| 497 | + 'EE_Messages_Processor' => array( |
|
| 498 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 499 | + ), |
|
| 500 | + 'EE_Messages_Queue' => array( |
|
| 501 | + 'EE_Message_Repository' => EE_Dependency_Map::load_new_object, |
|
| 502 | + ), |
|
| 503 | + 'EE_Messages_Template_Defaults' => array( |
|
| 504 | + 'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache, |
|
| 505 | + 'EEM_Message_Template' => EE_Dependency_Map::load_from_cache, |
|
| 506 | + ), |
|
| 507 | + 'EE_Message_To_Generate_From_Request' => array( |
|
| 508 | + 'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache, |
|
| 509 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 510 | + ), |
|
| 511 | + 'EventEspresso\core\services\commands\CommandBus' => array( |
|
| 512 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache, |
|
| 513 | + ), |
|
| 514 | + 'EventEspresso\services\commands\CommandHandler' => array( |
|
| 515 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 516 | + 'CommandBusInterface' => EE_Dependency_Map::load_from_cache, |
|
| 517 | + ), |
|
| 518 | + 'EventEspresso\core\services\commands\CommandHandlerManager' => array( |
|
| 519 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 520 | + ), |
|
| 521 | + 'EventEspresso\core\services\commands\CompositeCommandHandler' => array( |
|
| 522 | + 'EventEspresso\core\services\commands\CommandBus' => EE_Dependency_Map::load_from_cache, |
|
| 523 | + 'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache, |
|
| 524 | + ), |
|
| 525 | + 'EventEspresso\core\services\commands\CommandFactory' => array( |
|
| 526 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 527 | + ), |
|
| 528 | + 'EventEspresso\core\services\commands\middleware\CapChecker' => array( |
|
| 529 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 530 | + ), |
|
| 531 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => array( |
|
| 532 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 533 | + ), |
|
| 534 | + 'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker' => array( |
|
| 535 | + 'EE_Capabilities' => EE_Dependency_Map::load_from_cache, |
|
| 536 | + ), |
|
| 537 | + 'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler' => array( |
|
| 538 | + 'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 539 | + ), |
|
| 540 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler' => array( |
|
| 541 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 542 | + ), |
|
| 543 | + 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler' => array( |
|
| 544 | + 'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 545 | + ), |
|
| 546 | + 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler' => array( |
|
| 547 | + 'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 548 | + ), |
|
| 549 | + 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array( |
|
| 550 | + 'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache, |
|
| 551 | + ), |
|
| 552 | + 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler' => array( |
|
| 553 | + 'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 554 | + ), |
|
| 555 | + 'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler' => array( |
|
| 556 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 557 | + ), |
|
| 558 | + 'EventEspresso\core\domain\services\registration\CancelRegistrationService' => array( |
|
| 559 | + 'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache, |
|
| 560 | + ), |
|
| 561 | + 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler' => array( |
|
| 562 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 563 | + ), |
|
| 564 | + 'EventEspresso\core\services\database\TableManager' => array( |
|
| 565 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 566 | + ), |
|
| 567 | + 'EE_Data_Migration_Class_Base' => array( |
|
| 568 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 569 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 570 | + ), |
|
| 571 | + 'EE_DMS_Core_4_1_0' => array( |
|
| 572 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 573 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 574 | + ), |
|
| 575 | + 'EE_DMS_Core_4_2_0' => array( |
|
| 576 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 577 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 578 | + ), |
|
| 579 | + 'EE_DMS_Core_4_3_0' => array( |
|
| 580 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 581 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 582 | + ), |
|
| 583 | + 'EE_DMS_Core_4_4_0' => array( |
|
| 584 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 585 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 586 | + ), |
|
| 587 | + 'EE_DMS_Core_4_5_0' => array( |
|
| 588 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 589 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 590 | + ), |
|
| 591 | + 'EE_DMS_Core_4_6_0' => array( |
|
| 592 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 593 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 594 | + ), |
|
| 595 | + 'EE_DMS_Core_4_7_0' => array( |
|
| 596 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 597 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 598 | + ), |
|
| 599 | + 'EE_DMS_Core_4_8_0' => array( |
|
| 600 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 601 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 602 | + ), |
|
| 603 | + 'EE_DMS_Core_4_9_0' => array( |
|
| 604 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 605 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 606 | + ), |
|
| 607 | + 'EE_DMS_Core_4_10_0' => array( |
|
| 608 | + 'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache, |
|
| 609 | + 'EventEspresso\core\services\database\TableManager' => EE_Dependency_Map::load_from_cache, |
|
| 610 | + 'EE_DMS_Core_4_9_0' => EE_Dependency_Map::load_from_cache, |
|
| 611 | + ), |
|
| 612 | + 'EventEspresso\core\services\assets\I18nRegistry' => array( |
|
| 613 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 614 | + 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 615 | + array(), |
|
| 616 | + ), |
|
| 617 | + 'EventEspresso\core\services\assets\Registry' => array( |
|
| 618 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 619 | + 'EventEspresso\core\services\assets\I18nRegistry' => EE_Dependency_Map::load_from_cache, |
|
| 620 | + ), |
|
| 621 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled' => array( |
|
| 622 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 623 | + ), |
|
| 624 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout' => array( |
|
| 625 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 626 | + ), |
|
| 627 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees' => array( |
|
| 628 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 629 | + ), |
|
| 630 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoEvents' => array( |
|
| 631 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 632 | + ), |
|
| 633 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou' => array( |
|
| 634 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 635 | + ), |
|
| 636 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector' => array( |
|
| 637 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 638 | + ), |
|
| 639 | + 'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage' => array( |
|
| 640 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache, |
|
| 641 | + ), |
|
| 642 | + 'EventEspresso\core\services\cache\BasicCacheManager' => array( |
|
| 643 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 644 | + ), |
|
| 645 | + 'EventEspresso\core\services\cache\PostRelatedCacheManager' => array( |
|
| 646 | + 'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache, |
|
| 647 | + ), |
|
| 648 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array( |
|
| 649 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 650 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 651 | + ), |
|
| 652 | + 'EventEspresso\core\domain\values\EmailAddress' => array( |
|
| 653 | + null, |
|
| 654 | + 'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache, |
|
| 655 | + ), |
|
| 656 | + 'EventEspresso\core\services\orm\ModelFieldFactory' => array( |
|
| 657 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 658 | + ), |
|
| 659 | + 'LEGACY_MODELS' => array( |
|
| 660 | + null, |
|
| 661 | + 'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache, |
|
| 662 | + ), |
|
| 663 | + 'EE_Module_Request_Router' => array( |
|
| 664 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 665 | + ), |
|
| 666 | + 'EE_Registration_Processor' => array( |
|
| 667 | + 'EE_Request' => EE_Dependency_Map::load_from_cache, |
|
| 668 | + ), |
|
| 669 | + 'EventEspresso\core\services\notifications\PersistentAdminNoticeManager' => array( |
|
| 670 | + null, |
|
| 671 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache, |
|
| 672 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 673 | + ), |
|
| 674 | + 'EventEspresso\core\services\licensing\LicenseService' => array( |
|
| 675 | + 'EventEspresso\core\domain\services\pue\Stats' => EE_Dependency_Map::load_from_cache, |
|
| 676 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
| 677 | + ), |
|
| 678 | + 'EE_Admin_Transactions_List_Table' => array( |
|
| 679 | + null, |
|
| 680 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache, |
|
| 681 | + ), |
|
| 682 | + 'EventEspresso\core\domain\services\pue\Stats' => array( |
|
| 683 | + 'EventEspresso\core\domain\services\pue\Config' => EE_Dependency_Map::load_from_cache, |
|
| 684 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 685 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => EE_Dependency_Map::load_from_cache, |
|
| 686 | + ), |
|
| 687 | + 'EventEspresso\core\domain\services\pue\Config' => array( |
|
| 688 | + 'EE_Network_Config' => EE_Dependency_Map::load_from_cache, |
|
| 689 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
| 690 | + ), |
|
| 691 | + 'EventEspresso\core\domain\services\pue\StatsGatherer' => array( |
|
| 692 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
| 693 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 694 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 695 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 696 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 697 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
| 698 | + 'EE_Config' => EE_Dependency_Map::load_from_cache, |
|
| 699 | + ), |
|
| 700 | + 'EventEspresso\core\domain\services\admin\ExitModal' => array( |
|
| 701 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 702 | + ), |
|
| 703 | + 'EventEspresso\core\domain\services\admin\PluginUpsells' => array( |
|
| 704 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 705 | + ), |
|
| 706 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha' => array( |
|
| 707 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 708 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 709 | + ), |
|
| 710 | + 'EventEspresso\caffeinated\modules\recaptcha_invisible\RecaptchaAdminSettings' => array( |
|
| 711 | + 'EE_Registration_Config' => EE_Dependency_Map::load_from_cache, |
|
| 712 | + ), |
|
| 713 | + 'EventEspresso\modules\ticket_selector\ProcessTicketSelector' => array( |
|
| 714 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 715 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 716 | + 'EE_Session' => EE_Dependency_Map::load_from_cache, |
|
| 717 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 718 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache, |
|
| 719 | + ), |
|
| 720 | + 'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => array( |
|
| 721 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 722 | + ), |
|
| 723 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => array( |
|
| 724 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 725 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 726 | + ), |
|
| 727 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes' => array( |
|
| 728 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 729 | + ), |
|
| 730 | + 'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies' => array( |
|
| 731 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 732 | + ), |
|
| 733 | + 'EE_CPT_Strategy' => array( |
|
| 734 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 735 | + 'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache, |
|
| 736 | + ), |
|
| 737 | + 'EventEspresso\core\services\loaders\ObjectIdentifier' => array( |
|
| 738 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 739 | + ), |
|
| 740 | + 'EventEspresso\core\domain\services\assets\CoreAssetManager' => array( |
|
| 741 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 742 | + 'EE_Currency_Config' => EE_Dependency_Map::load_from_cache, |
|
| 743 | + 'EE_Template_Config' => EE_Dependency_Map::load_from_cache, |
|
| 744 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 745 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 746 | + ), |
|
| 747 | + 'EventEspresso\core\domain\services\admin\privacy\policy\PrivacyPolicy' => array( |
|
| 748 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache, |
|
| 749 | + 'EventEspresso\core\domain\values\session\SessionLifespan' => EE_Dependency_Map::load_from_cache |
|
| 750 | + ), |
|
| 751 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendee' => array( |
|
| 752 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 753 | + ), |
|
| 754 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportAttendeeBillingData' => array( |
|
| 755 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 756 | + 'EEM_Payment_Method' => EE_Dependency_Map::load_from_cache |
|
| 757 | + ), |
|
| 758 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportCheckins' => array( |
|
| 759 | + 'EEM_Checkin' => EE_Dependency_Map::load_from_cache, |
|
| 760 | + ), |
|
| 761 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportRegistration' => array( |
|
| 762 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 763 | + ), |
|
| 764 | + 'EventEspresso\core\domain\services\admin\privacy\export\ExportTransaction' => array( |
|
| 765 | + 'EEM_Transaction' => EE_Dependency_Map::load_from_cache, |
|
| 766 | + ), |
|
| 767 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAttendeeData' => array( |
|
| 768 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 769 | + ), |
|
| 770 | + 'EventEspresso\core\domain\services\admin\privacy\erasure\EraseAnswers' => array( |
|
| 771 | + 'EEM_Answer' => EE_Dependency_Map::load_from_cache, |
|
| 772 | + 'EEM_Question' => EE_Dependency_Map::load_from_cache, |
|
| 773 | + ), |
|
| 774 | + 'EventEspresso\core\CPTs\CptQueryModifier' => array( |
|
| 775 | + null, |
|
| 776 | + null, |
|
| 777 | + null, |
|
| 778 | + 'EE_Request_Handler' => EE_Dependency_Map::load_from_cache, |
|
| 779 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 780 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 781 | + ), |
|
| 782 | + 'EventEspresso\core\domain\services\admin\privacy\forms\PrivacySettingsFormHandler' => array( |
|
| 783 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 784 | + 'EE_Config' => EE_Dependency_Map::load_from_cache |
|
| 785 | + ), |
|
| 786 | + 'EventEspresso\core\services\editor\BlockRegistrationManager' => array( |
|
| 787 | + 'EventEspresso\core\services\assets\BlockAssetManagerCollection' => EE_Dependency_Map::load_from_cache, |
|
| 788 | + 'EventEspresso\core\domain\entities\editor\BlockCollection' => EE_Dependency_Map::load_from_cache, |
|
| 789 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
| 790 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 791 | + ), |
|
| 792 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => array( |
|
| 793 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 794 | + 'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache, |
|
| 795 | + 'EventEspresso\core\services\assets\Registry' => EE_Dependency_Map::load_from_cache, |
|
| 796 | + ), |
|
| 797 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => array( |
|
| 798 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 799 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 800 | + ), |
|
| 801 | + 'EventEspresso\core\domain\entities\editor\blocks\EventAttendees' => array( |
|
| 802 | + 'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager' => self::load_from_cache, |
|
| 803 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 804 | + 'EventEspresso\core\domain\services\blocks\EventAttendeesBlockRenderer' => self::load_from_cache, |
|
| 805 | + ), |
|
| 806 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => array( |
|
| 807 | + 'EventEspresso\core\services\container\Mirror' => EE_Dependency_Map::load_from_cache, |
|
| 808 | + 'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache, |
|
| 809 | + 'EE_Dependency_Map' => EE_Dependency_Map::load_from_cache, |
|
| 810 | + ), |
|
| 811 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => array( |
|
| 812 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache, |
|
| 813 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 814 | + ), |
|
| 815 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => array( |
|
| 816 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache, |
|
| 817 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationFactory' => EE_Dependency_Map::load_from_cache, |
|
| 818 | + ), |
|
| 819 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => array( |
|
| 820 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => EE_Dependency_Map::load_from_cache |
|
| 821 | + ), |
|
| 822 | + 'EventEspresso\core\libraries\rest_api\calculations\CalculatedModelFieldsFactory' => array( |
|
| 823 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 824 | + ), |
|
| 825 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => array( |
|
| 826 | + 'EventEspresso\core\libraries\rest_api\CalculatedModelFields' => EE_Dependency_Map::load_from_cache |
|
| 827 | + ), |
|
| 828 | + 'EventEspresso\core\libraries\rest_api\calculations\Datetime' => array( |
|
| 829 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 830 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 831 | + ), |
|
| 832 | + 'EventEspresso\core\libraries\rest_api\calculations\Event' => array( |
|
| 833 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 834 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 835 | + ), |
|
| 836 | + 'EventEspresso\core\libraries\rest_api\calculations\Registration' => array( |
|
| 837 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache |
|
| 838 | + ), |
|
| 839 | + 'EventEspresso\core\services\session\SessionStartHandler' => array( |
|
| 840 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 841 | + ), |
|
| 842 | + 'EE_URL_Validation_Strategy' => array( |
|
| 843 | + null, |
|
| 844 | + null, |
|
| 845 | + 'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache |
|
| 846 | + ), |
|
| 847 | + 'EventEspresso\admin_pages\general_settings\OrganizationSettings' => array( |
|
| 848 | + 'EE_Registry' => EE_Dependency_Map::load_from_cache, |
|
| 849 | + 'EE_Organization_Config' => EE_Dependency_Map::load_from_cache, |
|
| 850 | + 'EE_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 851 | + 'EE_Network_Core_Config' => EE_Dependency_Map::load_from_cache, |
|
| 852 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => EE_Dependency_Map::load_from_cache, |
|
| 853 | + ), |
|
| 854 | + 'EventEspresso\core\services\address\CountrySubRegionDao' => array( |
|
| 855 | + 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
| 856 | + 'EventEspresso\core\services\validators\JsonValidator' => EE_Dependency_Map::load_from_cache |
|
| 857 | + ), |
|
| 858 | + 'EventEspresso\core\domain\services\admin\ajax\WordpressHeartbeat' => array( |
|
| 859 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 860 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 861 | + ), |
|
| 862 | + 'EventEspresso\core\domain\services\admin\ajax\EventEditorHeartbeat' => array( |
|
| 863 | + 'EventEspresso\core\domain\Domain' => EE_Dependency_Map::load_from_cache, |
|
| 864 | + 'EE_Environment_Config' => EE_Dependency_Map::load_from_cache, |
|
| 865 | + ), |
|
| 866 | + 'EventEspresso\core\services\request\files\FilesDataHandler' => array( |
|
| 867 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 868 | + ), |
|
| 869 | + 'EventEspressoBatchRequest\BatchRequestProcessor' => [ |
|
| 870 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 871 | + ], |
|
| 872 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\QueryBuilder' => [ |
|
| 873 | + null, |
|
| 874 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 875 | + 'EEM_Registration' => EE_Dependency_Map::load_from_cache, |
|
| 876 | + ], |
|
| 877 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\AttendeeFilterHeader' => [ |
|
| 878 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 879 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 880 | + ], |
|
| 881 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\DateFilterHeader' => [ |
|
| 882 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 883 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 884 | + ], |
|
| 885 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\EventFilterHeader' => [ |
|
| 886 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 887 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 888 | + ], |
|
| 889 | + 'EventEspresso\core\domain\services\admin\registrations\list_table\page_header\TicketFilterHeader' => [ |
|
| 890 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 891 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 892 | + ], |
|
| 893 | + 'EventEspresso\core\domain\services\converters\RestApiSpoofer' => [ |
|
| 894 | + 'WP_REST_Server' => EE_Dependency_Map::load_from_cache, |
|
| 895 | + 'EED_Core_Rest_Api' => EE_Dependency_Map::load_from_cache, |
|
| 896 | + 'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache, |
|
| 897 | + null |
|
| 898 | + ], |
|
| 899 | + 'EventEspresso\core\domain\services\admin\events\default_settings\AdvancedEditorAdminFormSection' => [ |
|
| 900 | + 'EE_Admin_Config' => EE_Dependency_Map::load_from_cache |
|
| 901 | + ], |
|
| 902 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditor' => [ |
|
| 903 | + 'EE_Admin_Config' => EE_Dependency_Map::load_from_cache, |
|
| 904 | + 'EE_Event' => EE_Dependency_Map::not_registered, |
|
| 905 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\CurrentUser' => |
|
| 906 | + EE_Dependency_Map::not_registered, |
|
| 907 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => |
|
| 908 | + EE_Dependency_Map::load_from_cache, |
|
| 909 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\GeneralSettings' => |
|
| 910 | + EE_Dependency_Map::load_from_cache, |
|
| 911 | + 'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache, |
|
| 912 | + ], |
|
| 913 | + 'EventEspresso\core\services\graphql\GraphQLManager' => [ |
|
| 914 | + 'EventEspresso\core\services\graphql\TypesManager' => EE_Dependency_Map::load_from_cache, |
|
| 915 | + 'EventEspresso\core\services\graphql\InputsManager' => EE_Dependency_Map::load_from_cache, |
|
| 916 | + 'EventEspresso\core\services\graphql\EnumsManager' => EE_Dependency_Map::load_from_cache, |
|
| 917 | + 'EventEspresso\core\services\graphql\ConnectionsManager' => EE_Dependency_Map::load_from_cache, |
|
| 918 | + ], |
|
| 919 | + 'EventEspresso\core\services\graphql\TypesManager' => [ |
|
| 920 | + 'EventEspresso\core\services\graphql\types\TypeCollection' => EE_Dependency_Map::load_from_cache, |
|
| 921 | + ], |
|
| 922 | + 'EventEspresso\core\services\graphql\InputsManager' => [ |
|
| 923 | + 'EventEspresso\core\services\graphql\inputs\InputCollection' => EE_Dependency_Map::load_from_cache, |
|
| 924 | + ], |
|
| 925 | + 'EventEspresso\core\services\graphql\EnumsManager' => [ |
|
| 926 | + 'EventEspresso\core\services\graphql\enums\EnumCollection' => EE_Dependency_Map::load_from_cache, |
|
| 927 | + ], |
|
| 928 | + 'EventEspresso\core\services\graphql\ConnectionsManager' => [ |
|
| 929 | + 'EventEspresso\core\services\graphql\connections\ConnectionCollection' => EE_Dependency_Map::load_from_cache, |
|
| 930 | + ], |
|
| 931 | + 'EventEspresso\core\domain\services\graphql\types\Datetime' => [ |
|
| 932 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 933 | + ], |
|
| 934 | + 'EventEspresso\core\domain\services\graphql\types\Attendee' => [ |
|
| 935 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 936 | + ], |
|
| 937 | + 'EventEspresso\core\domain\services\graphql\types\Event' => [ |
|
| 938 | + 'EEM_Event' => EE_Dependency_Map::load_from_cache, |
|
| 939 | + ], |
|
| 940 | + 'EventEspresso\core\domain\services\graphql\types\Ticket' => [ |
|
| 941 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 942 | + ], |
|
| 943 | + 'EventEspresso\core\domain\services\graphql\types\Price' => [ |
|
| 944 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 945 | + ], |
|
| 946 | + 'EventEspresso\core\domain\services\graphql\types\PriceType' => [ |
|
| 947 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 948 | + ], |
|
| 949 | + 'EventEspresso\core\domain\services\graphql\types\Venue' => [ |
|
| 950 | + 'EEM_Venue' => EE_Dependency_Map::load_from_cache, |
|
| 951 | + ], |
|
| 952 | + 'EventEspresso\core\domain\services\graphql\types\State' => [ |
|
| 953 | + 'EEM_State' => EE_Dependency_Map::load_from_cache, |
|
| 954 | + ], |
|
| 955 | + 'EventEspresso\core\domain\services\graphql\types\Country' => [ |
|
| 956 | + 'EEM_Country' => EE_Dependency_Map::load_from_cache, |
|
| 957 | + ], |
|
| 958 | + 'EventEspresso\core\domain\services\graphql\connections\EventDatetimesConnection' => [ |
|
| 959 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 960 | + ], |
|
| 961 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryDatetimesConnection' => [ |
|
| 962 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 963 | + ], |
|
| 964 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryAttendeesConnection' => [ |
|
| 965 | + 'EEM_Attendee' => EE_Dependency_Map::load_from_cache, |
|
| 966 | + ], |
|
| 967 | + 'EventEspresso\core\domain\services\graphql\connections\DatetimeTicketsConnection' => [ |
|
| 968 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 969 | + ], |
|
| 970 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryTicketsConnection' => [ |
|
| 971 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 972 | + ], |
|
| 973 | + 'EventEspresso\core\domain\services\graphql\connections\TicketPricesConnection' => [ |
|
| 974 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 975 | + ], |
|
| 976 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryPricesConnection' => [ |
|
| 977 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 978 | + ], |
|
| 979 | + 'EventEspresso\core\domain\services\graphql\connections\RootQueryPriceTypesConnection' => [ |
|
| 980 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 981 | + ], |
|
| 982 | + 'EventEspresso\core\domain\services\graphql\connections\TicketDatetimesConnection' => [ |
|
| 983 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 984 | + ], |
|
| 985 | + 'EventEspresso\core\domain\services\graphql\connections\EventVenuesConnection' => [ |
|
| 986 | + 'EEM_Venue' => EE_Dependency_Map::load_from_cache, |
|
| 987 | + ], |
|
| 988 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => [ |
|
| 989 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes' => EE_Dependency_Map::load_from_cache, |
|
| 990 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Prices' => EE_Dependency_Map::load_from_cache, |
|
| 991 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes' => EE_Dependency_Map::load_from_cache, |
|
| 992 | + 'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets' => EE_Dependency_Map::load_from_cache, |
|
| 993 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache, |
|
| 994 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => EE_Dependency_Map::load_from_cache, |
|
| 995 | + ], |
|
| 996 | + 'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations' => [ |
|
| 997 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 998 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 999 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 1000 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 1001 | + ], |
|
| 1002 | + 'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => [ |
|
| 1003 | + 'EEM_Datetime' => EE_Dependency_Map::load_from_cache, |
|
| 1004 | + 'EEM_Price' => EE_Dependency_Map::load_from_cache, |
|
| 1005 | + 'EEM_Price_Type' => EE_Dependency_Map::load_from_cache, |
|
| 1006 | + 'EEM_Ticket' => EE_Dependency_Map::load_from_cache, |
|
| 1007 | + ], |
|
| 1008 | + 'EventEspresso\core\services\route_match\RouteHandler' => [ |
|
| 1009 | + 'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache, |
|
| 1010 | + 'EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache, |
|
| 1011 | + 'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache, |
|
| 1012 | + 'EventEspresso\core\services\route_match\RouteMatchSpecificationManager' => EE_Dependency_Map::load_from_cache, |
|
| 1013 | + ], |
|
| 1014 | + ); |
|
| 1015 | + } |
|
| 1016 | + |
|
| 1017 | + |
|
| 1018 | + /** |
|
| 1019 | + * Registers how core classes are loaded. |
|
| 1020 | + * This can either be done by simply providing the name of one of the EE_Registry loader methods such as: |
|
| 1021 | + * 'EE_Request_Handler' => 'load_core' |
|
| 1022 | + * 'EE_Messages_Queue' => 'load_lib' |
|
| 1023 | + * 'EEH_Debug_Tools' => 'load_helper' |
|
| 1024 | + * or, if greater control is required, by providing a custom closure. For example: |
|
| 1025 | + * 'Some_Class' => function () { |
|
| 1026 | + * return new Some_Class(); |
|
| 1027 | + * }, |
|
| 1028 | + * This is required for instantiating dependencies |
|
| 1029 | + * where an interface has been type hinted in a class constructor. For example: |
|
| 1030 | + * 'Required_Interface' => function () { |
|
| 1031 | + * return new A_Class_That_Implements_Required_Interface(); |
|
| 1032 | + * }, |
|
| 1033 | + */ |
|
| 1034 | + protected function _register_core_class_loaders() |
|
| 1035 | + { |
|
| 1036 | + $this->_class_loaders = array( |
|
| 1037 | + // load_core |
|
| 1038 | + 'EE_Dependency_Map' => function () { |
|
| 1039 | + return $this; |
|
| 1040 | + }, |
|
| 1041 | + 'EE_Capabilities' => 'load_core', |
|
| 1042 | + 'EE_Encryption' => 'load_core', |
|
| 1043 | + 'EE_Front_Controller' => 'load_core', |
|
| 1044 | + 'EE_Module_Request_Router' => 'load_core', |
|
| 1045 | + 'EE_Registry' => 'load_core', |
|
| 1046 | + 'EE_Request' => function () { |
|
| 1047 | + return $this->legacy_request; |
|
| 1048 | + }, |
|
| 1049 | + 'EventEspresso\core\services\request\Request' => function () { |
|
| 1050 | + return $this->request; |
|
| 1051 | + }, |
|
| 1052 | + 'EventEspresso\core\services\request\Response' => function () { |
|
| 1053 | + return $this->response; |
|
| 1054 | + }, |
|
| 1055 | + 'EE_Base' => 'load_core', |
|
| 1056 | + 'EE_Request_Handler' => 'load_core', |
|
| 1057 | + 'EE_Session' => 'load_core', |
|
| 1058 | + 'EE_Cron_Tasks' => 'load_core', |
|
| 1059 | + 'EE_System' => 'load_core', |
|
| 1060 | + 'EE_Maintenance_Mode' => 'load_core', |
|
| 1061 | + 'EE_Register_CPTs' => 'load_core', |
|
| 1062 | + 'EE_Admin' => 'load_core', |
|
| 1063 | + 'EE_CPT_Strategy' => 'load_core', |
|
| 1064 | + // load_class |
|
| 1065 | + 'EE_Registration_Processor' => 'load_class', |
|
| 1066 | + // load_lib |
|
| 1067 | + 'EE_Message_Resource_Manager' => 'load_lib', |
|
| 1068 | + 'EE_Message_Type_Collection' => 'load_lib', |
|
| 1069 | + 'EE_Message_Type_Collection_Loader' => 'load_lib', |
|
| 1070 | + 'EE_Messenger_Collection' => 'load_lib', |
|
| 1071 | + 'EE_Messenger_Collection_Loader' => 'load_lib', |
|
| 1072 | + 'EE_Messages_Processor' => 'load_lib', |
|
| 1073 | + 'EE_Message_Repository' => 'load_lib', |
|
| 1074 | + 'EE_Messages_Queue' => 'load_lib', |
|
| 1075 | + 'EE_Messages_Data_Handler_Collection' => 'load_lib', |
|
| 1076 | + 'EE_Message_Template_Group_Collection' => 'load_lib', |
|
| 1077 | + 'EE_Payment_Method_Manager' => 'load_lib', |
|
| 1078 | + 'EE_DMS_Core_4_1_0' => 'load_dms', |
|
| 1079 | + 'EE_DMS_Core_4_2_0' => 'load_dms', |
|
| 1080 | + 'EE_DMS_Core_4_3_0' => 'load_dms', |
|
| 1081 | + 'EE_DMS_Core_4_5_0' => 'load_dms', |
|
| 1082 | + 'EE_DMS_Core_4_6_0' => 'load_dms', |
|
| 1083 | + 'EE_DMS_Core_4_7_0' => 'load_dms', |
|
| 1084 | + 'EE_DMS_Core_4_8_0' => 'load_dms', |
|
| 1085 | + 'EE_DMS_Core_4_9_0' => 'load_dms', |
|
| 1086 | + 'EE_DMS_Core_4_10_0' => 'load_dms', |
|
| 1087 | + 'EE_Messages_Generator' => static function () { |
|
| 1088 | + return EE_Registry::instance()->load_lib( |
|
| 1089 | + 'Messages_Generator', |
|
| 1090 | + array(), |
|
| 1091 | + false, |
|
| 1092 | + false |
|
| 1093 | + ); |
|
| 1094 | + }, |
|
| 1095 | + 'EE_Messages_Template_Defaults' => static function ($arguments = array()) { |
|
| 1096 | + return EE_Registry::instance()->load_lib( |
|
| 1097 | + 'Messages_Template_Defaults', |
|
| 1098 | + $arguments, |
|
| 1099 | + false, |
|
| 1100 | + false |
|
| 1101 | + ); |
|
| 1102 | + }, |
|
| 1103 | + // load_helper |
|
| 1104 | + 'EEH_Parse_Shortcodes' => static function () { |
|
| 1105 | + if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) { |
|
| 1106 | + return new EEH_Parse_Shortcodes(); |
|
| 1107 | + } |
|
| 1108 | + return null; |
|
| 1109 | + }, |
|
| 1110 | + 'EE_Template_Config' => static function () { |
|
| 1111 | + return EE_Config::instance()->template_settings; |
|
| 1112 | + }, |
|
| 1113 | + 'EE_Currency_Config' => static function () { |
|
| 1114 | + return EE_Config::instance()->currency; |
|
| 1115 | + }, |
|
| 1116 | + 'EE_Registration_Config' => static function () { |
|
| 1117 | + return EE_Config::instance()->registration; |
|
| 1118 | + }, |
|
| 1119 | + 'EE_Core_Config' => static function () { |
|
| 1120 | + return EE_Config::instance()->core; |
|
| 1121 | + }, |
|
| 1122 | + 'EventEspresso\core\services\loaders\Loader' => static function () { |
|
| 1123 | + return LoaderFactory::getLoader(); |
|
| 1124 | + }, |
|
| 1125 | + 'EE_Network_Config' => static function () { |
|
| 1126 | + return EE_Network_Config::instance(); |
|
| 1127 | + }, |
|
| 1128 | + 'EE_Config' => static function () { |
|
| 1129 | + return EE_Config::instance(); |
|
| 1130 | + }, |
|
| 1131 | + 'EventEspresso\core\domain\Domain' => static function () { |
|
| 1132 | + return DomainFactory::getEventEspressoCoreDomain(); |
|
| 1133 | + }, |
|
| 1134 | + 'EE_Admin_Config' => static function () { |
|
| 1135 | + return EE_Config::instance()->admin; |
|
| 1136 | + }, |
|
| 1137 | + 'EE_Organization_Config' => static function () { |
|
| 1138 | + return EE_Config::instance()->organization; |
|
| 1139 | + }, |
|
| 1140 | + 'EE_Network_Core_Config' => static function () { |
|
| 1141 | + return EE_Network_Config::instance()->core; |
|
| 1142 | + }, |
|
| 1143 | + 'EE_Environment_Config' => static function () { |
|
| 1144 | + return EE_Config::instance()->environment; |
|
| 1145 | + }, |
|
| 1146 | + 'EED_Core_Rest_Api' => static function () { |
|
| 1147 | + return EED_Core_Rest_Api::instance(); |
|
| 1148 | + }, |
|
| 1149 | + 'WP_REST_Server' => static function () { |
|
| 1150 | + return rest_get_server(); |
|
| 1151 | + }, |
|
| 1152 | + ); |
|
| 1153 | + } |
|
| 1154 | + |
|
| 1155 | + |
|
| 1156 | + /** |
|
| 1157 | + * can be used for supplying alternate names for classes, |
|
| 1158 | + * or for connecting interface names to instantiable classes |
|
| 1159 | + * |
|
| 1160 | + * @throws InvalidAliasException |
|
| 1161 | + */ |
|
| 1162 | + protected function _register_core_aliases() |
|
| 1163 | + { |
|
| 1164 | + $aliases = array( |
|
| 1165 | + 'CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBusInterface', |
|
| 1166 | + 'EventEspresso\core\services\commands\CommandBusInterface' => 'EventEspresso\core\services\commands\CommandBus', |
|
| 1167 | + 'CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface', |
|
| 1168 | + 'EventEspresso\core\services\commands\CommandHandlerManagerInterface' => 'EventEspresso\core\services\commands\CommandHandlerManager', |
|
| 1169 | + 'CapChecker' => 'EventEspresso\core\services\commands\middleware\CapChecker', |
|
| 1170 | + 'AddActionHook' => 'EventEspresso\core\services\commands\middleware\AddActionHook', |
|
| 1171 | + 'CapabilitiesChecker' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1172 | + 'CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface', |
|
| 1173 | + 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker', |
|
| 1174 | + 'CreateRegistrationService' => 'EventEspresso\core\domain\services\registration\CreateRegistrationService', |
|
| 1175 | + 'CreateRegistrationCommandHandler' => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand', |
|
| 1176 | + 'CopyRegistrationDetailsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand', |
|
| 1177 | + 'CopyRegistrationPaymentsCommandHandler' => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand', |
|
| 1178 | + 'CancelRegistrationAndTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler', |
|
| 1179 | + 'UpdateRegistrationAndTransactionAfterChangeCommandHandler' => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler', |
|
| 1180 | + 'CreateTicketLineItemCommandHandler' => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand', |
|
| 1181 | + 'CreateTransactionCommandHandler' => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler', |
|
| 1182 | + 'CreateAttendeeCommandHandler' => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler', |
|
| 1183 | + 'TableManager' => 'EventEspresso\core\services\database\TableManager', |
|
| 1184 | + 'TableAnalysis' => 'EventEspresso\core\services\database\TableAnalysis', |
|
| 1185 | + 'EspressoShortcode' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1186 | + 'ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\ShortcodeInterface', |
|
| 1187 | + 'EventEspresso\core\services\shortcodes\ShortcodeInterface' => 'EventEspresso\core\services\shortcodes\EspressoShortcode', |
|
| 1188 | + 'EventEspresso\core\services\cache\CacheStorageInterface' => 'EventEspresso\core\services\cache\TransientCacheStorage', |
|
| 1189 | + 'LoaderInterface' => 'EventEspresso\core\services\loaders\LoaderInterface', |
|
| 1190 | + 'EventEspresso\core\services\loaders\LoaderInterface' => 'EventEspresso\core\services\loaders\Loader', |
|
| 1191 | + 'CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactoryInterface', |
|
| 1192 | + 'EventEspresso\core\services\commands\CommandFactoryInterface' => 'EventEspresso\core\services\commands\CommandFactory', |
|
| 1193 | + 'EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface', |
|
| 1194 | + 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService', |
|
| 1195 | + 'NoticeConverterInterface' => 'EventEspresso\core\services\notices\NoticeConverterInterface', |
|
| 1196 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors', |
|
| 1197 | + 'NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainerInterface', |
|
| 1198 | + 'EventEspresso\core\services\notices\NoticesContainerInterface' => 'EventEspresso\core\services\notices\NoticesContainer', |
|
| 1199 | + 'EventEspresso\core\services\request\RequestInterface' => 'EventEspresso\core\services\request\Request', |
|
| 1200 | + 'EventEspresso\core\services\request\ResponseInterface' => 'EventEspresso\core\services\request\Response', |
|
| 1201 | + 'EventEspresso\core\domain\DomainInterface' => 'EventEspresso\core\domain\Domain', |
|
| 1202 | + 'Registration_Processor' => 'EE_Registration_Processor', |
|
| 1203 | + ); |
|
| 1204 | + foreach ($aliases as $alias => $fqn) { |
|
| 1205 | + if (is_array($fqn)) { |
|
| 1206 | + foreach ($fqn as $class => $for_class) { |
|
| 1207 | + $this->class_cache->addAlias($class, $alias, $for_class); |
|
| 1208 | + } |
|
| 1209 | + continue; |
|
| 1210 | + } |
|
| 1211 | + $this->class_cache->addAlias($fqn, $alias); |
|
| 1212 | + } |
|
| 1213 | + if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) { |
|
| 1214 | + $this->class_cache->addAlias( |
|
| 1215 | + 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices', |
|
| 1216 | + 'EventEspresso\core\services\notices\NoticeConverterInterface' |
|
| 1217 | + ); |
|
| 1218 | + } |
|
| 1219 | + } |
|
| 1220 | + |
|
| 1221 | + |
|
| 1222 | + /** |
|
| 1223 | + * This is used to reset the internal map and class_loaders to their original default state at the beginning of the |
|
| 1224 | + * request Primarily used by unit tests. |
|
| 1225 | + */ |
|
| 1226 | + public function reset() |
|
| 1227 | + { |
|
| 1228 | + $this->_register_core_class_loaders(); |
|
| 1229 | + $this->_register_core_dependencies(); |
|
| 1230 | + } |
|
| 1231 | + |
|
| 1232 | + |
|
| 1233 | + /** |
|
| 1234 | + * PLZ NOTE: a better name for this method would be is_alias() |
|
| 1235 | + * because it returns TRUE if the provided fully qualified name IS an alias |
|
| 1236 | + * WHY? |
|
| 1237 | + * Because if a class is type hinting for a concretion, |
|
| 1238 | + * then why would we need to find another class to supply it? |
|
| 1239 | + * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`, |
|
| 1240 | + * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`. |
|
| 1241 | + * Don't go looking for some substitute. |
|
| 1242 | + * Whereas if a class is type hinting for an interface... |
|
| 1243 | + * then we need to find an actual class to use. |
|
| 1244 | + * So the interface IS the alias for some other FQN, |
|
| 1245 | + * and we need to find out if `Fully/Qualified/Namespace/SomeInterface` |
|
| 1246 | + * represents some other class. |
|
| 1247 | + * |
|
| 1248 | + * @deprecated 4.9.62.p |
|
| 1249 | + * @param string $fqn |
|
| 1250 | + * @param string $for_class |
|
| 1251 | + * @return bool |
|
| 1252 | + */ |
|
| 1253 | + public function has_alias($fqn = '', $for_class = '') |
|
| 1254 | + { |
|
| 1255 | + return $this->isAlias($fqn, $for_class); |
|
| 1256 | + } |
|
| 1257 | + |
|
| 1258 | + |
|
| 1259 | + /** |
|
| 1260 | + * PLZ NOTE: a better name for this method would be get_fqn_for_alias() |
|
| 1261 | + * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias |
|
| 1262 | + * functions recursively, so that multiple aliases can be used to drill down to a FQN |
|
| 1263 | + * for example: |
|
| 1264 | + * if the following two entries were added to the _aliases array: |
|
| 1265 | + * array( |
|
| 1266 | + * 'interface_alias' => 'some\namespace\interface' |
|
| 1267 | + * 'some\namespace\interface' => 'some\namespace\classname' |
|
| 1268 | + * ) |
|
| 1269 | + * then one could use EE_Registry::instance()->create( 'interface_alias' ) |
|
| 1270 | + * to load an instance of 'some\namespace\classname' |
|
| 1271 | + * |
|
| 1272 | + * @deprecated 4.9.62.p |
|
| 1273 | + * @param string $alias |
|
| 1274 | + * @param string $for_class |
|
| 1275 | + * @return string |
|
| 1276 | + */ |
|
| 1277 | + public function get_alias($alias = '', $for_class = '') |
|
| 1278 | + { |
|
| 1279 | + return $this->getFqnForAlias($alias, $for_class); |
|
| 1280 | + } |
|
| 1281 | 1281 | } |
@@ -15,11 +15,11 @@ |
||
| 15 | 15 | class WordPressPluginsPage extends RouteMatchSpecification |
| 16 | 16 | { |
| 17 | 17 | |
| 18 | - /** |
|
| 19 | - * @inheritDoc |
|
| 20 | - */ |
|
| 21 | - public function isMatchingRoute() |
|
| 22 | - { |
|
| 23 | - return strpos($this->request->requestUri(), 'wp-admin/plugins.php') !== false; |
|
| 24 | - } |
|
| 18 | + /** |
|
| 19 | + * @inheritDoc |
|
| 20 | + */ |
|
| 21 | + public function isMatchingRoute() |
|
| 22 | + { |
|
| 23 | + return strpos($this->request->requestUri(), 'wp-admin/plugins.php') !== false; |
|
| 24 | + } |
|
| 25 | 25 | } |