Completed
Branch EDTR/master (83b47e)
by
unknown
25:37 queued 16:41
created
core/domain/entities/routing/handlers/admin/EspressoEventEditor.php 1 patch
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -19,120 +19,120 @@
 block discarded – undo
19 19
 class EspressoEventEditor extends EspressoEventsAdmin
20 20
 {
21 21
 
22
-    /**
23
-     * returns true if the current request matches this route
24
-     *
25
-     * @return bool
26
-     * @since   $VID:$
27
-     */
28
-    public function matchesCurrentRequest()
29
-    {
30
-        global $pagenow;
31
-        return parent::matchesCurrentRequest()
32
-               && $pagenow
33
-               && $pagenow === 'admin.php'
34
-               && $this->admin_config->useAdvancedEditor()
35
-               && $this->request->getRequestParam('page') === 'espresso_events'
36
-               && (
37
-                $this->request->getRequestParam('action') === 'create_new'
38
-                || $this->request->getRequestParam('action') === 'edit'
39
-            );
40
-    }
22
+	/**
23
+	 * returns true if the current request matches this route
24
+	 *
25
+	 * @return bool
26
+	 * @since   $VID:$
27
+	 */
28
+	public function matchesCurrentRequest()
29
+	{
30
+		global $pagenow;
31
+		return parent::matchesCurrentRequest()
32
+			   && $pagenow
33
+			   && $pagenow === 'admin.php'
34
+			   && $this->admin_config->useAdvancedEditor()
35
+			   && $this->request->getRequestParam('page') === 'espresso_events'
36
+			   && (
37
+				$this->request->getRequestParam('action') === 'create_new'
38
+				|| $this->request->getRequestParam('action') === 'edit'
39
+			);
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @since $VID:$
45
-     */
46
-    protected function registerDependencies()
47
-    {
48
-        $this->dependency_map->registerDependencies(
49
-            'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData',
50
-            [
51
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes'                 => EE_Dependency_Map::load_from_cache,
52
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Prices'                    => EE_Dependency_Map::load_from_cache,
53
-                'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes'                => EE_Dependency_Map::load_from_cache,
54
-                'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets'                   => EE_Dependency_Map::load_from_cache,
55
-                'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache,
56
-                'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations'    => EE_Dependency_Map::load_from_cache,
57
-            ]
58
-        );
59
-        $this->dependency_map->registerDependencies(
60
-            'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations',
61
-            [
62
-                'EEM_Datetime'   => EE_Dependency_Map::load_from_cache,
63
-                'EEM_Event'      => EE_Dependency_Map::load_from_cache,
64
-                'EEM_Price'      => EE_Dependency_Map::load_from_cache,
65
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
66
-                'EEM_Ticket'     => EE_Dependency_Map::load_from_cache,
67
-            ]
68
-        );
69
-        $this->dependency_map->registerDependencies(
70
-            'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities',
71
-            [
72
-                'EEM_Datetime'                                                       => EE_Dependency_Map::load_from_cache,
73
-                'EEM_Event'                                                          => EE_Dependency_Map::load_from_cache,
74
-                'EEM_Price'                                                          => EE_Dependency_Map::load_from_cache,
75
-                'EEM_Price_Type'                                                     => EE_Dependency_Map::load_from_cache,
76
-                'EEM_Ticket'                                                         => EE_Dependency_Map::load_from_cache,
77
-                'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache,
78
-            ]
79
-        );
80
-        $this->dependency_map->registerDependencies(
81
-            'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes',
82
-            [
83
-                'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache,
84
-                'EEM_Datetime'                                                     => EE_Dependency_Map::load_from_cache,
85
-            ]
86
-        );
87
-        $this->dependency_map->registerDependencies(
88
-            'EventEspresso\core\domain\services\admin\entities\DefaultTickets',
89
-            [
90
-                'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache,
91
-                'EEM_Ticket'                                                      => EE_Dependency_Map::load_from_cache,
92
-            ]
93
-        );
94
-        $this->dependency_map->registerDependencies(
95
-            'EventEspresso\core\domain\services\admin\entities\DefaultPrices',
96
-            [
97
-                'EEM_Price'      => EE_Dependency_Map::load_from_cache,
98
-                'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
99
-            ]
100
-        );
101
-        $this->dependency_map->registerDependencies(
102
-            'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor',
103
-            [
104
-                'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache,
105
-                'EventEspresso\core\services\json\JsonDataNodeValidator'                        => EE_Dependency_Map::load_from_cache,
106
-            ]
107
-        );
108
-        /** @var EventEspressoData $primary_data_node */
109
-        $primary_data_node = $this->loader->getShared(
110
-            'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData'
111
-        );
112
-        $primary_data_node->setTargetScript(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR);
113
-        /** @var EventEditor $data_node */
114
-        $data_node = $this->loader->getShared(
115
-            'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor'
116
-        );
117
-        $this->setDataNode($data_node);
118
-    }
43
+	/**
44
+	 * @since $VID:$
45
+	 */
46
+	protected function registerDependencies()
47
+	{
48
+		$this->dependency_map->registerDependencies(
49
+			'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData',
50
+			[
51
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Datetimes'                 => EE_Dependency_Map::load_from_cache,
52
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Prices'                    => EE_Dependency_Map::load_from_cache,
53
+				'EventEspresso\core\domain\entities\admin\GraphQLData\PriceTypes'                => EE_Dependency_Map::load_from_cache,
54
+				'EventEspresso\core\domain\entities\admin\GraphQLData\Tickets'                   => EE_Dependency_Map::load_from_cache,
55
+				'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities' => EE_Dependency_Map::load_from_cache,
56
+				'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations'    => EE_Dependency_Map::load_from_cache,
57
+			]
58
+		);
59
+		$this->dependency_map->registerDependencies(
60
+			'EventEspresso\core\domain\services\admin\events\editor\EventEntityRelations',
61
+			[
62
+				'EEM_Datetime'   => EE_Dependency_Map::load_from_cache,
63
+				'EEM_Event'      => EE_Dependency_Map::load_from_cache,
64
+				'EEM_Price'      => EE_Dependency_Map::load_from_cache,
65
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
66
+				'EEM_Ticket'     => EE_Dependency_Map::load_from_cache,
67
+			]
68
+		);
69
+		$this->dependency_map->registerDependencies(
70
+			'EventEspresso\core\domain\services\admin\events\editor\NewEventDefaultEntities',
71
+			[
72
+				'EEM_Datetime'                                                       => EE_Dependency_Map::load_from_cache,
73
+				'EEM_Event'                                                          => EE_Dependency_Map::load_from_cache,
74
+				'EEM_Price'                                                          => EE_Dependency_Map::load_from_cache,
75
+				'EEM_Price_Type'                                                     => EE_Dependency_Map::load_from_cache,
76
+				'EEM_Ticket'                                                         => EE_Dependency_Map::load_from_cache,
77
+				'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes' => EE_Dependency_Map::load_from_cache,
78
+			]
79
+		);
80
+		$this->dependency_map->registerDependencies(
81
+			'EventEspresso\core\domain\services\admin\entities\DefaultDatetimes',
82
+			[
83
+				'EventEspresso\core\domain\services\admin\entities\DefaultTickets' => EE_Dependency_Map::load_from_cache,
84
+				'EEM_Datetime'                                                     => EE_Dependency_Map::load_from_cache,
85
+			]
86
+		);
87
+		$this->dependency_map->registerDependencies(
88
+			'EventEspresso\core\domain\services\admin\entities\DefaultTickets',
89
+			[
90
+				'EventEspresso\core\domain\services\admin\entities\DefaultPrices' => EE_Dependency_Map::load_from_cache,
91
+				'EEM_Ticket'                                                      => EE_Dependency_Map::load_from_cache,
92
+			]
93
+		);
94
+		$this->dependency_map->registerDependencies(
95
+			'EventEspresso\core\domain\services\admin\entities\DefaultPrices',
96
+			[
97
+				'EEM_Price'      => EE_Dependency_Map::load_from_cache,
98
+				'EEM_Price_Type' => EE_Dependency_Map::load_from_cache,
99
+			]
100
+		);
101
+		$this->dependency_map->registerDependencies(
102
+			'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor',
103
+			[
104
+				'EventEspresso\core\domain\services\admin\events\editor\EventEditorGraphQLData' => EE_Dependency_Map::load_from_cache,
105
+				'EventEspresso\core\services\json\JsonDataNodeValidator'                        => EE_Dependency_Map::load_from_cache,
106
+			]
107
+		);
108
+		/** @var EventEspressoData $primary_data_node */
109
+		$primary_data_node = $this->loader->getShared(
110
+			'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData'
111
+		);
112
+		$primary_data_node->setTargetScript(EspressoCoreAppAssetManager::JS_HANDLE_EDITOR);
113
+		/** @var EventEditor $data_node */
114
+		$data_node = $this->loader->getShared(
115
+			'EventEspresso\core\domain\entities\routing\data_nodes\domains\EventEditor'
116
+		);
117
+		$this->setDataNode($data_node);
118
+	}
119 119
 
120 120
 
121
-    /**
122
-     * implements logic required to run during request
123
-     *
124
-     * @return bool
125
-     * @since   $VID:$
126
-     */
127
-    protected function requestHandler()
128
-    {
129
-        /** @var GraphQLManager $graphQL_manager */
130
-        $graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager');
131
-        $graphQL_manager->init();
132
-        $this->asset_manager = $this->loader->getShared(
133
-            'EventEspresso\core\domain\services\assets\EspressoCoreAppAssetManager'
134
-        );
135
-        add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100);
136
-        return true;
137
-    }
121
+	/**
122
+	 * implements logic required to run during request
123
+	 *
124
+	 * @return bool
125
+	 * @since   $VID:$
126
+	 */
127
+	protected function requestHandler()
128
+	{
129
+		/** @var GraphQLManager $graphQL_manager */
130
+		$graphQL_manager = $this->loader->getShared('EventEspresso\core\services\graphql\GraphQLManager');
131
+		$graphQL_manager->init();
132
+		$this->asset_manager = $this->loader->getShared(
133
+			'EventEspresso\core\domain\services\assets\EspressoCoreAppAssetManager'
134
+		);
135
+		add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100);
136
+		return true;
137
+	}
138 138
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/admin/GutenbergEditor.php 1 patch
Indentation   +63 added lines, -63 removed lines patch added patch discarded remove patch
@@ -19,71 +19,71 @@
 block discarded – undo
19 19
 class GutenbergEditor extends AdminRoute
20 20
 {
21 21
 
22
-    /**
23
-     * returns true if the current request matches this route
24
-     *
25
-     * @return bool
26
-     * @since   $VID:$
27
-     */
28
-    public function matchesCurrentRequest()
29
-    {
30
-        global $pagenow;
31
-        return parent::matchesCurrentRequest()
32
-               && $pagenow
33
-               && (
34
-                   $pagenow === 'post-new.php'
35
-                   || (
36
-                       $pagenow === 'post.php'
37
-                       && $this->request->getRequestParam('action') === 'edit'
38
-                   )
39
-               );
40
-    }
22
+	/**
23
+	 * returns true if the current request matches this route
24
+	 *
25
+	 * @return bool
26
+	 * @since   $VID:$
27
+	 */
28
+	public function matchesCurrentRequest()
29
+	{
30
+		global $pagenow;
31
+		return parent::matchesCurrentRequest()
32
+			   && $pagenow
33
+			   && (
34
+				   $pagenow === 'post-new.php'
35
+				   || (
36
+					   $pagenow === 'post.php'
37
+					   && $this->request->getRequestParam('action') === 'edit'
38
+				   )
39
+			   );
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * @since $VID:$
45
-     */
46
-    protected function registerDependencies()
47
-    {
48
-        $this->dependency_map->registerDependencies(
49
-            'EventEspresso\core\domain\entities\routing\data_nodes\domains\GutenbergEditorData',
50
-            [
51
-                'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
52
-            ]
53
-        );
54
-        $this->dependency_map->registerDependencies(
55
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager',
56
-            [
57
-                'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
58
-                'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
59
-                'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
60
-            ]
61
-        );
62
-        /** @var EventEspressoData $primary_data_node */
63
-        $primary_data_node = $this->loader->getShared(
64
-            'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData'
65
-        );
66
-        $primary_data_node->setTargetScript(CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS);
67
-        /** @var EventEditor $data_node */
68
-        $data_node = $this->loader->getShared(
69
-            'EventEspresso\core\domain\entities\routing\data_nodes\domains\GutenbergEditorData'
70
-        );
71
-        $this->setDataNode($data_node);
72
-    }
43
+	/**
44
+	 * @since $VID:$
45
+	 */
46
+	protected function registerDependencies()
47
+	{
48
+		$this->dependency_map->registerDependencies(
49
+			'EventEspresso\core\domain\entities\routing\data_nodes\domains\GutenbergEditorData',
50
+			[
51
+				'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
52
+			]
53
+		);
54
+		$this->dependency_map->registerDependencies(
55
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager',
56
+			[
57
+				'EventEspresso\core\domain\Domain'                   => EE_Dependency_Map::load_from_cache,
58
+				'EventEspresso\core\services\assets\AssetCollection' => EE_Dependency_Map::load_from_cache,
59
+				'EventEspresso\core\services\assets\Registry'        => EE_Dependency_Map::load_from_cache,
60
+			]
61
+		);
62
+		/** @var EventEspressoData $primary_data_node */
63
+		$primary_data_node = $this->loader->getShared(
64
+			'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData'
65
+		);
66
+		$primary_data_node->setTargetScript(CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS);
67
+		/** @var EventEditor $data_node */
68
+		$data_node = $this->loader->getShared(
69
+			'EventEspresso\core\domain\entities\routing\data_nodes\domains\GutenbergEditorData'
70
+		);
71
+		$this->setDataNode($data_node);
72
+	}
73 73
 
74 74
 
75
-    /**
76
-     * implements logic required to run during request
77
-     *
78
-     * @return bool
79
-     * @since   $VID:$
80
-     */
81
-    protected function requestHandler()
82
-    {
83
-        $this->asset_manager = $this->loader->getShared(
84
-            'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager'
85
-        );
86
-        add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100);
87
-        return true;
88
-    }
75
+	/**
76
+	 * implements logic required to run during request
77
+	 *
78
+	 * @return bool
79
+	 * @since   $VID:$
80
+	 */
81
+	protected function requestHandler()
82
+	{
83
+		$this->asset_manager = $this->loader->getShared(
84
+			'EventEspresso\core\domain\entities\editor\CoreBlocksAssetManager'
85
+		);
86
+		add_action('admin_enqueue_scripts', [$this->asset_manager, 'enqueueBrowserAssets'], 100);
87
+		return true;
88
+	}
89 89
 }
Please login to merge, or discard this patch.
core/domain/entities/routing/handlers/shared/RoutingRequests.php 1 patch
Indentation   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -16,126 +16,126 @@
 block discarded – undo
16 16
 class RoutingRequests extends Route
17 17
 {
18 18
 
19
-    /**
20
-     * called just before matchesCurrentRequest()
21
-     * and allows Route to perform any setup required such as calling setSpecification()
22
-     *
23
-     * @since $VID:$
24
-     */
25
-    public function initialize()
26
-    {
27
-        $basic_nodes = [
28
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\Api',
29
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser',
30
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings',
31
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale',
32
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls',
33
-        ];
34
-        foreach ($basic_nodes as $basic_node) {
35
-            $this->dependency_map->registerDependencies(
36
-                $basic_node,
37
-                ['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache]
38
-            );
39
-        }
40
-        $this->dependency_map->registerDependencies(
41
-            'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData',
42
-            [
43
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\Api'    => EE_Dependency_Map::load_from_cache,
44
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache,
45
-                'EventEspresso\core\services\assets\JedLocaleData'                  => EE_Dependency_Map::load_from_cache,
46
-                'EventEspresso\core\services\json\JsonDataNodeValidator'            => EE_Dependency_Map::load_from_cache,
47
-            ]
48
-        );
49
-        $this->dependency_map->registerDependencies(
50
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\Config',
51
-            [
52
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser'        => EE_Dependency_Map::load_from_cache,
53
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache,
54
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings'    => EE_Dependency_Map::load_from_cache,
55
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale'             => EE_Dependency_Map::load_from_cache,
56
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency'       => EE_Dependency_Map::load_from_cache,
57
-                'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls'           => EE_Dependency_Map::load_from_cache,
58
-                'EventEspresso\core\services\json\JsonDataNodeValidator'                        => EE_Dependency_Map::load_from_cache,
59
-            ]
60
-        );
61
-        $this->dependency_map->registerDependencies(
62
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain',
63
-            [
64
-                'EventEspresso\core\domain\Domain'                       => EE_Dependency_Map::load_from_cache,
65
-                'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
66
-            ]
67
-        );
68
-        $this->dependency_map->registerDependencies(
69
-            'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency',
70
-            [
71
-                'EE_Currency_Config'                                     => EE_Dependency_Map::load_from_cache,
72
-                'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
73
-            ]
74
-        );
75
-        $this->setDataNode(
76
-            $this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData')
77
-        );
78
-    }
19
+	/**
20
+	 * called just before matchesCurrentRequest()
21
+	 * and allows Route to perform any setup required such as calling setSpecification()
22
+	 *
23
+	 * @since $VID:$
24
+	 */
25
+	public function initialize()
26
+	{
27
+		$basic_nodes = [
28
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\Api',
29
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser',
30
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings',
31
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale',
32
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls',
33
+		];
34
+		foreach ($basic_nodes as $basic_node) {
35
+			$this->dependency_map->registerDependencies(
36
+				$basic_node,
37
+				['EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache]
38
+			);
39
+		}
40
+		$this->dependency_map->registerDependencies(
41
+			'EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData',
42
+			[
43
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\Api'    => EE_Dependency_Map::load_from_cache,
44
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\Config' => EE_Dependency_Map::load_from_cache,
45
+				'EventEspresso\core\services\assets\JedLocaleData'                  => EE_Dependency_Map::load_from_cache,
46
+				'EventEspresso\core\services\json\JsonDataNodeValidator'            => EE_Dependency_Map::load_from_cache,
47
+			]
48
+		);
49
+		$this->dependency_map->registerDependencies(
50
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\Config',
51
+			[
52
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\CurrentUser'        => EE_Dependency_Map::load_from_cache,
53
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain' => EE_Dependency_Map::load_from_cache,
54
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\GeneralSettings'    => EE_Dependency_Map::load_from_cache,
55
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\Locale'             => EE_Dependency_Map::load_from_cache,
56
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency'       => EE_Dependency_Map::load_from_cache,
57
+				'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteUrls'           => EE_Dependency_Map::load_from_cache,
58
+				'EventEspresso\core\services\json\JsonDataNodeValidator'                        => EE_Dependency_Map::load_from_cache,
59
+			]
60
+		);
61
+		$this->dependency_map->registerDependencies(
62
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\EspressoCoreDomain',
63
+			[
64
+				'EventEspresso\core\domain\Domain'                       => EE_Dependency_Map::load_from_cache,
65
+				'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
66
+			]
67
+		);
68
+		$this->dependency_map->registerDependencies(
69
+			'EventEspresso\core\domain\entities\routing\data_nodes\core\SiteCurrency',
70
+			[
71
+				'EE_Currency_Config'                                     => EE_Dependency_Map::load_from_cache,
72
+				'EventEspresso\core\services\json\JsonDataNodeValidator' => EE_Dependency_Map::load_from_cache,
73
+			]
74
+		);
75
+		$this->setDataNode(
76
+			$this->loader->getShared('EventEspresso\core\domain\entities\routing\data_nodes\EventEspressoData')
77
+		);
78
+	}
79 79
 
80 80
 
81
-    /**
82
-     * returns true if the current request matches this route
83
-     *
84
-     * @return bool
85
-     * @since   $VID:$
86
-     */
87
-    public function matchesCurrentRequest()
88
-    {
89
-        return ! $this->request->isActivation() || $this->request->isUnitTesting();
90
-    }
81
+	/**
82
+	 * returns true if the current request matches this route
83
+	 *
84
+	 * @return bool
85
+	 * @since   $VID:$
86
+	 */
87
+	public function matchesCurrentRequest()
88
+	{
89
+		return ! $this->request->isActivation() || $this->request->isUnitTesting();
90
+	}
91 91
 
92 92
 
93
-    /**
94
-     * @since $VID:$
95
-     */
96
-    protected function registerDependencies()
97
-    {
98
-        $default = [
99
-            'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
100
-            'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
101
-            'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
102
-        ];
103
-        $admin = ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + $default;
104
-        $public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + $default;
105
-        $default_routes = [
106
-            // default dependencies
107
-            'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests'          => $default,
108
-            'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage' => $default,
109
-            'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests' => $default,
110
-            'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests'       => $default,
111
-            'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests'         => $default,
112
-            'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests'     => $default,
113
-            'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests'     => $default,
114
-            'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat'  => $default,
115
-            // admin dependencies
116
-            'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute'           => $admin,
117
-            'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin'  => $admin,
118
-            'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor'  => $admin,
119
-            'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin'  => $admin,
120
-            'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor'  => $admin,
121
-            // public dependencies
122
-            'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests' => $public,
123
-            'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests'  => $public,
124
-        ];
125
-        foreach ($default_routes as $route => $dependencies) {
126
-            $this->dependency_map->registerDependencies($route, $dependencies);
127
-        }
128
-    }
93
+	/**
94
+	 * @since $VID:$
95
+	 */
96
+	protected function registerDependencies()
97
+	{
98
+		$default = [
99
+			'EE_Dependency_Map'                           => EE_Dependency_Map::load_from_cache,
100
+			'EventEspresso\core\services\loaders\Loader'  => EE_Dependency_Map::load_from_cache,
101
+			'EventEspresso\core\services\request\Request' => EE_Dependency_Map::load_from_cache,
102
+		];
103
+		$admin = ['EE_Admin_Config' => EE_Dependency_Map::load_from_cache] + $default;
104
+		$public = ['EE_Maintenance_Mode' => EE_Dependency_Map::load_from_cache] + $default;
105
+		$default_routes = [
106
+			// default dependencies
107
+			'EventEspresso\core\domain\entities\routing\handlers\admin\PueRequests'          => $default,
108
+			'EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage' => $default,
109
+			'EventEspresso\core\domain\entities\routing\handlers\frontend\ShortcodeRequests' => $default,
110
+			'EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests'       => $default,
111
+			'EventEspresso\core\domain\entities\routing\handlers\shared\GQLRequests'         => $default,
112
+			'EventEspresso\core\domain\entities\routing\handlers\shared\RestApiRequests'     => $default,
113
+			'EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests'     => $default,
114
+			'EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat'  => $default,
115
+			// admin dependencies
116
+			'EventEspresso\core\domain\entities\routing\handlers\admin\AdminRoute'           => $admin,
117
+			'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin'  => $admin,
118
+			'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor'  => $admin,
119
+			'EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin'  => $admin,
120
+			'EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor'  => $admin,
121
+			// public dependencies
122
+			'EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests' => $public,
123
+			'EventEspresso\core\domain\entities\routing\handlers\frontend\FrontendRequests'  => $public,
124
+		];
125
+		foreach ($default_routes as $route => $dependencies) {
126
+			$this->dependency_map->registerDependencies($route, $dependencies);
127
+		}
128
+	}
129 129
 
130 130
 
131
-    /**
132
-     * implements logic required to run during request
133
-     *
134
-     * @return bool
135
-     * @since   $VID:$
136
-     */
137
-    protected function requestHandler()
138
-    {
139
-        return true;
140
-    }
131
+	/**
132
+	 * implements logic required to run during request
133
+	 *
134
+	 * @return bool
135
+	 * @since   $VID:$
136
+	 */
137
+	protected function requestHandler()
138
+	{
139
+		return true;
140
+	}
141 141
 }
Please login to merge, or discard this patch.
core/domain/entities/editor/CoreBlocksAssetManager.php 1 patch
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -20,53 +20,53 @@
 block discarded – undo
20 20
  */
21 21
 class CoreBlocksAssetManager extends BlockAssetManager
22 22
 {
23
-    const JS_HANDLE_CORE_BLOCKS = 'eventespresso-blocks';
23
+	const JS_HANDLE_CORE_BLOCKS = 'eventespresso-blocks';
24 24
 
25 25
 
26
-    /**
27
-     * @since 4.9.71.p
28
-     */
29
-    public function setAssetHandles()
30
-    {
31
-        $this->setEditorScriptHandle(CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS);
32
-        $this->setScriptHandle(CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS);
33
-    }
26
+	/**
27
+	 * @since 4.9.71.p
28
+	 */
29
+	public function setAssetHandles()
30
+	{
31
+		$this->setEditorScriptHandle(CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS);
32
+		$this->setScriptHandle(CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS);
33
+	}
34 34
 
35 35
 
36
-    /**
37
-     * @throws InvalidDataTypeException
38
-     * @throws InvalidEntityException
39
-     * @throws DuplicateCollectionIdentifierException
40
-     * @throws DomainException
41
-     */
42
-    public function addAssets()
43
-    {
44
-        parent::addAssets();
45
-        $this->registerJavascript();
46
-    }
36
+	/**
37
+	 * @throws InvalidDataTypeException
38
+	 * @throws InvalidEntityException
39
+	 * @throws DuplicateCollectionIdentifierException
40
+	 * @throws DomainException
41
+	 */
42
+	public function addAssets()
43
+	{
44
+		parent::addAssets();
45
+		$this->registerJavascript();
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * Register javascript assets
51
-     *
52
-     * @throws InvalidDataTypeException
53
-     * @throws InvalidEntityException
54
-     * @throws DuplicateCollectionIdentifierException
55
-     * @throws DomainException
56
-     */
57
-    private function registerJavascript()
58
-    {
59
-        $this->addJs(
60
-            CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS,
61
-            [
62
-                ReactAssetManager::JS_HANDLE_REACT,
63
-                ReactAssetManager::JS_HANDLE_REACT_DOM,
64
-                CoreAssetManager::JS_HANDLE_JS_CORE,
65
-                'wp-components',
66
-                'wp-i18n',
67
-                'wp-keycodes',
68
-                'wp-url',
69
-            ]
70
-        )->setRequiresTranslation();
71
-    }
49
+	/**
50
+	 * Register javascript assets
51
+	 *
52
+	 * @throws InvalidDataTypeException
53
+	 * @throws InvalidEntityException
54
+	 * @throws DuplicateCollectionIdentifierException
55
+	 * @throws DomainException
56
+	 */
57
+	private function registerJavascript()
58
+	{
59
+		$this->addJs(
60
+			CoreBlocksAssetManager::JS_HANDLE_CORE_BLOCKS,
61
+			[
62
+				ReactAssetManager::JS_HANDLE_REACT,
63
+				ReactAssetManager::JS_HANDLE_REACT_DOM,
64
+				CoreAssetManager::JS_HANDLE_JS_CORE,
65
+				'wp-components',
66
+				'wp-i18n',
67
+				'wp-keycodes',
68
+				'wp-url',
69
+			]
70
+		)->setRequiresTranslation();
71
+	}
72 72
 }
Please login to merge, or discard this patch.
core/services/json/PrimaryJsonDataNode.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -17,37 +17,37 @@
 block discarded – undo
17 17
 abstract class PrimaryJsonDataNode extends JsonDataNode
18 18
 {
19 19
 
20
-    /**
21
-     * wp script handle for the app that requires the JSON data
22
-     *
23
-     * @var string $target_script
24
-     */
25
-    private $target_script;
26
-
27
-
28
-    /**
29
-     * sets the WP script handle that this data node is providing data for.
30
-     * The JSON data will written to the DOM inline prior to the targeted script handle
31
-     *
32
-     * @param string $target_script
33
-     * @throws DomainException
34
-     */
35
-    public function setTargetScript($target_script)
36
-    {
37
-        if ($this->target_script !== null) {
38
-            $this->validator->overwriteError($target_script, 'target script');
39
-        }
40
-        $this->target_script = $target_script;
41
-    }
42
-
43
-
44
-    /**
45
-     * the WP script handle that this data node is providing data for
46
-     *
47
-     * @return string
48
-     */
49
-    public function targetScript()
50
-    {
51
-        return $this->target_script;
52
-    }
20
+	/**
21
+	 * wp script handle for the app that requires the JSON data
22
+	 *
23
+	 * @var string $target_script
24
+	 */
25
+	private $target_script;
26
+
27
+
28
+	/**
29
+	 * sets the WP script handle that this data node is providing data for.
30
+	 * The JSON data will written to the DOM inline prior to the targeted script handle
31
+	 *
32
+	 * @param string $target_script
33
+	 * @throws DomainException
34
+	 */
35
+	public function setTargetScript($target_script)
36
+	{
37
+		if ($this->target_script !== null) {
38
+			$this->validator->overwriteError($target_script, 'target script');
39
+		}
40
+		$this->target_script = $target_script;
41
+	}
42
+
43
+
44
+	/**
45
+	 * the WP script handle that this data node is providing data for
46
+	 *
47
+	 * @return string
48
+	 */
49
+	public function targetScript()
50
+	{
51
+		return $this->target_script;
52
+	}
53 53
 }
Please login to merge, or discard this patch.
core/EE_System.core.php 1 patch
Indentation   +1261 added lines, -1261 removed lines patch added patch discarded remove patch
@@ -28,1265 +28,1265 @@
 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\AdminRoute');
1145
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin');
1146
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin');
1147
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor');
1148
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor');
1149
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage');
1150
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat');
1151
-        do_action('AHEE__EE_System__load_controllers__complete');
1152
-    }
1153
-
1154
-
1155
-    /**
1156
-     * core_loaded_and_ready
1157
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1158
-     *
1159
-     * @access public
1160
-     * @return void
1161
-     * @throws Exception
1162
-     */
1163
-    public function core_loaded_and_ready()
1164
-    {
1165
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests');
1166
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests');
1167
-        // integrate WP_Query with the EE models
1168
-        $this->loader->getShared('EE_CPT_Strategy');
1169
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1170
-        // always load template tags, because it's faster than checking if it's a front-end request, and many page
1171
-        // builders require these even on the front-end
1172
-        require_once EE_PUBLIC . 'template_tags.php';
1173
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1174
-    }
1175
-
1176
-
1177
-    /**
1178
-     * initialize
1179
-     * this is the best place to begin initializing client code
1180
-     *
1181
-     * @access public
1182
-     * @return void
1183
-     */
1184
-    public function initialize()
1185
-    {
1186
-        do_action('AHEE__EE_System__initialize');
1187
-    }
1188
-
1189
-
1190
-    /**
1191
-     * initialize_last
1192
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1193
-     * initialize has done so
1194
-     *
1195
-     * @access public
1196
-     * @return void
1197
-     * @throws Exception
1198
-     */
1199
-    public function initialize_last()
1200
-    {
1201
-        do_action('AHEE__EE_System__initialize_last');
1202
-        /** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1203
-        $rewrite_rules = $this->loader->getShared(
1204
-            'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1205
-        );
1206
-        $rewrite_rules->flushRewriteRules();
1207
-        $this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests');
1208
-        add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1209
-    }
1210
-
1211
-
1212
-    /**
1213
-     * @return void
1214
-     */
1215
-    public function addEspressoToolbar()
1216
-    {
1217
-        $this->loader->getShared(
1218
-            'EventEspresso\core\domain\services\admin\AdminToolBar',
1219
-            array($this->registry->CAP)
1220
-        );
1221
-    }
1222
-
1223
-
1224
-    /**
1225
-     * do_not_cache
1226
-     * sets no cache headers and defines no cache constants for WP plugins
1227
-     *
1228
-     * @access public
1229
-     * @return void
1230
-     */
1231
-    public static function do_not_cache()
1232
-    {
1233
-        // set no cache constants
1234
-        if (! defined('DONOTCACHEPAGE')) {
1235
-            define('DONOTCACHEPAGE', true);
1236
-        }
1237
-        if (! defined('DONOTCACHCEOBJECT')) {
1238
-            define('DONOTCACHCEOBJECT', true);
1239
-        }
1240
-        if (! defined('DONOTCACHEDB')) {
1241
-            define('DONOTCACHEDB', true);
1242
-        }
1243
-        // add no cache headers
1244
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1245
-        // plus a little extra for nginx and Google Chrome
1246
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1247
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1248
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1249
-    }
1250
-
1251
-
1252
-    /**
1253
-     *    extra_nocache_headers
1254
-     *
1255
-     * @access    public
1256
-     * @param $headers
1257
-     * @return    array
1258
-     */
1259
-    public static function extra_nocache_headers($headers)
1260
-    {
1261
-        // for NGINX
1262
-        $headers['X-Accel-Expires'] = 0;
1263
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1264
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1265
-        return $headers;
1266
-    }
1267
-
1268
-
1269
-    /**
1270
-     *    nocache_headers
1271
-     *
1272
-     * @access    public
1273
-     * @return    void
1274
-     */
1275
-    public static function nocache_headers()
1276
-    {
1277
-        nocache_headers();
1278
-    }
1279
-
1280
-
1281
-    /**
1282
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1283
-     * never returned with the function.
1284
-     *
1285
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1286
-     * @return array
1287
-     */
1288
-    public function remove_pages_from_wp_list_pages($exclude_array)
1289
-    {
1290
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1291
-    }
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\AdminRoute');
1145
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoLegacyAdmin');
1146
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventsAdmin');
1147
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\EspressoEventEditor');
1148
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\GutenbergEditor');
1149
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\WordPressPluginsPage');
1150
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\WordPressHeartbeat');
1151
+		do_action('AHEE__EE_System__load_controllers__complete');
1152
+	}
1153
+
1154
+
1155
+	/**
1156
+	 * core_loaded_and_ready
1157
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1158
+	 *
1159
+	 * @access public
1160
+	 * @return void
1161
+	 * @throws Exception
1162
+	 */
1163
+	public function core_loaded_and_ready()
1164
+	{
1165
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\AssetRequests');
1166
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\shared\SessionRequests');
1167
+		// integrate WP_Query with the EE models
1168
+		$this->loader->getShared('EE_CPT_Strategy');
1169
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1170
+		// always load template tags, because it's faster than checking if it's a front-end request, and many page
1171
+		// builders require these even on the front-end
1172
+		require_once EE_PUBLIC . 'template_tags.php';
1173
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1174
+	}
1175
+
1176
+
1177
+	/**
1178
+	 * initialize
1179
+	 * this is the best place to begin initializing client code
1180
+	 *
1181
+	 * @access public
1182
+	 * @return void
1183
+	 */
1184
+	public function initialize()
1185
+	{
1186
+		do_action('AHEE__EE_System__initialize');
1187
+	}
1188
+
1189
+
1190
+	/**
1191
+	 * initialize_last
1192
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1193
+	 * initialize has done so
1194
+	 *
1195
+	 * @access public
1196
+	 * @return void
1197
+	 * @throws Exception
1198
+	 */
1199
+	public function initialize_last()
1200
+	{
1201
+		do_action('AHEE__EE_System__initialize_last');
1202
+		/** @var EventEspresso\core\domain\services\custom_post_types\RewriteRules $rewrite_rules */
1203
+		$rewrite_rules = $this->loader->getShared(
1204
+			'EventEspresso\core\domain\services\custom_post_types\RewriteRules'
1205
+		);
1206
+		$rewrite_rules->flushRewriteRules();
1207
+		$this->router->addRoute('EventEspresso\core\domain\entities\routing\handlers\admin\PersonalDataRequests');
1208
+		add_action('admin_bar_init', array($this, 'addEspressoToolbar'));
1209
+	}
1210
+
1211
+
1212
+	/**
1213
+	 * @return void
1214
+	 */
1215
+	public function addEspressoToolbar()
1216
+	{
1217
+		$this->loader->getShared(
1218
+			'EventEspresso\core\domain\services\admin\AdminToolBar',
1219
+			array($this->registry->CAP)
1220
+		);
1221
+	}
1222
+
1223
+
1224
+	/**
1225
+	 * do_not_cache
1226
+	 * sets no cache headers and defines no cache constants for WP plugins
1227
+	 *
1228
+	 * @access public
1229
+	 * @return void
1230
+	 */
1231
+	public static function do_not_cache()
1232
+	{
1233
+		// set no cache constants
1234
+		if (! defined('DONOTCACHEPAGE')) {
1235
+			define('DONOTCACHEPAGE', true);
1236
+		}
1237
+		if (! defined('DONOTCACHCEOBJECT')) {
1238
+			define('DONOTCACHCEOBJECT', true);
1239
+		}
1240
+		if (! defined('DONOTCACHEDB')) {
1241
+			define('DONOTCACHEDB', true);
1242
+		}
1243
+		// add no cache headers
1244
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1245
+		// plus a little extra for nginx and Google Chrome
1246
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1247
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1248
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1249
+	}
1250
+
1251
+
1252
+	/**
1253
+	 *    extra_nocache_headers
1254
+	 *
1255
+	 * @access    public
1256
+	 * @param $headers
1257
+	 * @return    array
1258
+	 */
1259
+	public static function extra_nocache_headers($headers)
1260
+	{
1261
+		// for NGINX
1262
+		$headers['X-Accel-Expires'] = 0;
1263
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1264
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1265
+		return $headers;
1266
+	}
1267
+
1268
+
1269
+	/**
1270
+	 *    nocache_headers
1271
+	 *
1272
+	 * @access    public
1273
+	 * @return    void
1274
+	 */
1275
+	public static function nocache_headers()
1276
+	{
1277
+		nocache_headers();
1278
+	}
1279
+
1280
+
1281
+	/**
1282
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1283
+	 * never returned with the function.
1284
+	 *
1285
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1286
+	 * @return array
1287
+	 */
1288
+	public function remove_pages_from_wp_list_pages($exclude_array)
1289
+	{
1290
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1291
+	}
1292 1292
 }
Please login to merge, or discard this patch.