Completed
Branch EDTR/master (6bd139)
by
unknown
35:03 queued 26:41
created
core/domain/entities/routing/handlers/admin/AdminRoute.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -24,30 +24,30 @@
 block discarded – undo
24 24
 abstract class AdminRoute extends Route
25 25
 {
26 26
 
27
-    /**
28
-     * @var EE_Admin_Config $admin_config
29
-     */
30
-    protected $admin_config;
27
+	/**
28
+	 * @var EE_Admin_Config $admin_config
29
+	 */
30
+	protected $admin_config;
31 31
 
32 32
 
33
-    /**
34
-     * Route constructor.
35
-     *
36
-     * @param EE_Admin_Config $admin_config
37
-     * @param EE_Dependency_Map                $dependency_map
38
-     * @param LoaderInterface                  $loader
39
-     * @param RequestInterface                 $request
40
-     * @param RouteMatchSpecificationInterface $specification
41
-     */
42
-    public function __construct(
43
-        EE_Admin_Config $admin_config,
44
-        EE_Dependency_Map $dependency_map,
45
-        LoaderInterface $loader,
46
-        RequestInterface $request,
47
-        RouteMatchSpecificationInterface $specification = null
48
-    ) {
49
-        $this->admin_config = $admin_config;
50
-        parent::__construct($dependency_map, $loader, $request, $specification);
51
-    }
33
+	/**
34
+	 * Route constructor.
35
+	 *
36
+	 * @param EE_Admin_Config $admin_config
37
+	 * @param EE_Dependency_Map                $dependency_map
38
+	 * @param LoaderInterface                  $loader
39
+	 * @param RequestInterface                 $request
40
+	 * @param RouteMatchSpecificationInterface $specification
41
+	 */
42
+	public function __construct(
43
+		EE_Admin_Config $admin_config,
44
+		EE_Dependency_Map $dependency_map,
45
+		LoaderInterface $loader,
46
+		RequestInterface $request,
47
+		RouteMatchSpecificationInterface $specification = null
48
+	) {
49
+		$this->admin_config = $admin_config;
50
+		parent::__construct($dependency_map, $loader, $request, $specification);
51
+	}
52 52
 
53 53
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/admin/EspressoEventEditor.php 1 patch
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -16,135 +16,135 @@
 block discarded – undo
16 16
 class EspressoEventEditor extends EspressoEventsAdmin
17 17
 {
18 18
 
19
-    /**
20
-     * @var EspressoEditorAssetManager $asset_manager
21
-     */
22
-    protected $asset_manager;
19
+	/**
20
+	 * @var EspressoEditorAssetManager $asset_manager
21
+	 */
22
+	protected $asset_manager;
23 23
 
24 24
 
25
-    /**
26
-     * returns true if the current request matches this route
27
-     *
28
-     * @return bool
29
-     * @since   $VID:$
30
-     */
31
-    public function matchesCurrentRequest()
32
-    {
33
-        return parent::matchesCurrentRequest()
34
-               && $this->admin_config->useAdvancedEditor()
35
-               && (
36
-                $this->request->getRequestParam('action') === 'create_new'
37
-                || $this->request->getRequestParam('action') === 'edit'
38
-            );
39
-    }
25
+	/**
26
+	 * returns true if the current request matches this route
27
+	 *
28
+	 * @return bool
29
+	 * @since   $VID:$
30
+	 */
31
+	public function matchesCurrentRequest()
32
+	{
33
+		return parent::matchesCurrentRequest()
34
+			   && $this->admin_config->useAdvancedEditor()
35
+			   && (
36
+				$this->request->getRequestParam('action') === 'create_new'
37
+				|| $this->request->getRequestParam('action') === 'edit'
38
+			);
39
+	}
40 40
 
41 41
 
42
-    /**
43
-     * @since $VID:$
44
-     */
45
-    protected function registerDependencies()
46
-    {
47
-        $this->dependency_map->registerDependencies(
48
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
49
-            [
50
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
51
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
52
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
53
-            ]
54
-        );
55
-        $this->dependency_map->registerDependencies(
56
-            'EventEspresso\core\domain\services\admin\events\editor\EventEditor',
57
-            [
58
-                'EE_Admin_Config'                                                               => EE_Dependency_Map::load_from_cache,
59
-                'EE_Event'                                                                      => EE_Dependency_Map::not_registered,
60
-                'EventEspresso\core\domain\entities\admin\GraphQLData\CurrentUser'              =>
61
-                    EE_Dependency_Map::not_registered,
62
-                'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' =>
63
-                    EE_Dependency_Map::load_from_cache,
64
-                'EventEspresso\core\domain\entities\admin\GraphQLData\GeneralSettings'          =>
65
-                    EE_Dependency_Map::load_from_cache,
66
-                'EventEspresso\core\services\assets\JedLocaleData'                              => EE_Dependency_Map::load_from_cache,
67
-            ]
68
-        );
69
-        $this->dependency_map->registerDependencies(
70
-            'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData',
71
-            [
72
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes'                 => EE_Dependency_Map::load_from_cache,
73
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Prices'                    => EE_Dependency_Map::load_from_cache,
74
-                'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes'                => EE_Dependency_Map::load_from_cache,
75
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets'                   => EE_Dependency_Map::load_from_cache,
76
-                'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache,
77
-                'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations'    => EE_Dependency_Map::load_from_cache,
78
-            ]
79
-        );
80
-        $this->dependency_map->registerDependencies(
81
-            'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations',
82
-            [
83
-                'EEM_Datetime'   => EE_Dependency_Map::load_from_cache,
84
-                'EEM_Event'      => EE_Dependency_Map::load_from_cache,
85
-                'EEM_Price'      => EE_Dependency_Map::load_from_cache,
86
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
87
-                'EEM_Ticket'     => EE_Dependency_Map::load_from_cache,
88
-            ]
89
-        );
90
-        $this->dependency_map->registerDependencies(
91
-            'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities',
92
-            [
93
-                'EEM_Datetime'                                                       => EE_Dependency_Map::load_from_cache,
94
-                'EEM_Event'                                                          => EE_Dependency_Map::load_from_cache,
95
-                'EEM_Price'                                                          => EE_Dependency_Map::load_from_cache,
96
-                'EEM_Price_Type'                                                     => EE_Dependency_Map::load_from_cache,
97
-                'EEM_Ticket'                                                         => EE_Dependency_Map::load_from_cache,
98
-                'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache,
99
-            ]
100
-        );
101
-        $this->dependency_map->registerDependencies(
102
-            'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes',
103
-            [
104
-                'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache,
105
-                'EEM_Datetime'                                                     => EE_Dependency_Map::load_from_cache,
106
-            ]
107
-        );
108
-        $this->dependency_map->registerDependencies(
109
-            'EventEspresso\core\domain\services\admin\entities\DefaultTickets',
110
-            [
111
-                'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache,
112
-                'EEM_Ticket'                                                      => EE_Dependency_Map::load_from_cache,
113
-            ]
114
-        );
115
-        $this->dependency_map->registerDependencies(
116
-            'EventEspresso\core\domain\services\admin\entities\DefaultPrices',
117
-            [
118
-                'EEM_Price'      => EE_Dependency_Map::load_from_cache,
119
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
120
-            ]
121
-        );
122
-    }
42
+	/**
43
+	 * @since $VID:$
44
+	 */
45
+	protected function registerDependencies()
46
+	{
47
+		$this->dependency_map->registerDependencies(
48
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager',
49
+			[
50
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
51
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
52
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
53
+			]
54
+		);
55
+		$this->dependency_map->registerDependencies(
56
+			'EventEspresso\core\domain\services\admin\events\editor\EventEditor',
57
+			[
58
+				'EE_Admin_Config'                                                               => EE_Dependency_Map::load_from_cache,
59
+				'EE_Event'                                                                      => EE_Dependency_Map::not_registered,
60
+				'EventEspresso\core\domain\entities\admin\GraphQLData\CurrentUser'              =>
61
+					EE_Dependency_Map::not_registered,
62
+				'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' =>
63
+					EE_Dependency_Map::load_from_cache,
64
+				'EventEspresso\core\domain\entities\admin\GraphQLData\GeneralSettings'          =>
65
+					EE_Dependency_Map::load_from_cache,
66
+				'EventEspresso\core\services\assets\JedLocaleData'                              => EE_Dependency_Map::load_from_cache,
67
+			]
68
+		);
69
+		$this->dependency_map->registerDependencies(
70
+			'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData',
71
+			[
72
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes'                 => EE_Dependency_Map::load_from_cache,
73
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Prices'                    => EE_Dependency_Map::load_from_cache,
74
+				'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes'                => EE_Dependency_Map::load_from_cache,
75
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets'                   => EE_Dependency_Map::load_from_cache,
76
+				'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache,
77
+				'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations'    => EE_Dependency_Map::load_from_cache,
78
+			]
79
+		);
80
+		$this->dependency_map->registerDependencies(
81
+			'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations',
82
+			[
83
+				'EEM_Datetime'   => EE_Dependency_Map::load_from_cache,
84
+				'EEM_Event'      => EE_Dependency_Map::load_from_cache,
85
+				'EEM_Price'      => EE_Dependency_Map::load_from_cache,
86
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
87
+				'EEM_Ticket'     => EE_Dependency_Map::load_from_cache,
88
+			]
89
+		);
90
+		$this->dependency_map->registerDependencies(
91
+			'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities',
92
+			[
93
+				'EEM_Datetime'                                                       => EE_Dependency_Map::load_from_cache,
94
+				'EEM_Event'                                                          => EE_Dependency_Map::load_from_cache,
95
+				'EEM_Price'                                                          => EE_Dependency_Map::load_from_cache,
96
+				'EEM_Price_Type'                                                     => EE_Dependency_Map::load_from_cache,
97
+				'EEM_Ticket'                                                         => EE_Dependency_Map::load_from_cache,
98
+				'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache,
99
+			]
100
+		);
101
+		$this->dependency_map->registerDependencies(
102
+			'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes',
103
+			[
104
+				'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache,
105
+				'EEM_Datetime'                                                     => EE_Dependency_Map::load_from_cache,
106
+			]
107
+		);
108
+		$this->dependency_map->registerDependencies(
109
+			'EventEspresso\core\domain\services\admin\entities\DefaultTickets',
110
+			[
111
+				'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache,
112
+				'EEM_Ticket'                                                      => EE_Dependency_Map::load_from_cache,
113
+			]
114
+		);
115
+		$this->dependency_map->registerDependencies(
116
+			'EventEspresso\core\domain\services\admin\entities\DefaultPrices',
117
+			[
118
+				'EEM_Price'      => EE_Dependency_Map::load_from_cache,
119
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
120
+			]
121
+		);
122
+	}
123 123
 
124 124
 
125
-    /**
126
-     * implements logic required to run during request
127
-     *
128
-     * @return bool
129
-     * @since   $VID:$
130
-     */
131
-    protected function requestHandler()
132
-    {
133
-        $this->asset_manager = $this->loader->getShared(
134
-            'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
135
-        );
136
-        add_action('admin_enqueue_scripts', [$this, 'enqueueEspressoEditorAssets'], 100);
137
-        return false;
138
-    }
125
+	/**
126
+	 * implements logic required to run during request
127
+	 *
128
+	 * @return bool
129
+	 * @since   $VID:$
130
+	 */
131
+	protected function requestHandler()
132
+	{
133
+		$this->asset_manager = $this->loader->getShared(
134
+			'EventEspresso\core\domain\services\assets\EspressoEditorAssetManager'
135
+		);
136
+		add_action('admin_enqueue_scripts', [$this, 'enqueueEspressoEditorAssets'], 100);
137
+		return false;
138
+	}
139 139
 
140 140
 
141
-    /**
142
-     * enqueue_scripts - Load the scripts and css
143
-     *
144
-     * @return void
145
-     */
146
-    public function enqueueEspressoEditorAssets()
147
-    {
148
-        $this->asset_manager->enqueueBrowserAssets();
149
-    }
141
+	/**
142
+	 * enqueue_scripts - Load the scripts and css
143
+	 *
144
+	 * @return void
145
+	 */
146
+	public function enqueueEspressoEditorAssets()
147
+	{
148
+		$this->asset_manager->enqueueBrowserAssets();
149
+	}
150 150
 }
Please login to merge, or discard this patch.
strategies/display/EE_Admin_File_Uploader_Display_Strategy.strategy.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -11,98 +11,98 @@
 block discarded – undo
11 11
 class EE_Admin_File_Uploader_Display_Strategy extends EE_Display_Strategy_Base
12 12
 {
13 13
 
14
-    /**
15
-     * Its important this media only get enqueued AFTER init, but before the footer... where the
16
-     * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine,
17
-     * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error
18
-     * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the button
19
-     * to select media).
20
-     * Besides that, no special consideration should be required to make the media uploader appear, besides having
21
-     * this input displayed.
22
-     *
23
-     * @deprecated. enqueue_js should be called automatically now
24
-     */
25
-    public static function enqueue_scripts()
26
-    {
27
-        EE_Error::doing_it_wrong(
28
-            __FUNCTION__,
29
-            __(
30
-                'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form',
31
-                'event_espresso'
32
-            ),
33
-            '4.9.8.rc.015'
34
-        );
35
-        wp_enqueue_media();
36
-        wp_enqueue_script('media-upload');
37
-        wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js');
38
-    }
14
+	/**
15
+	 * Its important this media only get enqueued AFTER init, but before the footer... where the
16
+	 * rest of our forms JS gets enqueued. Otherwise the JS gets enqueued fine, and loaded on the page fine,
17
+	 * but when you upload an image it gets uploaded fine to the server, but it doesn't display and reports an error
18
+	 * (also it doesn't show any of the currently existing media in the modal window that pops up when you click the button
19
+	 * to select media).
20
+	 * Besides that, no special consideration should be required to make the media uploader appear, besides having
21
+	 * this input displayed.
22
+	 *
23
+	 * @deprecated. enqueue_js should be called automatically now
24
+	 */
25
+	public static function enqueue_scripts()
26
+	{
27
+		EE_Error::doing_it_wrong(
28
+			__FUNCTION__,
29
+			__(
30
+				'EE_Admin_File_Uploader_Display_Strategy::enqueue_scripts() no longer needs to be called in order to display the admin uploader input correctly. This is handled now by EE_Admin_File_Uploader_Display_Strategy::enqueue_js() which is called automatically when enqueueing JS and CSS for the form',
31
+				'event_espresso'
32
+			),
33
+			'4.9.8.rc.015'
34
+		);
35
+		wp_enqueue_media();
36
+		wp_enqueue_script('media-upload');
37
+		wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js');
38
+	}
39 39
 
40 40
 
41
-    /**
42
-     * Enqueues the JS and CSS needed to display this input
43
-     */
44
-    public function enqueue_js()
45
-    {
46
-        wp_enqueue_media();
47
-        wp_enqueue_script('media-upload');
48
-        wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js');
49
-        parent::enqueue_js();
50
-    }
41
+	/**
42
+	 * Enqueues the JS and CSS needed to display this input
43
+	 */
44
+	public function enqueue_js()
45
+	{
46
+		wp_enqueue_media();
47
+		wp_enqueue_script('media-upload');
48
+		wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js');
49
+		parent::enqueue_js();
50
+	}
51 51
 
52 52
 
53
-    /**
54
-     * @return string of html to display the field
55
-     */
53
+	/**
54
+	 * @return string of html to display the field
55
+	 */
56 56
 
57
-    public function display()
58
-    {
59
-        // the actual input
60
-        $input = '<input type="text" size="34" ';
61
-        $input .= 'name="' . $this->_input->html_name() . '" ';
62
-        $input .= $this->_input->html_class() !== ''
63
-            ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" '
64
-            : 'class="large-text ee_media_url" ';
65
-        $input .= 'value="' . $this->_input->raw_value_in_form() . '" ';
66
-        $input .= $this->_input->other_html_attributes() . '>';
67
-        // image uploader
68
-        $uploader = EEH_HTML::link(
69
-            '#',
70
-            '<img src="' . admin_url('images/media-button-image.gif') . '" >',
71
-            __('click to add an image', 'event_espresso'),
72
-            '',
73
-            'ee_media_upload'
74
-        );
75
-        // only attempt to show the image if it at least exists
76
-        $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value())
77
-            ? EEH_HTML::br(2) . EEH_HTML::img(
78
-                $this->_input->raw_value(),
79
-                __('logo', 'event_espresso'),
80
-                '',
81
-                'ee_media_image'
82
-            )
83
-            : '';
84
-        // html string
85
-        return EEH_HTML::div(
86
-            $input . EEH_HTML::nbsp() . $uploader . $image,
87
-            '',
88
-            'ee_media_uploader_area'
89
-        );
90
-    }
57
+	public function display()
58
+	{
59
+		// the actual input
60
+		$input = '<input type="text" size="34" ';
61
+		$input .= 'name="' . $this->_input->html_name() . '" ';
62
+		$input .= $this->_input->html_class() !== ''
63
+			? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" '
64
+			: 'class="large-text ee_media_url" ';
65
+		$input .= 'value="' . $this->_input->raw_value_in_form() . '" ';
66
+		$input .= $this->_input->other_html_attributes() . '>';
67
+		// image uploader
68
+		$uploader = EEH_HTML::link(
69
+			'#',
70
+			'<img src="' . admin_url('images/media-button-image.gif') . '" >',
71
+			__('click to add an image', 'event_espresso'),
72
+			'',
73
+			'ee_media_upload'
74
+		);
75
+		// only attempt to show the image if it at least exists
76
+		$image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value())
77
+			? EEH_HTML::br(2) . EEH_HTML::img(
78
+				$this->_input->raw_value(),
79
+				__('logo', 'event_espresso'),
80
+				'',
81
+				'ee_media_image'
82
+			)
83
+			: '';
84
+		// html string
85
+		return EEH_HTML::div(
86
+			$input . EEH_HTML::nbsp() . $uploader . $image,
87
+			'',
88
+			'ee_media_uploader_area'
89
+		);
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * Asserts an image actually exists as quickly as possible by sending a HEAD
95
-     * request
96
-     *
97
-     * @param string $src
98
-     * @return boolean
99
-     */
100
-    protected function src_exists($src)
101
-    {
102
-        $results = wp_remote_head($src);
103
-        if (is_array($results) && ! $results instanceof WP_Error) {
104
-            return strpos($results['headers']['content-type'], "image") !== false;
105
-        }
106
-        return false;
107
-    }
93
+	/**
94
+	 * Asserts an image actually exists as quickly as possible by sending a HEAD
95
+	 * request
96
+	 *
97
+	 * @param string $src
98
+	 * @return boolean
99
+	 */
100
+	protected function src_exists($src)
101
+	{
102
+		$results = wp_remote_head($src);
103
+		if (is_array($results) && ! $results instanceof WP_Error) {
104
+			return strpos($results['headers']['content-type'], "image") !== false;
105
+		}
106
+		return false;
107
+	}
108 108
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         );
35 35
         wp_enqueue_media();
36 36
         wp_enqueue_script('media-upload');
37
-        wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js');
37
+        wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js');
38 38
     }
39 39
 
40 40
 
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
     {
46 46
         wp_enqueue_media();
47 47
         wp_enqueue_script('media-upload');
48
-        wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL . 'scripts/ee-media-uploader.js');
48
+        wp_enqueue_script('ee-payments', EE_GLOBAL_ASSETS_URL.'scripts/ee-media-uploader.js');
49 49
         parent::enqueue_js();
50 50
     }
51 51
 
@@ -58,23 +58,23 @@  discard block
 block discarded – undo
58 58
     {
59 59
         // the actual input
60 60
         $input = '<input type="text" size="34" ';
61
-        $input .= 'name="' . $this->_input->html_name() . '" ';
61
+        $input .= 'name="'.$this->_input->html_name().'" ';
62 62
         $input .= $this->_input->html_class() !== ''
63
-            ? 'class="large-text ee_media_url ' . $this->_input->html_class() . '" '
63
+            ? 'class="large-text ee_media_url '.$this->_input->html_class().'" '
64 64
             : 'class="large-text ee_media_url" ';
65
-        $input .= 'value="' . $this->_input->raw_value_in_form() . '" ';
66
-        $input .= $this->_input->other_html_attributes() . '>';
65
+        $input .= 'value="'.$this->_input->raw_value_in_form().'" ';
66
+        $input .= $this->_input->other_html_attributes().'>';
67 67
         // image uploader
68 68
         $uploader = EEH_HTML::link(
69 69
             '#',
70
-            '<img src="' . admin_url('images/media-button-image.gif') . '" >',
70
+            '<img src="'.admin_url('images/media-button-image.gif').'" >',
71 71
             __('click to add an image', 'event_espresso'),
72 72
             '',
73 73
             'ee_media_upload'
74 74
         );
75 75
         // only attempt to show the image if it at least exists
76 76
         $image = $this->_input->raw_value() && $this->src_exists($this->_input->raw_value())
77
-            ? EEH_HTML::br(2) . EEH_HTML::img(
77
+            ? EEH_HTML::br(2).EEH_HTML::img(
78 78
                 $this->_input->raw_value(),
79 79
                 __('logo', 'event_espresso'),
80 80
                 '',
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
             : '';
84 84
         // html string
85 85
         return EEH_HTML::div(
86
-            $input . EEH_HTML::nbsp() . $uploader . $image,
86
+            $input.EEH_HTML::nbsp().$uploader.$image,
87 87
             '',
88 88
             'ee_media_uploader_area'
89 89
         );
Please login to merge, or discard this patch.
core/services/routing/RouteMatchSpecificationFactory.php 1 patch
Indentation   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -23,44 +23,44 @@
 block discarded – undo
23 23
 class RouteMatchSpecificationFactory extends FactoryWithDependencyResolver
24 24
 {
25 25
 
26
-    /**
27
-     * RouteMatchSpecificationFactory constructor
28
-     *
29
-     * @param RouteMatchSpecificationDependencyResolver $dependency_resolver
30
-     * @param LoaderInterface                           $loader
31
-     */
32
-    public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader)
33
-    {
34
-        parent::__construct($dependency_resolver, $loader);
35
-    }
26
+	/**
27
+	 * RouteMatchSpecificationFactory constructor
28
+	 *
29
+	 * @param RouteMatchSpecificationDependencyResolver $dependency_resolver
30
+	 * @param LoaderInterface                           $loader
31
+	 */
32
+	public function __construct(RouteMatchSpecificationDependencyResolver $dependency_resolver, LoaderInterface $loader)
33
+	{
34
+		parent::__construct($dependency_resolver, $loader);
35
+	}
36 36
 
37
-    /**
38
-     * @param $fqcn
39
-     * @return RouteMatchSpecification
40
-     * @throws InvalidDataTypeException
41
-     * @since 4.9.71.p
42
-     */
43
-    public function createNewRouteMatchSpecification($fqcn)
44
-    {
45
-        $this->dependencyResolver()->resolveDependenciesForClass($fqcn);
46
-        return $this->loader()->getShared($fqcn);
47
-    }
37
+	/**
38
+	 * @param $fqcn
39
+	 * @return RouteMatchSpecification
40
+	 * @throws InvalidDataTypeException
41
+	 * @since 4.9.71.p
42
+	 */
43
+	public function createNewRouteMatchSpecification($fqcn)
44
+	{
45
+		$this->dependencyResolver()->resolveDependenciesForClass($fqcn);
46
+		return $this->loader()->getShared($fqcn);
47
+	}
48 48
 
49 49
 
50
-    /**
51
-     * @param $fqcn
52
-     * @return RouteMatchSpecification
53
-     * @throws InvalidArgumentException
54
-     * @throws InvalidDataTypeException
55
-     * @throws InvalidInterfaceException
56
-     * @since 4.9.71.p
57
-     */
58
-    public static function create($fqcn)
59
-    {
60
-        /** @var RouteMatchSpecificationFactory $specification_factory */
61
-        $specification_factory = LoaderFactory::getLoader()->getShared(
62
-            'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'
63
-        );
64
-        return $specification_factory->createNewRouteMatchSpecification($fqcn);
65
-    }
50
+	/**
51
+	 * @param $fqcn
52
+	 * @return RouteMatchSpecification
53
+	 * @throws InvalidArgumentException
54
+	 * @throws InvalidDataTypeException
55
+	 * @throws InvalidInterfaceException
56
+	 * @since 4.9.71.p
57
+	 */
58
+	public static function create($fqcn)
59
+	{
60
+		/** @var RouteMatchSpecificationFactory $specification_factory */
61
+		$specification_factory = LoaderFactory::getLoader()->getShared(
62
+			'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'
63
+		);
64
+		return $specification_factory->createNewRouteMatchSpecification($fqcn);
65
+	}
66 66
 }
Please login to merge, or discard this patch.
core/services/routing/RouteCollection.php 1 patch
Indentation   +64 added lines, -64 removed lines patch added patch discarded remove patch
@@ -17,76 +17,76 @@
 block discarded – undo
17 17
 class RouteCollection extends Collection
18 18
 {
19 19
 
20
-    const COLLECTION_NAME = 'routes';
20
+	const COLLECTION_NAME = 'routes';
21 21
 
22 22
 
23
-    /**
24
-     * RouteMatchSpecificationCollection constructor
25
-     *
26
-     * @throws InvalidInterfaceException
27
-     */
28
-    public function __construct()
29
-    {
30
-        parent::__construct(
31
-            'EventEspresso\core\domain\entities\routing\handlers\RouteInterface',
32
-            RouteCollection::COLLECTION_NAME
33
-        );
34
-    }
23
+	/**
24
+	 * RouteMatchSpecificationCollection constructor
25
+	 *
26
+	 * @throws InvalidInterfaceException
27
+	 */
28
+	public function __construct()
29
+	{
30
+		parent::__construct(
31
+			'EventEspresso\core\domain\entities\routing\handlers\RouteInterface',
32
+			RouteCollection::COLLECTION_NAME
33
+		);
34
+	}
35 35
 
36 36
 
37
-    /**
38
-     * getIdentifier
39
-     * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
40
-     * If no $identifier is supplied, then the  fully qualified class name is used
41
-     *
42
-     * @param        $object
43
-     * @param mixed  $identifier
44
-     * @return bool
45
-     */
46
-    public function getIdentifier($object, $identifier = null)
47
-    {
48
-        return ! empty($identifier)
49
-            ? $identifier
50
-            : get_class($object);
51
-    }
37
+	/**
38
+	 * getIdentifier
39
+	 * Overrides EventEspresso\core\services\collections\Collection::getIdentifier()
40
+	 * If no $identifier is supplied, then the  fully qualified class name is used
41
+	 *
42
+	 * @param        $object
43
+	 * @param mixed  $identifier
44
+	 * @return bool
45
+	 */
46
+	public function getIdentifier($object, $identifier = null)
47
+	{
48
+		return ! empty($identifier)
49
+			? $identifier
50
+			: get_class($object);
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * finds and returns all Routes that have yet to be handled
56
-     *
57
-     * @return RouteInterface[]
58
-     */
59
-    public function getRoutesForCurrentRequest()
60
-    {
61
-        $routes = [];
62
-        $this->rewind();
63
-        while ($this->valid()) {
64
-            /** @var RouteInterface $route */
65
-            $route = $this->current();
66
-            if ($route->matchesCurrentRequest()) {
67
-                $routes[] = $route;
68
-            }
69
-            $this->next();
70
-        }
71
-        $this->rewind();
72
-        return $routes;
73
-    }
54
+	/**
55
+	 * finds and returns all Routes that have yet to be handled
56
+	 *
57
+	 * @return RouteInterface[]
58
+	 */
59
+	public function getRoutesForCurrentRequest()
60
+	{
61
+		$routes = [];
62
+		$this->rewind();
63
+		while ($this->valid()) {
64
+			/** @var RouteInterface $route */
65
+			$route = $this->current();
66
+			if ($route->matchesCurrentRequest()) {
67
+				$routes[] = $route;
68
+			}
69
+			$this->next();
70
+		}
71
+		$this->rewind();
72
+		return $routes;
73
+	}
74 74
 
75 75
 
76
-    /**
77
-     * calls RouteInterface::handleRequest() on all Routes that
78
-     *      - match current request
79
-     *      - have yet to be handled
80
-     *
81
-     * @return void
82
-     */
83
-    public function handleRoutesForCurrentRequest()
84
-    {
85
-        $this->rewind();
86
-        while ($this->valid()) {
87
-            $this->current()->handleRequest();
88
-            $this->next();
89
-        }
90
-        $this->rewind();
91
-    }
76
+	/**
77
+	 * calls RouteInterface::handleRequest() on all Routes that
78
+	 *      - match current request
79
+	 *      - have yet to be handled
80
+	 *
81
+	 * @return void
82
+	 */
83
+	public function handleRoutesForCurrentRequest()
84
+	{
85
+		$this->rewind();
86
+		while ($this->valid()) {
87
+			$this->current()->handleRequest();
88
+			$this->next();
89
+		}
90
+		$this->rewind();
91
+	}
92 92
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Indentation   +1259 added lines, -1259 removed lines patch added patch discarded remove patch
@@ -28,1263 +28,1263 @@
 block discarded – undo
28 28
 final class EE_System implements ResettableInterface
29 29
 {
30 30
 
31
-    /**
32
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
33
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
34
-     */
35
-    const req_type_normal = 0;
36
-
37
-    /**
38
-     * Indicates this is a brand new installation of EE so we should install
39
-     * tables and default data etc
40
-     */
41
-    const req_type_new_activation = 1;
42
-
43
-    /**
44
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
45
-     * and we just exited maintenance mode). We MUST check the database is setup properly
46
-     * and that default data is setup too
47
-     */
48
-    const req_type_reactivation = 2;
49
-
50
-    /**
51
-     * indicates that EE has been upgraded since its previous request.
52
-     * We may have data migration scripts to call and will want to trigger maintenance mode
53
-     */
54
-    const req_type_upgrade = 3;
55
-
56
-    /**
57
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
58
-     */
59
-    const req_type_downgrade = 4;
60
-
61
-    /**
62
-     * @deprecated since version 4.6.0.dev.006
63
-     * Now whenever a new_activation is detected the request type is still just
64
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
65
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
66
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
67
-     * (Specifically, when the migration manager indicates migrations are finished
68
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
69
-     */
70
-    const req_type_activation_but_not_installed = 5;
71
-
72
-    /**
73
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
74
-     */
75
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
76
-
77
-    /**
78
-     * @var EE_System $_instance
79
-     */
80
-    private static $_instance;
81
-
82
-    /**
83
-     * @var EE_Registry $registry
84
-     */
85
-    private $registry;
86
-
87
-    /**
88
-     * @var LoaderInterface $loader
89
-     */
90
-    private $loader;
91
-
92
-    /**
93
-     * @var EE_Capabilities $capabilities
94
-     */
95
-    private $capabilities;
96
-
97
-    /**
98
-     * @var EE_Maintenance_Mode $maintenance_mode
99
-     */
100
-    private $maintenance_mode;
101
-
102
-    /**
103
-     * @var RequestInterface $request
104
-     */
105
-    private $request;
106
-
107
-    /**
108
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
109
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
110
-     *
111
-     * @var int $_req_type
112
-     */
113
-    private $_req_type;
114
-
115
-
116
-    /**
117
-     * @var RouteHandler $router
118
-     */
119
-    private $router;
120
-
121
-    /**
122
-     * Whether or not there was a non-micro version change in EE core version during this request
123
-     *
124
-     * @var boolean $_major_version_change
125
-     */
126
-    private $_major_version_change = false;
127
-
128
-    /**
129
-     * A Context DTO dedicated solely to identifying the current request type.
130
-     *
131
-     * @var RequestTypeContextCheckerInterface $request_type
132
-     */
133
-    private $request_type;
134
-
135
-
136
-    /**
137
-     * @singleton method used to instantiate class object
138
-     * @param EE_Registry|null         $registry
139
-     * @param LoaderInterface|null     $loader
140
-     * @param RequestInterface|null    $request
141
-     * @param EE_Maintenance_Mode|null $maintenance_mode
142
-     * @return EE_System
143
-     */
144
-    public static function instance(
145
-        EE_Registry $registry = null,
146
-        LoaderInterface $loader = null,
147
-        RequestInterface $request = null,
148
-        EE_Maintenance_Mode $maintenance_mode = null
149
-    ) {
150
-        // check if class object is instantiated
151
-        if (! self::$_instance instanceof EE_System) {
152
-            self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153
-        }
154
-        return self::$_instance;
155
-    }
156
-
157
-
158
-    /**
159
-     * resets the instance and returns it
160
-     *
161
-     * @return EE_System
162
-     */
163
-    public static function reset()
164
-    {
165
-        self::$_instance->_req_type = null;
166
-        // make sure none of the old hooks are left hanging around
167
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
168
-        // we need to reset the migration manager in order for it to detect DMSs properly
169
-        EE_Data_Migration_Manager::reset();
170
-        self::instance()->detect_activations_or_upgrades();
171
-        self::instance()->perform_activations_upgrades_and_migrations();
172
-        return self::instance();
173
-    }
174
-
175
-
176
-    /**
177
-     * sets hooks for running rest of system
178
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
179
-     * starting EE Addons from any other point may lead to problems
180
-     *
181
-     * @param EE_Registry         $registry
182
-     * @param LoaderInterface     $loader
183
-     * @param RequestInterface    $request
184
-     * @param EE_Maintenance_Mode $maintenance_mode
185
-     */
186
-    private function __construct(
187
-        EE_Registry $registry,
188
-        LoaderInterface $loader,
189
-        RequestInterface $request,
190
-        EE_Maintenance_Mode $maintenance_mode
191
-    ) {
192
-        $this->registry = $registry;
193
-        $this->loader = $loader;
194
-        $this->request = $request;
195
-        $this->maintenance_mode = $maintenance_mode;
196
-        do_action('AHEE__EE_System__construct__begin', $this);
197
-        add_action(
198
-            'AHEE__EE_Bootstrap__load_espresso_addons',
199
-            array($this, 'loadCapabilities'),
200
-            5
201
-        );
202
-        add_action(
203
-            'AHEE__EE_Bootstrap__load_espresso_addons',
204
-            array($this, 'loadCommandBus'),
205
-            7
206
-        );
207
-        add_action(
208
-            'AHEE__EE_Bootstrap__load_espresso_addons',
209
-            array($this, 'loadPluginApi'),
210
-            9
211
-        );
212
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
213
-        add_action(
214
-            'AHEE__EE_Bootstrap__load_espresso_addons',
215
-            array($this, 'load_espresso_addons')
216
-        );
217
-        // when an ee addon is activated, we want to call the core hook(s) again
218
-        // because the newly-activated addon didn't get a chance to run at all
219
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
220
-        // detect whether install or upgrade
221
-        add_action(
222
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
223
-            array($this, 'detect_activations_or_upgrades'),
224
-            3
225
-        );
226
-        // load EE_Config, EE_Textdomain, etc
227
-        add_action(
228
-            'AHEE__EE_Bootstrap__load_core_configuration',
229
-            array($this, 'load_core_configuration'),
230
-            5
231
-        );
232
-        // load specifications for matching routes to current request
233
-        add_action(
234
-            'AHEE__EE_Bootstrap__load_core_configuration',
235
-            array($this, 'loadRouteMatchSpecifications')
236
-        );
237
-        // load EE_Config, EE_Textdomain, etc
238
-        add_action(
239
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
240
-            array($this, 'register_shortcodes_modules_and_widgets'),
241
-            7
242
-        );
243
-        // you wanna get going? I wanna get going... let's get going!
244
-        add_action(
245
-            'AHEE__EE_Bootstrap__brew_espresso',
246
-            array($this, 'brew_espresso'),
247
-            9
248
-        );
249
-        // other housekeeping
250
-        // exclude EE critical pages from wp_list_pages
251
-        add_filter(
252
-            'wp_list_pages_excludes',
253
-            array($this, 'remove_pages_from_wp_list_pages'),
254
-            10
255
-        );
256
-        // ALL EE Addons should use the following hook point to attach their initial setup too
257
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
258
-        do_action('AHEE__EE_System__construct__complete', $this);
259
-    }
260
-
261
-
262
-    /**
263
-     * load and setup EE_Capabilities
264
-     *
265
-     * @return void
266
-     */
267
-    public function loadCapabilities()
268
-    {
269
-        $this->capabilities = $this->loader->getShared('EE_Capabilities');
270
-        add_action(
271
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
272
-            function () {
273
-                LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
274
-            }
275
-        );
276
-    }
277
-
278
-
279
-    /**
280
-     * create and cache the CommandBus, and also add middleware
281
-     * The CapChecker middleware requires the use of EE_Capabilities
282
-     * which is why we need to load the CommandBus after Caps are set up
283
-     *
284
-     * @return void
285
-     */
286
-    public function loadCommandBus()
287
-    {
288
-        $this->loader->getShared(
289
-            'CommandBusInterface',
290
-            array(
291
-                null,
292
-                apply_filters(
293
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
294
-                    array(
295
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
296
-                        $this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
297
-                    )
298
-                ),
299
-            )
300
-        );
301
-    }
302
-
303
-
304
-    /**
305
-     * @return void
306
-     * @throws EE_Error
307
-     */
308
-    public function loadPluginApi()
309
-    {
310
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
311
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
312
-        EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
313
-        $this->loader->getShared('EE_Request_Handler');
314
-    }
315
-
316
-
317
-    /**
318
-     * @param string $addon_name
319
-     * @param string $version_constant
320
-     * @param string $min_version_required
321
-     * @param string $load_callback
322
-     * @param string $plugin_file_constant
323
-     * @return void
324
-     */
325
-    private function deactivateIncompatibleAddon(
326
-        $addon_name,
327
-        $version_constant,
328
-        $min_version_required,
329
-        $load_callback,
330
-        $plugin_file_constant
331
-    ) {
332
-        if (! defined($version_constant)) {
333
-            return;
334
-        }
335
-        $addon_version = constant($version_constant);
336
-        if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
337
-            remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
338
-            if (! function_exists('deactivate_plugins')) {
339
-                require_once ABSPATH . 'wp-admin/includes/plugin.php';
340
-            }
341
-            deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
342
-            unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
343
-            EE_Error::add_error(
344
-                sprintf(
345
-                    esc_html__(
346
-                        '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.',
347
-                        'event_espresso'
348
-                    ),
349
-                    $addon_name,
350
-                    $min_version_required
351
-                ),
352
-                __FILE__,
353
-                __FUNCTION__ . "({$addon_name})",
354
-                __LINE__
355
-            );
356
-            EE_Error::get_notices(false, true);
357
-        }
358
-    }
359
-
360
-
361
-    /**
362
-     * load_espresso_addons
363
-     * allow addons to load first so that they can set hooks for running DMS's, etc
364
-     * this is hooked into both:
365
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
366
-     *        which runs during the WP 'plugins_loaded' action at priority 5
367
-     *    and the WP 'activate_plugin' hook point
368
-     *
369
-     * @access public
370
-     * @return void
371
-     */
372
-    public function load_espresso_addons()
373
-    {
374
-        $this->deactivateIncompatibleAddon(
375
-            'Wait Lists',
376
-            'EE_WAIT_LISTS_VERSION',
377
-            '1.0.0.beta.074',
378
-            'load_espresso_wait_lists',
379
-            'EE_WAIT_LISTS_PLUGIN_FILE'
380
-        );
381
-        $this->deactivateIncompatibleAddon(
382
-            'Automated Upcoming Event Notifications',
383
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
384
-            '1.0.0.beta.091',
385
-            'load_espresso_automated_upcoming_event_notification',
386
-            'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
387
-        );
388
-        do_action('AHEE__EE_System__load_espresso_addons');
389
-        // if the WP API basic auth plugin isn't already loaded, load it now.
390
-        // We want it for mobile apps. Just include the entire plugin
391
-        // also, don't load the basic auth when a plugin is getting activated, because
392
-        // it could be the basic auth plugin, and it doesn't check if its methods are already defined
393
-        // and causes a fatal error
394
-        if (($this->request->isWordPressApi() || $this->request->isApi())
395
-            && $this->request->getRequestParam('activate') !== 'true'
396
-            && ! function_exists('json_basic_auth_handler')
397
-            && ! function_exists('json_basic_auth_error')
398
-            && ! in_array(
399
-                $this->request->getRequestParam('action'),
400
-                array('activate', 'activate-selected'),
401
-                true
402
-            )
403
-        ) {
404
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php';
405
-        }
406
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
407
-    }
408
-
409
-
410
-    /**
411
-     * detect_activations_or_upgrades
412
-     * Checks for activation or upgrade of core first;
413
-     * then also checks if any registered addons have been activated or upgraded
414
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
415
-     * which runs during the WP 'plugins_loaded' action at priority 3
416
-     *
417
-     * @access public
418
-     * @return void
419
-     */
420
-    public function detect_activations_or_upgrades()
421
-    {
422
-        // first off: let's make sure to handle core
423
-        $this->detect_if_activation_or_upgrade();
424
-        foreach ($this->registry->addons as $addon) {
425
-            if ($addon instanceof EE_Addon) {
426
-                // detect teh request type for that addon
427
-                $addon->detect_activation_or_upgrade();
428
-            }
429
-        }
430
-    }
431
-
432
-
433
-    /**
434
-     * detect_if_activation_or_upgrade
435
-     * Takes care of detecting whether this is a brand new install or code upgrade,
436
-     * and either setting up the DB or setting up maintenance mode etc.
437
-     *
438
-     * @access public
439
-     * @return void
440
-     */
441
-    public function detect_if_activation_or_upgrade()
442
-    {
443
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
444
-        // check if db has been updated, or if its a brand-new installation
445
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
446
-        $request_type = $this->detect_req_type($espresso_db_update);
447
-        // EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
448
-        switch ($request_type) {
449
-            case EE_System::req_type_new_activation:
450
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
451
-                $this->_handle_core_version_change($espresso_db_update);
452
-                break;
453
-            case EE_System::req_type_reactivation:
454
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
455
-                $this->_handle_core_version_change($espresso_db_update);
456
-                break;
457
-            case EE_System::req_type_upgrade:
458
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
459
-                // migrations may be required now that we've upgraded
460
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
461
-                $this->_handle_core_version_change($espresso_db_update);
462
-                break;
463
-            case EE_System::req_type_downgrade:
464
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
465
-                // its possible migrations are no longer required
466
-                $this->maintenance_mode->set_maintenance_mode_if_db_old();
467
-                $this->_handle_core_version_change($espresso_db_update);
468
-                break;
469
-            case EE_System::req_type_normal:
470
-            default:
471
-                break;
472
-        }
473
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
474
-    }
475
-
476
-
477
-    /**
478
-     * Updates the list of installed versions and sets hooks for
479
-     * initializing the database later during the request
480
-     *
481
-     * @param array $espresso_db_update
482
-     */
483
-    private function _handle_core_version_change($espresso_db_update)
484
-    {
485
-        $this->update_list_of_installed_versions($espresso_db_update);
486
-        // get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
487
-        add_action(
488
-            'AHEE__EE_System__perform_activations_upgrades_and_migrations',
489
-            array($this, 'initialize_db_if_no_migrations_required')
490
-        );
491
-    }
492
-
493
-
494
-    /**
495
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
496
-     * information about what versions of EE have been installed and activated,
497
-     * NOT necessarily the state of the database
498
-     *
499
-     * @param mixed $espresso_db_update           the value of the WordPress option.
500
-     *                                            If not supplied, fetches it from the options table
501
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
502
-     */
503
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
504
-    {
505
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
506
-        if (! $espresso_db_update) {
507
-            $espresso_db_update = get_option('espresso_db_update');
508
-        }
509
-        // check that option is an array
510
-        if (! is_array($espresso_db_update)) {
511
-            // if option is FALSE, then it never existed
512
-            if ($espresso_db_update === false) {
513
-                // make $espresso_db_update an array and save option with autoload OFF
514
-                $espresso_db_update = array();
515
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
516
-            } else {
517
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
518
-                $espresso_db_update = array($espresso_db_update => array());
519
-                update_option('espresso_db_update', $espresso_db_update);
520
-            }
521
-        } else {
522
-            $corrected_db_update = array();
523
-            // if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
524
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
525
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
526
-                    // the key is an int, and the value IS NOT an array
527
-                    // so it must be numerically-indexed, where values are versions installed...
528
-                    // fix it!
529
-                    $version_string = $should_be_array;
530
-                    $corrected_db_update[ $version_string ] = array('unknown-date');
531
-                } else {
532
-                    // ok it checks out
533
-                    $corrected_db_update[ $should_be_version_string ] = $should_be_array;
534
-                }
535
-            }
536
-            $espresso_db_update = $corrected_db_update;
537
-            update_option('espresso_db_update', $espresso_db_update);
538
-        }
539
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
540
-        return $espresso_db_update;
541
-    }
542
-
543
-
544
-    /**
545
-     * Does the traditional work of setting up the plugin's database and adding default data.
546
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
547
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
548
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
549
-     * so that it will be done when migrations are finished
550
-     *
551
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
552
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
553
-     *                                       This is a resource-intensive job
554
-     *                                       so we prefer to only do it when necessary
555
-     * @return void
556
-     * @throws EE_Error
557
-     */
558
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
559
-    {
560
-        $request_type = $this->detect_req_type();
561
-        // only initialize system if we're not in maintenance mode.
562
-        if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
563
-            /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
564
-            $rewrite_rules = $this->loader->getShared(
565
-                'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
566
-            );
567
-            $rewrite_rules->flush();
568
-            if ($verify_schema) {
569
-                EEH_Activation::initialize_db_and_folders();
570
-            }
571
-            EEH_Activation::initialize_db_content();
572
-            EEH_Activation::system_initialization();
573
-            if ($initialize_addons_too) {
574
-                $this->initialize_addons();
575
-            }
576
-        } else {
577
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
578
-        }
579
-        if ($request_type === EE_System::req_type_new_activation
580
-            || $request_type === EE_System::req_type_reactivation
581
-            || (
582
-                $request_type === EE_System::req_type_upgrade
583
-                && $this->is_major_version_change()
584
-            )
585
-        ) {
586
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
587
-        }
588
-    }
589
-
590
-
591
-    /**
592
-     * Initializes the db for all registered addons
593
-     *
594
-     * @throws EE_Error
595
-     */
596
-    public function initialize_addons()
597
-    {
598
-        // foreach registered addon, make sure its db is up-to-date too
599
-        foreach ($this->registry->addons as $addon) {
600
-            if ($addon instanceof EE_Addon) {
601
-                $addon->initialize_db_if_no_migrations_required();
602
-            }
603
-        }
604
-    }
605
-
606
-
607
-    /**
608
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
609
-     *
610
-     * @param    array  $version_history
611
-     * @param    string $current_version_to_add version to be added to the version history
612
-     * @return    boolean success as to whether or not this option was changed
613
-     */
614
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
615
-    {
616
-        if (! $version_history) {
617
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
618
-        }
619
-        if ($current_version_to_add === null) {
620
-            $current_version_to_add = espresso_version();
621
-        }
622
-        $version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
623
-        // re-save
624
-        return update_option('espresso_db_update', $version_history);
625
-    }
626
-
627
-
628
-    /**
629
-     * Detects if the current version indicated in the has existed in the list of
630
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
631
-     *
632
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
633
-     *                                  If not supplied, fetches it from the options table.
634
-     *                                  Also, caches its result so later parts of the code can also know whether
635
-     *                                  there's been an update or not. This way we can add the current version to
636
-     *                                  espresso_db_update, but still know if this is a new install or not
637
-     * @return int one of the constants on EE_System::req_type_
638
-     */
639
-    public function detect_req_type($espresso_db_update = null)
640
-    {
641
-        if ($this->_req_type === null) {
642
-            $espresso_db_update = ! empty($espresso_db_update)
643
-                ? $espresso_db_update
644
-                : $this->fix_espresso_db_upgrade_option();
645
-            $this->_req_type = EE_System::detect_req_type_given_activation_history(
646
-                $espresso_db_update,
647
-                'ee_espresso_activation',
648
-                espresso_version()
649
-            );
650
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
651
-            $this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
652
-        }
653
-        return $this->_req_type;
654
-    }
655
-
656
-
657
-    /**
658
-     * Returns whether or not there was a non-micro version change (ie, change in either
659
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
660
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
661
-     *
662
-     * @param $activation_history
663
-     * @return bool
664
-     */
665
-    private function _detect_major_version_change($activation_history)
666
-    {
667
-        $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
668
-        $previous_version_parts = explode('.', $previous_version);
669
-        $current_version_parts = explode('.', espresso_version());
670
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
671
-               && (
672
-                   $previous_version_parts[0] !== $current_version_parts[0]
673
-                   || $previous_version_parts[1] !== $current_version_parts[1]
674
-               );
675
-    }
676
-
677
-
678
-    /**
679
-     * Returns true if either the major or minor version of EE changed during this request.
680
-     * 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
681
-     *
682
-     * @return bool
683
-     */
684
-    public function is_major_version_change()
685
-    {
686
-        return $this->_major_version_change;
687
-    }
688
-
689
-
690
-    /**
691
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
692
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
693
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
694
-     * just activated to (for core that will always be espresso_version())
695
-     *
696
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
697
-     *                                                 ee plugin. for core that's 'espresso_db_update'
698
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
699
-     *                                                 indicate that this plugin was just activated
700
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
701
-     *                                                 espresso_version())
702
-     * @return int one of the constants on EE_System::req_type_*
703
-     */
704
-    public static function detect_req_type_given_activation_history(
705
-        $activation_history_for_addon,
706
-        $activation_indicator_option_name,
707
-        $version_to_upgrade_to
708
-    ) {
709
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
710
-        if ($activation_history_for_addon) {
711
-            // it exists, so this isn't a completely new install
712
-            // check if this version already in that list of previously installed versions
713
-            if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
714
-                // it a version we haven't seen before
715
-                if ($version_is_higher === 1) {
716
-                    $req_type = EE_System::req_type_upgrade;
717
-                } else {
718
-                    $req_type = EE_System::req_type_downgrade;
719
-                }
720
-                delete_option($activation_indicator_option_name);
721
-            } else {
722
-                // its not an update. maybe a reactivation?
723
-                if (get_option($activation_indicator_option_name, false)) {
724
-                    if ($version_is_higher === -1) {
725
-                        $req_type = EE_System::req_type_downgrade;
726
-                    } elseif ($version_is_higher === 0) {
727
-                        // we've seen this version before, but it's an activation. must be a reactivation
728
-                        $req_type = EE_System::req_type_reactivation;
729
-                    } else {// $version_is_higher === 1
730
-                        $req_type = EE_System::req_type_upgrade;
731
-                    }
732
-                    delete_option($activation_indicator_option_name);
733
-                } else {
734
-                    // we've seen this version before and the activation indicate doesn't show it was just activated
735
-                    if ($version_is_higher === -1) {
736
-                        $req_type = EE_System::req_type_downgrade;
737
-                    } elseif ($version_is_higher === 0) {
738
-                        // we've seen this version before and it's not an activation. its normal request
739
-                        $req_type = EE_System::req_type_normal;
740
-                    } else {// $version_is_higher === 1
741
-                        $req_type = EE_System::req_type_upgrade;
742
-                    }
743
-                }
744
-            }
745
-        } else {
746
-            // brand new install
747
-            $req_type = EE_System::req_type_new_activation;
748
-            delete_option($activation_indicator_option_name);
749
-        }
750
-        return $req_type;
751
-    }
752
-
753
-
754
-    /**
755
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
756
-     * the $activation_history_for_addon
757
-     *
758
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
759
-     *                                             sometimes containing 'unknown-date'
760
-     * @param string $version_to_upgrade_to        (current version)
761
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
762
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
763
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
764
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
765
-     */
766
-    private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
767
-    {
768
-        // find the most recently-activated version
769
-        $most_recently_active_version =
770
-            EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
771
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
772
-    }
773
-
774
-
775
-    /**
776
-     * Gets the most recently active version listed in the activation history,
777
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
778
-     *
779
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
780
-     *                                   sometimes containing 'unknown-date'
781
-     * @return string
782
-     */
783
-    private static function _get_most_recently_active_version_from_activation_history($activation_history)
784
-    {
785
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
786
-        $most_recently_active_version = '0.0.0.dev.000';
787
-        if (is_array($activation_history)) {
788
-            foreach ($activation_history as $version => $times_activated) {
789
-                // check there is a record of when this version was activated. Otherwise,
790
-                // mark it as unknown
791
-                if (! $times_activated) {
792
-                    $times_activated = array('unknown-date');
793
-                }
794
-                if (is_string($times_activated)) {
795
-                    $times_activated = array($times_activated);
796
-                }
797
-                foreach ($times_activated as $an_activation) {
798
-                    if ($an_activation !== 'unknown-date'
799
-                        && $an_activation
800
-                           > $most_recently_active_version_activation) {
801
-                        $most_recently_active_version = $version;
802
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
803
-                            ? '1970-01-01 00:00:00'
804
-                            : $an_activation;
805
-                    }
806
-                }
807
-            }
808
-        }
809
-        return $most_recently_active_version;
810
-    }
811
-
812
-
813
-    /**
814
-     * This redirects to the about EE page after activation
815
-     *
816
-     * @return void
817
-     */
818
-    public function redirect_to_about_ee()
819
-    {
820
-        $notices = EE_Error::get_notices(false);
821
-        // if current user is an admin and it's not an ajax or rest request
822
-        if (! isset($notices['errors'])
823
-            && $this->request->isAdmin()
824
-            && apply_filters(
825
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
826
-                $this->capabilities->current_user_can('manage_options', 'espresso_about_default')
827
-            )
828
-        ) {
829
-            $query_params = array('page' => 'espresso_about');
830
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
831
-                $query_params['new_activation'] = true;
832
-            }
833
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
834
-                $query_params['reactivation'] = true;
835
-            }
836
-            $url = add_query_arg($query_params, admin_url('admin.php'));
837
-            wp_safe_redirect($url);
838
-            exit();
839
-        }
840
-    }
841
-
842
-
843
-    /**
844
-     * load_core_configuration
845
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
846
-     * which runs during the WP 'plugins_loaded' action at priority 5
847
-     *
848
-     * @return void
849
-     * @throws ReflectionException
850
-     * @throws Exception
851
-     */
852
-    public function load_core_configuration()
853
-    {
854
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
855
-        $this->loader->getShared('EE_Load_Textdomain');
856
-        // load textdomain
857
-        EE_Load_Textdomain::load_textdomain();
858
-        // load caf stuff a chance to play during the activation process too.
859
-        $this->_maybe_brew_regular();
860
-        // load and setup EE_Config and EE_Network_Config
861
-        $config = $this->loader->getShared('EE_Config');
862
-        $this->loader->getShared('EE_Network_Config');
863
-        // setup autoloaders
864
-        // enable logging?
865
-        if ($config->admin->use_remote_logging) {
866
-            $this->loader->getShared('EE_Log');
867
-        }
868
-        // check for activation errors
869
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
870
-        if ($activation_errors) {
871
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
872
-            update_option('ee_plugin_activation_errors', false);
873
-        }
874
-        // get model names
875
-        $this->_parse_model_names();
876
-        // configure custom post type definitions
877
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
878
-        $this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
879
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
880
-    }
881
-
882
-
883
-    /**
884
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
885
-     *
886
-     * @return void
887
-     * @throws ReflectionException
888
-     */
889
-    private function _parse_model_names()
890
-    {
891
-        // get all the files in the EE_MODELS folder that end in .model.php
892
-        $models = glob(EE_MODELS . '*.model.php');
893
-        $model_names = array();
894
-        $non_abstract_db_models = array();
895
-        foreach ($models as $model) {
896
-            // get model classname
897
-            $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
898
-            $short_name = str_replace('EEM_', '', $classname);
899
-            $reflectionClass = new ReflectionClass($classname);
900
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
901
-                $non_abstract_db_models[ $short_name ] = $classname;
902
-            }
903
-            $model_names[ $short_name ] = $classname;
904
-        }
905
-        $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
906
-        $this->registry->non_abstract_db_models = apply_filters(
907
-            'FHEE__EE_System__parse_implemented_model_names',
908
-            $non_abstract_db_models
909
-        );
910
-    }
911
-
912
-
913
-    /**
914
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
915
-     * that need to be setup before our EE_System launches.
916
-     *
917
-     * @return void
918
-     * @throws DomainException
919
-     * @throws InvalidArgumentException
920
-     * @throws InvalidDataTypeException
921
-     * @throws InvalidInterfaceException
922
-     * @throws InvalidClassException
923
-     * @throws InvalidFilePathException
924
-     */
925
-    private function _maybe_brew_regular()
926
-    {
927
-        /** @var Domain $domain */
928
-        $domain = DomainFactory::getShared(
929
-            new FullyQualifiedName(
930
-                'EventEspresso\core\domain\Domain'
931
-            ),
932
-            array(
933
-                new FilePath(EVENT_ESPRESSO_MAIN_FILE),
934
-                Version::fromString(espresso_version()),
935
-            )
936
-        );
937
-        if ($domain->isCaffeinated()) {
938
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
939
-        }
940
-    }
941
-
942
-
943
-    /**
944
-     * @since 4.9.71.p
945
-     * @throws Exception
946
-     */
947
-    public function loadRouteMatchSpecifications()
948
-    {
949
-        try {
950
-            $this->loader->getShared('EventEspresso\core\services\routing\RouteMatchSpecificationManager');
951
-            $this->loader->getShared('EventEspresso\core\services\routing\RouteCollection');
952
-            $this->router = $this->loader->getShared('EventEspresso\core\services\routing\RouteHandler');
953
-            // now load and prep all other Routes
954
-            $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\RoutingRequests');
955
-        } catch (Exception $exception) {
956
-            new ExceptionStackTraceDisplay($exception);
957
-        }
958
-        do_action('AHEE__EE_System__loadRouteMatchSpecifications');
959
-    }
960
-
961
-
962
-    /**
963
-     * register_shortcodes_modules_and_widgets
964
-     * generate lists of shortcodes and modules, then verify paths and classes
965
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
966
-     * which runs during the WP 'plugins_loaded' action at priority 7
967
-     *
968
-     * @access public
969
-     * @return void
970
-     * @throws Exception
971
-     */
972
-    public function register_shortcodes_modules_and_widgets()
973
-    {
974
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests');
975
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
976
-        // check for addons using old hook point
977
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
978
-            $this->_incompatible_addon_error();
979
-        }
980
-    }
981
-
982
-
983
-    /**
984
-     * _incompatible_addon_error
985
-     *
986
-     * @access public
987
-     * @return void
988
-     */
989
-    private function _incompatible_addon_error()
990
-    {
991
-        // get array of classes hooking into here
992
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
993
-            'AHEE__EE_System__register_shortcodes_modules_and_addons'
994
-        );
995
-        if (! empty($class_names)) {
996
-            $msg = __(
997
-                'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
998
-                'event_espresso'
999
-            );
1000
-            $msg .= '<ul>';
1001
-            foreach ($class_names as $class_name) {
1002
-                $msg .= '<li><b>Event Espresso - '
1003
-                        . str_replace(
1004
-                            array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'),
1005
-                            '',
1006
-                            $class_name
1007
-                        ) . '</b></li>';
1008
-            }
1009
-            $msg .= '</ul>';
1010
-            $msg .= __(
1011
-                'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1012
-                'event_espresso'
1013
-            );
1014
-            // save list of incompatible addons to wp-options for later use
1015
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
1016
-            if (is_admin()) {
1017
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1018
-            }
1019
-        }
1020
-    }
1021
-
1022
-
1023
-    /**
1024
-     * brew_espresso
1025
-     * begins the process of setting hooks for initializing EE in the correct order
1026
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1027
-     * which runs during the WP 'plugins_loaded' action at priority 9
1028
-     *
1029
-     * @return void
1030
-     * @throws Exception
1031
-     */
1032
-    public function brew_espresso()
1033
-    {
1034
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
1035
-        // load some final core systems
1036
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
1037
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1038
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
1039
-        add_action('init', array($this, 'load_controllers'), 7);
1040
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
1041
-        add_action('init', array($this, 'initialize'), 10);
1042
-        add_action('init', array($this, 'initialize_last'), 100);
1043
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests');
1044
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests');
1045
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests');
1046
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
1047
-    }
1048
-
1049
-
1050
-    /**
1051
-     *    set_hooks_for_core
1052
-     *
1053
-     * @access public
1054
-     * @return    void
1055
-     * @throws EE_Error
1056
-     */
1057
-    public function set_hooks_for_core()
1058
-    {
1059
-        $this->_deactivate_incompatible_addons();
1060
-        do_action('AHEE__EE_System__set_hooks_for_core');
1061
-        $this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1062
-        // caps need to be initialized on every request so that capability maps are set.
1063
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1064
-        $this->registry->CAP->init_caps();
1065
-    }
1066
-
1067
-
1068
-    /**
1069
-     * Using the information gathered in EE_System::_incompatible_addon_error,
1070
-     * deactivates any addons considered incompatible with the current version of EE
1071
-     */
1072
-    private function _deactivate_incompatible_addons()
1073
-    {
1074
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
1075
-        if (! empty($incompatible_addons)) {
1076
-            $active_plugins = get_option('active_plugins', array());
1077
-            foreach ($active_plugins as $active_plugin) {
1078
-                foreach ($incompatible_addons as $incompatible_addon) {
1079
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
1080
-                        unset($_GET['activate']);
1081
-                        espresso_deactivate_plugin($active_plugin);
1082
-                    }
1083
-                }
1084
-            }
1085
-        }
1086
-    }
1087
-
1088
-
1089
-    /**
1090
-     *    perform_activations_upgrades_and_migrations
1091
-     *
1092
-     * @access public
1093
-     * @return    void
1094
-     */
1095
-    public function perform_activations_upgrades_and_migrations()
1096
-    {
1097
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1098
-    }
1099
-
1100
-
1101
-    /**
1102
-     * @return void
1103
-     * @throws DomainException
1104
-     */
1105
-    public function load_CPTs_and_session()
1106
-    {
1107
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
1108
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1109
-        $register_custom_taxonomies = $this->loader->getShared(
1110
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1111
-        );
1112
-        $register_custom_taxonomies->registerCustomTaxonomies();
1113
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1114
-        $register_custom_post_types = $this->loader->getShared(
1115
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1116
-        );
1117
-        $register_custom_post_types->registerCustomPostTypes();
1118
-        /** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1119
-        $register_custom_taxonomy_terms = $this->loader->getShared(
1120
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1121
-        );
1122
-        $register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1123
-        // load legacy Custom Post Types and Taxonomies
1124
-        $this->loader->getShared('EE_Register_CPTs');
1125
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1126
-    }
1127
-
1128
-
1129
-    /**
1130
-     * load_controllers
1131
-     * this is the best place to load any additional controllers that needs access to EE core.
1132
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1133
-     * time
1134
-     *
1135
-     * @access public
1136
-     * @return void
1137
-     * @throws Exception
1138
-     */
1139
-    public function load_controllers()
1140
-    {
1141
-        do_action('AHEE__EE_System__load_controllers__start');
1142
-        // now start loading routes
1143
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests');
1144
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin');
1145
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin');
1146
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor');
1147
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage');
1148
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat');
1149
-        do_action('AHEE__EE_System__load_controllers__complete');
1150
-    }
1151
-
1152
-
1153
-    /**
1154
-     * core_loaded_and_ready
1155
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1156
-     *
1157
-     * @access public
1158
-     * @return void
1159
-     * @throws Exception
1160
-     */
1161
-    public function core_loaded_and_ready()
1162
-    {
1163
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests');
1164
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests');
1165
-        // integrate WP_Query with the EE models
1166
-        $this->loader->getShared('EE_CPT_Strategy');
1167
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1168
-        // always load template tags, because it's faster than checking if it's a front-end request, and many page
1169
-        // builders require these even on the front-end
1170
-        require_once EE_PUBLIC . 'template_tags.php';
1171
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1172
-    }
1173
-
1174
-
1175
-    /**
1176
-     * initialize
1177
-     * this is the best place to begin initializing client code
1178
-     *
1179
-     * @access public
1180
-     * @return void
1181
-     */
1182
-    public function initialize()
1183
-    {
1184
-        do_action('AHEE__EE_System__initialize');
1185
-    }
1186
-
1187
-
1188
-    /**
1189
-     * initialize_last
1190
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1191
-     * initialize has done so
1192
-     *
1193
-     * @access public
1194
-     * @return void
1195
-     * @throws Exception
1196
-     */
1197
-    public function initialize_last()
1198
-    {
1199
-        do_action('AHEE__EE_System__initialize_last');
1200
-        /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1201
-        $rewrite_rules = $this->loader->getShared(
1202
-            'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1203
-        );
1204
-        $rewrite_rules->flushRewriteRules();
1205
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests');
1206
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1207
-    }
1208
-
1209
-
1210
-    /**
1211
-     * @return void
1212
-     */
1213
-    public function addEspressoToolbar()
1214
-    {
1215
-        $this->loader->getShared(
1216
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1217
-            array($this->registry->CAP)
1218
-        );
1219
-    }
1220
-
1221
-
1222
-    /**
1223
-     * do_not_cache
1224
-     * sets no cache headers and defines no cache constants for WP plugins
1225
-     *
1226
-     * @access public
1227
-     * @return void
1228
-     */
1229
-    public static function do_not_cache()
1230
-    {
1231
-        // set no cache constants
1232
-        if (! defined('DONOTCACHEPAGE')) {
1233
-            define('DONOTCACHEPAGE', true);
1234
-        }
1235
-        if (! defined('DONOTCACHCEOBJECT')) {
1236
-            define('DONOTCACHCEOBJECT', true);
1237
-        }
1238
-        if (! defined('DONOTCACHEDB')) {
1239
-            define('DONOTCACHEDB', true);
1240
-        }
1241
-        // add no cache headers
1242
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1243
-        // plus a little extra for nginx and Google Chrome
1244
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1245
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1246
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1247
-    }
1248
-
1249
-
1250
-    /**
1251
-     *    extra_nocache_headers
1252
-     *
1253
-     * @access    public
1254
-     * @param $headers
1255
-     * @return    array
1256
-     */
1257
-    public static function extra_nocache_headers($headers)
1258
-    {
1259
-        // for NGINX
1260
-        $headers['X-Accel-Expires'] = 0;
1261
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1262
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1263
-        return $headers;
1264
-    }
1265
-
1266
-
1267
-    /**
1268
-     *    nocache_headers
1269
-     *
1270
-     * @access    public
1271
-     * @return    void
1272
-     */
1273
-    public static function nocache_headers()
1274
-    {
1275
-        nocache_headers();
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1281
-     * never returned with the function.
1282
-     *
1283
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1284
-     * @return array
1285
-     */
1286
-    public function remove_pages_from_wp_list_pages($exclude_array)
1287
-    {
1288
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1289
-    }
31
+	/**
32
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
33
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
34
+	 */
35
+	const req_type_normal = 0;
36
+
37
+	/**
38
+	 * Indicates this is a brand new installation of EE so we should install
39
+	 * tables and default data etc
40
+	 */
41
+	const req_type_new_activation = 1;
42
+
43
+	/**
44
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
45
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
46
+	 * and that default data is setup too
47
+	 */
48
+	const req_type_reactivation = 2;
49
+
50
+	/**
51
+	 * indicates that EE has been upgraded since its previous request.
52
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
53
+	 */
54
+	const req_type_upgrade = 3;
55
+
56
+	/**
57
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
58
+	 */
59
+	const req_type_downgrade = 4;
60
+
61
+	/**
62
+	 * @deprecated since version 4.6.0.dev.006
63
+	 * Now whenever a new_activation is detected the request type is still just
64
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
65
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
66
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
67
+	 * (Specifically, when the migration manager indicates migrations are finished
68
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
69
+	 */
70
+	const req_type_activation_but_not_installed = 5;
71
+
72
+	/**
73
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
74
+	 */
75
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
76
+
77
+	/**
78
+	 * @var EE_System $_instance
79
+	 */
80
+	private static $_instance;
81
+
82
+	/**
83
+	 * @var EE_Registry $registry
84
+	 */
85
+	private $registry;
86
+
87
+	/**
88
+	 * @var LoaderInterface $loader
89
+	 */
90
+	private $loader;
91
+
92
+	/**
93
+	 * @var EE_Capabilities $capabilities
94
+	 */
95
+	private $capabilities;
96
+
97
+	/**
98
+	 * @var EE_Maintenance_Mode $maintenance_mode
99
+	 */
100
+	private $maintenance_mode;
101
+
102
+	/**
103
+	 * @var RequestInterface $request
104
+	 */
105
+	private $request;
106
+
107
+	/**
108
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
109
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
110
+	 *
111
+	 * @var int $_req_type
112
+	 */
113
+	private $_req_type;
114
+
115
+
116
+	/**
117
+	 * @var RouteHandler $router
118
+	 */
119
+	private $router;
120
+
121
+	/**
122
+	 * Whether or not there was a non-micro version change in EE core version during this request
123
+	 *
124
+	 * @var boolean $_major_version_change
125
+	 */
126
+	private $_major_version_change = false;
127
+
128
+	/**
129
+	 * A Context DTO dedicated solely to identifying the current request type.
130
+	 *
131
+	 * @var RequestTypeContextCheckerInterface $request_type
132
+	 */
133
+	private $request_type;
134
+
135
+
136
+	/**
137
+	 * @singleton method used to instantiate class object
138
+	 * @param EE_Registry|null         $registry
139
+	 * @param LoaderInterface|null     $loader
140
+	 * @param RequestInterface|null    $request
141
+	 * @param EE_Maintenance_Mode|null $maintenance_mode
142
+	 * @return EE_System
143
+	 */
144
+	public static function instance(
145
+		EE_Registry $registry = null,
146
+		LoaderInterface $loader = null,
147
+		RequestInterface $request = null,
148
+		EE_Maintenance_Mode $maintenance_mode = null
149
+	) {
150
+		// check if class object is instantiated
151
+		if (! self::$_instance instanceof EE_System) {
152
+			self::$_instance = new self($registry, $loader, $request, $maintenance_mode);
153
+		}
154
+		return self::$_instance;
155
+	}
156
+
157
+
158
+	/**
159
+	 * resets the instance and returns it
160
+	 *
161
+	 * @return EE_System
162
+	 */
163
+	public static function reset()
164
+	{
165
+		self::$_instance->_req_type = null;
166
+		// make sure none of the old hooks are left hanging around
167
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
168
+		// we need to reset the migration manager in order for it to detect DMSs properly
169
+		EE_Data_Migration_Manager::reset();
170
+		self::instance()->detect_activations_or_upgrades();
171
+		self::instance()->perform_activations_upgrades_and_migrations();
172
+		return self::instance();
173
+	}
174
+
175
+
176
+	/**
177
+	 * sets hooks for running rest of system
178
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
179
+	 * starting EE Addons from any other point may lead to problems
180
+	 *
181
+	 * @param EE_Registry         $registry
182
+	 * @param LoaderInterface     $loader
183
+	 * @param RequestInterface    $request
184
+	 * @param EE_Maintenance_Mode $maintenance_mode
185
+	 */
186
+	private function __construct(
187
+		EE_Registry $registry,
188
+		LoaderInterface $loader,
189
+		RequestInterface $request,
190
+		EE_Maintenance_Mode $maintenance_mode
191
+	) {
192
+		$this->registry = $registry;
193
+		$this->loader = $loader;
194
+		$this->request = $request;
195
+		$this->maintenance_mode = $maintenance_mode;
196
+		do_action('AHEE__EE_System__construct__begin', $this);
197
+		add_action(
198
+			'AHEE__EE_Bootstrap__load_espresso_addons',
199
+			array($this, 'loadCapabilities'),
200
+			5
201
+		);
202
+		add_action(
203
+			'AHEE__EE_Bootstrap__load_espresso_addons',
204
+			array($this, 'loadCommandBus'),
205
+			7
206
+		);
207
+		add_action(
208
+			'AHEE__EE_Bootstrap__load_espresso_addons',
209
+			array($this, 'loadPluginApi'),
210
+			9
211
+		);
212
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
213
+		add_action(
214
+			'AHEE__EE_Bootstrap__load_espresso_addons',
215
+			array($this, 'load_espresso_addons')
216
+		);
217
+		// when an ee addon is activated, we want to call the core hook(s) again
218
+		// because the newly-activated addon didn't get a chance to run at all
219
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
220
+		// detect whether install or upgrade
221
+		add_action(
222
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
223
+			array($this, 'detect_activations_or_upgrades'),
224
+			3
225
+		);
226
+		// load EE_Config, EE_Textdomain, etc
227
+		add_action(
228
+			'AHEE__EE_Bootstrap__load_core_configuration',
229
+			array($this, 'load_core_configuration'),
230
+			5
231
+		);
232
+		// load specifications for matching routes to current request
233
+		add_action(
234
+			'AHEE__EE_Bootstrap__load_core_configuration',
235
+			array($this, 'loadRouteMatchSpecifications')
236
+		);
237
+		// load EE_Config, EE_Textdomain, etc
238
+		add_action(
239
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
240
+			array($this, 'register_shortcodes_modules_and_widgets'),
241
+			7
242
+		);
243
+		// you wanna get going? I wanna get going... let's get going!
244
+		add_action(
245
+			'AHEE__EE_Bootstrap__brew_espresso',
246
+			array($this, 'brew_espresso'),
247
+			9
248
+		);
249
+		// other housekeeping
250
+		// exclude EE critical pages from wp_list_pages
251
+		add_filter(
252
+			'wp_list_pages_excludes',
253
+			array($this, 'remove_pages_from_wp_list_pages'),
254
+			10
255
+		);
256
+		// ALL EE Addons should use the following hook point to attach their initial setup too
257
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
258
+		do_action('AHEE__EE_System__construct__complete', $this);
259
+	}
260
+
261
+
262
+	/**
263
+	 * load and setup EE_Capabilities
264
+	 *
265
+	 * @return void
266
+	 */
267
+	public function loadCapabilities()
268
+	{
269
+		$this->capabilities = $this->loader->getShared('EE_Capabilities');
270
+		add_action(
271
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
272
+			function () {
273
+				LoaderFactory::getLoader()->getShared('EE_Payment_Method_Manager');
274
+			}
275
+		);
276
+	}
277
+
278
+
279
+	/**
280
+	 * create and cache the CommandBus, and also add middleware
281
+	 * The CapChecker middleware requires the use of EE_Capabilities
282
+	 * which is why we need to load the CommandBus after Caps are set up
283
+	 *
284
+	 * @return void
285
+	 */
286
+	public function loadCommandBus()
287
+	{
288
+		$this->loader->getShared(
289
+			'CommandBusInterface',
290
+			array(
291
+				null,
292
+				apply_filters(
293
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
294
+					array(
295
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\CapChecker'),
296
+						$this->loader->getShared('EventEspresso\core\services\commands\middleware\AddActionHook'),
297
+					)
298
+				),
299
+			)
300
+		);
301
+	}
302
+
303
+
304
+	/**
305
+	 * @return void
306
+	 * @throws EE_Error
307
+	 */
308
+	public function loadPluginApi()
309
+	{
310
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
311
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
312
+		EEH_Autoloader::register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
313
+		$this->loader->getShared('EE_Request_Handler');
314
+	}
315
+
316
+
317
+	/**
318
+	 * @param string $addon_name
319
+	 * @param string $version_constant
320
+	 * @param string $min_version_required
321
+	 * @param string $load_callback
322
+	 * @param string $plugin_file_constant
323
+	 * @return void
324
+	 */
325
+	private function deactivateIncompatibleAddon(
326
+		$addon_name,
327
+		$version_constant,
328
+		$min_version_required,
329
+		$load_callback,
330
+		$plugin_file_constant
331
+	) {
332
+		if (! defined($version_constant)) {
333
+			return;
334
+		}
335
+		$addon_version = constant($version_constant);
336
+		if ($addon_version && version_compare($addon_version, $min_version_required, '<')) {
337
+			remove_action('AHEE__EE_System__load_espresso_addons', $load_callback);
338
+			if (! function_exists('deactivate_plugins')) {
339
+				require_once ABSPATH . 'wp-admin/includes/plugin.php';
340
+			}
341
+			deactivate_plugins(plugin_basename(constant($plugin_file_constant)));
342
+			unset($_GET['activate'], $_REQUEST['activate'], $_GET['activate-multi'], $_REQUEST['activate-multi']);
343
+			EE_Error::add_error(
344
+				sprintf(
345
+					esc_html__(
346
+						'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.',
347
+						'event_espresso'
348
+					),
349
+					$addon_name,
350
+					$min_version_required
351
+				),
352
+				__FILE__,
353
+				__FUNCTION__ . "({$addon_name})",
354
+				__LINE__
355
+			);
356
+			EE_Error::get_notices(false, true);
357
+		}
358
+	}
359
+
360
+
361
+	/**
362
+	 * load_espresso_addons
363
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
364
+	 * this is hooked into both:
365
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
366
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
367
+	 *    and the WP 'activate_plugin' hook point
368
+	 *
369
+	 * @access public
370
+	 * @return void
371
+	 */
372
+	public function load_espresso_addons()
373
+	{
374
+		$this->deactivateIncompatibleAddon(
375
+			'Wait Lists',
376
+			'EE_WAIT_LISTS_VERSION',
377
+			'1.0.0.beta.074',
378
+			'load_espresso_wait_lists',
379
+			'EE_WAIT_LISTS_PLUGIN_FILE'
380
+		);
381
+		$this->deactivateIncompatibleAddon(
382
+			'Automated Upcoming Event Notifications',
383
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_VERSION',
384
+			'1.0.0.beta.091',
385
+			'load_espresso_automated_upcoming_event_notification',
386
+			'EE_AUTOMATED_UPCOMING_EVENT_NOTIFICATION_PLUGIN_FILE'
387
+		);
388
+		do_action('AHEE__EE_System__load_espresso_addons');
389
+		// if the WP API basic auth plugin isn't already loaded, load it now.
390
+		// We want it for mobile apps. Just include the entire plugin
391
+		// also, don't load the basic auth when a plugin is getting activated, because
392
+		// it could be the basic auth plugin, and it doesn't check if its methods are already defined
393
+		// and causes a fatal error
394
+		if (($this->request->isWordPressApi() || $this->request->isApi())
395
+			&& $this->request->getRequestParam('activate') !== 'true'
396
+			&& ! function_exists('json_basic_auth_handler')
397
+			&& ! function_exists('json_basic_auth_error')
398
+			&& ! in_array(
399
+				$this->request->getRequestParam('action'),
400
+				array('activate', 'activate-selected'),
401
+				true
402
+			)
403
+		) {
404
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth/basic-auth.php';
405
+		}
406
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
407
+	}
408
+
409
+
410
+	/**
411
+	 * detect_activations_or_upgrades
412
+	 * Checks for activation or upgrade of core first;
413
+	 * then also checks if any registered addons have been activated or upgraded
414
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
415
+	 * which runs during the WP 'plugins_loaded' action at priority 3
416
+	 *
417
+	 * @access public
418
+	 * @return void
419
+	 */
420
+	public function detect_activations_or_upgrades()
421
+	{
422
+		// first off: let's make sure to handle core
423
+		$this->detect_if_activation_or_upgrade();
424
+		foreach ($this->registry->addons as $addon) {
425
+			if ($addon instanceof EE_Addon) {
426
+				// detect teh request type for that addon
427
+				$addon->detect_activation_or_upgrade();
428
+			}
429
+		}
430
+	}
431
+
432
+
433
+	/**
434
+	 * detect_if_activation_or_upgrade
435
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
436
+	 * and either setting up the DB or setting up maintenance mode etc.
437
+	 *
438
+	 * @access public
439
+	 * @return void
440
+	 */
441
+	public function detect_if_activation_or_upgrade()
442
+	{
443
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
444
+		// check if db has been updated, or if its a brand-new installation
445
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
446
+		$request_type = $this->detect_req_type($espresso_db_update);
447
+		// EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
448
+		switch ($request_type) {
449
+			case EE_System::req_type_new_activation:
450
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
451
+				$this->_handle_core_version_change($espresso_db_update);
452
+				break;
453
+			case EE_System::req_type_reactivation:
454
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
455
+				$this->_handle_core_version_change($espresso_db_update);
456
+				break;
457
+			case EE_System::req_type_upgrade:
458
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
459
+				// migrations may be required now that we've upgraded
460
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
461
+				$this->_handle_core_version_change($espresso_db_update);
462
+				break;
463
+			case EE_System::req_type_downgrade:
464
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
465
+				// its possible migrations are no longer required
466
+				$this->maintenance_mode->set_maintenance_mode_if_db_old();
467
+				$this->_handle_core_version_change($espresso_db_update);
468
+				break;
469
+			case EE_System::req_type_normal:
470
+			default:
471
+				break;
472
+		}
473
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
474
+	}
475
+
476
+
477
+	/**
478
+	 * Updates the list of installed versions and sets hooks for
479
+	 * initializing the database later during the request
480
+	 *
481
+	 * @param array $espresso_db_update
482
+	 */
483
+	private function _handle_core_version_change($espresso_db_update)
484
+	{
485
+		$this->update_list_of_installed_versions($espresso_db_update);
486
+		// get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
487
+		add_action(
488
+			'AHEE__EE_System__perform_activations_upgrades_and_migrations',
489
+			array($this, 'initialize_db_if_no_migrations_required')
490
+		);
491
+	}
492
+
493
+
494
+	/**
495
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
496
+	 * information about what versions of EE have been installed and activated,
497
+	 * NOT necessarily the state of the database
498
+	 *
499
+	 * @param mixed $espresso_db_update           the value of the WordPress option.
500
+	 *                                            If not supplied, fetches it from the options table
501
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
502
+	 */
503
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
504
+	{
505
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
506
+		if (! $espresso_db_update) {
507
+			$espresso_db_update = get_option('espresso_db_update');
508
+		}
509
+		// check that option is an array
510
+		if (! is_array($espresso_db_update)) {
511
+			// if option is FALSE, then it never existed
512
+			if ($espresso_db_update === false) {
513
+				// make $espresso_db_update an array and save option with autoload OFF
514
+				$espresso_db_update = array();
515
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
516
+			} else {
517
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
518
+				$espresso_db_update = array($espresso_db_update => array());
519
+				update_option('espresso_db_update', $espresso_db_update);
520
+			}
521
+		} else {
522
+			$corrected_db_update = array();
523
+			// if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
524
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
525
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
526
+					// the key is an int, and the value IS NOT an array
527
+					// so it must be numerically-indexed, where values are versions installed...
528
+					// fix it!
529
+					$version_string = $should_be_array;
530
+					$corrected_db_update[ $version_string ] = array('unknown-date');
531
+				} else {
532
+					// ok it checks out
533
+					$corrected_db_update[ $should_be_version_string ] = $should_be_array;
534
+				}
535
+			}
536
+			$espresso_db_update = $corrected_db_update;
537
+			update_option('espresso_db_update', $espresso_db_update);
538
+		}
539
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
540
+		return $espresso_db_update;
541
+	}
542
+
543
+
544
+	/**
545
+	 * Does the traditional work of setting up the plugin's database and adding default data.
546
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
547
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
548
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
549
+	 * so that it will be done when migrations are finished
550
+	 *
551
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
552
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
553
+	 *                                       This is a resource-intensive job
554
+	 *                                       so we prefer to only do it when necessary
555
+	 * @return void
556
+	 * @throws EE_Error
557
+	 */
558
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
559
+	{
560
+		$request_type = $this->detect_req_type();
561
+		// only initialize system if we're not in maintenance mode.
562
+		if ($this->maintenance_mode->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
563
+			/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
564
+			$rewrite_rules = $this->loader->getShared(
565
+				'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
566
+			);
567
+			$rewrite_rules->flush();
568
+			if ($verify_schema) {
569
+				EEH_Activation::initialize_db_and_folders();
570
+			}
571
+			EEH_Activation::initialize_db_content();
572
+			EEH_Activation::system_initialization();
573
+			if ($initialize_addons_too) {
574
+				$this->initialize_addons();
575
+			}
576
+		} else {
577
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
578
+		}
579
+		if ($request_type === EE_System::req_type_new_activation
580
+			|| $request_type === EE_System::req_type_reactivation
581
+			|| (
582
+				$request_type === EE_System::req_type_upgrade
583
+				&& $this->is_major_version_change()
584
+			)
585
+		) {
586
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
587
+		}
588
+	}
589
+
590
+
591
+	/**
592
+	 * Initializes the db for all registered addons
593
+	 *
594
+	 * @throws EE_Error
595
+	 */
596
+	public function initialize_addons()
597
+	{
598
+		// foreach registered addon, make sure its db is up-to-date too
599
+		foreach ($this->registry->addons as $addon) {
600
+			if ($addon instanceof EE_Addon) {
601
+				$addon->initialize_db_if_no_migrations_required();
602
+			}
603
+		}
604
+	}
605
+
606
+
607
+	/**
608
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
609
+	 *
610
+	 * @param    array  $version_history
611
+	 * @param    string $current_version_to_add version to be added to the version history
612
+	 * @return    boolean success as to whether or not this option was changed
613
+	 */
614
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
615
+	{
616
+		if (! $version_history) {
617
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
618
+		}
619
+		if ($current_version_to_add === null) {
620
+			$current_version_to_add = espresso_version();
621
+		}
622
+		$version_history[ $current_version_to_add ][] = date('Y-m-d H:i:s', time());
623
+		// re-save
624
+		return update_option('espresso_db_update', $version_history);
625
+	}
626
+
627
+
628
+	/**
629
+	 * Detects if the current version indicated in the has existed in the list of
630
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
631
+	 *
632
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
633
+	 *                                  If not supplied, fetches it from the options table.
634
+	 *                                  Also, caches its result so later parts of the code can also know whether
635
+	 *                                  there's been an update or not. This way we can add the current version to
636
+	 *                                  espresso_db_update, but still know if this is a new install or not
637
+	 * @return int one of the constants on EE_System::req_type_
638
+	 */
639
+	public function detect_req_type($espresso_db_update = null)
640
+	{
641
+		if ($this->_req_type === null) {
642
+			$espresso_db_update = ! empty($espresso_db_update)
643
+				? $espresso_db_update
644
+				: $this->fix_espresso_db_upgrade_option();
645
+			$this->_req_type = EE_System::detect_req_type_given_activation_history(
646
+				$espresso_db_update,
647
+				'ee_espresso_activation',
648
+				espresso_version()
649
+			);
650
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
651
+			$this->request->setIsActivation($this->_req_type !== EE_System::req_type_normal);
652
+		}
653
+		return $this->_req_type;
654
+	}
655
+
656
+
657
+	/**
658
+	 * Returns whether or not there was a non-micro version change (ie, change in either
659
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
660
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
661
+	 *
662
+	 * @param $activation_history
663
+	 * @return bool
664
+	 */
665
+	private function _detect_major_version_change($activation_history)
666
+	{
667
+		$previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
668
+		$previous_version_parts = explode('.', $previous_version);
669
+		$current_version_parts = explode('.', espresso_version());
670
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
671
+			   && (
672
+				   $previous_version_parts[0] !== $current_version_parts[0]
673
+				   || $previous_version_parts[1] !== $current_version_parts[1]
674
+			   );
675
+	}
676
+
677
+
678
+	/**
679
+	 * Returns true if either the major or minor version of EE changed during this request.
680
+	 * 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
681
+	 *
682
+	 * @return bool
683
+	 */
684
+	public function is_major_version_change()
685
+	{
686
+		return $this->_major_version_change;
687
+	}
688
+
689
+
690
+	/**
691
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
692
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
693
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
694
+	 * just activated to (for core that will always be espresso_version())
695
+	 *
696
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
697
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
698
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
699
+	 *                                                 indicate that this plugin was just activated
700
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
701
+	 *                                                 espresso_version())
702
+	 * @return int one of the constants on EE_System::req_type_*
703
+	 */
704
+	public static function detect_req_type_given_activation_history(
705
+		$activation_history_for_addon,
706
+		$activation_indicator_option_name,
707
+		$version_to_upgrade_to
708
+	) {
709
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
710
+		if ($activation_history_for_addon) {
711
+			// it exists, so this isn't a completely new install
712
+			// check if this version already in that list of previously installed versions
713
+			if (! isset($activation_history_for_addon[ $version_to_upgrade_to ])) {
714
+				// it a version we haven't seen before
715
+				if ($version_is_higher === 1) {
716
+					$req_type = EE_System::req_type_upgrade;
717
+				} else {
718
+					$req_type = EE_System::req_type_downgrade;
719
+				}
720
+				delete_option($activation_indicator_option_name);
721
+			} else {
722
+				// its not an update. maybe a reactivation?
723
+				if (get_option($activation_indicator_option_name, false)) {
724
+					if ($version_is_higher === -1) {
725
+						$req_type = EE_System::req_type_downgrade;
726
+					} elseif ($version_is_higher === 0) {
727
+						// we've seen this version before, but it's an activation. must be a reactivation
728
+						$req_type = EE_System::req_type_reactivation;
729
+					} else {// $version_is_higher === 1
730
+						$req_type = EE_System::req_type_upgrade;
731
+					}
732
+					delete_option($activation_indicator_option_name);
733
+				} else {
734
+					// we've seen this version before and the activation indicate doesn't show it was just activated
735
+					if ($version_is_higher === -1) {
736
+						$req_type = EE_System::req_type_downgrade;
737
+					} elseif ($version_is_higher === 0) {
738
+						// we've seen this version before and it's not an activation. its normal request
739
+						$req_type = EE_System::req_type_normal;
740
+					} else {// $version_is_higher === 1
741
+						$req_type = EE_System::req_type_upgrade;
742
+					}
743
+				}
744
+			}
745
+		} else {
746
+			// brand new install
747
+			$req_type = EE_System::req_type_new_activation;
748
+			delete_option($activation_indicator_option_name);
749
+		}
750
+		return $req_type;
751
+	}
752
+
753
+
754
+	/**
755
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
756
+	 * the $activation_history_for_addon
757
+	 *
758
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
759
+	 *                                             sometimes containing 'unknown-date'
760
+	 * @param string $version_to_upgrade_to        (current version)
761
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
762
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
763
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
764
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
765
+	 */
766
+	private static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
767
+	{
768
+		// find the most recently-activated version
769
+		$most_recently_active_version =
770
+			EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
771
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
772
+	}
773
+
774
+
775
+	/**
776
+	 * Gets the most recently active version listed in the activation history,
777
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
778
+	 *
779
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
780
+	 *                                   sometimes containing 'unknown-date'
781
+	 * @return string
782
+	 */
783
+	private static function _get_most_recently_active_version_from_activation_history($activation_history)
784
+	{
785
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
786
+		$most_recently_active_version = '0.0.0.dev.000';
787
+		if (is_array($activation_history)) {
788
+			foreach ($activation_history as $version => $times_activated) {
789
+				// check there is a record of when this version was activated. Otherwise,
790
+				// mark it as unknown
791
+				if (! $times_activated) {
792
+					$times_activated = array('unknown-date');
793
+				}
794
+				if (is_string($times_activated)) {
795
+					$times_activated = array($times_activated);
796
+				}
797
+				foreach ($times_activated as $an_activation) {
798
+					if ($an_activation !== 'unknown-date'
799
+						&& $an_activation
800
+						   > $most_recently_active_version_activation) {
801
+						$most_recently_active_version = $version;
802
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
803
+							? '1970-01-01 00:00:00'
804
+							: $an_activation;
805
+					}
806
+				}
807
+			}
808
+		}
809
+		return $most_recently_active_version;
810
+	}
811
+
812
+
813
+	/**
814
+	 * This redirects to the about EE page after activation
815
+	 *
816
+	 * @return void
817
+	 */
818
+	public function redirect_to_about_ee()
819
+	{
820
+		$notices = EE_Error::get_notices(false);
821
+		// if current user is an admin and it's not an ajax or rest request
822
+		if (! isset($notices['errors'])
823
+			&& $this->request->isAdmin()
824
+			&& apply_filters(
825
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
826
+				$this->capabilities->current_user_can('manage_options', 'espresso_about_default')
827
+			)
828
+		) {
829
+			$query_params = array('page' => 'espresso_about');
830
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
831
+				$query_params['new_activation'] = true;
832
+			}
833
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
834
+				$query_params['reactivation'] = true;
835
+			}
836
+			$url = add_query_arg($query_params, admin_url('admin.php'));
837
+			wp_safe_redirect($url);
838
+			exit();
839
+		}
840
+	}
841
+
842
+
843
+	/**
844
+	 * load_core_configuration
845
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
846
+	 * which runs during the WP 'plugins_loaded' action at priority 5
847
+	 *
848
+	 * @return void
849
+	 * @throws ReflectionException
850
+	 * @throws Exception
851
+	 */
852
+	public function load_core_configuration()
853
+	{
854
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
855
+		$this->loader->getShared('EE_Load_Textdomain');
856
+		// load textdomain
857
+		EE_Load_Textdomain::load_textdomain();
858
+		// load caf stuff a chance to play during the activation process too.
859
+		$this->_maybe_brew_regular();
860
+		// load and setup EE_Config and EE_Network_Config
861
+		$config = $this->loader->getShared('EE_Config');
862
+		$this->loader->getShared('EE_Network_Config');
863
+		// setup autoloaders
864
+		// enable logging?
865
+		if ($config->admin->use_remote_logging) {
866
+			$this->loader->getShared('EE_Log');
867
+		}
868
+		// check for activation errors
869
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
870
+		if ($activation_errors) {
871
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
872
+			update_option('ee_plugin_activation_errors', false);
873
+		}
874
+		// get model names
875
+		$this->_parse_model_names();
876
+		// configure custom post type definitions
877
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions');
878
+		$this->loader->getShared('EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions');
879
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
880
+	}
881
+
882
+
883
+	/**
884
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
885
+	 *
886
+	 * @return void
887
+	 * @throws ReflectionException
888
+	 */
889
+	private function _parse_model_names()
890
+	{
891
+		// get all the files in the EE_MODELS folder that end in .model.php
892
+		$models = glob(EE_MODELS . '*.model.php');
893
+		$model_names = array();
894
+		$non_abstract_db_models = array();
895
+		foreach ($models as $model) {
896
+			// get model classname
897
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
898
+			$short_name = str_replace('EEM_', '', $classname);
899
+			$reflectionClass = new ReflectionClass($classname);
900
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
901
+				$non_abstract_db_models[ $short_name ] = $classname;
902
+			}
903
+			$model_names[ $short_name ] = $classname;
904
+		}
905
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
906
+		$this->registry->non_abstract_db_models = apply_filters(
907
+			'FHEE__EE_System__parse_implemented_model_names',
908
+			$non_abstract_db_models
909
+		);
910
+	}
911
+
912
+
913
+	/**
914
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
915
+	 * that need to be setup before our EE_System launches.
916
+	 *
917
+	 * @return void
918
+	 * @throws DomainException
919
+	 * @throws InvalidArgumentException
920
+	 * @throws InvalidDataTypeException
921
+	 * @throws InvalidInterfaceException
922
+	 * @throws InvalidClassException
923
+	 * @throws InvalidFilePathException
924
+	 */
925
+	private function _maybe_brew_regular()
926
+	{
927
+		/** @var Domain $domain */
928
+		$domain = DomainFactory::getShared(
929
+			new FullyQualifiedName(
930
+				'EventEspresso\core\domain\Domain'
931
+			),
932
+			array(
933
+				new FilePath(EVENT_ESPRESSO_MAIN_FILE),
934
+				Version::fromString(espresso_version()),
935
+			)
936
+		);
937
+		if ($domain->isCaffeinated()) {
938
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
939
+		}
940
+	}
941
+
942
+
943
+	/**
944
+	 * @since 4.9.71.p
945
+	 * @throws Exception
946
+	 */
947
+	public function loadRouteMatchSpecifications()
948
+	{
949
+		try {
950
+			$this->loader->getShared('EventEspresso\core\services\routing\RouteMatchSpecificationManager');
951
+			$this->loader->getShared('EventEspresso\core\services\routing\RouteCollection');
952
+			$this->router = $this->loader->getShared('EventEspresso\core\services\routing\RouteHandler');
953
+			// now load and prep all other Routes
954
+			$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\RoutingRequests');
955
+		} catch (Exception $exception) {
956
+			new ExceptionStackTraceDisplay($exception);
957
+		}
958
+		do_action('AHEE__EE_System__loadRouteMatchSpecifications');
959
+	}
960
+
961
+
962
+	/**
963
+	 * register_shortcodes_modules_and_widgets
964
+	 * generate lists of shortcodes and modules, then verify paths and classes
965
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
966
+	 * which runs during the WP 'plugins_loaded' action at priority 7
967
+	 *
968
+	 * @access public
969
+	 * @return void
970
+	 * @throws Exception
971
+	 */
972
+	public function register_shortcodes_modules_and_widgets()
973
+	{
974
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests');
975
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
976
+		// check for addons using old hook point
977
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
978
+			$this->_incompatible_addon_error();
979
+		}
980
+	}
981
+
982
+
983
+	/**
984
+	 * _incompatible_addon_error
985
+	 *
986
+	 * @access public
987
+	 * @return void
988
+	 */
989
+	private function _incompatible_addon_error()
990
+	{
991
+		// get array of classes hooking into here
992
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook(
993
+			'AHEE__EE_System__register_shortcodes_modules_and_addons'
994
+		);
995
+		if (! empty($class_names)) {
996
+			$msg = __(
997
+				'The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
998
+				'event_espresso'
999
+			);
1000
+			$msg .= '<ul>';
1001
+			foreach ($class_names as $class_name) {
1002
+				$msg .= '<li><b>Event Espresso - '
1003
+						. str_replace(
1004
+							array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'),
1005
+							'',
1006
+							$class_name
1007
+						) . '</b></li>';
1008
+			}
1009
+			$msg .= '</ul>';
1010
+			$msg .= __(
1011
+				'Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
1012
+				'event_espresso'
1013
+			);
1014
+			// save list of incompatible addons to wp-options for later use
1015
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
1016
+			if (is_admin()) {
1017
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1018
+			}
1019
+		}
1020
+	}
1021
+
1022
+
1023
+	/**
1024
+	 * brew_espresso
1025
+	 * begins the process of setting hooks for initializing EE in the correct order
1026
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
1027
+	 * which runs during the WP 'plugins_loaded' action at priority 9
1028
+	 *
1029
+	 * @return void
1030
+	 * @throws Exception
1031
+	 */
1032
+	public function brew_espresso()
1033
+	{
1034
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
1035
+		// load some final core systems
1036
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
1037
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
1038
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
1039
+		add_action('init', array($this, 'load_controllers'), 7);
1040
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
1041
+		add_action('init', array($this, 'initialize'), 10);
1042
+		add_action('init', array($this, 'initialize_last'), 100);
1043
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests');
1044
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests');
1045
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests');
1046
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
1047
+	}
1048
+
1049
+
1050
+	/**
1051
+	 *    set_hooks_for_core
1052
+	 *
1053
+	 * @access public
1054
+	 * @return    void
1055
+	 * @throws EE_Error
1056
+	 */
1057
+	public function set_hooks_for_core()
1058
+	{
1059
+		$this->_deactivate_incompatible_addons();
1060
+		do_action('AHEE__EE_System__set_hooks_for_core');
1061
+		$this->loader->getShared('EventEspresso\core\domain\values\session\SessionLifespan');
1062
+		// caps need to be initialized on every request so that capability maps are set.
1063
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/8674
1064
+		$this->registry->CAP->init_caps();
1065
+	}
1066
+
1067
+
1068
+	/**
1069
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
1070
+	 * deactivates any addons considered incompatible with the current version of EE
1071
+	 */
1072
+	private function _deactivate_incompatible_addons()
1073
+	{
1074
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
1075
+		if (! empty($incompatible_addons)) {
1076
+			$active_plugins = get_option('active_plugins', array());
1077
+			foreach ($active_plugins as $active_plugin) {
1078
+				foreach ($incompatible_addons as $incompatible_addon) {
1079
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
1080
+						unset($_GET['activate']);
1081
+						espresso_deactivate_plugin($active_plugin);
1082
+					}
1083
+				}
1084
+			}
1085
+		}
1086
+	}
1087
+
1088
+
1089
+	/**
1090
+	 *    perform_activations_upgrades_and_migrations
1091
+	 *
1092
+	 * @access public
1093
+	 * @return    void
1094
+	 */
1095
+	public function perform_activations_upgrades_and_migrations()
1096
+	{
1097
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
1098
+	}
1099
+
1100
+
1101
+	/**
1102
+	 * @return void
1103
+	 * @throws DomainException
1104
+	 */
1105
+	public function load_CPTs_and_session()
1106
+	{
1107
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
1108
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies $register_custom_taxonomies */
1109
+		$register_custom_taxonomies = $this->loader->getShared(
1110
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'
1111
+		);
1112
+		$register_custom_taxonomies->registerCustomTaxonomies();
1113
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes $register_custom_post_types */
1114
+		$register_custom_post_types = $this->loader->getShared(
1115
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'
1116
+		);
1117
+		$register_custom_post_types->registerCustomPostTypes();
1118
+		/** @var EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms */
1119
+		$register_custom_taxonomy_terms = $this->loader->getShared(
1120
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomyTerms'
1121
+		);
1122
+		$register_custom_taxonomy_terms->registerCustomTaxonomyTerms();
1123
+		// load legacy Custom Post Types and Taxonomies
1124
+		$this->loader->getShared('EE_Register_CPTs');
1125
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
1126
+	}
1127
+
1128
+
1129
+	/**
1130
+	 * load_controllers
1131
+	 * this is the best place to load any additional controllers that needs access to EE core.
1132
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
1133
+	 * time
1134
+	 *
1135
+	 * @access public
1136
+	 * @return void
1137
+	 * @throws Exception
1138
+	 */
1139
+	public function load_controllers()
1140
+	{
1141
+		do_action('AHEE__EE_System__load_controllers__start');
1142
+		// now start loading routes
1143
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests');
1144
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin');
1145
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin');
1146
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor');
1147
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage');
1148
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat');
1149
+		do_action('AHEE__EE_System__load_controllers__complete');
1150
+	}
1151
+
1152
+
1153
+	/**
1154
+	 * core_loaded_and_ready
1155
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1156
+	 *
1157
+	 * @access public
1158
+	 * @return void
1159
+	 * @throws Exception
1160
+	 */
1161
+	public function core_loaded_and_ready()
1162
+	{
1163
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests');
1164
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests');
1165
+		// integrate WP_Query with the EE models
1166
+		$this->loader->getShared('EE_CPT_Strategy');
1167
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1168
+		// always load template tags, because it's faster than checking if it's a front-end request, and many page
1169
+		// builders require these even on the front-end
1170
+		require_once EE_PUBLIC . 'template_tags.php';
1171
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1172
+	}
1173
+
1174
+
1175
+	/**
1176
+	 * initialize
1177
+	 * this is the best place to begin initializing client code
1178
+	 *
1179
+	 * @access public
1180
+	 * @return void
1181
+	 */
1182
+	public function initialize()
1183
+	{
1184
+		do_action('AHEE__EE_System__initialize');
1185
+	}
1186
+
1187
+
1188
+	/**
1189
+	 * initialize_last
1190
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1191
+	 * initialize has done so
1192
+	 *
1193
+	 * @access public
1194
+	 * @return void
1195
+	 * @throws Exception
1196
+	 */
1197
+	public function initialize_last()
1198
+	{
1199
+		do_action('AHEE__EE_System__initialize_last');
1200
+		/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1201
+		$rewrite_rules = $this->loader->getShared(
1202
+			'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1203
+		);
1204
+		$rewrite_rules->flushRewriteRules();
1205
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests');
1206
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1207
+	}
1208
+
1209
+
1210
+	/**
1211
+	 * @return void
1212
+	 */
1213
+	public function addEspressoToolbar()
1214
+	{
1215
+		$this->loader->getShared(
1216
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1217
+			array($this->registry->CAP)
1218
+		);
1219
+	}
1220
+
1221
+
1222
+	/**
1223
+	 * do_not_cache
1224
+	 * sets no cache headers and defines no cache constants for WP plugins
1225
+	 *
1226
+	 * @access public
1227
+	 * @return void
1228
+	 */
1229
+	public static function do_not_cache()
1230
+	{
1231
+		// set no cache constants
1232
+		if (! defined('DONOTCACHEPAGE')) {
1233
+			define('DONOTCACHEPAGE', true);
1234
+		}
1235
+		if (! defined('DONOTCACHCEOBJECT')) {
1236
+			define('DONOTCACHCEOBJECT', true);
1237
+		}
1238
+		if (! defined('DONOTCACHEDB')) {
1239
+			define('DONOTCACHEDB', true);
1240
+		}
1241
+		// add no cache headers
1242
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1243
+		// plus a little extra for nginx and Google Chrome
1244
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1245
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1246
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1247
+	}
1248
+
1249
+
1250
+	/**
1251
+	 *    extra_nocache_headers
1252
+	 *
1253
+	 * @access    public
1254
+	 * @param $headers
1255
+	 * @return    array
1256
+	 */
1257
+	public static function extra_nocache_headers($headers)
1258
+	{
1259
+		// for NGINX
1260
+		$headers['X-Accel-Expires'] = 0;
1261
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1262
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1263
+		return $headers;
1264
+	}
1265
+
1266
+
1267
+	/**
1268
+	 *    nocache_headers
1269
+	 *
1270
+	 * @access    public
1271
+	 * @return    void
1272
+	 */
1273
+	public static function nocache_headers()
1274
+	{
1275
+		nocache_headers();
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1281
+	 * never returned with the function.
1282
+	 *
1283
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1284
+	 * @return array
1285
+	 */
1286
+	public function remove_pages_from_wp_list_pages($exclude_array)
1287
+	{
1288
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1289
+	}
1290 1290
 }
Please login to merge, or discard this patch.
core/EE_Front_Controller.core.php 1 patch
Indentation   +463 added lines, -463 removed lines patch added patch discarded remove patch
@@ -26,467 +26,467 @@
 block discarded – undo
26 26
 final class EE_Front_Controller
27 27
 {
28 28
 
29
-    /**
30
-     * @var string $_template_path
31
-     */
32
-    private $_template_path;
33
-
34
-    /**
35
-     * @var string $_template
36
-     */
37
-    private $_template;
38
-
39
-    /**
40
-     * @type EE_Registry $Registry
41
-     */
42
-    protected $Registry;
43
-
44
-    /**
45
-     * @type EE_Request_Handler $Request_Handler
46
-     */
47
-    protected $Request_Handler;
48
-
49
-    /**
50
-     * @type EE_Module_Request_Router $Module_Request_Router
51
-     */
52
-    protected $Module_Request_Router;
53
-
54
-
55
-    /**
56
-     *    class constructor
57
-     *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
58
-     *
59
-     * @access    public
60
-     * @param \EE_Registry              $Registry
61
-     * @param \EE_Request_Handler       $Request_Handler
62
-     * @param \EE_Module_Request_Router $Module_Request_Router
63
-     */
64
-    public function __construct(
65
-        EE_Registry $Registry,
66
-        EE_Request_Handler $Request_Handler,
67
-        EE_Module_Request_Router $Module_Request_Router
68
-    ) {
69
-        $this->Registry = $Registry;
70
-        $this->Request_Handler = $Request_Handler;
71
-        $this->Module_Request_Router = $Module_Request_Router;
72
-        // load other resources and begin to actually run shortcodes and modules
73
-        add_action('wp_loaded', array($this, 'wp_loaded'), 5);
74
-        // analyse the incoming WP request
75
-        add_action('parse_request', array($this, 'get_request'), 1, 1);
76
-        // process request with module factory
77
-        add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
78
-        // before headers sent
79
-        add_action('wp', array($this, 'wp'), 5);
80
-        // primarily used to process any content shortcodes
81
-        add_action('template_redirect', array($this, 'templateRedirect'), 999);
82
-        // header
83
-        add_action('wp_head', array($this, 'header_meta_tag'), 5);
84
-        add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
85
-        add_filter('template_include', array($this, 'template_include'), 1);
86
-        // display errors
87
-        add_action('loop_start', array($this, 'display_errors'), 2);
88
-        // the content
89
-        // add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
90
-        // exclude our private cpt comments
91
-        add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
92
-        // make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
93
-        add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
94
-        // action hook EE
95
-        do_action('AHEE__EE_Front_Controller__construct__done', $this);
96
-    }
97
-
98
-
99
-    /**
100
-     * @return EE_Request_Handler
101
-     */
102
-    public function Request_Handler()
103
-    {
104
-        return $this->Request_Handler;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return EE_Module_Request_Router
110
-     */
111
-    public function Module_Request_Router()
112
-    {
113
-        return $this->Module_Request_Router;
114
-    }
115
-
116
-
117
-    /**
118
-     * @return LegacyShortcodesManager
119
-     */
120
-    public function getLegacyShortcodesManager()
121
-    {
122
-        return EE_Config::getLegacyShortcodesManager();
123
-    }
124
-
125
-
126
-
127
-
128
-
129
-    /***********************************************        INIT ACTION HOOK         ***********************************************/
130
-    /**
131
-     * filter_wp_comments
132
-     * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
133
-     * widgets/queries done on frontend
134
-     *
135
-     * @param  array $clauses array of comment clauses setup by WP_Comment_Query
136
-     * @return array array of comment clauses with modifications.
137
-     * @throws InvalidArgumentException
138
-     * @throws InvalidDataTypeException
139
-     * @throws InvalidInterfaceException
140
-     */
141
-    public function filter_wp_comments($clauses)
142
-    {
143
-        global $wpdb;
144
-        if (strpos($clauses['join'], $wpdb->posts) !== false) {
145
-            /** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
146
-            $custom_post_types = LoaderFactory::getLoader()->getShared(
147
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
148
-            );
149
-            $cpts = $custom_post_types->getPrivateCustomPostTypes();
150
-            foreach ($cpts as $cpt => $details) {
151
-                $clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
152
-            }
153
-        }
154
-        return $clauses;
155
-    }
156
-
157
-
158
-    /**
159
-     * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
160
-     *
161
-     * @param  string $url incoming url
162
-     * @return string         final assembled url
163
-     */
164
-    public function maybe_force_admin_ajax_ssl($url)
165
-    {
166
-        if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
167
-            $url = str_replace('http://', 'https://', $url);
168
-        }
169
-        return $url;
170
-    }
171
-
172
-
173
-
174
-
175
-
176
-
177
-    /***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
178
-
179
-
180
-    /**
181
-     *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
182
-     *    default priority init phases have run
183
-     *
184
-     * @access    public
185
-     * @return    void
186
-     */
187
-    public function wp_loaded()
188
-    {
189
-    }
190
-
191
-
192
-
193
-
194
-
195
-    /***********************************************        PARSE_REQUEST HOOK         ***********************************************/
196
-    /**
197
-     *    _get_request
198
-     *
199
-     * @access public
200
-     * @param WP $WP
201
-     * @return void
202
-     */
203
-    public function get_request(WP $WP)
204
-    {
205
-        do_action('AHEE__EE_Front_Controller__get_request__start');
206
-        $this->Request_Handler->parse_request($WP);
207
-        do_action('AHEE__EE_Front_Controller__get_request__complete');
208
-    }
209
-
210
-
211
-    /**
212
-     *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
213
-     *
214
-     * @access    public
215
-     * @param   WP_Query $WP_Query
216
-     * @return    void
217
-     */
218
-    public function pre_get_posts($WP_Query)
219
-    {
220
-        // only load Module_Request_Router if this is the main query
221
-        if ($this->Module_Request_Router instanceof EE_Module_Request_Router
222
-            && $WP_Query->is_main_query()
223
-        ) {
224
-            // cycle thru module routes
225
-            while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
226
-                // determine module and method for route
227
-                $module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
228
-                if ($module instanceof EED_Module) {
229
-                    // get registered view for route
230
-                    $this->_template_path = $this->Module_Request_Router->get_view($route);
231
-                    // grab module name
232
-                    $module_name = $module->module_name();
233
-                    // map the module to the module objects
234
-                    $this->Registry->modules->{$module_name} = $module;
235
-                }
236
-            }
237
-        }
238
-    }
239
-
240
-
241
-
242
-
243
-
244
-    /***********************************************        WP HOOK         ***********************************************/
245
-
246
-
247
-    /**
248
-     *    wp - basically last chance to do stuff before headers sent
249
-     *
250
-     * @access    public
251
-     * @return    void
252
-     */
253
-    public function wp()
254
-    {
255
-    }
256
-
257
-
258
-
259
-    /***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
260
-
261
-
262
-    /**
263
-     * callback for the "template_redirect" hook point
264
-     * checks sidebars for EE widgets
265
-     * loads resources and assets accordingly
266
-     *
267
-     * @return void
268
-     */
269
-    public function templateRedirect()
270
-    {
271
-        global $wp_query;
272
-        if (empty($wp_query->posts)) {
273
-            return;
274
-        }
275
-        // if we already know this is an espresso page, then load assets
276
-        $load_assets = $this->Request_Handler->is_espresso_page();
277
-        // if we are already loading assets then just move along, otherwise check for widgets
278
-        $load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars();
279
-        if ($load_assets) {
280
-            add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
281
-            add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'), 10);
282
-        }
283
-    }
284
-
285
-
286
-    /**
287
-     * builds list of active widgets then scans active sidebars looking for them
288
-     * returns true is an EE widget is found in an active sidebar
289
-     * Please Note: this does NOT mean that the sidebar or widget
290
-     * is actually in use in a given template, as that is unfortunately not known
291
-     * until a sidebar and it's widgets are actually loaded
292
-     *
293
-     * @return boolean
294
-     */
295
-    private function espresso_widgets_in_active_sidebars()
296
-    {
297
-        $espresso_widgets = array();
298
-        foreach ($this->Registry->widgets as $widget_class => $widget) {
299
-            $id_base = EspressoWidget::getIdBase($widget_class);
300
-            if (is_active_widget(false, false, $id_base)) {
301
-                $espresso_widgets[] = $id_base;
302
-            }
303
-        }
304
-        $all_sidebar_widgets = wp_get_sidebars_widgets();
305
-        foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) {
306
-            if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
307
-                foreach ($sidebar_widgets as $sidebar_widget) {
308
-                    foreach ($espresso_widgets as $espresso_widget) {
309
-                        if (strpos($sidebar_widget, $espresso_widget) !== false) {
310
-                            return true;
311
-                        }
312
-                    }
313
-                }
314
-            }
315
-        }
316
-        return false;
317
-    }
318
-
319
-
320
-    /**
321
-     *    header_meta_tag
322
-     *
323
-     * @access    public
324
-     * @return    void
325
-     */
326
-    public function header_meta_tag()
327
-    {
328
-        print(
329
-        apply_filters(
330
-            'FHEE__EE_Front_Controller__header_meta_tag',
331
-            '<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
332
-        )
333
-        );
334
-
335
-        // let's exclude all event type taxonomy term archive pages from search engine indexing
336
-        // @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
337
-        // also exclude all critical pages from indexing
338
-        if ((
339
-                is_tax('espresso_event_type')
340
-                && get_option('blog_public') !== '0'
341
-            )
342
-            || is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
343
-        ) {
344
-            print(
345
-            apply_filters(
346
-                'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
347
-                '<meta name="robots" content="noindex,follow" />' . "\n"
348
-            )
349
-            );
350
-        }
351
-    }
352
-
353
-
354
-    /**
355
-     * wp_print_scripts
356
-     *
357
-     * @return void
358
-     */
359
-    public function wp_print_scripts()
360
-    {
361
-        global $post;
362
-        if (isset($post->EE_Event)
363
-            && $post->EE_Event instanceof EE_Event
364
-            && get_post_type() === 'espresso_events'
365
-            && is_singular()
366
-        ) {
367
-            \EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
368
-        }
369
-    }
370
-
371
-
372
-    public function enqueueStyle()
373
-    {
374
-        wp_enqueue_style('espresso_default');
375
-        wp_enqueue_style('espresso_custom_css');
376
-    }
377
-
378
-
379
-
380
-    /***********************************************        WP_FOOTER         ***********************************************/
381
-
382
-
383
-    public function enqueueScripts()
384
-    {
385
-        wp_enqueue_script('espresso_core');
386
-    }
387
-
388
-
389
-    /**
390
-     * display_errors
391
-     *
392
-     * @access public
393
-     * @return void
394
-     * @throws DomainException
395
-     */
396
-    public function display_errors()
397
-    {
398
-        static $shown_already = false;
399
-        do_action('AHEE__EE_Front_Controller__display_errors__begin');
400
-        if (! $shown_already
401
-            && apply_filters('FHEE__EE_Front_Controller__display_errors', true)
402
-            && is_main_query()
403
-            && ! is_feed()
404
-            && in_the_loop()
405
-            && did_action('wp_head')
406
-            && $this->Request_Handler->is_espresso_page()
407
-        ) {
408
-            echo EE_Error::get_notices();
409
-            $shown_already = true;
410
-            EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
411
-        }
412
-        do_action('AHEE__EE_Front_Controller__display_errors__end');
413
-    }
414
-
415
-
416
-
417
-
418
-
419
-    /***********************************************        UTILITIES         ***********************************************/
420
-    /**
421
-     *    template_include
422
-     *
423
-     * @access    public
424
-     * @param   string $template_include_path
425
-     * @return    string
426
-     */
427
-    public function template_include($template_include_path = null)
428
-    {
429
-        if ($this->Request_Handler->is_espresso_page()) {
430
-            $this->_template_path = ! empty($this->_template_path)
431
-                ? basename($this->_template_path)
432
-                : basename(
433
-                    $template_include_path
434
-                );
435
-            $template_path = EEH_Template::locate_template($this->_template_path, array(), false);
436
-            $this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
437
-            $this->_template = basename($this->_template_path);
438
-            return $this->_template_path;
439
-        }
440
-        return $template_include_path;
441
-    }
442
-
443
-
444
-    /**
445
-     *    get_selected_template
446
-     *
447
-     * @access    public
448
-     * @param bool $with_path
449
-     * @return    string
450
-     */
451
-    public function get_selected_template($with_path = false)
452
-    {
453
-        return $with_path ? $this->_template_path : $this->_template;
454
-    }
455
-
456
-
457
-    /**
458
-     * @deprecated 4.9.26
459
-     * @param string $shortcode_class
460
-     * @param \WP    $wp
461
-     */
462
-    public function initialize_shortcode($shortcode_class = '', WP $wp = null)
463
-    {
464
-        \EE_Error::doing_it_wrong(
465
-            __METHOD__,
466
-            __(
467
-                'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
468
-                'event_espresso'
469
-            ),
470
-            '4.9.26'
471
-        );
472
-        $this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
473
-    }
474
-
475
-
476
-    /**
477
-     * @return void
478
-     * @deprecated 4.9.57.p
479
-     */
480
-    public function loadPersistentAdminNoticeManager()
481
-    {
482
-    }
483
-
484
-
485
-    /**
486
-     * @return void
487
-     * @deprecated 4.9.64.p
488
-     */
489
-    public function employ_CPT_Strategy()
490
-    {
491
-    }
29
+	/**
30
+	 * @var string $_template_path
31
+	 */
32
+	private $_template_path;
33
+
34
+	/**
35
+	 * @var string $_template
36
+	 */
37
+	private $_template;
38
+
39
+	/**
40
+	 * @type EE_Registry $Registry
41
+	 */
42
+	protected $Registry;
43
+
44
+	/**
45
+	 * @type EE_Request_Handler $Request_Handler
46
+	 */
47
+	protected $Request_Handler;
48
+
49
+	/**
50
+	 * @type EE_Module_Request_Router $Module_Request_Router
51
+	 */
52
+	protected $Module_Request_Router;
53
+
54
+
55
+	/**
56
+	 *    class constructor
57
+	 *    should fire after shortcode, module, addon, or other plugin's default priority init phases have run
58
+	 *
59
+	 * @access    public
60
+	 * @param \EE_Registry              $Registry
61
+	 * @param \EE_Request_Handler       $Request_Handler
62
+	 * @param \EE_Module_Request_Router $Module_Request_Router
63
+	 */
64
+	public function __construct(
65
+		EE_Registry $Registry,
66
+		EE_Request_Handler $Request_Handler,
67
+		EE_Module_Request_Router $Module_Request_Router
68
+	) {
69
+		$this->Registry = $Registry;
70
+		$this->Request_Handler = $Request_Handler;
71
+		$this->Module_Request_Router = $Module_Request_Router;
72
+		// load other resources and begin to actually run shortcodes and modules
73
+		add_action('wp_loaded', array($this, 'wp_loaded'), 5);
74
+		// analyse the incoming WP request
75
+		add_action('parse_request', array($this, 'get_request'), 1, 1);
76
+		// process request with module factory
77
+		add_action('pre_get_posts', array($this, 'pre_get_posts'), 10, 1);
78
+		// before headers sent
79
+		add_action('wp', array($this, 'wp'), 5);
80
+		// primarily used to process any content shortcodes
81
+		add_action('template_redirect', array($this, 'templateRedirect'), 999);
82
+		// header
83
+		add_action('wp_head', array($this, 'header_meta_tag'), 5);
84
+		add_action('wp_print_scripts', array($this, 'wp_print_scripts'), 10);
85
+		add_filter('template_include', array($this, 'template_include'), 1);
86
+		// display errors
87
+		add_action('loop_start', array($this, 'display_errors'), 2);
88
+		// the content
89
+		// add_filter( 'the_content', array( $this, 'the_content' ), 5, 1 );
90
+		// exclude our private cpt comments
91
+		add_filter('comments_clauses', array($this, 'filter_wp_comments'), 10, 1);
92
+		// make sure any ajax requests will respect the url schema when requests are made against admin-ajax.php (http:// or https://)
93
+		add_filter('admin_url', array($this, 'maybe_force_admin_ajax_ssl'), 200, 1);
94
+		// action hook EE
95
+		do_action('AHEE__EE_Front_Controller__construct__done', $this);
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return EE_Request_Handler
101
+	 */
102
+	public function Request_Handler()
103
+	{
104
+		return $this->Request_Handler;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return EE_Module_Request_Router
110
+	 */
111
+	public function Module_Request_Router()
112
+	{
113
+		return $this->Module_Request_Router;
114
+	}
115
+
116
+
117
+	/**
118
+	 * @return LegacyShortcodesManager
119
+	 */
120
+	public function getLegacyShortcodesManager()
121
+	{
122
+		return EE_Config::getLegacyShortcodesManager();
123
+	}
124
+
125
+
126
+
127
+
128
+
129
+	/***********************************************        INIT ACTION HOOK         ***********************************************/
130
+	/**
131
+	 * filter_wp_comments
132
+	 * This simply makes sure that any "private" EE CPTs do not have their comments show up in any wp comment
133
+	 * widgets/queries done on frontend
134
+	 *
135
+	 * @param  array $clauses array of comment clauses setup by WP_Comment_Query
136
+	 * @return array array of comment clauses with modifications.
137
+	 * @throws InvalidArgumentException
138
+	 * @throws InvalidDataTypeException
139
+	 * @throws InvalidInterfaceException
140
+	 */
141
+	public function filter_wp_comments($clauses)
142
+	{
143
+		global $wpdb;
144
+		if (strpos($clauses['join'], $wpdb->posts) !== false) {
145
+			/** @var EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions $custom_post_types */
146
+			$custom_post_types = LoaderFactory::getLoader()->getShared(
147
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'
148
+			);
149
+			$cpts = $custom_post_types->getPrivateCustomPostTypes();
150
+			foreach ($cpts as $cpt => $details) {
151
+				$clauses['where'] .= $wpdb->prepare(" AND $wpdb->posts.post_type != %s", $cpt);
152
+			}
153
+		}
154
+		return $clauses;
155
+	}
156
+
157
+
158
+	/**
159
+	 * this just makes sure that if the site is using ssl that we force that for any admin ajax calls from frontend
160
+	 *
161
+	 * @param  string $url incoming url
162
+	 * @return string         final assembled url
163
+	 */
164
+	public function maybe_force_admin_ajax_ssl($url)
165
+	{
166
+		if (is_ssl() && preg_match('/admin-ajax.php/', $url)) {
167
+			$url = str_replace('http://', 'https://', $url);
168
+		}
169
+		return $url;
170
+	}
171
+
172
+
173
+
174
+
175
+
176
+
177
+	/***********************************************        WP_LOADED ACTION HOOK         ***********************************************/
178
+
179
+
180
+	/**
181
+	 *    wp_loaded - should fire after shortcode, module, addon, or other plugin's have been registered and their
182
+	 *    default priority init phases have run
183
+	 *
184
+	 * @access    public
185
+	 * @return    void
186
+	 */
187
+	public function wp_loaded()
188
+	{
189
+	}
190
+
191
+
192
+
193
+
194
+
195
+	/***********************************************        PARSE_REQUEST HOOK         ***********************************************/
196
+	/**
197
+	 *    _get_request
198
+	 *
199
+	 * @access public
200
+	 * @param WP $WP
201
+	 * @return void
202
+	 */
203
+	public function get_request(WP $WP)
204
+	{
205
+		do_action('AHEE__EE_Front_Controller__get_request__start');
206
+		$this->Request_Handler->parse_request($WP);
207
+		do_action('AHEE__EE_Front_Controller__get_request__complete');
208
+	}
209
+
210
+
211
+	/**
212
+	 *    pre_get_posts - basically a module factory for instantiating modules and selecting the final view template
213
+	 *
214
+	 * @access    public
215
+	 * @param   WP_Query $WP_Query
216
+	 * @return    void
217
+	 */
218
+	public function pre_get_posts($WP_Query)
219
+	{
220
+		// only load Module_Request_Router if this is the main query
221
+		if ($this->Module_Request_Router instanceof EE_Module_Request_Router
222
+			&& $WP_Query->is_main_query()
223
+		) {
224
+			// cycle thru module routes
225
+			while ($route = $this->Module_Request_Router->get_route($WP_Query)) {
226
+				// determine module and method for route
227
+				$module = $this->Module_Request_Router->resolve_route($route[0], $route[1]);
228
+				if ($module instanceof EED_Module) {
229
+					// get registered view for route
230
+					$this->_template_path = $this->Module_Request_Router->get_view($route);
231
+					// grab module name
232
+					$module_name = $module->module_name();
233
+					// map the module to the module objects
234
+					$this->Registry->modules->{$module_name} = $module;
235
+				}
236
+			}
237
+		}
238
+	}
239
+
240
+
241
+
242
+
243
+
244
+	/***********************************************        WP HOOK         ***********************************************/
245
+
246
+
247
+	/**
248
+	 *    wp - basically last chance to do stuff before headers sent
249
+	 *
250
+	 * @access    public
251
+	 * @return    void
252
+	 */
253
+	public function wp()
254
+	{
255
+	}
256
+
257
+
258
+
259
+	/***********************     GET_HEADER && WP_HEAD HOOK     ***********************/
260
+
261
+
262
+	/**
263
+	 * callback for the "template_redirect" hook point
264
+	 * checks sidebars for EE widgets
265
+	 * loads resources and assets accordingly
266
+	 *
267
+	 * @return void
268
+	 */
269
+	public function templateRedirect()
270
+	{
271
+		global $wp_query;
272
+		if (empty($wp_query->posts)) {
273
+			return;
274
+		}
275
+		// if we already know this is an espresso page, then load assets
276
+		$load_assets = $this->Request_Handler->is_espresso_page();
277
+		// if we are already loading assets then just move along, otherwise check for widgets
278
+		$load_assets = $load_assets ? $load_assets : $this->espresso_widgets_in_active_sidebars();
279
+		if ($load_assets) {
280
+			add_action('wp_enqueue_scripts', array($this, 'enqueueStyle'), 10);
281
+			add_action('wp_enqueue_scripts', array($this, 'enqueueScripts'), 10);
282
+		}
283
+	}
284
+
285
+
286
+	/**
287
+	 * builds list of active widgets then scans active sidebars looking for them
288
+	 * returns true is an EE widget is found in an active sidebar
289
+	 * Please Note: this does NOT mean that the sidebar or widget
290
+	 * is actually in use in a given template, as that is unfortunately not known
291
+	 * until a sidebar and it's widgets are actually loaded
292
+	 *
293
+	 * @return boolean
294
+	 */
295
+	private function espresso_widgets_in_active_sidebars()
296
+	{
297
+		$espresso_widgets = array();
298
+		foreach ($this->Registry->widgets as $widget_class => $widget) {
299
+			$id_base = EspressoWidget::getIdBase($widget_class);
300
+			if (is_active_widget(false, false, $id_base)) {
301
+				$espresso_widgets[] = $id_base;
302
+			}
303
+		}
304
+		$all_sidebar_widgets = wp_get_sidebars_widgets();
305
+		foreach ($all_sidebar_widgets as $sidebar_name => $sidebar_widgets) {
306
+			if (is_array($sidebar_widgets) && ! empty($sidebar_widgets)) {
307
+				foreach ($sidebar_widgets as $sidebar_widget) {
308
+					foreach ($espresso_widgets as $espresso_widget) {
309
+						if (strpos($sidebar_widget, $espresso_widget) !== false) {
310
+							return true;
311
+						}
312
+					}
313
+				}
314
+			}
315
+		}
316
+		return false;
317
+	}
318
+
319
+
320
+	/**
321
+	 *    header_meta_tag
322
+	 *
323
+	 * @access    public
324
+	 * @return    void
325
+	 */
326
+	public function header_meta_tag()
327
+	{
328
+		print(
329
+		apply_filters(
330
+			'FHEE__EE_Front_Controller__header_meta_tag',
331
+			'<meta name="generator" content="Event Espresso Version ' . EVENT_ESPRESSO_VERSION . "\" />\n"
332
+		)
333
+		);
334
+
335
+		// let's exclude all event type taxonomy term archive pages from search engine indexing
336
+		// @see https://events.codebasehq.com/projects/event-espresso/tickets/10249
337
+		// also exclude all critical pages from indexing
338
+		if ((
339
+				is_tax('espresso_event_type')
340
+				&& get_option('blog_public') !== '0'
341
+			)
342
+			|| is_page(EE_Registry::instance()->CFG->core->get_critical_pages_array())
343
+		) {
344
+			print(
345
+			apply_filters(
346
+				'FHEE__EE_Front_Controller__header_meta_tag__noindex_for_event_type',
347
+				'<meta name="robots" content="noindex,follow" />' . "\n"
348
+			)
349
+			);
350
+		}
351
+	}
352
+
353
+
354
+	/**
355
+	 * wp_print_scripts
356
+	 *
357
+	 * @return void
358
+	 */
359
+	public function wp_print_scripts()
360
+	{
361
+		global $post;
362
+		if (isset($post->EE_Event)
363
+			&& $post->EE_Event instanceof EE_Event
364
+			&& get_post_type() === 'espresso_events'
365
+			&& is_singular()
366
+		) {
367
+			\EEH_Schema::add_json_linked_data_for_event($post->EE_Event);
368
+		}
369
+	}
370
+
371
+
372
+	public function enqueueStyle()
373
+	{
374
+		wp_enqueue_style('espresso_default');
375
+		wp_enqueue_style('espresso_custom_css');
376
+	}
377
+
378
+
379
+
380
+	/***********************************************        WP_FOOTER         ***********************************************/
381
+
382
+
383
+	public function enqueueScripts()
384
+	{
385
+		wp_enqueue_script('espresso_core');
386
+	}
387
+
388
+
389
+	/**
390
+	 * display_errors
391
+	 *
392
+	 * @access public
393
+	 * @return void
394
+	 * @throws DomainException
395
+	 */
396
+	public function display_errors()
397
+	{
398
+		static $shown_already = false;
399
+		do_action('AHEE__EE_Front_Controller__display_errors__begin');
400
+		if (! $shown_already
401
+			&& apply_filters('FHEE__EE_Front_Controller__display_errors', true)
402
+			&& is_main_query()
403
+			&& ! is_feed()
404
+			&& in_the_loop()
405
+			&& did_action('wp_head')
406
+			&& $this->Request_Handler->is_espresso_page()
407
+		) {
408
+			echo EE_Error::get_notices();
409
+			$shown_already = true;
410
+			EEH_Template::display_template(EE_TEMPLATES . 'espresso-ajax-notices.template.php');
411
+		}
412
+		do_action('AHEE__EE_Front_Controller__display_errors__end');
413
+	}
414
+
415
+
416
+
417
+
418
+
419
+	/***********************************************        UTILITIES         ***********************************************/
420
+	/**
421
+	 *    template_include
422
+	 *
423
+	 * @access    public
424
+	 * @param   string $template_include_path
425
+	 * @return    string
426
+	 */
427
+	public function template_include($template_include_path = null)
428
+	{
429
+		if ($this->Request_Handler->is_espresso_page()) {
430
+			$this->_template_path = ! empty($this->_template_path)
431
+				? basename($this->_template_path)
432
+				: basename(
433
+					$template_include_path
434
+				);
435
+			$template_path = EEH_Template::locate_template($this->_template_path, array(), false);
436
+			$this->_template_path = ! empty($template_path) ? $template_path : $template_include_path;
437
+			$this->_template = basename($this->_template_path);
438
+			return $this->_template_path;
439
+		}
440
+		return $template_include_path;
441
+	}
442
+
443
+
444
+	/**
445
+	 *    get_selected_template
446
+	 *
447
+	 * @access    public
448
+	 * @param bool $with_path
449
+	 * @return    string
450
+	 */
451
+	public function get_selected_template($with_path = false)
452
+	{
453
+		return $with_path ? $this->_template_path : $this->_template;
454
+	}
455
+
456
+
457
+	/**
458
+	 * @deprecated 4.9.26
459
+	 * @param string $shortcode_class
460
+	 * @param \WP    $wp
461
+	 */
462
+	public function initialize_shortcode($shortcode_class = '', WP $wp = null)
463
+	{
464
+		\EE_Error::doing_it_wrong(
465
+			__METHOD__,
466
+			__(
467
+				'Usage is deprecated. Please use \EventEspresso\core\services\shortcodes\LegacyShortcodesManager::initializeShortcode() instead.',
468
+				'event_espresso'
469
+			),
470
+			'4.9.26'
471
+		);
472
+		$this->getLegacyShortcodesManager()->initializeShortcode($shortcode_class, $wp);
473
+	}
474
+
475
+
476
+	/**
477
+	 * @return void
478
+	 * @deprecated 4.9.57.p
479
+	 */
480
+	public function loadPersistentAdminNoticeManager()
481
+	{
482
+	}
483
+
484
+
485
+	/**
486
+	 * @return void
487
+	 * @deprecated 4.9.64.p
488
+	 */
489
+	public function employ_CPT_Strategy()
490
+	{
491
+	}
492 492
 }
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 2 patches
Indentation   +976 added lines, -976 removed lines patch added patch discarded remove patch
@@ -21,980 +21,980 @@
 block discarded – undo
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
-     * @type EE_Dependency_Map $_instance
55
-     */
56
-    protected static $_instance;
57
-
58
-    /**
59
-     * @var ClassInterfaceCache $class_cache
60
-     */
61
-    private $class_cache;
62
-
63
-    /**
64
-     * @type RequestInterface $request
65
-     */
66
-    protected $request;
67
-
68
-    /**
69
-     * @type LegacyRequestInterface $legacy_request
70
-     */
71
-    protected $legacy_request;
72
-
73
-    /**
74
-     * @type ResponseInterface $response
75
-     */
76
-    protected $response;
77
-
78
-    /**
79
-     * @type LoaderInterface $loader
80
-     */
81
-    protected $loader;
82
-
83
-    /**
84
-     * @type array $_dependency_map
85
-     */
86
-    protected $_dependency_map = [];
87
-
88
-    /**
89
-     * @type array $_class_loaders
90
-     */
91
-    protected $_class_loaders = [];
92
-
93
-
94
-    /**
95
-     * EE_Dependency_Map constructor.
96
-     *
97
-     * @param ClassInterfaceCache $class_cache
98
-     */
99
-    protected function __construct(ClassInterfaceCache $class_cache)
100
-    {
101
-        $this->class_cache = $class_cache;
102
-        do_action('EE_Dependency_Map____construct', $this);
103
-    }
104
-
105
-
106
-    /**
107
-     * @return void
108
-     * @throws InvalidAliasException
109
-     */
110
-    public function initialize()
111
-    {
112
-        $this->_register_core_dependencies();
113
-        $this->_register_core_class_loaders();
114
-        $this->_register_core_aliases();
115
-    }
116
-
117
-
118
-    /**
119
-     * @singleton method used to instantiate class object
120
-     * @param ClassInterfaceCache|null $class_cache
121
-     * @return EE_Dependency_Map
122
-     */
123
-    public static function instance(ClassInterfaceCache $class_cache = null)
124
-    {
125
-        // check if class object is instantiated, and instantiated properly
126
-        if (! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
127
-            && $class_cache instanceof ClassInterfaceCache
128
-        ) {
129
-            EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
130
-        }
131
-        return EE_Dependency_Map::$_instance;
132
-    }
133
-
134
-
135
-    /**
136
-     * @param RequestInterface $request
137
-     */
138
-    public function setRequest(RequestInterface $request)
139
-    {
140
-        $this->request = $request;
141
-    }
142
-
143
-
144
-    /**
145
-     * @param LegacyRequestInterface $legacy_request
146
-     */
147
-    public function setLegacyRequest(LegacyRequestInterface $legacy_request)
148
-    {
149
-        $this->legacy_request = $legacy_request;
150
-    }
151
-
152
-
153
-    /**
154
-     * @param ResponseInterface $response
155
-     */
156
-    public function setResponse(ResponseInterface $response)
157
-    {
158
-        $this->response = $response;
159
-    }
160
-
161
-
162
-    /**
163
-     * @param LoaderInterface $loader
164
-     */
165
-    public function setLoader(LoaderInterface $loader)
166
-    {
167
-        $this->loader = $loader;
168
-    }
169
-
170
-
171
-    /**
172
-     * @param string $class
173
-     * @param array  $dependencies
174
-     * @param int    $overwrite
175
-     * @return bool
176
-     */
177
-    public static function register_dependencies(
178
-        $class,
179
-        array $dependencies,
180
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
181
-    ) {
182
-        return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite);
183
-    }
184
-
185
-
186
-    /**
187
-     * Assigns an array of class names and corresponding load sources (new or cached)
188
-     * to the class specified by the first parameter.
189
-     * IMPORTANT !!!
190
-     * The order of elements in the incoming $dependencies array MUST match
191
-     * the order of the constructor parameters for the class in question.
192
-     * This is especially important when overriding any existing dependencies that are registered.
193
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
194
-     *
195
-     * @param string $class
196
-     * @param array  $dependencies
197
-     * @param int    $overwrite
198
-     * @return bool
199
-     */
200
-    public function registerDependencies(
201
-        $class,
202
-        array $dependencies,
203
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
204
-    ) {
205
-        $class = trim($class, '\\');
206
-        $registered = false;
207
-        if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
208
-            EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
209
-        }
210
-        // we need to make sure that any aliases used when registering a dependency
211
-        // get resolved to the correct class name
212
-        foreach ($dependencies as $dependency => $load_source) {
213
-            $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
214
-            if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
215
-                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
216
-            ) {
217
-                unset($dependencies[ $dependency ]);
218
-                $dependencies[ $alias ] = $load_source;
219
-                $registered = true;
220
-            }
221
-        }
222
-        // now add our two lists of dependencies together.
223
-        // using Union (+=) favours the arrays in precedence from left to right,
224
-        // so $dependencies is NOT overwritten because it is listed first
225
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
226
-        // Union is way faster than array_merge() but should be used with caution...
227
-        // especially with numerically indexed arrays
228
-        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
229
-        // now we need to ensure that the resulting dependencies
230
-        // array only has the entries that are required for the class
231
-        // so first count how many dependencies were originally registered for the class
232
-        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
233
-        // if that count is non-zero (meaning dependencies were already registered)
234
-        EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
235
-            // then truncate the  final array to match that count
236
-            ? array_slice($dependencies, 0, $dependency_count)
237
-            // otherwise just take the incoming array because nothing previously existed
238
-            : $dependencies;
239
-        return $registered;
240
-    }
241
-
242
-
243
-    /**
244
-     * @param string $class_name
245
-     * @param string $loader
246
-     * @return bool
247
-     * @throws DomainException
248
-     */
249
-    public static function register_class_loader($class_name, $loader = 'load_core')
250
-    {
251
-        return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader);
252
-    }
253
-
254
-
255
-    /**
256
-     * @param string $class_name
257
-     * @param string $loader
258
-     * @return bool
259
-     * @throws DomainException
260
-     */
261
-    public function registerClassLoader($class_name, $loader = 'load_core')
262
-    {
263
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
264
-            throw new DomainException(
265
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
266
-            );
267
-        }
268
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
269
-        if (! is_callable($loader)
270
-            && (
271
-                strpos($loader, 'load_') !== 0
272
-                || ! method_exists('EE_Registry', $loader)
273
-            )
274
-        ) {
275
-            throw new DomainException(
276
-                sprintf(
277
-                    esc_html__(
278
-                        '"%1$s" is not a valid loader method on EE_Registry.',
279
-                        'event_espresso'
280
-                    ),
281
-                    $loader
282
-                )
283
-            );
284
-        }
285
-        $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
286
-        if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
287
-            EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
288
-            return true;
289
-        }
290
-        return false;
291
-    }
292
-
293
-
294
-    /**
295
-     * @return array
296
-     */
297
-    public function dependency_map()
298
-    {
299
-        return $this->_dependency_map;
300
-    }
301
-
302
-
303
-    /**
304
-     * returns TRUE if dependency map contains a listing for the provided class name
305
-     *
306
-     * @param string $class_name
307
-     * @return boolean
308
-     */
309
-    public function has($class_name = '')
310
-    {
311
-        // all legacy models have the same dependencies
312
-        if (strpos($class_name, 'EEM_') === 0) {
313
-            $class_name = 'LEGACY_MODELS';
314
-        }
315
-        return isset($this->_dependency_map[ $class_name ]);
316
-    }
317
-
318
-
319
-    /**
320
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
321
-     *
322
-     * @param string $class_name
323
-     * @param string $dependency
324
-     * @return bool
325
-     */
326
-    public function has_dependency_for_class($class_name = '', $dependency = '')
327
-    {
328
-        // all legacy models have the same dependencies
329
-        if (strpos($class_name, 'EEM_') === 0) {
330
-            $class_name = 'LEGACY_MODELS';
331
-        }
332
-        $dependency = $this->getFqnForAlias($dependency, $class_name);
333
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
334
-    }
335
-
336
-
337
-    /**
338
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
339
-     *
340
-     * @param string $class_name
341
-     * @param string $dependency
342
-     * @return int
343
-     */
344
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
345
-    {
346
-        // all legacy models have the same dependencies
347
-        if (strpos($class_name, 'EEM_') === 0) {
348
-            $class_name = 'LEGACY_MODELS';
349
-        }
350
-        $dependency = $this->getFqnForAlias($dependency);
351
-        return $this->has_dependency_for_class($class_name, $dependency)
352
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
353
-            : EE_Dependency_Map::not_registered;
354
-    }
355
-
356
-
357
-    /**
358
-     * @param string $class_name
359
-     * @return string | Closure
360
-     */
361
-    public function class_loader($class_name)
362
-    {
363
-        // all legacy models use load_model()
364
-        if (strpos($class_name, 'EEM_') === 0) {
365
-            return 'load_model';
366
-        }
367
-        // EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
368
-        // perform strpos() first to avoid loading regex every time we load a class
369
-        if (strpos($class_name, 'EE_CPT_') === 0
370
-            && preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
371
-        ) {
372
-            return 'load_core';
373
-        }
374
-        $class_name = $this->getFqnForAlias($class_name);
375
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
376
-    }
377
-
378
-
379
-    /**
380
-     * @return array
381
-     */
382
-    public function class_loaders()
383
-    {
384
-        return $this->_class_loaders;
385
-    }
386
-
387
-
388
-    /**
389
-     * adds an alias for a classname
390
-     *
391
-     * @param string $fqcn      the class name that should be used (concrete class to replace interface)
392
-     * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
393
-     * @param string $for_class the class that has the dependency (is type hinting for the interface)
394
-     * @throws InvalidAliasException
395
-     */
396
-    public function add_alias($fqcn, $alias, $for_class = '')
397
-    {
398
-        $this->class_cache->addAlias($fqcn, $alias, $for_class);
399
-    }
400
-
401
-
402
-    /**
403
-     * Returns TRUE if the provided fully qualified name IS an alias
404
-     * WHY?
405
-     * Because if a class is type hinting for a concretion,
406
-     * then why would we need to find another class to supply it?
407
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
408
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
409
-     * Don't go looking for some substitute.
410
-     * Whereas if a class is type hinting for an interface...
411
-     * then we need to find an actual class to use.
412
-     * So the interface IS the alias for some other FQN,
413
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
414
-     * represents some other class.
415
-     *
416
-     * @param string $fqn
417
-     * @param string $for_class
418
-     * @return bool
419
-     */
420
-    public function isAlias($fqn = '', $for_class = '')
421
-    {
422
-        return $this->class_cache->isAlias($fqn, $for_class);
423
-    }
424
-
425
-
426
-    /**
427
-     * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
428
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
429
-     *  for example:
430
-     *      if the following two entries were added to the _aliases array:
431
-     *          array(
432
-     *              'interface_alias'           => 'some\namespace\interface'
433
-     *              'some\namespace\interface'  => 'some\namespace\classname'
434
-     *          )
435
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
-     *      to load an instance of 'some\namespace\classname'
437
-     *
438
-     * @param string $alias
439
-     * @param string $for_class
440
-     * @return string
441
-     */
442
-    public function getFqnForAlias($alias = '', $for_class = '')
443
-    {
444
-        return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
445
-    }
446
-
447
-
448
-    /**
449
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
450
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
451
-     * This is done by using the following class constants:
452
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
453
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
454
-     */
455
-    protected function _register_core_dependencies()
456
-    {
457
-        $this->_dependency_map = [
458
-            'EE_Request_Handler'                                                                                          => [
459
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
460
-            ],
461
-            'EE_System'                                                                                                   => [
462
-                'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
463
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
464
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
465
-                'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
466
-            ],
467
-            'EE_Cart'                                                                                                     => [
468
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
469
-            ],
470
-            'EE_Messenger_Collection_Loader'                                                                              => [
471
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
-            ],
473
-            'EE_Message_Type_Collection_Loader'                                                                           => [
474
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
-            ],
476
-            'EE_Message_Resource_Manager'                                                                                 => [
477
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
-            ],
481
-            'EE_Message_Factory'                                                                                          => [
482
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
-            ],
484
-            'EE_messages'                                                                                                 => [
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ],
487
-            'EE_Messages_Generator'                                                                                       => [
488
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
-            ],
493
-            'EE_Messages_Processor'                                                                                       => [
494
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
-            ],
496
-            'EE_Messages_Queue'                                                                                           => [
497
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
-            ],
499
-            'EE_Messages_Template_Defaults'                                                                               => [
500
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
-            ],
503
-            'EE_Message_To_Generate_From_Request'                                                                         => [
504
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
-            ],
507
-            'EventEspresso\core\services\commands\CommandBus'                                                             => [
508
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
-            ],
510
-            'EventEspresso\services\commands\CommandHandler'                                                              => [
511
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
-            ],
514
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
515
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
-            ],
517
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
518
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
-            ],
521
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => [
522
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
-            ],
524
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
525
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
-            ],
527
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
528
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
-            ],
530
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
531
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
-            ],
533
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
534
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
-            ],
536
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
537
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ],
539
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
540
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
-            ],
542
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
543
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ],
545
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
546
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
-            ],
548
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
549
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
-            ],
551
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
552
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
-            ],
554
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
555
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
-            ],
557
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
558
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
-            ],
560
-            'EventEspresso\core\services\database\TableManager'                                                           => [
561
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
-            ],
563
-            'EE_Data_Migration_Class_Base'                                                                                => [
564
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
-            ],
567
-            'EE_DMS_Core_4_1_0'                                                                                           => [
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_2_0'                                                                                           => [
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_3_0'                                                                                           => [
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_4_0'                                                                                           => [
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_5_0'                                                                                           => [
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_6_0'                                                                                           => [
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_7_0'                                                                                           => [
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_8_0'                                                                                           => [
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_9_0'                                                                                           => [
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_10_0'                                                                                          => [
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
-                'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
-            ],
608
-            'EventEspresso\core\services\assets\I18nRegistry'                                                             => [
609
-                'EventEspresso\core\domain\Domain'                 => EE_Dependency_Map::load_from_cache,
610
-                'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache,
611
-                [],
612
-            ],
613
-            'EventEspresso\core\services\assets\Registry'                                                                 => [
614
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
615
-                'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
616
-            ],
617
-            'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
618
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
619
-            ],
620
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
621
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
622
-            ],
623
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
624
-                'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
625
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
626
-            ],
627
-            'EventEspresso\core\domain\values\EmailAddress'                                                               => [
628
-                null,
629
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
630
-            ],
631
-            'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
632
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
633
-            ],
634
-            'LEGACY_MODELS'                                                                                               => [
635
-                null,
636
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
637
-            ],
638
-            'EE_Module_Request_Router'                                                                                    => [
639
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
640
-            ],
641
-            'EE_Registration_Processor'                                                                                   => [
642
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
643
-            ],
644
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
645
-                null,
646
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
647
-                'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
648
-            ],
649
-            'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
650
-                'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
651
-                'EE_Session'             => EE_Dependency_Map::load_from_cache,
652
-            ],
653
-            'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
654
-                'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
655
-                'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
656
-                'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
657
-                'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
658
-                'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
659
-            ],
660
-            'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
661
-                'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
662
-            ],
663
-            'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
664
-                'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
665
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
666
-            ],
667
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
668
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
669
-            ],
670
-            'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
671
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
672
-            ],
673
-            'EE_CPT_Strategy'                                                                                             => [
674
-                'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
675
-                'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
676
-            ],
677
-            'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
678
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
679
-            ],
680
-            'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
681
-                null,
682
-                null,
683
-                null,
684
-                'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
685
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
686
-                'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
687
-            ],
688
-            'EventEspresso\core\services\dependencies\DependencyResolver'                                                 => [
689
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
690
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
691
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
692
-            ],
693
-            'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver'                               => [
694
-                'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
695
-                'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
696
-                'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
697
-            ],
698
-            'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'                                          => [
699
-                'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
700
-                'EventEspresso\core\services\loaders\Loader'                                    => EE_Dependency_Map::load_from_cache,
701
-            ],
702
-            'EventEspresso\core\services\routing\RouteMatchSpecificationManager'                                          => [
703
-                'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
704
-                'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
705
-            ],
706
-            'EE_URL_Validation_Strategy'                                                                                  => [
707
-                null,
708
-                null,
709
-                'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
710
-            ],
711
-            'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
712
-                'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
713
-            ],
714
-            'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
715
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
716
-            ],
717
-            'EventEspresso\core\domain\services\converters\RestApiSpoofer'                                                => [
718
-                'WP_REST_Server'                                               => EE_Dependency_Map::load_from_cache,
719
-                'EED_Core_Rest_Api'                                            => EE_Dependency_Map::load_from_cache,
720
-                'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
721
-                null
722
-            ],
723
-            'EventEspresso\core\services\routing\RouteHandler'                                                            => [
724
-                'EventEspresso\core\services\loaders\Loader'          => EE_Dependency_Map::load_from_cache,
725
-                'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache,
726
-            ],
727
-            'EventEspresso\core\domain\entities\routing\handlers\shared\RoutingRequests'                                          => [
728
-                'EE_Dependency_Map'                                                                          => EE_Dependency_Map::load_from_cache,
729
-                'EventEspresso\core\services\loaders\Loader'                                                 => EE_Dependency_Map::load_from_cache,
730
-                'EventEspresso\core\services\request\Request'                                                => EE_Dependency_Map::load_from_cache,
731
-                'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' => EE_Dependency_Map::load_from_cache,
732
-            ],
733
-        ];
734
-    }
735
-
736
-
737
-    /**
738
-     * Registers how core classes are loaded.
739
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
740
-     *        'EE_Request_Handler' => 'load_core'
741
-     *        'EE_Messages_Queue'  => 'load_lib'
742
-     *        'EEH_Debug_Tools'    => 'load_helper'
743
-     * or, if greater control is required, by providing a custom closure. For example:
744
-     *        'Some_Class' => function () {
745
-     *            return new Some_Class();
746
-     *        },
747
-     * This is required for instantiating dependencies
748
-     * where an interface has been type hinted in a class constructor. For example:
749
-     *        'Required_Interface' => function () {
750
-     *            return new A_Class_That_Implements_Required_Interface();
751
-     *        },
752
-     */
753
-    protected function _register_core_class_loaders()
754
-    {
755
-        $this->_class_loaders = [
756
-            // load_core
757
-            'EE_Dependency_Map'                            => function () {
758
-                return $this;
759
-            },
760
-            'EE_Capabilities'                              => 'load_core',
761
-            'EE_Encryption'                                => 'load_core',
762
-            'EE_Front_Controller'                          => 'load_core',
763
-            'EE_Module_Request_Router'                     => 'load_core',
764
-            'EE_Registry'                                  => 'load_core',
765
-            'EE_Request'                                   => function () {
766
-                return $this->legacy_request;
767
-            },
768
-            'EventEspresso\core\services\request\Request'  => function () {
769
-                return $this->request;
770
-            },
771
-            'EventEspresso\core\services\request\Response' => function () {
772
-                return $this->response;
773
-            },
774
-            'EE_Base'                                      => 'load_core',
775
-            'EE_Request_Handler'                           => 'load_core',
776
-            'EE_Session'                                   => 'load_core',
777
-            'EE_Cron_Tasks'                                => 'load_core',
778
-            'EE_System'                                    => 'load_core',
779
-            'EE_Maintenance_Mode'                          => 'load_core',
780
-            'EE_Register_CPTs'                             => 'load_core',
781
-            'EE_Admin'                                     => 'load_core',
782
-            'EE_CPT_Strategy'                              => 'load_core',
783
-            // load_class
784
-            'EE_Registration_Processor'                    => 'load_class',
785
-            // load_lib
786
-            'EE_Message_Resource_Manager'                  => 'load_lib',
787
-            'EE_Message_Type_Collection'                   => 'load_lib',
788
-            'EE_Message_Type_Collection_Loader'            => 'load_lib',
789
-            'EE_Messenger_Collection'                      => 'load_lib',
790
-            'EE_Messenger_Collection_Loader'               => 'load_lib',
791
-            'EE_Messages_Processor'                        => 'load_lib',
792
-            'EE_Message_Repository'                        => 'load_lib',
793
-            'EE_Messages_Queue'                            => 'load_lib',
794
-            'EE_Messages_Data_Handler_Collection'          => 'load_lib',
795
-            'EE_Message_Template_Group_Collection'         => 'load_lib',
796
-            'EE_Payment_Method_Manager'                    => 'load_lib',
797
-            'EE_DMS_Core_4_1_0'                            => 'load_dms',
798
-            'EE_DMS_Core_4_2_0'                            => 'load_dms',
799
-            'EE_DMS_Core_4_3_0'                            => 'load_dms',
800
-            'EE_DMS_Core_4_5_0'                            => 'load_dms',
801
-            'EE_DMS_Core_4_6_0'                            => 'load_dms',
802
-            'EE_DMS_Core_4_7_0'                            => 'load_dms',
803
-            'EE_DMS_Core_4_8_0'                            => 'load_dms',
804
-            'EE_DMS_Core_4_9_0'                            => 'load_dms',
805
-            'EE_DMS_Core_4_10_0'                           => 'load_dms',
806
-            'EE_Messages_Generator'                        => static function () {
807
-                return EE_Registry::instance()->load_lib(
808
-                    'Messages_Generator',
809
-                    [],
810
-                    false,
811
-                    false
812
-                );
813
-            },
814
-            'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
815
-                return EE_Registry::instance()->load_lib(
816
-                    'Messages_Template_Defaults',
817
-                    $arguments,
818
-                    false,
819
-                    false
820
-                );
821
-            },
822
-            // load_helper
823
-            'EEH_Parse_Shortcodes'                         => static function () {
824
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
825
-                    return new EEH_Parse_Shortcodes();
826
-                }
827
-                return null;
828
-            },
829
-            'EE_Template_Config'                           => static function () {
830
-                return EE_Config::instance()->template_settings;
831
-            },
832
-            'EE_Currency_Config'                           => static function () {
833
-                return EE_Config::instance()->currency;
834
-            },
835
-            'EE_Registration_Config'                       => static function () {
836
-                return EE_Config::instance()->registration;
837
-            },
838
-            'EE_Core_Config'                               => static function () {
839
-                return EE_Config::instance()->core;
840
-            },
841
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
842
-                return LoaderFactory::getLoader();
843
-            },
844
-            'EE_Network_Config'                            => static function () {
845
-                return EE_Network_Config::instance();
846
-            },
847
-            'EE_Config'                                    => static function () {
848
-                return EE_Config::instance();
849
-            },
850
-            'EventEspresso\core\domain\Domain'             => static function () {
851
-                return DomainFactory::getEventEspressoCoreDomain();
852
-            },
853
-            'EE_Admin_Config'                              => static function () {
854
-                return EE_Config::instance()->admin;
855
-            },
856
-            'EE_Organization_Config'                       => static function () {
857
-                return EE_Config::instance()->organization;
858
-            },
859
-            'EE_Network_Core_Config'                       => static function () {
860
-                return EE_Network_Config::instance()->core;
861
-            },
862
-            'EE_Environment_Config'                        => static function () {
863
-                return EE_Config::instance()->environment;
864
-            },
865
-            'EED_Core_Rest_Api'                            => static function () {
866
-                return EED_Core_Rest_Api::instance();
867
-            },
868
-            'WP_REST_Server'                               => static function () {
869
-                return rest_get_server();
870
-            },
871
-        ];
872
-    }
873
-
874
-
875
-    /**
876
-     * can be used for supplying alternate names for classes,
877
-     * or for connecting interface names to instantiable classes
878
-     *
879
-     * @throws InvalidAliasException
880
-     */
881
-    protected function _register_core_aliases()
882
-    {
883
-        $aliases = [
884
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
885
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
886
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
887
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
888
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
889
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
890
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
891
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
892
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
893
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
894
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
895
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
896
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
897
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
898
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
899
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
900
-            'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
901
-            'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
902
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
903
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
904
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
905
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
906
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
907
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
908
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
909
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
910
-            'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
911
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
912
-            'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
913
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
914
-            'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
915
-            'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
916
-            'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
917
-            'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
918
-            'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
919
-            'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
920
-            'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
921
-            'Registration_Processor'                                                       => 'EE_Registration_Processor',
922
-        ];
923
-        foreach ($aliases as $alias => $fqn) {
924
-            if (is_array($fqn)) {
925
-                foreach ($fqn as $class => $for_class) {
926
-                    $this->class_cache->addAlias($class, $alias, $for_class);
927
-                }
928
-                continue;
929
-            }
930
-            $this->class_cache->addAlias($fqn, $alias);
931
-        }
932
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
933
-            $this->class_cache->addAlias(
934
-                'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
935
-                'EventEspresso\core\services\notices\NoticeConverterInterface'
936
-            );
937
-        }
938
-    }
939
-
940
-
941
-    /**
942
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
943
-     * request Primarily used by unit tests.
944
-     */
945
-    public function reset()
946
-    {
947
-        $this->_register_core_class_loaders();
948
-        $this->_register_core_dependencies();
949
-    }
950
-
951
-
952
-    /**
953
-     * PLZ NOTE: a better name for this method would be is_alias()
954
-     * because it returns TRUE if the provided fully qualified name IS an alias
955
-     * WHY?
956
-     * Because if a class is type hinting for a concretion,
957
-     * then why would we need to find another class to supply it?
958
-     * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
959
-     * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
960
-     * Don't go looking for some substitute.
961
-     * Whereas if a class is type hinting for an interface...
962
-     * then we need to find an actual class to use.
963
-     * So the interface IS the alias for some other FQN,
964
-     * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
965
-     * represents some other class.
966
-     *
967
-     * @param string $fqn
968
-     * @param string $for_class
969
-     * @return bool
970
-     * @deprecated 4.9.62.p
971
-     */
972
-    public function has_alias($fqn = '', $for_class = '')
973
-    {
974
-        return $this->isAlias($fqn, $for_class);
975
-    }
976
-
977
-
978
-    /**
979
-     * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
980
-     * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
981
-     * functions recursively, so that multiple aliases can be used to drill down to a FQN
982
-     *  for example:
983
-     *      if the following two entries were added to the _aliases array:
984
-     *          array(
985
-     *              'interface_alias'           => 'some\namespace\interface'
986
-     *              'some\namespace\interface'  => 'some\namespace\classname'
987
-     *          )
988
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
989
-     *      to load an instance of 'some\namespace\classname'
990
-     *
991
-     * @param string $alias
992
-     * @param string $for_class
993
-     * @return string
994
-     * @deprecated 4.9.62.p
995
-     */
996
-    public function get_alias($alias = '', $for_class = '')
997
-    {
998
-        return $this->getFqnForAlias($alias, $for_class);
999
-    }
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
+	 * @type EE_Dependency_Map $_instance
55
+	 */
56
+	protected static $_instance;
57
+
58
+	/**
59
+	 * @var ClassInterfaceCache $class_cache
60
+	 */
61
+	private $class_cache;
62
+
63
+	/**
64
+	 * @type RequestInterface $request
65
+	 */
66
+	protected $request;
67
+
68
+	/**
69
+	 * @type LegacyRequestInterface $legacy_request
70
+	 */
71
+	protected $legacy_request;
72
+
73
+	/**
74
+	 * @type ResponseInterface $response
75
+	 */
76
+	protected $response;
77
+
78
+	/**
79
+	 * @type LoaderInterface $loader
80
+	 */
81
+	protected $loader;
82
+
83
+	/**
84
+	 * @type array $_dependency_map
85
+	 */
86
+	protected $_dependency_map = [];
87
+
88
+	/**
89
+	 * @type array $_class_loaders
90
+	 */
91
+	protected $_class_loaders = [];
92
+
93
+
94
+	/**
95
+	 * EE_Dependency_Map constructor.
96
+	 *
97
+	 * @param ClassInterfaceCache $class_cache
98
+	 */
99
+	protected function __construct(ClassInterfaceCache $class_cache)
100
+	{
101
+		$this->class_cache = $class_cache;
102
+		do_action('EE_Dependency_Map____construct', $this);
103
+	}
104
+
105
+
106
+	/**
107
+	 * @return void
108
+	 * @throws InvalidAliasException
109
+	 */
110
+	public function initialize()
111
+	{
112
+		$this->_register_core_dependencies();
113
+		$this->_register_core_class_loaders();
114
+		$this->_register_core_aliases();
115
+	}
116
+
117
+
118
+	/**
119
+	 * @singleton method used to instantiate class object
120
+	 * @param ClassInterfaceCache|null $class_cache
121
+	 * @return EE_Dependency_Map
122
+	 */
123
+	public static function instance(ClassInterfaceCache $class_cache = null)
124
+	{
125
+		// check if class object is instantiated, and instantiated properly
126
+		if (! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
127
+			&& $class_cache instanceof ClassInterfaceCache
128
+		) {
129
+			EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
130
+		}
131
+		return EE_Dependency_Map::$_instance;
132
+	}
133
+
134
+
135
+	/**
136
+	 * @param RequestInterface $request
137
+	 */
138
+	public function setRequest(RequestInterface $request)
139
+	{
140
+		$this->request = $request;
141
+	}
142
+
143
+
144
+	/**
145
+	 * @param LegacyRequestInterface $legacy_request
146
+	 */
147
+	public function setLegacyRequest(LegacyRequestInterface $legacy_request)
148
+	{
149
+		$this->legacy_request = $legacy_request;
150
+	}
151
+
152
+
153
+	/**
154
+	 * @param ResponseInterface $response
155
+	 */
156
+	public function setResponse(ResponseInterface $response)
157
+	{
158
+		$this->response = $response;
159
+	}
160
+
161
+
162
+	/**
163
+	 * @param LoaderInterface $loader
164
+	 */
165
+	public function setLoader(LoaderInterface $loader)
166
+	{
167
+		$this->loader = $loader;
168
+	}
169
+
170
+
171
+	/**
172
+	 * @param string $class
173
+	 * @param array  $dependencies
174
+	 * @param int    $overwrite
175
+	 * @return bool
176
+	 */
177
+	public static function register_dependencies(
178
+		$class,
179
+		array $dependencies,
180
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
181
+	) {
182
+		return EE_Dependency_Map::$_instance->registerDependencies($class, $dependencies, $overwrite);
183
+	}
184
+
185
+
186
+	/**
187
+	 * Assigns an array of class names and corresponding load sources (new or cached)
188
+	 * to the class specified by the first parameter.
189
+	 * IMPORTANT !!!
190
+	 * The order of elements in the incoming $dependencies array MUST match
191
+	 * the order of the constructor parameters for the class in question.
192
+	 * This is especially important when overriding any existing dependencies that are registered.
193
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
194
+	 *
195
+	 * @param string $class
196
+	 * @param array  $dependencies
197
+	 * @param int    $overwrite
198
+	 * @return bool
199
+	 */
200
+	public function registerDependencies(
201
+		$class,
202
+		array $dependencies,
203
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
204
+	) {
205
+		$class = trim($class, '\\');
206
+		$registered = false;
207
+		if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
208
+			EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
209
+		}
210
+		// we need to make sure that any aliases used when registering a dependency
211
+		// get resolved to the correct class name
212
+		foreach ($dependencies as $dependency => $load_source) {
213
+			$alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
214
+			if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
215
+				|| ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
216
+			) {
217
+				unset($dependencies[ $dependency ]);
218
+				$dependencies[ $alias ] = $load_source;
219
+				$registered = true;
220
+			}
221
+		}
222
+		// now add our two lists of dependencies together.
223
+		// using Union (+=) favours the arrays in precedence from left to right,
224
+		// so $dependencies is NOT overwritten because it is listed first
225
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
226
+		// Union is way faster than array_merge() but should be used with caution...
227
+		// especially with numerically indexed arrays
228
+		$dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
229
+		// now we need to ensure that the resulting dependencies
230
+		// array only has the entries that are required for the class
231
+		// so first count how many dependencies were originally registered for the class
232
+		$dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
233
+		// if that count is non-zero (meaning dependencies were already registered)
234
+		EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
235
+			// then truncate the  final array to match that count
236
+			? array_slice($dependencies, 0, $dependency_count)
237
+			// otherwise just take the incoming array because nothing previously existed
238
+			: $dependencies;
239
+		return $registered;
240
+	}
241
+
242
+
243
+	/**
244
+	 * @param string $class_name
245
+	 * @param string $loader
246
+	 * @return bool
247
+	 * @throws DomainException
248
+	 */
249
+	public static function register_class_loader($class_name, $loader = 'load_core')
250
+	{
251
+		return EE_Dependency_Map::$_instance->registerClassLoader($class_name, $loader);
252
+	}
253
+
254
+
255
+	/**
256
+	 * @param string $class_name
257
+	 * @param string $loader
258
+	 * @return bool
259
+	 * @throws DomainException
260
+	 */
261
+	public function registerClassLoader($class_name, $loader = 'load_core')
262
+	{
263
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
264
+			throw new DomainException(
265
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
266
+			);
267
+		}
268
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
269
+		if (! is_callable($loader)
270
+			&& (
271
+				strpos($loader, 'load_') !== 0
272
+				|| ! method_exists('EE_Registry', $loader)
273
+			)
274
+		) {
275
+			throw new DomainException(
276
+				sprintf(
277
+					esc_html__(
278
+						'"%1$s" is not a valid loader method on EE_Registry.',
279
+						'event_espresso'
280
+					),
281
+					$loader
282
+				)
283
+			);
284
+		}
285
+		$class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
286
+		if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
287
+			EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
288
+			return true;
289
+		}
290
+		return false;
291
+	}
292
+
293
+
294
+	/**
295
+	 * @return array
296
+	 */
297
+	public function dependency_map()
298
+	{
299
+		return $this->_dependency_map;
300
+	}
301
+
302
+
303
+	/**
304
+	 * returns TRUE if dependency map contains a listing for the provided class name
305
+	 *
306
+	 * @param string $class_name
307
+	 * @return boolean
308
+	 */
309
+	public function has($class_name = '')
310
+	{
311
+		// all legacy models have the same dependencies
312
+		if (strpos($class_name, 'EEM_') === 0) {
313
+			$class_name = 'LEGACY_MODELS';
314
+		}
315
+		return isset($this->_dependency_map[ $class_name ]);
316
+	}
317
+
318
+
319
+	/**
320
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
321
+	 *
322
+	 * @param string $class_name
323
+	 * @param string $dependency
324
+	 * @return bool
325
+	 */
326
+	public function has_dependency_for_class($class_name = '', $dependency = '')
327
+	{
328
+		// all legacy models have the same dependencies
329
+		if (strpos($class_name, 'EEM_') === 0) {
330
+			$class_name = 'LEGACY_MODELS';
331
+		}
332
+		$dependency = $this->getFqnForAlias($dependency, $class_name);
333
+		return isset($this->_dependency_map[ $class_name ][ $dependency ]);
334
+	}
335
+
336
+
337
+	/**
338
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
339
+	 *
340
+	 * @param string $class_name
341
+	 * @param string $dependency
342
+	 * @return int
343
+	 */
344
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
345
+	{
346
+		// all legacy models have the same dependencies
347
+		if (strpos($class_name, 'EEM_') === 0) {
348
+			$class_name = 'LEGACY_MODELS';
349
+		}
350
+		$dependency = $this->getFqnForAlias($dependency);
351
+		return $this->has_dependency_for_class($class_name, $dependency)
352
+			? $this->_dependency_map[ $class_name ][ $dependency ]
353
+			: EE_Dependency_Map::not_registered;
354
+	}
355
+
356
+
357
+	/**
358
+	 * @param string $class_name
359
+	 * @return string | Closure
360
+	 */
361
+	public function class_loader($class_name)
362
+	{
363
+		// all legacy models use load_model()
364
+		if (strpos($class_name, 'EEM_') === 0) {
365
+			return 'load_model';
366
+		}
367
+		// EE_CPT_*_Strategy classes like EE_CPT_Event_Strategy, EE_CPT_Venue_Strategy, etc
368
+		// perform strpos() first to avoid loading regex every time we load a class
369
+		if (strpos($class_name, 'EE_CPT_') === 0
370
+			&& preg_match('/^EE_CPT_([a-zA-Z]+)_Strategy$/', $class_name)
371
+		) {
372
+			return 'load_core';
373
+		}
374
+		$class_name = $this->getFqnForAlias($class_name);
375
+		return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
376
+	}
377
+
378
+
379
+	/**
380
+	 * @return array
381
+	 */
382
+	public function class_loaders()
383
+	{
384
+		return $this->_class_loaders;
385
+	}
386
+
387
+
388
+	/**
389
+	 * adds an alias for a classname
390
+	 *
391
+	 * @param string $fqcn      the class name that should be used (concrete class to replace interface)
392
+	 * @param string $alias     the class name that would be type hinted for (abstract parent or interface)
393
+	 * @param string $for_class the class that has the dependency (is type hinting for the interface)
394
+	 * @throws InvalidAliasException
395
+	 */
396
+	public function add_alias($fqcn, $alias, $for_class = '')
397
+	{
398
+		$this->class_cache->addAlias($fqcn, $alias, $for_class);
399
+	}
400
+
401
+
402
+	/**
403
+	 * Returns TRUE if the provided fully qualified name IS an alias
404
+	 * WHY?
405
+	 * Because if a class is type hinting for a concretion,
406
+	 * then why would we need to find another class to supply it?
407
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
408
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
409
+	 * Don't go looking for some substitute.
410
+	 * Whereas if a class is type hinting for an interface...
411
+	 * then we need to find an actual class to use.
412
+	 * So the interface IS the alias for some other FQN,
413
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
414
+	 * represents some other class.
415
+	 *
416
+	 * @param string $fqn
417
+	 * @param string $for_class
418
+	 * @return bool
419
+	 */
420
+	public function isAlias($fqn = '', $for_class = '')
421
+	{
422
+		return $this->class_cache->isAlias($fqn, $for_class);
423
+	}
424
+
425
+
426
+	/**
427
+	 * Returns a FQN for provided alias if one exists, otherwise returns the original $alias
428
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
429
+	 *  for example:
430
+	 *      if the following two entries were added to the _aliases array:
431
+	 *          array(
432
+	 *              'interface_alias'           => 'some\namespace\interface'
433
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
434
+	 *          )
435
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
436
+	 *      to load an instance of 'some\namespace\classname'
437
+	 *
438
+	 * @param string $alias
439
+	 * @param string $for_class
440
+	 * @return string
441
+	 */
442
+	public function getFqnForAlias($alias = '', $for_class = '')
443
+	{
444
+		return (string) $this->class_cache->getFqnForAlias($alias, $for_class);
445
+	}
446
+
447
+
448
+	/**
449
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
450
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
451
+	 * This is done by using the following class constants:
452
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
453
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
454
+	 */
455
+	protected function _register_core_dependencies()
456
+	{
457
+		$this->_dependency_map = [
458
+			'EE_Request_Handler'                                                                                          => [
459
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
460
+			],
461
+			'EE_System'                                                                                                   => [
462
+				'EE_Registry'                                 => EE_Dependency_Map::load_from_cache,
463
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
464
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
465
+				'EE_Maintenance_Mode'                         => EE_Dependency_Map::load_from_cache,
466
+			],
467
+			'EE_Cart'                                                                                                     => [
468
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
469
+			],
470
+			'EE_Messenger_Collection_Loader'                                                                              => [
471
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
472
+			],
473
+			'EE_Message_Type_Collection_Loader'                                                                           => [
474
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
475
+			],
476
+			'EE_Message_Resource_Manager'                                                                                 => [
477
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
478
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
479
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
480
+			],
481
+			'EE_Message_Factory'                                                                                          => [
482
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
483
+			],
484
+			'EE_messages'                                                                                                 => [
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			],
487
+			'EE_Messages_Generator'                                                                                       => [
488
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
489
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
490
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
491
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
492
+			],
493
+			'EE_Messages_Processor'                                                                                       => [
494
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
495
+			],
496
+			'EE_Messages_Queue'                                                                                           => [
497
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
498
+			],
499
+			'EE_Messages_Template_Defaults'                                                                               => [
500
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
501
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
502
+			],
503
+			'EE_Message_To_Generate_From_Request'                                                                         => [
504
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
505
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
506
+			],
507
+			'EventEspresso\core\services\commands\CommandBus'                                                             => [
508
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
509
+			],
510
+			'EventEspresso\services\commands\CommandHandler'                                                              => [
511
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
512
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
513
+			],
514
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => [
515
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
516
+			],
517
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => [
518
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
519
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
520
+			],
521
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => [
522
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
523
+			],
524
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => [
525
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
526
+			],
527
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => [
528
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
529
+			],
530
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => [
531
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
532
+			],
533
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => [
534
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
535
+			],
536
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => [
537
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			],
539
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => [
540
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
541
+			],
542
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => [
543
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			],
545
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => [
546
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
547
+			],
548
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => [
549
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
550
+			],
551
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => [
552
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
553
+			],
554
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => [
555
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
556
+			],
557
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => [
558
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
559
+			],
560
+			'EventEspresso\core\services\database\TableManager'                                                           => [
561
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
562
+			],
563
+			'EE_Data_Migration_Class_Base'                                                                                => [
564
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
565
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
566
+			],
567
+			'EE_DMS_Core_4_1_0'                                                                                           => [
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_2_0'                                                                                           => [
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_3_0'                                                                                           => [
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_4_0'                                                                                           => [
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_5_0'                                                                                           => [
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_6_0'                                                                                           => [
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_7_0'                                                                                           => [
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_8_0'                                                                                           => [
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_9_0'                                                                                           => [
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_10_0'                                                                                          => [
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
+				'EE_DMS_Core_4_9_0'                                  => EE_Dependency_Map::load_from_cache,
607
+			],
608
+			'EventEspresso\core\services\assets\I18nRegistry'                                                             => [
609
+				'EventEspresso\core\domain\Domain'                 => EE_Dependency_Map::load_from_cache,
610
+				'EventEspresso\core\services\assets\JedLocaleData' => EE_Dependency_Map::load_from_cache,
611
+				[],
612
+			],
613
+			'EventEspresso\core\services\assets\Registry'                                                                 => [
614
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
615
+				'EventEspresso\core\services\assets\I18nRegistry'    => EE_Dependency_Map::load_from_cache,
616
+			],
617
+			'EventEspresso\core\services\cache\BasicCacheManager'                                                         => [
618
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
619
+			],
620
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                                                   => [
621
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
622
+			],
623
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService'                                  => [
624
+				'EE_Registration_Config'                     => EE_Dependency_Map::load_from_cache,
625
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
626
+			],
627
+			'EventEspresso\core\domain\values\EmailAddress'                                                               => [
628
+				null,
629
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
630
+			],
631
+			'EventEspresso\core\services\orm\ModelFieldFactory'                                                           => [
632
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
633
+			],
634
+			'LEGACY_MODELS'                                                                                               => [
635
+				null,
636
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
637
+			],
638
+			'EE_Module_Request_Router'                                                                                    => [
639
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
640
+			],
641
+			'EE_Registration_Processor'                                                                                   => [
642
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
643
+			],
644
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'                                      => [
645
+				null,
646
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
647
+				'EventEspresso\core\services\request\Request'                         => EE_Dependency_Map::load_from_cache,
648
+			],
649
+			'EventEspresso\caffeinated\modules\recaptcha_invisible\InvisibleRecaptcha'                                    => [
650
+				'EE_Registration_Config' => EE_Dependency_Map::load_from_cache,
651
+				'EE_Session'             => EE_Dependency_Map::load_from_cache,
652
+			],
653
+			'EventEspresso\modules\ticket_selector\ProcessTicketSelector'                                                 => [
654
+				'EE_Core_Config'                                                          => EE_Dependency_Map::load_from_cache,
655
+				'EventEspresso\core\services\request\Request'                             => EE_Dependency_Map::load_from_cache,
656
+				'EE_Session'                                                              => EE_Dependency_Map::load_from_cache,
657
+				'EEM_Ticket'                                                              => EE_Dependency_Map::load_from_cache,
658
+				'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker' => EE_Dependency_Map::load_from_cache,
659
+			],
660
+			'EventEspresso\modules\ticket_selector\TicketDatetimeAvailabilityTracker'                                     => [
661
+				'EEM_Datetime' => EE_Dependency_Map::load_from_cache,
662
+			],
663
+			'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions'                              => [
664
+				'EE_Core_Config'                             => EE_Dependency_Map::load_from_cache,
665
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
666
+			],
667
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomPostTypes'                                => [
668
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
669
+			],
670
+			'EventEspresso\core\domain\services\custom_post_types\RegisterCustomTaxonomies'                               => [
671
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
672
+			],
673
+			'EE_CPT_Strategy'                                                                                             => [
674
+				'EventEspresso\core\domain\entities\custom_post_types\CustomPostTypeDefinitions' => EE_Dependency_Map::load_from_cache,
675
+				'EventEspresso\core\domain\entities\custom_post_types\CustomTaxonomyDefinitions' => EE_Dependency_Map::load_from_cache,
676
+			],
677
+			'EventEspresso\core\services\loaders\ObjectIdentifier'                                                        => [
678
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
679
+			],
680
+			'EventEspresso\core\CPTs\CptQueryModifier'                                                                    => [
681
+				null,
682
+				null,
683
+				null,
684
+				'EE_Request_Handler'                          => EE_Dependency_Map::load_from_cache,
685
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
686
+				'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
687
+			],
688
+			'EventEspresso\core\services\dependencies\DependencyResolver'                                                 => [
689
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
690
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
691
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
692
+			],
693
+			'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver'                               => [
694
+				'EventEspresso\core\services\container\Mirror'            => EE_Dependency_Map::load_from_cache,
695
+				'EventEspresso\core\services\loaders\ClassInterfaceCache' => EE_Dependency_Map::load_from_cache,
696
+				'EE_Dependency_Map'                                       => EE_Dependency_Map::load_from_cache,
697
+			],
698
+			'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'                                          => [
699
+				'EventEspresso\core\services\routing\RouteMatchSpecificationDependencyResolver' => EE_Dependency_Map::load_from_cache,
700
+				'EventEspresso\core\services\loaders\Loader'                                    => EE_Dependency_Map::load_from_cache,
701
+			],
702
+			'EventEspresso\core\services\routing\RouteMatchSpecificationManager'                                          => [
703
+				'EventEspresso\core\services\routing\RouteMatchSpecificationCollection' => EE_Dependency_Map::load_from_cache,
704
+				'EventEspresso\core\services\routing\RouteMatchSpecificationFactory'    => EE_Dependency_Map::load_from_cache,
705
+			],
706
+			'EE_URL_Validation_Strategy'                                                                                  => [
707
+				null,
708
+				null,
709
+				'EventEspresso\core\services\validators\URLValidator' => EE_Dependency_Map::load_from_cache
710
+			],
711
+			'EventEspresso\core\services\request\files\FilesDataHandler'                                                  => [
712
+				'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
713
+			],
714
+			'EventEspressoBatchRequest\BatchRequestProcessor'                                                             => [
715
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
716
+			],
717
+			'EventEspresso\core\domain\services\converters\RestApiSpoofer'                                                => [
718
+				'WP_REST_Server'                                               => EE_Dependency_Map::load_from_cache,
719
+				'EED_Core_Rest_Api'                                            => EE_Dependency_Map::load_from_cache,
720
+				'EventEspresso\core\libraries\rest_api\controllers\model\Read' => EE_Dependency_Map::load_from_cache,
721
+				null
722
+			],
723
+			'EventEspresso\core\services\routing\RouteHandler'                                                            => [
724
+				'EventEspresso\core\services\loaders\Loader'          => EE_Dependency_Map::load_from_cache,
725
+				'EventEspresso\core\services\routing\RouteCollection' => EE_Dependency_Map::load_from_cache,
726
+			],
727
+			'EventEspresso\core\domain\entities\routing\handlers\shared\RoutingRequests'                                          => [
728
+				'EE_Dependency_Map'                                                                          => EE_Dependency_Map::load_from_cache,
729
+				'EventEspresso\core\services\loaders\Loader'                                                 => EE_Dependency_Map::load_from_cache,
730
+				'EventEspresso\core\services\request\Request'                                                => EE_Dependency_Map::load_from_cache,
731
+				'EventEspresso\core\domain\entities\routing\specifications\RouteMatchSpecificationInterface' => EE_Dependency_Map::load_from_cache,
732
+			],
733
+		];
734
+	}
735
+
736
+
737
+	/**
738
+	 * Registers how core classes are loaded.
739
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
740
+	 *        'EE_Request_Handler' => 'load_core'
741
+	 *        'EE_Messages_Queue'  => 'load_lib'
742
+	 *        'EEH_Debug_Tools'    => 'load_helper'
743
+	 * or, if greater control is required, by providing a custom closure. For example:
744
+	 *        'Some_Class' => function () {
745
+	 *            return new Some_Class();
746
+	 *        },
747
+	 * This is required for instantiating dependencies
748
+	 * where an interface has been type hinted in a class constructor. For example:
749
+	 *        'Required_Interface' => function () {
750
+	 *            return new A_Class_That_Implements_Required_Interface();
751
+	 *        },
752
+	 */
753
+	protected function _register_core_class_loaders()
754
+	{
755
+		$this->_class_loaders = [
756
+			// load_core
757
+			'EE_Dependency_Map'                            => function () {
758
+				return $this;
759
+			},
760
+			'EE_Capabilities'                              => 'load_core',
761
+			'EE_Encryption'                                => 'load_core',
762
+			'EE_Front_Controller'                          => 'load_core',
763
+			'EE_Module_Request_Router'                     => 'load_core',
764
+			'EE_Registry'                                  => 'load_core',
765
+			'EE_Request'                                   => function () {
766
+				return $this->legacy_request;
767
+			},
768
+			'EventEspresso\core\services\request\Request'  => function () {
769
+				return $this->request;
770
+			},
771
+			'EventEspresso\core\services\request\Response' => function () {
772
+				return $this->response;
773
+			},
774
+			'EE_Base'                                      => 'load_core',
775
+			'EE_Request_Handler'                           => 'load_core',
776
+			'EE_Session'                                   => 'load_core',
777
+			'EE_Cron_Tasks'                                => 'load_core',
778
+			'EE_System'                                    => 'load_core',
779
+			'EE_Maintenance_Mode'                          => 'load_core',
780
+			'EE_Register_CPTs'                             => 'load_core',
781
+			'EE_Admin'                                     => 'load_core',
782
+			'EE_CPT_Strategy'                              => 'load_core',
783
+			// load_class
784
+			'EE_Registration_Processor'                    => 'load_class',
785
+			// load_lib
786
+			'EE_Message_Resource_Manager'                  => 'load_lib',
787
+			'EE_Message_Type_Collection'                   => 'load_lib',
788
+			'EE_Message_Type_Collection_Loader'            => 'load_lib',
789
+			'EE_Messenger_Collection'                      => 'load_lib',
790
+			'EE_Messenger_Collection_Loader'               => 'load_lib',
791
+			'EE_Messages_Processor'                        => 'load_lib',
792
+			'EE_Message_Repository'                        => 'load_lib',
793
+			'EE_Messages_Queue'                            => 'load_lib',
794
+			'EE_Messages_Data_Handler_Collection'          => 'load_lib',
795
+			'EE_Message_Template_Group_Collection'         => 'load_lib',
796
+			'EE_Payment_Method_Manager'                    => 'load_lib',
797
+			'EE_DMS_Core_4_1_0'                            => 'load_dms',
798
+			'EE_DMS_Core_4_2_0'                            => 'load_dms',
799
+			'EE_DMS_Core_4_3_0'                            => 'load_dms',
800
+			'EE_DMS_Core_4_5_0'                            => 'load_dms',
801
+			'EE_DMS_Core_4_6_0'                            => 'load_dms',
802
+			'EE_DMS_Core_4_7_0'                            => 'load_dms',
803
+			'EE_DMS_Core_4_8_0'                            => 'load_dms',
804
+			'EE_DMS_Core_4_9_0'                            => 'load_dms',
805
+			'EE_DMS_Core_4_10_0'                           => 'load_dms',
806
+			'EE_Messages_Generator'                        => static function () {
807
+				return EE_Registry::instance()->load_lib(
808
+					'Messages_Generator',
809
+					[],
810
+					false,
811
+					false
812
+				);
813
+			},
814
+			'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
815
+				return EE_Registry::instance()->load_lib(
816
+					'Messages_Template_Defaults',
817
+					$arguments,
818
+					false,
819
+					false
820
+				);
821
+			},
822
+			// load_helper
823
+			'EEH_Parse_Shortcodes'                         => static function () {
824
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
825
+					return new EEH_Parse_Shortcodes();
826
+				}
827
+				return null;
828
+			},
829
+			'EE_Template_Config'                           => static function () {
830
+				return EE_Config::instance()->template_settings;
831
+			},
832
+			'EE_Currency_Config'                           => static function () {
833
+				return EE_Config::instance()->currency;
834
+			},
835
+			'EE_Registration_Config'                       => static function () {
836
+				return EE_Config::instance()->registration;
837
+			},
838
+			'EE_Core_Config'                               => static function () {
839
+				return EE_Config::instance()->core;
840
+			},
841
+			'EventEspresso\core\services\loaders\Loader'   => static function () {
842
+				return LoaderFactory::getLoader();
843
+			},
844
+			'EE_Network_Config'                            => static function () {
845
+				return EE_Network_Config::instance();
846
+			},
847
+			'EE_Config'                                    => static function () {
848
+				return EE_Config::instance();
849
+			},
850
+			'EventEspresso\core\domain\Domain'             => static function () {
851
+				return DomainFactory::getEventEspressoCoreDomain();
852
+			},
853
+			'EE_Admin_Config'                              => static function () {
854
+				return EE_Config::instance()->admin;
855
+			},
856
+			'EE_Organization_Config'                       => static function () {
857
+				return EE_Config::instance()->organization;
858
+			},
859
+			'EE_Network_Core_Config'                       => static function () {
860
+				return EE_Network_Config::instance()->core;
861
+			},
862
+			'EE_Environment_Config'                        => static function () {
863
+				return EE_Config::instance()->environment;
864
+			},
865
+			'EED_Core_Rest_Api'                            => static function () {
866
+				return EED_Core_Rest_Api::instance();
867
+			},
868
+			'WP_REST_Server'                               => static function () {
869
+				return rest_get_server();
870
+			},
871
+		];
872
+	}
873
+
874
+
875
+	/**
876
+	 * can be used for supplying alternate names for classes,
877
+	 * or for connecting interface names to instantiable classes
878
+	 *
879
+	 * @throws InvalidAliasException
880
+	 */
881
+	protected function _register_core_aliases()
882
+	{
883
+		$aliases = [
884
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
885
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
886
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
887
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
888
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
889
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
890
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
891
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
892
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
893
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
894
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
895
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
896
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
897
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
898
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
899
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
900
+			'CreateTransactionCommandHandler'                                              => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
901
+			'CreateAttendeeCommandHandler'                                                 => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
902
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
903
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
904
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
905
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
906
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
907
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
908
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
909
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
910
+			'CommandFactoryInterface'                                                      => 'EventEspresso\core\services\commands\CommandFactoryInterface',
911
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                 => 'EventEspresso\core\services\commands\CommandFactory',
912
+			'EmailValidatorInterface'                                                      => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
913
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface'  => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
914
+			'NoticeConverterInterface'                                                     => 'EventEspresso\core\services\notices\NoticeConverterInterface',
915
+			'EventEspresso\core\services\notices\NoticeConverterInterface'                 => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
916
+			'NoticesContainerInterface'                                                    => 'EventEspresso\core\services\notices\NoticesContainerInterface',
917
+			'EventEspresso\core\services\notices\NoticesContainerInterface'                => 'EventEspresso\core\services\notices\NoticesContainer',
918
+			'EventEspresso\core\services\request\RequestInterface'                         => 'EventEspresso\core\services\request\Request',
919
+			'EventEspresso\core\services\request\ResponseInterface'                        => 'EventEspresso\core\services\request\Response',
920
+			'EventEspresso\core\domain\DomainInterface'                                    => 'EventEspresso\core\domain\Domain',
921
+			'Registration_Processor'                                                       => 'EE_Registration_Processor',
922
+		];
923
+		foreach ($aliases as $alias => $fqn) {
924
+			if (is_array($fqn)) {
925
+				foreach ($fqn as $class => $for_class) {
926
+					$this->class_cache->addAlias($class, $alias, $for_class);
927
+				}
928
+				continue;
929
+			}
930
+			$this->class_cache->addAlias($fqn, $alias);
931
+		}
932
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
933
+			$this->class_cache->addAlias(
934
+				'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
935
+				'EventEspresso\core\services\notices\NoticeConverterInterface'
936
+			);
937
+		}
938
+	}
939
+
940
+
941
+	/**
942
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
943
+	 * request Primarily used by unit tests.
944
+	 */
945
+	public function reset()
946
+	{
947
+		$this->_register_core_class_loaders();
948
+		$this->_register_core_dependencies();
949
+	}
950
+
951
+
952
+	/**
953
+	 * PLZ NOTE: a better name for this method would be is_alias()
954
+	 * because it returns TRUE if the provided fully qualified name IS an alias
955
+	 * WHY?
956
+	 * Because if a class is type hinting for a concretion,
957
+	 * then why would we need to find another class to supply it?
958
+	 * ie: if a class asks for `Fully/Qualified/Namespace/SpecificClassName`,
959
+	 * then give it an instance of `Fully/Qualified/Namespace/SpecificClassName`.
960
+	 * Don't go looking for some substitute.
961
+	 * Whereas if a class is type hinting for an interface...
962
+	 * then we need to find an actual class to use.
963
+	 * So the interface IS the alias for some other FQN,
964
+	 * and we need to find out if `Fully/Qualified/Namespace/SomeInterface`
965
+	 * represents some other class.
966
+	 *
967
+	 * @param string $fqn
968
+	 * @param string $for_class
969
+	 * @return bool
970
+	 * @deprecated 4.9.62.p
971
+	 */
972
+	public function has_alias($fqn = '', $for_class = '')
973
+	{
974
+		return $this->isAlias($fqn, $for_class);
975
+	}
976
+
977
+
978
+	/**
979
+	 * PLZ NOTE: a better name for this method would be get_fqn_for_alias()
980
+	 * because it returns a FQN for provided alias if one exists, otherwise returns the original $alias
981
+	 * functions recursively, so that multiple aliases can be used to drill down to a FQN
982
+	 *  for example:
983
+	 *      if the following two entries were added to the _aliases array:
984
+	 *          array(
985
+	 *              'interface_alias'           => 'some\namespace\interface'
986
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
987
+	 *          )
988
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
989
+	 *      to load an instance of 'some\namespace\classname'
990
+	 *
991
+	 * @param string $alias
992
+	 * @param string $for_class
993
+	 * @return string
994
+	 * @deprecated 4.9.62.p
995
+	 */
996
+	public function get_alias($alias = '', $for_class = '')
997
+	{
998
+		return $this->getFqnForAlias($alias, $for_class);
999
+	}
1000 1000
 }
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public static function instance(ClassInterfaceCache $class_cache = null)
124 124
     {
125 125
         // check if class object is instantiated, and instantiated properly
126
-        if (! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
126
+        if ( ! EE_Dependency_Map::$_instance instanceof EE_Dependency_Map
127 127
             && $class_cache instanceof ClassInterfaceCache
128 128
         ) {
129 129
             EE_Dependency_Map::$_instance = new EE_Dependency_Map($class_cache);
@@ -204,18 +204,18 @@  discard block
 block discarded – undo
204 204
     ) {
205 205
         $class = trim($class, '\\');
206 206
         $registered = false;
207
-        if (empty(EE_Dependency_Map::$_instance->_dependency_map[ $class ])) {
208
-            EE_Dependency_Map::$_instance->_dependency_map[ $class ] = [];
207
+        if (empty(EE_Dependency_Map::$_instance->_dependency_map[$class])) {
208
+            EE_Dependency_Map::$_instance->_dependency_map[$class] = [];
209 209
         }
210 210
         // we need to make sure that any aliases used when registering a dependency
211 211
         // get resolved to the correct class name
212 212
         foreach ($dependencies as $dependency => $load_source) {
213 213
             $alias = EE_Dependency_Map::$_instance->getFqnForAlias($dependency);
214 214
             if ($overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
215
-                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[ $class ][ $alias ])
215
+                || ! isset(EE_Dependency_Map::$_instance->_dependency_map[$class][$alias])
216 216
             ) {
217
-                unset($dependencies[ $dependency ]);
218
-                $dependencies[ $alias ] = $load_source;
217
+                unset($dependencies[$dependency]);
218
+                $dependencies[$alias] = $load_source;
219 219
                 $registered = true;
220 220
             }
221 221
         }
@@ -225,13 +225,13 @@  discard block
 block discarded – undo
225 225
         // ie: with A = B + C, entries in B take precedence over duplicate entries in C
226 226
         // Union is way faster than array_merge() but should be used with caution...
227 227
         // especially with numerically indexed arrays
228
-        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[ $class ];
228
+        $dependencies += EE_Dependency_Map::$_instance->_dependency_map[$class];
229 229
         // now we need to ensure that the resulting dependencies
230 230
         // array only has the entries that are required for the class
231 231
         // so first count how many dependencies were originally registered for the class
232
-        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[ $class ]);
232
+        $dependency_count = count(EE_Dependency_Map::$_instance->_dependency_map[$class]);
233 233
         // if that count is non-zero (meaning dependencies were already registered)
234
-        EE_Dependency_Map::$_instance->_dependency_map[ $class ] = $dependency_count
234
+        EE_Dependency_Map::$_instance->_dependency_map[$class] = $dependency_count
235 235
             // then truncate the  final array to match that count
236 236
             ? array_slice($dependencies, 0, $dependency_count)
237 237
             // otherwise just take the incoming array because nothing previously existed
@@ -260,13 +260,13 @@  discard block
 block discarded – undo
260 260
      */
261 261
     public function registerClassLoader($class_name, $loader = 'load_core')
262 262
     {
263
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
263
+        if ( ! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
264 264
             throw new DomainException(
265 265
                 esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
266 266
             );
267 267
         }
268 268
         // check that loader is callable or method starts with "load_" and exists in EE_Registry
269
-        if (! is_callable($loader)
269
+        if ( ! is_callable($loader)
270 270
             && (
271 271
                 strpos($loader, 'load_') !== 0
272 272
                 || ! method_exists('EE_Registry', $loader)
@@ -283,8 +283,8 @@  discard block
 block discarded – undo
283 283
             );
284 284
         }
285 285
         $class_name = EE_Dependency_Map::$_instance->getFqnForAlias($class_name);
286
-        if (! isset(EE_Dependency_Map::$_instance->_class_loaders[ $class_name ])) {
287
-            EE_Dependency_Map::$_instance->_class_loaders[ $class_name ] = $loader;
286
+        if ( ! isset(EE_Dependency_Map::$_instance->_class_loaders[$class_name])) {
287
+            EE_Dependency_Map::$_instance->_class_loaders[$class_name] = $loader;
288 288
             return true;
289 289
         }
290 290
         return false;
@@ -312,7 +312,7 @@  discard block
 block discarded – undo
312 312
         if (strpos($class_name, 'EEM_') === 0) {
313 313
             $class_name = 'LEGACY_MODELS';
314 314
         }
315
-        return isset($this->_dependency_map[ $class_name ]);
315
+        return isset($this->_dependency_map[$class_name]);
316 316
     }
317 317
 
318 318
 
@@ -330,7 +330,7 @@  discard block
 block discarded – undo
330 330
             $class_name = 'LEGACY_MODELS';
331 331
         }
332 332
         $dependency = $this->getFqnForAlias($dependency, $class_name);
333
-        return isset($this->_dependency_map[ $class_name ][ $dependency ]);
333
+        return isset($this->_dependency_map[$class_name][$dependency]);
334 334
     }
335 335
 
336 336
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
         }
350 350
         $dependency = $this->getFqnForAlias($dependency);
351 351
         return $this->has_dependency_for_class($class_name, $dependency)
352
-            ? $this->_dependency_map[ $class_name ][ $dependency ]
352
+            ? $this->_dependency_map[$class_name][$dependency]
353 353
             : EE_Dependency_Map::not_registered;
354 354
     }
355 355
 
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
             return 'load_core';
373 373
         }
374 374
         $class_name = $this->getFqnForAlias($class_name);
375
-        return isset($this->_class_loaders[ $class_name ]) ? $this->_class_loaders[ $class_name ] : '';
375
+        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
376 376
     }
377 377
 
378 378
 
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
     {
755 755
         $this->_class_loaders = [
756 756
             // load_core
757
-            'EE_Dependency_Map'                            => function () {
757
+            'EE_Dependency_Map'                            => function() {
758 758
                 return $this;
759 759
             },
760 760
             'EE_Capabilities'                              => 'load_core',
@@ -762,13 +762,13 @@  discard block
 block discarded – undo
762 762
             'EE_Front_Controller'                          => 'load_core',
763 763
             'EE_Module_Request_Router'                     => 'load_core',
764 764
             'EE_Registry'                                  => 'load_core',
765
-            'EE_Request'                                   => function () {
765
+            'EE_Request'                                   => function() {
766 766
                 return $this->legacy_request;
767 767
             },
768
-            'EventEspresso\core\services\request\Request'  => function () {
768
+            'EventEspresso\core\services\request\Request'  => function() {
769 769
                 return $this->request;
770 770
             },
771
-            'EventEspresso\core\services\request\Response' => function () {
771
+            'EventEspresso\core\services\request\Response' => function() {
772 772
                 return $this->response;
773 773
             },
774 774
             'EE_Base'                                      => 'load_core',
@@ -803,7 +803,7 @@  discard block
 block discarded – undo
803 803
             'EE_DMS_Core_4_8_0'                            => 'load_dms',
804 804
             'EE_DMS_Core_4_9_0'                            => 'load_dms',
805 805
             'EE_DMS_Core_4_10_0'                           => 'load_dms',
806
-            'EE_Messages_Generator'                        => static function () {
806
+            'EE_Messages_Generator'                        => static function() {
807 807
                 return EE_Registry::instance()->load_lib(
808 808
                     'Messages_Generator',
809 809
                     [],
@@ -811,7 +811,7 @@  discard block
 block discarded – undo
811 811
                     false
812 812
                 );
813 813
             },
814
-            'EE_Messages_Template_Defaults'                => static function ($arguments = []) {
814
+            'EE_Messages_Template_Defaults'                => static function($arguments = []) {
815 815
                 return EE_Registry::instance()->load_lib(
816 816
                     'Messages_Template_Defaults',
817 817
                     $arguments,
@@ -820,52 +820,52 @@  discard block
 block discarded – undo
820 820
                 );
821 821
             },
822 822
             // load_helper
823
-            'EEH_Parse_Shortcodes'                         => static function () {
823
+            'EEH_Parse_Shortcodes'                         => static function() {
824 824
                 if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
825 825
                     return new EEH_Parse_Shortcodes();
826 826
                 }
827 827
                 return null;
828 828
             },
829
-            'EE_Template_Config'                           => static function () {
829
+            'EE_Template_Config'                           => static function() {
830 830
                 return EE_Config::instance()->template_settings;
831 831
             },
832
-            'EE_Currency_Config'                           => static function () {
832
+            'EE_Currency_Config'                           => static function() {
833 833
                 return EE_Config::instance()->currency;
834 834
             },
835
-            'EE_Registration_Config'                       => static function () {
835
+            'EE_Registration_Config'                       => static function() {
836 836
                 return EE_Config::instance()->registration;
837 837
             },
838
-            'EE_Core_Config'                               => static function () {
838
+            'EE_Core_Config'                               => static function() {
839 839
                 return EE_Config::instance()->core;
840 840
             },
841
-            'EventEspresso\core\services\loaders\Loader'   => static function () {
841
+            'EventEspresso\core\services\loaders\Loader'   => static function() {
842 842
                 return LoaderFactory::getLoader();
843 843
             },
844
-            'EE_Network_Config'                            => static function () {
844
+            'EE_Network_Config'                            => static function() {
845 845
                 return EE_Network_Config::instance();
846 846
             },
847
-            'EE_Config'                                    => static function () {
847
+            'EE_Config'                                    => static function() {
848 848
                 return EE_Config::instance();
849 849
             },
850
-            'EventEspresso\core\domain\Domain'             => static function () {
850
+            'EventEspresso\core\domain\Domain'             => static function() {
851 851
                 return DomainFactory::getEventEspressoCoreDomain();
852 852
             },
853
-            'EE_Admin_Config'                              => static function () {
853
+            'EE_Admin_Config'                              => static function() {
854 854
                 return EE_Config::instance()->admin;
855 855
             },
856
-            'EE_Organization_Config'                       => static function () {
856
+            'EE_Organization_Config'                       => static function() {
857 857
                 return EE_Config::instance()->organization;
858 858
             },
859
-            'EE_Network_Core_Config'                       => static function () {
859
+            'EE_Network_Core_Config'                       => static function() {
860 860
                 return EE_Network_Config::instance()->core;
861 861
             },
862
-            'EE_Environment_Config'                        => static function () {
862
+            'EE_Environment_Config'                        => static function() {
863 863
                 return EE_Config::instance()->environment;
864 864
             },
865
-            'EED_Core_Rest_Api'                            => static function () {
865
+            'EED_Core_Rest_Api'                            => static function() {
866 866
                 return EED_Core_Rest_Api::instance();
867 867
             },
868
-            'WP_REST_Server'                               => static function () {
868
+            'WP_REST_Server'                               => static function() {
869 869
                 return rest_get_server();
870 870
             },
871 871
         ];
@@ -929,7 +929,7 @@  discard block
 block discarded – undo
929 929
             }
930 930
             $this->class_cache->addAlias($fqn, $alias);
931 931
         }
932
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
932
+        if ( ! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
933 933
             $this->class_cache->addAlias(
934 934
                 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices',
935 935
                 'EventEspresso\core\services\notices\NoticeConverterInterface'
Please login to merge, or discard this patch.
core/EE_Error.core.php 2 patches
Indentation   +1128 added lines, -1128 removed lines patch added patch discarded remove patch
@@ -10,8 +10,8 @@  discard block
 block discarded – undo
10 10
 // if you're a dev and want to receive all errors via email
11 11
 // add this to your wp-config.php: define( 'EE_ERROR_EMAILS', TRUE );
12 12
 if (defined('WP_DEBUG') && WP_DEBUG === true && defined('EE_ERROR_EMAILS') && EE_ERROR_EMAILS === true) {
13
-    set_error_handler(array('EE_Error', 'error_handler'));
14
-    register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
13
+	set_error_handler(array('EE_Error', 'error_handler'));
14
+	register_shutdown_function(array('EE_Error', 'fatal_error_handler'));
15 15
 }
16 16
 
17 17
 
@@ -25,251 +25,251 @@  discard block
 block discarded – undo
25 25
 class EE_Error extends Exception
26 26
 {
27 27
 
28
-    const OPTIONS_KEY_NOTICES = 'ee_notices';
29
-
30
-
31
-    /**
32
-     * name of the file to log exceptions to
33
-     *
34
-     * @var string
35
-     */
36
-    private static $_exception_log_file = 'espresso_error_log.txt';
37
-
38
-    /**
39
-     *    stores details for all exception
40
-     *
41
-     * @var array
42
-     */
43
-    private static $_all_exceptions = array();
44
-
45
-    /**
46
-     *    tracks number of errors
47
-     *
48
-     * @var int
49
-     */
50
-    private static $_error_count = 0;
51
-
52
-    /**
53
-     * @var array $_espresso_notices
54
-     */
55
-    private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
56
-
57
-
58
-    /**
59
-     * @override default exception handling
60
-     * @param string         $message
61
-     * @param int            $code
62
-     * @param Exception|null $previous
63
-     */
64
-    public function __construct($message, $code = 0, Exception $previous = null)
65
-    {
66
-        if (version_compare(PHP_VERSION, '5.3.0', '<')) {
67
-            parent::__construct($message, $code);
68
-        } else {
69
-            parent::__construct($message, $code, $previous);
70
-        }
71
-    }
72
-
73
-
74
-    /**
75
-     *    error_handler
76
-     *
77
-     * @param $code
78
-     * @param $message
79
-     * @param $file
80
-     * @param $line
81
-     * @return void
82
-     */
83
-    public static function error_handler($code, $message, $file, $line)
84
-    {
85
-        $type = EE_Error::error_type($code);
86
-        $site = site_url();
87
-        switch ($site) {
88
-            case 'http://ee4.eventespresso.com/':
89
-            case 'http://ee4decaf.eventespresso.com/':
90
-            case 'http://ee4hf.eventespresso.com/':
91
-            case 'http://ee4a.eventespresso.com/':
92
-            case 'http://ee4ad.eventespresso.com/':
93
-            case 'http://ee4b.eventespresso.com/':
94
-            case 'http://ee4bd.eventespresso.com/':
95
-            case 'http://ee4d.eventespresso.com/':
96
-            case 'http://ee4dd.eventespresso.com/':
97
-                $to = '[email protected]';
98
-                break;
99
-            default:
100
-                $to = get_option('admin_email');
101
-        }
102
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
103
-        $msg = EE_Error::_format_error($type, $message, $file, $line);
104
-        if (function_exists('wp_mail')) {
105
-            add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
106
-            wp_mail($to, $subject, $msg);
107
-        }
108
-        echo '<div id="message" class="espresso-notices error"><p>';
109
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
110
-        echo '<br /></p></div>';
111
-    }
112
-
113
-
114
-    /**
115
-     * error_type
116
-     * http://www.php.net/manual/en/errorfunc.constants.php#109430
117
-     *
118
-     * @param $code
119
-     * @return string
120
-     */
121
-    public static function error_type($code)
122
-    {
123
-        switch ($code) {
124
-            case E_ERROR: // 1 //
125
-                return 'E_ERROR';
126
-            case E_WARNING: // 2 //
127
-                return 'E_WARNING';
128
-            case E_PARSE: // 4 //
129
-                return 'E_PARSE';
130
-            case E_NOTICE: // 8 //
131
-                return 'E_NOTICE';
132
-            case E_CORE_ERROR: // 16 //
133
-                return 'E_CORE_ERROR';
134
-            case E_CORE_WARNING: // 32 //
135
-                return 'E_CORE_WARNING';
136
-            case E_COMPILE_ERROR: // 64 //
137
-                return 'E_COMPILE_ERROR';
138
-            case E_COMPILE_WARNING: // 128 //
139
-                return 'E_COMPILE_WARNING';
140
-            case E_USER_ERROR: // 256 //
141
-                return 'E_USER_ERROR';
142
-            case E_USER_WARNING: // 512 //
143
-                return 'E_USER_WARNING';
144
-            case E_USER_NOTICE: // 1024 //
145
-                return 'E_USER_NOTICE';
146
-            case E_STRICT: // 2048 //
147
-                return 'E_STRICT';
148
-            case E_RECOVERABLE_ERROR: // 4096 //
149
-                return 'E_RECOVERABLE_ERROR';
150
-            case E_DEPRECATED: // 8192 //
151
-                return 'E_DEPRECATED';
152
-            case E_USER_DEPRECATED: // 16384 //
153
-                return 'E_USER_DEPRECATED';
154
-            case E_ALL: // 16384 //
155
-                return 'E_ALL';
156
-        }
157
-        return '';
158
-    }
159
-
160
-
161
-    /**
162
-     *    fatal_error_handler
163
-     *
164
-     * @return void
165
-     */
166
-    public static function fatal_error_handler()
167
-    {
168
-        $last_error = error_get_last();
169
-        if ($last_error['type'] === E_ERROR) {
170
-            EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
171
-        }
172
-    }
173
-
174
-
175
-    /**
176
-     * _format_error
177
-     *
178
-     * @param $code
179
-     * @param $message
180
-     * @param $file
181
-     * @param $line
182
-     * @return string
183
-     */
184
-    private static function _format_error($code, $message, $file, $line)
185
-    {
186
-        $html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
187
-        $html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
188
-        $html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
189
-        $html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
190
-        $html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
191
-        $html .= '</tbody></table>';
192
-        return $html;
193
-    }
194
-
195
-
196
-    /**
197
-     * set_content_type
198
-     *
199
-     * @param $content_type
200
-     * @return string
201
-     */
202
-    public static function set_content_type($content_type)
203
-    {
204
-        return 'text/html';
205
-    }
206
-
207
-
208
-    /**
209
-     * @return void
210
-     * @throws EE_Error
211
-     * @throws ReflectionException
212
-     */
213
-    public function get_error()
214
-    {
215
-        if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
216
-            throw $this;
217
-        }
218
-        // get separate user and developer messages if they exist
219
-        $msg = explode('||', $this->getMessage());
220
-        $user_msg = $msg[0];
221
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
222
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
223
-        // add details to _all_exceptions array
224
-        $x_time = time();
225
-        self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
226
-        self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
227
-        self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
228
-        self::$_all_exceptions[ $x_time ]['msg'] = $msg;
229
-        self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
230
-        self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
231
-        self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
232
-        self::$_error_count++;
233
-        // add_action( 'shutdown', array( $this, 'display_errors' ));
234
-        $this->display_errors();
235
-    }
236
-
237
-
238
-    /**
239
-     * @param bool   $check_stored
240
-     * @param string $type_to_check
241
-     * @return bool
242
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
243
-     * @throws \InvalidArgumentException
244
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
245
-     * @throws InvalidInterfaceException
246
-     */
247
-    public static function has_error($check_stored = false, $type_to_check = 'errors')
248
-    {
249
-        $has_error = isset(self::$_espresso_notices[ $type_to_check ])
250
-                     && ! empty(self::$_espresso_notices[ $type_to_check ])
251
-            ? true
252
-            : false;
253
-        if ($check_stored && ! $has_error) {
254
-            $notices = EE_Error::getStoredNotices();
255
-            foreach ($notices as $type => $notice) {
256
-                if ($type === $type_to_check && $notice) {
257
-                    return true;
258
-                }
259
-            }
260
-        }
261
-        return $has_error;
262
-    }
263
-
264
-
265
-    /**
266
-     * @echo string
267
-     * @throws \ReflectionException
268
-     */
269
-    public function display_errors()
270
-    {
271
-        $trace_details = '';
272
-        $output = '
28
+	const OPTIONS_KEY_NOTICES = 'ee_notices';
29
+
30
+
31
+	/**
32
+	 * name of the file to log exceptions to
33
+	 *
34
+	 * @var string
35
+	 */
36
+	private static $_exception_log_file = 'espresso_error_log.txt';
37
+
38
+	/**
39
+	 *    stores details for all exception
40
+	 *
41
+	 * @var array
42
+	 */
43
+	private static $_all_exceptions = array();
44
+
45
+	/**
46
+	 *    tracks number of errors
47
+	 *
48
+	 * @var int
49
+	 */
50
+	private static $_error_count = 0;
51
+
52
+	/**
53
+	 * @var array $_espresso_notices
54
+	 */
55
+	private static $_espresso_notices = array('success' => false, 'errors' => false, 'attention' => false);
56
+
57
+
58
+	/**
59
+	 * @override default exception handling
60
+	 * @param string         $message
61
+	 * @param int            $code
62
+	 * @param Exception|null $previous
63
+	 */
64
+	public function __construct($message, $code = 0, Exception $previous = null)
65
+	{
66
+		if (version_compare(PHP_VERSION, '5.3.0', '<')) {
67
+			parent::__construct($message, $code);
68
+		} else {
69
+			parent::__construct($message, $code, $previous);
70
+		}
71
+	}
72
+
73
+
74
+	/**
75
+	 *    error_handler
76
+	 *
77
+	 * @param $code
78
+	 * @param $message
79
+	 * @param $file
80
+	 * @param $line
81
+	 * @return void
82
+	 */
83
+	public static function error_handler($code, $message, $file, $line)
84
+	{
85
+		$type = EE_Error::error_type($code);
86
+		$site = site_url();
87
+		switch ($site) {
88
+			case 'http://ee4.eventespresso.com/':
89
+			case 'http://ee4decaf.eventespresso.com/':
90
+			case 'http://ee4hf.eventespresso.com/':
91
+			case 'http://ee4a.eventespresso.com/':
92
+			case 'http://ee4ad.eventespresso.com/':
93
+			case 'http://ee4b.eventespresso.com/':
94
+			case 'http://ee4bd.eventespresso.com/':
95
+			case 'http://ee4d.eventespresso.com/':
96
+			case 'http://ee4dd.eventespresso.com/':
97
+				$to = '[email protected]';
98
+				break;
99
+			default:
100
+				$to = get_option('admin_email');
101
+		}
102
+		$subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
103
+		$msg = EE_Error::_format_error($type, $message, $file, $line);
104
+		if (function_exists('wp_mail')) {
105
+			add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
106
+			wp_mail($to, $subject, $msg);
107
+		}
108
+		echo '<div id="message" class="espresso-notices error"><p>';
109
+		echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
110
+		echo '<br /></p></div>';
111
+	}
112
+
113
+
114
+	/**
115
+	 * error_type
116
+	 * http://www.php.net/manual/en/errorfunc.constants.php#109430
117
+	 *
118
+	 * @param $code
119
+	 * @return string
120
+	 */
121
+	public static function error_type($code)
122
+	{
123
+		switch ($code) {
124
+			case E_ERROR: // 1 //
125
+				return 'E_ERROR';
126
+			case E_WARNING: // 2 //
127
+				return 'E_WARNING';
128
+			case E_PARSE: // 4 //
129
+				return 'E_PARSE';
130
+			case E_NOTICE: // 8 //
131
+				return 'E_NOTICE';
132
+			case E_CORE_ERROR: // 16 //
133
+				return 'E_CORE_ERROR';
134
+			case E_CORE_WARNING: // 32 //
135
+				return 'E_CORE_WARNING';
136
+			case E_COMPILE_ERROR: // 64 //
137
+				return 'E_COMPILE_ERROR';
138
+			case E_COMPILE_WARNING: // 128 //
139
+				return 'E_COMPILE_WARNING';
140
+			case E_USER_ERROR: // 256 //
141
+				return 'E_USER_ERROR';
142
+			case E_USER_WARNING: // 512 //
143
+				return 'E_USER_WARNING';
144
+			case E_USER_NOTICE: // 1024 //
145
+				return 'E_USER_NOTICE';
146
+			case E_STRICT: // 2048 //
147
+				return 'E_STRICT';
148
+			case E_RECOVERABLE_ERROR: // 4096 //
149
+				return 'E_RECOVERABLE_ERROR';
150
+			case E_DEPRECATED: // 8192 //
151
+				return 'E_DEPRECATED';
152
+			case E_USER_DEPRECATED: // 16384 //
153
+				return 'E_USER_DEPRECATED';
154
+			case E_ALL: // 16384 //
155
+				return 'E_ALL';
156
+		}
157
+		return '';
158
+	}
159
+
160
+
161
+	/**
162
+	 *    fatal_error_handler
163
+	 *
164
+	 * @return void
165
+	 */
166
+	public static function fatal_error_handler()
167
+	{
168
+		$last_error = error_get_last();
169
+		if ($last_error['type'] === E_ERROR) {
170
+			EE_Error::error_handler(E_ERROR, $last_error['message'], $last_error['file'], $last_error['line']);
171
+		}
172
+	}
173
+
174
+
175
+	/**
176
+	 * _format_error
177
+	 *
178
+	 * @param $code
179
+	 * @param $message
180
+	 * @param $file
181
+	 * @param $line
182
+	 * @return string
183
+	 */
184
+	private static function _format_error($code, $message, $file, $line)
185
+	{
186
+		$html = "<table cellpadding='5'><thead bgcolor='#f8f8f8'><th>Item</th><th align='left'>Details</th></thead><tbody>";
187
+		$html .= "<tr valign='top'><td><b>Code</b></td><td>$code</td></tr>";
188
+		$html .= "<tr valign='top'><td><b>Error</b></td><td>$message</td></tr>";
189
+		$html .= "<tr valign='top'><td><b>File</b></td><td>$file</td></tr>";
190
+		$html .= "<tr valign='top'><td><b>Line</b></td><td>$line</td></tr>";
191
+		$html .= '</tbody></table>';
192
+		return $html;
193
+	}
194
+
195
+
196
+	/**
197
+	 * set_content_type
198
+	 *
199
+	 * @param $content_type
200
+	 * @return string
201
+	 */
202
+	public static function set_content_type($content_type)
203
+	{
204
+		return 'text/html';
205
+	}
206
+
207
+
208
+	/**
209
+	 * @return void
210
+	 * @throws EE_Error
211
+	 * @throws ReflectionException
212
+	 */
213
+	public function get_error()
214
+	{
215
+		if (apply_filters('FHEE__EE_Error__get_error__show_normal_exceptions', false)) {
216
+			throw $this;
217
+		}
218
+		// get separate user and developer messages if they exist
219
+		$msg = explode('||', $this->getMessage());
220
+		$user_msg = $msg[0];
221
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
222
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
223
+		// add details to _all_exceptions array
224
+		$x_time = time();
225
+		self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
226
+		self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
227
+		self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
228
+		self::$_all_exceptions[ $x_time ]['msg'] = $msg;
229
+		self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
230
+		self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
231
+		self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
232
+		self::$_error_count++;
233
+		// add_action( 'shutdown', array( $this, 'display_errors' ));
234
+		$this->display_errors();
235
+	}
236
+
237
+
238
+	/**
239
+	 * @param bool   $check_stored
240
+	 * @param string $type_to_check
241
+	 * @return bool
242
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
243
+	 * @throws \InvalidArgumentException
244
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
245
+	 * @throws InvalidInterfaceException
246
+	 */
247
+	public static function has_error($check_stored = false, $type_to_check = 'errors')
248
+	{
249
+		$has_error = isset(self::$_espresso_notices[ $type_to_check ])
250
+					 && ! empty(self::$_espresso_notices[ $type_to_check ])
251
+			? true
252
+			: false;
253
+		if ($check_stored && ! $has_error) {
254
+			$notices = EE_Error::getStoredNotices();
255
+			foreach ($notices as $type => $notice) {
256
+				if ($type === $type_to_check && $notice) {
257
+					return true;
258
+				}
259
+			}
260
+		}
261
+		return $has_error;
262
+	}
263
+
264
+
265
+	/**
266
+	 * @echo string
267
+	 * @throws \ReflectionException
268
+	 */
269
+	public function display_errors()
270
+	{
271
+		$trace_details = '';
272
+		$output = '
273 273
 <style type="text/css">
274 274
 	#ee-error-message {
275 275
 		max-width:90% !important;
@@ -325,21 +325,21 @@  discard block
 block discarded – undo
325 325
 	}
326 326
 </style>
327 327
 <div id="ee-error-message" class="error">';
328
-        if (! WP_DEBUG) {
329
-            $output .= '
328
+		if (! WP_DEBUG) {
329
+			$output .= '
330 330
 	<p>';
331
-        }
332
-        // cycle thru errors
333
-        foreach (self::$_all_exceptions as $time => $ex) {
334
-            $error_code = '';
335
-            // process trace info
336
-            if (empty($ex['trace'])) {
337
-                $trace_details .= __(
338
-                    'Sorry, but no trace information was available for this exception.',
339
-                    'event_espresso'
340
-                );
341
-            } else {
342
-                $trace_details .= '
331
+		}
332
+		// cycle thru errors
333
+		foreach (self::$_all_exceptions as $time => $ex) {
334
+			$error_code = '';
335
+			// process trace info
336
+			if (empty($ex['trace'])) {
337
+				$trace_details .= __(
338
+					'Sorry, but no trace information was available for this exception.',
339
+					'event_espresso'
340
+				);
341
+			} else {
342
+				$trace_details .= '
343 343
 			<div id="ee-trace-details">
344 344
 			<table width="100%" border="0" cellpadding="5" cellspacing="0">
345 345
 				<tr>
@@ -349,43 +349,43 @@  discard block
 block discarded – undo
349 349
 					<th scope="col" align="left">Class</th>
350 350
 					<th scope="col" align="left">Method( arguments )</th>
351 351
 				</tr>';
352
-                $last_on_stack = count($ex['trace']) - 1;
353
-                // reverse array so that stack is in proper chronological order
354
-                $sorted_trace = array_reverse($ex['trace']);
355
-                foreach ($sorted_trace as $nmbr => $trace) {
356
-                    $file = isset($trace['file']) ? $trace['file'] : '';
357
-                    $class = isset($trace['class']) ? $trace['class'] : '';
358
-                    $type = isset($trace['type']) ? $trace['type'] : '';
359
-                    $function = isset($trace['function']) ? $trace['function'] : '';
360
-                    $args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
361
-                    $line = isset($trace['line']) ? $trace['line'] : '';
362
-                    $zebra = ($nmbr % 2) ? ' odd' : '';
363
-                    if (empty($file) && ! empty($class)) {
364
-                        $a = new ReflectionClass($class);
365
-                        $file = $a->getFileName();
366
-                        if (empty($line) && ! empty($function)) {
367
-                            try {
368
-                                // if $function is a closure, this throws an exception
369
-                                $b = new ReflectionMethod($class, $function);
370
-                                $line = $b->getStartLine();
371
-                            } catch (Exception $closure_exception) {
372
-                                $line = 'unknown';
373
-                            }
374
-                        }
375
-                    }
376
-                    if ($nmbr === $last_on_stack) {
377
-                        $file = $ex['file'] !== '' ? $ex['file'] : $file;
378
-                        $line = $ex['line'] !== '' ? $ex['line'] : $line;
379
-                        $error_code = self::generate_error_code($file, $trace['function'], $line);
380
-                    }
381
-                    $nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
382
-                    $line_dsply = ! empty($line) ? $line : '&nbsp;';
383
-                    $file_dsply = ! empty($file) ? $file : '&nbsp;';
384
-                    $class_dsply = ! empty($class) ? $class : '&nbsp;';
385
-                    $type_dsply = ! empty($type) ? $type : '&nbsp;';
386
-                    $function_dsply = ! empty($function) ? $function : '&nbsp;';
387
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
388
-                    $trace_details .= '
352
+				$last_on_stack = count($ex['trace']) - 1;
353
+				// reverse array so that stack is in proper chronological order
354
+				$sorted_trace = array_reverse($ex['trace']);
355
+				foreach ($sorted_trace as $nmbr => $trace) {
356
+					$file = isset($trace['file']) ? $trace['file'] : '';
357
+					$class = isset($trace['class']) ? $trace['class'] : '';
358
+					$type = isset($trace['type']) ? $trace['type'] : '';
359
+					$function = isset($trace['function']) ? $trace['function'] : '';
360
+					$args = isset($trace['args']) ? $this->_convert_args_to_string($trace['args']) : '';
361
+					$line = isset($trace['line']) ? $trace['line'] : '';
362
+					$zebra = ($nmbr % 2) ? ' odd' : '';
363
+					if (empty($file) && ! empty($class)) {
364
+						$a = new ReflectionClass($class);
365
+						$file = $a->getFileName();
366
+						if (empty($line) && ! empty($function)) {
367
+							try {
368
+								// if $function is a closure, this throws an exception
369
+								$b = new ReflectionMethod($class, $function);
370
+								$line = $b->getStartLine();
371
+							} catch (Exception $closure_exception) {
372
+								$line = 'unknown';
373
+							}
374
+						}
375
+					}
376
+					if ($nmbr === $last_on_stack) {
377
+						$file = $ex['file'] !== '' ? $ex['file'] : $file;
378
+						$line = $ex['line'] !== '' ? $ex['line'] : $line;
379
+						$error_code = self::generate_error_code($file, $trace['function'], $line);
380
+					}
381
+					$nmbr_dsply = ! empty($nmbr) ? $nmbr : '&nbsp;';
382
+					$line_dsply = ! empty($line) ? $line : '&nbsp;';
383
+					$file_dsply = ! empty($file) ? $file : '&nbsp;';
384
+					$class_dsply = ! empty($class) ? $class : '&nbsp;';
385
+					$type_dsply = ! empty($type) ? $type : '&nbsp;';
386
+					$function_dsply = ! empty($function) ? $function : '&nbsp;';
387
+					$args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
388
+					$trace_details .= '
389 389
 					<tr>
390 390
 						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
391 391
 						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
@@ -393,626 +393,626 @@  discard block
 block discarded – undo
393 393
 						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
394 394
 						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
395 395
 					</tr>';
396
-                }
397
-                $trace_details .= '
396
+				}
397
+				$trace_details .= '
398 398
 			 </table>
399 399
 			</div>';
400
-            }
401
-            $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
402
-            // add generic non-identifying messages for non-privileged users
403
-            if (! WP_DEBUG) {
404
-                $output .= '<span class="ee-error-user-msg-spn">'
405
-                           . trim($ex['msg'])
406
-                           . '</span> &nbsp; <sup>'
407
-                           . $ex['code']
408
-                           . '</sup><br />';
409
-            } else {
410
-                // or helpful developer messages if debugging is on
411
-                $output .= '
400
+			}
401
+			$ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
402
+			// add generic non-identifying messages for non-privileged users
403
+			if (! WP_DEBUG) {
404
+				$output .= '<span class="ee-error-user-msg-spn">'
405
+						   . trim($ex['msg'])
406
+						   . '</span> &nbsp; <sup>'
407
+						   . $ex['code']
408
+						   . '</sup><br />';
409
+			} else {
410
+				// or helpful developer messages if debugging is on
411
+				$output .= '
412 412
 		<div class="ee-error-dev-msg-dv">
413 413
 			<p class="ee-error-dev-msg-pg">
414 414
 				<strong class="ee-error-dev-msg-str">An '
415
-                           . $ex['name']
416
-                           . ' exception was thrown!</strong>  &nbsp; <span>code: '
417
-                           . $ex['code']
418
-                           . '</span><br />
415
+						   . $ex['name']
416
+						   . ' exception was thrown!</strong>  &nbsp; <span>code: '
417
+						   . $ex['code']
418
+						   . '</span><br />
419 419
 				<span class="big-text">"'
420
-                           . trim($ex['msg'])
421
-                           . '"</span><br/>
420
+						   . trim($ex['msg'])
421
+						   . '"</span><br/>
422 422
 				<a id="display-ee-error-trace-'
423
-                           . self::$_error_count
424
-                           . $time
425
-                           . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
426
-                           . self::$_error_count
427
-                           . $time
428
-                           . '">
423
+						   . self::$_error_count
424
+						   . $time
425
+						   . '" class="display-ee-error-trace-lnk small-text" rel="ee-error-trace-'
426
+						   . self::$_error_count
427
+						   . $time
428
+						   . '">
429 429
 					'
430
-                           . __('click to view backtrace and class/method details', 'event_espresso')
431
-                           . '
430
+						   . __('click to view backtrace and class/method details', 'event_espresso')
431
+						   . '
432 432
 				</a><br />
433 433
 				<span class="small-text lt-grey-text">'
434
-                           . $ex['file']
435
-                           . ' &nbsp; ( line no: '
436
-                           . $ex['line']
437
-                           . ' )</span>
434
+						   . $ex['file']
435
+						   . ' &nbsp; ( line no: '
436
+						   . $ex['line']
437
+						   . ' )</span>
438 438
 			</p>
439 439
 			<div id="ee-error-trace-'
440
-                           . self::$_error_count
441
-                           . $time
442
-                           . '-dv" class="ee-error-trace-dv" style="display: none;">
440
+						   . self::$_error_count
441
+						   . $time
442
+						   . '-dv" class="ee-error-trace-dv" style="display: none;">
443 443
 				'
444
-                           . $trace_details;
445
-                if (! empty($class)) {
446
-                    $output .= '
444
+						   . $trace_details;
445
+				if (! empty($class)) {
446
+					$output .= '
447 447
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
448 448
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
449 449
 						<h3>Class Details</h3>';
450
-                    $a = new ReflectionClass($class);
451
-                    $output .= '
450
+					$a = new ReflectionClass($class);
451
+					$output .= '
452 452
 						<pre>' . $a . '</pre>
453 453
 					</div>
454 454
 				</div>';
455
-                }
456
-                $output .= '
455
+				}
456
+				$output .= '
457 457
 			</div>
458 458
 		</div>
459 459
 		<br />';
460
-            }
461
-            $this->write_to_error_log($time, $ex);
462
-        }
463
-        // remove last linebreak
464
-        $output = substr($output, 0, -6);
465
-        if (! WP_DEBUG) {
466
-            $output .= '
460
+			}
461
+			$this->write_to_error_log($time, $ex);
462
+		}
463
+		// remove last linebreak
464
+		$output = substr($output, 0, -6);
465
+		if (! WP_DEBUG) {
466
+			$output .= '
467 467
 	</p>';
468
-        }
469
-        $output .= '
468
+		}
469
+		$output .= '
470 470
 </div>';
471
-        $output .= self::_print_scripts(true);
472
-        if (defined('DOING_AJAX')) {
473
-            echo wp_json_encode(array('error' => $output));
474
-            exit();
475
-        }
476
-        echo $output;
477
-        die();
478
-    }
479
-
480
-
481
-    /**
482
-     *    generate string from exception trace args
483
-     *
484
-     * @param array $arguments
485
-     * @param bool  $array
486
-     * @return string
487
-     */
488
-    private function _convert_args_to_string($arguments = array(), $array = false)
489
-    {
490
-        $arg_string = '';
491
-        if (! empty($arguments)) {
492
-            $args = array();
493
-            foreach ($arguments as $arg) {
494
-                if (! empty($arg)) {
495
-                    if (is_string($arg)) {
496
-                        $args[] = " '" . $arg . "'";
497
-                    } elseif (is_array($arg)) {
498
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
499
-                    } elseif ($arg === null) {
500
-                        $args[] = ' NULL';
501
-                    } elseif (is_bool($arg)) {
502
-                        $args[] = ($arg) ? ' TRUE' : ' FALSE';
503
-                    } elseif (is_object($arg)) {
504
-                        $args[] = ' OBJECT ' . get_class($arg);
505
-                    } elseif (is_resource($arg)) {
506
-                        $args[] = get_resource_type($arg);
507
-                    } else {
508
-                        $args[] = $arg;
509
-                    }
510
-                }
511
-            }
512
-            $arg_string = implode(', ', $args);
513
-        }
514
-        if ($array) {
515
-            $arg_string .= ' )';
516
-        }
517
-        return $arg_string;
518
-    }
519
-
520
-
521
-    /**
522
-     *    add error message
523
-     *
524
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
525
-     *                            separate messages for user || dev
526
-     * @param        string $file the file that the error occurred in - just use __FILE__
527
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
528
-     * @param        string $line the line number where the error occurred - just use __LINE__
529
-     * @return        void
530
-     */
531
-    public static function add_error($msg = null, $file = null, $func = null, $line = null)
532
-    {
533
-        self::_add_notice('errors', $msg, $file, $func, $line);
534
-        self::$_error_count++;
535
-    }
536
-
537
-
538
-    /**
539
-     * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
540
-     * adds an error
541
-     *
542
-     * @param string $msg
543
-     * @param string $file
544
-     * @param string $func
545
-     * @param string $line
546
-     * @throws EE_Error
547
-     */
548
-    public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
549
-    {
550
-        if (WP_DEBUG) {
551
-            throw new EE_Error($msg);
552
-        }
553
-        EE_Error::add_error($msg, $file, $func, $line);
554
-    }
555
-
556
-
557
-    /**
558
-     *    add success message
559
-     *
560
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
561
-     *                            separate messages for user || dev
562
-     * @param        string $file the file that the error occurred in - just use __FILE__
563
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
564
-     * @param        string $line the line number where the error occurred - just use __LINE__
565
-     * @return        void
566
-     */
567
-    public static function add_success($msg = null, $file = null, $func = null, $line = null)
568
-    {
569
-        self::_add_notice('success', $msg, $file, $func, $line);
570
-    }
571
-
572
-
573
-    /**
574
-     *    add attention message
575
-     *
576
-     * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
577
-     *                            separate messages for user || dev
578
-     * @param        string $file the file that the error occurred in - just use __FILE__
579
-     * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
580
-     * @param        string $line the line number where the error occurred - just use __LINE__
581
-     * @return        void
582
-     */
583
-    public static function add_attention($msg = null, $file = null, $func = null, $line = null)
584
-    {
585
-        self::_add_notice('attention', $msg, $file, $func, $line);
586
-    }
587
-
588
-
589
-    /**
590
-     * @param string $type whether the message is for a success or error notification
591
-     * @param string $msg  the message to display to users or developers
592
-     *                     - adding a double pipe || (OR) creates separate messages for user || dev
593
-     * @param string $file the file that the error occurred in - just use __FILE__
594
-     * @param string $func the function/method that the error occurred in - just use __FUNCTION__
595
-     * @param string $line the line number where the error occurred - just use __LINE__
596
-     * @return void
597
-     */
598
-    private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
599
-    {
600
-        if (empty($msg)) {
601
-            EE_Error::doing_it_wrong(
602
-                'EE_Error::add_' . $type . '()',
603
-                sprintf(
604
-                    __(
605
-                        'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
606
-                        'event_espresso'
607
-                    ),
608
-                    $type,
609
-                    $file,
610
-                    $line
611
-                ),
612
-                EVENT_ESPRESSO_VERSION
613
-            );
614
-        }
615
-        if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
616
-            EE_Error::doing_it_wrong(
617
-                'EE_Error::add_error()',
618
-                __(
619
-                    'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
620
-                    'event_espresso'
621
-                ),
622
-                EVENT_ESPRESSO_VERSION
623
-            );
624
-        }
625
-        // get separate user and developer messages if they exist
626
-        $msg = explode('||', $msg);
627
-        $user_msg = $msg[0];
628
-        $dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
629
-        /**
630
-         * Do an action so other code can be triggered when a notice is created
631
-         *
632
-         * @param string $type     can be 'errors', 'attention', or 'success'
633
-         * @param string $user_msg message displayed to user when WP_DEBUG is off
634
-         * @param string $user_msg message displayed to user when WP_DEBUG is on
635
-         * @param string $file     file where error was generated
636
-         * @param string $func     function where error was generated
637
-         * @param string $line     line where error was generated
638
-         */
639
-        do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
640
-        $msg = WP_DEBUG ? $dev_msg : $user_msg;
641
-        // add notice if message exists
642
-        if (! empty($msg)) {
643
-            // get error code
644
-            $notice_code = EE_Error::generate_error_code($file, $func, $line);
645
-            if (WP_DEBUG && $type === 'errors') {
646
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
647
-            }
648
-            // add notice. Index by code if it's not blank
649
-            if ($notice_code) {
650
-                self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
651
-            } else {
652
-                self::$_espresso_notices[ $type ][] = $msg;
653
-            }
654
-            add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
655
-        }
656
-    }
657
-
658
-
659
-    /**
660
-     * in some case it may be necessary to overwrite the existing success messages
661
-     *
662
-     * @return        void
663
-     */
664
-    public static function overwrite_success()
665
-    {
666
-        self::$_espresso_notices['success'] = false;
667
-    }
668
-
669
-
670
-    /**
671
-     * in some case it may be necessary to overwrite the existing attention messages
672
-     *
673
-     * @return void
674
-     */
675
-    public static function overwrite_attention()
676
-    {
677
-        self::$_espresso_notices['attention'] = false;
678
-    }
679
-
680
-
681
-    /**
682
-     * in some case it may be necessary to overwrite the existing error messages
683
-     *
684
-     * @return void
685
-     */
686
-    public static function overwrite_errors()
687
-    {
688
-        self::$_espresso_notices['errors'] = false;
689
-    }
690
-
691
-
692
-    /**
693
-     * @return void
694
-     */
695
-    public static function reset_notices()
696
-    {
697
-        self::$_espresso_notices['success'] = false;
698
-        self::$_espresso_notices['attention'] = false;
699
-        self::$_espresso_notices['errors'] = false;
700
-    }
701
-
702
-
703
-    /**
704
-     * @return int
705
-     */
706
-    public static function has_notices()
707
-    {
708
-        $has_notices = 0;
709
-        // check for success messages
710
-        $has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
711
-            ? 3
712
-            : $has_notices;
713
-        // check for attention messages
714
-        $has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
715
-            ? 2
716
-            : $has_notices;
717
-        // check for error messages
718
-        $has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
719
-            ? 1
720
-            : $has_notices;
721
-        return $has_notices;
722
-    }
723
-
724
-
725
-    /**
726
-     * This simply returns non formatted error notices as they were sent into the EE_Error object.
727
-     *
728
-     * @since 4.9.0
729
-     * @return array
730
-     */
731
-    public static function get_vanilla_notices()
732
-    {
733
-        return array(
734
-            'success'   => isset(self::$_espresso_notices['success'])
735
-                ? self::$_espresso_notices['success']
736
-                : array(),
737
-            'attention' => isset(self::$_espresso_notices['attention'])
738
-                ? self::$_espresso_notices['attention']
739
-                : array(),
740
-            'errors'    => isset(self::$_espresso_notices['errors'])
741
-                ? self::$_espresso_notices['errors']
742
-                : array(),
743
-        );
744
-    }
745
-
746
-
747
-    /**
748
-     * @return array
749
-     * @throws InvalidArgumentException
750
-     * @throws InvalidDataTypeException
751
-     * @throws InvalidInterfaceException
752
-     */
753
-    public static function getStoredNotices()
754
-    {
755
-        if ($user_id = get_current_user_id()) {
756
-            // get notices for logged in user
757
-            $notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id);
758
-            return is_array($notices) ? $notices : array();
759
-        }
760
-        if (EE_Session::isLoadedAndActive()) {
761
-            // get notices for user currently engaged in a session
762
-            $session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES);
763
-            return is_array($session_data) ? $session_data : array();
764
-        }
765
-        // get global notices and hope they apply to the current site visitor
766
-        $notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
767
-        return is_array($notices) ? $notices : array();
768
-    }
769
-
770
-
771
-    /**
772
-     * @param array $notices
773
-     * @return bool
774
-     * @throws InvalidArgumentException
775
-     * @throws InvalidDataTypeException
776
-     * @throws InvalidInterfaceException
777
-     */
778
-    public static function storeNotices(array $notices)
779
-    {
780
-        if ($user_id = get_current_user_id()) {
781
-            // store notices for logged in user
782
-            return (bool) update_user_option(
783
-                $user_id,
784
-                EE_Error::OPTIONS_KEY_NOTICES,
785
-                $notices
786
-            );
787
-        }
788
-        if (EE_Session::isLoadedAndActive()) {
789
-            // store notices for user currently engaged in a session
790
-            return EE_Session::instance()->set_session_data(
791
-                array(EE_Error::OPTIONS_KEY_NOTICES => $notices)
792
-            );
793
-        }
794
-        // store global notices and hope they apply to the same site visitor on the next request
795
-        return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices);
796
-    }
797
-
798
-
799
-    /**
800
-     * @return bool|TRUE
801
-     * @throws InvalidArgumentException
802
-     * @throws InvalidDataTypeException
803
-     * @throws InvalidInterfaceException
804
-     */
805
-    public static function clearNotices()
806
-    {
807
-        if ($user_id = get_current_user_id()) {
808
-            // clear notices for logged in user
809
-            return (bool) update_user_option(
810
-                $user_id,
811
-                EE_Error::OPTIONS_KEY_NOTICES,
812
-                array()
813
-            );
814
-        }
815
-        if (EE_Session::isLoadedAndActive()) {
816
-            // clear notices for user currently engaged in a session
817
-            return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES);
818
-        }
819
-        // clear global notices and hope none belonged to some for some other site visitor
820
-        return update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
821
-    }
822
-
823
-
824
-    /**
825
-     * saves notices to the db for retrieval on next request
826
-     *
827
-     * @return void
828
-     * @throws InvalidArgumentException
829
-     * @throws InvalidDataTypeException
830
-     * @throws InvalidInterfaceException
831
-     */
832
-    public static function stashNoticesBeforeRedirect()
833
-    {
834
-        EE_Error::get_notices(false, true);
835
-    }
836
-
837
-
838
-    /**
839
-     * compile all error or success messages into one string
840
-     *
841
-     * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
842
-     * @param boolean $format_output            whether or not to format the messages for display in the WP admin
843
-     * @param boolean $save_to_transient        whether or not to save notices to the db for retrieval on next request
844
-     *                                          - ONLY do this just before redirecting
845
-     * @param boolean $remove_empty             whether or not to unset empty messages
846
-     * @return array
847
-     * @throws InvalidArgumentException
848
-     * @throws InvalidDataTypeException
849
-     * @throws InvalidInterfaceException
850
-     */
851
-    public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
852
-    {
853
-        $success_messages = '';
854
-        $attention_messages = '';
855
-        $error_messages = '';
856
-        // either save notices to the db
857
-        if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
858
-            self::$_espresso_notices = array_merge(
859
-                EE_Error::getStoredNotices(),
860
-                self::$_espresso_notices
861
-            );
862
-            EE_Error::storeNotices(self::$_espresso_notices);
863
-            return array();
864
-        }
865
-        $print_scripts = EE_Error::combineExistingAndNewNotices();
866
-        // check for success messages
867
-        if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
868
-            // combine messages
869
-            $success_messages .= implode('<br />', self::$_espresso_notices['success']);
870
-            $print_scripts = true;
871
-        }
872
-        // check for attention messages
873
-        if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
874
-            // combine messages
875
-            $attention_messages .= implode('<br />', self::$_espresso_notices['attention']);
876
-            $print_scripts = true;
877
-        }
878
-        // check for error messages
879
-        if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
880
-            $error_messages .= count(self::$_espresso_notices['errors']) > 1
881
-                ? __('The following errors have occurred:<br />', 'event_espresso')
882
-                : __('An error has occurred:<br />', 'event_espresso');
883
-            // combine messages
884
-            $error_messages .= implode('<br />', self::$_espresso_notices['errors']);
885
-            $print_scripts = true;
886
-        }
887
-        if ($format_output) {
888
-            $notices = EE_Error::formatNoticesOutput(
889
-                $success_messages,
890
-                $attention_messages,
891
-                $error_messages
892
-            );
893
-        } else {
894
-            $notices = array(
895
-                'success'   => $success_messages,
896
-                'attention' => $attention_messages,
897
-                'errors'    => $error_messages,
898
-            );
899
-            if ($remove_empty) {
900
-                // remove empty notices
901
-                foreach ($notices as $type => $notice) {
902
-                    if (empty($notice)) {
903
-                        unset($notices[ $type ]);
904
-                    }
905
-                }
906
-            }
907
-        }
908
-        if ($print_scripts) {
909
-            self::_print_scripts();
910
-        }
911
-        return $notices;
912
-    }
913
-
914
-
915
-    /**
916
-     * @return bool
917
-     * @throws InvalidArgumentException
918
-     * @throws InvalidDataTypeException
919
-     * @throws InvalidInterfaceException
920
-     */
921
-    private static function combineExistingAndNewNotices()
922
-    {
923
-        $print_scripts = false;
924
-        // grab any notices that have been previously saved
925
-        $notices = EE_Error::getStoredNotices();
926
-        if (! empty($notices)) {
927
-            foreach ($notices as $type => $notice) {
928
-                if (is_array($notice) && ! empty($notice)) {
929
-                    // make sure that existing notice type is an array
930
-                    self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
931
-                                                        && ! empty(self::$_espresso_notices[ $type ])
932
-                        ? self::$_espresso_notices[ $type ]
933
-                        : array();
934
-                    // add newly created notices to existing ones
935
-                    self::$_espresso_notices[ $type ] += $notice;
936
-                    $print_scripts = true;
937
-                }
938
-            }
939
-            // now clear any stored notices
940
-            EE_Error::clearNotices();
941
-        }
942
-        return $print_scripts;
943
-    }
944
-
945
-
946
-    /**
947
-     * @param string $success_messages
948
-     * @param string $attention_messages
949
-     * @param string $error_messages
950
-     * @return string
951
-     */
952
-    private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages)
953
-    {
954
-        $notices = '<div id="espresso-notices">';
955
-        $close = is_admin()
956
-            ? ''
957
-            : '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>';
958
-        if ($success_messages !== '') {
959
-            $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
960
-            $css_class = is_admin() ? 'updated fade' : 'success fade-away';
961
-            // showMessage( $success_messages );
962
-            $notices .= '<div id="' . $css_id . '" '
963
-                        . 'class="espresso-notices ' . $css_class . '" '
964
-                        . 'style="display:none;">'
965
-                        . '<p>' . $success_messages . '</p>'
966
-                        . $close
967
-                        . '</div>';
968
-        }
969
-        if ($attention_messages !== '') {
970
-            $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
971
-            $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
972
-            // showMessage( $error_messages, TRUE );
973
-            $notices .= '<div id="' . $css_id . '" '
974
-                        . 'class="espresso-notices ' . $css_class . '" '
975
-                        . 'style="display:none;">'
976
-                        . '<p>' . $attention_messages . '</p>'
977
-                        . $close
978
-                        . '</div>';
979
-        }
980
-        if ($error_messages !== '') {
981
-            $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
982
-            $css_class = is_admin() ? 'error' : 'error fade-away';
983
-            // showMessage( $error_messages, TRUE );
984
-            $notices .= '<div id="' . $css_id . '" '
985
-                        . 'class="espresso-notices ' . $css_class . '" '
986
-                        . 'style="display:none;">'
987
-                        . '<p>' . $error_messages . '</p>'
988
-                        . $close
989
-                        . '</div>';
990
-        }
991
-        $notices .= '</div>';
992
-        return $notices;
993
-    }
994
-
995
-
996
-    /**
997
-     * _print_scripts
998
-     *
999
-     * @param    bool $force_print
1000
-     * @return    string
1001
-     */
1002
-    private static function _print_scripts($force_print = false)
1003
-    {
1004
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1005
-            if (wp_script_is('ee_error_js', 'registered')) {
1006
-                wp_enqueue_style('espresso_default');
1007
-                wp_enqueue_style('espresso_custom_css');
1008
-                wp_enqueue_script('ee_error_js');
1009
-            }
1010
-            if (wp_script_is('ee_error_js', 'enqueued')) {
1011
-                wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1012
-                return '';
1013
-            }
1014
-        } else {
1015
-            return '
471
+		$output .= self::_print_scripts(true);
472
+		if (defined('DOING_AJAX')) {
473
+			echo wp_json_encode(array('error' => $output));
474
+			exit();
475
+		}
476
+		echo $output;
477
+		die();
478
+	}
479
+
480
+
481
+	/**
482
+	 *    generate string from exception trace args
483
+	 *
484
+	 * @param array $arguments
485
+	 * @param bool  $array
486
+	 * @return string
487
+	 */
488
+	private function _convert_args_to_string($arguments = array(), $array = false)
489
+	{
490
+		$arg_string = '';
491
+		if (! empty($arguments)) {
492
+			$args = array();
493
+			foreach ($arguments as $arg) {
494
+				if (! empty($arg)) {
495
+					if (is_string($arg)) {
496
+						$args[] = " '" . $arg . "'";
497
+					} elseif (is_array($arg)) {
498
+						$args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
499
+					} elseif ($arg === null) {
500
+						$args[] = ' NULL';
501
+					} elseif (is_bool($arg)) {
502
+						$args[] = ($arg) ? ' TRUE' : ' FALSE';
503
+					} elseif (is_object($arg)) {
504
+						$args[] = ' OBJECT ' . get_class($arg);
505
+					} elseif (is_resource($arg)) {
506
+						$args[] = get_resource_type($arg);
507
+					} else {
508
+						$args[] = $arg;
509
+					}
510
+				}
511
+			}
512
+			$arg_string = implode(', ', $args);
513
+		}
514
+		if ($array) {
515
+			$arg_string .= ' )';
516
+		}
517
+		return $arg_string;
518
+	}
519
+
520
+
521
+	/**
522
+	 *    add error message
523
+	 *
524
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
525
+	 *                            separate messages for user || dev
526
+	 * @param        string $file the file that the error occurred in - just use __FILE__
527
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
528
+	 * @param        string $line the line number where the error occurred - just use __LINE__
529
+	 * @return        void
530
+	 */
531
+	public static function add_error($msg = null, $file = null, $func = null, $line = null)
532
+	{
533
+		self::_add_notice('errors', $msg, $file, $func, $line);
534
+		self::$_error_count++;
535
+	}
536
+
537
+
538
+	/**
539
+	 * If WP_DEBUG is active, throws an exception. If WP_DEBUG is off, just
540
+	 * adds an error
541
+	 *
542
+	 * @param string $msg
543
+	 * @param string $file
544
+	 * @param string $func
545
+	 * @param string $line
546
+	 * @throws EE_Error
547
+	 */
548
+	public static function throw_exception_if_debugging($msg = null, $file = null, $func = null, $line = null)
549
+	{
550
+		if (WP_DEBUG) {
551
+			throw new EE_Error($msg);
552
+		}
553
+		EE_Error::add_error($msg, $file, $func, $line);
554
+	}
555
+
556
+
557
+	/**
558
+	 *    add success message
559
+	 *
560
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
561
+	 *                            separate messages for user || dev
562
+	 * @param        string $file the file that the error occurred in - just use __FILE__
563
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
564
+	 * @param        string $line the line number where the error occurred - just use __LINE__
565
+	 * @return        void
566
+	 */
567
+	public static function add_success($msg = null, $file = null, $func = null, $line = null)
568
+	{
569
+		self::_add_notice('success', $msg, $file, $func, $line);
570
+	}
571
+
572
+
573
+	/**
574
+	 *    add attention message
575
+	 *
576
+	 * @param        string $msg  the message to display to users or developers - adding a double pipe || (OR) creates
577
+	 *                            separate messages for user || dev
578
+	 * @param        string $file the file that the error occurred in - just use __FILE__
579
+	 * @param        string $func the function/method that the error occurred in - just use __FUNCTION__
580
+	 * @param        string $line the line number where the error occurred - just use __LINE__
581
+	 * @return        void
582
+	 */
583
+	public static function add_attention($msg = null, $file = null, $func = null, $line = null)
584
+	{
585
+		self::_add_notice('attention', $msg, $file, $func, $line);
586
+	}
587
+
588
+
589
+	/**
590
+	 * @param string $type whether the message is for a success or error notification
591
+	 * @param string $msg  the message to display to users or developers
592
+	 *                     - adding a double pipe || (OR) creates separate messages for user || dev
593
+	 * @param string $file the file that the error occurred in - just use __FILE__
594
+	 * @param string $func the function/method that the error occurred in - just use __FUNCTION__
595
+	 * @param string $line the line number where the error occurred - just use __LINE__
596
+	 * @return void
597
+	 */
598
+	private static function _add_notice($type = 'success', $msg = '', $file = '', $func = '', $line = '')
599
+	{
600
+		if (empty($msg)) {
601
+			EE_Error::doing_it_wrong(
602
+				'EE_Error::add_' . $type . '()',
603
+				sprintf(
604
+					__(
605
+						'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
606
+						'event_espresso'
607
+					),
608
+					$type,
609
+					$file,
610
+					$line
611
+				),
612
+				EVENT_ESPRESSO_VERSION
613
+			);
614
+		}
615
+		if ($type === 'errors' && (empty($file) || empty($func) || empty($line))) {
616
+			EE_Error::doing_it_wrong(
617
+				'EE_Error::add_error()',
618
+				__(
619
+					'You need to provide the file name, function name, and line number that the error occurred on in order to better assist with debugging.',
620
+					'event_espresso'
621
+				),
622
+				EVENT_ESPRESSO_VERSION
623
+			);
624
+		}
625
+		// get separate user and developer messages if they exist
626
+		$msg = explode('||', $msg);
627
+		$user_msg = $msg[0];
628
+		$dev_msg = isset($msg[1]) ? $msg[1] : $msg[0];
629
+		/**
630
+		 * Do an action so other code can be triggered when a notice is created
631
+		 *
632
+		 * @param string $type     can be 'errors', 'attention', or 'success'
633
+		 * @param string $user_msg message displayed to user when WP_DEBUG is off
634
+		 * @param string $user_msg message displayed to user when WP_DEBUG is on
635
+		 * @param string $file     file where error was generated
636
+		 * @param string $func     function where error was generated
637
+		 * @param string $line     line where error was generated
638
+		 */
639
+		do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
640
+		$msg = WP_DEBUG ? $dev_msg : $user_msg;
641
+		// add notice if message exists
642
+		if (! empty($msg)) {
643
+			// get error code
644
+			$notice_code = EE_Error::generate_error_code($file, $func, $line);
645
+			if (WP_DEBUG && $type === 'errors') {
646
+				$msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
647
+			}
648
+			// add notice. Index by code if it's not blank
649
+			if ($notice_code) {
650
+				self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
651
+			} else {
652
+				self::$_espresso_notices[ $type ][] = $msg;
653
+			}
654
+			add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
655
+		}
656
+	}
657
+
658
+
659
+	/**
660
+	 * in some case it may be necessary to overwrite the existing success messages
661
+	 *
662
+	 * @return        void
663
+	 */
664
+	public static function overwrite_success()
665
+	{
666
+		self::$_espresso_notices['success'] = false;
667
+	}
668
+
669
+
670
+	/**
671
+	 * in some case it may be necessary to overwrite the existing attention messages
672
+	 *
673
+	 * @return void
674
+	 */
675
+	public static function overwrite_attention()
676
+	{
677
+		self::$_espresso_notices['attention'] = false;
678
+	}
679
+
680
+
681
+	/**
682
+	 * in some case it may be necessary to overwrite the existing error messages
683
+	 *
684
+	 * @return void
685
+	 */
686
+	public static function overwrite_errors()
687
+	{
688
+		self::$_espresso_notices['errors'] = false;
689
+	}
690
+
691
+
692
+	/**
693
+	 * @return void
694
+	 */
695
+	public static function reset_notices()
696
+	{
697
+		self::$_espresso_notices['success'] = false;
698
+		self::$_espresso_notices['attention'] = false;
699
+		self::$_espresso_notices['errors'] = false;
700
+	}
701
+
702
+
703
+	/**
704
+	 * @return int
705
+	 */
706
+	public static function has_notices()
707
+	{
708
+		$has_notices = 0;
709
+		// check for success messages
710
+		$has_notices = self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])
711
+			? 3
712
+			: $has_notices;
713
+		// check for attention messages
714
+		$has_notices = self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])
715
+			? 2
716
+			: $has_notices;
717
+		// check for error messages
718
+		$has_notices = self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])
719
+			? 1
720
+			: $has_notices;
721
+		return $has_notices;
722
+	}
723
+
724
+
725
+	/**
726
+	 * This simply returns non formatted error notices as they were sent into the EE_Error object.
727
+	 *
728
+	 * @since 4.9.0
729
+	 * @return array
730
+	 */
731
+	public static function get_vanilla_notices()
732
+	{
733
+		return array(
734
+			'success'   => isset(self::$_espresso_notices['success'])
735
+				? self::$_espresso_notices['success']
736
+				: array(),
737
+			'attention' => isset(self::$_espresso_notices['attention'])
738
+				? self::$_espresso_notices['attention']
739
+				: array(),
740
+			'errors'    => isset(self::$_espresso_notices['errors'])
741
+				? self::$_espresso_notices['errors']
742
+				: array(),
743
+		);
744
+	}
745
+
746
+
747
+	/**
748
+	 * @return array
749
+	 * @throws InvalidArgumentException
750
+	 * @throws InvalidDataTypeException
751
+	 * @throws InvalidInterfaceException
752
+	 */
753
+	public static function getStoredNotices()
754
+	{
755
+		if ($user_id = get_current_user_id()) {
756
+			// get notices for logged in user
757
+			$notices = get_user_option(EE_Error::OPTIONS_KEY_NOTICES, $user_id);
758
+			return is_array($notices) ? $notices : array();
759
+		}
760
+		if (EE_Session::isLoadedAndActive()) {
761
+			// get notices for user currently engaged in a session
762
+			$session_data = EE_Session::instance()->get_session_data(EE_Error::OPTIONS_KEY_NOTICES);
763
+			return is_array($session_data) ? $session_data : array();
764
+		}
765
+		// get global notices and hope they apply to the current site visitor
766
+		$notices = get_option(EE_Error::OPTIONS_KEY_NOTICES, array());
767
+		return is_array($notices) ? $notices : array();
768
+	}
769
+
770
+
771
+	/**
772
+	 * @param array $notices
773
+	 * @return bool
774
+	 * @throws InvalidArgumentException
775
+	 * @throws InvalidDataTypeException
776
+	 * @throws InvalidInterfaceException
777
+	 */
778
+	public static function storeNotices(array $notices)
779
+	{
780
+		if ($user_id = get_current_user_id()) {
781
+			// store notices for logged in user
782
+			return (bool) update_user_option(
783
+				$user_id,
784
+				EE_Error::OPTIONS_KEY_NOTICES,
785
+				$notices
786
+			);
787
+		}
788
+		if (EE_Session::isLoadedAndActive()) {
789
+			// store notices for user currently engaged in a session
790
+			return EE_Session::instance()->set_session_data(
791
+				array(EE_Error::OPTIONS_KEY_NOTICES => $notices)
792
+			);
793
+		}
794
+		// store global notices and hope they apply to the same site visitor on the next request
795
+		return update_option(EE_Error::OPTIONS_KEY_NOTICES, $notices);
796
+	}
797
+
798
+
799
+	/**
800
+	 * @return bool|TRUE
801
+	 * @throws InvalidArgumentException
802
+	 * @throws InvalidDataTypeException
803
+	 * @throws InvalidInterfaceException
804
+	 */
805
+	public static function clearNotices()
806
+	{
807
+		if ($user_id = get_current_user_id()) {
808
+			// clear notices for logged in user
809
+			return (bool) update_user_option(
810
+				$user_id,
811
+				EE_Error::OPTIONS_KEY_NOTICES,
812
+				array()
813
+			);
814
+		}
815
+		if (EE_Session::isLoadedAndActive()) {
816
+			// clear notices for user currently engaged in a session
817
+			return EE_Session::instance()->reset_data(EE_Error::OPTIONS_KEY_NOTICES);
818
+		}
819
+		// clear global notices and hope none belonged to some for some other site visitor
820
+		return update_option(EE_Error::OPTIONS_KEY_NOTICES, array());
821
+	}
822
+
823
+
824
+	/**
825
+	 * saves notices to the db for retrieval on next request
826
+	 *
827
+	 * @return void
828
+	 * @throws InvalidArgumentException
829
+	 * @throws InvalidDataTypeException
830
+	 * @throws InvalidInterfaceException
831
+	 */
832
+	public static function stashNoticesBeforeRedirect()
833
+	{
834
+		EE_Error::get_notices(false, true);
835
+	}
836
+
837
+
838
+	/**
839
+	 * compile all error or success messages into one string
840
+	 *
841
+	 * @see EE_Error::get_raw_notices if you want the raw notices without any preparations made to them
842
+	 * @param boolean $format_output            whether or not to format the messages for display in the WP admin
843
+	 * @param boolean $save_to_transient        whether or not to save notices to the db for retrieval on next request
844
+	 *                                          - ONLY do this just before redirecting
845
+	 * @param boolean $remove_empty             whether or not to unset empty messages
846
+	 * @return array
847
+	 * @throws InvalidArgumentException
848
+	 * @throws InvalidDataTypeException
849
+	 * @throws InvalidInterfaceException
850
+	 */
851
+	public static function get_notices($format_output = true, $save_to_transient = false, $remove_empty = true)
852
+	{
853
+		$success_messages = '';
854
+		$attention_messages = '';
855
+		$error_messages = '';
856
+		// either save notices to the db
857
+		if ($save_to_transient || isset($_REQUEST['activate-selected'])) {
858
+			self::$_espresso_notices = array_merge(
859
+				EE_Error::getStoredNotices(),
860
+				self::$_espresso_notices
861
+			);
862
+			EE_Error::storeNotices(self::$_espresso_notices);
863
+			return array();
864
+		}
865
+		$print_scripts = EE_Error::combineExistingAndNewNotices();
866
+		// check for success messages
867
+		if (self::$_espresso_notices['success'] && ! empty(self::$_espresso_notices['success'])) {
868
+			// combine messages
869
+			$success_messages .= implode('<br />', self::$_espresso_notices['success']);
870
+			$print_scripts = true;
871
+		}
872
+		// check for attention messages
873
+		if (self::$_espresso_notices['attention'] && ! empty(self::$_espresso_notices['attention'])) {
874
+			// combine messages
875
+			$attention_messages .= implode('<br />', self::$_espresso_notices['attention']);
876
+			$print_scripts = true;
877
+		}
878
+		// check for error messages
879
+		if (self::$_espresso_notices['errors'] && ! empty(self::$_espresso_notices['errors'])) {
880
+			$error_messages .= count(self::$_espresso_notices['errors']) > 1
881
+				? __('The following errors have occurred:<br />', 'event_espresso')
882
+				: __('An error has occurred:<br />', 'event_espresso');
883
+			// combine messages
884
+			$error_messages .= implode('<br />', self::$_espresso_notices['errors']);
885
+			$print_scripts = true;
886
+		}
887
+		if ($format_output) {
888
+			$notices = EE_Error::formatNoticesOutput(
889
+				$success_messages,
890
+				$attention_messages,
891
+				$error_messages
892
+			);
893
+		} else {
894
+			$notices = array(
895
+				'success'   => $success_messages,
896
+				'attention' => $attention_messages,
897
+				'errors'    => $error_messages,
898
+			);
899
+			if ($remove_empty) {
900
+				// remove empty notices
901
+				foreach ($notices as $type => $notice) {
902
+					if (empty($notice)) {
903
+						unset($notices[ $type ]);
904
+					}
905
+				}
906
+			}
907
+		}
908
+		if ($print_scripts) {
909
+			self::_print_scripts();
910
+		}
911
+		return $notices;
912
+	}
913
+
914
+
915
+	/**
916
+	 * @return bool
917
+	 * @throws InvalidArgumentException
918
+	 * @throws InvalidDataTypeException
919
+	 * @throws InvalidInterfaceException
920
+	 */
921
+	private static function combineExistingAndNewNotices()
922
+	{
923
+		$print_scripts = false;
924
+		// grab any notices that have been previously saved
925
+		$notices = EE_Error::getStoredNotices();
926
+		if (! empty($notices)) {
927
+			foreach ($notices as $type => $notice) {
928
+				if (is_array($notice) && ! empty($notice)) {
929
+					// make sure that existing notice type is an array
930
+					self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
931
+														&& ! empty(self::$_espresso_notices[ $type ])
932
+						? self::$_espresso_notices[ $type ]
933
+						: array();
934
+					// add newly created notices to existing ones
935
+					self::$_espresso_notices[ $type ] += $notice;
936
+					$print_scripts = true;
937
+				}
938
+			}
939
+			// now clear any stored notices
940
+			EE_Error::clearNotices();
941
+		}
942
+		return $print_scripts;
943
+	}
944
+
945
+
946
+	/**
947
+	 * @param string $success_messages
948
+	 * @param string $attention_messages
949
+	 * @param string $error_messages
950
+	 * @return string
951
+	 */
952
+	private static function formatNoticesOutput($success_messages, $attention_messages, $error_messages)
953
+	{
954
+		$notices = '<div id="espresso-notices">';
955
+		$close = is_admin()
956
+			? ''
957
+			: '<a class="close-espresso-notice hide-if-no-js"><span class="dashicons dashicons-no"/></a>';
958
+		if ($success_messages !== '') {
959
+			$css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
960
+			$css_class = is_admin() ? 'updated fade' : 'success fade-away';
961
+			// showMessage( $success_messages );
962
+			$notices .= '<div id="' . $css_id . '" '
963
+						. 'class="espresso-notices ' . $css_class . '" '
964
+						. 'style="display:none;">'
965
+						. '<p>' . $success_messages . '</p>'
966
+						. $close
967
+						. '</div>';
968
+		}
969
+		if ($attention_messages !== '') {
970
+			$css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
971
+			$css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
972
+			// showMessage( $error_messages, TRUE );
973
+			$notices .= '<div id="' . $css_id . '" '
974
+						. 'class="espresso-notices ' . $css_class . '" '
975
+						. 'style="display:none;">'
976
+						. '<p>' . $attention_messages . '</p>'
977
+						. $close
978
+						. '</div>';
979
+		}
980
+		if ($error_messages !== '') {
981
+			$css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
982
+			$css_class = is_admin() ? 'error' : 'error fade-away';
983
+			// showMessage( $error_messages, TRUE );
984
+			$notices .= '<div id="' . $css_id . '" '
985
+						. 'class="espresso-notices ' . $css_class . '" '
986
+						. 'style="display:none;">'
987
+						. '<p>' . $error_messages . '</p>'
988
+						. $close
989
+						. '</div>';
990
+		}
991
+		$notices .= '</div>';
992
+		return $notices;
993
+	}
994
+
995
+
996
+	/**
997
+	 * _print_scripts
998
+	 *
999
+	 * @param    bool $force_print
1000
+	 * @return    string
1001
+	 */
1002
+	private static function _print_scripts($force_print = false)
1003
+	{
1004
+		if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1005
+			if (wp_script_is('ee_error_js', 'registered')) {
1006
+				wp_enqueue_style('espresso_default');
1007
+				wp_enqueue_style('espresso_custom_css');
1008
+				wp_enqueue_script('ee_error_js');
1009
+			}
1010
+			if (wp_script_is('ee_error_js', 'enqueued')) {
1011
+				wp_localize_script('ee_error_js', 'ee_settings', array('wp_debug' => WP_DEBUG));
1012
+				return '';
1013
+			}
1014
+		} else {
1015
+			return '
1016 1016
 <script>
1017 1017
 /* <![CDATA[ */
1018 1018
 var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
@@ -1022,221 +1022,221 @@  discard block
 block discarded – undo
1022 1022
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1023 1023
 <script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1024 1024
 ';
1025
-        }
1026
-        return '';
1027
-    }
1028
-
1029
-
1030
-    /**
1031
-     * @return void
1032
-     */
1033
-    public static function enqueue_error_scripts()
1034
-    {
1035
-        self::_print_scripts();
1036
-    }
1037
-
1038
-
1039
-    /**
1040
-     * create error code from filepath, function name,
1041
-     * and line number where exception or error was thrown
1042
-     *
1043
-     * @param string $file
1044
-     * @param string $func
1045
-     * @param string $line
1046
-     * @return string
1047
-     */
1048
-    public static function generate_error_code($file = '', $func = '', $line = '')
1049
-    {
1050
-        $file = explode('.', basename($file));
1051
-        $error_code = ! empty($file[0]) ? $file[0] : '';
1052
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1053
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1054
-        return $error_code;
1055
-    }
1056
-
1057
-
1058
-    /**
1059
-     * write exception details to log file
1060
-     * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
1061
-     *
1062
-     * @param int   $time
1063
-     * @param array $ex
1064
-     * @param bool  $clear
1065
-     * @return void
1066
-     */
1067
-    public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1068
-    {
1069
-        if (empty($ex)) {
1070
-            return;
1071
-        }
1072
-        if (! $time) {
1073
-            $time = time();
1074
-        }
1075
-        $exception_log = '----------------------------------------------------------------------------------------'
1076
-                         . PHP_EOL;
1077
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1078
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1079
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1080
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1081
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1082
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1083
-        $exception_log .= $ex['string'] . PHP_EOL;
1084
-        $exception_log .= '----------------------------------------------------------------------------------------'
1085
-                          . PHP_EOL;
1086
-        try {
1087
-            error_log($exception_log);
1088
-        } catch (EE_Error $e) {
1089
-            EE_Error::add_error(
1090
-                sprintf(
1091
-                    __(
1092
-                        'Event Espresso error logging could not be setup because: %s',
1093
-                        'event_espresso'
1094
-                    ),
1095
-                    $e->getMessage()
1096
-                )
1097
-            );
1098
-        }
1099
-    }
1100
-
1101
-
1102
-    /**
1103
-     * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1104
-     * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1105
-     * but the code execution is done in a manner that could lead to unexpected results
1106
-     * (i.e. running to early, or too late in WP or EE loading process).
1107
-     * A good test for knowing whether to use this method is:
1108
-     * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1109
-     * Yes -> use EE_Error::add_error() or throw new EE_Error()
1110
-     * 2. If this is loaded before something else, it won't break anything,
1111
-     * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1112
-     *
1113
-     * @uses   constant WP_DEBUG test if wp_debug is on or not
1114
-     * @param string $function      The function that was called
1115
-     * @param string $message       A message explaining what has been done incorrectly
1116
-     * @param string $version       The version of Event Espresso where the error was added
1117
-     * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1118
-     *                              for a deprecated function. This allows deprecation to occur during one version,
1119
-     *                              but not have any notices appear until a later version. This allows developers
1120
-     *                              extra time to update their code before notices appear.
1121
-     * @param int    $error_type
1122
-     */
1123
-    public static function doing_it_wrong(
1124
-        $function,
1125
-        $message,
1126
-        $version,
1127
-        $applies_when = '',
1128
-        $error_type = null
1129
-    ) {
1130
-        if (defined('WP_DEBUG') && WP_DEBUG) {
1131
-            EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1132
-        }
1133
-    }
1134
-
1135
-
1136
-    /**
1137
-     * Like get_notices, but returns an array of all the notices of the given type.
1138
-     *
1139
-     * @return array {
1140
-     * @type array $success   all the success messages
1141
-     * @type array $errors    all the error messages
1142
-     * @type array $attention all the attention messages
1143
-     * }
1144
-     */
1145
-    public static function get_raw_notices()
1146
-    {
1147
-        return self::$_espresso_notices;
1148
-    }
1149
-
1150
-
1151
-    /**
1152
-     * @deprecated 4.9.27
1153
-     * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1154
-     * @param string $pan_message  the message to be stored persistently until dismissed
1155
-     * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1156
-     * @return void
1157
-     * @throws InvalidDataTypeException
1158
-     */
1159
-    public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1160
-    {
1161
-        new PersistentAdminNotice(
1162
-            $pan_name,
1163
-            $pan_message,
1164
-            $force_update
1165
-        );
1166
-        EE_Error::doing_it_wrong(
1167
-            __METHOD__,
1168
-            sprintf(
1169
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1170
-                '\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1171
-            ),
1172
-            '4.9.27'
1173
-        );
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     * @deprecated 4.9.27
1179
-     * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1180
-     * @param bool   $purge
1181
-     * @param bool   $return
1182
-     * @throws DomainException
1183
-     * @throws InvalidInterfaceException
1184
-     * @throws InvalidDataTypeException
1185
-     * @throws ServiceNotFoundException
1186
-     * @throws InvalidArgumentException
1187
-     */
1188
-    public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1189
-    {
1190
-        /** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1191
-        $persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1192
-            'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1193
-        );
1194
-        $persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1195
-        EE_Error::doing_it_wrong(
1196
-            __METHOD__,
1197
-            sprintf(
1198
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1199
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1200
-            ),
1201
-            '4.9.27'
1202
-        );
1203
-    }
1204
-
1205
-
1206
-    /**
1207
-     * @deprecated 4.9.27
1208
-     * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1209
-     * @param  string $pan_message the message to be stored persistently until dismissed
1210
-     * @param  string $return_url  URL to go back to after nag notice is dismissed
1211
-     */
1212
-    public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1213
-    {
1214
-        EE_Error::doing_it_wrong(
1215
-            __METHOD__,
1216
-            sprintf(
1217
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1218
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1219
-            ),
1220
-            '4.9.27'
1221
-        );
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * @deprecated 4.9.27
1227
-     * @param string $return_url
1228
-     */
1229
-    public static function get_persistent_admin_notices($return_url = '')
1230
-    {
1231
-        EE_Error::doing_it_wrong(
1232
-            __METHOD__,
1233
-            sprintf(
1234
-                __('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1235
-                '\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1236
-            ),
1237
-            '4.9.27'
1238
-        );
1239
-    }
1025
+		}
1026
+		return '';
1027
+	}
1028
+
1029
+
1030
+	/**
1031
+	 * @return void
1032
+	 */
1033
+	public static function enqueue_error_scripts()
1034
+	{
1035
+		self::_print_scripts();
1036
+	}
1037
+
1038
+
1039
+	/**
1040
+	 * create error code from filepath, function name,
1041
+	 * and line number where exception or error was thrown
1042
+	 *
1043
+	 * @param string $file
1044
+	 * @param string $func
1045
+	 * @param string $line
1046
+	 * @return string
1047
+	 */
1048
+	public static function generate_error_code($file = '', $func = '', $line = '')
1049
+	{
1050
+		$file = explode('.', basename($file));
1051
+		$error_code = ! empty($file[0]) ? $file[0] : '';
1052
+		$error_code .= ! empty($func) ? ' - ' . $func : '';
1053
+		$error_code .= ! empty($line) ? ' - ' . $line : '';
1054
+		return $error_code;
1055
+	}
1056
+
1057
+
1058
+	/**
1059
+	 * write exception details to log file
1060
+	 * Since 4.9.53.rc.006 this writes to the standard PHP log file, not EE's custom log file
1061
+	 *
1062
+	 * @param int   $time
1063
+	 * @param array $ex
1064
+	 * @param bool  $clear
1065
+	 * @return void
1066
+	 */
1067
+	public function write_to_error_log($time = 0, $ex = array(), $clear = false)
1068
+	{
1069
+		if (empty($ex)) {
1070
+			return;
1071
+		}
1072
+		if (! $time) {
1073
+			$time = time();
1074
+		}
1075
+		$exception_log = '----------------------------------------------------------------------------------------'
1076
+						 . PHP_EOL;
1077
+		$exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1078
+		$exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1079
+		$exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1080
+		$exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1081
+		$exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1082
+		$exception_log .= 'Stack trace: ' . PHP_EOL;
1083
+		$exception_log .= $ex['string'] . PHP_EOL;
1084
+		$exception_log .= '----------------------------------------------------------------------------------------'
1085
+						  . PHP_EOL;
1086
+		try {
1087
+			error_log($exception_log);
1088
+		} catch (EE_Error $e) {
1089
+			EE_Error::add_error(
1090
+				sprintf(
1091
+					__(
1092
+						'Event Espresso error logging could not be setup because: %s',
1093
+						'event_espresso'
1094
+					),
1095
+					$e->getMessage()
1096
+				)
1097
+			);
1098
+		}
1099
+	}
1100
+
1101
+
1102
+	/**
1103
+	 * This is just a wrapper for the EEH_Debug_Tools::instance()->doing_it_wrong() method.
1104
+	 * doing_it_wrong() is used in those cases where a normal PHP error won't get thrown,
1105
+	 * but the code execution is done in a manner that could lead to unexpected results
1106
+	 * (i.e. running to early, or too late in WP or EE loading process).
1107
+	 * A good test for knowing whether to use this method is:
1108
+	 * 1. Is there going to be a PHP error if something isn't setup/used correctly?
1109
+	 * Yes -> use EE_Error::add_error() or throw new EE_Error()
1110
+	 * 2. If this is loaded before something else, it won't break anything,
1111
+	 * but just wont' do what its supposed to do? Yes -> use EE_Error::doing_it_wrong()
1112
+	 *
1113
+	 * @uses   constant WP_DEBUG test if wp_debug is on or not
1114
+	 * @param string $function      The function that was called
1115
+	 * @param string $message       A message explaining what has been done incorrectly
1116
+	 * @param string $version       The version of Event Espresso where the error was added
1117
+	 * @param string $applies_when  a version string for when you want the doing_it_wrong notice to begin appearing
1118
+	 *                              for a deprecated function. This allows deprecation to occur during one version,
1119
+	 *                              but not have any notices appear until a later version. This allows developers
1120
+	 *                              extra time to update their code before notices appear.
1121
+	 * @param int    $error_type
1122
+	 */
1123
+	public static function doing_it_wrong(
1124
+		$function,
1125
+		$message,
1126
+		$version,
1127
+		$applies_when = '',
1128
+		$error_type = null
1129
+	) {
1130
+		if (defined('WP_DEBUG') && WP_DEBUG) {
1131
+			EEH_Debug_Tools::instance()->doing_it_wrong($function, $message, $version, $applies_when, $error_type);
1132
+		}
1133
+	}
1134
+
1135
+
1136
+	/**
1137
+	 * Like get_notices, but returns an array of all the notices of the given type.
1138
+	 *
1139
+	 * @return array {
1140
+	 * @type array $success   all the success messages
1141
+	 * @type array $errors    all the error messages
1142
+	 * @type array $attention all the attention messages
1143
+	 * }
1144
+	 */
1145
+	public static function get_raw_notices()
1146
+	{
1147
+		return self::$_espresso_notices;
1148
+	}
1149
+
1150
+
1151
+	/**
1152
+	 * @deprecated 4.9.27
1153
+	 * @param string $pan_name     the name, or key of the Persistent Admin Notice to be stored
1154
+	 * @param string $pan_message  the message to be stored persistently until dismissed
1155
+	 * @param bool   $force_update allows one to enforce the reappearance of a persistent message.
1156
+	 * @return void
1157
+	 * @throws InvalidDataTypeException
1158
+	 */
1159
+	public static function add_persistent_admin_notice($pan_name = '', $pan_message, $force_update = false)
1160
+	{
1161
+		new PersistentAdminNotice(
1162
+			$pan_name,
1163
+			$pan_message,
1164
+			$force_update
1165
+		);
1166
+		EE_Error::doing_it_wrong(
1167
+			__METHOD__,
1168
+			sprintf(
1169
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1170
+				'\EventEspresso\core\domain\entities\notifications\PersistentAdminNotice'
1171
+			),
1172
+			'4.9.27'
1173
+		);
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 * @deprecated 4.9.27
1179
+	 * @param string $pan_name the name, or key of the Persistent Admin Notice to be dismissed
1180
+	 * @param bool   $purge
1181
+	 * @param bool   $return
1182
+	 * @throws DomainException
1183
+	 * @throws InvalidInterfaceException
1184
+	 * @throws InvalidDataTypeException
1185
+	 * @throws ServiceNotFoundException
1186
+	 * @throws InvalidArgumentException
1187
+	 */
1188
+	public static function dismiss_persistent_admin_notice($pan_name = '', $purge = false, $return = false)
1189
+	{
1190
+		/** @var PersistentAdminNoticeManager $persistent_admin_notice_manager */
1191
+		$persistent_admin_notice_manager = LoaderFactory::getLoader()->getShared(
1192
+			'EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1193
+		);
1194
+		$persistent_admin_notice_manager->dismissNotice($pan_name, $purge, $return);
1195
+		EE_Error::doing_it_wrong(
1196
+			__METHOD__,
1197
+			sprintf(
1198
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1199
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1200
+			),
1201
+			'4.9.27'
1202
+		);
1203
+	}
1204
+
1205
+
1206
+	/**
1207
+	 * @deprecated 4.9.27
1208
+	 * @param  string $pan_name    the name, or key of the Persistent Admin Notice to be stored
1209
+	 * @param  string $pan_message the message to be stored persistently until dismissed
1210
+	 * @param  string $return_url  URL to go back to after nag notice is dismissed
1211
+	 */
1212
+	public static function display_persistent_admin_notices($pan_name = '', $pan_message = '', $return_url = '')
1213
+	{
1214
+		EE_Error::doing_it_wrong(
1215
+			__METHOD__,
1216
+			sprintf(
1217
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1218
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1219
+			),
1220
+			'4.9.27'
1221
+		);
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * @deprecated 4.9.27
1227
+	 * @param string $return_url
1228
+	 */
1229
+	public static function get_persistent_admin_notices($return_url = '')
1230
+	{
1231
+		EE_Error::doing_it_wrong(
1232
+			__METHOD__,
1233
+			sprintf(
1234
+				__('Usage is deprecated. Use "%1$s" instead.', 'event_espresso'),
1235
+				'\EventEspresso\core\services\notifications\PersistentAdminNoticeManager'
1236
+			),
1237
+			'4.9.27'
1238
+		);
1239
+	}
1240 1240
 }
1241 1241
 
1242 1242
 // end of Class EE_Exceptions
@@ -1249,29 +1249,29 @@  discard block
 block discarded – undo
1249 1249
  */
1250 1250
 function espresso_error_enqueue_scripts()
1251 1251
 {
1252
-    // js for error handling
1253
-    if (! wp_script_is('espresso_core', 'registered')) {
1254
-        wp_register_script(
1255
-            'espresso_core',
1256
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1257
-            ['jquery'],
1258
-            EVENT_ESPRESSO_VERSION,
1259
-            false
1260
-        );
1261
-    }
1262
-    wp_register_script(
1263
-        'ee_error_js',
1264
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1265
-        array('espresso_core'),
1266
-        EVENT_ESPRESSO_VERSION,
1267
-        false
1268
-    );
1252
+	// js for error handling
1253
+	if (! wp_script_is('espresso_core', 'registered')) {
1254
+		wp_register_script(
1255
+			'espresso_core',
1256
+			EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1257
+			['jquery'],
1258
+			EVENT_ESPRESSO_VERSION,
1259
+			false
1260
+		);
1261
+	}
1262
+	wp_register_script(
1263
+		'ee_error_js',
1264
+		EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1265
+		array('espresso_core'),
1266
+		EVENT_ESPRESSO_VERSION,
1267
+		false
1268
+	);
1269 1269
 }
1270 1270
 
1271 1271
 if (is_admin()) {
1272
-    add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1272
+	add_action('admin_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1273 1273
 } else {
1274
-    add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1274
+	add_action('wp_enqueue_scripts', 'espresso_error_enqueue_scripts', 5);
1275 1275
 }
1276 1276
 
1277 1277
 
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -99,14 +99,14 @@  discard block
 block discarded – undo
99 99
             default:
100 100
                 $to = get_option('admin_email');
101 101
         }
102
-        $subject = $type . ' ' . $message . ' in ' . EVENT_ESPRESSO_VERSION . ' on ' . site_url();
102
+        $subject = $type.' '.$message.' in '.EVENT_ESPRESSO_VERSION.' on '.site_url();
103 103
         $msg = EE_Error::_format_error($type, $message, $file, $line);
104 104
         if (function_exists('wp_mail')) {
105 105
             add_filter('wp_mail_content_type', array('EE_Error', 'set_content_type'));
106 106
             wp_mail($to, $subject, $msg);
107 107
         }
108 108
         echo '<div id="message" class="espresso-notices error"><p>';
109
-        echo $type . ': ' . $message . '<br />' . $file . ' line ' . $line;
109
+        echo $type.': '.$message.'<br />'.$file.' line '.$line;
110 110
         echo '<br /></p></div>';
111 111
     }
112 112
 
@@ -222,13 +222,13 @@  discard block
 block discarded – undo
222 222
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
223 223
         // add details to _all_exceptions array
224 224
         $x_time = time();
225
-        self::$_all_exceptions[ $x_time ]['name'] = get_class($this);
226
-        self::$_all_exceptions[ $x_time ]['file'] = $this->getFile();
227
-        self::$_all_exceptions[ $x_time ]['line'] = $this->getLine();
228
-        self::$_all_exceptions[ $x_time ]['msg'] = $msg;
229
-        self::$_all_exceptions[ $x_time ]['code'] = $this->getCode();
230
-        self::$_all_exceptions[ $x_time ]['trace'] = $this->getTrace();
231
-        self::$_all_exceptions[ $x_time ]['string'] = $this->getTraceAsString();
225
+        self::$_all_exceptions[$x_time]['name'] = get_class($this);
226
+        self::$_all_exceptions[$x_time]['file'] = $this->getFile();
227
+        self::$_all_exceptions[$x_time]['line'] = $this->getLine();
228
+        self::$_all_exceptions[$x_time]['msg'] = $msg;
229
+        self::$_all_exceptions[$x_time]['code'] = $this->getCode();
230
+        self::$_all_exceptions[$x_time]['trace'] = $this->getTrace();
231
+        self::$_all_exceptions[$x_time]['string'] = $this->getTraceAsString();
232 232
         self::$_error_count++;
233 233
         // add_action( 'shutdown', array( $this, 'display_errors' ));
234 234
         $this->display_errors();
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
      */
247 247
     public static function has_error($check_stored = false, $type_to_check = 'errors')
248 248
     {
249
-        $has_error = isset(self::$_espresso_notices[ $type_to_check ])
250
-                     && ! empty(self::$_espresso_notices[ $type_to_check ])
249
+        $has_error = isset(self::$_espresso_notices[$type_to_check])
250
+                     && ! empty(self::$_espresso_notices[$type_to_check])
251 251
             ? true
252 252
             : false;
253 253
         if ($check_stored && ! $has_error) {
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	}
326 326
 </style>
327 327
 <div id="ee-error-message" class="error">';
328
-        if (! WP_DEBUG) {
328
+        if ( ! WP_DEBUG) {
329 329
             $output .= '
330 330
 	<p>';
331 331
         }
@@ -384,14 +384,14 @@  discard block
 block discarded – undo
384 384
                     $class_dsply = ! empty($class) ? $class : '&nbsp;';
385 385
                     $type_dsply = ! empty($type) ? $type : '&nbsp;';
386 386
                     $function_dsply = ! empty($function) ? $function : '&nbsp;';
387
-                    $args_dsply = ! empty($args) ? '( ' . $args . ' )' : '';
387
+                    $args_dsply = ! empty($args) ? '( '.$args.' )' : '';
388 388
                     $trace_details .= '
389 389
 					<tr>
390
-						<td align="right" class="' . $zebra . '">' . $nmbr_dsply . '</td>
391
-						<td align="right" class="' . $zebra . '">' . $line_dsply . '</td>
392
-						<td align="left" class="' . $zebra . '">' . $file_dsply . '</td>
393
-						<td align="left" class="' . $zebra . '">' . $class_dsply . '</td>
394
-						<td align="left" class="' . $zebra . '">' . $type_dsply . $function_dsply . $args_dsply . '</td>
390
+						<td align="right" class="' . $zebra.'">'.$nmbr_dsply.'</td>
391
+						<td align="right" class="' . $zebra.'">'.$line_dsply.'</td>
392
+						<td align="left" class="' . $zebra.'">'.$file_dsply.'</td>
393
+						<td align="left" class="' . $zebra.'">'.$class_dsply.'</td>
394
+						<td align="left" class="' . $zebra.'">'.$type_dsply.$function_dsply.$args_dsply.'</td>
395 395
 					</tr>';
396 396
                 }
397 397
                 $trace_details .= '
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
             }
401 401
             $ex['code'] = $ex['code'] ? $ex['code'] : $error_code;
402 402
             // add generic non-identifying messages for non-privileged users
403
-            if (! WP_DEBUG) {
403
+            if ( ! WP_DEBUG) {
404 404
                 $output .= '<span class="ee-error-user-msg-spn">'
405 405
                            . trim($ex['msg'])
406 406
                            . '</span> &nbsp; <sup>'
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
                            . '-dv" class="ee-error-trace-dv" style="display: none;">
443 443
 				'
444 444
                            . $trace_details;
445
-                if (! empty($class)) {
445
+                if ( ! empty($class)) {
446 446
                     $output .= '
447 447
 				<div style="padding:3px; margin:0 0 1em; border:1px solid #666; background:#fff; border-radius:3px;">
448 448
 					<div style="padding:1em 2em; border:1px solid #666; background:#f9f9f9;">
449 449
 						<h3>Class Details</h3>';
450 450
                     $a = new ReflectionClass($class);
451 451
                     $output .= '
452
-						<pre>' . $a . '</pre>
452
+						<pre>' . $a.'</pre>
453 453
 					</div>
454 454
 				</div>';
455 455
                 }
@@ -462,7 +462,7 @@  discard block
 block discarded – undo
462 462
         }
463 463
         // remove last linebreak
464 464
         $output = substr($output, 0, -6);
465
-        if (! WP_DEBUG) {
465
+        if ( ! WP_DEBUG) {
466 466
             $output .= '
467 467
 	</p>';
468 468
         }
@@ -488,20 +488,20 @@  discard block
 block discarded – undo
488 488
     private function _convert_args_to_string($arguments = array(), $array = false)
489 489
     {
490 490
         $arg_string = '';
491
-        if (! empty($arguments)) {
491
+        if ( ! empty($arguments)) {
492 492
             $args = array();
493 493
             foreach ($arguments as $arg) {
494
-                if (! empty($arg)) {
494
+                if ( ! empty($arg)) {
495 495
                     if (is_string($arg)) {
496
-                        $args[] = " '" . $arg . "'";
496
+                        $args[] = " '".$arg."'";
497 497
                     } elseif (is_array($arg)) {
498
-                        $args[] = 'ARRAY(' . $this->_convert_args_to_string($arg, true);
498
+                        $args[] = 'ARRAY('.$this->_convert_args_to_string($arg, true);
499 499
                     } elseif ($arg === null) {
500 500
                         $args[] = ' NULL';
501 501
                     } elseif (is_bool($arg)) {
502 502
                         $args[] = ($arg) ? ' TRUE' : ' FALSE';
503 503
                     } elseif (is_object($arg)) {
504
-                        $args[] = ' OBJECT ' . get_class($arg);
504
+                        $args[] = ' OBJECT '.get_class($arg);
505 505
                     } elseif (is_resource($arg)) {
506 506
                         $args[] = get_resource_type($arg);
507 507
                     } else {
@@ -599,7 +599,7 @@  discard block
 block discarded – undo
599 599
     {
600 600
         if (empty($msg)) {
601 601
             EE_Error::doing_it_wrong(
602
-                'EE_Error::add_' . $type . '()',
602
+                'EE_Error::add_'.$type.'()',
603 603
                 sprintf(
604 604
                     __(
605 605
                         'Notifications are not much use without a message! Please add a message to the EE_Error::add_%s() call made in %s on line %d',
@@ -639,17 +639,17 @@  discard block
 block discarded – undo
639 639
         do_action('AHEE__EE_Error___add_notice', $type, $user_msg, $dev_msg, $file, $func, $line);
640 640
         $msg = WP_DEBUG ? $dev_msg : $user_msg;
641 641
         // add notice if message exists
642
-        if (! empty($msg)) {
642
+        if ( ! empty($msg)) {
643 643
             // get error code
644 644
             $notice_code = EE_Error::generate_error_code($file, $func, $line);
645 645
             if (WP_DEBUG && $type === 'errors') {
646
-                $msg .= '<br/><span class="tiny-text">' . $notice_code . '</span>';
646
+                $msg .= '<br/><span class="tiny-text">'.$notice_code.'</span>';
647 647
             }
648 648
             // add notice. Index by code if it's not blank
649 649
             if ($notice_code) {
650
-                self::$_espresso_notices[ $type ][ $notice_code ] = $msg;
650
+                self::$_espresso_notices[$type][$notice_code] = $msg;
651 651
             } else {
652
-                self::$_espresso_notices[ $type ][] = $msg;
652
+                self::$_espresso_notices[$type][] = $msg;
653 653
             }
654 654
             add_action('wp_footer', array('EE_Error', 'enqueue_error_scripts'), 1);
655 655
         }
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
                 // remove empty notices
901 901
                 foreach ($notices as $type => $notice) {
902 902
                     if (empty($notice)) {
903
-                        unset($notices[ $type ]);
903
+                        unset($notices[$type]);
904 904
                     }
905 905
                 }
906 906
             }
@@ -923,16 +923,16 @@  discard block
 block discarded – undo
923 923
         $print_scripts = false;
924 924
         // grab any notices that have been previously saved
925 925
         $notices = EE_Error::getStoredNotices();
926
-        if (! empty($notices)) {
926
+        if ( ! empty($notices)) {
927 927
             foreach ($notices as $type => $notice) {
928 928
                 if (is_array($notice) && ! empty($notice)) {
929 929
                     // make sure that existing notice type is an array
930
-                    self::$_espresso_notices[ $type ] = is_array(self::$_espresso_notices[ $type ])
931
-                                                        && ! empty(self::$_espresso_notices[ $type ])
932
-                        ? self::$_espresso_notices[ $type ]
930
+                    self::$_espresso_notices[$type] = is_array(self::$_espresso_notices[$type])
931
+                                                        && ! empty(self::$_espresso_notices[$type])
932
+                        ? self::$_espresso_notices[$type]
933 933
                         : array();
934 934
                     // add newly created notices to existing ones
935
-                    self::$_espresso_notices[ $type ] += $notice;
935
+                    self::$_espresso_notices[$type] += $notice;
936 936
                     $print_scripts = true;
937 937
                 }
938 938
             }
@@ -959,10 +959,10 @@  discard block
 block discarded – undo
959 959
             $css_id = is_admin() ? 'ee-success-message' : 'espresso-notices-success';
960 960
             $css_class = is_admin() ? 'updated fade' : 'success fade-away';
961 961
             // showMessage( $success_messages );
962
-            $notices .= '<div id="' . $css_id . '" '
963
-                        . 'class="espresso-notices ' . $css_class . '" '
962
+            $notices .= '<div id="'.$css_id.'" '
963
+                        . 'class="espresso-notices '.$css_class.'" '
964 964
                         . 'style="display:none;">'
965
-                        . '<p>' . $success_messages . '</p>'
965
+                        . '<p>'.$success_messages.'</p>'
966 966
                         . $close
967 967
                         . '</div>';
968 968
         }
@@ -970,10 +970,10 @@  discard block
 block discarded – undo
970 970
             $css_id = is_admin() ? 'ee-attention-message' : 'espresso-notices-attention';
971 971
             $css_class = is_admin() ? 'updated ee-notices-attention' : 'attention fade-away';
972 972
             // showMessage( $error_messages, TRUE );
973
-            $notices .= '<div id="' . $css_id . '" '
974
-                        . 'class="espresso-notices ' . $css_class . '" '
973
+            $notices .= '<div id="'.$css_id.'" '
974
+                        . 'class="espresso-notices '.$css_class.'" '
975 975
                         . 'style="display:none;">'
976
-                        . '<p>' . $attention_messages . '</p>'
976
+                        . '<p>'.$attention_messages.'</p>'
977 977
                         . $close
978 978
                         . '</div>';
979 979
         }
@@ -981,10 +981,10 @@  discard block
 block discarded – undo
981 981
             $css_id = is_admin() ? 'ee-error-message' : 'espresso-notices-error';
982 982
             $css_class = is_admin() ? 'error' : 'error fade-away';
983 983
             // showMessage( $error_messages, TRUE );
984
-            $notices .= '<div id="' . $css_id . '" '
985
-                        . 'class="espresso-notices ' . $css_class . '" '
984
+            $notices .= '<div id="'.$css_id.'" '
985
+                        . 'class="espresso-notices '.$css_class.'" '
986 986
                         . 'style="display:none;">'
987
-                        . '<p>' . $error_messages . '</p>'
987
+                        . '<p>'.$error_messages.'</p>'
988 988
                         . $close
989 989
                         . '</div>';
990 990
         }
@@ -1001,7 +1001,7 @@  discard block
 block discarded – undo
1001 1001
      */
1002 1002
     private static function _print_scripts($force_print = false)
1003 1003
     {
1004
-        if (! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1004
+        if ( ! $force_print && (did_action('admin_enqueue_scripts') || did_action('wp_enqueue_scripts'))) {
1005 1005
             if (wp_script_is('ee_error_js', 'registered')) {
1006 1006
                 wp_enqueue_style('espresso_default');
1007 1007
                 wp_enqueue_style('espresso_custom_css');
@@ -1015,12 +1015,12 @@  discard block
 block discarded – undo
1015 1015
             return '
1016 1016
 <script>
1017 1017
 /* <![CDATA[ */
1018
-var ee_settings = {"wp_debug":"' . WP_DEBUG . '"};
1018
+var ee_settings = {"wp_debug":"' . WP_DEBUG.'"};
1019 1019
 /* ]]> */
1020 1020
 </script>
1021
-<script src="' . includes_url() . 'js/jquery/jquery.js" type="text/javascript"></script>
1022
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1023
-<script src="' . EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js' . '?ver=' . espresso_version() . '" type="text/javascript"></script>
1021
+<script src="' . includes_url().'js/jquery/jquery.js" type="text/javascript"></script>
1022
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1023
+<script src="' . EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js'.'?ver='.espresso_version().'" type="text/javascript"></script>
1024 1024
 ';
1025 1025
         }
1026 1026
         return '';
@@ -1049,8 +1049,8 @@  discard block
 block discarded – undo
1049 1049
     {
1050 1050
         $file = explode('.', basename($file));
1051 1051
         $error_code = ! empty($file[0]) ? $file[0] : '';
1052
-        $error_code .= ! empty($func) ? ' - ' . $func : '';
1053
-        $error_code .= ! empty($line) ? ' - ' . $line : '';
1052
+        $error_code .= ! empty($func) ? ' - '.$func : '';
1053
+        $error_code .= ! empty($line) ? ' - '.$line : '';
1054 1054
         return $error_code;
1055 1055
     }
1056 1056
 
@@ -1069,18 +1069,18 @@  discard block
 block discarded – undo
1069 1069
         if (empty($ex)) {
1070 1070
             return;
1071 1071
         }
1072
-        if (! $time) {
1072
+        if ( ! $time) {
1073 1073
             $time = time();
1074 1074
         }
1075 1075
         $exception_log = '----------------------------------------------------------------------------------------'
1076 1076
                          . PHP_EOL;
1077
-        $exception_log .= '[' . date('Y-m-d H:i:s', $time) . ']  Exception Details' . PHP_EOL;
1078
-        $exception_log .= 'Message: ' . $ex['msg'] . PHP_EOL;
1079
-        $exception_log .= 'Code: ' . $ex['code'] . PHP_EOL;
1080
-        $exception_log .= 'File: ' . $ex['file'] . PHP_EOL;
1081
-        $exception_log .= 'Line No: ' . $ex['line'] . PHP_EOL;
1082
-        $exception_log .= 'Stack trace: ' . PHP_EOL;
1083
-        $exception_log .= $ex['string'] . PHP_EOL;
1077
+        $exception_log .= '['.date('Y-m-d H:i:s', $time).']  Exception Details'.PHP_EOL;
1078
+        $exception_log .= 'Message: '.$ex['msg'].PHP_EOL;
1079
+        $exception_log .= 'Code: '.$ex['code'].PHP_EOL;
1080
+        $exception_log .= 'File: '.$ex['file'].PHP_EOL;
1081
+        $exception_log .= 'Line No: '.$ex['line'].PHP_EOL;
1082
+        $exception_log .= 'Stack trace: '.PHP_EOL;
1083
+        $exception_log .= $ex['string'].PHP_EOL;
1084 1084
         $exception_log .= '----------------------------------------------------------------------------------------'
1085 1085
                           . PHP_EOL;
1086 1086
         try {
@@ -1250,10 +1250,10 @@  discard block
 block discarded – undo
1250 1250
 function espresso_error_enqueue_scripts()
1251 1251
 {
1252 1252
     // js for error handling
1253
-    if (! wp_script_is('espresso_core', 'registered')) {
1253
+    if ( ! wp_script_is('espresso_core', 'registered')) {
1254 1254
         wp_register_script(
1255 1255
             'espresso_core',
1256
-            EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js',
1256
+            EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js',
1257 1257
             ['jquery'],
1258 1258
             EVENT_ESPRESSO_VERSION,
1259 1259
             false
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
     }
1262 1262
     wp_register_script(
1263 1263
         'ee_error_js',
1264
-        EE_GLOBAL_ASSETS_URL . 'scripts/EE_Error.js',
1264
+        EE_GLOBAL_ASSETS_URL.'scripts/EE_Error.js',
1265 1265
         array('espresso_core'),
1266 1266
         EVENT_ESPRESSO_VERSION,
1267 1267
         false
Please login to merge, or discard this patch.