Completed
Branch FET-9856-direct-instantiation (d3e084)
by
unknown
57:58 queued 46:07
created
core/EE_Load_Espresso_Core.core.php 1 patch
Indentation   +208 added lines, -208 removed lines patch added patch discarded remove patch
@@ -4,7 +4,7 @@  discard block
 block discarded – undo
4 4
 use EventEspresso\core\services\loaders\LoaderInterface;
5 5
 
6 6
 if (! defined('EVENT_ESPRESSO_VERSION')) {
7
-    exit('No direct script access allowed');
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -24,213 +24,213 @@  discard block
 block discarded – undo
24 24
 class EE_Load_Espresso_Core implements EEI_Request_Decorator, EEI_Request_Stack_Core_App
25 25
 {
26 26
 
27
-    /**
28
-     * @type LoaderInterface $loader
29
-     */
30
-    protected $loader;
31
-
32
-    /**
33
-     * @var EE_Request $request
34
-     */
35
-    protected $request;
36
-
37
-    /**
38
-     * @var EE_Response $response
39
-     */
40
-    protected $response;
41
-
42
-    /**
43
-     * @var EE_Dependency_Map $dependency_map
44
-     */
45
-    protected $dependency_map;
46
-
47
-    /**
48
-     * @var EE_Registry $registry
49
-     */
50
-    protected $registry;
51
-
52
-
53
-
54
-    /**
55
-     * EE_Load_Espresso_Core constructor
56
-     */
57
-    public function __construct()
58
-    {
59
-        espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php');
60
-    }
61
-
62
-
63
-
64
-    /**
65
-     * handle
66
-     * sets hooks for running rest of system
67
-     * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
68
-     * starting EE Addons from any other point may lead to problems
69
-     *
70
-     * @param EE_Request  $request
71
-     * @param EE_Response $response
72
-     * @return EE_Response
73
-     * @throws EE_Error
74
-     * @throws InvalidDataTypeException
75
-     * @throws InvalidInterfaceException
76
-     * @throws InvalidArgumentException
77
-     */
78
-    public function handle_request(EE_Request $request, EE_Response $response)
79
-    {
80
-        $this->request = $request;
81
-        $this->response = $response;
82
-        // info about how to load classes required by other classes
83
-        $this->dependency_map = $this->_load_dependency_map();
84
-        // central repository for classes
85
-        $this->registry = $this->_load_registry();
86
-        // PSR4 Autoloaders
87
-        $this->registry->load_core('EE_Psr4AutoloaderInit');
88
-        do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
89
-        $this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader');
90
-        $this->dependency_map->setLoader($this->loader);
91
-        // build DI container
92
-        // $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
93
-        // $OpenCoffeeShop->addRecipes();
94
-        // $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
95
-        // workarounds for PHP < 5.3
96
-        $this->_load_class_tools();
97
-        // load interfaces
98
-        espresso_load_required('EEI_Payment_Method_Interfaces',
99
-            EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php');
100
-        // deprecated functions
101
-        espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
102
-        // WP cron jobs
103
-        $this->registry->load_core('Cron_Tasks');
104
-        $this->registry->load_core('EE_Request_Handler');
105
-        $this->registry->load_core('EE_System');
106
-        return $this->response;
107
-    }
108
-
109
-
110
-
111
-    /**
112
-     * @return EE_Request
113
-     */
114
-    public function request()
115
-    {
116
-        return $this->request;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * @return EE_Response
123
-     */
124
-    public function response()
125
-    {
126
-        return $this->response;
127
-    }
128
-
129
-
130
-
131
-    /**
132
-     * @return EE_Dependency_Map
133
-     * @throws EE_Error
134
-     */
135
-    public function dependency_map()
136
-    {
137
-        if (! $this->dependency_map instanceof EE_Dependency_Map) {
138
-            throw new EE_Error(
139
-                sprintf(
140
-                    __('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
141
-                    print_r($this->dependency_map, true)
142
-                )
143
-            );
144
-        }
145
-        return $this->dependency_map;
146
-    }
147
-
148
-
149
-
150
-    /**
151
-     * @return EE_Registry
152
-     * @throws EE_Error
153
-     */
154
-    public function registry()
155
-    {
156
-        if (! $this->registry instanceof EE_Registry) {
157
-            throw new EE_Error(
158
-                sprintf(
159
-                    __('Invalid EE_Registry: "%1$s"', 'event_espresso'),
160
-                    print_r($this->registry, true)
161
-                )
162
-            );
163
-        }
164
-        return $this->registry;
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * @return EE_Dependency_Map
171
-     */
172
-    private function _load_dependency_map()
173
-    {
174
-        if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
175
-            EE_Error::add_error(
176
-                __('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
177
-                __FILE__, __FUNCTION__, __LINE__
178
-            );
179
-            wp_die(EE_Error::get_notices());
180
-        }
181
-        require_once(EE_CORE . 'EE_Dependency_Map.core.php');
182
-        return EE_Dependency_Map::instance($this->request, $this->response);
183
-    }
184
-
185
-
186
-
187
-    /**
188
-     * @return EE_Registry
189
-     */
190
-    private function _load_registry()
191
-    {
192
-        if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
193
-            EE_Error::add_error(
194
-                __('The EE_Registry core class could not be loaded.', 'event_espresso'),
195
-                __FILE__, __FUNCTION__, __LINE__
196
-            );
197
-            wp_die(EE_Error::get_notices());
198
-        }
199
-        require_once(EE_CORE . 'EE_Registry.core.php');
200
-        return EE_Registry::instance($this->dependency_map);
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * @return void
207
-     */
208
-    private function _load_class_tools()
209
-    {
210
-        if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
211
-            EE_Error::add_error(
212
-                __('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
213
-                __FILE__, __FUNCTION__, __LINE__
214
-            );
215
-        }
216
-        require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
217
-    }
218
-
219
-
220
-
221
-    /**
222
-     * called after the request stack has been fully processed
223
-     * if any of the middleware apps has requested the plugin be deactivated, then we do that now
224
-     *
225
-     * @param EE_Request  $request
226
-     * @param EE_Response $response
227
-     */
228
-    public function handle_response(EE_Request $request, EE_Response $response)
229
-    {
230
-        if ($response->plugin_deactivated()) {
231
-            espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
232
-        }
233
-    }
27
+	/**
28
+	 * @type LoaderInterface $loader
29
+	 */
30
+	protected $loader;
31
+
32
+	/**
33
+	 * @var EE_Request $request
34
+	 */
35
+	protected $request;
36
+
37
+	/**
38
+	 * @var EE_Response $response
39
+	 */
40
+	protected $response;
41
+
42
+	/**
43
+	 * @var EE_Dependency_Map $dependency_map
44
+	 */
45
+	protected $dependency_map;
46
+
47
+	/**
48
+	 * @var EE_Registry $registry
49
+	 */
50
+	protected $registry;
51
+
52
+
53
+
54
+	/**
55
+	 * EE_Load_Espresso_Core constructor
56
+	 */
57
+	public function __construct()
58
+	{
59
+		espresso_load_required('EventEspresso\core\Factory', EE_CORE . 'Factory.php');
60
+	}
61
+
62
+
63
+
64
+	/**
65
+	 * handle
66
+	 * sets hooks for running rest of system
67
+	 * provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
68
+	 * starting EE Addons from any other point may lead to problems
69
+	 *
70
+	 * @param EE_Request  $request
71
+	 * @param EE_Response $response
72
+	 * @return EE_Response
73
+	 * @throws EE_Error
74
+	 * @throws InvalidDataTypeException
75
+	 * @throws InvalidInterfaceException
76
+	 * @throws InvalidArgumentException
77
+	 */
78
+	public function handle_request(EE_Request $request, EE_Response $response)
79
+	{
80
+		$this->request = $request;
81
+		$this->response = $response;
82
+		// info about how to load classes required by other classes
83
+		$this->dependency_map = $this->_load_dependency_map();
84
+		// central repository for classes
85
+		$this->registry = $this->_load_registry();
86
+		// PSR4 Autoloaders
87
+		$this->registry->load_core('EE_Psr4AutoloaderInit');
88
+		do_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading');
89
+		$this->loader = $this->registry->create('EventEspresso\core\services\loaders\Loader');
90
+		$this->dependency_map->setLoader($this->loader);
91
+		// build DI container
92
+		// $OpenCoffeeShop = new EventEspresso\core\services\container\OpenCoffeeShop();
93
+		// $OpenCoffeeShop->addRecipes();
94
+		// $CoffeeShop = $OpenCoffeeShop->CoffeeShop();
95
+		// workarounds for PHP < 5.3
96
+		$this->_load_class_tools();
97
+		// load interfaces
98
+		espresso_load_required('EEI_Payment_Method_Interfaces',
99
+			EE_LIBRARIES . 'payment_methods' . DS . 'EEI_Payment_Method_Interfaces.php');
100
+		// deprecated functions
101
+		espresso_load_required('EE_Deprecated', EE_CORE . 'EE_Deprecated.core.php');
102
+		// WP cron jobs
103
+		$this->registry->load_core('Cron_Tasks');
104
+		$this->registry->load_core('EE_Request_Handler');
105
+		$this->registry->load_core('EE_System');
106
+		return $this->response;
107
+	}
108
+
109
+
110
+
111
+	/**
112
+	 * @return EE_Request
113
+	 */
114
+	public function request()
115
+	{
116
+		return $this->request;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * @return EE_Response
123
+	 */
124
+	public function response()
125
+	{
126
+		return $this->response;
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * @return EE_Dependency_Map
133
+	 * @throws EE_Error
134
+	 */
135
+	public function dependency_map()
136
+	{
137
+		if (! $this->dependency_map instanceof EE_Dependency_Map) {
138
+			throw new EE_Error(
139
+				sprintf(
140
+					__('Invalid EE_Dependency_Map: "%1$s"', 'event_espresso'),
141
+					print_r($this->dependency_map, true)
142
+				)
143
+			);
144
+		}
145
+		return $this->dependency_map;
146
+	}
147
+
148
+
149
+
150
+	/**
151
+	 * @return EE_Registry
152
+	 * @throws EE_Error
153
+	 */
154
+	public function registry()
155
+	{
156
+		if (! $this->registry instanceof EE_Registry) {
157
+			throw new EE_Error(
158
+				sprintf(
159
+					__('Invalid EE_Registry: "%1$s"', 'event_espresso'),
160
+					print_r($this->registry, true)
161
+				)
162
+			);
163
+		}
164
+		return $this->registry;
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * @return EE_Dependency_Map
171
+	 */
172
+	private function _load_dependency_map()
173
+	{
174
+		if (! is_readable(EE_CORE . 'EE_Dependency_Map.core.php')) {
175
+			EE_Error::add_error(
176
+				__('The EE_Dependency_Map core class could not be loaded.', 'event_espresso'),
177
+				__FILE__, __FUNCTION__, __LINE__
178
+			);
179
+			wp_die(EE_Error::get_notices());
180
+		}
181
+		require_once(EE_CORE . 'EE_Dependency_Map.core.php');
182
+		return EE_Dependency_Map::instance($this->request, $this->response);
183
+	}
184
+
185
+
186
+
187
+	/**
188
+	 * @return EE_Registry
189
+	 */
190
+	private function _load_registry()
191
+	{
192
+		if (! is_readable(EE_CORE . 'EE_Registry.core.php')) {
193
+			EE_Error::add_error(
194
+				__('The EE_Registry core class could not be loaded.', 'event_espresso'),
195
+				__FILE__, __FUNCTION__, __LINE__
196
+			);
197
+			wp_die(EE_Error::get_notices());
198
+		}
199
+		require_once(EE_CORE . 'EE_Registry.core.php');
200
+		return EE_Registry::instance($this->dependency_map);
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * @return void
207
+	 */
208
+	private function _load_class_tools()
209
+	{
210
+		if (! is_readable(EE_HELPERS . 'EEH_Class_Tools.helper.php')) {
211
+			EE_Error::add_error(
212
+				__('The EEH_Class_Tools helper could not be loaded.', 'event_espresso'),
213
+				__FILE__, __FUNCTION__, __LINE__
214
+			);
215
+		}
216
+		require_once(EE_HELPERS . 'EEH_Class_Tools.helper.php');
217
+	}
218
+
219
+
220
+
221
+	/**
222
+	 * called after the request stack has been fully processed
223
+	 * if any of the middleware apps has requested the plugin be deactivated, then we do that now
224
+	 *
225
+	 * @param EE_Request  $request
226
+	 * @param EE_Response $response
227
+	 */
228
+	public function handle_response(EE_Request $request, EE_Response $response)
229
+	{
230
+		if ($response->plugin_deactivated()) {
231
+			espresso_deactivate_plugin(EE_PLUGIN_BASENAME);
232
+		}
233
+	}
234 234
 
235 235
 
236 236
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Capabilities.lib.php 2 patches
Indentation   +159 added lines, -159 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @since           4.5.0
8 8
  */
9 9
 if (! defined('EVENT_ESPRESSO_VERSION')) {
10
-    exit('No direct script access allowed');
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -21,174 +21,174 @@  discard block
 block discarded – undo
21 21
 class EE_Register_Capabilities implements EEI_Plugin_API
22 22
 {
23 23
 
24
-    /**
25
-     * Holds the settings for a specific registration.
26
-     *
27
-     * @var array
28
-     */
29
-    protected static $_registry = array();
24
+	/**
25
+	 * Holds the settings for a specific registration.
26
+	 *
27
+	 * @var array
28
+	 */
29
+	protected static $_registry = array();
30 30
 
31 31
 
32
-    /**
33
-     * Used to register capability items with EE core.
34
-     *
35
-     * @since 4.5.0
36
-     * @param string $cap_reference                                                       usually will be a class name
37
-     *                                                                                    that references capability
38
-     *                                                                                    related items setup for
39
-     *                                                                                    something.
40
-     * @param array  $setup_args                                                          {
41
-     *                                                                                    An array of items related to
42
-     *                                                                                    registering capabilities.
43
-     * @type array   $capabilities                                                        An array mapping capability
44
-     *       strings to core WP Role. Something like: array(
45
-     *                                                                                    'administrator'    => array(
46
-     *                                                                                    'read_cap', 'edit_cap',
47
-     *                                                                                    'delete_cap'),
48
-     *                                                                                    'author'                =>
49
-     *                                                                                    array( 'read_cap' )
50
-     *                                                                                    ).
51
-     * @type array   $capability_maps                                                     EE_Meta_Capability_Map[]
52
-     * @see   EE_Capabilities.php for php docs on these objects.
53
-     *                                                                                    Should be indexed by the
54
-     *                                                                                    classname for the capability
55
-     *                                                                                    map and values representing
56
-     *                                                                                    the arguments for the map.
57
-     *                                                                                    }
58
-     * @throws EE_Error
59
-     * @return void
60
-     */
61
-    public static function register($cap_reference = null, $setup_args = array())
62
-    {
63
-        //required fields MUST be present, so let's make sure they are.
64
-        if ($cap_reference === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) {
65
-            throw new EE_Error(
66
-                __('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".',
67
-                    'event_espresso')
68
-            );
69
-        }
70
-        //make sure we don't register twice
71
-        if (isset(self::$_registry[$cap_reference])) {
72
-            return;
73
-        }
74
-        //make sure this is not registered too late or too early.
75
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
76
-            EE_Error::doing_it_wrong(__METHOD__,
77
-                sprintf(__('%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.',
78
-                    'event_espresso'), $cap_reference), '4.5.0');
79
-        }
80
-        //some preliminary sanitization and setting to the $_registry property
81
-        self::$_registry[ $cap_reference ] = array(
82
-            'caps'               => isset($setup_args['capabilities']) && is_array($setup_args['capabilities'])
83
-                ? $setup_args['capabilities']
84
-                : array(),
85
-            'cap_maps'           => isset($setup_args['capability_maps'])
86
-                ? $setup_args['capability_maps']
87
-                : array(),
88
-        );
89
-        //set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once)
90
-        add_filter(
91
-            'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
92
-            array('EE_Register_Capabilities', 'register_capabilities')
93
-        );
94
-        //add filter for cap maps
95
-        add_filter(
96
-            'FHEE__EE_Capabilities___set_meta_caps__meta_caps',
97
-            array('EE_Register_Capabilities', 'register_cap_maps')
98
-        );
99
-    }
32
+	/**
33
+	 * Used to register capability items with EE core.
34
+	 *
35
+	 * @since 4.5.0
36
+	 * @param string $cap_reference                                                       usually will be a class name
37
+	 *                                                                                    that references capability
38
+	 *                                                                                    related items setup for
39
+	 *                                                                                    something.
40
+	 * @param array  $setup_args                                                          {
41
+	 *                                                                                    An array of items related to
42
+	 *                                                                                    registering capabilities.
43
+	 * @type array   $capabilities                                                        An array mapping capability
44
+	 *       strings to core WP Role. Something like: array(
45
+	 *                                                                                    'administrator'    => array(
46
+	 *                                                                                    'read_cap', 'edit_cap',
47
+	 *                                                                                    'delete_cap'),
48
+	 *                                                                                    'author'                =>
49
+	 *                                                                                    array( 'read_cap' )
50
+	 *                                                                                    ).
51
+	 * @type array   $capability_maps                                                     EE_Meta_Capability_Map[]
52
+	 * @see   EE_Capabilities.php for php docs on these objects.
53
+	 *                                                                                    Should be indexed by the
54
+	 *                                                                                    classname for the capability
55
+	 *                                                                                    map and values representing
56
+	 *                                                                                    the arguments for the map.
57
+	 *                                                                                    }
58
+	 * @throws EE_Error
59
+	 * @return void
60
+	 */
61
+	public static function register($cap_reference = null, $setup_args = array())
62
+	{
63
+		//required fields MUST be present, so let's make sure they are.
64
+		if ($cap_reference === null || ! is_array($setup_args) || empty($setup_args['capabilities'])) {
65
+			throw new EE_Error(
66
+				__('In order to register capabilities with EE_Register_Capabilities::register, you must include a unique name to reference the capabilities being registered, plus an array containing the following keys: "capabilities".',
67
+					'event_espresso')
68
+			);
69
+		}
70
+		//make sure we don't register twice
71
+		if (isset(self::$_registry[$cap_reference])) {
72
+			return;
73
+		}
74
+		//make sure this is not registered too late or too early.
75
+		if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
76
+			EE_Error::doing_it_wrong(__METHOD__,
77
+				sprintf(__('%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.',
78
+					'event_espresso'), $cap_reference), '4.5.0');
79
+		}
80
+		//some preliminary sanitization and setting to the $_registry property
81
+		self::$_registry[ $cap_reference ] = array(
82
+			'caps'               => isset($setup_args['capabilities']) && is_array($setup_args['capabilities'])
83
+				? $setup_args['capabilities']
84
+				: array(),
85
+			'cap_maps'           => isset($setup_args['capability_maps'])
86
+				? $setup_args['capability_maps']
87
+				: array(),
88
+		);
89
+		//set initial caps (note that EE_Capabilities takes care of making sure that the caps get added only once)
90
+		add_filter(
91
+			'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
92
+			array('EE_Register_Capabilities', 'register_capabilities')
93
+		);
94
+		//add filter for cap maps
95
+		add_filter(
96
+			'FHEE__EE_Capabilities___set_meta_caps__meta_caps',
97
+			array('EE_Register_Capabilities', 'register_cap_maps')
98
+		);
99
+	}
100 100
 
101 101
 
102
-    /**
103
-     * callback for FHEE__EE_Capabilities__init_caps_map__caps filter.
104
-     * Takes care of registering additional capabilities to the caps map.   Note, that this also on the initial
105
-     * registration ensures that new capabilities are added to existing roles.
106
-     *
107
-     * @param array $incoming_caps The original caps map.
108
-     * @return array merged in new caps.
109
-     */
110
-    public static function register_capabilities($incoming_caps)
111
-    {
112
-        foreach (self::$_registry as $cap_reference => $caps_and_cap_map) {
113
-            $incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']);
114
-        }
115
-        return $incoming_caps;
116
-    }
102
+	/**
103
+	 * callback for FHEE__EE_Capabilities__init_caps_map__caps filter.
104
+	 * Takes care of registering additional capabilities to the caps map.   Note, that this also on the initial
105
+	 * registration ensures that new capabilities are added to existing roles.
106
+	 *
107
+	 * @param array $incoming_caps The original caps map.
108
+	 * @return array merged in new caps.
109
+	 */
110
+	public static function register_capabilities($incoming_caps)
111
+	{
112
+		foreach (self::$_registry as $cap_reference => $caps_and_cap_map) {
113
+			$incoming_caps = array_merge_recursive($incoming_caps, $caps_and_cap_map['caps']);
114
+		}
115
+		return $incoming_caps;
116
+	}
117 117
 
118 118
 
119
-    /**
120
-     * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of
121
-     * capability maps for the WP meta_caps filter called in EE_Capabilities.
122
-     *
123
-     * @since 4.5.0
124
-     * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array.
125
-     * @return EE_Meta_Capability_Map[]
126
-     * @throws EE_Error
127
-     */
128
-    public static function register_cap_maps($cap_maps)
129
-    {
130
-        //loop through and instantiate cap maps.
131
-        foreach (self::$_registry as $cap_reference => $setup) {
132
-            if (! isset($setup['cap_maps'])) {
133
-                continue;
134
-            }
135
-            foreach ($setup['cap_maps'] as $cap_class => $args) {
119
+	/**
120
+	 * Callback for the 'FHEE__EE_Capabilities___set_meta_caps__meta_caps' filter which registers an array of
121
+	 * capability maps for the WP meta_caps filter called in EE_Capabilities.
122
+	 *
123
+	 * @since 4.5.0
124
+	 * @param EE_Meta_Capability_Map[] $cap_maps The existing cap maps array.
125
+	 * @return EE_Meta_Capability_Map[]
126
+	 * @throws EE_Error
127
+	 */
128
+	public static function register_cap_maps($cap_maps)
129
+	{
130
+		//loop through and instantiate cap maps.
131
+		foreach (self::$_registry as $cap_reference => $setup) {
132
+			if (! isset($setup['cap_maps'])) {
133
+				continue;
134
+			}
135
+			foreach ($setup['cap_maps'] as $cap_class => $args) {
136 136
 
137
-                /**
138
-                 * account for cases where capability maps may be indexed
139
-                 * numerically to allow for the same map class to be utilized
140
-                 * In those cases, maps will be setup in an array like:
141
-                 * array(
142
-                 *    0 => array( 'EE_Meta_Capability' => array(
143
-                 *        'ee_edit_cap', array( 'Object_Name',
144
-                 *        'ee_edit_published_cap',
145
-                 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
146
-                 *        ) )
147
-                 *    1 => ...
148
-                 * )
149
-                 * instead of:
150
-                 * array(
151
-                 *    'EE_Meta_Capability' => array(
152
-                 *        'ee_edit_cap', array( 'Object_Name',
153
-                 *        'ee_edit_published_cap',
154
-                 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
155
-                 *        ),
156
-                 *    ...
157
-                 * )
158
-                 */
159
-                if (is_numeric($cap_class)) {
160
-                    $cap_class = key($args);
161
-                    $args      = $args[$cap_class];
162
-                }
137
+				/**
138
+				 * account for cases where capability maps may be indexed
139
+				 * numerically to allow for the same map class to be utilized
140
+				 * In those cases, maps will be setup in an array like:
141
+				 * array(
142
+				 *    0 => array( 'EE_Meta_Capability' => array(
143
+				 *        'ee_edit_cap', array( 'Object_Name',
144
+				 *        'ee_edit_published_cap',
145
+				 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
146
+				 *        ) )
147
+				 *    1 => ...
148
+				 * )
149
+				 * instead of:
150
+				 * array(
151
+				 *    'EE_Meta_Capability' => array(
152
+				 *        'ee_edit_cap', array( 'Object_Name',
153
+				 *        'ee_edit_published_cap',
154
+				 *        'ee_edit_others_cap', 'ee_edit_private_cap' )
155
+				 *        ),
156
+				 *    ...
157
+				 * )
158
+				 */
159
+				if (is_numeric($cap_class)) {
160
+					$cap_class = key($args);
161
+					$args      = $args[$cap_class];
162
+				}
163 163
 
164
-                if (! class_exists($cap_class)) {
165
-                    throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments',
166
-                        'event_espresso'), $cap_reference));
167
-                }
164
+				if (! class_exists($cap_class)) {
165
+					throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments',
166
+						'event_espresso'), $cap_reference));
167
+				}
168 168
 
169
-                if (count($args) !== 2) {
170
-                    throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments.  The array should have two values the first being a string and the second an array.',
171
-                        'event_espresso'), $cap_reference));
172
-                }
173
-                $cap_maps[] = new $cap_class($args[0], $args[1]);
174
-            }
175
-        }
176
-        return $cap_maps;
177
-    }
169
+				if (count($args) !== 2) {
170
+					throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments.  The array should have two values the first being a string and the second an array.',
171
+						'event_espresso'), $cap_reference));
172
+				}
173
+				$cap_maps[] = new $cap_class($args[0], $args[1]);
174
+			}
175
+		}
176
+		return $cap_maps;
177
+	}
178 178
 
179 179
 
180 180
 
181
-    /**
182
-     * @param string $cap_reference
183
-     * @throws EE_Error
184
-     */
185
-    public static function deregister($cap_reference = '')
186
-    {
187
-        if (! empty(self::$_registry[$cap_reference])) {
188
-            if (! empty(self::$_registry[ $cap_reference ]['caps'])) {
189
-                EE_Capabilities::instance()->removeCaps(self::$_registry[ $cap_reference ]['caps']);
190
-            }
191
-            unset(self::$_registry[$cap_reference]);
192
-        }
193
-    }
181
+	/**
182
+	 * @param string $cap_reference
183
+	 * @throws EE_Error
184
+	 */
185
+	public static function deregister($cap_reference = '')
186
+	{
187
+		if (! empty(self::$_registry[$cap_reference])) {
188
+			if (! empty(self::$_registry[ $cap_reference ]['caps'])) {
189
+				EE_Capabilities::instance()->removeCaps(self::$_registry[ $cap_reference ]['caps']);
190
+			}
191
+			unset(self::$_registry[$cap_reference]);
192
+		}
193
+	}
194 194
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
  * @subpackage      plugin api, capabilities
7 7
  * @since           4.5.0
8 8
  */
9
-if (! defined('EVENT_ESPRESSO_VERSION')) {
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10 10
     exit('No direct script access allowed');
11 11
 }
12 12
 
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
             return;
73 73
         }
74 74
         //make sure this is not registered too late or too early.
75
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
75
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')) {
76 76
             EE_Error::doing_it_wrong(__METHOD__,
77 77
                 sprintf(__('%s has been registered too late.  Please ensure that EE_Register_Capabilities::register has been called at some point before the "AHEE__EE_System___detect_if_activation_or_upgrade__begin" action hook has been called.',
78 78
                     'event_espresso'), $cap_reference), '4.5.0');
79 79
         }
80 80
         //some preliminary sanitization and setting to the $_registry property
81
-        self::$_registry[ $cap_reference ] = array(
81
+        self::$_registry[$cap_reference] = array(
82 82
             'caps'               => isset($setup_args['capabilities']) && is_array($setup_args['capabilities'])
83 83
                 ? $setup_args['capabilities']
84 84
                 : array(),
@@ -129,7 +129,7 @@  discard block
 block discarded – undo
129 129
     {
130 130
         //loop through and instantiate cap maps.
131 131
         foreach (self::$_registry as $cap_reference => $setup) {
132
-            if (! isset($setup['cap_maps'])) {
132
+            if ( ! isset($setup['cap_maps'])) {
133 133
                 continue;
134 134
             }
135 135
             foreach ($setup['cap_maps'] as $cap_class => $args) {
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                     $args      = $args[$cap_class];
162 162
                 }
163 163
 
164
-                if (! class_exists($cap_class)) {
164
+                if ( ! class_exists($cap_class)) {
165 165
                     throw new EE_Error(sprintf(__('An addon (%s) has tried to register a capability map improperly.  Capability map arrays must be indexed by capability map classname, and an array for the class arguments',
166 166
                         'event_espresso'), $cap_reference));
167 167
                 }
@@ -184,9 +184,9 @@  discard block
 block discarded – undo
184 184
      */
185 185
     public static function deregister($cap_reference = '')
186 186
     {
187
-        if (! empty(self::$_registry[$cap_reference])) {
188
-            if (! empty(self::$_registry[ $cap_reference ]['caps'])) {
189
-                EE_Capabilities::instance()->removeCaps(self::$_registry[ $cap_reference ]['caps']);
187
+        if ( ! empty(self::$_registry[$cap_reference])) {
188
+            if ( ! empty(self::$_registry[$cap_reference]['caps'])) {
189
+                EE_Capabilities::instance()->removeCaps(self::$_registry[$cap_reference]['caps']);
190 190
             }
191 191
             unset(self::$_registry[$cap_reference]);
192 192
         }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
Indentation   +991 added lines, -991 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if (! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -19,1050 +19,1050 @@  discard block
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * possibly truncated version of the EE core version string
24
-     *
25
-     * @var string
26
-     */
27
-    protected static $_core_version = '';
22
+	/**
23
+	 * possibly truncated version of the EE core version string
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected static $_core_version = '';
28 28
 
29
-    /**
30
-     * Holds values for registered addons
31
-     *
32
-     * @var array
33
-     */
34
-    protected static $_settings = array();
29
+	/**
30
+	 * Holds values for registered addons
31
+	 *
32
+	 * @var array
33
+	 */
34
+	protected static $_settings = array();
35 35
 
36
-    /**
37
-     * @var  array $_incompatible_addons keys are addon SLUGS
38
-     * (first argument passed to EE_Register_Addon::register()), keys are
39
-     * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
40
-     * Generally this should be used sparingly, as we don't want to muddle up
41
-     * EE core with knowledge of ALL the addons out there.
42
-     * If you want NO versions of an addon to run with a certain version of core,
43
-     * it's usually best to define the addon's "min_core_version" as part of its call
44
-     * to EE_Register_Addon::register(), rather than using this array with a super high value for its
45
-     * minimum plugin version.
46
-     * @access    protected
47
-     */
48
-    protected static $_incompatible_addons = array(
49
-        'Multi_Event_Registration' => '2.0.11.rc.002',
50
-        'Promotions'               => '1.0.0.rc.084',
51
-    );
36
+	/**
37
+	 * @var  array $_incompatible_addons keys are addon SLUGS
38
+	 * (first argument passed to EE_Register_Addon::register()), keys are
39
+	 * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
40
+	 * Generally this should be used sparingly, as we don't want to muddle up
41
+	 * EE core with knowledge of ALL the addons out there.
42
+	 * If you want NO versions of an addon to run with a certain version of core,
43
+	 * it's usually best to define the addon's "min_core_version" as part of its call
44
+	 * to EE_Register_Addon::register(), rather than using this array with a super high value for its
45
+	 * minimum plugin version.
46
+	 * @access    protected
47
+	 */
48
+	protected static $_incompatible_addons = array(
49
+		'Multi_Event_Registration' => '2.0.11.rc.002',
50
+		'Promotions'               => '1.0.0.rc.084',
51
+	);
52 52
 
53 53
 
54
-    /**
55
-     * We should always be comparing core to a version like '4.3.0.rc.000',
56
-     * not just '4.3.0'.
57
-     * So if the addon developer doesn't provide that full version string,
58
-     * fill in the blanks for them
59
-     *
60
-     * @param string $min_core_version
61
-     * @return string always like '4.3.0.rc.000'
62
-     */
63
-    protected static function _effective_version($min_core_version)
64
-    {
65
-        // versions: 4 . 3 . 1 . p . 123
66
-        // offsets:    0 . 1 . 2 . 3 . 4
67
-        $version_parts = explode('.', $min_core_version);
68
-        //check they specified the micro version (after 2nd period)
69
-        if (! isset($version_parts[2])) {
70
-            $version_parts[2] = '0';
71
-        }
72
-        //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
73
-        //soon we can assume that's 'rc', but this current version is 'alpha'
74
-        if (! isset($version_parts[3])) {
75
-            $version_parts[3] = 'dev';
76
-        }
77
-        if (! isset($version_parts[4])) {
78
-            $version_parts[4] = '000';
79
-        }
80
-        return implode('.', $version_parts);
81
-    }
54
+	/**
55
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
56
+	 * not just '4.3.0'.
57
+	 * So if the addon developer doesn't provide that full version string,
58
+	 * fill in the blanks for them
59
+	 *
60
+	 * @param string $min_core_version
61
+	 * @return string always like '4.3.0.rc.000'
62
+	 */
63
+	protected static function _effective_version($min_core_version)
64
+	{
65
+		// versions: 4 . 3 . 1 . p . 123
66
+		// offsets:    0 . 1 . 2 . 3 . 4
67
+		$version_parts = explode('.', $min_core_version);
68
+		//check they specified the micro version (after 2nd period)
69
+		if (! isset($version_parts[2])) {
70
+			$version_parts[2] = '0';
71
+		}
72
+		//if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
73
+		//soon we can assume that's 'rc', but this current version is 'alpha'
74
+		if (! isset($version_parts[3])) {
75
+			$version_parts[3] = 'dev';
76
+		}
77
+		if (! isset($version_parts[4])) {
78
+			$version_parts[4] = '000';
79
+		}
80
+		return implode('.', $version_parts);
81
+	}
82 82
 
83 83
 
84
-    /**
85
-     * Returns whether or not the min core version requirement of the addon is met
86
-     *
87
-     * @param string $min_core_version    the minimum core version required by the addon
88
-     * @param string $actual_core_version the actual core version, optional
89
-     * @return boolean
90
-     */
91
-    public static function _meets_min_core_version_requirement(
92
-        $min_core_version,
93
-        $actual_core_version = EVENT_ESPRESSO_VERSION
94
-    ) {
95
-        return version_compare(
96
-            self::_effective_version($actual_core_version),
97
-            self::_effective_version($min_core_version),
98
-            '>='
99
-        );
100
-    }
84
+	/**
85
+	 * Returns whether or not the min core version requirement of the addon is met
86
+	 *
87
+	 * @param string $min_core_version    the minimum core version required by the addon
88
+	 * @param string $actual_core_version the actual core version, optional
89
+	 * @return boolean
90
+	 */
91
+	public static function _meets_min_core_version_requirement(
92
+		$min_core_version,
93
+		$actual_core_version = EVENT_ESPRESSO_VERSION
94
+	) {
95
+		return version_compare(
96
+			self::_effective_version($actual_core_version),
97
+			self::_effective_version($min_core_version),
98
+			'>='
99
+		);
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     *    Method for registering new EE_Addons.
105
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
106
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
107
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
108
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
109
-     * 'activate_plugin', it registers the addon still, but its components are not registered
110
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
111
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
112
-     * (so that we can detect that the addon has activated on the subsequent request)
113
-     *
114
-     * @since    4.3.0
115
-     * @param string                  $addon_name                           the EE_Addon's name. Required.
116
-     * @param  array                  $setup_args                           {                                    An
117
-     *                                                                      array of arguments provided for registering
118
-     *                                                                      the message type.
119
-     * @type  string                  $class_name                           the addon's main file name.
120
-     *                                                                      If left blank, generated from the addon
121
-     *                                                                      name, changes something like "calendar" to
122
-     *                                                                      "EE_Calendar"
123
-     * @type string                   $min_core_version                     the minimum version of EE Core that the
124
-     *       addon will work with. eg "4.8.1.rc.084"
125
-     * @type string                   $version                              the "software" version for the addon. eg
126
-     *       "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress
127
-     * @type string                   $main_file_path                       the full server path to the main file
128
-     *       loaded
129
-     *                                                                      directly by WP
130
-     * @type string                   $admin_path                           full server path to the folder where the
131
-     *       addon\'s admin files reside
132
-     * @type string                   $admin_callback                       a method to be called when the EE Admin is
133
-     *       first invoked, can be used for hooking into any admin page
134
-     * @type string                   $config_section                       the section name for this addon's
135
-     *       configuration settings section (defaults to "addons")
136
-     * @type string                   $config_class                         the class name for this addon's
137
-     *       configuration settings object
138
-     * @type string                   $config_name                          the class name for this addon's
139
-     *       configuration settings object
140
-     * @type string                   $autoloader_paths                     an array of class names and the full server
141
-     *       paths to those files. Required.
142
-     * @type string                   $autoloader_folders                   an array of  "full server paths" for any
143
-     *       folders containing classes that might be invoked by the addon
144
-     * @type string                   $dms_paths                            an array of full server paths to folders
145
-     *       that contain data migration scripts. Required.
146
-     * @type string                   $module_paths                         an array of full server paths to any
147
-     *       EED_Modules used by the addon
148
-     * @type string                   $shortcode_paths                      an array of full server paths to folders
149
-     *       that contain EES_Shortcodes
150
-     * @type string                   $widget_paths                         an array of full server paths to folders
151
-     *       that contain WP_Widgets
152
-     * @type string                   $pue_options
153
-     * @type array                    $capabilities                         an array indexed by role name
154
-     *                                                                      (i.e administrator,author ) and the values
155
-     *                                                                      are an array of caps to add to the role.
156
-     *                                                                      'administrator' => array(
157
-     *                                                                      'read_addon', 'edit_addon', etc.
158
-     *                                                                      ).
159
-     * @type EE_Meta_Capability_Map[] $capability_maps                      an array of EE_Meta_Capability_Map object
160
-     *       for any addons that need to register any special meta mapped capabilities.  Should be indexed where the
161
-     *       key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class.
162
-     * @type array                    $model_paths                          array of folders containing DB models
163
-     * @see      EE_Register_Model
164
-     * @type array                    $class_paths                          array of folders containing DB classes
165
-     * @see      EE_Register_Model
166
-     * @type array                    $model_extension_paths                array of folders containing DB model
167
-     *       extensions
168
-     * @see      EE_Register_Model_Extension
169
-     * @type array                    $class_extension_paths                array of folders containing DB class
170
-     *       extensions
171
-     * @see      EE_Register_Model_Extension
172
-     * @type array message_types {
173
-     *                                                                      An array of message types with the key as
174
-     *                                                                      the message type name and the values as
175
-     *                                                                      below:
176
-     * @type string                   $mtfilename                           The filename of the message type being
177
-     *       registered. This will be the main EE_{Messagetype_Name}_message_type class.
178
-     *                                                                      (eg.
179
-     *                                                                      EE_Declined_Registration_message_type.class.php)
180
-     *                                                                      Required.
181
-     * @type array                    $autoloadpaths                        An array of paths to add to the messages
182
-     *                                                                      autoloader for the new message type.
183
-     *                                                                      Required.
184
-     * @type array                    $messengers_to_activate_with          An array of messengers that this message
185
-     *                                                                      type should activate with. Each value in
186
-     *                                                                      the
187
-     *                                                                      array
188
-     *                                                                      should match the name property of a
189
-     *                                                                      EE_messenger. Optional.
190
-     * @type array                    $messengers_to_validate_with          An array of messengers that this message
191
-     *                                                                      type should validate with. Each value in
192
-     *                                                                      the
193
-     *                                                                      array
194
-     *                                                                      should match the name property of an
195
-     *                                                                      EE_messenger.
196
-     *                                                                      Optional.
197
-     *                                                                      }
198
-     * @type array                    $custom_post_types
199
-     * @type array                    $custom_taxonomies
200
-     * @type array                    $payment_method_paths                 each element is the folder containing the
201
-     *                                                                      EE_PMT_Base child class
202
-     *                                                                      (eg,
203
-     *                                                                      '/wp-content/plugins/my_plugin/Payomatic/'
204
-     *                                                                      which contains the files
205
-     *                                                                      EE_PMT_Payomatic.pm.php)
206
-     * @type array                    $default_terms
207
-     * @type array                    $namespace                            {
208
-     *                                                                      An array with two items for registering the
209
-     *                                                                      addon's namespace. (If, for some reason,
210
-     *                                                                      you
211
-     *                                                                      require additional namespaces, use
212
-     *                                                                      EventEspresso\core\Psr4Autoloader::addNamespace()
213
-     *                                                                      directly)
214
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
215
-     * @type string                   $FQNS                                 the namespace prefix
216
-     * @type string                   $DIR                                  a base directory for class files in the
217
-     *       namespace.
218
-     *                                                                      }
219
-     *                                                                      }
220
-     * @throws EE_Error
221
-     * @return void
222
-     */
223
-    public static function register($addon_name = '', $setup_args = array())
224
-    {
225
-        // required fields MUST be present, so let's make sure they are.
226
-        \EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
227
-        // get class name for addon
228
-        $class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
229
-        //setup $_settings array from incoming values.
230
-        $addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
231
-        // setup PUE
232
-        \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
233
-        // does this addon work with this version of core or WordPress ?
234
-        if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
235
-            return;
236
-        }
237
-        // register namespaces
238
-        \EE_Register_Addon::_setup_namespaces($addon_settings);
239
-        // check if this is an activation request
240
-        if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
241
-            // dont bother setting up the rest of the addon atm
242
-            return;
243
-        }
244
-        // we need cars
245
-        \EE_Register_Addon::_setup_autoloaders($addon_name);
246
-        // register new models and extensions
247
-        \EE_Register_Addon::_register_models_and_extensions($addon_name);
248
-        // setup DMS
249
-        \EE_Register_Addon::_register_data_migration_scripts($addon_name);
250
-        // if config_class is present let's register config.
251
-        \EE_Register_Addon::_register_config($addon_name);
252
-        // register admin pages
253
-        \EE_Register_Addon::_register_admin_pages($addon_name);
254
-        // add to list of modules to be registered
255
-        \EE_Register_Addon::_register_modules($addon_name);
256
-        // add to list of shortcodes to be registered
257
-        \EE_Register_Addon::_register_shortcodes($addon_name);
258
-        // add to list of widgets to be registered
259
-        \EE_Register_Addon::_register_widgets($addon_name);
260
-        // register capability related stuff.
261
-        \EE_Register_Addon::_register_capabilities($addon_name);
262
-        // any message type to register?
263
-        \EE_Register_Addon::_register_message_types($addon_name);
264
-        // any custom post type/ custom capabilities or default terms to register
265
-        \EE_Register_Addon::_register_custom_post_types($addon_name);
266
-        // and any payment methods
267
-        \EE_Register_Addon::_register_payment_methods($addon_name);
268
-        // load and instantiate main addon class
269
-        $addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name);
270
-        $addon->after_registration();
271
-    }
103
+	/**
104
+	 *    Method for registering new EE_Addons.
105
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
106
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
107
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
108
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
109
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
110
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
111
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
112
+	 * (so that we can detect that the addon has activated on the subsequent request)
113
+	 *
114
+	 * @since    4.3.0
115
+	 * @param string                  $addon_name                           the EE_Addon's name. Required.
116
+	 * @param  array                  $setup_args                           {                                    An
117
+	 *                                                                      array of arguments provided for registering
118
+	 *                                                                      the message type.
119
+	 * @type  string                  $class_name                           the addon's main file name.
120
+	 *                                                                      If left blank, generated from the addon
121
+	 *                                                                      name, changes something like "calendar" to
122
+	 *                                                                      "EE_Calendar"
123
+	 * @type string                   $min_core_version                     the minimum version of EE Core that the
124
+	 *       addon will work with. eg "4.8.1.rc.084"
125
+	 * @type string                   $version                              the "software" version for the addon. eg
126
+	 *       "1.0.0.p" for a first stable release, or "1.0.0.rc.043" for a version in progress
127
+	 * @type string                   $main_file_path                       the full server path to the main file
128
+	 *       loaded
129
+	 *                                                                      directly by WP
130
+	 * @type string                   $admin_path                           full server path to the folder where the
131
+	 *       addon\'s admin files reside
132
+	 * @type string                   $admin_callback                       a method to be called when the EE Admin is
133
+	 *       first invoked, can be used for hooking into any admin page
134
+	 * @type string                   $config_section                       the section name for this addon's
135
+	 *       configuration settings section (defaults to "addons")
136
+	 * @type string                   $config_class                         the class name for this addon's
137
+	 *       configuration settings object
138
+	 * @type string                   $config_name                          the class name for this addon's
139
+	 *       configuration settings object
140
+	 * @type string                   $autoloader_paths                     an array of class names and the full server
141
+	 *       paths to those files. Required.
142
+	 * @type string                   $autoloader_folders                   an array of  "full server paths" for any
143
+	 *       folders containing classes that might be invoked by the addon
144
+	 * @type string                   $dms_paths                            an array of full server paths to folders
145
+	 *       that contain data migration scripts. Required.
146
+	 * @type string                   $module_paths                         an array of full server paths to any
147
+	 *       EED_Modules used by the addon
148
+	 * @type string                   $shortcode_paths                      an array of full server paths to folders
149
+	 *       that contain EES_Shortcodes
150
+	 * @type string                   $widget_paths                         an array of full server paths to folders
151
+	 *       that contain WP_Widgets
152
+	 * @type string                   $pue_options
153
+	 * @type array                    $capabilities                         an array indexed by role name
154
+	 *                                                                      (i.e administrator,author ) and the values
155
+	 *                                                                      are an array of caps to add to the role.
156
+	 *                                                                      'administrator' => array(
157
+	 *                                                                      'read_addon', 'edit_addon', etc.
158
+	 *                                                                      ).
159
+	 * @type EE_Meta_Capability_Map[] $capability_maps                      an array of EE_Meta_Capability_Map object
160
+	 *       for any addons that need to register any special meta mapped capabilities.  Should be indexed where the
161
+	 *       key is the EE_Meta_Capability_Map class name and the values are the arguments sent to the class.
162
+	 * @type array                    $model_paths                          array of folders containing DB models
163
+	 * @see      EE_Register_Model
164
+	 * @type array                    $class_paths                          array of folders containing DB classes
165
+	 * @see      EE_Register_Model
166
+	 * @type array                    $model_extension_paths                array of folders containing DB model
167
+	 *       extensions
168
+	 * @see      EE_Register_Model_Extension
169
+	 * @type array                    $class_extension_paths                array of folders containing DB class
170
+	 *       extensions
171
+	 * @see      EE_Register_Model_Extension
172
+	 * @type array message_types {
173
+	 *                                                                      An array of message types with the key as
174
+	 *                                                                      the message type name and the values as
175
+	 *                                                                      below:
176
+	 * @type string                   $mtfilename                           The filename of the message type being
177
+	 *       registered. This will be the main EE_{Messagetype_Name}_message_type class.
178
+	 *                                                                      (eg.
179
+	 *                                                                      EE_Declined_Registration_message_type.class.php)
180
+	 *                                                                      Required.
181
+	 * @type array                    $autoloadpaths                        An array of paths to add to the messages
182
+	 *                                                                      autoloader for the new message type.
183
+	 *                                                                      Required.
184
+	 * @type array                    $messengers_to_activate_with          An array of messengers that this message
185
+	 *                                                                      type should activate with. Each value in
186
+	 *                                                                      the
187
+	 *                                                                      array
188
+	 *                                                                      should match the name property of a
189
+	 *                                                                      EE_messenger. Optional.
190
+	 * @type array                    $messengers_to_validate_with          An array of messengers that this message
191
+	 *                                                                      type should validate with. Each value in
192
+	 *                                                                      the
193
+	 *                                                                      array
194
+	 *                                                                      should match the name property of an
195
+	 *                                                                      EE_messenger.
196
+	 *                                                                      Optional.
197
+	 *                                                                      }
198
+	 * @type array                    $custom_post_types
199
+	 * @type array                    $custom_taxonomies
200
+	 * @type array                    $payment_method_paths                 each element is the folder containing the
201
+	 *                                                                      EE_PMT_Base child class
202
+	 *                                                                      (eg,
203
+	 *                                                                      '/wp-content/plugins/my_plugin/Payomatic/'
204
+	 *                                                                      which contains the files
205
+	 *                                                                      EE_PMT_Payomatic.pm.php)
206
+	 * @type array                    $default_terms
207
+	 * @type array                    $namespace                            {
208
+	 *                                                                      An array with two items for registering the
209
+	 *                                                                      addon's namespace. (If, for some reason,
210
+	 *                                                                      you
211
+	 *                                                                      require additional namespaces, use
212
+	 *                                                                      EventEspresso\core\Psr4Autoloader::addNamespace()
213
+	 *                                                                      directly)
214
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
215
+	 * @type string                   $FQNS                                 the namespace prefix
216
+	 * @type string                   $DIR                                  a base directory for class files in the
217
+	 *       namespace.
218
+	 *                                                                      }
219
+	 *                                                                      }
220
+	 * @throws EE_Error
221
+	 * @return void
222
+	 */
223
+	public static function register($addon_name = '', $setup_args = array())
224
+	{
225
+		// required fields MUST be present, so let's make sure they are.
226
+		\EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
227
+		// get class name for addon
228
+		$class_name = \EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
229
+		//setup $_settings array from incoming values.
230
+		$addon_settings = \EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
231
+		// setup PUE
232
+		\EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
233
+		// does this addon work with this version of core or WordPress ?
234
+		if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
235
+			return;
236
+		}
237
+		// register namespaces
238
+		\EE_Register_Addon::_setup_namespaces($addon_settings);
239
+		// check if this is an activation request
240
+		if (\EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
241
+			// dont bother setting up the rest of the addon atm
242
+			return;
243
+		}
244
+		// we need cars
245
+		\EE_Register_Addon::_setup_autoloaders($addon_name);
246
+		// register new models and extensions
247
+		\EE_Register_Addon::_register_models_and_extensions($addon_name);
248
+		// setup DMS
249
+		\EE_Register_Addon::_register_data_migration_scripts($addon_name);
250
+		// if config_class is present let's register config.
251
+		\EE_Register_Addon::_register_config($addon_name);
252
+		// register admin pages
253
+		\EE_Register_Addon::_register_admin_pages($addon_name);
254
+		// add to list of modules to be registered
255
+		\EE_Register_Addon::_register_modules($addon_name);
256
+		// add to list of shortcodes to be registered
257
+		\EE_Register_Addon::_register_shortcodes($addon_name);
258
+		// add to list of widgets to be registered
259
+		\EE_Register_Addon::_register_widgets($addon_name);
260
+		// register capability related stuff.
261
+		\EE_Register_Addon::_register_capabilities($addon_name);
262
+		// any message type to register?
263
+		\EE_Register_Addon::_register_message_types($addon_name);
264
+		// any custom post type/ custom capabilities or default terms to register
265
+		\EE_Register_Addon::_register_custom_post_types($addon_name);
266
+		// and any payment methods
267
+		\EE_Register_Addon::_register_payment_methods($addon_name);
268
+		// load and instantiate main addon class
269
+		$addon = \EE_Register_Addon::_load_and_init_addon_class($addon_name);
270
+		$addon->after_registration();
271
+	}
272 272
 
273 273
 
274
-    /**
275
-     * @param string $addon_name
276
-     * @param array  $setup_args
277
-     * @return void
278
-     * @throws \EE_Error
279
-     */
280
-    private static function _verify_parameters($addon_name, array $setup_args)
281
-    {
282
-        // required fields MUST be present, so let's make sure they are.
283
-        if (empty($addon_name) || ! is_array($setup_args)) {
284
-            throw new EE_Error(
285
-                __(
286
-                    'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
287
-                    'event_espresso'
288
-                )
289
-            );
290
-        }
291
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
292
-            throw new EE_Error(
293
-                sprintf(
294
-                    __(
295
-                        'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
296
-                        'event_espresso'
297
-                    ),
298
-                    implode(',', array_keys($setup_args))
299
-                )
300
-            );
301
-        }
302
-        // check that addon has not already been registered with that name
303
-        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
304
-            throw new EE_Error(
305
-                sprintf(
306
-                    __(
307
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
308
-                        'event_espresso'
309
-                    ),
310
-                    $addon_name
311
-                )
312
-            );
313
-        }
314
-    }
274
+	/**
275
+	 * @param string $addon_name
276
+	 * @param array  $setup_args
277
+	 * @return void
278
+	 * @throws \EE_Error
279
+	 */
280
+	private static function _verify_parameters($addon_name, array $setup_args)
281
+	{
282
+		// required fields MUST be present, so let's make sure they are.
283
+		if (empty($addon_name) || ! is_array($setup_args)) {
284
+			throw new EE_Error(
285
+				__(
286
+					'In order to register an EE_Addon with EE_Register_Addon::register(), you must include the "addon_name" (the name of the addon), and an array of arguments.',
287
+					'event_espresso'
288
+				)
289
+			);
290
+		}
291
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
292
+			throw new EE_Error(
293
+				sprintf(
294
+					__(
295
+						'When registering an addon, you didn\'t provide the "main_file_path", which is the full path to the main file loaded directly by Wordpress. You only provided %s',
296
+						'event_espresso'
297
+					),
298
+					implode(',', array_keys($setup_args))
299
+				)
300
+			);
301
+		}
302
+		// check that addon has not already been registered with that name
303
+		if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
304
+			throw new EE_Error(
305
+				sprintf(
306
+					__(
307
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
308
+						'event_espresso'
309
+					),
310
+					$addon_name
311
+				)
312
+			);
313
+		}
314
+	}
315 315
 
316 316
 
317
-    /**
318
-     * @param string $addon_name
319
-     * @param array  $setup_args
320
-     * @return string
321
-     */
322
-    private static function _parse_class_name($addon_name, array $setup_args)
323
-    {
324
-        if (empty($setup_args['class_name'])) {
325
-            // generate one by first separating name with spaces
326
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
327
-            //capitalize, then replace spaces with underscores
328
-            $class_name = str_replace(' ', '_', ucwords($class_name));
329
-        } else {
330
-            $class_name = $setup_args['class_name'];
331
-        }
332
-        return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
333
-    }
317
+	/**
318
+	 * @param string $addon_name
319
+	 * @param array  $setup_args
320
+	 * @return string
321
+	 */
322
+	private static function _parse_class_name($addon_name, array $setup_args)
323
+	{
324
+		if (empty($setup_args['class_name'])) {
325
+			// generate one by first separating name with spaces
326
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
327
+			//capitalize, then replace spaces with underscores
328
+			$class_name = str_replace(' ', '_', ucwords($class_name));
329
+		} else {
330
+			$class_name = $setup_args['class_name'];
331
+		}
332
+		return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
333
+	}
334 334
 
335 335
 
336
-    /**
337
-     * @param string $class_name
338
-     * @param array  $setup_args
339
-     * @return array
340
-     */
341
-    private static function _get_addon_settings($class_name, array $setup_args)
342
-    {
343
-        //setup $_settings array from incoming values.
344
-        $addon_settings = array(
345
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
346
-            'class_name'            => $class_name,
347
-            // the addon slug for use in URLs, etc
348
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
349
-                ? (string)$setup_args['plugin_slug']
350
-                : '',
351
-            // page slug to be used when generating the "Settings" link on the WP plugin page
352
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
353
-                ? (string)$setup_args['plugin_action_slug']
354
-                : '',
355
-            // the "software" version for the addon
356
-            'version'               => isset($setup_args['version'])
357
-                ? (string)$setup_args['version']
358
-                : '',
359
-            // the minimum version of EE Core that the addon will work with
360
-            'min_core_version'      => isset($setup_args['min_core_version'])
361
-                ? (string)$setup_args['min_core_version']
362
-                : '',
363
-            // the minimum version of WordPress that the addon will work with
364
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
365
-                ? (string)$setup_args['min_wp_version']
366
-                : EE_MIN_WP_VER_REQUIRED,
367
-            // full server path to main file (file loaded directly by WP)
368
-            'main_file_path'        => isset($setup_args['main_file_path'])
369
-                ? (string)$setup_args['main_file_path']
370
-                : '',
371
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
372
-            'admin_path'            => isset($setup_args['admin_path'])
373
-                ? (string)$setup_args['admin_path'] : '',
374
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
375
-            'admin_callback'        => isset($setup_args['admin_callback'])
376
-                ? (string)$setup_args['admin_callback']
377
-                : '',
378
-            // the section name for this addon's configuration settings section (defaults to "addons")
379
-            'config_section'        => isset($setup_args['config_section'])
380
-                ? (string)$setup_args['config_section']
381
-                : 'addons',
382
-            // the class name for this addon's configuration settings object
383
-            'config_class'          => isset($setup_args['config_class'])
384
-                ? (string)$setup_args['config_class'] : '',
385
-            //the name given to the config for this addons' configuration settings object (optional)
386
-            'config_name'           => isset($setup_args['config_name'])
387
-                ? (string)$setup_args['config_name'] : '',
388
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
389
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
390
-                ? (array)$setup_args['autoloader_paths']
391
-                : array(),
392
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
393
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
394
-                ? (array)$setup_args['autoloader_folders']
395
-                : array(),
396
-            // array of full server paths to any EE_DMS data migration scripts used by the addon
397
-            'dms_paths'             => isset($setup_args['dms_paths'])
398
-                ? (array)$setup_args['dms_paths']
399
-                : array(),
400
-            // array of full server paths to any EED_Modules used by the addon
401
-            'module_paths'          => isset($setup_args['module_paths'])
402
-                ? (array)$setup_args['module_paths']
403
-                : array(),
404
-            // array of full server paths to any EES_Shortcodes used by the addon
405
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
406
-                ? (array)$setup_args['shortcode_paths']
407
-                : array(),
408
-            // array of full server paths to any WP_Widgets used by the addon
409
-            'widget_paths'          => isset($setup_args['widget_paths'])
410
-                ? (array)$setup_args['widget_paths']
411
-                : array(),
412
-            // array of PUE options used by the addon
413
-            'pue_options'           => isset($setup_args['pue_options'])
414
-                ? (array)$setup_args['pue_options']
415
-                : array(),
416
-            'message_types'         => isset($setup_args['message_types'])
417
-                ? (array)$setup_args['message_types']
418
-                : array(),
419
-            'capabilities'          => isset($setup_args['capabilities'])
420
-                ? (array)$setup_args['capabilities']
421
-                : array(),
422
-            'capability_maps'       => isset($setup_args['capability_maps'])
423
-                ? (array)$setup_args['capability_maps']
424
-                : array(),
425
-            'model_paths'           => isset($setup_args['model_paths'])
426
-                ? (array)$setup_args['model_paths']
427
-                : array(),
428
-            'class_paths'           => isset($setup_args['class_paths'])
429
-                ? (array)$setup_args['class_paths']
430
-                : array(),
431
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
432
-                ? (array)$setup_args['model_extension_paths']
433
-                : array(),
434
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
435
-                ? (array)$setup_args['class_extension_paths']
436
-                : array(),
437
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
438
-                ? (array)$setup_args['custom_post_types']
439
-                : array(),
440
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
441
-                ? (array)$setup_args['custom_taxonomies']
442
-                : array(),
443
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
444
-                ? (array)$setup_args['payment_method_paths']
445
-                : array(),
446
-            'default_terms'         => isset($setup_args['default_terms'])
447
-                ? (array)$setup_args['default_terms']
448
-                : array(),
449
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
450
-            // that can be used for adding upgrading/marketing info
451
-            'plugins_page_row'      => isset($setup_args['plugins_page_row'])
452
-                ? $setup_args['plugins_page_row']
453
-                : '',
454
-            'namespace'             => isset(
455
-                $setup_args['namespace'],
456
-                $setup_args['namespace']['FQNS'],
457
-                $setup_args['namespace']['DIR']
458
-            )
459
-                ? (array)$setup_args['namespace']
460
-                : array(),
461
-        );
462
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
463
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
464
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
465
-                                                && ! empty($addon_settings['admin_path'])
466
-            ? $addon_settings['plugin_slug']
467
-            : $addon_settings['plugin_action_slug'];
468
-        // full server path to main file (file loaded directly by WP)
469
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
470
-        return $addon_settings;
471
-    }
336
+	/**
337
+	 * @param string $class_name
338
+	 * @param array  $setup_args
339
+	 * @return array
340
+	 */
341
+	private static function _get_addon_settings($class_name, array $setup_args)
342
+	{
343
+		//setup $_settings array from incoming values.
344
+		$addon_settings = array(
345
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
346
+			'class_name'            => $class_name,
347
+			// the addon slug for use in URLs, etc
348
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
349
+				? (string)$setup_args['plugin_slug']
350
+				: '',
351
+			// page slug to be used when generating the "Settings" link on the WP plugin page
352
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
353
+				? (string)$setup_args['plugin_action_slug']
354
+				: '',
355
+			// the "software" version for the addon
356
+			'version'               => isset($setup_args['version'])
357
+				? (string)$setup_args['version']
358
+				: '',
359
+			// the minimum version of EE Core that the addon will work with
360
+			'min_core_version'      => isset($setup_args['min_core_version'])
361
+				? (string)$setup_args['min_core_version']
362
+				: '',
363
+			// the minimum version of WordPress that the addon will work with
364
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
365
+				? (string)$setup_args['min_wp_version']
366
+				: EE_MIN_WP_VER_REQUIRED,
367
+			// full server path to main file (file loaded directly by WP)
368
+			'main_file_path'        => isset($setup_args['main_file_path'])
369
+				? (string)$setup_args['main_file_path']
370
+				: '',
371
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
372
+			'admin_path'            => isset($setup_args['admin_path'])
373
+				? (string)$setup_args['admin_path'] : '',
374
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
375
+			'admin_callback'        => isset($setup_args['admin_callback'])
376
+				? (string)$setup_args['admin_callback']
377
+				: '',
378
+			// the section name for this addon's configuration settings section (defaults to "addons")
379
+			'config_section'        => isset($setup_args['config_section'])
380
+				? (string)$setup_args['config_section']
381
+				: 'addons',
382
+			// the class name for this addon's configuration settings object
383
+			'config_class'          => isset($setup_args['config_class'])
384
+				? (string)$setup_args['config_class'] : '',
385
+			//the name given to the config for this addons' configuration settings object (optional)
386
+			'config_name'           => isset($setup_args['config_name'])
387
+				? (string)$setup_args['config_name'] : '',
388
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
389
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
390
+				? (array)$setup_args['autoloader_paths']
391
+				: array(),
392
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
393
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
394
+				? (array)$setup_args['autoloader_folders']
395
+				: array(),
396
+			// array of full server paths to any EE_DMS data migration scripts used by the addon
397
+			'dms_paths'             => isset($setup_args['dms_paths'])
398
+				? (array)$setup_args['dms_paths']
399
+				: array(),
400
+			// array of full server paths to any EED_Modules used by the addon
401
+			'module_paths'          => isset($setup_args['module_paths'])
402
+				? (array)$setup_args['module_paths']
403
+				: array(),
404
+			// array of full server paths to any EES_Shortcodes used by the addon
405
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
406
+				? (array)$setup_args['shortcode_paths']
407
+				: array(),
408
+			// array of full server paths to any WP_Widgets used by the addon
409
+			'widget_paths'          => isset($setup_args['widget_paths'])
410
+				? (array)$setup_args['widget_paths']
411
+				: array(),
412
+			// array of PUE options used by the addon
413
+			'pue_options'           => isset($setup_args['pue_options'])
414
+				? (array)$setup_args['pue_options']
415
+				: array(),
416
+			'message_types'         => isset($setup_args['message_types'])
417
+				? (array)$setup_args['message_types']
418
+				: array(),
419
+			'capabilities'          => isset($setup_args['capabilities'])
420
+				? (array)$setup_args['capabilities']
421
+				: array(),
422
+			'capability_maps'       => isset($setup_args['capability_maps'])
423
+				? (array)$setup_args['capability_maps']
424
+				: array(),
425
+			'model_paths'           => isset($setup_args['model_paths'])
426
+				? (array)$setup_args['model_paths']
427
+				: array(),
428
+			'class_paths'           => isset($setup_args['class_paths'])
429
+				? (array)$setup_args['class_paths']
430
+				: array(),
431
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
432
+				? (array)$setup_args['model_extension_paths']
433
+				: array(),
434
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
435
+				? (array)$setup_args['class_extension_paths']
436
+				: array(),
437
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
438
+				? (array)$setup_args['custom_post_types']
439
+				: array(),
440
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
441
+				? (array)$setup_args['custom_taxonomies']
442
+				: array(),
443
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
444
+				? (array)$setup_args['payment_method_paths']
445
+				: array(),
446
+			'default_terms'         => isset($setup_args['default_terms'])
447
+				? (array)$setup_args['default_terms']
448
+				: array(),
449
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
450
+			// that can be used for adding upgrading/marketing info
451
+			'plugins_page_row'      => isset($setup_args['plugins_page_row'])
452
+				? $setup_args['plugins_page_row']
453
+				: '',
454
+			'namespace'             => isset(
455
+				$setup_args['namespace'],
456
+				$setup_args['namespace']['FQNS'],
457
+				$setup_args['namespace']['DIR']
458
+			)
459
+				? (array)$setup_args['namespace']
460
+				: array(),
461
+		);
462
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
463
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
464
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
465
+												&& ! empty($addon_settings['admin_path'])
466
+			? $addon_settings['plugin_slug']
467
+			: $addon_settings['plugin_action_slug'];
468
+		// full server path to main file (file loaded directly by WP)
469
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
470
+		return $addon_settings;
471
+	}
472 472
 
473 473
 
474
-    /**
475
-     * @param string $addon_name
476
-     * @param array  $addon_settings
477
-     * @return boolean
478
-     */
479
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
480
-    {
481
-        global $wp_version;
482
-        $incompatibility_message = '';
483
-        //check whether this addon version is compatible with EE core
484
-        if (
485
-            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
486
-            && ! self::_meets_min_core_version_requirement(
487
-                EE_Register_Addon::$_incompatible_addons[$addon_name],
488
-                $addon_settings['version']
489
-            )
490
-        ) {
491
-            $incompatibility_message = sprintf(
492
-                __(
493
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.'
494
-                ),
495
-                $addon_name,
496
-                '<br />',
497
-                EE_Register_Addon::$_incompatible_addons[$addon_name],
498
-                '<span style="font-weight: bold; color: #D54E21;">',
499
-                '</span><br />'
500
-            );
501
-        } else if (
502
-        ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
503
-        ) {
504
-            $incompatibility_message = sprintf(
505
-                __(
506
-                    '%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
507
-                    'event_espresso'
508
-                ),
509
-                $addon_name,
510
-                self::_effective_version($addon_settings['min_core_version']),
511
-                self::_effective_version(espresso_version()),
512
-                '<br />',
513
-                '<span style="font-weight: bold; color: #D54E21;">',
514
-                '</span><br />'
515
-            );
516
-        } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
517
-            $incompatibility_message = sprintf(
518
-                __(
519
-                    '%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
520
-                    'event_espresso'
521
-                ),
522
-                $addon_name,
523
-                $addon_settings['min_wp_version'],
524
-                '<br />',
525
-                '<span style="font-weight: bold; color: #D54E21;">',
526
-                '</span><br />'
527
-            );
528
-        }
529
-        if (! empty($incompatibility_message)) {
530
-            // remove 'activate' from the REQUEST
531
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
532
-            unset($_GET['activate'], $_REQUEST['activate']);
533
-            if (current_user_can('activate_plugins')) {
534
-                // show an error message indicating the plugin didn't activate properly
535
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
536
-            }
537
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
538
-            return false;
539
-        }
540
-        // addon IS compatible
541
-        return true;
542
-    }
474
+	/**
475
+	 * @param string $addon_name
476
+	 * @param array  $addon_settings
477
+	 * @return boolean
478
+	 */
479
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
480
+	{
481
+		global $wp_version;
482
+		$incompatibility_message = '';
483
+		//check whether this addon version is compatible with EE core
484
+		if (
485
+			isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
486
+			&& ! self::_meets_min_core_version_requirement(
487
+				EE_Register_Addon::$_incompatible_addons[$addon_name],
488
+				$addon_settings['version']
489
+			)
490
+		) {
491
+			$incompatibility_message = sprintf(
492
+				__(
493
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon is not compatible with this version of Event Espresso.%2$sPlease upgrade your "%1$s" addon to version %3$s or newer to resolve this issue.'
494
+				),
495
+				$addon_name,
496
+				'<br />',
497
+				EE_Register_Addon::$_incompatible_addons[$addon_name],
498
+				'<span style="font-weight: bold; color: #D54E21;">',
499
+				'</span><br />'
500
+			);
501
+		} else if (
502
+		! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
503
+		) {
504
+			$incompatibility_message = sprintf(
505
+				__(
506
+					'%5$sIMPORTANT!%6$sThe Event Espresso "%1$s" addon requires Event Espresso Core version "%2$s" or higher in order to run.%4$sYour version of Event Espresso Core is currently at "%3$s". Please upgrade Event Espresso Core first and then re-activate "%1$s".',
507
+					'event_espresso'
508
+				),
509
+				$addon_name,
510
+				self::_effective_version($addon_settings['min_core_version']),
511
+				self::_effective_version(espresso_version()),
512
+				'<br />',
513
+				'<span style="font-weight: bold; color: #D54E21;">',
514
+				'</span><br />'
515
+			);
516
+		} else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
517
+			$incompatibility_message = sprintf(
518
+				__(
519
+					'%4$sIMPORTANT!%5$sThe Event Espresso "%1$s" addon requires WordPress version "%2$s" or greater.%3$sPlease update your version of WordPress to use the "%1$s" addon and to keep your site secure.',
520
+					'event_espresso'
521
+				),
522
+				$addon_name,
523
+				$addon_settings['min_wp_version'],
524
+				'<br />',
525
+				'<span style="font-weight: bold; color: #D54E21;">',
526
+				'</span><br />'
527
+			);
528
+		}
529
+		if (! empty($incompatibility_message)) {
530
+			// remove 'activate' from the REQUEST
531
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
532
+			unset($_GET['activate'], $_REQUEST['activate']);
533
+			if (current_user_can('activate_plugins')) {
534
+				// show an error message indicating the plugin didn't activate properly
535
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
536
+			}
537
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
538
+			return false;
539
+		}
540
+		// addon IS compatible
541
+		return true;
542
+	}
543 543
 
544 544
 
545
-    /**
546
-     * if plugin update engine is being used for auto-updates,
547
-     * then let's set that up now before going any further so that ALL addons can be updated
548
-     * (not needed if PUE is not being used)
549
-     *
550
-     * @param string $addon_name
551
-     * @param string $class_name
552
-     * @param array  $setup_args
553
-     * @return void
554
-     */
555
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
556
-    {
557
-        if (! empty($setup_args['pue_options'])) {
558
-            self::$_settings[$addon_name]['pue_options'] = array(
559
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
560
-                    ? (string)$setup_args['pue_options']['pue_plugin_slug']
561
-                    : 'espresso_' . strtolower($class_name),
562
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
563
-                    ? (string)$setup_args['pue_options']['plugin_basename']
564
-                    : plugin_basename($setup_args['main_file_path']),
565
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
566
-                    ? (string)$setup_args['pue_options']['checkPeriod']
567
-                    : '24',
568
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
569
-                    ? (string)$setup_args['pue_options']['use_wp_update']
570
-                    : false,
571
-            );
572
-            add_action(
573
-                'AHEE__EE_System__brew_espresso__after_pue_init',
574
-                array('EE_Register_Addon', 'load_pue_update')
575
-            );
576
-        }
577
-    }
545
+	/**
546
+	 * if plugin update engine is being used for auto-updates,
547
+	 * then let's set that up now before going any further so that ALL addons can be updated
548
+	 * (not needed if PUE is not being used)
549
+	 *
550
+	 * @param string $addon_name
551
+	 * @param string $class_name
552
+	 * @param array  $setup_args
553
+	 * @return void
554
+	 */
555
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
556
+	{
557
+		if (! empty($setup_args['pue_options'])) {
558
+			self::$_settings[$addon_name]['pue_options'] = array(
559
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
560
+					? (string)$setup_args['pue_options']['pue_plugin_slug']
561
+					: 'espresso_' . strtolower($class_name),
562
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
563
+					? (string)$setup_args['pue_options']['plugin_basename']
564
+					: plugin_basename($setup_args['main_file_path']),
565
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
566
+					? (string)$setup_args['pue_options']['checkPeriod']
567
+					: '24',
568
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
569
+					? (string)$setup_args['pue_options']['use_wp_update']
570
+					: false,
571
+			);
572
+			add_action(
573
+				'AHEE__EE_System__brew_espresso__after_pue_init',
574
+				array('EE_Register_Addon', 'load_pue_update')
575
+			);
576
+		}
577
+	}
578 578
 
579 579
 
580
-    /**
581
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
582
-     *
583
-     * @param array $addon_settings
584
-     * @return void
585
-     */
586
-    private static function _setup_namespaces(array $addon_settings)
587
-    {
588
-        //
589
-        if (
590
-        isset(
591
-            $addon_settings['namespace'],
592
-            $addon_settings['namespace']['FQNS'],
593
-            $addon_settings['namespace']['DIR']
594
-        )
595
-        ) {
596
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
597
-                $addon_settings['namespace']['FQNS'],
598
-                $addon_settings['namespace']['DIR']
599
-            );
600
-        }
601
-    }
580
+	/**
581
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
582
+	 *
583
+	 * @param array $addon_settings
584
+	 * @return void
585
+	 */
586
+	private static function _setup_namespaces(array $addon_settings)
587
+	{
588
+		//
589
+		if (
590
+		isset(
591
+			$addon_settings['namespace'],
592
+			$addon_settings['namespace']['FQNS'],
593
+			$addon_settings['namespace']['DIR']
594
+		)
595
+		) {
596
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
597
+				$addon_settings['namespace']['FQNS'],
598
+				$addon_settings['namespace']['DIR']
599
+			);
600
+		}
601
+	}
602 602
 
603 603
 
604
-    /**
605
-     * @param string $addon_name
606
-     * @param array  $addon_settings
607
-     * @return bool
608
-     */
609
-    private static function _addon_activation($addon_name, array $addon_settings)
610
-    {
611
-        // this is an activation request
612
-        if (did_action('activate_plugin')) {
613
-            //to find if THIS is the addon that was activated, just check if we have already registered it or not
614
-            //(as the newly-activated addon wasn't around the first time addons were registered).
615
-            //Note: the presence of pue_options in the addon registration options will initialize the $_settings
616
-            //property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
617
-            if (! isset(self::$_settings[$addon_name])
618
-                || (isset(self::$_settings[$addon_name])
619
-                    && ! isset(self::$_settings[$addon_name]['class_name'])
620
-                )
621
-            ) {
622
-                self::$_settings[$addon_name] = $addon_settings;
623
-                $addon                        = self::_load_and_init_addon_class($addon_name);
624
-                $addon->set_activation_indicator_option();
625
-                // dont bother setting up the rest of the addon.
626
-                // we know it was just activated and the request will end soon
627
-            }
628
-            return true;
629
-        }
630
-        // make sure this was called in the right place!
631
-        if (
632
-            ! did_action('AHEE__EE_System__load_espresso_addons')
633
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
634
-        ) {
635
-            EE_Error::doing_it_wrong(
636
-                __METHOD__,
637
-                sprintf(
638
-                    __(
639
-                        'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
640
-                        'event_espresso'
641
-                    ),
642
-                    $addon_name
643
-                ),
644
-                '4.3.0'
645
-            );
646
-        }
647
-        // make sure addon settings are set correctly without overwriting anything existing
648
-        if (isset(self::$_settings[$addon_name])) {
649
-            self::$_settings[$addon_name] += $addon_settings;
650
-        } else {
651
-            self::$_settings[$addon_name] = $addon_settings;
652
-        }
653
-        return false;
654
-    }
604
+	/**
605
+	 * @param string $addon_name
606
+	 * @param array  $addon_settings
607
+	 * @return bool
608
+	 */
609
+	private static function _addon_activation($addon_name, array $addon_settings)
610
+	{
611
+		// this is an activation request
612
+		if (did_action('activate_plugin')) {
613
+			//to find if THIS is the addon that was activated, just check if we have already registered it or not
614
+			//(as the newly-activated addon wasn't around the first time addons were registered).
615
+			//Note: the presence of pue_options in the addon registration options will initialize the $_settings
616
+			//property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
617
+			if (! isset(self::$_settings[$addon_name])
618
+				|| (isset(self::$_settings[$addon_name])
619
+					&& ! isset(self::$_settings[$addon_name]['class_name'])
620
+				)
621
+			) {
622
+				self::$_settings[$addon_name] = $addon_settings;
623
+				$addon                        = self::_load_and_init_addon_class($addon_name);
624
+				$addon->set_activation_indicator_option();
625
+				// dont bother setting up the rest of the addon.
626
+				// we know it was just activated and the request will end soon
627
+			}
628
+			return true;
629
+		}
630
+		// make sure this was called in the right place!
631
+		if (
632
+			! did_action('AHEE__EE_System__load_espresso_addons')
633
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
634
+		) {
635
+			EE_Error::doing_it_wrong(
636
+				__METHOD__,
637
+				sprintf(
638
+					__(
639
+						'An attempt to register an EE_Addon named "%s" has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__load_espresso_addons" hook to register addons.',
640
+						'event_espresso'
641
+					),
642
+					$addon_name
643
+				),
644
+				'4.3.0'
645
+			);
646
+		}
647
+		// make sure addon settings are set correctly without overwriting anything existing
648
+		if (isset(self::$_settings[$addon_name])) {
649
+			self::$_settings[$addon_name] += $addon_settings;
650
+		} else {
651
+			self::$_settings[$addon_name] = $addon_settings;
652
+		}
653
+		return false;
654
+	}
655 655
 
656 656
 
657
-    /**
658
-     * @param string $addon_name
659
-     * @return void
660
-     * @throws \EE_Error
661
-     */
662
-    private static function _setup_autoloaders($addon_name)
663
-    {
664
-        if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
665
-            // setup autoloader for single file
666
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
667
-        }
668
-        // setup autoloaders for folders
669
-        if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
670
-            foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
671
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
672
-            }
673
-        }
674
-    }
657
+	/**
658
+	 * @param string $addon_name
659
+	 * @return void
660
+	 * @throws \EE_Error
661
+	 */
662
+	private static function _setup_autoloaders($addon_name)
663
+	{
664
+		if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
665
+			// setup autoloader for single file
666
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
667
+		}
668
+		// setup autoloaders for folders
669
+		if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
670
+			foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
671
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
672
+			}
673
+		}
674
+	}
675 675
 
676 676
 
677
-    /**
678
-     * register new models and extensions
679
-     *
680
-     * @param string $addon_name
681
-     * @return void
682
-     * @throws \EE_Error
683
-     */
684
-    private static function _register_models_and_extensions($addon_name)
685
-    {
686
-        // register new models
687
-        if (
688
-            ! empty(self::$_settings[$addon_name]['model_paths'])
689
-            || ! empty(self::$_settings[$addon_name]['class_paths'])
690
-        ) {
691
-            EE_Register_Model::register(
692
-                $addon_name,
693
-                array(
694
-                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
695
-                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
696
-                )
697
-            );
698
-        }
699
-        // register model extensions
700
-        if (
701
-            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
702
-            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
703
-        ) {
704
-            EE_Register_Model_Extensions::register(
705
-                $addon_name,
706
-                array(
707
-                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
708
-                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
709
-                )
710
-            );
711
-        }
712
-    }
677
+	/**
678
+	 * register new models and extensions
679
+	 *
680
+	 * @param string $addon_name
681
+	 * @return void
682
+	 * @throws \EE_Error
683
+	 */
684
+	private static function _register_models_and_extensions($addon_name)
685
+	{
686
+		// register new models
687
+		if (
688
+			! empty(self::$_settings[$addon_name]['model_paths'])
689
+			|| ! empty(self::$_settings[$addon_name]['class_paths'])
690
+		) {
691
+			EE_Register_Model::register(
692
+				$addon_name,
693
+				array(
694
+					'model_paths' => self::$_settings[$addon_name]['model_paths'],
695
+					'class_paths' => self::$_settings[$addon_name]['class_paths'],
696
+				)
697
+			);
698
+		}
699
+		// register model extensions
700
+		if (
701
+			! empty(self::$_settings[$addon_name]['model_extension_paths'])
702
+			|| ! empty(self::$_settings[$addon_name]['class_extension_paths'])
703
+		) {
704
+			EE_Register_Model_Extensions::register(
705
+				$addon_name,
706
+				array(
707
+					'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
708
+					'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
709
+				)
710
+			);
711
+		}
712
+	}
713 713
 
714 714
 
715
-    /**
716
-     * @param string $addon_name
717
-     * @return void
718
-     * @throws \EE_Error
719
-     */
720
-    private static function _register_data_migration_scripts($addon_name)
721
-    {
722
-        // setup DMS
723
-        if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
724
-            EE_Register_Data_Migration_Scripts::register(
725
-                $addon_name,
726
-                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
727
-            );
728
-        }
729
-    }
715
+	/**
716
+	 * @param string $addon_name
717
+	 * @return void
718
+	 * @throws \EE_Error
719
+	 */
720
+	private static function _register_data_migration_scripts($addon_name)
721
+	{
722
+		// setup DMS
723
+		if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
724
+			EE_Register_Data_Migration_Scripts::register(
725
+				$addon_name,
726
+				array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
727
+			);
728
+		}
729
+	}
730 730
 
731 731
 
732
-    /**
733
-     * @param string $addon_name
734
-     * @return void
735
-     * @throws \EE_Error
736
-     */
737
-    private static function _register_config($addon_name)
738
-    {
739
-        // if config_class is present let's register config.
740
-        if (! empty(self::$_settings[$addon_name]['config_class'])) {
741
-            EE_Register_Config::register(
742
-                self::$_settings[$addon_name]['config_class'],
743
-                array(
744
-                    'config_section' => self::$_settings[$addon_name]['config_section'],
745
-                    'config_name'    => self::$_settings[$addon_name]['config_name'],
746
-                )
747
-            );
748
-        }
749
-    }
732
+	/**
733
+	 * @param string $addon_name
734
+	 * @return void
735
+	 * @throws \EE_Error
736
+	 */
737
+	private static function _register_config($addon_name)
738
+	{
739
+		// if config_class is present let's register config.
740
+		if (! empty(self::$_settings[$addon_name]['config_class'])) {
741
+			EE_Register_Config::register(
742
+				self::$_settings[$addon_name]['config_class'],
743
+				array(
744
+					'config_section' => self::$_settings[$addon_name]['config_section'],
745
+					'config_name'    => self::$_settings[$addon_name]['config_name'],
746
+				)
747
+			);
748
+		}
749
+	}
750 750
 
751 751
 
752
-    /**
753
-     * @param string $addon_name
754
-     * @return void
755
-     * @throws \EE_Error
756
-     */
757
-    private static function _register_admin_pages($addon_name)
758
-    {
759
-        if (! empty(self::$_settings[$addon_name]['admin_path'])) {
760
-            EE_Register_Admin_Page::register(
761
-                $addon_name,
762
-                array('page_path' => self::$_settings[$addon_name]['admin_path'])
763
-            );
764
-        }
765
-    }
752
+	/**
753
+	 * @param string $addon_name
754
+	 * @return void
755
+	 * @throws \EE_Error
756
+	 */
757
+	private static function _register_admin_pages($addon_name)
758
+	{
759
+		if (! empty(self::$_settings[$addon_name]['admin_path'])) {
760
+			EE_Register_Admin_Page::register(
761
+				$addon_name,
762
+				array('page_path' => self::$_settings[$addon_name]['admin_path'])
763
+			);
764
+		}
765
+	}
766 766
 
767 767
 
768
-    /**
769
-     * @param string $addon_name
770
-     * @return void
771
-     * @throws \EE_Error
772
-     */
773
-    private static function _register_modules($addon_name)
774
-    {
775
-        if (! empty(self::$_settings[$addon_name]['module_paths'])) {
776
-            EE_Register_Module::register(
777
-                $addon_name,
778
-                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
779
-            );
780
-        }
781
-    }
768
+	/**
769
+	 * @param string $addon_name
770
+	 * @return void
771
+	 * @throws \EE_Error
772
+	 */
773
+	private static function _register_modules($addon_name)
774
+	{
775
+		if (! empty(self::$_settings[$addon_name]['module_paths'])) {
776
+			EE_Register_Module::register(
777
+				$addon_name,
778
+				array('module_paths' => self::$_settings[$addon_name]['module_paths'])
779
+			);
780
+		}
781
+	}
782 782
 
783 783
 
784
-    /**
785
-     * @param string $addon_name
786
-     * @return void
787
-     * @throws \EE_Error
788
-     */
789
-    private static function _register_shortcodes($addon_name)
790
-    {
791
-        if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
792
-            EE_Register_Shortcode::register(
793
-                $addon_name,
794
-                array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])
795
-            );
796
-        }
797
-    }
784
+	/**
785
+	 * @param string $addon_name
786
+	 * @return void
787
+	 * @throws \EE_Error
788
+	 */
789
+	private static function _register_shortcodes($addon_name)
790
+	{
791
+		if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
792
+			EE_Register_Shortcode::register(
793
+				$addon_name,
794
+				array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])
795
+			);
796
+		}
797
+	}
798 798
 
799 799
 
800
-    /**
801
-     * @param string $addon_name
802
-     * @return void
803
-     * @throws \EE_Error
804
-     */
805
-    private static function _register_widgets($addon_name)
806
-    {
807
-        if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
808
-            EE_Register_Widget::register(
809
-                $addon_name,
810
-                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
811
-            );
812
-        }
813
-    }
800
+	/**
801
+	 * @param string $addon_name
802
+	 * @return void
803
+	 * @throws \EE_Error
804
+	 */
805
+	private static function _register_widgets($addon_name)
806
+	{
807
+		if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
808
+			EE_Register_Widget::register(
809
+				$addon_name,
810
+				array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
811
+			);
812
+		}
813
+	}
814 814
 
815 815
 
816
-    /**
817
-     * @param string $addon_name
818
-     * @return void
819
-     * @throws \EE_Error
820
-     */
821
-    private static function _register_capabilities($addon_name)
822
-    {
823
-        if (! empty(self::$_settings[$addon_name]['capabilities'])) {
824
-            EE_Register_Capabilities::register(
825
-                $addon_name,
826
-                array(
827
-                    'capabilities'       => self::$_settings[$addon_name]['capabilities'],
828
-                    'capability_maps'    => self::$_settings[$addon_name]['capability_maps'],
829
-                )
830
-            );
831
-        }
832
-    }
816
+	/**
817
+	 * @param string $addon_name
818
+	 * @return void
819
+	 * @throws \EE_Error
820
+	 */
821
+	private static function _register_capabilities($addon_name)
822
+	{
823
+		if (! empty(self::$_settings[$addon_name]['capabilities'])) {
824
+			EE_Register_Capabilities::register(
825
+				$addon_name,
826
+				array(
827
+					'capabilities'       => self::$_settings[$addon_name]['capabilities'],
828
+					'capability_maps'    => self::$_settings[$addon_name]['capability_maps'],
829
+				)
830
+			);
831
+		}
832
+	}
833 833
 
834 834
 
835
-    /**
836
-     * @param string $addon_name
837
-     * @return void
838
-     * @throws \EE_Error
839
-     */
840
-    private static function _register_message_types($addon_name)
841
-    {
842
-        if (! empty(self::$_settings[$addon_name]['message_types'])) {
843
-            add_action(
844
-                'EE_Brewing_Regular___messages_caf',
845
-                array('EE_Register_Addon', 'register_message_types')
846
-            );
847
-        }
848
-    }
835
+	/**
836
+	 * @param string $addon_name
837
+	 * @return void
838
+	 * @throws \EE_Error
839
+	 */
840
+	private static function _register_message_types($addon_name)
841
+	{
842
+		if (! empty(self::$_settings[$addon_name]['message_types'])) {
843
+			add_action(
844
+				'EE_Brewing_Regular___messages_caf',
845
+				array('EE_Register_Addon', 'register_message_types')
846
+			);
847
+		}
848
+	}
849 849
 
850 850
 
851
-    /**
852
-     * @param string $addon_name
853
-     * @return void
854
-     * @throws \EE_Error
855
-     */
856
-    private static function _register_custom_post_types($addon_name)
857
-    {
858
-        if (
859
-            ! empty(self::$_settings[$addon_name]['custom_post_types'])
860
-            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
861
-        ) {
862
-            EE_Register_CPT::register(
863
-                $addon_name,
864
-                array(
865
-                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
866
-                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
867
-                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
868
-                )
869
-            );
870
-        }
871
-    }
851
+	/**
852
+	 * @param string $addon_name
853
+	 * @return void
854
+	 * @throws \EE_Error
855
+	 */
856
+	private static function _register_custom_post_types($addon_name)
857
+	{
858
+		if (
859
+			! empty(self::$_settings[$addon_name]['custom_post_types'])
860
+			|| ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
861
+		) {
862
+			EE_Register_CPT::register(
863
+				$addon_name,
864
+				array(
865
+					'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
866
+					'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
867
+					'default_terms' => self::$_settings[$addon_name]['default_terms'],
868
+				)
869
+			);
870
+		}
871
+	}
872 872
 
873 873
 
874
-    /**
875
-     * @param string $addon_name
876
-     * @return void
877
-     * @throws \EE_Error
878
-     */
879
-    private static function _register_payment_methods($addon_name)
880
-    {
881
-        if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
882
-            EE_Register_Payment_Method::register(
883
-                $addon_name,
884
-                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
885
-            );
886
-        }
887
-    }
874
+	/**
875
+	 * @param string $addon_name
876
+	 * @return void
877
+	 * @throws \EE_Error
878
+	 */
879
+	private static function _register_payment_methods($addon_name)
880
+	{
881
+		if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
882
+			EE_Register_Payment_Method::register(
883
+				$addon_name,
884
+				array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
885
+			);
886
+		}
887
+	}
888 888
 
889 889
 
890
-    /**
891
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
892
-     *
893
-     * @param string $addon_name
894
-     * @return EE_Addon
895
-     */
896
-    private static function _load_and_init_addon_class($addon_name)
897
-    {
898
-        $addon = EE_Registry::instance()->load_addon(
899
-            dirname(self::$_settings[$addon_name]['main_file_path']),
900
-            self::$_settings[$addon_name]['class_name']
901
-        );
902
-        $addon->set_name($addon_name);
903
-        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
904
-        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
905
-        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
906
-        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
907
-        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
908
-        $addon->set_version(self::$_settings[$addon_name]['version']);
909
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
910
-        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
911
-        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
912
-        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
913
-        //unfortunately this can't be hooked in upon construction, because we don't have
914
-        //the plugin mainfile's path upon construction.
915
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
916
-        // call any additional admin_callback functions during load_admin_controller hook
917
-        if (! empty(self::$_settings[$addon_name]['admin_callback'])) {
918
-            add_action(
919
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
920
-                array($addon, self::$_settings[$addon_name]['admin_callback'])
921
-            );
922
-        }
923
-        return $addon;
924
-    }
890
+	/**
891
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
892
+	 *
893
+	 * @param string $addon_name
894
+	 * @return EE_Addon
895
+	 */
896
+	private static function _load_and_init_addon_class($addon_name)
897
+	{
898
+		$addon = EE_Registry::instance()->load_addon(
899
+			dirname(self::$_settings[$addon_name]['main_file_path']),
900
+			self::$_settings[$addon_name]['class_name']
901
+		);
902
+		$addon->set_name($addon_name);
903
+		$addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
904
+		$addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
905
+		$addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
906
+		$addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
907
+		$addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
908
+		$addon->set_version(self::$_settings[$addon_name]['version']);
909
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
910
+		$addon->set_config_section(self::$_settings[$addon_name]['config_section']);
911
+		$addon->set_config_class(self::$_settings[$addon_name]['config_class']);
912
+		$addon->set_config_name(self::$_settings[$addon_name]['config_name']);
913
+		//unfortunately this can't be hooked in upon construction, because we don't have
914
+		//the plugin mainfile's path upon construction.
915
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
916
+		// call any additional admin_callback functions during load_admin_controller hook
917
+		if (! empty(self::$_settings[$addon_name]['admin_callback'])) {
918
+			add_action(
919
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
920
+				array($addon, self::$_settings[$addon_name]['admin_callback'])
921
+			);
922
+		}
923
+		return $addon;
924
+	}
925 925
 
926 926
 
927
-    /**
928
-     *    load_pue_update - Update notifications
929
-     *
930
-     * @return    void
931
-     */
932
-    public static function load_pue_update()
933
-    {
934
-        // load PUE client
935
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
936
-        // cycle thru settings
937
-        foreach (self::$_settings as $settings) {
938
-            if (! empty($settings['pue_options'])) {
939
-                // initiate the class and start the plugin update engine!
940
-                new PluginUpdateEngineChecker(
941
-                // host file URL
942
-                    'https://eventespresso.com',
943
-                    // plugin slug(s)
944
-                    array(
945
-                        'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
946
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
947
-                    ),
948
-                    // options
949
-                    array(
950
-                        'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
951
-                        'lang_domain'       => 'event_espresso',
952
-                        'checkPeriod'       => $settings['pue_options']['checkPeriod'],
953
-                        'option_key'        => 'site_license_key',
954
-                        'options_page_slug' => 'event_espresso',
955
-                        'plugin_basename'   => $settings['pue_options']['plugin_basename'],
956
-                        // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
957
-                        'use_wp_update'     => $settings['pue_options']['use_wp_update'],
958
-                    )
959
-                );
960
-            }
961
-        }
962
-    }
927
+	/**
928
+	 *    load_pue_update - Update notifications
929
+	 *
930
+	 * @return    void
931
+	 */
932
+	public static function load_pue_update()
933
+	{
934
+		// load PUE client
935
+		require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
936
+		// cycle thru settings
937
+		foreach (self::$_settings as $settings) {
938
+			if (! empty($settings['pue_options'])) {
939
+				// initiate the class and start the plugin update engine!
940
+				new PluginUpdateEngineChecker(
941
+				// host file URL
942
+					'https://eventespresso.com',
943
+					// plugin slug(s)
944
+					array(
945
+						'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
946
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
947
+					),
948
+					// options
949
+					array(
950
+						'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
951
+						'lang_domain'       => 'event_espresso',
952
+						'checkPeriod'       => $settings['pue_options']['checkPeriod'],
953
+						'option_key'        => 'site_license_key',
954
+						'options_page_slug' => 'event_espresso',
955
+						'plugin_basename'   => $settings['pue_options']['plugin_basename'],
956
+						// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
957
+						'use_wp_update'     => $settings['pue_options']['use_wp_update'],
958
+					)
959
+				);
960
+			}
961
+		}
962
+	}
963 963
 
964 964
 
965
-    /**
966
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
967
-     *
968
-     * @since 4.4.0
969
-     * @return void
970
-     * @throws \EE_Error
971
-     */
972
-    public static function register_message_types()
973
-    {
974
-        foreach (self::$_settings as $addon_name => $settings) {
975
-            if (! empty($settings['message_types'])) {
976
-                foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
977
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
978
-                }
979
-            }
980
-        }
981
-    }
965
+	/**
966
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
967
+	 *
968
+	 * @since 4.4.0
969
+	 * @return void
970
+	 * @throws \EE_Error
971
+	 */
972
+	public static function register_message_types()
973
+	{
974
+		foreach (self::$_settings as $addon_name => $settings) {
975
+			if (! empty($settings['message_types'])) {
976
+				foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
977
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
978
+				}
979
+			}
980
+		}
981
+	}
982 982
 
983 983
 
984
-    /**
985
-     * This deregisters an addon that was previously registered with a specific addon_name.
986
-     *
987
-     * @since    4.3.0
988
-     * @param string $addon_name the name for the addon that was previously registered
989
-     * @throws EE_Error
990
-     * @return void
991
-     */
992
-    public static function deregister($addon_name = null)
993
-    {
994
-        if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) {
995
-            do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
996
-            $class_name = self::$_settings[$addon_name]['class_name'];
997
-            if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
998
-                // setup DMS
999
-                EE_Register_Data_Migration_Scripts::deregister($addon_name);
1000
-            }
1001
-            if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1002
-                // register admin page
1003
-                EE_Register_Admin_Page::deregister($addon_name);
1004
-            }
1005
-            if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1006
-                // add to list of modules to be registered
1007
-                EE_Register_Module::deregister($addon_name);
1008
-            }
1009
-            if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
1010
-                // add to list of shortcodes to be registered
1011
-                EE_Register_Shortcode::deregister($addon_name);
1012
-            }
1013
-            if (! empty(self::$_settings[$addon_name]['config_class'])) {
1014
-                // if config_class present let's register config.
1015
-                EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1016
-            }
1017
-            if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1018
-                // add to list of widgets to be registered
1019
-                EE_Register_Widget::deregister($addon_name);
1020
-            }
1021
-            if (! empty(self::$_settings[$addon_name]['model_paths'])
1022
-                ||
1023
-                ! empty(self::$_settings[$addon_name]['class_paths'])
1024
-            ) {
1025
-                // add to list of shortcodes to be registered
1026
-                EE_Register_Model::deregister($addon_name);
1027
-            }
1028
-            if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1029
-                ||
1030
-                ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1031
-            ) {
1032
-                // add to list of shortcodes to be registered
1033
-                EE_Register_Model_Extensions::deregister($addon_name);
1034
-            }
1035
-            if (! empty(self::$_settings[$addon_name]['message_types'])) {
1036
-                foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1037
-                    EE_Register_Message_Type::deregister($message_type);
1038
-                }
1039
-            }
1040
-            //deregister capabilities for addon
1041
-            if (
1042
-                ! empty(self::$_settings[$addon_name]['capabilities'])
1043
-                || ! empty(self::$_settings[$addon_name]['capability_maps'])
1044
-            ) {
1045
-                EE_Register_Capabilities::deregister($addon_name);
1046
-            }
1047
-            //deregister custom_post_types for addon
1048
-            if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1049
-                EE_Register_CPT::deregister($addon_name);
1050
-            }
1051
-            if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1052
-                EE_Register_Payment_Method::deregister($addon_name);
1053
-            }
1054
-            remove_action(
1055
-                'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1056
-                array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')
1057
-            );
1058
-            remove_action(
1059
-                'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1060
-                array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')
1061
-            );
1062
-            unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]);
1063
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1064
-        }
1065
-    }
984
+	/**
985
+	 * This deregisters an addon that was previously registered with a specific addon_name.
986
+	 *
987
+	 * @since    4.3.0
988
+	 * @param string $addon_name the name for the addon that was previously registered
989
+	 * @throws EE_Error
990
+	 * @return void
991
+	 */
992
+	public static function deregister($addon_name = null)
993
+	{
994
+		if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) {
995
+			do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
996
+			$class_name = self::$_settings[$addon_name]['class_name'];
997
+			if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
998
+				// setup DMS
999
+				EE_Register_Data_Migration_Scripts::deregister($addon_name);
1000
+			}
1001
+			if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1002
+				// register admin page
1003
+				EE_Register_Admin_Page::deregister($addon_name);
1004
+			}
1005
+			if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1006
+				// add to list of modules to be registered
1007
+				EE_Register_Module::deregister($addon_name);
1008
+			}
1009
+			if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
1010
+				// add to list of shortcodes to be registered
1011
+				EE_Register_Shortcode::deregister($addon_name);
1012
+			}
1013
+			if (! empty(self::$_settings[$addon_name]['config_class'])) {
1014
+				// if config_class present let's register config.
1015
+				EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1016
+			}
1017
+			if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1018
+				// add to list of widgets to be registered
1019
+				EE_Register_Widget::deregister($addon_name);
1020
+			}
1021
+			if (! empty(self::$_settings[$addon_name]['model_paths'])
1022
+				||
1023
+				! empty(self::$_settings[$addon_name]['class_paths'])
1024
+			) {
1025
+				// add to list of shortcodes to be registered
1026
+				EE_Register_Model::deregister($addon_name);
1027
+			}
1028
+			if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1029
+				||
1030
+				! empty(self::$_settings[$addon_name]['class_extension_paths'])
1031
+			) {
1032
+				// add to list of shortcodes to be registered
1033
+				EE_Register_Model_Extensions::deregister($addon_name);
1034
+			}
1035
+			if (! empty(self::$_settings[$addon_name]['message_types'])) {
1036
+				foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1037
+					EE_Register_Message_Type::deregister($message_type);
1038
+				}
1039
+			}
1040
+			//deregister capabilities for addon
1041
+			if (
1042
+				! empty(self::$_settings[$addon_name]['capabilities'])
1043
+				|| ! empty(self::$_settings[$addon_name]['capability_maps'])
1044
+			) {
1045
+				EE_Register_Capabilities::deregister($addon_name);
1046
+			}
1047
+			//deregister custom_post_types for addon
1048
+			if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1049
+				EE_Register_CPT::deregister($addon_name);
1050
+			}
1051
+			if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1052
+				EE_Register_Payment_Method::deregister($addon_name);
1053
+			}
1054
+			remove_action(
1055
+				'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1056
+				array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')
1057
+			);
1058
+			remove_action(
1059
+				'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1060
+				array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')
1061
+			);
1062
+			unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]);
1063
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1064
+		}
1065
+	}
1066 1066
 
1067 1067
 
1068 1068
 }
Please login to merge, or discard this patch.
Spacing   +76 added lines, -76 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (! defined('EVENT_ESPRESSO_VERSION')) {
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2 2
     exit('No direct script access allowed');
3 3
 }
4 4
 
@@ -66,15 +66,15 @@  discard block
 block discarded – undo
66 66
         // offsets:    0 . 1 . 2 . 3 . 4
67 67
         $version_parts = explode('.', $min_core_version);
68 68
         //check they specified the micro version (after 2nd period)
69
-        if (! isset($version_parts[2])) {
69
+        if ( ! isset($version_parts[2])) {
70 70
             $version_parts[2] = '0';
71 71
         }
72 72
         //if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
73 73
         //soon we can assume that's 'rc', but this current version is 'alpha'
74
-        if (! isset($version_parts[3])) {
74
+        if ( ! isset($version_parts[3])) {
75 75
             $version_parts[3] = 'dev';
76 76
         }
77
-        if (! isset($version_parts[4])) {
77
+        if ( ! isset($version_parts[4])) {
78 78
             $version_parts[4] = '000';
79 79
         }
80 80
         return implode('.', $version_parts);
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
         // setup PUE
232 232
         \EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
233 233
         // does this addon work with this version of core or WordPress ?
234
-        if (! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
234
+        if ( ! \EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
235 235
             return;
236 236
         }
237 237
         // register namespaces
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
                 )
289 289
             );
290 290
         }
291
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
291
+        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
292 292
             throw new EE_Error(
293 293
                 sprintf(
294 294
                     __(
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
         } else {
330 330
             $class_name = $setup_args['class_name'];
331 331
         }
332
-        return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
332
+        return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_'.$class_name;
333 333
     }
334 334
 
335 335
 
@@ -346,105 +346,105 @@  discard block
 block discarded – undo
346 346
             'class_name'            => $class_name,
347 347
             // the addon slug for use in URLs, etc
348 348
             'plugin_slug'           => isset($setup_args['plugin_slug'])
349
-                ? (string)$setup_args['plugin_slug']
349
+                ? (string) $setup_args['plugin_slug']
350 350
                 : '',
351 351
             // page slug to be used when generating the "Settings" link on the WP plugin page
352 352
             'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
353
-                ? (string)$setup_args['plugin_action_slug']
353
+                ? (string) $setup_args['plugin_action_slug']
354 354
                 : '',
355 355
             // the "software" version for the addon
356 356
             'version'               => isset($setup_args['version'])
357
-                ? (string)$setup_args['version']
357
+                ? (string) $setup_args['version']
358 358
                 : '',
359 359
             // the minimum version of EE Core that the addon will work with
360 360
             'min_core_version'      => isset($setup_args['min_core_version'])
361
-                ? (string)$setup_args['min_core_version']
361
+                ? (string) $setup_args['min_core_version']
362 362
                 : '',
363 363
             // the minimum version of WordPress that the addon will work with
364 364
             'min_wp_version'        => isset($setup_args['min_wp_version'])
365
-                ? (string)$setup_args['min_wp_version']
365
+                ? (string) $setup_args['min_wp_version']
366 366
                 : EE_MIN_WP_VER_REQUIRED,
367 367
             // full server path to main file (file loaded directly by WP)
368 368
             'main_file_path'        => isset($setup_args['main_file_path'])
369
-                ? (string)$setup_args['main_file_path']
369
+                ? (string) $setup_args['main_file_path']
370 370
                 : '',
371 371
             // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
372 372
             'admin_path'            => isset($setup_args['admin_path'])
373
-                ? (string)$setup_args['admin_path'] : '',
373
+                ? (string) $setup_args['admin_path'] : '',
374 374
             // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
375 375
             'admin_callback'        => isset($setup_args['admin_callback'])
376
-                ? (string)$setup_args['admin_callback']
376
+                ? (string) $setup_args['admin_callback']
377 377
                 : '',
378 378
             // the section name for this addon's configuration settings section (defaults to "addons")
379 379
             'config_section'        => isset($setup_args['config_section'])
380
-                ? (string)$setup_args['config_section']
380
+                ? (string) $setup_args['config_section']
381 381
                 : 'addons',
382 382
             // the class name for this addon's configuration settings object
383 383
             'config_class'          => isset($setup_args['config_class'])
384
-                ? (string)$setup_args['config_class'] : '',
384
+                ? (string) $setup_args['config_class'] : '',
385 385
             //the name given to the config for this addons' configuration settings object (optional)
386 386
             'config_name'           => isset($setup_args['config_name'])
387
-                ? (string)$setup_args['config_name'] : '',
387
+                ? (string) $setup_args['config_name'] : '',
388 388
             // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
389 389
             'autoloader_paths'      => isset($setup_args['autoloader_paths'])
390
-                ? (array)$setup_args['autoloader_paths']
390
+                ? (array) $setup_args['autoloader_paths']
391 391
                 : array(),
392 392
             // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
393 393
             'autoloader_folders'    => isset($setup_args['autoloader_folders'])
394
-                ? (array)$setup_args['autoloader_folders']
394
+                ? (array) $setup_args['autoloader_folders']
395 395
                 : array(),
396 396
             // array of full server paths to any EE_DMS data migration scripts used by the addon
397 397
             'dms_paths'             => isset($setup_args['dms_paths'])
398
-                ? (array)$setup_args['dms_paths']
398
+                ? (array) $setup_args['dms_paths']
399 399
                 : array(),
400 400
             // array of full server paths to any EED_Modules used by the addon
401 401
             'module_paths'          => isset($setup_args['module_paths'])
402
-                ? (array)$setup_args['module_paths']
402
+                ? (array) $setup_args['module_paths']
403 403
                 : array(),
404 404
             // array of full server paths to any EES_Shortcodes used by the addon
405 405
             'shortcode_paths'       => isset($setup_args['shortcode_paths'])
406
-                ? (array)$setup_args['shortcode_paths']
406
+                ? (array) $setup_args['shortcode_paths']
407 407
                 : array(),
408 408
             // array of full server paths to any WP_Widgets used by the addon
409 409
             'widget_paths'          => isset($setup_args['widget_paths'])
410
-                ? (array)$setup_args['widget_paths']
410
+                ? (array) $setup_args['widget_paths']
411 411
                 : array(),
412 412
             // array of PUE options used by the addon
413 413
             'pue_options'           => isset($setup_args['pue_options'])
414
-                ? (array)$setup_args['pue_options']
414
+                ? (array) $setup_args['pue_options']
415 415
                 : array(),
416 416
             'message_types'         => isset($setup_args['message_types'])
417
-                ? (array)$setup_args['message_types']
417
+                ? (array) $setup_args['message_types']
418 418
                 : array(),
419 419
             'capabilities'          => isset($setup_args['capabilities'])
420
-                ? (array)$setup_args['capabilities']
420
+                ? (array) $setup_args['capabilities']
421 421
                 : array(),
422 422
             'capability_maps'       => isset($setup_args['capability_maps'])
423
-                ? (array)$setup_args['capability_maps']
423
+                ? (array) $setup_args['capability_maps']
424 424
                 : array(),
425 425
             'model_paths'           => isset($setup_args['model_paths'])
426
-                ? (array)$setup_args['model_paths']
426
+                ? (array) $setup_args['model_paths']
427 427
                 : array(),
428 428
             'class_paths'           => isset($setup_args['class_paths'])
429
-                ? (array)$setup_args['class_paths']
429
+                ? (array) $setup_args['class_paths']
430 430
                 : array(),
431 431
             'model_extension_paths' => isset($setup_args['model_extension_paths'])
432
-                ? (array)$setup_args['model_extension_paths']
432
+                ? (array) $setup_args['model_extension_paths']
433 433
                 : array(),
434 434
             'class_extension_paths' => isset($setup_args['class_extension_paths'])
435
-                ? (array)$setup_args['class_extension_paths']
435
+                ? (array) $setup_args['class_extension_paths']
436 436
                 : array(),
437 437
             'custom_post_types'     => isset($setup_args['custom_post_types'])
438
-                ? (array)$setup_args['custom_post_types']
438
+                ? (array) $setup_args['custom_post_types']
439 439
                 : array(),
440 440
             'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
441
-                ? (array)$setup_args['custom_taxonomies']
441
+                ? (array) $setup_args['custom_taxonomies']
442 442
                 : array(),
443 443
             'payment_method_paths'  => isset($setup_args['payment_method_paths'])
444
-                ? (array)$setup_args['payment_method_paths']
444
+                ? (array) $setup_args['payment_method_paths']
445 445
                 : array(),
446 446
             'default_terms'         => isset($setup_args['default_terms'])
447
-                ? (array)$setup_args['default_terms']
447
+                ? (array) $setup_args['default_terms']
448 448
                 : array(),
449 449
             // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
450 450
             // that can be used for adding upgrading/marketing info
@@ -456,7 +456,7 @@  discard block
 block discarded – undo
456 456
                 $setup_args['namespace']['FQNS'],
457 457
                 $setup_args['namespace']['DIR']
458 458
             )
459
-                ? (array)$setup_args['namespace']
459
+                ? (array) $setup_args['namespace']
460 460
                 : array(),
461 461
         );
462 462
         // if plugin_action_slug is NOT set, but an admin page path IS set,
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
                 '</span><br />'
527 527
             );
528 528
         }
529
-        if (! empty($incompatibility_message)) {
529
+        if ( ! empty($incompatibility_message)) {
530 530
             // remove 'activate' from the REQUEST
531 531
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
532 532
             unset($_GET['activate'], $_REQUEST['activate']);
@@ -554,19 +554,19 @@  discard block
 block discarded – undo
554 554
      */
555 555
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
556 556
     {
557
-        if (! empty($setup_args['pue_options'])) {
557
+        if ( ! empty($setup_args['pue_options'])) {
558 558
             self::$_settings[$addon_name]['pue_options'] = array(
559 559
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
560
-                    ? (string)$setup_args['pue_options']['pue_plugin_slug']
561
-                    : 'espresso_' . strtolower($class_name),
560
+                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
561
+                    : 'espresso_'.strtolower($class_name),
562 562
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
563
-                    ? (string)$setup_args['pue_options']['plugin_basename']
563
+                    ? (string) $setup_args['pue_options']['plugin_basename']
564 564
                     : plugin_basename($setup_args['main_file_path']),
565 565
                 'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
566
-                    ? (string)$setup_args['pue_options']['checkPeriod']
566
+                    ? (string) $setup_args['pue_options']['checkPeriod']
567 567
                     : '24',
568 568
                 'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
569
-                    ? (string)$setup_args['pue_options']['use_wp_update']
569
+                    ? (string) $setup_args['pue_options']['use_wp_update']
570 570
                     : false,
571 571
             );
572 572
             add_action(
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
             //(as the newly-activated addon wasn't around the first time addons were registered).
615 615
             //Note: the presence of pue_options in the addon registration options will initialize the $_settings
616 616
             //property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
617
-            if (! isset(self::$_settings[$addon_name])
617
+            if ( ! isset(self::$_settings[$addon_name])
618 618
                 || (isset(self::$_settings[$addon_name])
619 619
                     && ! isset(self::$_settings[$addon_name]['class_name'])
620 620
                 )
@@ -661,13 +661,13 @@  discard block
 block discarded – undo
661 661
      */
662 662
     private static function _setup_autoloaders($addon_name)
663 663
     {
664
-        if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
664
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
665 665
             // setup autoloader for single file
666 666
             EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
667 667
         }
668 668
         // setup autoloaders for folders
669
-        if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
670
-            foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
669
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
670
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
671 671
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
672 672
             }
673 673
         }
@@ -720,7 +720,7 @@  discard block
 block discarded – undo
720 720
     private static function _register_data_migration_scripts($addon_name)
721 721
     {
722 722
         // setup DMS
723
-        if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
723
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
724 724
             EE_Register_Data_Migration_Scripts::register(
725 725
                 $addon_name,
726 726
                 array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
     private static function _register_config($addon_name)
738 738
     {
739 739
         // if config_class is present let's register config.
740
-        if (! empty(self::$_settings[$addon_name]['config_class'])) {
740
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
741 741
             EE_Register_Config::register(
742 742
                 self::$_settings[$addon_name]['config_class'],
743 743
                 array(
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
      */
757 757
     private static function _register_admin_pages($addon_name)
758 758
     {
759
-        if (! empty(self::$_settings[$addon_name]['admin_path'])) {
759
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
760 760
             EE_Register_Admin_Page::register(
761 761
                 $addon_name,
762 762
                 array('page_path' => self::$_settings[$addon_name]['admin_path'])
@@ -772,7 +772,7 @@  discard block
 block discarded – undo
772 772
      */
773 773
     private static function _register_modules($addon_name)
774 774
     {
775
-        if (! empty(self::$_settings[$addon_name]['module_paths'])) {
775
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
776 776
             EE_Register_Module::register(
777 777
                 $addon_name,
778 778
                 array('module_paths' => self::$_settings[$addon_name]['module_paths'])
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
      */
789 789
     private static function _register_shortcodes($addon_name)
790 790
     {
791
-        if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
791
+        if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
792 792
             EE_Register_Shortcode::register(
793 793
                 $addon_name,
794 794
                 array('shortcode_paths' => self::$_settings[$addon_name]['shortcode_paths'])
@@ -804,7 +804,7 @@  discard block
 block discarded – undo
804 804
      */
805 805
     private static function _register_widgets($addon_name)
806 806
     {
807
-        if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
807
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
808 808
             EE_Register_Widget::register(
809 809
                 $addon_name,
810 810
                 array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
@@ -820,7 +820,7 @@  discard block
 block discarded – undo
820 820
      */
821 821
     private static function _register_capabilities($addon_name)
822 822
     {
823
-        if (! empty(self::$_settings[$addon_name]['capabilities'])) {
823
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
824 824
             EE_Register_Capabilities::register(
825 825
                 $addon_name,
826 826
                 array(
@@ -839,7 +839,7 @@  discard block
 block discarded – undo
839 839
      */
840 840
     private static function _register_message_types($addon_name)
841 841
     {
842
-        if (! empty(self::$_settings[$addon_name]['message_types'])) {
842
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
843 843
             add_action(
844 844
                 'EE_Brewing_Regular___messages_caf',
845 845
                 array('EE_Register_Addon', 'register_message_types')
@@ -878,7 +878,7 @@  discard block
 block discarded – undo
878 878
      */
879 879
     private static function _register_payment_methods($addon_name)
880 880
     {
881
-        if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
881
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
882 882
             EE_Register_Payment_Method::register(
883 883
                 $addon_name,
884 884
                 array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
@@ -914,7 +914,7 @@  discard block
 block discarded – undo
914 914
         //the plugin mainfile's path upon construction.
915 915
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
916 916
         // call any additional admin_callback functions during load_admin_controller hook
917
-        if (! empty(self::$_settings[$addon_name]['admin_callback'])) {
917
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
918 918
             add_action(
919 919
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
920 920
                 array($addon, self::$_settings[$addon_name]['admin_callback'])
@@ -932,10 +932,10 @@  discard block
 block discarded – undo
932 932
     public static function load_pue_update()
933 933
     {
934 934
         // load PUE client
935
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
935
+        require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php';
936 936
         // cycle thru settings
937 937
         foreach (self::$_settings as $settings) {
938
-            if (! empty($settings['pue_options'])) {
938
+            if ( ! empty($settings['pue_options'])) {
939 939
                 // initiate the class and start the plugin update engine!
940 940
                 new PluginUpdateEngineChecker(
941 941
                 // host file URL
@@ -943,7 +943,7 @@  discard block
 block discarded – undo
943 943
                     // plugin slug(s)
944 944
                     array(
945 945
                         'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
946
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
946
+                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
947 947
                     ),
948 948
                     // options
949 949
                     array(
@@ -972,8 +972,8 @@  discard block
 block discarded – undo
972 972
     public static function register_message_types()
973 973
     {
974 974
         foreach (self::$_settings as $addon_name => $settings) {
975
-            if (! empty($settings['message_types'])) {
976
-                foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
975
+            if ( ! empty($settings['message_types'])) {
976
+                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
977 977
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
978 978
                 }
979 979
             }
@@ -994,46 +994,46 @@  discard block
 block discarded – undo
994 994
         if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) {
995 995
             do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
996 996
             $class_name = self::$_settings[$addon_name]['class_name'];
997
-            if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
997
+            if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
998 998
                 // setup DMS
999 999
                 EE_Register_Data_Migration_Scripts::deregister($addon_name);
1000 1000
             }
1001
-            if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1001
+            if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1002 1002
                 // register admin page
1003 1003
                 EE_Register_Admin_Page::deregister($addon_name);
1004 1004
             }
1005
-            if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1005
+            if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1006 1006
                 // add to list of modules to be registered
1007 1007
                 EE_Register_Module::deregister($addon_name);
1008 1008
             }
1009
-            if (! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
1009
+            if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])) {
1010 1010
                 // add to list of shortcodes to be registered
1011 1011
                 EE_Register_Shortcode::deregister($addon_name);
1012 1012
             }
1013
-            if (! empty(self::$_settings[$addon_name]['config_class'])) {
1013
+            if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1014 1014
                 // if config_class present let's register config.
1015 1015
                 EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1016 1016
             }
1017
-            if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1017
+            if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1018 1018
                 // add to list of widgets to be registered
1019 1019
                 EE_Register_Widget::deregister($addon_name);
1020 1020
             }
1021
-            if (! empty(self::$_settings[$addon_name]['model_paths'])
1021
+            if ( ! empty(self::$_settings[$addon_name]['model_paths'])
1022 1022
                 ||
1023 1023
                 ! empty(self::$_settings[$addon_name]['class_paths'])
1024 1024
             ) {
1025 1025
                 // add to list of shortcodes to be registered
1026 1026
                 EE_Register_Model::deregister($addon_name);
1027 1027
             }
1028
-            if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1028
+            if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1029 1029
                 ||
1030 1030
                 ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1031 1031
             ) {
1032 1032
                 // add to list of shortcodes to be registered
1033 1033
                 EE_Register_Model_Extensions::deregister($addon_name);
1034 1034
             }
1035
-            if (! empty(self::$_settings[$addon_name]['message_types'])) {
1036
-                foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1035
+            if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1036
+                foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1037 1037
                     EE_Register_Message_Type::deregister($message_type);
1038 1038
                 }
1039 1039
             }
@@ -1045,14 +1045,14 @@  discard block
 block discarded – undo
1045 1045
                 EE_Register_Capabilities::deregister($addon_name);
1046 1046
             }
1047 1047
             //deregister custom_post_types for addon
1048
-            if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1048
+            if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1049 1049
                 EE_Register_CPT::deregister($addon_name);
1050 1050
             }
1051
-            if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1051
+            if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1052 1052
                 EE_Register_Payment_Method::deregister($addon_name);
1053 1053
             }
1054 1054
             remove_action(
1055
-                'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1055
+                'deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1056 1056
                 array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')
1057 1057
             );
1058 1058
             remove_action(
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 2 patches
Spacing   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
     /**
21 21
      * prefix added to all payment method capabilities names
22 22
      */
23
-    const   CAPABILITIES_PREFIX= 'ee_payment_method_';
23
+    const   CAPABILITIES_PREFIX = 'ee_payment_method_';
24 24
 
25 25
     /**
26 26
      * @var EE_Payment_Method_Manager $_instance
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
     public static function instance()
77 77
     {
78 78
         // check if class object is instantiated, and instantiated properly
79
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
79
+        if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
80 80
             EE_Registry::instance()->load_lib('PMT_Base');
81 81
             self::$_instance = new self();
82 82
         }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function maybe_register_payment_methods($force_recheck = false)
111 111
     {
112
-        if (! $this->_payment_method_types || $force_recheck) {
112
+        if ( ! $this->_payment_method_types || $force_recheck) {
113 113
             $this->_register_payment_methods();
114 114
         }
115 115
     }
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
     protected function _register_payment_methods()
125 125
     {
126 126
         // grab list of installed modules
127
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
127
+        $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
128 128
         // filter list of modules to register
129 129
         $pm_to_register = apply_filters(
130 130
             'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
@@ -165,31 +165,31 @@  discard block
 block discarded – undo
165 165
         // create class name from module directory name
166 166
         $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
167 167
         // add class prefix
168
-        $module_class = 'EE_PMT_' . $module;
168
+        $module_class = 'EE_PMT_'.$module;
169 169
         // does the module exist ?
170
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
170
+        if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) {
171 171
             $msg = sprintf(
172 172
                 esc_html__(
173 173
                     'The requested %s payment method file could not be found or is not readable due to file permissions.',
174 174
                     'event_espresso'
175 175
                 ), $module
176 176
             );
177
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
177
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
178 178
             return false;
179 179
         }
180 180
         // load the module class file
181
-        require_once($payment_method_path . DS . $module_class . $module_ext);
181
+        require_once($payment_method_path.DS.$module_class.$module_ext);
182 182
         // verify that class exists
183
-        if (! class_exists($module_class)) {
183
+        if ( ! class_exists($module_class)) {
184 184
             $msg = sprintf(
185 185
                 esc_html__('The requested %s module class does not exist.', 'event_espresso'),
186 186
                 $module_class
187 187
             );
188
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
188
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
189 189
             return false;
190 190
         }
191 191
         // add to array of registered modules
192
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
192
+        $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext;
193 193
         return true;
194 194
     }
195 195
 
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
         if ($force_recheck || empty($this->payment_method_objects)) {
257 257
             $this->maybe_register_payment_methods($force_recheck);
258 258
             foreach ($this->payment_method_type_names(true) as $classname) {
259
-                if (! isset($this->payment_method_objects[$classname])) {
259
+                if ( ! isset($this->payment_method_objects[$classname])) {
260 260
                     $this->payment_method_objects[$classname] = new $classname;
261 261
                 }
262 262
             }
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
      */
289 289
     public function payment_method_class_from_type($type)
290 290
     {
291
-        return 'EE_PMT_' . $type;
291
+        return 'EE_PMT_'.$type;
292 292
     }
293 293
 
294 294
 
@@ -304,13 +304,13 @@  discard block
 block discarded – undo
304 304
     {
305 305
         $this->maybe_register_payment_methods();
306 306
         $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
307
-        if (! $payment_method instanceof EE_Payment_Method) {
307
+        if ( ! $payment_method instanceof EE_Payment_Method) {
308 308
             $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
309 309
             if (class_exists($pm_type_class)) {
310 310
                 /** @var $pm_type_obj EE_PMT_Base */
311 311
                 $pm_type_obj = new $pm_type_class;
312 312
                 $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
313
-                if (! $payment_method) {
313
+                if ( ! $payment_method) {
314 314
                     $payment_method = $this->create_payment_method_of_type($pm_type_obj);
315 315
                 }
316 316
                 $payment_method->set_type($payment_method_type);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
                         'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
342 342
                         'event_espresso'
343 343
                     ),
344
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
344
+                    '<a href="'.admin_url('admin.php?page=espresso_messages').'">',
345 345
                     '</a>'
346 346
                 ),
347 347
                 true
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
                 'PMD_type'       => $pm_type_obj->system_name(),
369 369
                 'PMD_name'       => $pm_type_obj->pretty_name(),
370 370
                 'PMD_admin_name' => $pm_type_obj->pretty_name(),
371
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
371
+                'PMD_slug'       => $pm_type_obj->system_name(), //automatically converted to slug
372 372
                 'PMD_wp_user'    => $current_user->ID,
373 373
                 'PMD_order'      => EEM_Payment_Method::instance()->count(
374 374
                         array(array('PMD_type' => array('!=', 'Admin_Only')))
@@ -391,14 +391,14 @@  discard block
 block discarded – undo
391 391
     {
392 392
         $pm_type_obj = $payment_method->type_obj();
393 393
         $payment_method->set_description($pm_type_obj->default_description());
394
-        if (! $payment_method->button_url()) {
394
+        if ( ! $payment_method->button_url()) {
395 395
             $payment_method->set_button_url($pm_type_obj->default_button_url());
396 396
         }
397 397
         //now add setup its default extra meta properties
398 398
         $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
399
-        if (! empty($extra_metas)) {
399
+        if ( ! empty($extra_metas)) {
400 400
             //verify the payment method has an ID before adding extra meta
401
-            if (! $payment_method->ID()) {
401
+            if ( ! $payment_method->ID()) {
402 402
                 $payment_method->save();
403 403
             }
404 404
             foreach ($extra_metas as $meta_name => $input) {
@@ -506,7 +506,7 @@  discard block
 block discarded – undo
506 506
     {
507 507
         $caps = array();
508 508
         foreach ($this->payment_method_type_names() as $payment_method_name) {
509
-            $caps = $this->addPaymentMethodCap($payment_method_name,$caps);
509
+            $caps = $this->addPaymentMethodCap($payment_method_name, $caps);
510 510
         }
511 511
         return $caps;
512 512
     }
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
                 )
542 542
             );
543 543
         }
544
-        if(! isset($payment_method_caps[$role])) {
544
+        if ( ! isset($payment_method_caps[$role])) {
545 545
             $payment_method_caps[$role] = array();
546 546
         }
547 547
         $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
Please login to merge, or discard this patch.
Indentation   +564 added lines, -564 removed lines patch added patch discarded remove patch
@@ -19,570 +19,570 @@
 block discarded – undo
19 19
 class EE_Payment_Method_Manager implements ResettableInterface
20 20
 {
21 21
 
22
-    /**
23
-     * prefix added to all payment method capabilities names
24
-     */
25
-    const   CAPABILITIES_PREFIX= 'ee_payment_method_';
26
-
27
-    /**
28
-     * @var EE_Payment_Method_Manager $_instance
29
-     */
30
-    private static $_instance;
31
-
32
-    /**
33
-     * @var boolean
34
-     */
35
-    protected $payment_method_caps_initialized = false;
36
-
37
-    /**
38
-     * @var array keys are class names without 'EE_PMT_', values are their filepaths
39
-     */
40
-    protected $_payment_method_types = array();
41
-
42
-    /**
43
-     * @var EE_PMT_Base[]
44
-     */
45
-    protected $payment_method_objects = array();
46
-
47
-
48
-
49
-    /**
50
-     * EE_Payment_Method_Manager constructor.
51
-     *
52
-     * @throws EE_Error
53
-     * @throws DomainException
54
-     */
55
-    public function __construct()
56
-    {
57
-        // if in admin lets ensure caps are set.
58
-        if (is_admin()) {
59
-            $this->_register_payment_methods();
60
-            // set them immediately
61
-            $this->initializePaymentMethodCaps();
62
-            // plus any time they get reset
63
-            add_filter(
64
-                'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
65
-                array($this, 'addPaymentMethodCapsDuringReset')
66
-            );
67
-        }
68
-    }
69
-
70
-
71
-
72
-    /**
73
-     * @singleton method used to instantiate class object
74
-     * @return EE_Payment_Method_Manager instance
75
-     * @throws DomainException
76
-     * @throws EE_Error
77
-     */
78
-    public static function instance()
79
-    {
80
-        // check if class object is instantiated, and instantiated properly
81
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
82
-            EE_Registry::instance()->load_lib('PMT_Base');
83
-            self::$_instance = new self();
84
-        }
85
-        return self::$_instance;
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * Resets the instance and returns a new one
92
-     *
93
-     * @return EE_Payment_Method_Manager
94
-     * @throws DomainException
95
-     * @throws EE_Error
96
-     */
97
-    public static function reset()
98
-    {
99
-        self::$_instance = null;
100
-        return self::instance();
101
-    }
102
-
103
-
104
-
105
-    /**
106
-     * If necessary, re-register payment methods
107
-     *
108
-     * @param boolean $force_recheck whether to recheck for payment method types,
109
-     *                               or just re-use the PMTs we found last time we checked during this request (if
110
-     *                               we have not yet checked during this request, then we need to check anyways)
111
-     */
112
-    public function maybe_register_payment_methods($force_recheck = false)
113
-    {
114
-        if (! $this->_payment_method_types || $force_recheck) {
115
-            $this->_register_payment_methods();
116
-        }
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * register_payment_methods
123
-     *
124
-     * @return array
125
-     */
126
-    protected function _register_payment_methods()
127
-    {
128
-        // grab list of installed modules
129
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
130
-        // filter list of modules to register
131
-        $pm_to_register = apply_filters(
132
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
133
-            $pm_to_register
134
-        );
135
-        // remove any duplicates if that should happen for some reason
136
-        $pm_to_register = array_unique($pm_to_register);
137
-        // loop through folders
138
-        foreach ($pm_to_register as $pm_path) {
139
-            $this->register_payment_method($pm_path);
140
-        }
141
-        do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
142
-        // filter list of installed modules
143
-        //keep them organized alphabetically by the payment method type's name
144
-        ksort($this->_payment_method_types);
145
-        return apply_filters(
146
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
147
-            $this->_payment_method_types
148
-        );
149
-    }
150
-
151
-
152
-
153
-    /**
154
-     * register_payment_method- makes core aware of this payment method
155
-     *
156
-     * @param string $payment_method_path - full path up to and including payment method folder
157
-     * @return boolean
158
-     */
159
-    public function register_payment_method($payment_method_path = '')
160
-    {
161
-        do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
162
-        $module_ext = '.pm.php';
163
-        // make all separators match
164
-        $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
165
-        // grab and sanitize module name
166
-        $module_dir = basename($payment_method_path);
167
-        // create class name from module directory name
168
-        $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
169
-        // add class prefix
170
-        $module_class = 'EE_PMT_' . $module;
171
-        // does the module exist ?
172
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
173
-            $msg = sprintf(
174
-                esc_html__(
175
-                    'The requested %s payment method file could not be found or is not readable due to file permissions.',
176
-                    'event_espresso'
177
-                ), $module
178
-            );
179
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
180
-            return false;
181
-        }
182
-        // load the module class file
183
-        require_once($payment_method_path . DS . $module_class . $module_ext);
184
-        // verify that class exists
185
-        if (! class_exists($module_class)) {
186
-            $msg = sprintf(
187
-                esc_html__('The requested %s module class does not exist.', 'event_espresso'),
188
-                $module_class
189
-            );
190
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
191
-            return false;
192
-        }
193
-        // add to array of registered modules
194
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
195
-        return true;
196
-    }
197
-
198
-
199
-
200
-    /**
201
-     * Checks if a payment method has been registered, and if so includes it
202
-     *
203
-     * @param string  $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_')
204
-     * @param boolean $force_recheck       whether to force re-checking for new payment method types
205
-     * @return boolean
206
-     */
207
-    public function payment_method_type_exists($payment_method_name, $force_recheck = false)
208
-    {
209
-        if (
210
-            $force_recheck
211
-            || ! is_array($this->_payment_method_types)
212
-            || ! isset($this->_payment_method_types[$payment_method_name])
213
-        ) {
214
-            $this->maybe_register_payment_methods($force_recheck);
215
-        }
216
-        if (isset($this->_payment_method_types[$payment_method_name])) {
217
-            require_once($this->_payment_method_types[$payment_method_name]);
218
-            return true;
219
-        }
220
-        return false;
221
-    }
222
-
223
-
224
-
225
-    /**
226
-     * Returns all the class names of the various payment method types
227
-     *
228
-     * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
229
-     *                               (what you'd find in wp_esp_payment_method.PMD_type)
230
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
231
-     * @return array
232
-     */
233
-    public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
234
-    {
235
-        $this->maybe_register_payment_methods($force_recheck);
236
-        if ($with_prefixes) {
237
-            $classnames = array_keys($this->_payment_method_types);
238
-            $payment_methods = array();
239
-            foreach ($classnames as $classname) {
240
-                $payment_methods[] = $this->payment_method_class_from_type($classname);
241
-            }
242
-            return $payment_methods;
243
-        }
244
-        return array_keys($this->_payment_method_types);
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Gets an object of each payment method type, none of which are bound to a
251
-     * payment method instance
252
-     *
253
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
254
-     * @return EE_PMT_Base[]
255
-     */
256
-    public function payment_method_types($force_recheck = false)
257
-    {
258
-        if ($force_recheck || empty($this->payment_method_objects)) {
259
-            $this->maybe_register_payment_methods($force_recheck);
260
-            foreach ($this->payment_method_type_names(true) as $classname) {
261
-                if (! isset($this->payment_method_objects[$classname])) {
262
-                    $this->payment_method_objects[$classname] = new $classname;
263
-                }
264
-            }
265
-        }
266
-        return $this->payment_method_objects;
267
-    }
268
-
269
-
270
-
271
-    /**
272
-     * Changes the payment method's class name into the payment method type's name
273
-     * (as used on the payment method's table's PMD_type field)
274
-     *
275
-     * @param string $classname
276
-     * @return string
277
-     */
278
-    public function payment_method_type_sans_class_prefix($classname)
279
-    {
280
-        return str_replace('EE_PMT_', '', $classname);
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * Does the opposite of payment-method_type_sans_prefix
287
-     *
288
-     * @param string $type
289
-     * @return string
290
-     */
291
-    public function payment_method_class_from_type($type)
292
-    {
293
-        return 'EE_PMT_' . $type;
294
-    }
295
-
296
-
297
-
298
-    /**
299
-     * Activates a payment method of the given type.
300
-     *
301
-     * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
302
-     * @return EE_Payment_Method
303
-     * @throws EE_Error
304
-     */
305
-    public function activate_a_payment_method_of_type($payment_method_type)
306
-    {
307
-        $this->maybe_register_payment_methods();
308
-        $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
309
-        if (! $payment_method instanceof EE_Payment_Method) {
310
-            $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
311
-            if (class_exists($pm_type_class)) {
312
-                /** @var $pm_type_obj EE_PMT_Base */
313
-                $pm_type_obj = new $pm_type_class;
314
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
315
-                if (! $payment_method) {
316
-                    $payment_method = $this->create_payment_method_of_type($pm_type_obj);
317
-                }
318
-                $payment_method->set_type($payment_method_type);
319
-                $this->initialize_payment_method($payment_method);
320
-            } else {
321
-                throw new EE_Error(
322
-                    sprintf(
323
-                        esc_html__(
324
-                            'There is no payment method of type %1$s, so it could not be activated',
325
-                            'event_espresso'
326
-                        ),
327
-                        $pm_type_class
328
-                    )
329
-                );
330
-            }
331
-        }
332
-        $payment_method->set_active();
333
-        $payment_method->save();
334
-        if ($payment_method->type() === 'Invoice') {
335
-            /** @type EE_Message_Resource_Manager $message_resource_manager */
336
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
337
-            $message_resource_manager->ensure_message_type_is_active('invoice', 'html');
338
-            $message_resource_manager->ensure_messenger_is_active('pdf');
339
-            EE_Error::add_persistent_admin_notice(
340
-                'invoice_pm_requirements_notice',
341
-                sprintf(
342
-                    esc_html__(
343
-                        'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
344
-                        'event_espresso'
345
-                    ),
346
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
347
-                    '</a>'
348
-                ),
349
-                true
350
-            );
351
-        }
352
-        return $payment_method;
353
-    }
354
-
355
-
356
-
357
-    /**
358
-     * Creates a payment method of the specified type. Does not save it.
359
-     *
360
-     * @global WP_User    $current_user
361
-     * @param EE_PMT_Base $pm_type_obj
362
-     * @return EE_Payment_Method
363
-     * @throws EE_Error
364
-     */
365
-    public function create_payment_method_of_type($pm_type_obj)
366
-    {
367
-        global $current_user;
368
-        $payment_method = EE_Payment_Method::new_instance(
369
-            array(
370
-                'PMD_type'       => $pm_type_obj->system_name(),
371
-                'PMD_name'       => $pm_type_obj->pretty_name(),
372
-                'PMD_admin_name' => $pm_type_obj->pretty_name(),
373
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
374
-                'PMD_wp_user'    => $current_user->ID,
375
-                'PMD_order'      => EEM_Payment_Method::instance()->count(
376
-                        array(array('PMD_type' => array('!=', 'Admin_Only')))
377
-                    ) * 10,
378
-            )
379
-        );
380
-        return $payment_method;
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * Sets the initial payment method properties (including extra meta)
387
-     *
388
-     * @param EE_Payment_Method $payment_method
389
-     * @return EE_Payment_Method
390
-     * @throws EE_Error
391
-     */
392
-    public function initialize_payment_method($payment_method)
393
-    {
394
-        $pm_type_obj = $payment_method->type_obj();
395
-        $payment_method->set_description($pm_type_obj->default_description());
396
-        if (! $payment_method->button_url()) {
397
-            $payment_method->set_button_url($pm_type_obj->default_button_url());
398
-        }
399
-        //now add setup its default extra meta properties
400
-        $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
401
-        if (! empty($extra_metas)) {
402
-            //verify the payment method has an ID before adding extra meta
403
-            if (! $payment_method->ID()) {
404
-                $payment_method->save();
405
-            }
406
-            foreach ($extra_metas as $meta_name => $input) {
407
-                $payment_method->update_extra_meta($meta_name, $input->raw_value());
408
-            }
409
-        }
410
-        return $payment_method;
411
-    }
412
-
413
-
414
-
415
-    /**
416
-     * Makes sure the payment method is related to the specified payment method
417
-     *
418
-     * @deprecated in 4.9.40 because the currency payment method table is being deprecated
419
-     * @param EE_Payment_Method $payment_method
420
-     * @return EE_Payment_Method
421
-     * @throws EE_Error
422
-     */
423
-    public function set_usable_currencies_on_payment_method($payment_method)
424
-    {
425
-        EE_Error::doing_it_wrong(
426
-            'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
427
-            esc_html__(
428
-                'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
429
-                'event_espresso'
430
-            ),
431
-            '4.9.40'
432
-        );
433
-        return $payment_method;
434
-    }
435
-
436
-
437
-
438
-    /**
439
-     * Deactivates a payment method of the given payment method slug.
440
-     *
441
-     * @param string $payment_method_slug The slug for the payment method to deactivate.
442
-     * @return int count of rows updated.
443
-     * @throws EE_Error
444
-     */
445
-    public function deactivate_payment_method($payment_method_slug)
446
-    {
447
-        EE_Log::instance()->log(
448
-            __FILE__,
449
-            __FUNCTION__,
450
-            sprintf(
451
-                esc_html__(
452
-                    'Payment method with slug %1$s is being deactivated by site admin',
453
-                    'event_espresso'
454
-                ),
455
-                $payment_method_slug
456
-            ),
457
-            'payment_method_change'
458
-        );
459
-        $count_updated = EEM_Payment_Method::instance()->update(
460
-            array('PMD_scope' => array()),
461
-            array(array('PMD_slug' => $payment_method_slug))
462
-        );
463
-        return $count_updated;
464
-    }
465
-
466
-
467
-
468
-    /**
469
-     * initializes payment method access caps via EE_Capabilities::init_role_caps()
470
-     * upon EE_Payment_Method_Manager construction
471
-     *
472
-     * @throws EE_Error
473
-     * @throws DomainException
474
-     */
475
-    protected function initializePaymentMethodCaps()
476
-    {
477
-        // don't do this twice
478
-        if ($this->payment_method_caps_initialized) {
479
-            return;
480
-        }
481
-        EE_Capabilities::instance()->addCaps(
482
-            $this->getPaymentMethodCaps()
483
-        );
484
-        $this->payment_method_caps_initialized = true;
485
-    }
486
-
487
-
488
-
489
-    /**
490
-     * array  of dynamic payment method access caps.
491
-     * at the time of writing, october 20 2014, these are the caps added:
492
-     *  ee_payment_method_admin_only
493
-     *  ee_payment_method_aim
494
-     *  ee_payment_method_bank
495
-     *  ee_payment_method_check
496
-     *  ee_payment_method_invoice
497
-     *  ee_payment_method_mijireh
498
-     *  ee_payment_method_paypal_pro
499
-     *  ee_payment_method_paypal_standard
500
-     * Any other payment methods added to core or via addons will also get
501
-     * their related capability automatically added too, so long as they are
502
-     * registered properly using EE_Register_Payment_Method::register()
503
-     *
504
-     * @return array
505
-     * @throws DomainException
506
-     */
507
-    protected function getPaymentMethodCaps()
508
-    {
509
-        $caps = array();
510
-        foreach ($this->payment_method_type_names() as $payment_method_name) {
511
-            $caps = $this->addPaymentMethodCap($payment_method_name,$caps);
512
-        }
513
-        return $caps;
514
-    }
515
-
516
-
517
-
518
-    /**
519
-     * @param string $payment_method_name
520
-     * @param array  $payment_method_caps
521
-     * @param string $role
522
-     * @return array
523
-     * @throws DomainException
524
-     */
525
-    public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator')
526
-    {
527
-        if (empty($payment_method_name)) {
528
-            throw new DomainException(
529
-                esc_html__(
530
-                    'The name of a payment method must be specified to add capabilities.',
531
-                    'event_espresso'
532
-                )
533
-            );
534
-        }
535
-        if (empty($role)) {
536
-            throw new DomainException(
537
-                sprintf(
538
-                    esc_html__(
539
-                        'No role was supplied while trying to add capabilities for the %1$s payment method.',
540
-                        'event_espresso'
541
-                    ),
542
-                    $payment_method_name
543
-                )
544
-            );
545
-        }
546
-        if(! isset($payment_method_caps[$role])) {
547
-            $payment_method_caps[$role] = array();
548
-        }
549
-        $payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
550
-                                                  . strtolower($payment_method_name);
551
-        return $payment_method_caps;
552
-    }
553
-
554
-
555
-
556
-    /**
557
-     * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter
558
-     * to add dynamic payment method access caps when capabilities are reset
559
-     * (or if that filter is called and PM caps are not already set)
560
-     *
561
-     * @param array $caps capabilities being filtered
562
-     * @param bool  $reset
563
-     * @return array
564
-     * @throws DomainException
565
-     */
566
-    public function addPaymentMethodCapsDuringReset(array $caps, $reset = false)
567
-    {
568
-        if ($reset || ! $this->payment_method_caps_initialized) {
569
-            $this->payment_method_caps_initialized = true;
570
-            $caps = array_merge_recursive($caps, $this->getPaymentMethodCaps());
571
-        }
572
-        return $caps;
573
-    }
574
-
575
-
576
-
577
-    /**
578
-     * @deprecated 4.9.42
579
-     * @param $caps
580
-     * @return mixed
581
-     */
582
-    public function add_payment_method_caps($caps)
583
-    {
584
-        return $caps;
585
-    }
22
+	/**
23
+	 * prefix added to all payment method capabilities names
24
+	 */
25
+	const   CAPABILITIES_PREFIX= 'ee_payment_method_';
26
+
27
+	/**
28
+	 * @var EE_Payment_Method_Manager $_instance
29
+	 */
30
+	private static $_instance;
31
+
32
+	/**
33
+	 * @var boolean
34
+	 */
35
+	protected $payment_method_caps_initialized = false;
36
+
37
+	/**
38
+	 * @var array keys are class names without 'EE_PMT_', values are their filepaths
39
+	 */
40
+	protected $_payment_method_types = array();
41
+
42
+	/**
43
+	 * @var EE_PMT_Base[]
44
+	 */
45
+	protected $payment_method_objects = array();
46
+
47
+
48
+
49
+	/**
50
+	 * EE_Payment_Method_Manager constructor.
51
+	 *
52
+	 * @throws EE_Error
53
+	 * @throws DomainException
54
+	 */
55
+	public function __construct()
56
+	{
57
+		// if in admin lets ensure caps are set.
58
+		if (is_admin()) {
59
+			$this->_register_payment_methods();
60
+			// set them immediately
61
+			$this->initializePaymentMethodCaps();
62
+			// plus any time they get reset
63
+			add_filter(
64
+				'FHEE__EE_Capabilities__addCaps__capabilities_to_add',
65
+				array($this, 'addPaymentMethodCapsDuringReset')
66
+			);
67
+		}
68
+	}
69
+
70
+
71
+
72
+	/**
73
+	 * @singleton method used to instantiate class object
74
+	 * @return EE_Payment_Method_Manager instance
75
+	 * @throws DomainException
76
+	 * @throws EE_Error
77
+	 */
78
+	public static function instance()
79
+	{
80
+		// check if class object is instantiated, and instantiated properly
81
+		if (! self::$_instance instanceof EE_Payment_Method_Manager) {
82
+			EE_Registry::instance()->load_lib('PMT_Base');
83
+			self::$_instance = new self();
84
+		}
85
+		return self::$_instance;
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * Resets the instance and returns a new one
92
+	 *
93
+	 * @return EE_Payment_Method_Manager
94
+	 * @throws DomainException
95
+	 * @throws EE_Error
96
+	 */
97
+	public static function reset()
98
+	{
99
+		self::$_instance = null;
100
+		return self::instance();
101
+	}
102
+
103
+
104
+
105
+	/**
106
+	 * If necessary, re-register payment methods
107
+	 *
108
+	 * @param boolean $force_recheck whether to recheck for payment method types,
109
+	 *                               or just re-use the PMTs we found last time we checked during this request (if
110
+	 *                               we have not yet checked during this request, then we need to check anyways)
111
+	 */
112
+	public function maybe_register_payment_methods($force_recheck = false)
113
+	{
114
+		if (! $this->_payment_method_types || $force_recheck) {
115
+			$this->_register_payment_methods();
116
+		}
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * register_payment_methods
123
+	 *
124
+	 * @return array
125
+	 */
126
+	protected function _register_payment_methods()
127
+	{
128
+		// grab list of installed modules
129
+		$pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
130
+		// filter list of modules to register
131
+		$pm_to_register = apply_filters(
132
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
133
+			$pm_to_register
134
+		);
135
+		// remove any duplicates if that should happen for some reason
136
+		$pm_to_register = array_unique($pm_to_register);
137
+		// loop through folders
138
+		foreach ($pm_to_register as $pm_path) {
139
+			$this->register_payment_method($pm_path);
140
+		}
141
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
142
+		// filter list of installed modules
143
+		//keep them organized alphabetically by the payment method type's name
144
+		ksort($this->_payment_method_types);
145
+		return apply_filters(
146
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
147
+			$this->_payment_method_types
148
+		);
149
+	}
150
+
151
+
152
+
153
+	/**
154
+	 * register_payment_method- makes core aware of this payment method
155
+	 *
156
+	 * @param string $payment_method_path - full path up to and including payment method folder
157
+	 * @return boolean
158
+	 */
159
+	public function register_payment_method($payment_method_path = '')
160
+	{
161
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
162
+		$module_ext = '.pm.php';
163
+		// make all separators match
164
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
165
+		// grab and sanitize module name
166
+		$module_dir = basename($payment_method_path);
167
+		// create class name from module directory name
168
+		$module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
169
+		// add class prefix
170
+		$module_class = 'EE_PMT_' . $module;
171
+		// does the module exist ?
172
+		if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
173
+			$msg = sprintf(
174
+				esc_html__(
175
+					'The requested %s payment method file could not be found or is not readable due to file permissions.',
176
+					'event_espresso'
177
+				), $module
178
+			);
179
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
180
+			return false;
181
+		}
182
+		// load the module class file
183
+		require_once($payment_method_path . DS . $module_class . $module_ext);
184
+		// verify that class exists
185
+		if (! class_exists($module_class)) {
186
+			$msg = sprintf(
187
+				esc_html__('The requested %s module class does not exist.', 'event_espresso'),
188
+				$module_class
189
+			);
190
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
191
+			return false;
192
+		}
193
+		// add to array of registered modules
194
+		$this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
195
+		return true;
196
+	}
197
+
198
+
199
+
200
+	/**
201
+	 * Checks if a payment method has been registered, and if so includes it
202
+	 *
203
+	 * @param string  $payment_method_name like 'PayPal_Pro', (ie class name without the prefix 'EEPM_')
204
+	 * @param boolean $force_recheck       whether to force re-checking for new payment method types
205
+	 * @return boolean
206
+	 */
207
+	public function payment_method_type_exists($payment_method_name, $force_recheck = false)
208
+	{
209
+		if (
210
+			$force_recheck
211
+			|| ! is_array($this->_payment_method_types)
212
+			|| ! isset($this->_payment_method_types[$payment_method_name])
213
+		) {
214
+			$this->maybe_register_payment_methods($force_recheck);
215
+		}
216
+		if (isset($this->_payment_method_types[$payment_method_name])) {
217
+			require_once($this->_payment_method_types[$payment_method_name]);
218
+			return true;
219
+		}
220
+		return false;
221
+	}
222
+
223
+
224
+
225
+	/**
226
+	 * Returns all the class names of the various payment method types
227
+	 *
228
+	 * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
229
+	 *                               (what you'd find in wp_esp_payment_method.PMD_type)
230
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
231
+	 * @return array
232
+	 */
233
+	public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
234
+	{
235
+		$this->maybe_register_payment_methods($force_recheck);
236
+		if ($with_prefixes) {
237
+			$classnames = array_keys($this->_payment_method_types);
238
+			$payment_methods = array();
239
+			foreach ($classnames as $classname) {
240
+				$payment_methods[] = $this->payment_method_class_from_type($classname);
241
+			}
242
+			return $payment_methods;
243
+		}
244
+		return array_keys($this->_payment_method_types);
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Gets an object of each payment method type, none of which are bound to a
251
+	 * payment method instance
252
+	 *
253
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
254
+	 * @return EE_PMT_Base[]
255
+	 */
256
+	public function payment_method_types($force_recheck = false)
257
+	{
258
+		if ($force_recheck || empty($this->payment_method_objects)) {
259
+			$this->maybe_register_payment_methods($force_recheck);
260
+			foreach ($this->payment_method_type_names(true) as $classname) {
261
+				if (! isset($this->payment_method_objects[$classname])) {
262
+					$this->payment_method_objects[$classname] = new $classname;
263
+				}
264
+			}
265
+		}
266
+		return $this->payment_method_objects;
267
+	}
268
+
269
+
270
+
271
+	/**
272
+	 * Changes the payment method's class name into the payment method type's name
273
+	 * (as used on the payment method's table's PMD_type field)
274
+	 *
275
+	 * @param string $classname
276
+	 * @return string
277
+	 */
278
+	public function payment_method_type_sans_class_prefix($classname)
279
+	{
280
+		return str_replace('EE_PMT_', '', $classname);
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * Does the opposite of payment-method_type_sans_prefix
287
+	 *
288
+	 * @param string $type
289
+	 * @return string
290
+	 */
291
+	public function payment_method_class_from_type($type)
292
+	{
293
+		return 'EE_PMT_' . $type;
294
+	}
295
+
296
+
297
+
298
+	/**
299
+	 * Activates a payment method of the given type.
300
+	 *
301
+	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
302
+	 * @return EE_Payment_Method
303
+	 * @throws EE_Error
304
+	 */
305
+	public function activate_a_payment_method_of_type($payment_method_type)
306
+	{
307
+		$this->maybe_register_payment_methods();
308
+		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
309
+		if (! $payment_method instanceof EE_Payment_Method) {
310
+			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
311
+			if (class_exists($pm_type_class)) {
312
+				/** @var $pm_type_obj EE_PMT_Base */
313
+				$pm_type_obj = new $pm_type_class;
314
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
315
+				if (! $payment_method) {
316
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
317
+				}
318
+				$payment_method->set_type($payment_method_type);
319
+				$this->initialize_payment_method($payment_method);
320
+			} else {
321
+				throw new EE_Error(
322
+					sprintf(
323
+						esc_html__(
324
+							'There is no payment method of type %1$s, so it could not be activated',
325
+							'event_espresso'
326
+						),
327
+						$pm_type_class
328
+					)
329
+				);
330
+			}
331
+		}
332
+		$payment_method->set_active();
333
+		$payment_method->save();
334
+		if ($payment_method->type() === 'Invoice') {
335
+			/** @type EE_Message_Resource_Manager $message_resource_manager */
336
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
337
+			$message_resource_manager->ensure_message_type_is_active('invoice', 'html');
338
+			$message_resource_manager->ensure_messenger_is_active('pdf');
339
+			EE_Error::add_persistent_admin_notice(
340
+				'invoice_pm_requirements_notice',
341
+				sprintf(
342
+					esc_html__(
343
+						'The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
344
+						'event_espresso'
345
+					),
346
+					'<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
347
+					'</a>'
348
+				),
349
+				true
350
+			);
351
+		}
352
+		return $payment_method;
353
+	}
354
+
355
+
356
+
357
+	/**
358
+	 * Creates a payment method of the specified type. Does not save it.
359
+	 *
360
+	 * @global WP_User    $current_user
361
+	 * @param EE_PMT_Base $pm_type_obj
362
+	 * @return EE_Payment_Method
363
+	 * @throws EE_Error
364
+	 */
365
+	public function create_payment_method_of_type($pm_type_obj)
366
+	{
367
+		global $current_user;
368
+		$payment_method = EE_Payment_Method::new_instance(
369
+			array(
370
+				'PMD_type'       => $pm_type_obj->system_name(),
371
+				'PMD_name'       => $pm_type_obj->pretty_name(),
372
+				'PMD_admin_name' => $pm_type_obj->pretty_name(),
373
+				'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
374
+				'PMD_wp_user'    => $current_user->ID,
375
+				'PMD_order'      => EEM_Payment_Method::instance()->count(
376
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
377
+					) * 10,
378
+			)
379
+		);
380
+		return $payment_method;
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * Sets the initial payment method properties (including extra meta)
387
+	 *
388
+	 * @param EE_Payment_Method $payment_method
389
+	 * @return EE_Payment_Method
390
+	 * @throws EE_Error
391
+	 */
392
+	public function initialize_payment_method($payment_method)
393
+	{
394
+		$pm_type_obj = $payment_method->type_obj();
395
+		$payment_method->set_description($pm_type_obj->default_description());
396
+		if (! $payment_method->button_url()) {
397
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
398
+		}
399
+		//now add setup its default extra meta properties
400
+		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
401
+		if (! empty($extra_metas)) {
402
+			//verify the payment method has an ID before adding extra meta
403
+			if (! $payment_method->ID()) {
404
+				$payment_method->save();
405
+			}
406
+			foreach ($extra_metas as $meta_name => $input) {
407
+				$payment_method->update_extra_meta($meta_name, $input->raw_value());
408
+			}
409
+		}
410
+		return $payment_method;
411
+	}
412
+
413
+
414
+
415
+	/**
416
+	 * Makes sure the payment method is related to the specified payment method
417
+	 *
418
+	 * @deprecated in 4.9.40 because the currency payment method table is being deprecated
419
+	 * @param EE_Payment_Method $payment_method
420
+	 * @return EE_Payment_Method
421
+	 * @throws EE_Error
422
+	 */
423
+	public function set_usable_currencies_on_payment_method($payment_method)
424
+	{
425
+		EE_Error::doing_it_wrong(
426
+			'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
427
+			esc_html__(
428
+				'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
429
+				'event_espresso'
430
+			),
431
+			'4.9.40'
432
+		);
433
+		return $payment_method;
434
+	}
435
+
436
+
437
+
438
+	/**
439
+	 * Deactivates a payment method of the given payment method slug.
440
+	 *
441
+	 * @param string $payment_method_slug The slug for the payment method to deactivate.
442
+	 * @return int count of rows updated.
443
+	 * @throws EE_Error
444
+	 */
445
+	public function deactivate_payment_method($payment_method_slug)
446
+	{
447
+		EE_Log::instance()->log(
448
+			__FILE__,
449
+			__FUNCTION__,
450
+			sprintf(
451
+				esc_html__(
452
+					'Payment method with slug %1$s is being deactivated by site admin',
453
+					'event_espresso'
454
+				),
455
+				$payment_method_slug
456
+			),
457
+			'payment_method_change'
458
+		);
459
+		$count_updated = EEM_Payment_Method::instance()->update(
460
+			array('PMD_scope' => array()),
461
+			array(array('PMD_slug' => $payment_method_slug))
462
+		);
463
+		return $count_updated;
464
+	}
465
+
466
+
467
+
468
+	/**
469
+	 * initializes payment method access caps via EE_Capabilities::init_role_caps()
470
+	 * upon EE_Payment_Method_Manager construction
471
+	 *
472
+	 * @throws EE_Error
473
+	 * @throws DomainException
474
+	 */
475
+	protected function initializePaymentMethodCaps()
476
+	{
477
+		// don't do this twice
478
+		if ($this->payment_method_caps_initialized) {
479
+			return;
480
+		}
481
+		EE_Capabilities::instance()->addCaps(
482
+			$this->getPaymentMethodCaps()
483
+		);
484
+		$this->payment_method_caps_initialized = true;
485
+	}
486
+
487
+
488
+
489
+	/**
490
+	 * array  of dynamic payment method access caps.
491
+	 * at the time of writing, october 20 2014, these are the caps added:
492
+	 *  ee_payment_method_admin_only
493
+	 *  ee_payment_method_aim
494
+	 *  ee_payment_method_bank
495
+	 *  ee_payment_method_check
496
+	 *  ee_payment_method_invoice
497
+	 *  ee_payment_method_mijireh
498
+	 *  ee_payment_method_paypal_pro
499
+	 *  ee_payment_method_paypal_standard
500
+	 * Any other payment methods added to core or via addons will also get
501
+	 * their related capability automatically added too, so long as they are
502
+	 * registered properly using EE_Register_Payment_Method::register()
503
+	 *
504
+	 * @return array
505
+	 * @throws DomainException
506
+	 */
507
+	protected function getPaymentMethodCaps()
508
+	{
509
+		$caps = array();
510
+		foreach ($this->payment_method_type_names() as $payment_method_name) {
511
+			$caps = $this->addPaymentMethodCap($payment_method_name,$caps);
512
+		}
513
+		return $caps;
514
+	}
515
+
516
+
517
+
518
+	/**
519
+	 * @param string $payment_method_name
520
+	 * @param array  $payment_method_caps
521
+	 * @param string $role
522
+	 * @return array
523
+	 * @throws DomainException
524
+	 */
525
+	public function addPaymentMethodCap($payment_method_name, array $payment_method_caps, $role = 'administrator')
526
+	{
527
+		if (empty($payment_method_name)) {
528
+			throw new DomainException(
529
+				esc_html__(
530
+					'The name of a payment method must be specified to add capabilities.',
531
+					'event_espresso'
532
+				)
533
+			);
534
+		}
535
+		if (empty($role)) {
536
+			throw new DomainException(
537
+				sprintf(
538
+					esc_html__(
539
+						'No role was supplied while trying to add capabilities for the %1$s payment method.',
540
+						'event_espresso'
541
+					),
542
+					$payment_method_name
543
+				)
544
+			);
545
+		}
546
+		if(! isset($payment_method_caps[$role])) {
547
+			$payment_method_caps[$role] = array();
548
+		}
549
+		$payment_method_caps[$role][] = EE_Payment_Method_Manager::CAPABILITIES_PREFIX
550
+												  . strtolower($payment_method_name);
551
+		return $payment_method_caps;
552
+	}
553
+
554
+
555
+
556
+	/**
557
+	 * callback for FHEE__EE_Capabilities__init_role_caps__caps_map filter
558
+	 * to add dynamic payment method access caps when capabilities are reset
559
+	 * (or if that filter is called and PM caps are not already set)
560
+	 *
561
+	 * @param array $caps capabilities being filtered
562
+	 * @param bool  $reset
563
+	 * @return array
564
+	 * @throws DomainException
565
+	 */
566
+	public function addPaymentMethodCapsDuringReset(array $caps, $reset = false)
567
+	{
568
+		if ($reset || ! $this->payment_method_caps_initialized) {
569
+			$this->payment_method_caps_initialized = true;
570
+			$caps = array_merge_recursive($caps, $this->getPaymentMethodCaps());
571
+		}
572
+		return $caps;
573
+	}
574
+
575
+
576
+
577
+	/**
578
+	 * @deprecated 4.9.42
579
+	 * @param $caps
580
+	 * @return mixed
581
+	 */
582
+	public function add_payment_method_caps($caps)
583
+	{
584
+		return $caps;
585
+	}
586 586
 
587 587
 
588 588
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Payment_Method.lib.php 1 patch
Indentation   +143 added lines, -143 removed lines patch added patch discarded remove patch
@@ -18,149 +18,149 @@
 block discarded – undo
18 18
 class EE_Register_Payment_Method implements EEI_Plugin_API
19 19
 {
20 20
 
21
-    /**
22
-     * Holds values for registered payment methods
23
-     *
24
-     * @var array
25
-     */
26
-    protected static $_settings = array();
27
-
28
-
29
-
30
-    /**
31
-     * Method for registering new EE_PMT_Base children
32
-     *
33
-     * @since    4.5.0
34
-     * @param string  $payment_method_id    a unique identifier for this set of modules Required.
35
-     * @param  array  $setup_args           an array of arguments provided for registering modules Required.{
36
-     * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class
37
-     *                                      (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains
38
-     *                                      the files EE_PMT_Payomatic.pm.php)
39
-     *                                      }
40
-     * @throws EE_Error
41
-     * @type array payment_method_paths    an array of full server paths to folders containing any EE_PMT_Base
42
-     *                                      children, or to the EED_Module files themselves
43
-     * @return void
44
-     * @throws DomainException
45
-     */
46
-    public static function register($payment_method_id = null, $setup_args = array())
47
-    {
48
-        //required fields MUST be present, so let's make sure they are.
49
-        if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) {
50
-            throw new EE_Error(
51
-                esc_html__(
52
-                    'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
53
-                    'event_espresso'
54
-                )
55
-            );
56
-        }
57
-        //make sure we don't register twice
58
-        if (isset(self::$_settings[$payment_method_id])) {
59
-            return;
60
-        }
61
-        //make sure this was called in the right place!
62
-        if (
63
-            ! did_action('AHEE__EE_System__load_espresso_addons')
64
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
65
-        ) {
66
-            EE_Error::doing_it_wrong(
67
-                __METHOD__,
68
-                esc_html__(
69
-                    'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
70
-                    'event_espresso'
71
-                ),
72
-                '4.3.0'
73
-            );
74
-        }
75
-        //setup $_settings array from incoming values.
76
-        self::$_settings[$payment_method_id] = array(
77
-            // array of full server paths to any EE_PMT_Base children used
78
-            'payment_method_paths' => isset($setup_args['payment_method_paths'])
79
-                ? (array)$setup_args['payment_method_paths']
80
-                : array(),
81
-        );
82
-        // add to list of modules to be registered
83
-        add_filter(
84
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
85
-            array('EE_Register_Payment_Method', 'add_payment_methods')
86
-        );
87
-        // If EE_Payment_Method_Manager::register_payment_methods has already been called,
88
-        // then we need to add our caps for this payment method manually
89
-        if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) {
90
-            // register payment methods directly
91
-            foreach (self::$_settings[$payment_method_id]['payment_method_paths'] as $payment_method_path) {
92
-                EE_Payment_Method_Manager::instance()->register_payment_method($payment_method_path);
93
-            }
94
-            EE_Capabilities::instance()->addCaps(
95
-                self::getPaymentMethodCapabilities(self::$_settings[$payment_method_id])
96
-            );
97
-        }
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * Filters the list of payment methods to add ours.
104
-     * and they're just full filepaths to FOLDERS containing a payment method class file. Eg.
105
-     *
106
-     * @param array $payment_method_folders array of paths to all payment methods that require registering
107
-     * @return array
108
-     */
109
-    public static function add_payment_methods($payment_method_folders)
110
-    {
111
-        foreach (self::$_settings as $settings) {
112
-            foreach ($settings['payment_method_paths'] as $payment_method_path) {
113
-                $payment_method_folders[] = $payment_method_path;
114
-            }
115
-        }
116
-        return $payment_method_folders;
117
-    }
118
-
119
-
120
-
121
-    /**
122
-     * This deregisters a module that was previously registered with a specific $module_id.
123
-     *
124
-     * @since    4.3.0
125
-     *
126
-     * @param string $module_id the name for the module that was previously registered
127
-     * @return void
128
-     * @throws DomainException
129
-     * @throws EE_Error
130
-     */
131
-    public static function deregister($module_id = null)
132
-    {
133
-        if (isset(self::$_settings[$module_id])) {
134
-            EE_Capabilities::instance()->removeCaps(
135
-                self::getPaymentMethodCapabilities(self::$_settings[$module_id])
136
-            );
137
-            unset(self::$_settings[$module_id]);
138
-        }
139
-    }
140
-
141
-
142
-
143
-    /**
144
-     * returns an array of the caps that get added when a Payment Method is registered
145
-     *
146
-     * @param array $settings
147
-     * @return array
148
-     * @throws DomainException
149
-     * @throws EE_Error
150
-     */
151
-    private static function getPaymentMethodCapabilities(array $settings)
152
-    {
153
-        $payment_method_caps = array('administrator' => array());
154
-        if (isset($settings['payment_method_paths'])) {
155
-            foreach ($settings['payment_method_paths'] as $payment_method_path) {
156
-                $payment_method_caps = EE_Payment_Method_Manager::instance()->addPaymentMethodCap(
157
-                    strtolower(basename($payment_method_path)),
158
-                    $payment_method_caps
159
-                );
160
-            }
161
-        }
162
-        return $payment_method_caps;
163
-    }
21
+	/**
22
+	 * Holds values for registered payment methods
23
+	 *
24
+	 * @var array
25
+	 */
26
+	protected static $_settings = array();
27
+
28
+
29
+
30
+	/**
31
+	 * Method for registering new EE_PMT_Base children
32
+	 *
33
+	 * @since    4.5.0
34
+	 * @param string  $payment_method_id    a unique identifier for this set of modules Required.
35
+	 * @param  array  $setup_args           an array of arguments provided for registering modules Required.{
36
+	 * @type string[] $payment_method_paths each element is the folder containing the EE_PMT_Base child class
37
+	 *                                      (eg, 'public_html/wp-content/plugins/my_plugin/Payomatic/' which contains
38
+	 *                                      the files EE_PMT_Payomatic.pm.php)
39
+	 *                                      }
40
+	 * @throws EE_Error
41
+	 * @type array payment_method_paths    an array of full server paths to folders containing any EE_PMT_Base
42
+	 *                                      children, or to the EED_Module files themselves
43
+	 * @return void
44
+	 * @throws DomainException
45
+	 */
46
+	public static function register($payment_method_id = null, $setup_args = array())
47
+	{
48
+		//required fields MUST be present, so let's make sure they are.
49
+		if (empty($payment_method_id) || ! is_array($setup_args) || empty($setup_args['payment_method_paths'])) {
50
+			throw new EE_Error(
51
+				esc_html__(
52
+					'In order to register Payment Methods with EE_Register_Payment_Method::register(), you must include a "payment_method_id" (a unique identifier for this set of modules), and an array containing the following keys: "payment_method_paths" (an array of full server paths to folders that contain modules, or to the module files themselves)',
53
+					'event_espresso'
54
+				)
55
+			);
56
+		}
57
+		//make sure we don't register twice
58
+		if (isset(self::$_settings[$payment_method_id])) {
59
+			return;
60
+		}
61
+		//make sure this was called in the right place!
62
+		if (
63
+			! did_action('AHEE__EE_System__load_espresso_addons')
64
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
65
+		) {
66
+			EE_Error::doing_it_wrong(
67
+				__METHOD__,
68
+				esc_html__(
69
+					'An attempt to register modules has failed because it was not registered at the correct time.  Please use the "AHEE__EE_System__register_shortcodes_modules_and_widgets" hook to register modules.',
70
+					'event_espresso'
71
+				),
72
+				'4.3.0'
73
+			);
74
+		}
75
+		//setup $_settings array from incoming values.
76
+		self::$_settings[$payment_method_id] = array(
77
+			// array of full server paths to any EE_PMT_Base children used
78
+			'payment_method_paths' => isset($setup_args['payment_method_paths'])
79
+				? (array)$setup_args['payment_method_paths']
80
+				: array(),
81
+		);
82
+		// add to list of modules to be registered
83
+		add_filter(
84
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
85
+			array('EE_Register_Payment_Method', 'add_payment_methods')
86
+		);
87
+		// If EE_Payment_Method_Manager::register_payment_methods has already been called,
88
+		// then we need to add our caps for this payment method manually
89
+		if (did_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods')) {
90
+			// register payment methods directly
91
+			foreach (self::$_settings[$payment_method_id]['payment_method_paths'] as $payment_method_path) {
92
+				EE_Payment_Method_Manager::instance()->register_payment_method($payment_method_path);
93
+			}
94
+			EE_Capabilities::instance()->addCaps(
95
+				self::getPaymentMethodCapabilities(self::$_settings[$payment_method_id])
96
+			);
97
+		}
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * Filters the list of payment methods to add ours.
104
+	 * and they're just full filepaths to FOLDERS containing a payment method class file. Eg.
105
+	 *
106
+	 * @param array $payment_method_folders array of paths to all payment methods that require registering
107
+	 * @return array
108
+	 */
109
+	public static function add_payment_methods($payment_method_folders)
110
+	{
111
+		foreach (self::$_settings as $settings) {
112
+			foreach ($settings['payment_method_paths'] as $payment_method_path) {
113
+				$payment_method_folders[] = $payment_method_path;
114
+			}
115
+		}
116
+		return $payment_method_folders;
117
+	}
118
+
119
+
120
+
121
+	/**
122
+	 * This deregisters a module that was previously registered with a specific $module_id.
123
+	 *
124
+	 * @since    4.3.0
125
+	 *
126
+	 * @param string $module_id the name for the module that was previously registered
127
+	 * @return void
128
+	 * @throws DomainException
129
+	 * @throws EE_Error
130
+	 */
131
+	public static function deregister($module_id = null)
132
+	{
133
+		if (isset(self::$_settings[$module_id])) {
134
+			EE_Capabilities::instance()->removeCaps(
135
+				self::getPaymentMethodCapabilities(self::$_settings[$module_id])
136
+			);
137
+			unset(self::$_settings[$module_id]);
138
+		}
139
+	}
140
+
141
+
142
+
143
+	/**
144
+	 * returns an array of the caps that get added when a Payment Method is registered
145
+	 *
146
+	 * @param array $settings
147
+	 * @return array
148
+	 * @throws DomainException
149
+	 * @throws EE_Error
150
+	 */
151
+	private static function getPaymentMethodCapabilities(array $settings)
152
+	{
153
+		$payment_method_caps = array('administrator' => array());
154
+		if (isset($settings['payment_method_paths'])) {
155
+			foreach ($settings['payment_method_paths'] as $payment_method_path) {
156
+				$payment_method_caps = EE_Payment_Method_Manager::instance()->addPaymentMethodCap(
157
+					strtolower(basename($payment_method_path)),
158
+					$payment_method_caps
159
+				);
160
+			}
161
+		}
162
+		return $payment_method_caps;
163
+	}
164 164
 
165 165
 }
166 166
 // End of file EE_Register_Payment_Method.lib.php
Please login to merge, or discard this patch.
core/EE_Deprecated.core.php 2 patches
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -1047,7 +1047,7 @@  discard block
 block discarded – undo
1047 1047
 		);
1048 1048
 		do_action(
1049 1049
 			'AHEE__EE_Capabilities__init_role_caps__complete',
1050
-            $capabilities_map
1050
+			$capabilities_map
1051 1051
 		);
1052 1052
 	}
1053 1053
 );
@@ -1067,9 +1067,9 @@  discard block
 block discarded – undo
1067 1067
 			'filter'
1068 1068
 		);
1069 1069
 		return apply_filters(
1070
-            'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1071
-            $existing_attendee, $registration, $attendee_data
1072
-        );
1070
+			'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee',
1071
+			$existing_attendee, $registration, $attendee_data
1072
+		);
1073 1073
 	},
1074 1074
 	10,3
1075 1075
 );
@@ -1082,88 +1082,88 @@  discard block
 block discarded – undo
1082 1082
 class EE_Event_List_Query extends WP_Query
1083 1083
 {
1084 1084
 
1085
-    private $title;
1086
-
1087
-    private $css_class;
1088
-
1089
-    private $category_slug;
1090
-
1091
-    /**
1092
-     * EE_Event_List_Query constructor.
1093
-     *
1094
-     * @param array $args
1095
-     */
1096
-    public function __construct($args = array())
1097
-    {
1098
-        \EE_Error::doing_it_wrong(
1099
-            __METHOD__,
1100
-            __(
1101
-                'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1102
-                'event_espresso'
1103
-            ),
1104
-            '4.9.27',
1105
-            '5.0.0'
1106
-        );
1107
-        $this->title = isset($args['title']) ? $args['title'] : '';
1108
-        $this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1109
-        $this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1110
-        $limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1111
-        // the current "page" we are viewing
1112
-        $paged = max(1, get_query_var('paged'));
1113
-        // Force these args
1114
-        $args = array_merge(
1115
-            $args, array(
1116
-            'post_type'              => 'espresso_events',
1117
-            'posts_per_page'         => $limit,
1118
-            'update_post_term_cache' => false,
1119
-            'update_post_meta_cache' => false,
1120
-            'paged'                  => $paged,
1121
-            'offset'                 => ($paged - 1) * $limit
1122
-        )
1123
-        );
1124
-        // run the query
1125
-        parent::__construct($args);
1126
-    }
1127
-
1128
-
1129
-
1130
-    /**
1131
-     * event_list_title
1132
-     *
1133
-     * @param string $event_list_title
1134
-     * @return string
1135
-     */
1136
-    public function event_list_title($event_list_title = '')
1137
-    {
1138
-        if (! empty($this->title)) {
1139
-            return $this->title;
1140
-        }
1141
-        return $event_list_title;
1142
-    }
1143
-
1144
-
1145
-
1146
-    /**
1147
-     * event_list_css
1148
-     *
1149
-     * @param string $event_list_css
1150
-     * @return string
1151
-     */
1152
-    public function event_list_css($event_list_css = '')
1153
-    {
1154
-        $event_list_css .= ! empty($event_list_css)
1155
-            ? ' '
1156
-            : '';
1157
-        $event_list_css .= ! empty($this->css_class)
1158
-            ? $this->css_class
1159
-            : '';
1160
-        $event_list_css .= ! empty($event_list_css)
1161
-            ? ' '
1162
-            : '';
1163
-        $event_list_css .= ! empty($this->category_slug)
1164
-            ? $this->category_slug
1165
-            : '';
1166
-        return $event_list_css;
1167
-    }
1085
+	private $title;
1086
+
1087
+	private $css_class;
1088
+
1089
+	private $category_slug;
1090
+
1091
+	/**
1092
+	 * EE_Event_List_Query constructor.
1093
+	 *
1094
+	 * @param array $args
1095
+	 */
1096
+	public function __construct($args = array())
1097
+	{
1098
+		\EE_Error::doing_it_wrong(
1099
+			__METHOD__,
1100
+			__(
1101
+				'Usage is deprecated. Please use \EventEspresso\core\domain\services\wp_queries\EventListQuery instead.',
1102
+				'event_espresso'
1103
+			),
1104
+			'4.9.27',
1105
+			'5.0.0'
1106
+		);
1107
+		$this->title = isset($args['title']) ? $args['title'] : '';
1108
+		$this->css_class = isset($args['css_class']) ? $args['css_class'] : '';
1109
+		$this->category_slug = isset($args['category_slug']) ? $args['category_slug'] : '';
1110
+		$limit = isset($args['limit']) && absint($args['limit']) ? $args['limit'] : 10;
1111
+		// the current "page" we are viewing
1112
+		$paged = max(1, get_query_var('paged'));
1113
+		// Force these args
1114
+		$args = array_merge(
1115
+			$args, array(
1116
+			'post_type'              => 'espresso_events',
1117
+			'posts_per_page'         => $limit,
1118
+			'update_post_term_cache' => false,
1119
+			'update_post_meta_cache' => false,
1120
+			'paged'                  => $paged,
1121
+			'offset'                 => ($paged - 1) * $limit
1122
+		)
1123
+		);
1124
+		// run the query
1125
+		parent::__construct($args);
1126
+	}
1127
+
1128
+
1129
+
1130
+	/**
1131
+	 * event_list_title
1132
+	 *
1133
+	 * @param string $event_list_title
1134
+	 * @return string
1135
+	 */
1136
+	public function event_list_title($event_list_title = '')
1137
+	{
1138
+		if (! empty($this->title)) {
1139
+			return $this->title;
1140
+		}
1141
+		return $event_list_title;
1142
+	}
1143
+
1144
+
1145
+
1146
+	/**
1147
+	 * event_list_css
1148
+	 *
1149
+	 * @param string $event_list_css
1150
+	 * @return string
1151
+	 */
1152
+	public function event_list_css($event_list_css = '')
1153
+	{
1154
+		$event_list_css .= ! empty($event_list_css)
1155
+			? ' '
1156
+			: '';
1157
+		$event_list_css .= ! empty($this->css_class)
1158
+			? $this->css_class
1159
+			: '';
1160
+		$event_list_css .= ! empty($event_list_css)
1161
+			? ' '
1162
+			: '';
1163
+		$event_list_css .= ! empty($this->category_slug)
1164
+			? $this->category_slug
1165
+			: '';
1166
+		return $event_list_css;
1167
+	}
1168 1168
 
1169 1169
 }
Please login to merge, or discard this patch.
Spacing   +178 added lines, -178 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'No direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * ************************************************************************
@@ -43,8 +43,8 @@  discard block
 block discarded – undo
43 43
 	$action_or_filter = 'action'
44 44
 ) {
45 45
 	$action_or_filter = $action_or_filter === 'action'
46
-		? esc_html__( 'action', 'event_espresso' )
47
-		: esc_html__( 'filter', 'event_espresso' );
46
+		? esc_html__('action', 'event_espresso')
47
+		: esc_html__('filter', 'event_espresso');
48 48
 	EE_Error::doing_it_wrong(
49 49
 		$deprecated_filter,
50 50
 		sprintf(
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
  * @param \EE_Checkout $checkout
69 69
  * @return string
70 70
  */
71
-function ee_deprecated__registration_checkout__button_text( $submit_button_text, EE_Checkout $checkout ) {
71
+function ee_deprecated__registration_checkout__button_text($submit_button_text, EE_Checkout $checkout) {
72 72
 	// list of old filters
73 73
 	$deprecated_filters = array(
74 74
 		'update_registration_details' => true,
@@ -78,16 +78,16 @@  discard block
 block discarded – undo
78 78
 		'proceed_to' => true,
79 79
 	);
80 80
 	// loop thru and call doing_it_wrong() or remove any that aren't being used
81
-	foreach ( $deprecated_filters as $deprecated_filter => $on ) {
81
+	foreach ($deprecated_filters as $deprecated_filter => $on) {
82 82
 		// was this filter called ?
83
-		if ( has_action( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter )) {
83
+		if (has_action('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter)) {
84 84
 			// only display doing_it_wrong() notice to Event Admins during non-AJAX requests
85
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter' ) && ! defined( 'DOING_AJAX' ) ) {
85
+			if (EE_Registry::instance()->CAP->current_user_can('ee_read_ee', 'hide_doing_it_wrong_for_deprecated_SPCO_filter') && ! defined('DOING_AJAX')) {
86 86
 				EE_Error::doing_it_wrong(
87
-					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
87
+					'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
88 88
 					sprintf(
89
-						__( 'The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso' ),
90
-						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__' . $deprecated_filter,
89
+						__('The %1$s filter is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new filter: %2$s"%3$s" found in "%4$s"', 'event_espresso'),
90
+						'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__'.$deprecated_filter,
91 91
 						'<br />',
92 92
 						'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text',
93 93
 						'/modules/single_page_checkout/inc/EE_SPCO_Reg_Step.class.php'
@@ -96,24 +96,24 @@  discard block
 block discarded – undo
96 96
 				);
97 97
 			}
98 98
 		} else {
99
-			unset( $deprecated_filters[ $deprecated_filter ] );
99
+			unset($deprecated_filters[$deprecated_filter]);
100 100
 		}
101 101
 	}
102
-	if ( ! empty( $deprecated_filters )) {
103
-
104
-		if ( $checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset( $deprecated_filters[ 'update_registration_details' ] )) {
105
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text );
106
-		} else if ( $checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset( $deprecated_filters[ 'process_payment' ] ) ) {
107
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text );
108
-		} else if ( $checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset( $deprecated_filters[ 'finalize_registration' ] ) ) {
109
-			$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text );
102
+	if ( ! empty($deprecated_filters)) {
103
+
104
+		if ($checkout->current_step->slug() == 'attendee_information' && $checkout->revisit && isset($deprecated_filters['update_registration_details'])) {
105
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__update_registration_details', $submit_button_text);
106
+		} else if ($checkout->current_step->slug() == 'payment_options' && $checkout->revisit && isset($deprecated_filters['process_payment'])) {
107
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__process_payment', $submit_button_text);
108
+		} else if ($checkout->next_step instanceof EE_SPCO_Reg_Step && $checkout->next_step->slug() == 'finalize_registration' && isset($deprecated_filters['finalize_registration'])) {
109
+			$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__finalize_registration', $submit_button_text);
110 110
 		}
111
-		if ( $checkout->next_step instanceof EE_SPCO_Reg_Step ) {
112
-			if ( $checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset( $deprecated_filters[ 'and_proceed_to_payment' ] ) ) {
113
-				$submit_button_text .= apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text );
111
+		if ($checkout->next_step instanceof EE_SPCO_Reg_Step) {
112
+			if ($checkout->payment_required() && $checkout->next_step->slug() == 'payment_options' && isset($deprecated_filters['and_proceed_to_payment'])) {
113
+				$submit_button_text .= apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__and_proceed_to_payment', $submit_button_text);
114 114
 			}
115
-			if ( $checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset( $deprecated_filters[ 'proceed_to' ] ) ) {
116
-				$submit_button_text = apply_filters( 'FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text ) . $checkout->next_step->name();
115
+			if ($checkout->next_step->slug() != 'finalize_registration' && ! $checkout->revisit && isset($deprecated_filters['proceed_to'])) {
116
+				$submit_button_text = apply_filters('FHEE__EED_Single_Page_Checkout__registration_checkout__button_text__proceed_to', $submit_button_text).$checkout->next_step->name();
117 117
 			}
118 118
 		}
119 119
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 	return $submit_button_text;
122 122
 
123 123
 }
124
-add_filter( 'FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2 );
124
+add_filter('FHEE__EE_SPCO_Reg_Step__set_submit_button_text___submit_button_text', 'ee_deprecated__registration_checkout__button_text', 10, 2);
125 125
 
126 126
 
127 127
 
@@ -132,16 +132,16 @@  discard block
 block discarded – undo
132 132
  * @param \EE_Checkout $checkout
133 133
  * @param boolean $status_updates
134 134
  */
135
-function ee_deprecated_finalize_transaction( EE_Checkout $checkout, $status_updates ) {
135
+function ee_deprecated_finalize_transaction(EE_Checkout $checkout, $status_updates) {
136 136
 	$action_ref = NULL;
137
-	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__new_transaction' ) ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
138
-	$action_ref = has_action( 'AHEE__EE_Transaction__finalize__all_transaction' ) ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
139
-	if ( $action_ref ) {
137
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__new_transaction') ? 'AHEE__EE_Transaction__finalize__new_transaction' : $action_ref;
138
+	$action_ref = has_action('AHEE__EE_Transaction__finalize__all_transaction') ? 'AHEE__EE_Transaction__finalize__all_transaction' : $action_ref;
139
+	if ($action_ref) {
140 140
 
141 141
 		EE_Error::doing_it_wrong(
142 142
 			$action_ref,
143 143
 			sprintf(
144
-				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso' ),
144
+				__('This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use one of the following new actions: %1$s"%3$s" found in "%2$s" %1$s"%4$s" found in "%2$s" %1$s"%5$s" found in "%2$s" %1$s"%6$s" found in "%2$s"', 'event_espresso'),
145 145
 				'<br />',
146 146
 				'/core/business/EE_Transaction_Processor.class.php',
147 147
 				'AHEE__EE_Transaction_Processor__finalize',
@@ -151,39 +151,39 @@  discard block
 block discarded – undo
151 151
 			),
152 152
 			'4.6.0'
153 153
 		);
154
-		switch ( $action_ref ) {
154
+		switch ($action_ref) {
155 155
 			case 'AHEE__EE_Transaction__finalize__new_transaction' :
156
-				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request );
156
+				do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, $checkout->admin_request);
157 157
 				break;
158 158
 			case 'AHEE__EE_Transaction__finalize__all_transaction' :
159
-				do_action( 'AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array( 'new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates ), $checkout->admin_request );
159
+				do_action('AHEE__EE_Transaction__finalize__new_transaction', $checkout->transaction, array('new_reg' => ! $checkout->revisit, 'to_approved' => $status_updates), $checkout->admin_request);
160 160
 				break;
161 161
 		}
162 162
 	}
163 163
 }
164
-add_action( 'AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2 );
164
+add_action('AHEE__EE_SPCO_Reg_Step_Finalize_Registration__process_reg_step__completed', 'ee_deprecated_finalize_transaction', 10, 2);
165 165
 /**
166 166
  * ee_deprecated_finalize_registration
167 167
  *
168 168
  * @param EE_Registration $registration
169 169
  */
170
-function ee_deprecated_finalize_registration( EE_Registration $registration ) {
171
-	$action_ref = has_action( 'AHEE__EE_Registration__finalize__update_and_new_reg' ) ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
172
-	if ( $action_ref ) {
170
+function ee_deprecated_finalize_registration(EE_Registration $registration) {
171
+	$action_ref = has_action('AHEE__EE_Registration__finalize__update_and_new_reg') ? 'AHEE__EE_Registration__finalize__update_and_new_reg' : NULL;
172
+	if ($action_ref) {
173 173
 		EE_Error::doing_it_wrong(
174 174
 			$action_ref,
175 175
 			sprintf(
176
-				__( 'This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso' ),
176
+				__('This action is deprecated.  It *may* work as an attempt to build in backwards compatibility.  However, it is recommended to use the following new action: %1$s"%3$s" found in "%2$s"', 'event_espresso'),
177 177
 				'<br />',
178 178
 				'/core/business/EE_Registration_Processor.class.php',
179 179
 				'AHEE__EE_Registration_Processor__trigger_registration_status_changed_hook'
180 180
 			),
181 181
 			'4.6.0'
182 182
 		);
183
-		do_action( 'AHEE__EE_Registration__finalize__update_and_new_reg', $registration, ( is_admin() && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )));
183
+		do_action('AHEE__EE_Registration__finalize__update_and_new_reg', $registration, (is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX)));
184 184
 	}
185 185
 }
186
-add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1 );
186
+add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', 'ee_deprecated_finalize_registration', 10, 1);
187 187
 
188 188
 
189 189
 
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
  * Called after EED_Module::set_hooks() and EED_Module::set_admin_hooks() was called.
192 192
  * Checks if any deprecated hooks were hooked-into and provide doing_it_wrong messages appropriately.
193 193
  */
194
-function ee_deprecated_hooks(){
194
+function ee_deprecated_hooks() {
195 195
 	/**
196 196
 	 * @var $hooks array where keys are hook names, and their values are array{
197 197
 	 *			@type string $version  when deprecated
@@ -202,25 +202,25 @@  discard block
 block discarded – undo
202 202
 	$hooks = array(
203 203
 		'AHEE__EE_System___do_setup_validations' => array(
204 204
 			'version' => '4.6.0',
205
-			'alternative' => __( 'Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso' ),
205
+			'alternative' => __('Instead use "AHEE__EEH_Activation__validate_messages_system" which is called after validating messages (done on every new install, upgrade, reactivation, and downgrade)', 'event_espresso'),
206 206
 			'still_works' => FALSE
207 207
 		)
208 208
 	);
209
-	foreach( $hooks as $name => $deprecation_info ){
210
-		if( has_action( $name ) ){
209
+	foreach ($hooks as $name => $deprecation_info) {
210
+		if (has_action($name)) {
211 211
 			EE_Error::doing_it_wrong(
212 212
 				$name,
213 213
 				sprintf(
214
-					__('This filter is deprecated. %1$s%2$s','event_espresso'),
215
-					$deprecation_info[ 'still_works' ] ?  __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __( 'It has been completely removed.', 'event_espresso' ),
216
-					isset( $deprecation_info[ 'alternative' ] ) ? $deprecation_info[ 'alternative' ] : __( 'Please read the current EE4 documentation further or contact Support.', 'event_espresso' )
214
+					__('This filter is deprecated. %1$s%2$s', 'event_espresso'),
215
+					$deprecation_info['still_works'] ? __('It *may* work as an attempt to build in backwards compatibility.', 'event_espresso') : __('It has been completely removed.', 'event_espresso'),
216
+					isset($deprecation_info['alternative']) ? $deprecation_info['alternative'] : __('Please read the current EE4 documentation further or contact Support.', 'event_espresso')
217 217
 				),
218
-				isset( $deprecation_info[ 'version' ] ) ? $deprecation_info[ 'version' ] : __( 'recently', 'event_espresso' )
218
+				isset($deprecation_info['version']) ? $deprecation_info['version'] : __('recently', 'event_espresso')
219 219
 			);
220 220
 		}
221 221
 	}
222 222
 }
223
-add_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks' );
223
+add_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons', 'ee_deprecated_hooks');
224 224
 
225 225
 
226 226
 
@@ -231,9 +231,9 @@  discard block
 block discarded – undo
231 231
  * @return boolean
232 232
  */
233 233
 function ee_deprecated_using_old_registration_admin_custom_questions_form_hooks() {
234
-	$in_use =  has_filter( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns' )
235
-			|| has_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save' );
236
-	if( $in_use ) {
234
+	$in_use = has_filter('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns')
235
+			|| has_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save');
236
+	if ($in_use) {
237 237
 		$msg = __(
238 238
 			'We detected you are using the filter FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns or AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save.'
239 239
 			. 'Both of these have been deprecated and should not be used anymore. You should instead use FHEE__EE_Form_Section_Proper___construct__options_array to customize the contents of the form,'
@@ -242,18 +242,18 @@  discard block
 block discarded – undo
242 242
 			'event_espresso' )
243 243
 		;
244 244
 		EE_Error::doing_it_wrong(
245
-			__CLASS__ . '::' . __FUNCTION__,
245
+			__CLASS__.'::'.__FUNCTION__,
246 246
 			$msg,
247 247
 			'4.8.32.rc.000'
248 248
 		);
249 249
 		//it seems the doing_it_wrong messages get output during some hidden html tags, so add an error to make sure this gets noticed
250
-		if ( is_admin() && ! defined( 'DOING_AJAX' ) ) {
251
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
250
+		if (is_admin() && ! defined('DOING_AJAX')) {
251
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
252 252
 		}
253 253
 	}
254 254
 	return $in_use;
255 255
 }
256
-add_action( 'AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks' );
256
+add_action('AHEE__Registrations_Admin_Page___registration_details_metabox__start', 'ee_deprecated_using_old_registration_admin_custom_questions_form_hooks');
257 257
 
258 258
 /**
259 259
  * @deprecated since 4.8.32.rc.000 because it has issues on https://events.codebasehq.com/projects/event-espresso/tickets/9165
@@ -262,34 +262,34 @@  discard block
 block discarded – undo
262 262
  * @param EE_Admin_Page $admin_page
263 263
  * @return void
264 264
  */
265
-function ee_deprecated_update_attendee_registration_form_old( $admin_page ) {
265
+function ee_deprecated_update_attendee_registration_form_old($admin_page) {
266 266
 	//check if the old hooks are in use. If not, do the default
267
-	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
268
-		|| ! $admin_page instanceof EE_Admin_Page ) {
267
+	if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
268
+		|| ! $admin_page instanceof EE_Admin_Page) {
269 269
 		return;
270 270
 	}
271 271
 	$req_data = $admin_page->get_request_data();
272
-	$qstns = isset( $req_data['qstn'] ) ? $req_data['qstn'] : FALSE;
273
-	$REG_ID = isset( $req_data['_REG_ID'] ) ? absint( $req_data['_REG_ID'] ) : FALSE;
274
-	$qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns );
275
-	if ( ! $REG_ID || ! $qstns ) {
276
-		EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
272
+	$qstns = isset($req_data['qstn']) ? $req_data['qstn'] : FALSE;
273
+	$REG_ID = isset($req_data['_REG_ID']) ? absint($req_data['_REG_ID']) : FALSE;
274
+	$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
275
+	if ( ! $REG_ID || ! $qstns) {
276
+		EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
277 277
 	}
278 278
 	$success = TRUE;
279 279
 
280 280
 	// allow others to get in on this awesome fun   :D
281
-	do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns );
281
+	do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns);
282 282
 	// loop thru questions... FINALLY!!!
283 283
 
284
-	foreach ( $qstns as $QST_ID => $qstn ) {
284
+	foreach ($qstns as $QST_ID => $qstn) {
285 285
 		//if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
286
-		if ( !is_array($qstn) ) {
287
-			$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
286
+		if ( ! is_array($qstn)) {
287
+			$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
288 288
 			continue;
289 289
 		}
290 290
 
291 291
 
292
-		foreach ( $qstn as $ANS_ID => $ANS_value ) {
292
+		foreach ($qstn as $ANS_ID => $ANS_value) {
293 293
 			//get answer
294 294
 			$query_params = array(
295 295
 				0 => array(
@@ -300,7 +300,7 @@  discard block
 block discarded – undo
300 300
 				);
301 301
 			$answer = EEM_Answer::instance()->get_one($query_params);
302 302
 			//this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
303
-			if ( ! $answer instanceof EE_Answer ) {
303
+			if ( ! $answer instanceof EE_Answer) {
304 304
 				$set_values = array(
305 305
 					'QST_ID' => $QST_ID,
306 306
 					'REG_ID' => $REG_ID,
@@ -315,11 +315,11 @@  discard block
 block discarded – undo
315 315
 		}
316 316
 	}
317 317
 	$what = __('Registration Form', 'event_espresso');
318
-	$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
319
-	$admin_page->redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
318
+	$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
319
+	$admin_page->redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
320 320
 	exit;
321 321
 }
322
-add_action( 'AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1 );
322
+add_action('AHEE__Registrations_Admin_Page___update_attendee_registration_form__start', 'ee_deprecated_update_attendee_registration_form_old', 10, 1);
323 323
 /**
324 324
  * Render the registration admin page's custom questions area in the old fashion
325 325
  * and firing the old hooks. When this method is removed, we can probably also
@@ -332,31 +332,31 @@  discard block
 block discarded – undo
332 332
  * @return bool
333 333
  * @throws \EE_Error
334 334
  */
335
-function ee_deprecated_reg_questions_meta_box_old( $do_default_action, $admin_page, $registration ) {
335
+function ee_deprecated_reg_questions_meta_box_old($do_default_action, $admin_page, $registration) {
336 336
 	//check if the old hooks are in use. If not, do the default
337
-	if( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
338
-		|| ! $admin_page instanceof EE_Admin_Page ) {
337
+	if ( ! ee_deprecated_using_old_registration_admin_custom_questions_form_hooks()
338
+		|| ! $admin_page instanceof EE_Admin_Page) {
339 339
 		return $do_default_action;
340 340
 	}
341
-	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $admin_page, 'form_before_question_group' ), 10, 1 );
342
-	add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $admin_page, 'form_after_question_group' ), 10, 1 );
343
-	add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $admin_page, 'form_form_field_label_wrap' ), 10, 1 );
344
-	add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $admin_page, 'form_form_field_input__wrap' ), 10, 1 );
341
+	add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($admin_page, 'form_before_question_group'), 10, 1);
342
+	add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($admin_page, 'form_after_question_group'), 10, 1);
343
+	add_filter('FHEE__EEH_Form_Fields__label_html', array($admin_page, 'form_form_field_label_wrap'), 10, 1);
344
+	add_filter('FHEE__EEH_Form_Fields__input_html', array($admin_page, 'form_form_field_input__wrap'), 10, 1);
345 345
 
346
-	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $registration, $registration->get('EVT_ID') );
346
+	$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($registration, $registration->get('EVT_ID'));
347 347
 
348
-	EE_Registry::instance()->load_helper( 'Form_Fields' );
348
+	EE_Registry::instance()->load_helper('Form_Fields');
349 349
 	$template_args = array(
350
-		'att_questions' => EEH_Form_Fields::generate_question_groups_html( $question_groups ),
350
+		'att_questions' => EEH_Form_Fields::generate_question_groups_html($question_groups),
351 351
 		'reg_questions_form_action' => 'edit_registration',
352 352
 		'REG_ID' => $registration->ID()
353 353
 	);
354
-	$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
355
-	echo EEH_Template::display_template( $template_path, $template_args, TRUE );
354
+	$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
355
+	echo EEH_Template::display_template($template_path, $template_args, TRUE);
356 356
 	//indicate that we should not do the default admin page code
357 357
 	return false;
358 358
 }
359
-add_action( 'FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3 );
359
+add_action('FHEE__Registrations_Admin_Page___reg_questions_meta_box__do_default', 'ee_deprecated_reg_questions_meta_box_old', 10, 3);
360 360
 
361 361
 
362 362
 
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 			'4.9.0'
398 398
 		);
399 399
 		/** @var EE_Message_Resource_Manager $message_resource_manager */
400
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
401
-		$messenger = $message_resource_manager->get_messenger( $messenger_name );
402
-		$message_type = $message_resource_manager->get_message_type( $message_type_name );
400
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
401
+		$messenger = $message_resource_manager->get_messenger($messenger_name);
402
+		$message_type = $message_resource_manager->get_message_type($message_type_name);
403 403
 		return EE_Registry::instance()->load_lib(
404 404
 			'Messages_Template_Defaults',
405 405
 			array(
@@ -464,15 +464,15 @@  discard block
 block discarded – undo
464 464
 	/**
465 465
 	 * @param string $method
466 466
 	 */
467
-	public function _class_is_deprecated( $method ) {
467
+	public function _class_is_deprecated($method) {
468 468
 		EE_Error::doing_it_wrong(
469
-			'EE_messages::' . $method,
470
-			__( 'EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.' ),
469
+			'EE_messages::'.$method,
470
+			__('EE_messages has been deprecated.  Please use EE_Message_Resource_Manager instead.'),
471 471
 			'4.9.0',
472 472
 			'4.10.0.p'
473 473
 		);
474 474
 		// Please use EE_Message_Resource_Manager instead
475
-		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
475
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
476 476
 	}
477 477
 
478 478
 
@@ -482,10 +482,10 @@  discard block
 block discarded – undo
482 482
 	 * @param string $messenger_name
483 483
 	 * @return boolean TRUE if it was PREVIOUSLY active, and FALSE if it was previously inactive
484 484
 	 */
485
-	public function ensure_messenger_is_active( $messenger_name ) {
485
+	public function ensure_messenger_is_active($messenger_name) {
486 486
 		// EE_messages has been deprecated
487
-		$this->_class_is_deprecated( __FUNCTION__ );
488
-		return $this->_message_resource_manager->ensure_messenger_is_active( $messenger_name );
487
+		$this->_class_is_deprecated(__FUNCTION__);
488
+		return $this->_message_resource_manager->ensure_messenger_is_active($messenger_name);
489 489
 	}
490 490
 
491 491
 
@@ -497,10 +497,10 @@  discard block
 block discarded – undo
497 497
 	 * @return bool true if it got activated (or was active) and false if not.
498 498
 	 * @throws \EE_Error
499 499
 	 */
500
-	public function ensure_message_type_is_active( $message_type, $messenger ) {
500
+	public function ensure_message_type_is_active($message_type, $messenger) {
501 501
 		// EE_messages has been deprecated
502
-		$this->_class_is_deprecated( __FUNCTION__ );
503
-		return $this->_message_resource_manager->ensure_message_type_is_active( $message_type, $messenger );
502
+		$this->_class_is_deprecated(__FUNCTION__);
503
+		return $this->_message_resource_manager->ensure_message_type_is_active($message_type, $messenger);
504 504
 	}
505 505
 
506 506
 
@@ -513,10 +513,10 @@  discard block
 block discarded – undo
513 513
 	 *                                            they are already setup.)
514 514
 	 * @return boolean an array of generated templates or false if nothing generated/activated.
515 515
 	 */
516
-	public function activate_messenger( $messenger_name, $mts_to_activate = array() ) {
516
+	public function activate_messenger($messenger_name, $mts_to_activate = array()) {
517 517
 		// EE_messages has been deprecated
518
-		$this->_class_is_deprecated( __FUNCTION__ );
519
-		return $this->_message_resource_manager->activate_messenger( $messenger_name, $mts_to_activate );
518
+		$this->_class_is_deprecated(__FUNCTION__);
519
+		return $this->_message_resource_manager->activate_messenger($messenger_name, $mts_to_activate);
520 520
 	}
521 521
 
522 522
 
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
 	 *
529 529
 	 * @return bool true is a generating messenger and can be sent OR FALSE meaning cannot send.
530 530
 	 */
531
-	public function is_generating_messenger_and_active( EE_messenger $messenger, EE_message_type $message_type ) {
531
+	public function is_generating_messenger_and_active(EE_messenger $messenger, EE_message_type $message_type) {
532 532
 		// EE_messages has been deprecated
533
-		$this->_class_is_deprecated( __FUNCTION__ );
534
-		return $this->_message_resource_manager->is_generating_messenger_and_active( $messenger, $message_type );
533
+		$this->_class_is_deprecated(__FUNCTION__);
534
+		return $this->_message_resource_manager->is_generating_messenger_and_active($messenger, $message_type);
535 535
 	}
536 536
 
537 537
 
@@ -541,10 +541,10 @@  discard block
 block discarded – undo
541 541
 	 * @param string $messenger
542 542
 	 * @return EE_messenger | null
543 543
 	 */
544
-	public function get_messenger_if_active( $messenger ) {
544
+	public function get_messenger_if_active($messenger) {
545 545
 		// EE_messages has been deprecated
546
-		$this->_class_is_deprecated( __FUNCTION__ );
547
-		return $this->_message_resource_manager->get_active_messenger( $messenger );
546
+		$this->_class_is_deprecated(__FUNCTION__);
547
+		return $this->_message_resource_manager->get_active_messenger($messenger);
548 548
 	}
549 549
 
550 550
 
@@ -565,9 +565,9 @@  discard block
 block discarded – undo
565 565
 	 *                  'message_type' => null
566 566
 	 *                  )
567 567
 	 */
568
-	public function validate_for_use( EE_Message $message ) {
568
+	public function validate_for_use(EE_Message $message) {
569 569
 		// EE_messages has been deprecated
570
-		$this->_class_is_deprecated( __FUNCTION__ );
570
+		$this->_class_is_deprecated(__FUNCTION__);
571 571
 		return array(
572 572
 			'messenger'    => $message->messenger_object(),
573 573
 			'message_type' => $message->message_type_object(),
@@ -595,41 +595,41 @@  discard block
 block discarded – undo
595 595
 		$send = true
596 596
 	) {
597 597
 		// EE_messages has been deprecated
598
-		$this->_class_is_deprecated( __FUNCTION__ );
598
+		$this->_class_is_deprecated(__FUNCTION__);
599 599
 		/** @type EE_Messages_Processor $processor */
600
-		$processor = EE_Registry::instance()->load_lib( 'Messages_Processor' );
600
+		$processor = EE_Registry::instance()->load_lib('Messages_Processor');
601 601
 		$error = false;
602 602
 		//try to intelligently determine what method we'll call based on the incoming data.
603 603
 		//if generating and sending are different then generate and send immediately.
604
-		if ( ! empty( $sending_messenger ) && $sending_messenger != $generating_messenger && $send ) {
604
+		if ( ! empty($sending_messenger) && $sending_messenger != $generating_messenger && $send) {
605 605
 			//in the legacy system, when generating and sending were different, that means all the
606 606
 			//vars are already in the request object.  So let's just use that.
607 607
 			try {
608 608
 				/** @type EE_Message_To_Generate_From_Request $mtg */
609
-				$mtg = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' );
610
-				$processor->generate_and_send_now( $mtg );
611
-			} catch ( EE_Error $e ) {
609
+				$mtg = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
610
+				$processor->generate_and_send_now($mtg);
611
+			} catch (EE_Error $e) {
612 612
 				$error_msg = __(
613 613
 					'Please note that a system message failed to send due to a technical issue.',
614 614
 					'event_espresso'
615 615
 				);
616 616
 				// add specific message for developers if WP_DEBUG in on
617
-				$error_msg .= '||' . $e->getMessage();
618
-				EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
617
+				$error_msg .= '||'.$e->getMessage();
618
+				EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
619 619
 				$error = true;
620 620
 			}
621 621
 		} else {
622
-			$processor->generate_for_all_active_messengers( $type, $vars, $send );
622
+			$processor->generate_for_all_active_messengers($type, $vars, $send);
623 623
 			//let's find out if there were any errors and how many successfully were queued.
624 624
 			$count_errors = $processor->get_queue()->count_STS_in_queue(
625
-				array( EEM_Message::status_failed, EEM_Message::status_debug_only )
625
+				array(EEM_Message::status_failed, EEM_Message::status_debug_only)
626 626
 			);
627
-			$count_queued = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete );
628
-			$count_retry = $processor->get_queue()->count_STS_in_queue( EEM_Message::status_retry );
627
+			$count_queued = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
628
+			$count_retry = $processor->get_queue()->count_STS_in_queue(EEM_Message::status_retry);
629 629
 			$count_errors = $count_errors + $count_retry;
630
-			if ( $count_errors > 0 ) {
630
+			if ($count_errors > 0) {
631 631
 				$error = true;
632
-				if ( $count_errors > 1 && $count_retry > 1 && $count_queued > 1 ) {
632
+				if ($count_errors > 1 && $count_retry > 1 && $count_queued > 1) {
633 633
 					$message = sprintf(
634 634
 						__(
635 635
 							'There were %d errors and %d messages successfully queued for generation and sending',
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 						$count_errors,
639 639
 						$count_queued
640 640
 					);
641
-				} elseif ( $count_errors > 1 && $count_queued === 1 ) {
641
+				} elseif ($count_errors > 1 && $count_queued === 1) {
642 642
 					$message = sprintf(
643 643
 						__(
644 644
 							'There were %d errors and %d message successfully queued for generation.',
@@ -647,7 +647,7 @@  discard block
 block discarded – undo
647 647
 						$count_errors,
648 648
 						$count_queued
649 649
 					);
650
-				} elseif ( $count_errors === 1 && $count_queued > 1 ) {
650
+				} elseif ($count_errors === 1 && $count_queued > 1) {
651 651
 					$message = sprintf(
652 652
 						__(
653 653
 							'There was %d error and %d messages successfully queued for generation.',
@@ -665,9 +665,9 @@  discard block
 block discarded – undo
665 665
 						$count_errors
666 666
 					);
667 667
 				}
668
-				EE_Error::add_error( $message, __FILE__, __FUNCTION__, __LINE__ );
668
+				EE_Error::add_error($message, __FILE__, __FUNCTION__, __LINE__);
669 669
 			} else {
670
-				if ( $count_queued === 1 ) {
670
+				if ($count_queued === 1) {
671 671
 					$message = sprintf(
672 672
 						__(
673 673
 							'%d message successfully queued for generation.',
@@ -684,18 +684,18 @@  discard block
 block discarded – undo
684 684
 						$count_queued
685 685
 					);
686 686
 				}
687
-				EE_Error::add_success( $message );
687
+				EE_Error::add_success($message);
688 688
 			}
689 689
 		}
690 690
 		//if no error then return the generated message(s).
691
-		if ( ! $error && ! $send ) {
692
-			$generated_queue = $processor->generate_queue( false );
691
+		if ( ! $error && ! $send) {
692
+			$generated_queue = $processor->generate_queue(false);
693 693
 			//get message and return.
694 694
 			$generated_queue->get_message_repository()->rewind();
695 695
 			$messages = array();
696
-			while ( $generated_queue->get_message_repository()->valid() ) {
696
+			while ($generated_queue->get_message_repository()->valid()) {
697 697
 				$message = $generated_queue->get_message_repository()->current();
698
-				if ( $message instanceof EE_Message ) {
698
+				if ($message instanceof EE_Message) {
699 699
 					//set properties that might be expected by add-ons (backward compat)
700 700
 					$message->content = $message->content();
701 701
 					$message->template_pack = $message->get_template_pack();
@@ -720,10 +720,10 @@  discard block
 block discarded – undo
720 720
 	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular preview
721 721
 	 * @return string          The body of the message.
722 722
 	 */
723
-	public function preview_message( $type, $context, $messenger, $send = false ) {
723
+	public function preview_message($type, $context, $messenger, $send = false) {
724 724
 		// EE_messages has been deprecated
725
-		$this->_class_is_deprecated( __FUNCTION__ );
726
-		return EED_Messages::preview_message( $type, $context, $messenger, $send );
725
+		$this->_class_is_deprecated(__FUNCTION__);
726
+		return EED_Messages::preview_message($type, $context, $messenger, $send);
727 727
 	}
728 728
 
729 729
 
@@ -737,14 +737,14 @@  discard block
 block discarded – undo
737 737
 	 *
738 738
 	 * @return bool          success or fail.
739 739
 	 */
740
-	public function send_message_with_messenger_only( $messenger, $message_type, $message ) {
740
+	public function send_message_with_messenger_only($messenger, $message_type, $message) {
741 741
 		// EE_messages has been deprecated
742
-		$this->_class_is_deprecated( __FUNCTION__ );
742
+		$this->_class_is_deprecated(__FUNCTION__);
743 743
 		//setup for sending to new method.
744 744
 		/** @type EE_Messages_Queue $queue */
745
-		$queue = EE_Registry::instance()->load_lib( 'Messages_Queue' );
745
+		$queue = EE_Registry::instance()->load_lib('Messages_Queue');
746 746
 		//make sure we have a proper message object
747
-		if ( ! $message instanceof EE_Message && is_object( $message ) && isset( $message->content ) ) {
747
+		if ( ! $message instanceof EE_Message && is_object($message) && isset($message->content)) {
748 748
 			$msg = EE_Message_Factory::create(
749 749
 				array(
750 750
 					'MSG_messenger'    => $messenger,
@@ -756,15 +756,15 @@  discard block
 block discarded – undo
756 756
 		} else {
757 757
 			$msg = $message;
758 758
 		}
759
-		if ( ! $msg instanceof EE_Message ) {
759
+		if ( ! $msg instanceof EE_Message) {
760 760
 			return false;
761 761
 		}
762 762
 		//make sure any content in a content property (if not empty) is set on the MSG_content.
763
-		if ( ! empty( $msg->content ) ) {
764
-			$msg->set( 'MSG_content', $msg->content );
763
+		if ( ! empty($msg->content)) {
764
+			$msg->set('MSG_content', $msg->content);
765 765
 		}
766
-		$queue->add( $msg );
767
-		return EED_Messages::send_message_with_messenger_only( $messenger, $message_type, $queue );
766
+		$queue->add($msg);
767
+		return EED_Messages::send_message_with_messenger_only($messenger, $message_type, $queue);
768 768
 	}
769 769
 
770 770
 
@@ -778,11 +778,11 @@  discard block
 block discarded – undo
778 778
 	 * @return array|object if creation is successful then we return an array of info, otherwise an error_object is returned.
779 779
 	 * @throws \EE_Error
780 780
 	 */
781
-	public function create_new_templates( $messenger, $message_type, $GRP_ID = 0, $is_global = false ) {
781
+	public function create_new_templates($messenger, $message_type, $GRP_ID = 0, $is_global = false) {
782 782
 		// EE_messages has been deprecated
783
-		$this->_class_is_deprecated( __FUNCTION__ );
784
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
785
-		return EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $is_global );
783
+		$this->_class_is_deprecated(__FUNCTION__);
784
+		EE_Registry::instance()->load_helper('MSG_Template');
785
+		return EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $is_global);
786 786
 	}
787 787
 
788 788
 
@@ -793,11 +793,11 @@  discard block
 block discarded – undo
793 793
 	 * @param  string $message_type_name name of EE_message_type
794 794
 	 * @return array
795 795
 	 */
796
-	public function get_fields( $messenger_name, $message_type_name ) {
796
+	public function get_fields($messenger_name, $message_type_name) {
797 797
 		// EE_messages has been deprecated
798
-		$this->_class_is_deprecated( __FUNCTION__ );
799
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
800
-		return EEH_MSG_Template::get_fields( $messenger_name, $message_type_name );
798
+		$this->_class_is_deprecated(__FUNCTION__);
799
+		EE_Registry::instance()->load_helper('MSG_Template');
800
+		return EEH_MSG_Template::get_fields($messenger_name, $message_type_name);
801 801
 	}
802 802
 
803 803
 
@@ -811,13 +811,13 @@  discard block
 block discarded – undo
811 811
 	 * @return array                    multidimensional array of messenger and message_type objects
812 812
 	 *                                    (messengers index, and message_type index);
813 813
 	 */
814
-	public function get_installed( $type = 'all', $skip_cache = false ) {
814
+	public function get_installed($type = 'all', $skip_cache = false) {
815 815
 		// EE_messages has been deprecated
816
-		$this->_class_is_deprecated( __FUNCTION__ );
817
-		if ( $skip_cache ) {
816
+		$this->_class_is_deprecated(__FUNCTION__);
817
+		if ($skip_cache) {
818 818
 			$this->_message_resource_manager->reset_active_messengers_and_message_types();
819 819
 		}
820
-		switch ( $type ) {
820
+		switch ($type) {
821 821
 			case 'messengers' :
822 822
 				return array(
823 823
 					'messenger' => $this->_message_resource_manager->installed_messengers(),
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 	 */
847 847
 	public function get_active_messengers() {
848 848
 		// EE_messages has been deprecated
849
-		$this->_class_is_deprecated( __FUNCTION__ );
849
+		$this->_class_is_deprecated(__FUNCTION__);
850 850
 		return $this->_message_resource_manager->active_messengers();
851 851
 	}
852 852
 
@@ -858,7 +858,7 @@  discard block
 block discarded – undo
858 858
 	 */
859 859
 	public function get_active_message_types() {
860 860
 		// EE_messages has been deprecated
861
-		$this->_class_is_deprecated( __FUNCTION__ );
861
+		$this->_class_is_deprecated(__FUNCTION__);
862 862
 		return $this->_message_resource_manager->list_of_active_message_types();
863 863
 	}
864 864
 
@@ -870,7 +870,7 @@  discard block
 block discarded – undo
870 870
 	 */
871 871
 	public function get_active_message_type_objects() {
872 872
 		// EE_messages has been deprecated
873
-		$this->_class_is_deprecated( __FUNCTION__ );
873
+		$this->_class_is_deprecated(__FUNCTION__);
874 874
 		return $this->_message_resource_manager->get_active_message_type_objects();
875 875
 	}
876 876
 
@@ -882,10 +882,10 @@  discard block
 block discarded – undo
882 882
 	 * @param string $messenger The messenger being checked
883 883
 	 * @return EE_message_type[]    (or empty array if none present)
884 884
 	 */
885
-	public function get_active_message_types_per_messenger( $messenger ) {
885
+	public function get_active_message_types_per_messenger($messenger) {
886 886
 		// EE_messages has been deprecated
887
-		$this->_class_is_deprecated( __FUNCTION__ );
888
-		return $this->_message_resource_manager->get_active_message_types_for_messenger( $messenger );
887
+		$this->_class_is_deprecated(__FUNCTION__);
888
+		return $this->_message_resource_manager->get_active_message_types_for_messenger($messenger);
889 889
 	}
890 890
 
891 891
 
@@ -896,10 +896,10 @@  discard block
 block discarded – undo
896 896
 	 * @param string $message_type The string should correspond to a message type.
897 897
 	 * @return EE_message_type|null
898 898
 	 */
899
-	public function get_active_message_type( $messenger, $message_type ) {
899
+	public function get_active_message_type($messenger, $message_type) {
900 900
 		// EE_messages has been deprecated
901
-		$this->_class_is_deprecated( __FUNCTION__ );
902
-		return $this->_message_resource_manager->get_active_message_type_for_messenger( $messenger, $message_type );
901
+		$this->_class_is_deprecated(__FUNCTION__);
902
+		return $this->_message_resource_manager->get_active_message_type_for_messenger($messenger, $message_type);
903 903
 	}
904 904
 
905 905
 
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
 	 */
911 911
 	public function get_installed_message_types() {
912 912
 		// EE_messages has been deprecated
913
-		$this->_class_is_deprecated( __FUNCTION__ );
913
+		$this->_class_is_deprecated(__FUNCTION__);
914 914
 		return $this->_message_resource_manager->installed_message_types();
915 915
 	}
916 916
 
@@ -922,7 +922,7 @@  discard block
 block discarded – undo
922 922
 	 */
923 923
 	public function get_installed_messengers() {
924 924
 		// EE_messages has been deprecated
925
-		$this->_class_is_deprecated( __FUNCTION__ );
925
+		$this->_class_is_deprecated(__FUNCTION__);
926 926
 		return $this->_message_resource_manager->installed_messengers();
927 927
 	}
928 928
 
@@ -933,10 +933,10 @@  discard block
 block discarded – undo
933 933
 	 * @param   bool $slugs_only Whether to return an array of just slugs and labels (true) or all contexts indexed by message type.
934 934
 	 * @return array
935 935
 	 */
936
-	public function get_all_contexts( $slugs_only = true ) {
936
+	public function get_all_contexts($slugs_only = true) {
937 937
 		// EE_messages has been deprecated
938
-		$this->_class_is_deprecated( __FUNCTION__ );
939
-		return $this->_message_resource_manager->get_all_contexts( $slugs_only );
938
+		$this->_class_is_deprecated(__FUNCTION__);
939
+		return $this->_message_resource_manager->get_all_contexts($slugs_only);
940 940
 	}
941 941
 
942 942
 
@@ -995,7 +995,7 @@  discard block
 block discarded – undo
995 995
 add_filter(
996 996
 	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__css',
997 997
 	function($event_list_iframe_css) {
998
-		if ( ! has_filter( 'FHEE__EventsArchiveIframe__event_list_iframe__css' )) {
998
+		if ( ! has_filter('FHEE__EventsArchiveIframe__event_list_iframe__css')) {
999 999
 			return $event_list_iframe_css;
1000 1000
 		}
1001 1001
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1015,7 +1015,7 @@  discard block
 block discarded – undo
1015 1015
 add_filter(
1016 1016
 	'FHEE__EventEspresso_modules_events_archive_EventsArchiveIframe__display__js',
1017 1017
 	function($event_list_iframe_js) {
1018
-		if ( ! has_filter( 'FHEE__EED_Ticket_Selector__ticket_selector_iframe__js' )) {
1018
+		if ( ! has_filter('FHEE__EED_Ticket_Selector__ticket_selector_iframe__js')) {
1019 1019
 			return $event_list_iframe_js;
1020 1020
 		}
1021 1021
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1035,7 +1035,7 @@  discard block
 block discarded – undo
1035 1035
 add_action(
1036 1036
 	'AHEE__EE_Capabilities__addCaps__complete',
1037 1037
 	function($capabilities_map) {
1038
-		if ( ! has_action( 'AHEE__EE_Capabilities__init_role_caps__complete' )) {
1038
+		if ( ! has_action('AHEE__EE_Capabilities__init_role_caps__complete')) {
1039 1039
 			return;
1040 1040
 		}
1041 1041
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1055,7 +1055,7 @@  discard block
 block discarded – undo
1055 1055
 add_filter(
1056 1056
 	'FHEE_EventEspresso_core_services_commands_attendee_CreateAttendeeCommandHandler__findExistingAttendee__existing_attendee',
1057 1057
 	function($existing_attendee, $registration, $attendee_data) {
1058
-		if ( ! has_filter( 'FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee' )) {
1058
+		if ( ! has_filter('FHEE_EE_Single_Page_Checkout__save_registration_items__find_existing_attendee')) {
1059 1059
 			return $existing_attendee;
1060 1060
 		}
1061 1061
 		deprecated_espresso_action_or_filter_doing_it_wrong(
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
             $existing_attendee, $registration, $attendee_data
1072 1072
         );
1073 1073
 	},
1074
-	10,3
1074
+	10, 3
1075 1075
 );
1076 1076
 
1077 1077
 /**
@@ -1135,7 +1135,7 @@  discard block
 block discarded – undo
1135 1135
      */
1136 1136
     public function event_list_title($event_list_title = '')
1137 1137
     {
1138
-        if (! empty($this->title)) {
1138
+        if ( ! empty($this->title)) {
1139 1139
             return $this->title;
1140 1140
         }
1141 1141
         return $event_list_title;
Please login to merge, or discard this patch.
core/helpers/EEH_Activation.helper.php 2 patches
Indentation   +1652 added lines, -1652 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\interfaces\ResettableInterface;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -17,243 +17,243 @@  discard block
 block discarded – undo
17 17
 class EEH_Activation implements ResettableInterface
18 18
 {
19 19
 
20
-    /**
21
-     * constant used to indicate a cron task is no longer in use
22
-     */
23
-    const cron_task_no_longer_in_use = 'no_longer_in_use';
24
-
25
-    /**
26
-     * option name that will indicate whether or not we still
27
-     * need to create EE's folders in the uploads directory
28
-     * (because if EE was installed without file system access,
29
-     * we need to request credentials before we can create them)
30
-     */
31
-    const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
32
-
33
-    /**
34
-     * WP_User->ID
35
-     *
36
-     * @var int
37
-     */
38
-    private static $_default_creator_id;
39
-
40
-    /**
41
-     * indicates whether or not we've already verified core's default data during this request,
42
-     * because after migrations are done, any addons activated while in maintenance mode
43
-     * will want to setup their own default data, and they might hook into core's default data
44
-     * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
45
-     * This prevents doing that for EVERY single addon.
46
-     *
47
-     * @var boolean
48
-     */
49
-    protected static $_initialized_db_content_already_in_this_request = false;
50
-
51
-    /**
52
-     * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
53
-     */
54
-    private static $table_analysis;
55
-
56
-    /**
57
-     * @var \EventEspresso\core\services\database\TableManager $table_manager
58
-     */
59
-    private static $table_manager;
60
-
61
-
62
-    /**
63
-     * @return \EventEspresso\core\services\database\TableAnalysis
64
-     */
65
-    public static function getTableAnalysis()
66
-    {
67
-        if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
68
-            self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
69
-        }
70
-        return self::$table_analysis;
71
-    }
72
-
73
-
74
-    /**
75
-     * @return \EventEspresso\core\services\database\TableManager
76
-     */
77
-    public static function getTableManager()
78
-    {
79
-        if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
80
-            self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
81
-        }
82
-        return self::$table_manager;
83
-    }
84
-
85
-
86
-    /**
87
-     *    _ensure_table_name_has_prefix
88
-     *
89
-     * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
90
-     * @access     public
91
-     * @static
92
-     * @param $table_name
93
-     * @return string
94
-     */
95
-    public static function ensure_table_name_has_prefix($table_name)
96
-    {
97
-        return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
98
-    }
99
-
100
-
101
-    /**
102
-     *    system_initialization
103
-     *    ensures the EE configuration settings are loaded with at least default options set
104
-     *    and that all critical EE pages have been generated with the appropriate shortcodes in place
105
-     *
106
-     * @access public
107
-     * @static
108
-     * @return void
109
-     */
110
-    public static function system_initialization()
111
-    {
112
-        EEH_Activation::reset_and_update_config();
113
-        //which is fired BEFORE activation of plugin anyways
114
-        EEH_Activation::verify_default_pages_exist();
115
-    }
116
-
117
-
118
-    /**
119
-     * Sets the database schema and creates folders. This should
120
-     * be called on plugin activation and reactivation
121
-     *
122
-     * @return boolean success, whether the database and folders are setup properly
123
-     * @throws \EE_Error
124
-     */
125
-    public static function initialize_db_and_folders()
126
-    {
127
-        $good_filesystem = EEH_Activation::create_upload_directories();
128
-        $good_db         = EEH_Activation::create_database_tables();
129
-        return $good_filesystem && $good_db;
130
-    }
131
-
132
-
133
-    /**
134
-     * assuming we have an up-to-date database schema, this will populate it
135
-     * with default and initial data. This should be called
136
-     * upon activation of a new plugin, reactivation, and at the end
137
-     * of running migration scripts
138
-     *
139
-     * @throws \EE_Error
140
-     */
141
-    public static function initialize_db_content()
142
-    {
143
-        //let's avoid doing all this logic repeatedly, especially when addons are requesting it
144
-        if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
145
-            return;
146
-        }
147
-        EEH_Activation::$_initialized_db_content_already_in_this_request = true;
148
-
149
-        EEH_Activation::initialize_system_questions();
150
-        EEH_Activation::insert_default_status_codes();
151
-        EEH_Activation::generate_default_message_templates();
152
-        EEH_Activation::create_no_ticket_prices_array();
153
-
154
-        EEH_Activation::validate_messages_system();
155
-        EEH_Activation::insert_default_payment_methods();
156
-        //in case we've
157
-        EEH_Activation::remove_cron_tasks();
158
-        EEH_Activation::create_cron_tasks();
159
-        // remove all TXN locks since that is being done via extra meta now
160
-        delete_option('ee_locked_transactions');
161
-        //also, check for CAF default db content
162
-        do_action('AHEE__EEH_Activation__initialize_db_content');
163
-        //also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
164
-        //which users really won't care about on initial activation
165
-        EE_Error::overwrite_success();
166
-    }
167
-
168
-
169
-    /**
170
-     * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
171
-     * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
172
-     * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
173
-     * (null)
174
-     *
175
-     * @param string $which_to_include can be 'current' (ones that are currently in use),
176
-     *                                 'old' (only returns ones that should no longer be used),or 'all',
177
-     * @return array
178
-     * @throws \EE_Error
179
-     */
180
-    public static function get_cron_tasks($which_to_include)
181
-    {
182
-        $cron_tasks = apply_filters(
183
-            'FHEE__EEH_Activation__get_cron_tasks',
184
-            array(
185
-                'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
20
+	/**
21
+	 * constant used to indicate a cron task is no longer in use
22
+	 */
23
+	const cron_task_no_longer_in_use = 'no_longer_in_use';
24
+
25
+	/**
26
+	 * option name that will indicate whether or not we still
27
+	 * need to create EE's folders in the uploads directory
28
+	 * (because if EE was installed without file system access,
29
+	 * we need to request credentials before we can create them)
30
+	 */
31
+	const upload_directories_incomplete_option_name = 'ee_upload_directories_incomplete';
32
+
33
+	/**
34
+	 * WP_User->ID
35
+	 *
36
+	 * @var int
37
+	 */
38
+	private static $_default_creator_id;
39
+
40
+	/**
41
+	 * indicates whether or not we've already verified core's default data during this request,
42
+	 * because after migrations are done, any addons activated while in maintenance mode
43
+	 * will want to setup their own default data, and they might hook into core's default data
44
+	 * and trigger core to setup its default data. In which case they might all ask for core to init its default data.
45
+	 * This prevents doing that for EVERY single addon.
46
+	 *
47
+	 * @var boolean
48
+	 */
49
+	protected static $_initialized_db_content_already_in_this_request = false;
50
+
51
+	/**
52
+	 * @var \EventEspresso\core\services\database\TableAnalysis $table_analysis
53
+	 */
54
+	private static $table_analysis;
55
+
56
+	/**
57
+	 * @var \EventEspresso\core\services\database\TableManager $table_manager
58
+	 */
59
+	private static $table_manager;
60
+
61
+
62
+	/**
63
+	 * @return \EventEspresso\core\services\database\TableAnalysis
64
+	 */
65
+	public static function getTableAnalysis()
66
+	{
67
+		if (! self::$table_analysis instanceof \EventEspresso\core\services\database\TableAnalysis) {
68
+			self::$table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true);
69
+		}
70
+		return self::$table_analysis;
71
+	}
72
+
73
+
74
+	/**
75
+	 * @return \EventEspresso\core\services\database\TableManager
76
+	 */
77
+	public static function getTableManager()
78
+	{
79
+		if (! self::$table_manager instanceof \EventEspresso\core\services\database\TableManager) {
80
+			self::$table_manager = EE_Registry::instance()->create('TableManager', array(), true);
81
+		}
82
+		return self::$table_manager;
83
+	}
84
+
85
+
86
+	/**
87
+	 *    _ensure_table_name_has_prefix
88
+	 *
89
+	 * @deprecated instead use TableAnalysis::ensureTableNameHasPrefix()
90
+	 * @access     public
91
+	 * @static
92
+	 * @param $table_name
93
+	 * @return string
94
+	 */
95
+	public static function ensure_table_name_has_prefix($table_name)
96
+	{
97
+		return \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix($table_name);
98
+	}
99
+
100
+
101
+	/**
102
+	 *    system_initialization
103
+	 *    ensures the EE configuration settings are loaded with at least default options set
104
+	 *    and that all critical EE pages have been generated with the appropriate shortcodes in place
105
+	 *
106
+	 * @access public
107
+	 * @static
108
+	 * @return void
109
+	 */
110
+	public static function system_initialization()
111
+	{
112
+		EEH_Activation::reset_and_update_config();
113
+		//which is fired BEFORE activation of plugin anyways
114
+		EEH_Activation::verify_default_pages_exist();
115
+	}
116
+
117
+
118
+	/**
119
+	 * Sets the database schema and creates folders. This should
120
+	 * be called on plugin activation and reactivation
121
+	 *
122
+	 * @return boolean success, whether the database and folders are setup properly
123
+	 * @throws \EE_Error
124
+	 */
125
+	public static function initialize_db_and_folders()
126
+	{
127
+		$good_filesystem = EEH_Activation::create_upload_directories();
128
+		$good_db         = EEH_Activation::create_database_tables();
129
+		return $good_filesystem && $good_db;
130
+	}
131
+
132
+
133
+	/**
134
+	 * assuming we have an up-to-date database schema, this will populate it
135
+	 * with default and initial data. This should be called
136
+	 * upon activation of a new plugin, reactivation, and at the end
137
+	 * of running migration scripts
138
+	 *
139
+	 * @throws \EE_Error
140
+	 */
141
+	public static function initialize_db_content()
142
+	{
143
+		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
144
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
145
+			return;
146
+		}
147
+		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
148
+
149
+		EEH_Activation::initialize_system_questions();
150
+		EEH_Activation::insert_default_status_codes();
151
+		EEH_Activation::generate_default_message_templates();
152
+		EEH_Activation::create_no_ticket_prices_array();
153
+
154
+		EEH_Activation::validate_messages_system();
155
+		EEH_Activation::insert_default_payment_methods();
156
+		//in case we've
157
+		EEH_Activation::remove_cron_tasks();
158
+		EEH_Activation::create_cron_tasks();
159
+		// remove all TXN locks since that is being done via extra meta now
160
+		delete_option('ee_locked_transactions');
161
+		//also, check for CAF default db content
162
+		do_action('AHEE__EEH_Activation__initialize_db_content');
163
+		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
164
+		//which users really won't care about on initial activation
165
+		EE_Error::overwrite_success();
166
+	}
167
+
168
+
169
+	/**
170
+	 * Returns an array of cron tasks. Array values are the actions fired by the cron tasks (the "hooks"),
171
+	 * values are the frequency (the "recurrence"). See http://codex.wordpress.org/Function_Reference/wp_schedule_event
172
+	 * If the cron task should NO longer be used, it should have a value of EEH_Activation::cron_task_no_longer_in_use
173
+	 * (null)
174
+	 *
175
+	 * @param string $which_to_include can be 'current' (ones that are currently in use),
176
+	 *                                 'old' (only returns ones that should no longer be used),or 'all',
177
+	 * @return array
178
+	 * @throws \EE_Error
179
+	 */
180
+	public static function get_cron_tasks($which_to_include)
181
+	{
182
+		$cron_tasks = apply_filters(
183
+			'FHEE__EEH_Activation__get_cron_tasks',
184
+			array(
185
+				'AHEE__EE_Cron_Tasks__clean_up_junk_transactions'      => 'hourly',
186 186
 //				'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions' => EEH_Activation::cron_task_no_longer_in_use, actually this is still in use
187
-                'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
188
-                //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
189
-                'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
190
-            )
191
-        );
192
-        if ($which_to_include === 'old') {
193
-            $cron_tasks = array_filter(
194
-                $cron_tasks,
195
-                function ($value) {
196
-                    return $value === EEH_Activation::cron_task_no_longer_in_use;
197
-                }
198
-            );
199
-        } elseif ($which_to_include === 'current') {
200
-            $cron_tasks = array_filter($cron_tasks);
201
-        } elseif (WP_DEBUG && $which_to_include !== 'all') {
202
-            throw new EE_Error(
203
-                sprintf(
204
-                    __(
205
-                        'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
206
-                        'event_espresso'
207
-                    ),
208
-                    $which_to_include
209
-                )
210
-            );
211
-        }
212
-        return $cron_tasks;
213
-    }
214
-
215
-
216
-    /**
217
-     * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
218
-     *
219
-     * @throws \EE_Error
220
-     */
221
-    public static function create_cron_tasks()
222
-    {
223
-
224
-        foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
225
-            if (! wp_next_scheduled($hook_name)) {
226
-                /**
227
-                 * This allows client code to define the initial start timestamp for this schedule.
228
-                 */
229
-                if (is_array($frequency)
230
-                    && count($frequency) === 2
231
-                    && isset($frequency[0], $frequency[1])
232
-                ) {
233
-                    $start_timestamp = $frequency[0];
234
-                    $frequency = $frequency[1];
235
-                } else {
236
-                    $start_timestamp = time();
237
-                }
238
-                wp_schedule_event($start_timestamp, $frequency, $hook_name);
239
-            }
240
-        }
241
-
242
-    }
243
-
244
-
245
-    /**
246
-     * Remove the currently-existing and now-removed cron tasks.
247
-     *
248
-     * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
249
-     * @throws \EE_Error
250
-     */
251
-    public static function remove_cron_tasks($remove_all = true)
252
-    {
253
-        $cron_tasks_to_remove = $remove_all ? 'all' : 'old';
254
-        $crons                = _get_cron_array();
255
-        $crons                = is_array($crons) ? $crons : array();
256
-        /* reminder of what $crons look like:
187
+				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use,
188
+				//there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
189
+				'AHEE_EE_Cron_Tasks__clean_out_old_gateway_logs'       => 'daily',
190
+			)
191
+		);
192
+		if ($which_to_include === 'old') {
193
+			$cron_tasks = array_filter(
194
+				$cron_tasks,
195
+				function ($value) {
196
+					return $value === EEH_Activation::cron_task_no_longer_in_use;
197
+				}
198
+			);
199
+		} elseif ($which_to_include === 'current') {
200
+			$cron_tasks = array_filter($cron_tasks);
201
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
202
+			throw new EE_Error(
203
+				sprintf(
204
+					__(
205
+						'Invalid argument of "%1$s" passed to EEH_Activation::get_cron_tasks. Valid values are "all", "old" and "current".',
206
+						'event_espresso'
207
+					),
208
+					$which_to_include
209
+				)
210
+			);
211
+		}
212
+		return $cron_tasks;
213
+	}
214
+
215
+
216
+	/**
217
+	 * Ensure cron tasks are setup (the removal of crons should be done by remove_crons())
218
+	 *
219
+	 * @throws \EE_Error
220
+	 */
221
+	public static function create_cron_tasks()
222
+	{
223
+
224
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
225
+			if (! wp_next_scheduled($hook_name)) {
226
+				/**
227
+				 * This allows client code to define the initial start timestamp for this schedule.
228
+				 */
229
+				if (is_array($frequency)
230
+					&& count($frequency) === 2
231
+					&& isset($frequency[0], $frequency[1])
232
+				) {
233
+					$start_timestamp = $frequency[0];
234
+					$frequency = $frequency[1];
235
+				} else {
236
+					$start_timestamp = time();
237
+				}
238
+				wp_schedule_event($start_timestamp, $frequency, $hook_name);
239
+			}
240
+		}
241
+
242
+	}
243
+
244
+
245
+	/**
246
+	 * Remove the currently-existing and now-removed cron tasks.
247
+	 *
248
+	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
249
+	 * @throws \EE_Error
250
+	 */
251
+	public static function remove_cron_tasks($remove_all = true)
252
+	{
253
+		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
254
+		$crons                = _get_cron_array();
255
+		$crons                = is_array($crons) ? $crons : array();
256
+		/* reminder of what $crons look like:
257 257
          * Top-level keys are timestamps, and their values are arrays.
258 258
          * The 2nd level arrays have keys with each of the cron task hook names to run at that time
259 259
          * and their values are arrays.
@@ -270,912 +270,912 @@  discard block
 block discarded – undo
270 270
          *					...
271 271
          *      ...
272 272
          */
273
-        $ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
274
-        foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
275
-            if (is_array($hooks_to_fire_at_time)) {
276
-                foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
277
-                    if (isset($ee_cron_tasks_to_remove[$hook_name])
278
-                        && is_array($ee_cron_tasks_to_remove[$hook_name])
279
-                    ) {
280
-                        unset($crons[$timestamp][$hook_name]);
281
-                    }
282
-                }
283
-                //also take care of any empty cron timestamps.
284
-                if (empty($hooks_to_fire_at_time)) {
285
-                    unset($crons[$timestamp]);
286
-                }
287
-            }
288
-        }
289
-        _set_cron_array($crons);
290
-    }
291
-
292
-
293
-    /**
294
-     *    CPT_initialization
295
-     *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
296
-     *
297
-     * @access public
298
-     * @static
299
-     * @return void
300
-     */
301
-    public static function CPT_initialization()
302
-    {
303
-        // register Custom Post Types
304
-        EE_Registry::instance()->load_core('Register_CPTs');
305
-        flush_rewrite_rules();
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     *    reset_and_update_config
312
-     * The following code was moved over from EE_Config so that it will no longer run on every request.
313
-     * If there is old calendar config data saved, then it will get converted on activation.
314
-     * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
315
-     *
316
-     * @access public
317
-     * @static
318
-     * @return void
319
-     */
320
-    public static function reset_and_update_config()
321
-    {
322
-        do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
323
-        add_filter(
324
-            'FHEE__EE_Config___load_core_config__config_settings',
325
-            array('EEH_Activation', 'migrate_old_config_data'),
326
-            10,
327
-            3
328
-        );
329
-        //EE_Config::reset();
330
-        if (! EE_Config::logging_enabled()) {
331
-            delete_option(EE_Config::LOG_NAME);
332
-        }
333
-    }
334
-
335
-
336
-    /**
337
-     *    load_calendar_config
338
-     *
339
-     * @access    public
340
-     * @return    void
341
-     */
342
-    public static function load_calendar_config()
343
-    {
344
-        // grab array of all plugin folders and loop thru it
345
-        $plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
346
-        if (empty($plugins)) {
347
-            return;
348
-        }
349
-        foreach ($plugins as $plugin_path) {
350
-            // grab plugin folder name from path
351
-            $plugin = basename($plugin_path);
352
-            // drill down to Espresso plugins
353
-            // then to calendar related plugins
354
-            if (
355
-                strpos($plugin, 'espresso') !== false
356
-                || strpos($plugin, 'Espresso') !== false
357
-                || strpos($plugin, 'ee4') !== false
358
-                || strpos($plugin, 'EE4') !== false
359
-                || strpos($plugin, 'calendar') !== false
360
-            ) {
361
-                // this is what we are looking for
362
-                $calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
363
-                // does it exist in this folder ?
364
-                if (is_readable($calendar_config)) {
365
-                    // YEAH! let's load it
366
-                    require_once($calendar_config);
367
-                }
368
-            }
369
-        }
370
-    }
371
-
372
-
373
-
374
-    /**
375
-     *    _migrate_old_config_data
376
-     *
377
-     * @access    public
378
-     * @param array|stdClass $settings
379
-     * @param string         $config
380
-     * @param \EE_Config     $EE_Config
381
-     * @return \stdClass
382
-     */
383
-    public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
384
-    {
385
-        $convert_from_array = array('addons');
386
-        // in case old settings were saved as an array
387
-        if (is_array($settings) && in_array($config, $convert_from_array)) {
388
-            // convert existing settings to an object
389
-            $config_array = $settings;
390
-            $settings = new stdClass();
391
-            foreach ($config_array as $key => $value) {
392
-                if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
393
-                    $EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
394
-                } else {
395
-                    $settings->{$key} = $value;
396
-                }
397
-            }
398
-            add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
399
-        }
400
-        return $settings;
401
-    }
402
-
403
-
404
-    /**
405
-     * deactivate_event_espresso
406
-     *
407
-     * @access public
408
-     * @static
409
-     * @return void
410
-     */
411
-    public static function deactivate_event_espresso()
412
-    {
413
-        // check permissions
414
-        if (current_user_can('activate_plugins')) {
415
-            deactivate_plugins(EE_PLUGIN_BASENAME, true);
416
-        }
417
-    }
418
-
419
-
420
-
421
-
422
-
423
-    /**
424
-     * verify_default_pages_exist
425
-     *
426
-     * @access public
427
-     * @static
428
-     * @return void
429
-     */
430
-    public static function verify_default_pages_exist()
431
-    {
432
-        $critical_page_problem = false;
433
-        $critical_pages = array(
434
-            array(
435
-                'id'   => 'reg_page_id',
436
-                'name' => __('Registration Checkout', 'event_espresso'),
437
-                'post' => null,
438
-                'code' => 'ESPRESSO_CHECKOUT',
439
-            ),
440
-            array(
441
-                'id'   => 'txn_page_id',
442
-                'name' => __('Transactions', 'event_espresso'),
443
-                'post' => null,
444
-                'code' => 'ESPRESSO_TXN_PAGE',
445
-            ),
446
-            array(
447
-                'id'   => 'thank_you_page_id',
448
-                'name' => __('Thank You', 'event_espresso'),
449
-                'post' => null,
450
-                'code' => 'ESPRESSO_THANK_YOU',
451
-            ),
452
-            array(
453
-                'id'   => 'cancel_page_id',
454
-                'name' => __('Registration Cancelled', 'event_espresso'),
455
-                'post' => null,
456
-                'code' => 'ESPRESSO_CANCELLED',
457
-            ),
458
-        );
459
-        $EE_Core_Config = EE_Registry::instance()->CFG->core;
460
-        foreach ($critical_pages as $critical_page) {
461
-            // is critical page ID set in config ?
462
-            if ($EE_Core_Config->{$critical_page['id']} !== false) {
463
-                // attempt to find post by ID
464
-                $critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
465
-            }
466
-            // no dice?
467
-            if ($critical_page['post'] === null) {
468
-                // attempt to find post by title
469
-                $critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
470
-                // still nothing?
471
-                if ($critical_page['post'] === null) {
472
-                    $critical_page = EEH_Activation::create_critical_page($critical_page);
473
-                    // REALLY? Still nothing ??!?!?
474
-                    if ($critical_page['post'] === null) {
475
-                        $msg = __(
476
-                            'The Event Espresso critical page configuration settings could not be updated.',
477
-                            'event_espresso'
478
-                        );
479
-                        EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
480
-                        break;
481
-                    }
482
-                }
483
-            }
484
-            // check that Post ID matches critical page ID in config
485
-            if (
486
-                isset($critical_page['post']->ID)
487
-                && $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
488
-            ) {
489
-                //update Config with post ID
490
-                $EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
-                if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
-                    $msg = __(
493
-                        'The Event Espresso critical page configuration settings could not be updated.',
494
-                        'event_espresso'
495
-                    );
496
-                    EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
497
-                }
498
-            }
499
-            $critical_page_problem =
500
-                ! isset($critical_page['post']->post_status)
501
-                || $critical_page['post']->post_status !== 'publish'
502
-                || strpos($critical_page['post']->post_content, $critical_page['code']) === false
503
-                    ? true
504
-                    : $critical_page_problem;
505
-        }
506
-        if ($critical_page_problem) {
507
-            $msg = sprintf(
508
-                __(
509
-                    'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
510
-                    'event_espresso'
511
-                ),
512
-                '<a href="'
513
-                . admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
514
-                . '">'
515
-                . __('Event Espresso Critical Pages Settings', 'event_espresso')
516
-                . '</a>'
517
-            );
518
-            EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
519
-        }
520
-        if (EE_Error::has_notices()) {
521
-            EE_Error::get_notices(false, true, true);
522
-        }
523
-    }
524
-
525
-
526
-
527
-    /**
528
-     * Returns the first post which uses the specified shortcode
529
-     *
530
-     * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
531
-     *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
532
-     *                             "[ESPRESSO_THANK_YOU"
533
-     *                             (we don't search for the closing shortcode bracket because they might have added
534
-     *                             parameter to the shortcode
535
-     * @return WP_Post or NULl
536
-     */
537
-    public static function get_page_by_ee_shortcode($ee_shortcode)
538
-    {
539
-        global $wpdb;
540
-        $shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
-        $post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542
-        if ($post_id) {
543
-            return get_post($post_id);
544
-        } else {
545
-            return null;
546
-        }
547
-    }
548
-
549
-
550
-    /**
551
-     *    This function generates a post for critical espresso pages
552
-     *
553
-     * @access public
554
-     * @static
555
-     * @param array $critical_page
556
-     * @return array
557
-     */
558
-    public static function create_critical_page($critical_page)
559
-    {
560
-
561
-        $post_args = array(
562
-            'post_title'     => $critical_page['name'],
563
-            'post_status'    => 'publish',
564
-            'post_type'      => 'page',
565
-            'comment_status' => 'closed',
566
-            'post_content'   => '[' . $critical_page['code'] . ']',
567
-        );
568
-
569
-        $post_id = wp_insert_post($post_args);
570
-        if (! $post_id) {
571
-            $msg = sprintf(
572
-                __('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573
-                $critical_page['name']
574
-            );
575
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
576
-            return $critical_page;
577
-        }
578
-        // get newly created post's details
579
-        if (! $critical_page['post'] = get_post($post_id)) {
580
-            $msg = sprintf(
581
-                __('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582
-                $critical_page['name']
583
-            );
584
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
585
-        }
586
-
587
-        return $critical_page;
588
-
589
-    }
590
-
591
-
592
-
593
-
594
-    /**
595
-     * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
596
-     * The role being used to check is filterable.
597
-     *
598
-     * @since  4.6.0
599
-     * @global WPDB $wpdb
600
-     * @return mixed null|int WP_user ID or NULL
601
-     */
602
-    public static function get_default_creator_id()
603
-    {
604
-        global $wpdb;
605
-        if ( ! empty(self::$_default_creator_id)) {
606
-            return self::$_default_creator_id;
607
-        }/**/
608
-        $role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
609
-        //let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
610
-        $pre_filtered_id = apply_filters(
611
-            'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
612
-            false,
613
-            $role_to_check
614
-        );
615
-        if ($pre_filtered_id !== false) {
616
-            return (int)$pre_filtered_id;
617
-        }
618
-        $capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619
-        $query = $wpdb->prepare(
620
-            "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
-            '%' . $role_to_check . '%'
622
-        );
623
-        $user_id = $wpdb->get_var($query);
624
-        $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
-        if ($user_id && (int)$user_id) {
626
-            self::$_default_creator_id = (int)$user_id;
627
-            return self::$_default_creator_id;
628
-        } else {
629
-            return null;
630
-        }
631
-    }
632
-
633
-
634
-
635
-    /**
636
-     * used by EE and EE addons during plugin activation to create tables.
637
-     * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
638
-     * but includes extra logic regarding activations.
639
-     *
640
-     * @access public
641
-     * @static
642
-     * @param string  $table_name              without the $wpdb->prefix
643
-     * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
644
-     *                                         table query)
645
-     * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
646
-     * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
647
-     *                                         and new once this function is done (ie, you really do want to CREATE a
648
-     *                                         table, and expect it to be empty once you're done) leave as FALSE when
649
-     *                                         you just want to verify the table exists and matches this definition
650
-     *                                         (and if it HAS data in it you want to leave it be)
651
-     * @return void
652
-     * @throws EE_Error if there are database errors
653
-     */
654
-    public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
655
-    {
656
-        if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
657
-            return;
658
-        }
659
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660
-        if ( ! function_exists('dbDelta')) {
661
-            require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
662
-        }
663
-        $tableAnalysis = \EEH_Activation::getTableAnalysis();
664
-        $wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
665
-        // do we need to first delete an existing version of this table ?
666
-        if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
667
-            // ok, delete the table... but ONLY if it's empty
668
-            $deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
669
-            // table is NOT empty, are you SURE you want to delete this table ???
670
-            if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
671
-                \EEH_Activation::getTableManager()->dropTable($wp_table_name);
672
-            } else if ( ! $deleted_safely) {
673
-                // so we should be more cautious rather than just dropping tables so easily
674
-                error_log(
675
-                    sprintf(
676
-                        __(
677
-                            'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
678
-                            'event_espresso'
679
-                        ),
680
-                        $wp_table_name,
681
-                        '<br/>',
682
-                        'espresso_db_update'
683
-                    )
684
-                );
685
-            }
686
-        }
687
-        $engine = str_replace('ENGINE=', '', $engine);
688
-        \EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
689
-    }
690
-
691
-
692
-
693
-    /**
694
-     *    add_column_if_it_doesn't_exist
695
-     *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
696
-     *
697
-     * @access     public
698
-     * @static
699
-     * @deprecated instead use TableManager::addColumn()
700
-     * @param string $table_name  (without "wp_", eg "esp_attendee"
701
-     * @param string $column_name
702
-     * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
703
-     *                            'VARCHAR(10)'
704
-     * @return bool|int
705
-     */
706
-    public static function add_column_if_it_doesnt_exist(
707
-        $table_name,
708
-        $column_name,
709
-        $column_info = 'INT UNSIGNED NOT NULL'
710
-    ) {
711
-        return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
712
-    }
713
-
714
-
715
-    /**
716
-     * get_fields_on_table
717
-     * Gets all the fields on the database table.
718
-     *
719
-     * @access     public
720
-     * @deprecated instead use TableManager::getTableColumns()
721
-     * @static
722
-     * @param string $table_name , without prefixed $wpdb->prefix
723
-     * @return array of database column names
724
-     */
725
-    public static function get_fields_on_table($table_name = null)
726
-    {
727
-        return \EEH_Activation::getTableManager()->getTableColumns($table_name);
728
-    }
729
-
730
-
731
-    /**
732
-     * db_table_is_empty
733
-     *
734
-     * @access     public\
735
-     * @deprecated instead use TableAnalysis::tableIsEmpty()
736
-     * @static
737
-     * @param string $table_name
738
-     * @return bool
739
-     */
740
-    public static function db_table_is_empty($table_name)
741
-    {
742
-        return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
743
-    }
744
-
745
-
746
-    /**
747
-     * delete_db_table_if_empty
748
-     *
749
-     * @access public
750
-     * @static
751
-     * @param string $table_name
752
-     * @return bool | int
753
-     */
754
-    public static function delete_db_table_if_empty($table_name)
755
-    {
756
-        if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
757
-            return \EEH_Activation::getTableManager()->dropTable($table_name);
758
-        }
759
-        return false;
760
-    }
761
-
762
-
763
-    /**
764
-     * delete_unused_db_table
765
-     *
766
-     * @access     public
767
-     * @static
768
-     * @deprecated instead use TableManager::dropTable()
769
-     * @param string $table_name
770
-     * @return bool | int
771
-     */
772
-    public static function delete_unused_db_table($table_name)
773
-    {
774
-        return \EEH_Activation::getTableManager()->dropTable($table_name);
775
-    }
776
-
777
-
778
-    /**
779
-     * drop_index
780
-     *
781
-     * @access     public
782
-     * @static
783
-     * @deprecated instead use TableManager::dropIndex()
784
-     * @param string $table_name
785
-     * @param string $index_name
786
-     * @return bool | int
787
-     */
788
-    public static function drop_index($table_name, $index_name)
789
-    {
790
-        return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
791
-    }
792
-
793
-
794
-
795
-    /**
796
-     * create_database_tables
797
-     *
798
-     * @access public
799
-     * @static
800
-     * @throws EE_Error
801
-     * @return boolean success (whether database is setup properly or not)
802
-     */
803
-    public static function create_database_tables()
804
-    {
805
-        EE_Registry::instance()->load_core('Data_Migration_Manager');
806
-        //find the migration script that sets the database to be compatible with the code
807
-        $dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
808
-        if ($dms_name) {
809
-            $current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
810
-            $current_data_migration_script->set_migrating(false);
811
-            $current_data_migration_script->schema_changes_before_migration();
812
-            $current_data_migration_script->schema_changes_after_migration();
813
-            if ($current_data_migration_script->get_errors()) {
814
-                if (WP_DEBUG) {
815
-                    foreach ($current_data_migration_script->get_errors() as $error) {
816
-                        EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
817
-                    }
818
-                } else {
819
-                    EE_Error::add_error(
820
-                        __(
821
-                            'There were errors creating the Event Espresso database tables and Event Espresso has been 
273
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
274
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
275
+			if (is_array($hooks_to_fire_at_time)) {
276
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
277
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
278
+						&& is_array($ee_cron_tasks_to_remove[$hook_name])
279
+					) {
280
+						unset($crons[$timestamp][$hook_name]);
281
+					}
282
+				}
283
+				//also take care of any empty cron timestamps.
284
+				if (empty($hooks_to_fire_at_time)) {
285
+					unset($crons[$timestamp]);
286
+				}
287
+			}
288
+		}
289
+		_set_cron_array($crons);
290
+	}
291
+
292
+
293
+	/**
294
+	 *    CPT_initialization
295
+	 *    registers all EE CPTs ( Custom Post Types ) then flushes rewrite rules so that all endpoints exist
296
+	 *
297
+	 * @access public
298
+	 * @static
299
+	 * @return void
300
+	 */
301
+	public static function CPT_initialization()
302
+	{
303
+		// register Custom Post Types
304
+		EE_Registry::instance()->load_core('Register_CPTs');
305
+		flush_rewrite_rules();
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 *    reset_and_update_config
312
+	 * The following code was moved over from EE_Config so that it will no longer run on every request.
313
+	 * If there is old calendar config data saved, then it will get converted on activation.
314
+	 * This was basically a DMS before we had DMS's, and will get removed after a few more versions.
315
+	 *
316
+	 * @access public
317
+	 * @static
318
+	 * @return void
319
+	 */
320
+	public static function reset_and_update_config()
321
+	{
322
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
323
+		add_filter(
324
+			'FHEE__EE_Config___load_core_config__config_settings',
325
+			array('EEH_Activation', 'migrate_old_config_data'),
326
+			10,
327
+			3
328
+		);
329
+		//EE_Config::reset();
330
+		if (! EE_Config::logging_enabled()) {
331
+			delete_option(EE_Config::LOG_NAME);
332
+		}
333
+	}
334
+
335
+
336
+	/**
337
+	 *    load_calendar_config
338
+	 *
339
+	 * @access    public
340
+	 * @return    void
341
+	 */
342
+	public static function load_calendar_config()
343
+	{
344
+		// grab array of all plugin folders and loop thru it
345
+		$plugins = glob(WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR);
346
+		if (empty($plugins)) {
347
+			return;
348
+		}
349
+		foreach ($plugins as $plugin_path) {
350
+			// grab plugin folder name from path
351
+			$plugin = basename($plugin_path);
352
+			// drill down to Espresso plugins
353
+			// then to calendar related plugins
354
+			if (
355
+				strpos($plugin, 'espresso') !== false
356
+				|| strpos($plugin, 'Espresso') !== false
357
+				|| strpos($plugin, 'ee4') !== false
358
+				|| strpos($plugin, 'EE4') !== false
359
+				|| strpos($plugin, 'calendar') !== false
360
+			) {
361
+				// this is what we are looking for
362
+				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
363
+				// does it exist in this folder ?
364
+				if (is_readable($calendar_config)) {
365
+					// YEAH! let's load it
366
+					require_once($calendar_config);
367
+				}
368
+			}
369
+		}
370
+	}
371
+
372
+
373
+
374
+	/**
375
+	 *    _migrate_old_config_data
376
+	 *
377
+	 * @access    public
378
+	 * @param array|stdClass $settings
379
+	 * @param string         $config
380
+	 * @param \EE_Config     $EE_Config
381
+	 * @return \stdClass
382
+	 */
383
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config)
384
+	{
385
+		$convert_from_array = array('addons');
386
+		// in case old settings were saved as an array
387
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
388
+			// convert existing settings to an object
389
+			$config_array = $settings;
390
+			$settings = new stdClass();
391
+			foreach ($config_array as $key => $value) {
392
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
393
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
394
+				} else {
395
+					$settings->{$key} = $value;
396
+				}
397
+			}
398
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
399
+		}
400
+		return $settings;
401
+	}
402
+
403
+
404
+	/**
405
+	 * deactivate_event_espresso
406
+	 *
407
+	 * @access public
408
+	 * @static
409
+	 * @return void
410
+	 */
411
+	public static function deactivate_event_espresso()
412
+	{
413
+		// check permissions
414
+		if (current_user_can('activate_plugins')) {
415
+			deactivate_plugins(EE_PLUGIN_BASENAME, true);
416
+		}
417
+	}
418
+
419
+
420
+
421
+
422
+
423
+	/**
424
+	 * verify_default_pages_exist
425
+	 *
426
+	 * @access public
427
+	 * @static
428
+	 * @return void
429
+	 */
430
+	public static function verify_default_pages_exist()
431
+	{
432
+		$critical_page_problem = false;
433
+		$critical_pages = array(
434
+			array(
435
+				'id'   => 'reg_page_id',
436
+				'name' => __('Registration Checkout', 'event_espresso'),
437
+				'post' => null,
438
+				'code' => 'ESPRESSO_CHECKOUT',
439
+			),
440
+			array(
441
+				'id'   => 'txn_page_id',
442
+				'name' => __('Transactions', 'event_espresso'),
443
+				'post' => null,
444
+				'code' => 'ESPRESSO_TXN_PAGE',
445
+			),
446
+			array(
447
+				'id'   => 'thank_you_page_id',
448
+				'name' => __('Thank You', 'event_espresso'),
449
+				'post' => null,
450
+				'code' => 'ESPRESSO_THANK_YOU',
451
+			),
452
+			array(
453
+				'id'   => 'cancel_page_id',
454
+				'name' => __('Registration Cancelled', 'event_espresso'),
455
+				'post' => null,
456
+				'code' => 'ESPRESSO_CANCELLED',
457
+			),
458
+		);
459
+		$EE_Core_Config = EE_Registry::instance()->CFG->core;
460
+		foreach ($critical_pages as $critical_page) {
461
+			// is critical page ID set in config ?
462
+			if ($EE_Core_Config->{$critical_page['id']} !== false) {
463
+				// attempt to find post by ID
464
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']});
465
+			}
466
+			// no dice?
467
+			if ($critical_page['post'] === null) {
468
+				// attempt to find post by title
469
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
470
+				// still nothing?
471
+				if ($critical_page['post'] === null) {
472
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
473
+					// REALLY? Still nothing ??!?!?
474
+					if ($critical_page['post'] === null) {
475
+						$msg = __(
476
+							'The Event Espresso critical page configuration settings could not be updated.',
477
+							'event_espresso'
478
+						);
479
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
480
+						break;
481
+					}
482
+				}
483
+			}
484
+			// check that Post ID matches critical page ID in config
485
+			if (
486
+				isset($critical_page['post']->ID)
487
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
488
+			) {
489
+				//update Config with post ID
490
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
491
+				if (! EE_Config::instance()->update_espresso_config(false, false)) {
492
+					$msg = __(
493
+						'The Event Espresso critical page configuration settings could not be updated.',
494
+						'event_espresso'
495
+					);
496
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
497
+				}
498
+			}
499
+			$critical_page_problem =
500
+				! isset($critical_page['post']->post_status)
501
+				|| $critical_page['post']->post_status !== 'publish'
502
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === false
503
+					? true
504
+					: $critical_page_problem;
505
+		}
506
+		if ($critical_page_problem) {
507
+			$msg = sprintf(
508
+				__(
509
+					'A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.',
510
+					'event_espresso'
511
+				),
512
+				'<a href="'
513
+				. admin_url('admin.php?page=espresso_general_settings&action=critical_pages')
514
+				. '">'
515
+				. __('Event Espresso Critical Pages Settings', 'event_espresso')
516
+				. '</a>'
517
+			);
518
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
519
+		}
520
+		if (EE_Error::has_notices()) {
521
+			EE_Error::get_notices(false, true, true);
522
+		}
523
+	}
524
+
525
+
526
+
527
+	/**
528
+	 * Returns the first post which uses the specified shortcode
529
+	 *
530
+	 * @param string $ee_shortcode usually one of the critical pages shortcodes, eg
531
+	 *                             ESPRESSO_THANK_YOU. So we will search fora post with the content
532
+	 *                             "[ESPRESSO_THANK_YOU"
533
+	 *                             (we don't search for the closing shortcode bracket because they might have added
534
+	 *                             parameter to the shortcode
535
+	 * @return WP_Post or NULl
536
+	 */
537
+	public static function get_page_by_ee_shortcode($ee_shortcode)
538
+	{
539
+		global $wpdb;
540
+		$shortcode_and_opening_bracket = '[' . $ee_shortcode;
541
+		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
542
+		if ($post_id) {
543
+			return get_post($post_id);
544
+		} else {
545
+			return null;
546
+		}
547
+	}
548
+
549
+
550
+	/**
551
+	 *    This function generates a post for critical espresso pages
552
+	 *
553
+	 * @access public
554
+	 * @static
555
+	 * @param array $critical_page
556
+	 * @return array
557
+	 */
558
+	public static function create_critical_page($critical_page)
559
+	{
560
+
561
+		$post_args = array(
562
+			'post_title'     => $critical_page['name'],
563
+			'post_status'    => 'publish',
564
+			'post_type'      => 'page',
565
+			'comment_status' => 'closed',
566
+			'post_content'   => '[' . $critical_page['code'] . ']',
567
+		);
568
+
569
+		$post_id = wp_insert_post($post_args);
570
+		if (! $post_id) {
571
+			$msg = sprintf(
572
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
573
+				$critical_page['name']
574
+			);
575
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
576
+			return $critical_page;
577
+		}
578
+		// get newly created post's details
579
+		if (! $critical_page['post'] = get_post($post_id)) {
580
+			$msg = sprintf(
581
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
582
+				$critical_page['name']
583
+			);
584
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
585
+		}
586
+
587
+		return $critical_page;
588
+
589
+	}
590
+
591
+
592
+
593
+
594
+	/**
595
+	 * Tries to find the oldest admin for this site.  If there are no admins for this site then return NULL.
596
+	 * The role being used to check is filterable.
597
+	 *
598
+	 * @since  4.6.0
599
+	 * @global WPDB $wpdb
600
+	 * @return mixed null|int WP_user ID or NULL
601
+	 */
602
+	public static function get_default_creator_id()
603
+	{
604
+		global $wpdb;
605
+		if ( ! empty(self::$_default_creator_id)) {
606
+			return self::$_default_creator_id;
607
+		}/**/
608
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
609
+		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
610
+		$pre_filtered_id = apply_filters(
611
+			'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id',
612
+			false,
613
+			$role_to_check
614
+		);
615
+		if ($pre_filtered_id !== false) {
616
+			return (int)$pre_filtered_id;
617
+		}
618
+		$capabilities_key = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('capabilities');
619
+		$query = $wpdb->prepare(
620
+			"SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1",
621
+			'%' . $role_to_check . '%'
622
+		);
623
+		$user_id = $wpdb->get_var($query);
624
+		$user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
625
+		if ($user_id && (int)$user_id) {
626
+			self::$_default_creator_id = (int)$user_id;
627
+			return self::$_default_creator_id;
628
+		} else {
629
+			return null;
630
+		}
631
+	}
632
+
633
+
634
+
635
+	/**
636
+	 * used by EE and EE addons during plugin activation to create tables.
637
+	 * Its a wrapper for EventEspresso\core\services\database\TableManager::createTable,
638
+	 * but includes extra logic regarding activations.
639
+	 *
640
+	 * @access public
641
+	 * @static
642
+	 * @param string  $table_name              without the $wpdb->prefix
643
+	 * @param string  $sql                     SQL for creating the table (contents between brackets in an SQL create
644
+	 *                                         table query)
645
+	 * @param string  $engine                  like 'ENGINE=MyISAM' or 'ENGINE=InnoDB'
646
+	 * @param boolean $drop_pre_existing_table set to TRUE when you want to make SURE the table is completely empty
647
+	 *                                         and new once this function is done (ie, you really do want to CREATE a
648
+	 *                                         table, and expect it to be empty once you're done) leave as FALSE when
649
+	 *                                         you just want to verify the table exists and matches this definition
650
+	 *                                         (and if it HAS data in it you want to leave it be)
651
+	 * @return void
652
+	 * @throws EE_Error if there are database errors
653
+	 */
654
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false)
655
+	{
656
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', false, $table_name, $sql)) {
657
+			return;
658
+		}
659
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
660
+		if ( ! function_exists('dbDelta')) {
661
+			require_once(ABSPATH . 'wp-admin/includes/upgrade.php');
662
+		}
663
+		$tableAnalysis = \EEH_Activation::getTableAnalysis();
664
+		$wp_table_name = $tableAnalysis->ensureTableNameHasPrefix($table_name);
665
+		// do we need to first delete an existing version of this table ?
666
+		if ($drop_pre_existing_table && $tableAnalysis->tableExists($wp_table_name)) {
667
+			// ok, delete the table... but ONLY if it's empty
668
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
669
+			// table is NOT empty, are you SURE you want to delete this table ???
670
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
671
+				\EEH_Activation::getTableManager()->dropTable($wp_table_name);
672
+			} else if ( ! $deleted_safely) {
673
+				// so we should be more cautious rather than just dropping tables so easily
674
+				error_log(
675
+					sprintf(
676
+						__(
677
+							'It appears that database table "%1$s" exists when it shouldn\'t, and therefore may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend: %2$s 1. create a new COMPLETE backup of your database, %2$s 2. delete ALL tables from your database, %2$s 3. restore to your previous backup. %2$s If, however, you have not restored to a backup, then somehow your "%3$s" WordPress option could not be read. You can probably ignore this message, but should investigate why that option is being removed.',
678
+							'event_espresso'
679
+						),
680
+						$wp_table_name,
681
+						'<br/>',
682
+						'espresso_db_update'
683
+					)
684
+				);
685
+			}
686
+		}
687
+		$engine = str_replace('ENGINE=', '', $engine);
688
+		\EEH_Activation::getTableManager()->createTable($table_name, $sql, $engine);
689
+	}
690
+
691
+
692
+
693
+	/**
694
+	 *    add_column_if_it_doesn't_exist
695
+	 *    Checks if this column already exists on the specified table. Handy for addons which want to add a column
696
+	 *
697
+	 * @access     public
698
+	 * @static
699
+	 * @deprecated instead use TableManager::addColumn()
700
+	 * @param string $table_name  (without "wp_", eg "esp_attendee"
701
+	 * @param string $column_name
702
+	 * @param string $column_info if your SQL were 'ALTER TABLE table_name ADD price VARCHAR(10)', this would be
703
+	 *                            'VARCHAR(10)'
704
+	 * @return bool|int
705
+	 */
706
+	public static function add_column_if_it_doesnt_exist(
707
+		$table_name,
708
+		$column_name,
709
+		$column_info = 'INT UNSIGNED NOT NULL'
710
+	) {
711
+		return \EEH_Activation::getTableManager()->addColumn($table_name, $column_name, $column_info);
712
+	}
713
+
714
+
715
+	/**
716
+	 * get_fields_on_table
717
+	 * Gets all the fields on the database table.
718
+	 *
719
+	 * @access     public
720
+	 * @deprecated instead use TableManager::getTableColumns()
721
+	 * @static
722
+	 * @param string $table_name , without prefixed $wpdb->prefix
723
+	 * @return array of database column names
724
+	 */
725
+	public static function get_fields_on_table($table_name = null)
726
+	{
727
+		return \EEH_Activation::getTableManager()->getTableColumns($table_name);
728
+	}
729
+
730
+
731
+	/**
732
+	 * db_table_is_empty
733
+	 *
734
+	 * @access     public\
735
+	 * @deprecated instead use TableAnalysis::tableIsEmpty()
736
+	 * @static
737
+	 * @param string $table_name
738
+	 * @return bool
739
+	 */
740
+	public static function db_table_is_empty($table_name)
741
+	{
742
+		return \EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name);
743
+	}
744
+
745
+
746
+	/**
747
+	 * delete_db_table_if_empty
748
+	 *
749
+	 * @access public
750
+	 * @static
751
+	 * @param string $table_name
752
+	 * @return bool | int
753
+	 */
754
+	public static function delete_db_table_if_empty($table_name)
755
+	{
756
+		if (\EEH_Activation::getTableAnalysis()->tableIsEmpty($table_name)) {
757
+			return \EEH_Activation::getTableManager()->dropTable($table_name);
758
+		}
759
+		return false;
760
+	}
761
+
762
+
763
+	/**
764
+	 * delete_unused_db_table
765
+	 *
766
+	 * @access     public
767
+	 * @static
768
+	 * @deprecated instead use TableManager::dropTable()
769
+	 * @param string $table_name
770
+	 * @return bool | int
771
+	 */
772
+	public static function delete_unused_db_table($table_name)
773
+	{
774
+		return \EEH_Activation::getTableManager()->dropTable($table_name);
775
+	}
776
+
777
+
778
+	/**
779
+	 * drop_index
780
+	 *
781
+	 * @access     public
782
+	 * @static
783
+	 * @deprecated instead use TableManager::dropIndex()
784
+	 * @param string $table_name
785
+	 * @param string $index_name
786
+	 * @return bool | int
787
+	 */
788
+	public static function drop_index($table_name, $index_name)
789
+	{
790
+		return \EEH_Activation::getTableManager()->dropIndex($table_name, $index_name);
791
+	}
792
+
793
+
794
+
795
+	/**
796
+	 * create_database_tables
797
+	 *
798
+	 * @access public
799
+	 * @static
800
+	 * @throws EE_Error
801
+	 * @return boolean success (whether database is setup properly or not)
802
+	 */
803
+	public static function create_database_tables()
804
+	{
805
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
806
+		//find the migration script that sets the database to be compatible with the code
807
+		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
808
+		if ($dms_name) {
809
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
810
+			$current_data_migration_script->set_migrating(false);
811
+			$current_data_migration_script->schema_changes_before_migration();
812
+			$current_data_migration_script->schema_changes_after_migration();
813
+			if ($current_data_migration_script->get_errors()) {
814
+				if (WP_DEBUG) {
815
+					foreach ($current_data_migration_script->get_errors() as $error) {
816
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
817
+					}
818
+				} else {
819
+					EE_Error::add_error(
820
+						__(
821
+							'There were errors creating the Event Espresso database tables and Event Espresso has been 
822 822
                             deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.',
823
-                            'event_espresso'
824
-                        )
825
-                    );
826
-                }
827
-                return false;
828
-            }
829
-            EE_Data_Migration_Manager::instance()->update_current_database_state_to();
830
-        } else {
831
-            EE_Error::add_error(
832
-                __(
833
-                    'Could not determine most up-to-date data migration script from which to pull database schema
823
+							'event_espresso'
824
+						)
825
+					);
826
+				}
827
+				return false;
828
+			}
829
+			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
830
+		} else {
831
+			EE_Error::add_error(
832
+				__(
833
+					'Could not determine most up-to-date data migration script from which to pull database schema
834 834
                      structure. So database is probably not setup properly',
835
-                    'event_espresso'
836
-                ),
837
-                __FILE__,
838
-                __FUNCTION__,
839
-                __LINE__
840
-            );
841
-            return false;
842
-        }
843
-        return true;
844
-    }
845
-
846
-
847
-
848
-    /**
849
-     * initialize_system_questions
850
-     *
851
-     * @access public
852
-     * @static
853
-     * @return void
854
-     */
855
-    public static function initialize_system_questions()
856
-    {
857
-        // QUESTION GROUPS
858
-        global $wpdb;
859
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
860
-        $SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
861
-        // what we have
862
-        $question_groups = $wpdb->get_col($SQL);
863
-        // check the response
864
-        $question_groups = is_array($question_groups) ? $question_groups : array();
865
-        // what we should have
866
-        $QSG_systems = array(1, 2);
867
-        // loop thru what we should have and compare to what we have
868
-        foreach ($QSG_systems as $QSG_system) {
869
-            // reset values array
870
-            $QSG_values = array();
871
-            // if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
872
-            if (! in_array("$QSG_system", $question_groups)) {
873
-                // add it
874
-                switch ($QSG_system) {
875
-                    case 1:
876
-                        $QSG_values = array(
877
-                            'QSG_name'            => __('Personal Information', 'event_espresso'),
878
-                            'QSG_identifier'      => 'personal-information-' . time(),
879
-                            'QSG_desc'            => '',
880
-                            'QSG_order'           => 1,
881
-                            'QSG_show_group_name' => 1,
882
-                            'QSG_show_group_desc' => 1,
883
-                            'QSG_system'          => EEM_Question_Group::system_personal,
884
-                            'QSG_deleted'         => 0,
885
-                        );
886
-                        break;
887
-                    case 2:
888
-                        $QSG_values = array(
889
-                            'QSG_name'            => __('Address Information', 'event_espresso'),
890
-                            'QSG_identifier'      => 'address-information-' . time(),
891
-                            'QSG_desc'            => '',
892
-                            'QSG_order'           => 2,
893
-                            'QSG_show_group_name' => 1,
894
-                            'QSG_show_group_desc' => 1,
895
-                            'QSG_system'          => EEM_Question_Group::system_address,
896
-                            'QSG_deleted'         => 0,
897
-                        );
898
-                        break;
899
-                }
900
-                // make sure we have some values before inserting them
901
-                if (! empty($QSG_values)) {
902
-                    // insert system question
903
-                    $wpdb->insert(
904
-                        $table_name,
905
-                        $QSG_values,
906
-                        array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
907
-                    );
908
-                    $QSG_IDs[$QSG_system] = $wpdb->insert_id;
909
-                }
910
-            }
911
-        }
912
-        // QUESTIONS
913
-        global $wpdb;
914
-        $table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
915
-        $SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
916
-        // what we have
917
-        $questions = $wpdb->get_col($SQL);
918
-        // what we should have
919
-        $QST_systems = array(
920
-            'fname',
921
-            'lname',
922
-            'email',
923
-            'address',
924
-            'address2',
925
-            'city',
926
-            'country',
927
-            'state',
928
-            'zip',
929
-            'phone',
930
-        );
931
-        $order_for_group_1 = 1;
932
-        $order_for_group_2 = 1;
933
-        // loop thru what we should have and compare to what we have
934
-        foreach ($QST_systems as $QST_system) {
935
-            // reset values array
936
-            $QST_values = array();
937
-            // if we don't have what we should have
938
-            if (! in_array($QST_system, $questions)) {
939
-                // add it
940
-                switch ($QST_system) {
941
-                    case 'fname':
942
-                        $QST_values = array(
943
-                            'QST_display_text'  => __('First Name', 'event_espresso'),
944
-                            'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
945
-                            'QST_system'        => 'fname',
946
-                            'QST_type'          => 'TEXT',
947
-                            'QST_required'      => 1,
948
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
949
-                            'QST_order'         => 1,
950
-                            'QST_admin_only'    => 0,
951
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
952
-                            'QST_wp_user'       => self::get_default_creator_id(),
953
-                            'QST_deleted'       => 0,
954
-                        );
955
-                        break;
956
-                    case 'lname':
957
-                        $QST_values = array(
958
-                            'QST_display_text'  => __('Last Name', 'event_espresso'),
959
-                            'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
960
-                            'QST_system'        => 'lname',
961
-                            'QST_type'          => 'TEXT',
962
-                            'QST_required'      => 1,
963
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
964
-                            'QST_order'         => 2,
965
-                            'QST_admin_only'    => 0,
966
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
967
-                            'QST_wp_user'       => self::get_default_creator_id(),
968
-                            'QST_deleted'       => 0,
969
-                        );
970
-                        break;
971
-                    case 'email':
972
-                        $QST_values = array(
973
-                            'QST_display_text'  => __('Email Address', 'event_espresso'),
974
-                            'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
975
-                            'QST_system'        => 'email',
976
-                            'QST_type'          => 'EMAIL',
977
-                            'QST_required'      => 1,
978
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
979
-                            'QST_order'         => 3,
980
-                            'QST_admin_only'    => 0,
981
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982
-                            'QST_wp_user'       => self::get_default_creator_id(),
983
-                            'QST_deleted'       => 0,
984
-                        );
985
-                        break;
986
-                    case 'address':
987
-                        $QST_values = array(
988
-                            'QST_display_text'  => __('Address', 'event_espresso'),
989
-                            'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
990
-                            'QST_system'        => 'address',
991
-                            'QST_type'          => 'TEXT',
992
-                            'QST_required'      => 0,
993
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
994
-                            'QST_order'         => 4,
995
-                            'QST_admin_only'    => 0,
996
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
997
-                            'QST_wp_user'       => self::get_default_creator_id(),
998
-                            'QST_deleted'       => 0,
999
-                        );
1000
-                        break;
1001
-                    case 'address2':
1002
-                        $QST_values = array(
1003
-                            'QST_display_text'  => __('Address2', 'event_espresso'),
1004
-                            'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1005
-                            'QST_system'        => 'address2',
1006
-                            'QST_type'          => 'TEXT',
1007
-                            'QST_required'      => 0,
1008
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1009
-                            'QST_order'         => 5,
1010
-                            'QST_admin_only'    => 0,
1011
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012
-                            'QST_wp_user'       => self::get_default_creator_id(),
1013
-                            'QST_deleted'       => 0,
1014
-                        );
1015
-                        break;
1016
-                    case 'city':
1017
-                        $QST_values = array(
1018
-                            'QST_display_text'  => __('City', 'event_espresso'),
1019
-                            'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1020
-                            'QST_system'        => 'city',
1021
-                            'QST_type'          => 'TEXT',
1022
-                            'QST_required'      => 0,
1023
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1024
-                            'QST_order'         => 6,
1025
-                            'QST_admin_only'    => 0,
1026
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1027
-                            'QST_wp_user'       => self::get_default_creator_id(),
1028
-                            'QST_deleted'       => 0,
1029
-                        );
1030
-                        break;
1031
-                    case 'country':
1032
-                        $QST_values = array(
1033
-                            'QST_display_text'  => __('Country', 'event_espresso'),
1034
-                            'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1035
-                            'QST_system'        => 'country',
1036
-                            'QST_type'          => 'COUNTRY',
1037
-                            'QST_required'      => 0,
1038
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1039
-                            'QST_order'         => 7,
1040
-                            'QST_admin_only'    => 0,
1041
-                            'QST_wp_user'       => self::get_default_creator_id(),
1042
-                            'QST_deleted'       => 0,
1043
-                        );
1044
-                        break;
1045
-                    case 'state':
1046
-                        $QST_values = array(
1047
-                            'QST_display_text'  => __('State/Province', 'event_espresso'),
1048
-                            'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1049
-                            'QST_system'        => 'state',
1050
-                            'QST_type'          => 'STATE',
1051
-                            'QST_required'      => 0,
1052
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1053
-                            'QST_order'         => 8,
1054
-                            'QST_admin_only'    => 0,
1055
-                            'QST_wp_user'       => self::get_default_creator_id(),
1056
-                            'QST_deleted'       => 0,
1057
-                        );
1058
-                        break;
1059
-                    case 'zip':
1060
-                        $QST_values = array(
1061
-                            'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1062
-                            'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1063
-                            'QST_system'        => 'zip',
1064
-                            'QST_type'          => 'TEXT',
1065
-                            'QST_required'      => 0,
1066
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1067
-                            'QST_order'         => 9,
1068
-                            'QST_admin_only'    => 0,
1069
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1070
-                            'QST_wp_user'       => self::get_default_creator_id(),
1071
-                            'QST_deleted'       => 0,
1072
-                        );
1073
-                        break;
1074
-                    case 'phone':
1075
-                        $QST_values = array(
1076
-                            'QST_display_text'  => __('Phone Number', 'event_espresso'),
1077
-                            'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1078
-                            'QST_system'        => 'phone',
1079
-                            'QST_type'          => 'TEXT',
1080
-                            'QST_required'      => 0,
1081
-                            'QST_required_text' => __('This field is required', 'event_espresso'),
1082
-                            'QST_order'         => 10,
1083
-                            'QST_admin_only'    => 0,
1084
-                            'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1085
-                            'QST_wp_user'       => self::get_default_creator_id(),
1086
-                            'QST_deleted'       => 0,
1087
-                        );
1088
-                        break;
1089
-                }
1090
-                if (! empty($QST_values)) {
1091
-                    // insert system question
1092
-                    $wpdb->insert(
1093
-                        $table_name,
1094
-                        $QST_values,
1095
-                        array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1096
-                    );
1097
-                    $QST_ID = $wpdb->insert_id;
1098
-                    // QUESTION GROUP QUESTIONS
1099
-                    if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1100
-                        $system_question_we_want = EEM_Question_Group::system_personal;
1101
-                    } else {
1102
-                        $system_question_we_want = EEM_Question_Group::system_address;
1103
-                    }
1104
-                    if (isset($QSG_IDs[$system_question_we_want])) {
1105
-                        $QSG_ID = $QSG_IDs[$system_question_we_want];
1106
-                    } else {
1107
-                        $id_col = EEM_Question_Group::instance()
1108
-                                                    ->get_col(array(array('QSG_system' => $system_question_we_want)));
1109
-                        if (is_array($id_col)) {
1110
-                            $QSG_ID = reset($id_col);
1111
-                        } else {
1112
-                            //ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1113
-                            EE_Log::instance()->log(
1114
-                                __FILE__,
1115
-                                __FUNCTION__,
1116
-                                sprintf(
1117
-                                    __(
1118
-                                        'Could not associate question %1$s to a question group because no system question
835
+					'event_espresso'
836
+				),
837
+				__FILE__,
838
+				__FUNCTION__,
839
+				__LINE__
840
+			);
841
+			return false;
842
+		}
843
+		return true;
844
+	}
845
+
846
+
847
+
848
+	/**
849
+	 * initialize_system_questions
850
+	 *
851
+	 * @access public
852
+	 * @static
853
+	 * @return void
854
+	 */
855
+	public static function initialize_system_questions()
856
+	{
857
+		// QUESTION GROUPS
858
+		global $wpdb;
859
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group');
860
+		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
861
+		// what we have
862
+		$question_groups = $wpdb->get_col($SQL);
863
+		// check the response
864
+		$question_groups = is_array($question_groups) ? $question_groups : array();
865
+		// what we should have
866
+		$QSG_systems = array(1, 2);
867
+		// loop thru what we should have and compare to what we have
868
+		foreach ($QSG_systems as $QSG_system) {
869
+			// reset values array
870
+			$QSG_values = array();
871
+			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
872
+			if (! in_array("$QSG_system", $question_groups)) {
873
+				// add it
874
+				switch ($QSG_system) {
875
+					case 1:
876
+						$QSG_values = array(
877
+							'QSG_name'            => __('Personal Information', 'event_espresso'),
878
+							'QSG_identifier'      => 'personal-information-' . time(),
879
+							'QSG_desc'            => '',
880
+							'QSG_order'           => 1,
881
+							'QSG_show_group_name' => 1,
882
+							'QSG_show_group_desc' => 1,
883
+							'QSG_system'          => EEM_Question_Group::system_personal,
884
+							'QSG_deleted'         => 0,
885
+						);
886
+						break;
887
+					case 2:
888
+						$QSG_values = array(
889
+							'QSG_name'            => __('Address Information', 'event_espresso'),
890
+							'QSG_identifier'      => 'address-information-' . time(),
891
+							'QSG_desc'            => '',
892
+							'QSG_order'           => 2,
893
+							'QSG_show_group_name' => 1,
894
+							'QSG_show_group_desc' => 1,
895
+							'QSG_system'          => EEM_Question_Group::system_address,
896
+							'QSG_deleted'         => 0,
897
+						);
898
+						break;
899
+				}
900
+				// make sure we have some values before inserting them
901
+				if (! empty($QSG_values)) {
902
+					// insert system question
903
+					$wpdb->insert(
904
+						$table_name,
905
+						$QSG_values,
906
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
907
+					);
908
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
909
+				}
910
+			}
911
+		}
912
+		// QUESTIONS
913
+		global $wpdb;
914
+		$table_name = \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question');
915
+		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
916
+		// what we have
917
+		$questions = $wpdb->get_col($SQL);
918
+		// what we should have
919
+		$QST_systems = array(
920
+			'fname',
921
+			'lname',
922
+			'email',
923
+			'address',
924
+			'address2',
925
+			'city',
926
+			'country',
927
+			'state',
928
+			'zip',
929
+			'phone',
930
+		);
931
+		$order_for_group_1 = 1;
932
+		$order_for_group_2 = 1;
933
+		// loop thru what we should have and compare to what we have
934
+		foreach ($QST_systems as $QST_system) {
935
+			// reset values array
936
+			$QST_values = array();
937
+			// if we don't have what we should have
938
+			if (! in_array($QST_system, $questions)) {
939
+				// add it
940
+				switch ($QST_system) {
941
+					case 'fname':
942
+						$QST_values = array(
943
+							'QST_display_text'  => __('First Name', 'event_espresso'),
944
+							'QST_admin_label'   => __('First Name - System Question', 'event_espresso'),
945
+							'QST_system'        => 'fname',
946
+							'QST_type'          => 'TEXT',
947
+							'QST_required'      => 1,
948
+							'QST_required_text' => __('This field is required', 'event_espresso'),
949
+							'QST_order'         => 1,
950
+							'QST_admin_only'    => 0,
951
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
952
+							'QST_wp_user'       => self::get_default_creator_id(),
953
+							'QST_deleted'       => 0,
954
+						);
955
+						break;
956
+					case 'lname':
957
+						$QST_values = array(
958
+							'QST_display_text'  => __('Last Name', 'event_espresso'),
959
+							'QST_admin_label'   => __('Last Name - System Question', 'event_espresso'),
960
+							'QST_system'        => 'lname',
961
+							'QST_type'          => 'TEXT',
962
+							'QST_required'      => 1,
963
+							'QST_required_text' => __('This field is required', 'event_espresso'),
964
+							'QST_order'         => 2,
965
+							'QST_admin_only'    => 0,
966
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
967
+							'QST_wp_user'       => self::get_default_creator_id(),
968
+							'QST_deleted'       => 0,
969
+						);
970
+						break;
971
+					case 'email':
972
+						$QST_values = array(
973
+							'QST_display_text'  => __('Email Address', 'event_espresso'),
974
+							'QST_admin_label'   => __('Email Address - System Question', 'event_espresso'),
975
+							'QST_system'        => 'email',
976
+							'QST_type'          => 'EMAIL',
977
+							'QST_required'      => 1,
978
+							'QST_required_text' => __('This field is required', 'event_espresso'),
979
+							'QST_order'         => 3,
980
+							'QST_admin_only'    => 0,
981
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
982
+							'QST_wp_user'       => self::get_default_creator_id(),
983
+							'QST_deleted'       => 0,
984
+						);
985
+						break;
986
+					case 'address':
987
+						$QST_values = array(
988
+							'QST_display_text'  => __('Address', 'event_espresso'),
989
+							'QST_admin_label'   => __('Address - System Question', 'event_espresso'),
990
+							'QST_system'        => 'address',
991
+							'QST_type'          => 'TEXT',
992
+							'QST_required'      => 0,
993
+							'QST_required_text' => __('This field is required', 'event_espresso'),
994
+							'QST_order'         => 4,
995
+							'QST_admin_only'    => 0,
996
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
997
+							'QST_wp_user'       => self::get_default_creator_id(),
998
+							'QST_deleted'       => 0,
999
+						);
1000
+						break;
1001
+					case 'address2':
1002
+						$QST_values = array(
1003
+							'QST_display_text'  => __('Address2', 'event_espresso'),
1004
+							'QST_admin_label'   => __('Address2 - System Question', 'event_espresso'),
1005
+							'QST_system'        => 'address2',
1006
+							'QST_type'          => 'TEXT',
1007
+							'QST_required'      => 0,
1008
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1009
+							'QST_order'         => 5,
1010
+							'QST_admin_only'    => 0,
1011
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1012
+							'QST_wp_user'       => self::get_default_creator_id(),
1013
+							'QST_deleted'       => 0,
1014
+						);
1015
+						break;
1016
+					case 'city':
1017
+						$QST_values = array(
1018
+							'QST_display_text'  => __('City', 'event_espresso'),
1019
+							'QST_admin_label'   => __('City - System Question', 'event_espresso'),
1020
+							'QST_system'        => 'city',
1021
+							'QST_type'          => 'TEXT',
1022
+							'QST_required'      => 0,
1023
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1024
+							'QST_order'         => 6,
1025
+							'QST_admin_only'    => 0,
1026
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1027
+							'QST_wp_user'       => self::get_default_creator_id(),
1028
+							'QST_deleted'       => 0,
1029
+						);
1030
+						break;
1031
+					case 'country':
1032
+						$QST_values = array(
1033
+							'QST_display_text'  => __('Country', 'event_espresso'),
1034
+							'QST_admin_label'   => __('Country - System Question', 'event_espresso'),
1035
+							'QST_system'        => 'country',
1036
+							'QST_type'          => 'COUNTRY',
1037
+							'QST_required'      => 0,
1038
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1039
+							'QST_order'         => 7,
1040
+							'QST_admin_only'    => 0,
1041
+							'QST_wp_user'       => self::get_default_creator_id(),
1042
+							'QST_deleted'       => 0,
1043
+						);
1044
+						break;
1045
+					case 'state':
1046
+						$QST_values = array(
1047
+							'QST_display_text'  => __('State/Province', 'event_espresso'),
1048
+							'QST_admin_label'   => __('State/Province - System Question', 'event_espresso'),
1049
+							'QST_system'        => 'state',
1050
+							'QST_type'          => 'STATE',
1051
+							'QST_required'      => 0,
1052
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1053
+							'QST_order'         => 8,
1054
+							'QST_admin_only'    => 0,
1055
+							'QST_wp_user'       => self::get_default_creator_id(),
1056
+							'QST_deleted'       => 0,
1057
+						);
1058
+						break;
1059
+					case 'zip':
1060
+						$QST_values = array(
1061
+							'QST_display_text'  => __('Zip/Postal Code', 'event_espresso'),
1062
+							'QST_admin_label'   => __('Zip/Postal Code - System Question', 'event_espresso'),
1063
+							'QST_system'        => 'zip',
1064
+							'QST_type'          => 'TEXT',
1065
+							'QST_required'      => 0,
1066
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1067
+							'QST_order'         => 9,
1068
+							'QST_admin_only'    => 0,
1069
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1070
+							'QST_wp_user'       => self::get_default_creator_id(),
1071
+							'QST_deleted'       => 0,
1072
+						);
1073
+						break;
1074
+					case 'phone':
1075
+						$QST_values = array(
1076
+							'QST_display_text'  => __('Phone Number', 'event_espresso'),
1077
+							'QST_admin_label'   => __('Phone Number - System Question', 'event_espresso'),
1078
+							'QST_system'        => 'phone',
1079
+							'QST_type'          => 'TEXT',
1080
+							'QST_required'      => 0,
1081
+							'QST_required_text' => __('This field is required', 'event_espresso'),
1082
+							'QST_order'         => 10,
1083
+							'QST_admin_only'    => 0,
1084
+							'QST_max'           => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1085
+							'QST_wp_user'       => self::get_default_creator_id(),
1086
+							'QST_deleted'       => 0,
1087
+						);
1088
+						break;
1089
+				}
1090
+				if (! empty($QST_values)) {
1091
+					// insert system question
1092
+					$wpdb->insert(
1093
+						$table_name,
1094
+						$QST_values,
1095
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1096
+					);
1097
+					$QST_ID = $wpdb->insert_id;
1098
+					// QUESTION GROUP QUESTIONS
1099
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1100
+						$system_question_we_want = EEM_Question_Group::system_personal;
1101
+					} else {
1102
+						$system_question_we_want = EEM_Question_Group::system_address;
1103
+					}
1104
+					if (isset($QSG_IDs[$system_question_we_want])) {
1105
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1106
+					} else {
1107
+						$id_col = EEM_Question_Group::instance()
1108
+													->get_col(array(array('QSG_system' => $system_question_we_want)));
1109
+						if (is_array($id_col)) {
1110
+							$QSG_ID = reset($id_col);
1111
+						} else {
1112
+							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1113
+							EE_Log::instance()->log(
1114
+								__FILE__,
1115
+								__FUNCTION__,
1116
+								sprintf(
1117
+									__(
1118
+										'Could not associate question %1$s to a question group because no system question
1119 1119
                                          group existed',
1120
-                                        'event_espresso'
1121
-                                    ),
1122
-                                    $QST_ID),
1123
-                                'error');
1124
-                            continue;
1125
-                        }
1126
-                    }
1127
-                    // add system questions to groups
1128
-                    $wpdb->insert(
1129
-                        \EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1130
-                        array(
1131
-                            'QSG_ID'    => $QSG_ID,
1132
-                            'QST_ID'    => $QST_ID,
1133
-                            'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1134
-                        ),
1135
-                        array('%d', '%d', '%d')
1136
-                    );
1137
-                }
1138
-            }
1139
-        }
1140
-    }
1141
-
1142
-
1143
-    /**
1144
-     * Makes sure the default payment method (Invoice) is active.
1145
-     * This used to be done automatically as part of constructing the old gateways config
1146
-     *
1147
-     * @throws \EE_Error
1148
-     */
1149
-    public static function insert_default_payment_methods()
1150
-    {
1151
-        if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153
-            EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154
-        } else {
1155
-            EEM_Payment_Method::instance()->verify_button_urls();
1156
-        }
1157
-    }
1158
-
1159
-    /**
1160
-     * insert_default_status_codes
1161
-     *
1162
-     * @access public
1163
-     * @static
1164
-     * @return void
1165
-     */
1166
-    public static function insert_default_status_codes()
1167
-    {
1168
-
1169
-        global $wpdb;
1170
-
1171
-        if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1172
-
1173
-            $table_name = EEM_Status::instance()->table();
1174
-
1175
-            $SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1176
-            $wpdb->query($SQL);
1177
-
1178
-            $SQL = "INSERT INTO $table_name
1120
+										'event_espresso'
1121
+									),
1122
+									$QST_ID),
1123
+								'error');
1124
+							continue;
1125
+						}
1126
+					}
1127
+					// add system questions to groups
1128
+					$wpdb->insert(
1129
+						\EEH_Activation::getTableAnalysis()->ensureTableNameHasPrefix('esp_question_group_question'),
1130
+						array(
1131
+							'QSG_ID'    => $QSG_ID,
1132
+							'QST_ID'    => $QST_ID,
1133
+							'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++,
1134
+						),
1135
+						array('%d', '%d', '%d')
1136
+					);
1137
+				}
1138
+			}
1139
+		}
1140
+	}
1141
+
1142
+
1143
+	/**
1144
+	 * Makes sure the default payment method (Invoice) is active.
1145
+	 * This used to be done automatically as part of constructing the old gateways config
1146
+	 *
1147
+	 * @throws \EE_Error
1148
+	 */
1149
+	public static function insert_default_payment_methods()
1150
+	{
1151
+		if (! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1152
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1153
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1154
+		} else {
1155
+			EEM_Payment_Method::instance()->verify_button_urls();
1156
+		}
1157
+	}
1158
+
1159
+	/**
1160
+	 * insert_default_status_codes
1161
+	 *
1162
+	 * @access public
1163
+	 * @static
1164
+	 * @return void
1165
+	 */
1166
+	public static function insert_default_status_codes()
1167
+	{
1168
+
1169
+		global $wpdb;
1170
+
1171
+		if (\EEH_Activation::getTableAnalysis()->tableExists(EEM_Status::instance()->table())) {
1172
+
1173
+			$table_name = EEM_Status::instance()->table();
1174
+
1175
+			$SQL = "DELETE FROM $table_name WHERE STS_ID IN ( 'ACT', 'NAC', 'NOP', 'OPN', 'CLS', 'PND', 'ONG', 'SEC', 'DRF', 'DEL', 'DEN', 'EXP', 'RPP', 'RCN', 'RDC', 'RAP', 'RNA', 'RWL', 'TAB', 'TIN', 'TFL', 'TCM', 'TOP', 'PAP', 'PCN', 'PFL', 'PDC', 'EDR', 'ESN', 'PPN', 'RIC', 'MSN', 'MFL', 'MID', 'MRS', 'MIC', 'MDO', 'MEX' );";
1176
+			$wpdb->query($SQL);
1177
+
1178
+			$SQL = "INSERT INTO $table_name
1179 1179
 					(STS_ID, STS_code, STS_type, STS_can_edit, STS_desc, STS_open) VALUES
1180 1180
 					('ACT', 'ACTIVE', 'event', 0, NULL, 1),
1181 1181
 					('NAC', 'NOT_ACTIVE', 'event', 0, NULL, 0),
@@ -1215,521 +1215,521 @@  discard block
 block discarded – undo
1215 1215
 					('MID', 'IDLE', 'message', 0, NULL, 1),
1216 1216
 					('MRS', 'RESEND', 'message', 0, NULL, 1),
1217 1217
 					('MIC', 'INCOMPLETE', 'message', 0, NULL, 0);";
1218
-            $wpdb->query($SQL);
1219
-
1220
-        }
1221
-
1222
-    }
1223
-
1224
-
1225
-    /**
1226
-     * create_upload_directories
1227
-     * Creates folders in the uploads directory to facilitate addons and templates
1228
-     *
1229
-     * @access public
1230
-     * @static
1231
-     * @return boolean success of verifying upload directories exist
1232
-     */
1233
-    public static function create_upload_directories()
1234
-    {
1235
-        // Create the required folders
1236
-        $folders = array(
1237
-            EVENT_ESPRESSO_TEMPLATE_DIR,
1238
-            EVENT_ESPRESSO_GATEWAY_DIR,
1239
-            EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
-            EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
-            EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1242
-        );
1243
-        foreach ($folders as $folder) {
1244
-            try {
1245
-                EEH_File::ensure_folder_exists_and_is_writable($folder);
1246
-                @ chmod($folder, 0755);
1247
-            } catch (EE_Error $e) {
1248
-                EE_Error::add_error(
1249
-                    sprintf(
1250
-                        __('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251
-                        $folder,
1252
-                        '<br />' . $e->getMessage()
1253
-                    ),
1254
-                    __FILE__, __FUNCTION__, __LINE__
1255
-                );
1256
-                //indicate we'll need to fix this later
1257
-                update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1258
-                return false;
1259
-            }
1260
-        }
1261
-        //just add the .htaccess file to the logs directory to begin with. Even if logging
1262
-        //is disabled, there might be activation errors recorded in there
1263
-        EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1264
-        //remember EE's folders are all good
1265
-        delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266
-        return true;
1267
-    }
1268
-
1269
-    /**
1270
-     * Whether the upload directories need to be fixed or not.
1271
-     * If EE is installed but filesystem access isn't initially available,
1272
-     * we need to get the user's filesystem credentials and THEN create them,
1273
-     * so there might be period of time when EE is installed but its
1274
-     * upload directories aren't available. This indicates such a state
1275
-     *
1276
-     * @return boolean
1277
-     */
1278
-    public static function upload_directories_incomplete()
1279
-    {
1280
-        return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1281
-    }
1282
-
1283
-
1284
-    /**
1285
-     * generate_default_message_templates
1286
-     *
1287
-     * @static
1288
-     * @throws EE_Error
1289
-     * @return bool     true means new templates were created.
1290
-     *                  false means no templates were created.
1291
-     *                  This is NOT an error flag. To check for errors you will want
1292
-     *                  to use either EE_Error or a try catch for an EE_Error exception.
1293
-     */
1294
-    public static function generate_default_message_templates()
1295
-    {
1296
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1297
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1298
-        /*
1218
+			$wpdb->query($SQL);
1219
+
1220
+		}
1221
+
1222
+	}
1223
+
1224
+
1225
+	/**
1226
+	 * create_upload_directories
1227
+	 * Creates folders in the uploads directory to facilitate addons and templates
1228
+	 *
1229
+	 * @access public
1230
+	 * @static
1231
+	 * @return boolean success of verifying upload directories exist
1232
+	 */
1233
+	public static function create_upload_directories()
1234
+	{
1235
+		// Create the required folders
1236
+		$folders = array(
1237
+			EVENT_ESPRESSO_TEMPLATE_DIR,
1238
+			EVENT_ESPRESSO_GATEWAY_DIR,
1239
+			EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1240
+			EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1241
+			EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/',
1242
+		);
1243
+		foreach ($folders as $folder) {
1244
+			try {
1245
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1246
+				@ chmod($folder, 0755);
1247
+			} catch (EE_Error $e) {
1248
+				EE_Error::add_error(
1249
+					sprintf(
1250
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1251
+						$folder,
1252
+						'<br />' . $e->getMessage()
1253
+					),
1254
+					__FILE__, __FUNCTION__, __LINE__
1255
+				);
1256
+				//indicate we'll need to fix this later
1257
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1258
+				return false;
1259
+			}
1260
+		}
1261
+		//just add the .htaccess file to the logs directory to begin with. Even if logging
1262
+		//is disabled, there might be activation errors recorded in there
1263
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR . 'logs/');
1264
+		//remember EE's folders are all good
1265
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1266
+		return true;
1267
+	}
1268
+
1269
+	/**
1270
+	 * Whether the upload directories need to be fixed or not.
1271
+	 * If EE is installed but filesystem access isn't initially available,
1272
+	 * we need to get the user's filesystem credentials and THEN create them,
1273
+	 * so there might be period of time when EE is installed but its
1274
+	 * upload directories aren't available. This indicates such a state
1275
+	 *
1276
+	 * @return boolean
1277
+	 */
1278
+	public static function upload_directories_incomplete()
1279
+	{
1280
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1281
+	}
1282
+
1283
+
1284
+	/**
1285
+	 * generate_default_message_templates
1286
+	 *
1287
+	 * @static
1288
+	 * @throws EE_Error
1289
+	 * @return bool     true means new templates were created.
1290
+	 *                  false means no templates were created.
1291
+	 *                  This is NOT an error flag. To check for errors you will want
1292
+	 *                  to use either EE_Error or a try catch for an EE_Error exception.
1293
+	 */
1294
+	public static function generate_default_message_templates()
1295
+	{
1296
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1297
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1298
+		/*
1299 1299
          * This first method is taking care of ensuring any default messengers
1300 1300
          * that should be made active and have templates generated are done.
1301 1301
          */
1302
-        $new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1303
-            $message_resource_manager
1304
-        );
1305
-        /**
1306
-         * This method is verifying there are no NEW default message types
1307
-         * for ACTIVE messengers that need activated (and corresponding templates setup).
1308
-         */
1309
-        $new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1310
-            $message_resource_manager
1311
-        );
1312
-        //after all is done, let's persist these changes to the db.
1313
-        $message_resource_manager->update_has_activated_messengers_option();
1314
-        $message_resource_manager->update_active_messengers_option();
1315
-        // will return true if either of these are true.  Otherwise will return false.
1316
-        return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1317
-    }
1318
-
1319
-
1320
-
1321
-    /**
1322
-     * @param \EE_Message_Resource_Manager $message_resource_manager
1323
-     * @return array|bool
1324
-     * @throws \EE_Error
1325
-     */
1326
-    protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1327
-        EE_Message_Resource_Manager $message_resource_manager
1328
-    ) {
1329
-        /** @type EE_messenger[] $active_messengers */
1330
-        $active_messengers = $message_resource_manager->active_messengers();
1331
-        $installed_message_types = $message_resource_manager->installed_message_types();
1332
-        $templates_created = false;
1333
-        foreach ($active_messengers as $active_messenger) {
1334
-            $default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1335
-            $default_message_type_names_to_activate = array();
1336
-            // looping through each default message type reported by the messenger
1337
-            // and setup the actual message types to activate.
1338
-            foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1339
-                // if already active or has already been activated before we skip
1340
-                // (otherwise we might reactivate something user's intentionally deactivated.)
1341
-                // we also skip if the message type is not installed.
1342
-                if (
1343
-                    $message_resource_manager->has_message_type_been_activated_for_messenger(
1344
-                        $default_message_type_name_for_messenger,
1345
-                        $active_messenger->name
1346
-                    )
1347
-                    || $message_resource_manager->is_message_type_active_for_messenger(
1348
-                        $active_messenger->name,
1349
-                        $default_message_type_name_for_messenger
1350
-                    )
1351
-                    || ! isset($installed_message_types[$default_message_type_name_for_messenger])
1352
-                ) {
1353
-                    continue;
1354
-                }
1355
-                $default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1356
-            }
1357
-            //let's activate!
1358
-            $message_resource_manager->ensure_message_types_are_active(
1359
-                $default_message_type_names_to_activate,
1360
-                $active_messenger->name,
1361
-                false
1362
-            );
1363
-            //activate the templates for these message types
1364
-            if ( ! empty($default_message_type_names_to_activate)) {
1365
-                $templates_created = EEH_MSG_Template::generate_new_templates(
1366
-                    $active_messenger->name,
1367
-                    $default_message_type_names_for_messenger,
1368
-                    '',
1369
-                    true
1370
-                );
1371
-            }
1372
-        }
1373
-        return $templates_created;
1374
-    }
1375
-
1376
-
1377
-
1378
-    /**
1379
-     * This will activate and generate default messengers and default message types for those messengers.
1380
-     *
1381
-     * @param EE_message_Resource_Manager $message_resource_manager
1382
-     * @return array|bool  True means there were default messengers and message type templates generated.
1383
-     *                     False means that there were no templates generated
1384
-     *                     (which could simply mean there are no default message types for a messenger).
1385
-     * @throws EE_Error
1386
-     */
1387
-    protected static function _activate_and_generate_default_messengers_and_message_templates(
1388
-        EE_Message_Resource_Manager $message_resource_manager
1389
-    ) {
1390
-        /** @type EE_messenger[] $messengers_to_generate */
1391
-        $messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1392
-        $installed_message_types = $message_resource_manager->installed_message_types();
1393
-        $templates_generated = false;
1394
-        foreach ($messengers_to_generate as $messenger_to_generate) {
1395
-            $default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1396
-            //verify the default message types match an installed message type.
1397
-            foreach ($default_message_type_names_for_messenger as $key => $name) {
1398
-                if (
1399
-                    ! isset($installed_message_types[$name])
1400
-                    || $message_resource_manager->has_message_type_been_activated_for_messenger(
1401
-                        $name,
1402
-                        $messenger_to_generate->name
1403
-                    )
1404
-                ) {
1405
-                    unset($default_message_type_names_for_messenger[$key]);
1406
-                }
1407
-            }
1408
-            // in previous iterations, the active_messengers option in the db
1409
-            // needed updated before calling create templates. however with the changes this may not be necessary.
1410
-            // This comment is left here just in case we discover that we _do_ need to update before
1411
-            // passing off to create templates (after the refactor is done).
1412
-            // @todo remove this comment when determined not necessary.
1413
-            $message_resource_manager->activate_messenger(
1414
-                $messenger_to_generate->name,
1415
-                $default_message_type_names_for_messenger,
1416
-                false
1417
-            );
1418
-            //create any templates needing created (or will reactivate templates already generated as necessary).
1419
-            if ( ! empty($default_message_type_names_for_messenger)) {
1420
-                $templates_generated = EEH_MSG_Template::generate_new_templates(
1421
-                    $messenger_to_generate->name,
1422
-                    $default_message_type_names_for_messenger,
1423
-                    '',
1424
-                    true
1425
-                );
1426
-            }
1427
-        }
1428
-        return $templates_generated;
1429
-    }
1430
-
1431
-
1432
-    /**
1433
-     * This returns the default messengers to generate templates for on activation of EE.
1434
-     * It considers:
1435
-     * - whether a messenger is already active in the db.
1436
-     * - whether a messenger has been made active at any time in the past.
1437
-     *
1438
-     * @static
1439
-     * @param  EE_Message_Resource_Manager $message_resource_manager
1440
-     * @return EE_messenger[]
1441
-     */
1442
-    protected static function _get_default_messengers_to_generate_on_activation(
1443
-        EE_Message_Resource_Manager $message_resource_manager
1444
-    ) {
1445
-        $active_messengers    = $message_resource_manager->active_messengers();
1446
-        $installed_messengers = $message_resource_manager->installed_messengers();
1447
-        $has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1448
-
1449
-        $messengers_to_generate = array();
1450
-        foreach ($installed_messengers as $installed_messenger) {
1451
-            //if installed messenger is a messenger that should be activated on install
1452
-            //and is not already active
1453
-            //and has never been activated
1454
-            if (
1455
-                ! $installed_messenger->activate_on_install
1456
-                || isset($active_messengers[$installed_messenger->name])
1457
-                || isset($has_activated[$installed_messenger->name])
1458
-            ) {
1459
-                continue;
1460
-            }
1461
-            $messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1462
-        }
1463
-        return $messengers_to_generate;
1464
-    }
1465
-
1466
-
1467
-    /**
1468
-     * This simply validates active message types to ensure they actually match installed
1469
-     * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1470
-     * rows are set inactive.
1471
-     * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1472
-     * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1473
-     * are still handled in here.
1474
-     *
1475
-     * @since 4.3.1
1476
-     * @return void
1477
-     */
1478
-    public static function validate_messages_system()
1479
-    {
1480
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
1481
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1482
-        $message_resource_manager->validate_active_message_types_are_installed();
1483
-        do_action('AHEE__EEH_Activation__validate_messages_system');
1484
-    }
1485
-
1486
-
1487
-    /**
1488
-     * create_no_ticket_prices_array
1489
-     *
1490
-     * @access public
1491
-     * @static
1492
-     * @return void
1493
-     */
1494
-    public static function create_no_ticket_prices_array()
1495
-    {
1496
-        // this creates an array for tracking events that have no active ticket prices created
1497
-        // this allows us to warn admins of the situation so that it can be corrected
1498
-        $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
-        if (! $espresso_no_ticket_prices) {
1500
-            add_option('ee_no_ticket_prices', array(), '', false);
1501
-        }
1502
-    }
1503
-
1504
-
1505
-    /**
1506
-     * plugin_deactivation
1507
-     *
1508
-     * @access public
1509
-     * @static
1510
-     * @return void
1511
-     */
1512
-    public static function plugin_deactivation()
1513
-    {
1514
-    }
1515
-
1516
-
1517
-    /**
1518
-     * Finds all our EE4 custom post types, and deletes them and their associated data
1519
-     * (like post meta or term relations)
1520
-     *
1521
-     * @global wpdb $wpdb
1522
-     * @throws \EE_Error
1523
-     */
1524
-    public static function delete_all_espresso_cpt_data()
1525
-    {
1526
-        global $wpdb;
1527
-        //get all the CPT post_types
1528
-        $ee_post_types = array();
1529
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1530
-            if (method_exists($model_name, 'instance')) {
1531
-                $model_obj = call_user_func(array($model_name, 'instance'));
1532
-                if ($model_obj instanceof EEM_CPT_Base) {
1533
-                    $ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1534
-                }
1535
-            }
1536
-        }
1537
-        //get all our CPTs
1538
-        $query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1539
-        $cpt_ids = $wpdb->get_col($query);
1540
-        //delete each post meta and term relations too
1541
-        foreach ($cpt_ids as $post_id) {
1542
-            wp_delete_post($post_id, true);
1543
-        }
1544
-    }
1545
-
1546
-    /**
1547
-     * Deletes all EE custom tables
1548
-     *
1549
-     * @return array
1550
-     */
1551
-    public static function drop_espresso_tables()
1552
-    {
1553
-        $tables = array();
1554
-        // load registry
1555
-        foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1556
-            if (method_exists($model_name, 'instance')) {
1557
-                $model_obj = call_user_func(array($model_name, 'instance'));
1558
-                if ($model_obj instanceof EEM_Base) {
1559
-                    foreach ($model_obj->get_tables() as $table) {
1560
-                        if (strpos($table->get_table_name(), 'esp_')
1561
-                            &&
1562
-                            (
1563
-                                is_main_site()//main site? nuke them all
1564
-                                || ! $table->is_global()//not main site,but not global either. nuke it
1565
-                            )
1566
-                        ) {
1567
-                            $tables[$table->get_table_name()] = $table->get_table_name();
1568
-                        }
1569
-                    }
1570
-                }
1571
-            }
1572
-        }
1573
-
1574
-        //there are some tables whose models were removed.
1575
-        //they should be removed when removing all EE core's data
1576
-        $tables_without_models = array(
1577
-            'esp_promotion',
1578
-            'esp_promotion_applied',
1579
-            'esp_promotion_object',
1580
-            'esp_promotion_rule',
1581
-            'esp_rule',
1582
-        );
1583
-        foreach ($tables_without_models as $table) {
1584
-            $tables[$table] = $table;
1585
-        }
1586
-        return \EEH_Activation::getTableManager()->dropTables($tables);
1587
-    }
1588
-
1589
-
1590
-
1591
-    /**
1592
-     * Drops all the tables mentioned in a single MYSQL query. Double-checks
1593
-     * each table name provided has a wpdb prefix attached, and that it exists.
1594
-     * Returns the list actually deleted
1595
-     *
1596
-     * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1597
-     * @global WPDB $wpdb
1598
-     * @param array $table_names
1599
-     * @return array of table names which we deleted
1600
-     */
1601
-    public static function drop_tables($table_names)
1602
-    {
1603
-        return \EEH_Activation::getTableManager()->dropTables($table_names);
1604
-    }
1605
-
1606
-
1607
-
1608
-    /**
1609
-     * plugin_uninstall
1610
-     *
1611
-     * @access public
1612
-     * @static
1613
-     * @param bool $remove_all
1614
-     * @return void
1615
-     */
1616
-    public static function delete_all_espresso_tables_and_data($remove_all = true)
1617
-    {
1618
-        global $wpdb;
1619
-        self::drop_espresso_tables();
1620
-        $wp_options_to_delete = array(
1621
-            'ee_no_ticket_prices'                => true,
1622
-            'ee_active_messengers'               => true,
1623
-            'ee_has_activated_messenger'         => true,
1624
-            'ee_flush_rewrite_rules'             => true,
1625
-            'ee_config'                          => false,
1626
-            'ee_data_migration_current_db_state' => true,
1627
-            'ee_data_migration_mapping_'         => false,
1628
-            'ee_data_migration_script_'          => false,
1629
-            'ee_data_migrations'                 => true,
1630
-            'ee_dms_map'                         => false,
1631
-            'ee_notices'                         => true,
1632
-            'lang_file_check_'                   => false,
1633
-            'ee_maintenance_mode'                => true,
1634
-            'ee_ueip_optin'                      => true,
1635
-            'ee_ueip_has_notified'               => true,
1636
-            'ee_plugin_activation_errors'        => true,
1637
-            'ee_id_mapping_from'                 => false,
1638
-            'espresso_persistent_admin_notices'  => true,
1639
-            'ee_encryption_key'                  => true,
1640
-            'pue_force_upgrade_'                 => false,
1641
-            'pue_json_error_'                    => false,
1642
-            'pue_install_key_'                   => false,
1643
-            'pue_verification_error_'            => false,
1644
-            'pu_dismissed_upgrade_'              => false,
1645
-            'external_updates-'                  => false,
1646
-            'ee_extra_data'                      => true,
1647
-            'ee_ssn_'                            => false,
1648
-            'ee_rss_'                            => false,
1649
-            'ee_rte_n_tx_'                       => false,
1650
-            'ee_pers_admin_notices'              => true,
1651
-            'ee_job_parameters_'                 => false,
1652
-            'ee_upload_directories_incomplete'   => true,
1653
-            'ee_verified_db_collations'          => true,
1654
-        );
1655
-        if (is_main_site()) {
1656
-            $wp_options_to_delete['ee_network_config'] = true;
1657
-        }
1658
-        $undeleted_options = array();
1659
-        foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1660
-            if ($no_wildcard) {
1661
-                if ( ! delete_option($option_name)) {
1662
-                    $undeleted_options[] = $option_name;
1663
-                }
1664
-            } else {
1665
-                $option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1666
-                foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1667
-                    if ( ! delete_option($option_name_from_wildcard)) {
1668
-                        $undeleted_options[] = $option_name_from_wildcard;
1669
-                    }
1670
-                }
1671
-            }
1672
-        }
1673
-        //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1674
-        remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1675
-        if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676
-            $db_update_sans_ee4 = array();
1677
-            foreach ($espresso_db_update as $version => $times_activated) {
1678
-                if ((string)$version[0] === '3') {//if its NON EE4
1679
-                    $db_update_sans_ee4[$version] = $times_activated;
1680
-                }
1681
-            }
1682
-            update_option('espresso_db_update', $db_update_sans_ee4);
1683
-        }
1684
-        $errors = '';
1685
-        if ( ! empty($undeleted_options)) {
1686
-            $errors .= sprintf(
1687
-                __('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1688
-                '<br/>',
1689
-                implode(',<br/>', $undeleted_options)
1690
-            );
1691
-        }
1692
-        if ( ! empty($errors)) {
1693
-            EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1694
-        }
1695
-    }
1696
-
1697
-    /**
1698
-     * Gets the mysql error code from the last used query by wpdb
1699
-     *
1700
-     * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1701
-     */
1702
-    public static function last_wpdb_error_code()
1703
-    {
1704
-        global $wpdb;
1705
-        if ($wpdb->use_mysqli) {
1706
-            return mysqli_errno($wpdb->dbh);
1707
-        } else {
1708
-            return mysql_errno($wpdb->dbh);
1709
-        }
1710
-    }
1711
-
1712
-    /**
1713
-     * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1714
-     *
1715
-     * @global wpdb  $wpdb
1716
-     * @deprecated instead use TableAnalysis::tableExists()
1717
-     * @param string $table_name with or without $wpdb->prefix
1718
-     * @return boolean
1719
-     */
1720
-    public static function table_exists($table_name)
1721
-    {
1722
-        return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1723
-    }
1724
-
1725
-    /**
1726
-     * Resets the cache on EEH_Activation
1727
-     */
1728
-    public static function reset()
1729
-    {
1730
-        self::$_default_creator_id                             = null;
1731
-        self::$_initialized_db_content_already_in_this_request = false;
1732
-    }
1302
+		$new_templates_created_for_messenger = self::_activate_and_generate_default_messengers_and_message_templates(
1303
+			$message_resource_manager
1304
+		);
1305
+		/**
1306
+		 * This method is verifying there are no NEW default message types
1307
+		 * for ACTIVE messengers that need activated (and corresponding templates setup).
1308
+		 */
1309
+		$new_templates_created_for_message_type = self::_activate_new_message_types_for_active_messengers_and_generate_default_templates(
1310
+			$message_resource_manager
1311
+		);
1312
+		//after all is done, let's persist these changes to the db.
1313
+		$message_resource_manager->update_has_activated_messengers_option();
1314
+		$message_resource_manager->update_active_messengers_option();
1315
+		// will return true if either of these are true.  Otherwise will return false.
1316
+		return $new_templates_created_for_message_type || $new_templates_created_for_messenger;
1317
+	}
1318
+
1319
+
1320
+
1321
+	/**
1322
+	 * @param \EE_Message_Resource_Manager $message_resource_manager
1323
+	 * @return array|bool
1324
+	 * @throws \EE_Error
1325
+	 */
1326
+	protected static function _activate_new_message_types_for_active_messengers_and_generate_default_templates(
1327
+		EE_Message_Resource_Manager $message_resource_manager
1328
+	) {
1329
+		/** @type EE_messenger[] $active_messengers */
1330
+		$active_messengers = $message_resource_manager->active_messengers();
1331
+		$installed_message_types = $message_resource_manager->installed_message_types();
1332
+		$templates_created = false;
1333
+		foreach ($active_messengers as $active_messenger) {
1334
+			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1335
+			$default_message_type_names_to_activate = array();
1336
+			// looping through each default message type reported by the messenger
1337
+			// and setup the actual message types to activate.
1338
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1339
+				// if already active or has already been activated before we skip
1340
+				// (otherwise we might reactivate something user's intentionally deactivated.)
1341
+				// we also skip if the message type is not installed.
1342
+				if (
1343
+					$message_resource_manager->has_message_type_been_activated_for_messenger(
1344
+						$default_message_type_name_for_messenger,
1345
+						$active_messenger->name
1346
+					)
1347
+					|| $message_resource_manager->is_message_type_active_for_messenger(
1348
+						$active_messenger->name,
1349
+						$default_message_type_name_for_messenger
1350
+					)
1351
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1352
+				) {
1353
+					continue;
1354
+				}
1355
+				$default_message_type_names_to_activate[] = $default_message_type_name_for_messenger;
1356
+			}
1357
+			//let's activate!
1358
+			$message_resource_manager->ensure_message_types_are_active(
1359
+				$default_message_type_names_to_activate,
1360
+				$active_messenger->name,
1361
+				false
1362
+			);
1363
+			//activate the templates for these message types
1364
+			if ( ! empty($default_message_type_names_to_activate)) {
1365
+				$templates_created = EEH_MSG_Template::generate_new_templates(
1366
+					$active_messenger->name,
1367
+					$default_message_type_names_for_messenger,
1368
+					'',
1369
+					true
1370
+				);
1371
+			}
1372
+		}
1373
+		return $templates_created;
1374
+	}
1375
+
1376
+
1377
+
1378
+	/**
1379
+	 * This will activate and generate default messengers and default message types for those messengers.
1380
+	 *
1381
+	 * @param EE_message_Resource_Manager $message_resource_manager
1382
+	 * @return array|bool  True means there were default messengers and message type templates generated.
1383
+	 *                     False means that there were no templates generated
1384
+	 *                     (which could simply mean there are no default message types for a messenger).
1385
+	 * @throws EE_Error
1386
+	 */
1387
+	protected static function _activate_and_generate_default_messengers_and_message_templates(
1388
+		EE_Message_Resource_Manager $message_resource_manager
1389
+	) {
1390
+		/** @type EE_messenger[] $messengers_to_generate */
1391
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1392
+		$installed_message_types = $message_resource_manager->installed_message_types();
1393
+		$templates_generated = false;
1394
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1395
+			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1396
+			//verify the default message types match an installed message type.
1397
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1398
+				if (
1399
+					! isset($installed_message_types[$name])
1400
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger(
1401
+						$name,
1402
+						$messenger_to_generate->name
1403
+					)
1404
+				) {
1405
+					unset($default_message_type_names_for_messenger[$key]);
1406
+				}
1407
+			}
1408
+			// in previous iterations, the active_messengers option in the db
1409
+			// needed updated before calling create templates. however with the changes this may not be necessary.
1410
+			// This comment is left here just in case we discover that we _do_ need to update before
1411
+			// passing off to create templates (after the refactor is done).
1412
+			// @todo remove this comment when determined not necessary.
1413
+			$message_resource_manager->activate_messenger(
1414
+				$messenger_to_generate->name,
1415
+				$default_message_type_names_for_messenger,
1416
+				false
1417
+			);
1418
+			//create any templates needing created (or will reactivate templates already generated as necessary).
1419
+			if ( ! empty($default_message_type_names_for_messenger)) {
1420
+				$templates_generated = EEH_MSG_Template::generate_new_templates(
1421
+					$messenger_to_generate->name,
1422
+					$default_message_type_names_for_messenger,
1423
+					'',
1424
+					true
1425
+				);
1426
+			}
1427
+		}
1428
+		return $templates_generated;
1429
+	}
1430
+
1431
+
1432
+	/**
1433
+	 * This returns the default messengers to generate templates for on activation of EE.
1434
+	 * It considers:
1435
+	 * - whether a messenger is already active in the db.
1436
+	 * - whether a messenger has been made active at any time in the past.
1437
+	 *
1438
+	 * @static
1439
+	 * @param  EE_Message_Resource_Manager $message_resource_manager
1440
+	 * @return EE_messenger[]
1441
+	 */
1442
+	protected static function _get_default_messengers_to_generate_on_activation(
1443
+		EE_Message_Resource_Manager $message_resource_manager
1444
+	) {
1445
+		$active_messengers    = $message_resource_manager->active_messengers();
1446
+		$installed_messengers = $message_resource_manager->installed_messengers();
1447
+		$has_activated        = $message_resource_manager->get_has_activated_messengers_option();
1448
+
1449
+		$messengers_to_generate = array();
1450
+		foreach ($installed_messengers as $installed_messenger) {
1451
+			//if installed messenger is a messenger that should be activated on install
1452
+			//and is not already active
1453
+			//and has never been activated
1454
+			if (
1455
+				! $installed_messenger->activate_on_install
1456
+				|| isset($active_messengers[$installed_messenger->name])
1457
+				|| isset($has_activated[$installed_messenger->name])
1458
+			) {
1459
+				continue;
1460
+			}
1461
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1462
+		}
1463
+		return $messengers_to_generate;
1464
+	}
1465
+
1466
+
1467
+	/**
1468
+	 * This simply validates active message types to ensure they actually match installed
1469
+	 * message types.  If there's a mismatch then we deactivate the message type and ensure all related db
1470
+	 * rows are set inactive.
1471
+	 * Note: Messengers are no longer validated here as of 4.9.0 because they get validated automatically whenever
1472
+	 * EE_Messenger_Resource_Manager is constructed.  Message Types are a bit more resource heavy for validation so they
1473
+	 * are still handled in here.
1474
+	 *
1475
+	 * @since 4.3.1
1476
+	 * @return void
1477
+	 */
1478
+	public static function validate_messages_system()
1479
+	{
1480
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
1481
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1482
+		$message_resource_manager->validate_active_message_types_are_installed();
1483
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1484
+	}
1485
+
1486
+
1487
+	/**
1488
+	 * create_no_ticket_prices_array
1489
+	 *
1490
+	 * @access public
1491
+	 * @static
1492
+	 * @return void
1493
+	 */
1494
+	public static function create_no_ticket_prices_array()
1495
+	{
1496
+		// this creates an array for tracking events that have no active ticket prices created
1497
+		// this allows us to warn admins of the situation so that it can be corrected
1498
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', false);
1499
+		if (! $espresso_no_ticket_prices) {
1500
+			add_option('ee_no_ticket_prices', array(), '', false);
1501
+		}
1502
+	}
1503
+
1504
+
1505
+	/**
1506
+	 * plugin_deactivation
1507
+	 *
1508
+	 * @access public
1509
+	 * @static
1510
+	 * @return void
1511
+	 */
1512
+	public static function plugin_deactivation()
1513
+	{
1514
+	}
1515
+
1516
+
1517
+	/**
1518
+	 * Finds all our EE4 custom post types, and deletes them and their associated data
1519
+	 * (like post meta or term relations)
1520
+	 *
1521
+	 * @global wpdb $wpdb
1522
+	 * @throws \EE_Error
1523
+	 */
1524
+	public static function delete_all_espresso_cpt_data()
1525
+	{
1526
+		global $wpdb;
1527
+		//get all the CPT post_types
1528
+		$ee_post_types = array();
1529
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1530
+			if (method_exists($model_name, 'instance')) {
1531
+				$model_obj = call_user_func(array($model_name, 'instance'));
1532
+				if ($model_obj instanceof EEM_CPT_Base) {
1533
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1534
+				}
1535
+			}
1536
+		}
1537
+		//get all our CPTs
1538
+		$query   = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (" . implode(",", $ee_post_types) . ")";
1539
+		$cpt_ids = $wpdb->get_col($query);
1540
+		//delete each post meta and term relations too
1541
+		foreach ($cpt_ids as $post_id) {
1542
+			wp_delete_post($post_id, true);
1543
+		}
1544
+	}
1545
+
1546
+	/**
1547
+	 * Deletes all EE custom tables
1548
+	 *
1549
+	 * @return array
1550
+	 */
1551
+	public static function drop_espresso_tables()
1552
+	{
1553
+		$tables = array();
1554
+		// load registry
1555
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1556
+			if (method_exists($model_name, 'instance')) {
1557
+				$model_obj = call_user_func(array($model_name, 'instance'));
1558
+				if ($model_obj instanceof EEM_Base) {
1559
+					foreach ($model_obj->get_tables() as $table) {
1560
+						if (strpos($table->get_table_name(), 'esp_')
1561
+							&&
1562
+							(
1563
+								is_main_site()//main site? nuke them all
1564
+								|| ! $table->is_global()//not main site,but not global either. nuke it
1565
+							)
1566
+						) {
1567
+							$tables[$table->get_table_name()] = $table->get_table_name();
1568
+						}
1569
+					}
1570
+				}
1571
+			}
1572
+		}
1573
+
1574
+		//there are some tables whose models were removed.
1575
+		//they should be removed when removing all EE core's data
1576
+		$tables_without_models = array(
1577
+			'esp_promotion',
1578
+			'esp_promotion_applied',
1579
+			'esp_promotion_object',
1580
+			'esp_promotion_rule',
1581
+			'esp_rule',
1582
+		);
1583
+		foreach ($tables_without_models as $table) {
1584
+			$tables[$table] = $table;
1585
+		}
1586
+		return \EEH_Activation::getTableManager()->dropTables($tables);
1587
+	}
1588
+
1589
+
1590
+
1591
+	/**
1592
+	 * Drops all the tables mentioned in a single MYSQL query. Double-checks
1593
+	 * each table name provided has a wpdb prefix attached, and that it exists.
1594
+	 * Returns the list actually deleted
1595
+	 *
1596
+	 * @deprecated in 4.9.13. Instead use TableManager::dropTables()
1597
+	 * @global WPDB $wpdb
1598
+	 * @param array $table_names
1599
+	 * @return array of table names which we deleted
1600
+	 */
1601
+	public static function drop_tables($table_names)
1602
+	{
1603
+		return \EEH_Activation::getTableManager()->dropTables($table_names);
1604
+	}
1605
+
1606
+
1607
+
1608
+	/**
1609
+	 * plugin_uninstall
1610
+	 *
1611
+	 * @access public
1612
+	 * @static
1613
+	 * @param bool $remove_all
1614
+	 * @return void
1615
+	 */
1616
+	public static function delete_all_espresso_tables_and_data($remove_all = true)
1617
+	{
1618
+		global $wpdb;
1619
+		self::drop_espresso_tables();
1620
+		$wp_options_to_delete = array(
1621
+			'ee_no_ticket_prices'                => true,
1622
+			'ee_active_messengers'               => true,
1623
+			'ee_has_activated_messenger'         => true,
1624
+			'ee_flush_rewrite_rules'             => true,
1625
+			'ee_config'                          => false,
1626
+			'ee_data_migration_current_db_state' => true,
1627
+			'ee_data_migration_mapping_'         => false,
1628
+			'ee_data_migration_script_'          => false,
1629
+			'ee_data_migrations'                 => true,
1630
+			'ee_dms_map'                         => false,
1631
+			'ee_notices'                         => true,
1632
+			'lang_file_check_'                   => false,
1633
+			'ee_maintenance_mode'                => true,
1634
+			'ee_ueip_optin'                      => true,
1635
+			'ee_ueip_has_notified'               => true,
1636
+			'ee_plugin_activation_errors'        => true,
1637
+			'ee_id_mapping_from'                 => false,
1638
+			'espresso_persistent_admin_notices'  => true,
1639
+			'ee_encryption_key'                  => true,
1640
+			'pue_force_upgrade_'                 => false,
1641
+			'pue_json_error_'                    => false,
1642
+			'pue_install_key_'                   => false,
1643
+			'pue_verification_error_'            => false,
1644
+			'pu_dismissed_upgrade_'              => false,
1645
+			'external_updates-'                  => false,
1646
+			'ee_extra_data'                      => true,
1647
+			'ee_ssn_'                            => false,
1648
+			'ee_rss_'                            => false,
1649
+			'ee_rte_n_tx_'                       => false,
1650
+			'ee_pers_admin_notices'              => true,
1651
+			'ee_job_parameters_'                 => false,
1652
+			'ee_upload_directories_incomplete'   => true,
1653
+			'ee_verified_db_collations'          => true,
1654
+		);
1655
+		if (is_main_site()) {
1656
+			$wp_options_to_delete['ee_network_config'] = true;
1657
+		}
1658
+		$undeleted_options = array();
1659
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1660
+			if ($no_wildcard) {
1661
+				if ( ! delete_option($option_name)) {
1662
+					$undeleted_options[] = $option_name;
1663
+				}
1664
+			} else {
1665
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1666
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1667
+					if ( ! delete_option($option_name_from_wildcard)) {
1668
+						$undeleted_options[] = $option_name_from_wildcard;
1669
+					}
1670
+				}
1671
+			}
1672
+		}
1673
+		//also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1674
+		remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1675
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1676
+			$db_update_sans_ee4 = array();
1677
+			foreach ($espresso_db_update as $version => $times_activated) {
1678
+				if ((string)$version[0] === '3') {//if its NON EE4
1679
+					$db_update_sans_ee4[$version] = $times_activated;
1680
+				}
1681
+			}
1682
+			update_option('espresso_db_update', $db_update_sans_ee4);
1683
+		}
1684
+		$errors = '';
1685
+		if ( ! empty($undeleted_options)) {
1686
+			$errors .= sprintf(
1687
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1688
+				'<br/>',
1689
+				implode(',<br/>', $undeleted_options)
1690
+			);
1691
+		}
1692
+		if ( ! empty($errors)) {
1693
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1694
+		}
1695
+	}
1696
+
1697
+	/**
1698
+	 * Gets the mysql error code from the last used query by wpdb
1699
+	 *
1700
+	 * @return int mysql error code, see https://dev.mysql.com/doc/refman/5.5/en/error-messages-server.html
1701
+	 */
1702
+	public static function last_wpdb_error_code()
1703
+	{
1704
+		global $wpdb;
1705
+		if ($wpdb->use_mysqli) {
1706
+			return mysqli_errno($wpdb->dbh);
1707
+		} else {
1708
+			return mysql_errno($wpdb->dbh);
1709
+		}
1710
+	}
1711
+
1712
+	/**
1713
+	 * Checks that the database table exists. Also works on temporary tables (for unit tests mostly).
1714
+	 *
1715
+	 * @global wpdb  $wpdb
1716
+	 * @deprecated instead use TableAnalysis::tableExists()
1717
+	 * @param string $table_name with or without $wpdb->prefix
1718
+	 * @return boolean
1719
+	 */
1720
+	public static function table_exists($table_name)
1721
+	{
1722
+		return \EEH_Activation::getTableAnalysis()->tableExists($table_name);
1723
+	}
1724
+
1725
+	/**
1726
+	 * Resets the cache on EEH_Activation
1727
+	 */
1728
+	public static function reset()
1729
+	{
1730
+		self::$_default_creator_id                             = null;
1731
+		self::$_initialized_db_content_already_in_this_request = false;
1732
+	}
1733 1733
 }
1734 1734
 // End of file EEH_Activation.helper.php
1735 1735
 // Location: /helpers/EEH_Activation.core.php
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -598,7 +598,7 @@
 block discarded – undo
598 598
      *
599 599
      * @since  4.6.0
600 600
      * @global WPDB $wpdb
601
-     * @return mixed null|int WP_user ID or NULL
601
+     * @return integer|null null|int WP_user ID or NULL
602 602
      */
603 603
     public static function get_default_creator_id()
604 604
     {
Please login to merge, or discard this patch.
core/EE_System.core.php 2 patches
Indentation   +1498 added lines, -1498 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@  discard block
 block discarded – undo
6 6
 
7 7
 
8 8
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
-    exit('No direct script access allowed');
9
+	exit('No direct script access allowed');
10 10
 }
11 11
 
12 12
 
@@ -23,1503 +23,1503 @@  discard block
 block discarded – undo
23 23
 {
24 24
 
25 25
 
26
-    /**
27
-     * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
28
-     * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
29
-     */
30
-    const req_type_normal = 0;
31
-
32
-    /**
33
-     * Indicates this is a brand new installation of EE so we should install
34
-     * tables and default data etc
35
-     */
36
-    const req_type_new_activation = 1;
37
-
38
-    /**
39
-     * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
40
-     * and we just exited maintenance mode). We MUST check the database is setup properly
41
-     * and that default data is setup too
42
-     */
43
-    const req_type_reactivation = 2;
44
-
45
-    /**
46
-     * indicates that EE has been upgraded since its previous request.
47
-     * We may have data migration scripts to call and will want to trigger maintenance mode
48
-     */
49
-    const req_type_upgrade = 3;
50
-
51
-    /**
52
-     * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
53
-     */
54
-    const req_type_downgrade = 4;
55
-
56
-    /**
57
-     * @deprecated since version 4.6.0.dev.006
58
-     * Now whenever a new_activation is detected the request type is still just
59
-     * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
60
-     * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
61
-     * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
62
-     * (Specifically, when the migration manager indicates migrations are finished
63
-     * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
64
-     */
65
-    const req_type_activation_but_not_installed = 5;
66
-
67
-    /**
68
-     * option prefix for recording the activation history (like core's "espresso_db_update") of addons
69
-     */
70
-    const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
71
-
72
-
73
-    /**
74
-     * @var EE_System $_instance
75
-     */
76
-    private static $_instance;
77
-
78
-    /**
79
-     * @var EE_Registry $registry
80
-     */
81
-    protected $registry;
82
-
83
-    /**
84
-     * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
85
-     * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
86
-     *
87
-     * @var int $_req_type
88
-     */
89
-    private $_req_type;
90
-
91
-    /**
92
-     * Whether or not there was a non-micro version change in EE core version during this request
93
-     *
94
-     * @var boolean $_major_version_change
95
-     */
96
-    private $_major_version_change = false;
97
-
98
-
99
-
100
-    /**
101
-     * @singleton method used to instantiate class object
102
-     * @access    public
103
-     * @param  EE_Registry $Registry
104
-     * @return EE_System
105
-     */
106
-    public static function instance(EE_Registry $Registry = null)
107
-    {
108
-        // check if class object is instantiated
109
-        if ( ! self::$_instance instanceof EE_System) {
110
-            self::$_instance = new self($Registry);
111
-        }
112
-        return self::$_instance;
113
-    }
114
-
115
-
116
-
117
-    /**
118
-     * resets the instance and returns it
119
-     *
120
-     * @return EE_System
121
-     */
122
-    public static function reset()
123
-    {
124
-        self::$_instance->_req_type = null;
125
-        //make sure none of the old hooks are left hanging around
126
-        remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
127
-        //we need to reset the migration manager in order for it to detect DMSs properly
128
-        EE_Data_Migration_Manager::reset();
129
-        self::instance()->detect_activations_or_upgrades();
130
-        self::instance()->perform_activations_upgrades_and_migrations();
131
-        return self::instance();
132
-    }
133
-
134
-
135
-
136
-    /**
137
-     *    sets hooks for running rest of system
138
-     *    provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
139
-     *    starting EE Addons from any other point may lead to problems
140
-     *
141
-     * @access private
142
-     * @param  EE_Registry $Registry
143
-     */
144
-    private function __construct(EE_Registry $Registry)
145
-    {
146
-        $this->registry = $Registry;
147
-        do_action('AHEE__EE_System__construct__begin', $this);
148
-        add_action(
149
-            'AHEE__EE_Bootstrap__load_espresso_addons',
150
-            array($this, 'loadCapabilities'),
151
-            5
152
-        );
153
-        add_action(
154
-            'AHEE__EE_Bootstrap__load_espresso_addons',
155
-            array($this, 'loadCommandBus'),
156
-            7
157
-        );
158
-        add_action(
159
-            'AHEE__EE_Bootstrap__load_espresso_addons',
160
-            array($this, 'loadPluginApi'),
161
-            9
162
-        );
163
-        // allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
164
-        add_action(
165
-            'AHEE__EE_Bootstrap__load_espresso_addons',
166
-            array($this, 'load_espresso_addons')
167
-        );
168
-        // when an ee addon is activated, we want to call the core hook(s) again
169
-        // because the newly-activated addon didn't get a chance to run at all
170
-        add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
171
-        // detect whether install or upgrade
172
-        add_action(
173
-            'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
174
-            array($this, 'detect_activations_or_upgrades'),
175
-            3
176
-        );
177
-        // load EE_Config, EE_Textdomain, etc
178
-        add_action(
179
-            'AHEE__EE_Bootstrap__load_core_configuration',
180
-            array($this, 'load_core_configuration'),
181
-            5
182
-        );
183
-        // load EE_Config, EE_Textdomain, etc
184
-        add_action(
185
-            'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
186
-            array($this, 'register_shortcodes_modules_and_widgets'),
187
-            7
188
-        );
189
-        // you wanna get going? I wanna get going... let's get going!
190
-        add_action(
191
-            'AHEE__EE_Bootstrap__brew_espresso',
192
-            array($this, 'brew_espresso'),
193
-            9
194
-        );
195
-        //other housekeeping
196
-        //exclude EE critical pages from wp_list_pages
197
-        add_filter(
198
-            'wp_list_pages_excludes',
199
-            array($this, 'remove_pages_from_wp_list_pages'),
200
-            10
201
-        );
202
-        // ALL EE Addons should use the following hook point to attach their initial setup too
203
-        // it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
204
-        do_action('AHEE__EE_System__construct__complete', $this);
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * load and setup EE_Capabilities
211
-     *
212
-     * @return void
213
-     * @throws EE_Error
214
-     */
215
-    public function loadCapabilities()
216
-    {
217
-        $this->registry->load_core('EE_Capabilities');
218
-        add_action(
219
-            'AHEE__EE_Capabilities__init_caps__before_initialization',
220
-            function() {
221
-                EE_Registry::instance()->load_lib('Payment_Method_Manager');
222
-            }
223
-        );
224
-    }
225
-
226
-
227
-
228
-    /**
229
-     * create and cache the CommandBus, and also add middleware
230
-     * The CapChecker middleware requires the use of EE_Capabilities
231
-     * which is why we need to load the CommandBus after Caps are set up
232
-     *
233
-     * @return void
234
-     * @throws EE_Error
235
-     */
236
-    public function loadCommandBus()
237
-    {
238
-        $this->registry->create(
239
-            'CommandBusInterface',
240
-            array(
241
-                null,
242
-                apply_filters(
243
-                    'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
244
-                    array(
245
-                        $this->registry->create('CapChecker'),
246
-                        $this->registry->create('AddActionHook'),
247
-                    )
248
-                ),
249
-            ),
250
-            true
251
-        );
252
-    }
253
-
254
-
255
-
256
-    /**
257
-     * @return void
258
-     * @throws EE_Error
259
-     */
260
-    public function loadPluginApi()
261
-    {
262
-        // set autoloaders for all of the classes implementing EEI_Plugin_API
263
-        // which provide helpers for EE plugin authors to more easily register certain components with EE.
264
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
265
-    }
266
-
267
-
268
-
269
-    /**
270
-     * load_espresso_addons
271
-     * allow addons to load first so that they can set hooks for running DMS's, etc
272
-     * this is hooked into both:
273
-     *    'AHEE__EE_Bootstrap__load_core_configuration'
274
-     *        which runs during the WP 'plugins_loaded' action at priority 5
275
-     *    and the WP 'activate_plugin' hook point
276
-     *
277
-     * @access public
278
-     * @return void
279
-     * @throws EE_Error
280
-     */
281
-    public function load_espresso_addons()
282
-    {
283
-        do_action('AHEE__EE_System__load_espresso_addons');
284
-        //if the WP API basic auth plugin isn't already loaded, load it now.
285
-        //We want it for mobile apps. Just include the entire plugin
286
-        //also, don't load the basic auth when a plugin is getting activated, because
287
-        //it could be the basic auth plugin, and it doesn't check if its methods are already defined
288
-        //and causes a fatal error
289
-        if (
290
-            ! (isset($_GET['activate']) && $_GET['activate'] === 'true')
291
-            && ! function_exists('json_basic_auth_handler')
292
-            && ! function_exists('json_basic_auth_error')
293
-            && ! (
294
-                isset($_GET['action'])
295
-                && in_array($_GET['action'], array('activate', 'activate-selected'), true)
296
-            )
297
-        ) {
298
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
299
-        }
300
-        do_action('AHEE__EE_System__load_espresso_addons__complete');
301
-    }
302
-
303
-
304
-
305
-    /**
306
-     * detect_activations_or_upgrades
307
-     * Checks for activation or upgrade of core first;
308
-     * then also checks if any registered addons have been activated or upgraded
309
-     * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
310
-     * which runs during the WP 'plugins_loaded' action at priority 3
311
-     *
312
-     * @access public
313
-     * @return void
314
-     */
315
-    public function detect_activations_or_upgrades()
316
-    {
317
-        //first off: let's make sure to handle core
318
-        $this->detect_if_activation_or_upgrade();
319
-        foreach ($this->registry->addons as $addon) {
320
-            //detect teh request type for that addon
321
-            $addon->detect_activation_or_upgrade();
322
-        }
323
-    }
324
-
325
-
326
-
327
-    /**
328
-     * detect_if_activation_or_upgrade
329
-     * Takes care of detecting whether this is a brand new install or code upgrade,
330
-     * and either setting up the DB or setting up maintenance mode etc.
331
-     *
332
-     * @access public
333
-     * @return void
334
-     */
335
-    public function detect_if_activation_or_upgrade()
336
-    {
337
-        do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
338
-        // load M-Mode class
339
-        $this->registry->load_core('Maintenance_Mode');
340
-        // check if db has been updated, or if its a brand-new installation
341
-        $espresso_db_update = $this->fix_espresso_db_upgrade_option();
342
-        $request_type = $this->detect_req_type($espresso_db_update);
343
-        //EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
344
-        switch ($request_type) {
345
-            case EE_System::req_type_new_activation:
346
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
347
-                $this->_handle_core_version_change($espresso_db_update);
348
-                break;
349
-            case EE_System::req_type_reactivation:
350
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
351
-                $this->_handle_core_version_change($espresso_db_update);
352
-                break;
353
-            case EE_System::req_type_upgrade:
354
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
355
-                //migrations may be required now that we've upgraded
356
-                EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
357
-                $this->_handle_core_version_change($espresso_db_update);
358
-                //				echo "done upgrade";die;
359
-                break;
360
-            case EE_System::req_type_downgrade:
361
-                do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
362
-                //its possible migrations are no longer required
363
-                EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
364
-                $this->_handle_core_version_change($espresso_db_update);
365
-                break;
366
-            case EE_System::req_type_normal:
367
-            default:
368
-                //				$this->_maybe_redirect_to_ee_about();
369
-                break;
370
-        }
371
-        do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * Updates the list of installed versions and sets hooks for
378
-     * initializing the database later during the request
379
-     *
380
-     * @param array $espresso_db_update
381
-     */
382
-    protected function _handle_core_version_change($espresso_db_update)
383
-    {
384
-        $this->update_list_of_installed_versions($espresso_db_update);
385
-        //get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
386
-        add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations',
387
-            array($this, 'initialize_db_if_no_migrations_required'));
388
-    }
389
-
390
-
391
-
392
-    /**
393
-     * standardizes the wp option 'espresso_db_upgrade' which actually stores
394
-     * information about what versions of EE have been installed and activated,
395
-     * NOT necessarily the state of the database
396
-     *
397
-     * @param mixed $espresso_db_update the value of the WordPress option.
398
-     *                                            If not supplied, fetches it from the options table
399
-     * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
400
-     */
401
-    private function fix_espresso_db_upgrade_option($espresso_db_update = null)
402
-    {
403
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
404
-        if ( ! $espresso_db_update) {
405
-            $espresso_db_update = get_option('espresso_db_update');
406
-        }
407
-        // check that option is an array
408
-        if ( ! is_array($espresso_db_update)) {
409
-            // if option is FALSE, then it never existed
410
-            if ($espresso_db_update === false) {
411
-                // make $espresso_db_update an array and save option with autoload OFF
412
-                $espresso_db_update = array();
413
-                add_option('espresso_db_update', $espresso_db_update, '', 'no');
414
-            } else {
415
-                // option is NOT FALSE but also is NOT an array, so make it an array and save it
416
-                $espresso_db_update = array($espresso_db_update => array());
417
-                update_option('espresso_db_update', $espresso_db_update);
418
-            }
419
-        } else {
420
-            $corrected_db_update = array();
421
-            //if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
422
-            foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
423
-                if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
424
-                    //the key is an int, and the value IS NOT an array
425
-                    //so it must be numerically-indexed, where values are versions installed...
426
-                    //fix it!
427
-                    $version_string = $should_be_array;
428
-                    $corrected_db_update[$version_string] = array('unknown-date');
429
-                } else {
430
-                    //ok it checks out
431
-                    $corrected_db_update[$should_be_version_string] = $should_be_array;
432
-                }
433
-            }
434
-            $espresso_db_update = $corrected_db_update;
435
-            update_option('espresso_db_update', $espresso_db_update);
436
-        }
437
-        do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
438
-        return $espresso_db_update;
439
-    }
440
-
441
-
442
-
443
-    /**
444
-     * Does the traditional work of setting up the plugin's database and adding default data.
445
-     * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
446
-     * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
447
-     * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
448
-     * so that it will be done when migrations are finished
449
-     *
450
-     * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
451
-     * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
452
-     *                                       This is a resource-intensive job
453
-     *                                       so we prefer to only do it when necessary
454
-     * @return void
455
-     * @throws EE_Error
456
-     */
457
-    public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
458
-    {
459
-        $request_type = $this->detect_req_type();
460
-        //only initialize system if we're not in maintenance mode.
461
-        if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
462
-            update_option('ee_flush_rewrite_rules', true);
463
-            if ($verify_schema) {
464
-                EEH_Activation::initialize_db_and_folders();
465
-            }
466
-            EEH_Activation::initialize_db_content();
467
-            EEH_Activation::system_initialization();
468
-            if ($initialize_addons_too) {
469
-                $this->initialize_addons();
470
-            }
471
-        } else {
472
-            EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
473
-        }
474
-        if ($request_type === EE_System::req_type_new_activation
475
-            || $request_type === EE_System::req_type_reactivation
476
-            || (
477
-                $request_type === EE_System::req_type_upgrade
478
-                && $this->is_major_version_change()
479
-            )
480
-        ) {
481
-            add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
482
-        }
483
-    }
484
-
485
-
486
-
487
-    /**
488
-     * Initializes the db for all registered addons
489
-     *
490
-     * @throws EE_Error
491
-     */
492
-    public function initialize_addons()
493
-    {
494
-        //foreach registered addon, make sure its db is up-to-date too
495
-        foreach ($this->registry->addons as $addon) {
496
-            $addon->initialize_db_if_no_migrations_required();
497
-        }
498
-    }
499
-
500
-
501
-
502
-    /**
503
-     * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
504
-     *
505
-     * @param    array  $version_history
506
-     * @param    string $current_version_to_add version to be added to the version history
507
-     * @return    boolean success as to whether or not this option was changed
508
-     */
509
-    public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
510
-    {
511
-        if ( ! $version_history) {
512
-            $version_history = $this->fix_espresso_db_upgrade_option($version_history);
513
-        }
514
-        if ($current_version_to_add === null) {
515
-            $current_version_to_add = espresso_version();
516
-        }
517
-        $version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
518
-        // re-save
519
-        return update_option('espresso_db_update', $version_history);
520
-    }
521
-
522
-
523
-
524
-    /**
525
-     * Detects if the current version indicated in the has existed in the list of
526
-     * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
527
-     *
528
-     * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
529
-     *                                  If not supplied, fetches it from the options table.
530
-     *                                  Also, caches its result so later parts of the code can also know whether
531
-     *                                  there's been an update or not. This way we can add the current version to
532
-     *                                  espresso_db_update, but still know if this is a new install or not
533
-     * @return int one of the constants on EE_System::req_type_
534
-     */
535
-    public function detect_req_type($espresso_db_update = null)
536
-    {
537
-        if ($this->_req_type === null) {
538
-            $espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update
539
-                : $this->fix_espresso_db_upgrade_option();
540
-            $this->_req_type = EE_System::detect_req_type_given_activation_history($espresso_db_update,
541
-                'ee_espresso_activation', espresso_version());
542
-            $this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
543
-        }
544
-        return $this->_req_type;
545
-    }
546
-
547
-
548
-
549
-    /**
550
-     * Returns whether or not there was a non-micro version change (ie, change in either
551
-     * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
552
-     * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
553
-     *
554
-     * @param $activation_history
555
-     * @return bool
556
-     */
557
-    protected function _detect_major_version_change($activation_history)
558
-    {
559
-        $previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
560
-        $previous_version_parts = explode('.', $previous_version);
561
-        $current_version_parts = explode('.', espresso_version());
562
-        return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
563
-               && ($previous_version_parts[0] !== $current_version_parts[0]
564
-                   || $previous_version_parts[1] !== $current_version_parts[1]
565
-               );
566
-    }
567
-
568
-
569
-
570
-    /**
571
-     * Returns true if either the major or minor version of EE changed during this request.
572
-     * 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
573
-     *
574
-     * @return bool
575
-     */
576
-    public function is_major_version_change()
577
-    {
578
-        return $this->_major_version_change;
579
-    }
580
-
581
-
582
-
583
-    /**
584
-     * Determines the request type for any ee addon, given three piece of info: the current array of activation
585
-     * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
586
-     * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
587
-     * just activated to (for core that will always be espresso_version())
588
-     *
589
-     * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
590
-     *                                                 ee plugin. for core that's 'espresso_db_update'
591
-     * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
592
-     *                                                 indicate that this plugin was just activated
593
-     * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
594
-     *                                                 espresso_version())
595
-     * @return int one of the constants on EE_System::req_type_*
596
-     */
597
-    public static function detect_req_type_given_activation_history(
598
-        $activation_history_for_addon,
599
-        $activation_indicator_option_name,
600
-        $version_to_upgrade_to
601
-    ) {
602
-        $version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
603
-        if ($activation_history_for_addon) {
604
-            //it exists, so this isn't a completely new install
605
-            //check if this version already in that list of previously installed versions
606
-            if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) {
607
-                //it a version we haven't seen before
608
-                if ($version_is_higher === 1) {
609
-                    $req_type = EE_System::req_type_upgrade;
610
-                } else {
611
-                    $req_type = EE_System::req_type_downgrade;
612
-                }
613
-                delete_option($activation_indicator_option_name);
614
-            } else {
615
-                // its not an update. maybe a reactivation?
616
-                if (get_option($activation_indicator_option_name, false)) {
617
-                    if ($version_is_higher === -1) {
618
-                        $req_type = EE_System::req_type_downgrade;
619
-                    } elseif ($version_is_higher === 0) {
620
-                        //we've seen this version before, but it's an activation. must be a reactivation
621
-                        $req_type = EE_System::req_type_reactivation;
622
-                    } else {//$version_is_higher === 1
623
-                        $req_type = EE_System::req_type_upgrade;
624
-                    }
625
-                    delete_option($activation_indicator_option_name);
626
-                } else {
627
-                    //we've seen this version before and the activation indicate doesn't show it was just activated
628
-                    if ($version_is_higher === -1) {
629
-                        $req_type = EE_System::req_type_downgrade;
630
-                    } elseif ($version_is_higher === 0) {
631
-                        //we've seen this version before and it's not an activation. its normal request
632
-                        $req_type = EE_System::req_type_normal;
633
-                    } else {//$version_is_higher === 1
634
-                        $req_type = EE_System::req_type_upgrade;
635
-                    }
636
-                }
637
-            }
638
-        } else {
639
-            //brand new install
640
-            $req_type = EE_System::req_type_new_activation;
641
-            delete_option($activation_indicator_option_name);
642
-        }
643
-        return $req_type;
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * Detects if the $version_to_upgrade_to is higher than the most recent version in
650
-     * the $activation_history_for_addon
651
-     *
652
-     * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
653
-     *                                             sometimes containing 'unknown-date'
654
-     * @param string $version_to_upgrade_to        (current version)
655
-     * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
656
-     *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
657
-     *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
658
-     *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
659
-     */
660
-    protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
661
-    {
662
-        //find the most recently-activated version
663
-        $most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
664
-        return version_compare($version_to_upgrade_to, $most_recently_active_version);
665
-    }
666
-
667
-
668
-
669
-    /**
670
-     * Gets the most recently active version listed in the activation history,
671
-     * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
672
-     *
673
-     * @param array $activation_history  (keys are versions, values are arrays of times activated,
674
-     *                                   sometimes containing 'unknown-date'
675
-     * @return string
676
-     */
677
-    protected static function _get_most_recently_active_version_from_activation_history($activation_history)
678
-    {
679
-        $most_recently_active_version_activation = '1970-01-01 00:00:00';
680
-        $most_recently_active_version = '0.0.0.dev.000';
681
-        if (is_array($activation_history)) {
682
-            foreach ($activation_history as $version => $times_activated) {
683
-                //check there is a record of when this version was activated. Otherwise,
684
-                //mark it as unknown
685
-                if ( ! $times_activated) {
686
-                    $times_activated = array('unknown-date');
687
-                }
688
-                if (is_string($times_activated)) {
689
-                    $times_activated = array($times_activated);
690
-                }
691
-                foreach ($times_activated as $an_activation) {
692
-                    if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) {
693
-                        $most_recently_active_version = $version;
694
-                        $most_recently_active_version_activation = $an_activation === 'unknown-date'
695
-                            ? '1970-01-01 00:00:00' : $an_activation;
696
-                    }
697
-                }
698
-            }
699
-        }
700
-        return $most_recently_active_version;
701
-    }
702
-
703
-
704
-
705
-    /**
706
-     * This redirects to the about EE page after activation
707
-     *
708
-     * @return void
709
-     */
710
-    public function redirect_to_about_ee()
711
-    {
712
-        $notices = EE_Error::get_notices(false);
713
-        //if current user is an admin and it's not an ajax or rest request
714
-        if (
715
-            ! (defined('DOING_AJAX') && DOING_AJAX)
716
-            && ! (defined('REST_REQUEST') && REST_REQUEST)
717
-            && ! isset($notices['errors'])
718
-            && apply_filters(
719
-                'FHEE__EE_System__redirect_to_about_ee__do_redirect',
720
-                $this->registry->CAP->current_user_can('manage_options', 'espresso_about_default')
721
-            )
722
-        ) {
723
-            $query_params = array('page' => 'espresso_about');
724
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
725
-                $query_params['new_activation'] = true;
726
-            }
727
-            if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
728
-                $query_params['reactivation'] = true;
729
-            }
730
-            $url = add_query_arg($query_params, admin_url('admin.php'));
731
-            wp_safe_redirect($url);
732
-            exit();
733
-        }
734
-    }
735
-
736
-
737
-
738
-    /**
739
-     * load_core_configuration
740
-     * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
741
-     * which runs during the WP 'plugins_loaded' action at priority 5
742
-     *
743
-     * @return void
744
-     * @throws \ReflectionException
745
-     */
746
-    public function load_core_configuration()
747
-    {
748
-        do_action('AHEE__EE_System__load_core_configuration__begin', $this);
749
-        $this->registry->load_core('EE_Load_Textdomain');
750
-        //load textdomain
751
-        EE_Load_Textdomain::load_textdomain();
752
-        // load and setup EE_Config and EE_Network_Config
753
-        $this->registry->load_core('Config');
754
-        $this->registry->load_core('Network_Config');
755
-        // setup autoloaders
756
-        // enable logging?
757
-        if ($this->registry->CFG->admin->use_full_logging) {
758
-            $this->registry->load_core('Log');
759
-        }
760
-        // check for activation errors
761
-        $activation_errors = get_option('ee_plugin_activation_errors', false);
762
-        if ($activation_errors) {
763
-            EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
764
-            update_option('ee_plugin_activation_errors', false);
765
-        }
766
-        // get model names
767
-        $this->_parse_model_names();
768
-        //load caf stuff a chance to play during the activation process too.
769
-        $this->_maybe_brew_regular();
770
-        do_action('AHEE__EE_System__load_core_configuration__complete', $this);
771
-    }
772
-
773
-
774
-
775
-    /**
776
-     * cycles through all of the models/*.model.php files, and assembles an array of model names
777
-     *
778
-     * @return void
779
-     * @throws ReflectionException
780
-     */
781
-    private function _parse_model_names()
782
-    {
783
-        //get all the files in the EE_MODELS folder that end in .model.php
784
-        $models = glob(EE_MODELS . '*.model.php');
785
-        $model_names = array();
786
-        $non_abstract_db_models = array();
787
-        foreach ($models as $model) {
788
-            // get model classname
789
-            $classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
790
-            $short_name = str_replace('EEM_', '', $classname);
791
-            $reflectionClass = new ReflectionClass($classname);
792
-            if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
793
-                $non_abstract_db_models[$short_name] = $classname;
794
-            }
795
-            $model_names[$short_name] = $classname;
796
-        }
797
-        $this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
798
-        $this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names',
799
-            $non_abstract_db_models);
800
-    }
801
-
802
-
803
-
804
-    /**
805
-     * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
806
-     * that need to be setup before our EE_System launches.
807
-     *
808
-     * @return void
809
-     */
810
-    private function _maybe_brew_regular()
811
-    {
812
-        if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
813
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
814
-        }
815
-    }
816
-
817
-
818
-
819
-    /**
820
-     * register_shortcodes_modules_and_widgets
821
-     * generate lists of shortcodes and modules, then verify paths and classes
822
-     * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
823
-     * which runs during the WP 'plugins_loaded' action at priority 7
824
-     *
825
-     * @access public
826
-     * @return void
827
-     */
828
-    public function register_shortcodes_modules_and_widgets()
829
-    {
830
-        try {
831
-            // load, register, and add shortcodes the new way
832
-            new ShortcodesManager(
833
-            // and the old way, but we'll put it under control of the new system
834
-                EE_Config::getLegacyShortcodesManager()
835
-            );
836
-        } catch (Exception $exception) {
837
-            new ExceptionStackTraceDisplay($exception);
838
-        }
839
-        do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
840
-        // check for addons using old hook point
841
-        if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
842
-            $this->_incompatible_addon_error();
843
-        }
844
-    }
845
-
846
-
847
-
848
-    /**
849
-     * _incompatible_addon_error
850
-     *
851
-     * @access public
852
-     * @return void
853
-     */
854
-    private function _incompatible_addon_error()
855
-    {
856
-        // get array of classes hooking into here
857
-        $class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons');
858
-        if ( ! empty($class_names)) {
859
-            $msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
860
-                'event_espresso');
861
-            $msg .= '<ul>';
862
-            foreach ($class_names as $class_name) {
863
-                $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
864
-                        $class_name) . '</b></li>';
865
-            }
866
-            $msg .= '</ul>';
867
-            $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
868
-                'event_espresso');
869
-            // save list of incompatible addons to wp-options for later use
870
-            add_option('ee_incompatible_addons', $class_names, '', 'no');
871
-            if (is_admin()) {
872
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
873
-            }
874
-        }
875
-    }
876
-
877
-
878
-
879
-    /**
880
-     * brew_espresso
881
-     * begins the process of setting hooks for initializing EE in the correct order
882
-     * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
883
-     * which runs during the WP 'plugins_loaded' action at priority 9
884
-     *
885
-     * @return void
886
-     */
887
-    public function brew_espresso()
888
-    {
889
-        do_action('AHEE__EE_System__brew_espresso__begin', $this);
890
-        // load some final core systems
891
-        add_action('init', array($this, 'set_hooks_for_core'), 1);
892
-        add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
893
-        add_action('init', array($this, 'load_CPTs_and_session'), 5);
894
-        add_action('init', array($this, 'load_controllers'), 7);
895
-        add_action('init', array($this, 'core_loaded_and_ready'), 9);
896
-        add_action('init', array($this, 'initialize'), 10);
897
-        add_action('init', array($this, 'initialize_last'), 100);
898
-        add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100);
899
-        if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
900
-            // pew pew pew
901
-            $this->registry->load_core('PUE');
902
-            do_action('AHEE__EE_System__brew_espresso__after_pue_init');
903
-        }
904
-        do_action('AHEE__EE_System__brew_espresso__complete', $this);
905
-    }
906
-
907
-
908
-
909
-    /**
910
-     *    set_hooks_for_core
911
-     *
912
-     * @access public
913
-     * @return    void
914
-     * @throws EE_Error
915
-     */
916
-    public function set_hooks_for_core()
917
-    {
918
-        $this->_deactivate_incompatible_addons();
919
-        do_action('AHEE__EE_System__set_hooks_for_core');
920
-        //caps need to be initialized on every request so that capability maps are set.
921
-        //@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
922
-        $this->registry->CAP->init_caps();
923
-    }
924
-
925
-
926
-
927
-    /**
928
-     * Using the information gathered in EE_System::_incompatible_addon_error,
929
-     * deactivates any addons considered incompatible with the current version of EE
930
-     */
931
-    private function _deactivate_incompatible_addons()
932
-    {
933
-        $incompatible_addons = get_option('ee_incompatible_addons', array());
934
-        if ( ! empty($incompatible_addons)) {
935
-            $active_plugins = get_option('active_plugins', array());
936
-            foreach ($active_plugins as $active_plugin) {
937
-                foreach ($incompatible_addons as $incompatible_addon) {
938
-                    if (strpos($active_plugin, $incompatible_addon) !== false) {
939
-                        unset($_GET['activate']);
940
-                        espresso_deactivate_plugin($active_plugin);
941
-                    }
942
-                }
943
-            }
944
-        }
945
-    }
946
-
947
-
948
-
949
-    /**
950
-     *    perform_activations_upgrades_and_migrations
951
-     *
952
-     * @access public
953
-     * @return    void
954
-     */
955
-    public function perform_activations_upgrades_and_migrations()
956
-    {
957
-        //first check if we had previously attempted to setup EE's directories but failed
958
-        if (EEH_Activation::upload_directories_incomplete()) {
959
-            EEH_Activation::create_upload_directories();
960
-        }
961
-        do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
962
-    }
963
-
964
-
965
-
966
-    /**
967
-     *    load_CPTs_and_session
968
-     *
969
-     * @access public
970
-     * @return    void
971
-     */
972
-    public function load_CPTs_and_session()
973
-    {
974
-        do_action('AHEE__EE_System__load_CPTs_and_session__start');
975
-        // register Custom Post Types
976
-        $this->registry->load_core('Register_CPTs');
977
-        do_action('AHEE__EE_System__load_CPTs_and_session__complete');
978
-    }
979
-
980
-
981
-
982
-    /**
983
-     * load_controllers
984
-     * this is the best place to load any additional controllers that needs access to EE core.
985
-     * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
986
-     * time
987
-     *
988
-     * @access public
989
-     * @return void
990
-     */
991
-    public function load_controllers()
992
-    {
993
-        do_action('AHEE__EE_System__load_controllers__start');
994
-        // let's get it started
995
-        if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
996
-            do_action('AHEE__EE_System__load_controllers__load_front_controllers');
997
-            $this->registry->load_core('Front_Controller');
998
-        } else if ( ! EE_FRONT_AJAX) {
999
-            do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1000
-            EE_Registry::instance()->load_core('Admin');
1001
-        }
1002
-        do_action('AHEE__EE_System__load_controllers__complete');
1003
-    }
1004
-
1005
-
1006
-
1007
-    /**
1008
-     * core_loaded_and_ready
1009
-     * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1010
-     *
1011
-     * @access public
1012
-     * @return void
1013
-     */
1014
-    public function core_loaded_and_ready()
1015
-    {
1016
-        $this->registry->load_core('Session');
1017
-        do_action('AHEE__EE_System__core_loaded_and_ready');
1018
-        // load_espresso_template_tags
1019
-        if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1020
-            require_once(EE_PUBLIC . 'template_tags.php');
1021
-        }
1022
-        do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1023
-        $this->registry->create('EventEspresso\core\services\assets\Registry', array(), true);
1024
-    }
1025
-
1026
-
1027
-
1028
-    /**
1029
-     * initialize
1030
-     * this is the best place to begin initializing client code
1031
-     *
1032
-     * @access public
1033
-     * @return void
1034
-     */
1035
-    public function initialize()
1036
-    {
1037
-        do_action('AHEE__EE_System__initialize');
1038
-    }
1039
-
1040
-
1041
-
1042
-    /**
1043
-     * initialize_last
1044
-     * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1045
-     * initialize has done so
1046
-     *
1047
-     * @access public
1048
-     * @return void
1049
-     */
1050
-    public function initialize_last()
1051
-    {
1052
-        do_action('AHEE__EE_System__initialize_last');
1053
-    }
1054
-
1055
-
1056
-
1057
-    /**
1058
-     * set_hooks_for_shortcodes_modules_and_addons
1059
-     * this is the best place for other systems to set callbacks for hooking into other parts of EE
1060
-     * this happens at the very beginning of the wp_loaded hook point
1061
-     *
1062
-     * @access public
1063
-     * @return void
1064
-     */
1065
-    public function set_hooks_for_shortcodes_modules_and_addons()
1066
-    {
1067
-        //		do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' );
1068
-    }
1069
-
1070
-
1071
-
1072
-    /**
1073
-     * do_not_cache
1074
-     * sets no cache headers and defines no cache constants for WP plugins
1075
-     *
1076
-     * @access public
1077
-     * @return void
1078
-     */
1079
-    public static function do_not_cache()
1080
-    {
1081
-        // set no cache constants
1082
-        if ( ! defined('DONOTCACHEPAGE')) {
1083
-            define('DONOTCACHEPAGE', true);
1084
-        }
1085
-        if ( ! defined('DONOTCACHCEOBJECT')) {
1086
-            define('DONOTCACHCEOBJECT', true);
1087
-        }
1088
-        if ( ! defined('DONOTCACHEDB')) {
1089
-            define('DONOTCACHEDB', true);
1090
-        }
1091
-        // add no cache headers
1092
-        add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1093
-        // plus a little extra for nginx and Google Chrome
1094
-        add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1095
-        // prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1096
-        remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1097
-    }
1098
-
1099
-
1100
-
1101
-    /**
1102
-     *    extra_nocache_headers
1103
-     *
1104
-     * @access    public
1105
-     * @param $headers
1106
-     * @return    array
1107
-     */
1108
-    public static function extra_nocache_headers($headers)
1109
-    {
1110
-        // for NGINX
1111
-        $headers['X-Accel-Expires'] = 0;
1112
-        // plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1113
-        $headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1114
-        return $headers;
1115
-    }
1116
-
1117
-
1118
-
1119
-    /**
1120
-     *    nocache_headers
1121
-     *
1122
-     * @access    public
1123
-     * @return    void
1124
-     */
1125
-    public static function nocache_headers()
1126
-    {
1127
-        nocache_headers();
1128
-    }
1129
-
1130
-
1131
-
1132
-    /**
1133
-     *    espresso_toolbar_items
1134
-     *
1135
-     * @access public
1136
-     * @param  WP_Admin_Bar $admin_bar
1137
-     * @return void
1138
-     */
1139
-    public function espresso_toolbar_items(WP_Admin_Bar $admin_bar)
1140
-    {
1141
-        // if in full M-Mode, or its an AJAX request, or user is NOT an admin
1142
-        if (
1143
-            defined('DOING_AJAX')
1144
-            || ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
1145
-            || EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
1146
-        ) {
1147
-            return;
1148
-        }
1149
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1150
-        $menu_class = 'espresso_menu_item_class';
1151
-        //we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
1152
-        //because they're only defined in each of their respective constructors
1153
-        //and this might be a frontend request, in which case they aren't available
1154
-        $events_admin_url = admin_url('admin.php?page=espresso_events');
1155
-        $reg_admin_url = admin_url('admin.php?page=espresso_registrations');
1156
-        $extensions_admin_url = admin_url('admin.php?page=espresso_packages');
1157
-        //Top Level
1158
-        $admin_bar->add_menu(array(
1159
-            'id'    => 'espresso-toolbar',
1160
-            'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'
1161
-                       . _x('Event Espresso', 'admin bar menu group label', 'event_espresso')
1162
-                       . '</span>',
1163
-            'href'  => $events_admin_url,
1164
-            'meta'  => array(
1165
-                'title' => __('Event Espresso', 'event_espresso'),
1166
-                'class' => $menu_class . 'first',
1167
-            ),
1168
-        ));
1169
-        //Events
1170
-        if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) {
1171
-            $admin_bar->add_menu(array(
1172
-                'id'     => 'espresso-toolbar-events',
1173
-                'parent' => 'espresso-toolbar',
1174
-                'title'  => __('Events', 'event_espresso'),
1175
-                'href'   => $events_admin_url,
1176
-                'meta'   => array(
1177
-                    'title'  => __('Events', 'event_espresso'),
1178
-                    'target' => '',
1179
-                    'class'  => $menu_class,
1180
-                ),
1181
-            ));
1182
-        }
1183
-        if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) {
1184
-            //Events Add New
1185
-            $admin_bar->add_menu(array(
1186
-                'id'     => 'espresso-toolbar-events-new',
1187
-                'parent' => 'espresso-toolbar-events',
1188
-                'title'  => __('Add New', 'event_espresso'),
1189
-                'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url),
1190
-                'meta'   => array(
1191
-                    'title'  => __('Add New', 'event_espresso'),
1192
-                    'target' => '',
1193
-                    'class'  => $menu_class,
1194
-                ),
1195
-            ));
1196
-        }
1197
-        if (is_single() && (get_post_type() === 'espresso_events')) {
1198
-            //Current post
1199
-            global $post;
1200
-            if ($this->registry->CAP->current_user_can('ee_edit_event',
1201
-                'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)
1202
-            ) {
1203
-                //Events Edit Current Event
1204
-                $admin_bar->add_menu(array(
1205
-                    'id'     => 'espresso-toolbar-events-edit',
1206
-                    'parent' => 'espresso-toolbar-events',
1207
-                    'title'  => __('Edit Event', 'event_espresso'),
1208
-                    'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID),
1209
-                        $events_admin_url),
1210
-                    'meta'   => array(
1211
-                        'title'  => __('Edit Event', 'event_espresso'),
1212
-                        'target' => '',
1213
-                        'class'  => $menu_class,
1214
-                    ),
1215
-                ));
1216
-            }
1217
-        }
1218
-        //Events View
1219
-        if ($this->registry->CAP->current_user_can('ee_read_events',
1220
-            'ee_admin_bar_menu_espresso-toolbar-events-view')
1221
-        ) {
1222
-            $admin_bar->add_menu(array(
1223
-                'id'     => 'espresso-toolbar-events-view',
1224
-                'parent' => 'espresso-toolbar-events',
1225
-                'title'  => __('View', 'event_espresso'),
1226
-                'href'   => $events_admin_url,
1227
-                'meta'   => array(
1228
-                    'title'  => __('View', 'event_espresso'),
1229
-                    'target' => '',
1230
-                    'class'  => $menu_class,
1231
-                ),
1232
-            ));
1233
-        }
1234
-        if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) {
1235
-            //Events View All
1236
-            $admin_bar->add_menu(array(
1237
-                'id'     => 'espresso-toolbar-events-all',
1238
-                'parent' => 'espresso-toolbar-events-view',
1239
-                'title'  => __('All', 'event_espresso'),
1240
-                'href'   => $events_admin_url,
1241
-                'meta'   => array(
1242
-                    'title'  => __('All', 'event_espresso'),
1243
-                    'target' => '',
1244
-                    'class'  => $menu_class,
1245
-                ),
1246
-            ));
1247
-        }
1248
-        if ($this->registry->CAP->current_user_can('ee_read_events',
1249
-            'ee_admin_bar_menu_espresso-toolbar-events-today')
1250
-        ) {
1251
-            //Events View Today
1252
-            $admin_bar->add_menu(array(
1253
-                'id'     => 'espresso-toolbar-events-today',
1254
-                'parent' => 'espresso-toolbar-events-view',
1255
-                'title'  => __('Today', 'event_espresso'),
1256
-                'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'),
1257
-                    $events_admin_url),
1258
-                'meta'   => array(
1259
-                    'title'  => __('Today', 'event_espresso'),
1260
-                    'target' => '',
1261
-                    'class'  => $menu_class,
1262
-                ),
1263
-            ));
1264
-        }
1265
-        if ($this->registry->CAP->current_user_can('ee_read_events',
1266
-            'ee_admin_bar_menu_espresso-toolbar-events-month')
1267
-        ) {
1268
-            //Events View This Month
1269
-            $admin_bar->add_menu(array(
1270
-                'id'     => 'espresso-toolbar-events-month',
1271
-                'parent' => 'espresso-toolbar-events-view',
1272
-                'title'  => __('This Month', 'event_espresso'),
1273
-                'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'),
1274
-                    $events_admin_url),
1275
-                'meta'   => array(
1276
-                    'title'  => __('This Month', 'event_espresso'),
1277
-                    'target' => '',
1278
-                    'class'  => $menu_class,
1279
-                ),
1280
-            ));
1281
-        }
1282
-        //Registration Overview
1283
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1284
-            'ee_admin_bar_menu_espresso-toolbar-registrations')
1285
-        ) {
1286
-            $admin_bar->add_menu(array(
1287
-                'id'     => 'espresso-toolbar-registrations',
1288
-                'parent' => 'espresso-toolbar',
1289
-                'title'  => __('Registrations', 'event_espresso'),
1290
-                'href'   => $reg_admin_url,
1291
-                'meta'   => array(
1292
-                    'title'  => __('Registrations', 'event_espresso'),
1293
-                    'target' => '',
1294
-                    'class'  => $menu_class,
1295
-                ),
1296
-            ));
1297
-        }
1298
-        //Registration Overview Today
1299
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1300
-            'ee_admin_bar_menu_espresso-toolbar-registrations-today')
1301
-        ) {
1302
-            $admin_bar->add_menu(array(
1303
-                'id'     => 'espresso-toolbar-registrations-today',
1304
-                'parent' => 'espresso-toolbar-registrations',
1305
-                'title'  => __('Today', 'event_espresso'),
1306
-                'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'),
1307
-                    $reg_admin_url),
1308
-                'meta'   => array(
1309
-                    'title'  => __('Today', 'event_espresso'),
1310
-                    'target' => '',
1311
-                    'class'  => $menu_class,
1312
-                ),
1313
-            ));
1314
-        }
1315
-        //Registration Overview Today Completed
1316
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1317
-            'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')
1318
-        ) {
1319
-            $admin_bar->add_menu(array(
1320
-                'id'     => 'espresso-toolbar-registrations-today-approved',
1321
-                'parent' => 'espresso-toolbar-registrations-today',
1322
-                'title'  => __('Approved', 'event_espresso'),
1323
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1324
-                    'action'      => 'default',
1325
-                    'status'      => 'today',
1326
-                    '_reg_status' => EEM_Registration::status_id_approved,
1327
-                ), $reg_admin_url),
1328
-                'meta'   => array(
1329
-                    'title'  => __('Approved', 'event_espresso'),
1330
-                    'target' => '',
1331
-                    'class'  => $menu_class,
1332
-                ),
1333
-            ));
1334
-        }
1335
-        //Registration Overview Today Pending\
1336
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1337
-            'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')
1338
-        ) {
1339
-            $admin_bar->add_menu(array(
1340
-                'id'     => 'espresso-toolbar-registrations-today-pending',
1341
-                'parent' => 'espresso-toolbar-registrations-today',
1342
-                'title'  => __('Pending', 'event_espresso'),
1343
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1344
-                    'action'     => 'default',
1345
-                    'status'     => 'today',
1346
-                    'reg_status' => EEM_Registration::status_id_pending_payment,
1347
-                ), $reg_admin_url),
1348
-                'meta'   => array(
1349
-                    'title'  => __('Pending Payment', 'event_espresso'),
1350
-                    'target' => '',
1351
-                    'class'  => $menu_class,
1352
-                ),
1353
-            ));
1354
-        }
1355
-        //Registration Overview Today Incomplete
1356
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1357
-            'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')
1358
-        ) {
1359
-            $admin_bar->add_menu(array(
1360
-                'id'     => 'espresso-toolbar-registrations-today-not-approved',
1361
-                'parent' => 'espresso-toolbar-registrations-today',
1362
-                'title'  => __('Not Approved', 'event_espresso'),
1363
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1364
-                    'action'      => 'default',
1365
-                    'status'      => 'today',
1366
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1367
-                ), $reg_admin_url),
1368
-                'meta'   => array(
1369
-                    'title'  => __('Not Approved', 'event_espresso'),
1370
-                    'target' => '',
1371
-                    'class'  => $menu_class,
1372
-                ),
1373
-            ));
1374
-        }
1375
-        //Registration Overview Today Incomplete
1376
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1377
-            'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')
1378
-        ) {
1379
-            $admin_bar->add_menu(array(
1380
-                'id'     => 'espresso-toolbar-registrations-today-cancelled',
1381
-                'parent' => 'espresso-toolbar-registrations-today',
1382
-                'title'  => __('Cancelled', 'event_espresso'),
1383
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1384
-                    'action'      => 'default',
1385
-                    'status'      => 'today',
1386
-                    '_reg_status' => EEM_Registration::status_id_cancelled,
1387
-                ), $reg_admin_url),
1388
-                'meta'   => array(
1389
-                    'title'  => __('Cancelled', 'event_espresso'),
1390
-                    'target' => '',
1391
-                    'class'  => $menu_class,
1392
-                ),
1393
-            ));
1394
-        }
1395
-        //Registration Overview This Month
1396
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1397
-            'ee_admin_bar_menu_espresso-toolbar-registrations-month')
1398
-        ) {
1399
-            $admin_bar->add_menu(array(
1400
-                'id'     => 'espresso-toolbar-registrations-month',
1401
-                'parent' => 'espresso-toolbar-registrations',
1402
-                'title'  => __('This Month', 'event_espresso'),
1403
-                'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'),
1404
-                    $reg_admin_url),
1405
-                'meta'   => array(
1406
-                    'title'  => __('This Month', 'event_espresso'),
1407
-                    'target' => '',
1408
-                    'class'  => $menu_class,
1409
-                ),
1410
-            ));
1411
-        }
1412
-        //Registration Overview This Month Approved
1413
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1414
-            'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')
1415
-        ) {
1416
-            $admin_bar->add_menu(array(
1417
-                'id'     => 'espresso-toolbar-registrations-month-approved',
1418
-                'parent' => 'espresso-toolbar-registrations-month',
1419
-                'title'  => __('Approved', 'event_espresso'),
1420
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1421
-                    'action'      => 'default',
1422
-                    'status'      => 'month',
1423
-                    '_reg_status' => EEM_Registration::status_id_approved,
1424
-                ), $reg_admin_url),
1425
-                'meta'   => array(
1426
-                    'title'  => __('Approved', 'event_espresso'),
1427
-                    'target' => '',
1428
-                    'class'  => $menu_class,
1429
-                ),
1430
-            ));
1431
-        }
1432
-        //Registration Overview This Month Pending
1433
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1434
-            'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')
1435
-        ) {
1436
-            $admin_bar->add_menu(array(
1437
-                'id'     => 'espresso-toolbar-registrations-month-pending',
1438
-                'parent' => 'espresso-toolbar-registrations-month',
1439
-                'title'  => __('Pending', 'event_espresso'),
1440
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1441
-                    'action'      => 'default',
1442
-                    'status'      => 'month',
1443
-                    '_reg_status' => EEM_Registration::status_id_pending_payment,
1444
-                ), $reg_admin_url),
1445
-                'meta'   => array(
1446
-                    'title'  => __('Pending', 'event_espresso'),
1447
-                    'target' => '',
1448
-                    'class'  => $menu_class,
1449
-                ),
1450
-            ));
1451
-        }
1452
-        //Registration Overview This Month Not Approved
1453
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1454
-            'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')
1455
-        ) {
1456
-            $admin_bar->add_menu(array(
1457
-                'id'     => 'espresso-toolbar-registrations-month-not-approved',
1458
-                'parent' => 'espresso-toolbar-registrations-month',
1459
-                'title'  => __('Not Approved', 'event_espresso'),
1460
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1461
-                    'action'      => 'default',
1462
-                    'status'      => 'month',
1463
-                    '_reg_status' => EEM_Registration::status_id_not_approved,
1464
-                ), $reg_admin_url),
1465
-                'meta'   => array(
1466
-                    'title'  => __('Not Approved', 'event_espresso'),
1467
-                    'target' => '',
1468
-                    'class'  => $menu_class,
1469
-                ),
1470
-            ));
1471
-        }
1472
-        //Registration Overview This Month Cancelled
1473
-        if ($this->registry->CAP->current_user_can('ee_read_registrations',
1474
-            'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')
1475
-        ) {
1476
-            $admin_bar->add_menu(array(
1477
-                'id'     => 'espresso-toolbar-registrations-month-cancelled',
1478
-                'parent' => 'espresso-toolbar-registrations-month',
1479
-                'title'  => __('Cancelled', 'event_espresso'),
1480
-                'href'   => EEH_URL::add_query_args_and_nonce(array(
1481
-                    'action'      => 'default',
1482
-                    'status'      => 'month',
1483
-                    '_reg_status' => EEM_Registration::status_id_cancelled,
1484
-                ), $reg_admin_url),
1485
-                'meta'   => array(
1486
-                    'title'  => __('Cancelled', 'event_espresso'),
1487
-                    'target' => '',
1488
-                    'class'  => $menu_class,
1489
-                ),
1490
-            ));
1491
-        }
1492
-        //Extensions & Services
1493
-        if ($this->registry->CAP->current_user_can('ee_read_ee',
1494
-            'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')
1495
-        ) {
1496
-            $admin_bar->add_menu(array(
1497
-                'id'     => 'espresso-toolbar-extensions-and-services',
1498
-                'parent' => 'espresso-toolbar',
1499
-                'title'  => __('Extensions & Services', 'event_espresso'),
1500
-                'href'   => $extensions_admin_url,
1501
-                'meta'   => array(
1502
-                    'title'  => __('Extensions & Services', 'event_espresso'),
1503
-                    'target' => '',
1504
-                    'class'  => $menu_class,
1505
-                ),
1506
-            ));
1507
-        }
1508
-    }
1509
-
1510
-
1511
-
1512
-    /**
1513
-     * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1514
-     * never returned with the function.
1515
-     *
1516
-     * @param  array $exclude_array any existing pages being excluded are in this array.
1517
-     * @return array
1518
-     */
1519
-    public function remove_pages_from_wp_list_pages($exclude_array)
1520
-    {
1521
-        return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1522
-    }
26
+	/**
27
+	 * indicates this is a 'normal' request. Ie, not activation, nor upgrade, nor activation.
28
+	 * So examples of this would be a normal GET request on the frontend or backend, or a POST, etc
29
+	 */
30
+	const req_type_normal = 0;
31
+
32
+	/**
33
+	 * Indicates this is a brand new installation of EE so we should install
34
+	 * tables and default data etc
35
+	 */
36
+	const req_type_new_activation = 1;
37
+
38
+	/**
39
+	 * we've detected that EE has been reactivated (or EE was activated during maintenance mode,
40
+	 * and we just exited maintenance mode). We MUST check the database is setup properly
41
+	 * and that default data is setup too
42
+	 */
43
+	const req_type_reactivation = 2;
44
+
45
+	/**
46
+	 * indicates that EE has been upgraded since its previous request.
47
+	 * We may have data migration scripts to call and will want to trigger maintenance mode
48
+	 */
49
+	const req_type_upgrade = 3;
50
+
51
+	/**
52
+	 * TODO  will detect that EE has been DOWNGRADED. We probably don't want to run in this case...
53
+	 */
54
+	const req_type_downgrade = 4;
55
+
56
+	/**
57
+	 * @deprecated since version 4.6.0.dev.006
58
+	 * Now whenever a new_activation is detected the request type is still just
59
+	 * new_activation (same for reactivation, upgrade, downgrade etc), but if we'r ein maintenance mode
60
+	 * EE_System::initialize_db_if_no_migrations_required and EE_Addon::initialize_db_if_no_migrations_required
61
+	 * will instead enqueue that EE plugin's db initialization for when we're taken out of maintenance mode.
62
+	 * (Specifically, when the migration manager indicates migrations are finished
63
+	 * EE_Data_Migration_Manager::initialize_db_for_enqueued_ee_plugins() will be called)
64
+	 */
65
+	const req_type_activation_but_not_installed = 5;
66
+
67
+	/**
68
+	 * option prefix for recording the activation history (like core's "espresso_db_update") of addons
69
+	 */
70
+	const addon_activation_history_option_prefix = 'ee_addon_activation_history_';
71
+
72
+
73
+	/**
74
+	 * @var EE_System $_instance
75
+	 */
76
+	private static $_instance;
77
+
78
+	/**
79
+	 * @var EE_Registry $registry
80
+	 */
81
+	protected $registry;
82
+
83
+	/**
84
+	 * Stores which type of request this is, options being one of the constants on EE_System starting with req_type_*.
85
+	 * It can be a brand-new activation, a reactivation, an upgrade, a downgrade, or a normal request.
86
+	 *
87
+	 * @var int $_req_type
88
+	 */
89
+	private $_req_type;
90
+
91
+	/**
92
+	 * Whether or not there was a non-micro version change in EE core version during this request
93
+	 *
94
+	 * @var boolean $_major_version_change
95
+	 */
96
+	private $_major_version_change = false;
97
+
98
+
99
+
100
+	/**
101
+	 * @singleton method used to instantiate class object
102
+	 * @access    public
103
+	 * @param  EE_Registry $Registry
104
+	 * @return EE_System
105
+	 */
106
+	public static function instance(EE_Registry $Registry = null)
107
+	{
108
+		// check if class object is instantiated
109
+		if ( ! self::$_instance instanceof EE_System) {
110
+			self::$_instance = new self($Registry);
111
+		}
112
+		return self::$_instance;
113
+	}
114
+
115
+
116
+
117
+	/**
118
+	 * resets the instance and returns it
119
+	 *
120
+	 * @return EE_System
121
+	 */
122
+	public static function reset()
123
+	{
124
+		self::$_instance->_req_type = null;
125
+		//make sure none of the old hooks are left hanging around
126
+		remove_all_actions('AHEE__EE_System__perform_activations_upgrades_and_migrations');
127
+		//we need to reset the migration manager in order for it to detect DMSs properly
128
+		EE_Data_Migration_Manager::reset();
129
+		self::instance()->detect_activations_or_upgrades();
130
+		self::instance()->perform_activations_upgrades_and_migrations();
131
+		return self::instance();
132
+	}
133
+
134
+
135
+
136
+	/**
137
+	 *    sets hooks for running rest of system
138
+	 *    provides "AHEE__EE_System__construct__complete" hook for EE Addons to use as their starting point
139
+	 *    starting EE Addons from any other point may lead to problems
140
+	 *
141
+	 * @access private
142
+	 * @param  EE_Registry $Registry
143
+	 */
144
+	private function __construct(EE_Registry $Registry)
145
+	{
146
+		$this->registry = $Registry;
147
+		do_action('AHEE__EE_System__construct__begin', $this);
148
+		add_action(
149
+			'AHEE__EE_Bootstrap__load_espresso_addons',
150
+			array($this, 'loadCapabilities'),
151
+			5
152
+		);
153
+		add_action(
154
+			'AHEE__EE_Bootstrap__load_espresso_addons',
155
+			array($this, 'loadCommandBus'),
156
+			7
157
+		);
158
+		add_action(
159
+			'AHEE__EE_Bootstrap__load_espresso_addons',
160
+			array($this, 'loadPluginApi'),
161
+			9
162
+		);
163
+		// allow addons to load first so that they can register autoloaders, set hooks for running DMS's, etc
164
+		add_action(
165
+			'AHEE__EE_Bootstrap__load_espresso_addons',
166
+			array($this, 'load_espresso_addons')
167
+		);
168
+		// when an ee addon is activated, we want to call the core hook(s) again
169
+		// because the newly-activated addon didn't get a chance to run at all
170
+		add_action('activate_plugin', array($this, 'load_espresso_addons'), 1);
171
+		// detect whether install or upgrade
172
+		add_action(
173
+			'AHEE__EE_Bootstrap__detect_activations_or_upgrades',
174
+			array($this, 'detect_activations_or_upgrades'),
175
+			3
176
+		);
177
+		// load EE_Config, EE_Textdomain, etc
178
+		add_action(
179
+			'AHEE__EE_Bootstrap__load_core_configuration',
180
+			array($this, 'load_core_configuration'),
181
+			5
182
+		);
183
+		// load EE_Config, EE_Textdomain, etc
184
+		add_action(
185
+			'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets',
186
+			array($this, 'register_shortcodes_modules_and_widgets'),
187
+			7
188
+		);
189
+		// you wanna get going? I wanna get going... let's get going!
190
+		add_action(
191
+			'AHEE__EE_Bootstrap__brew_espresso',
192
+			array($this, 'brew_espresso'),
193
+			9
194
+		);
195
+		//other housekeeping
196
+		//exclude EE critical pages from wp_list_pages
197
+		add_filter(
198
+			'wp_list_pages_excludes',
199
+			array($this, 'remove_pages_from_wp_list_pages'),
200
+			10
201
+		);
202
+		// ALL EE Addons should use the following hook point to attach their initial setup too
203
+		// it's extremely important for EE Addons to register any class autoloaders so that they can be available when the EE_Config loads
204
+		do_action('AHEE__EE_System__construct__complete', $this);
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * load and setup EE_Capabilities
211
+	 *
212
+	 * @return void
213
+	 * @throws EE_Error
214
+	 */
215
+	public function loadCapabilities()
216
+	{
217
+		$this->registry->load_core('EE_Capabilities');
218
+		add_action(
219
+			'AHEE__EE_Capabilities__init_caps__before_initialization',
220
+			function() {
221
+				EE_Registry::instance()->load_lib('Payment_Method_Manager');
222
+			}
223
+		);
224
+	}
225
+
226
+
227
+
228
+	/**
229
+	 * create and cache the CommandBus, and also add middleware
230
+	 * The CapChecker middleware requires the use of EE_Capabilities
231
+	 * which is why we need to load the CommandBus after Caps are set up
232
+	 *
233
+	 * @return void
234
+	 * @throws EE_Error
235
+	 */
236
+	public function loadCommandBus()
237
+	{
238
+		$this->registry->create(
239
+			'CommandBusInterface',
240
+			array(
241
+				null,
242
+				apply_filters(
243
+					'FHEE__EE_Load_Espresso_Core__handle_request__CommandBus_middleware',
244
+					array(
245
+						$this->registry->create('CapChecker'),
246
+						$this->registry->create('AddActionHook'),
247
+					)
248
+				),
249
+			),
250
+			true
251
+		);
252
+	}
253
+
254
+
255
+
256
+	/**
257
+	 * @return void
258
+	 * @throws EE_Error
259
+	 */
260
+	public function loadPluginApi()
261
+	{
262
+		// set autoloaders for all of the classes implementing EEI_Plugin_API
263
+		// which provide helpers for EE plugin authors to more easily register certain components with EE.
264
+		EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
265
+	}
266
+
267
+
268
+
269
+	/**
270
+	 * load_espresso_addons
271
+	 * allow addons to load first so that they can set hooks for running DMS's, etc
272
+	 * this is hooked into both:
273
+	 *    'AHEE__EE_Bootstrap__load_core_configuration'
274
+	 *        which runs during the WP 'plugins_loaded' action at priority 5
275
+	 *    and the WP 'activate_plugin' hook point
276
+	 *
277
+	 * @access public
278
+	 * @return void
279
+	 * @throws EE_Error
280
+	 */
281
+	public function load_espresso_addons()
282
+	{
283
+		do_action('AHEE__EE_System__load_espresso_addons');
284
+		//if the WP API basic auth plugin isn't already loaded, load it now.
285
+		//We want it for mobile apps. Just include the entire plugin
286
+		//also, don't load the basic auth when a plugin is getting activated, because
287
+		//it could be the basic auth plugin, and it doesn't check if its methods are already defined
288
+		//and causes a fatal error
289
+		if (
290
+			! (isset($_GET['activate']) && $_GET['activate'] === 'true')
291
+			&& ! function_exists('json_basic_auth_handler')
292
+			&& ! function_exists('json_basic_auth_error')
293
+			&& ! (
294
+				isset($_GET['action'])
295
+				&& in_array($_GET['action'], array('activate', 'activate-selected'), true)
296
+			)
297
+		) {
298
+			include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
299
+		}
300
+		do_action('AHEE__EE_System__load_espresso_addons__complete');
301
+	}
302
+
303
+
304
+
305
+	/**
306
+	 * detect_activations_or_upgrades
307
+	 * Checks for activation or upgrade of core first;
308
+	 * then also checks if any registered addons have been activated or upgraded
309
+	 * This is hooked into 'AHEE__EE_Bootstrap__detect_activations_or_upgrades'
310
+	 * which runs during the WP 'plugins_loaded' action at priority 3
311
+	 *
312
+	 * @access public
313
+	 * @return void
314
+	 */
315
+	public function detect_activations_or_upgrades()
316
+	{
317
+		//first off: let's make sure to handle core
318
+		$this->detect_if_activation_or_upgrade();
319
+		foreach ($this->registry->addons as $addon) {
320
+			//detect teh request type for that addon
321
+			$addon->detect_activation_or_upgrade();
322
+		}
323
+	}
324
+
325
+
326
+
327
+	/**
328
+	 * detect_if_activation_or_upgrade
329
+	 * Takes care of detecting whether this is a brand new install or code upgrade,
330
+	 * and either setting up the DB or setting up maintenance mode etc.
331
+	 *
332
+	 * @access public
333
+	 * @return void
334
+	 */
335
+	public function detect_if_activation_or_upgrade()
336
+	{
337
+		do_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin');
338
+		// load M-Mode class
339
+		$this->registry->load_core('Maintenance_Mode');
340
+		// check if db has been updated, or if its a brand-new installation
341
+		$espresso_db_update = $this->fix_espresso_db_upgrade_option();
342
+		$request_type = $this->detect_req_type($espresso_db_update);
343
+		//EEH_Debug_Tools::printr( $request_type, '$request_type', __FILE__, __LINE__ );
344
+		switch ($request_type) {
345
+			case EE_System::req_type_new_activation:
346
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__new_activation');
347
+				$this->_handle_core_version_change($espresso_db_update);
348
+				break;
349
+			case EE_System::req_type_reactivation:
350
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__reactivation');
351
+				$this->_handle_core_version_change($espresso_db_update);
352
+				break;
353
+			case EE_System::req_type_upgrade:
354
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__upgrade');
355
+				//migrations may be required now that we've upgraded
356
+				EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
357
+				$this->_handle_core_version_change($espresso_db_update);
358
+				//				echo "done upgrade";die;
359
+				break;
360
+			case EE_System::req_type_downgrade:
361
+				do_action('AHEE__EE_System__detect_if_activation_or_upgrade__downgrade');
362
+				//its possible migrations are no longer required
363
+				EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
364
+				$this->_handle_core_version_change($espresso_db_update);
365
+				break;
366
+			case EE_System::req_type_normal:
367
+			default:
368
+				//				$this->_maybe_redirect_to_ee_about();
369
+				break;
370
+		}
371
+		do_action('AHEE__EE_System__detect_if_activation_or_upgrade__complete');
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * Updates the list of installed versions and sets hooks for
378
+	 * initializing the database later during the request
379
+	 *
380
+	 * @param array $espresso_db_update
381
+	 */
382
+	protected function _handle_core_version_change($espresso_db_update)
383
+	{
384
+		$this->update_list_of_installed_versions($espresso_db_update);
385
+		//get ready to verify the DB is ok (provided we aren't in maintenance mode, of course)
386
+		add_action('AHEE__EE_System__perform_activations_upgrades_and_migrations',
387
+			array($this, 'initialize_db_if_no_migrations_required'));
388
+	}
389
+
390
+
391
+
392
+	/**
393
+	 * standardizes the wp option 'espresso_db_upgrade' which actually stores
394
+	 * information about what versions of EE have been installed and activated,
395
+	 * NOT necessarily the state of the database
396
+	 *
397
+	 * @param mixed $espresso_db_update the value of the WordPress option.
398
+	 *                                            If not supplied, fetches it from the options table
399
+	 * @return array the correct value of 'espresso_db_upgrade', after saving it, if it needed correction
400
+	 */
401
+	private function fix_espresso_db_upgrade_option($espresso_db_update = null)
402
+	{
403
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__begin', $espresso_db_update);
404
+		if ( ! $espresso_db_update) {
405
+			$espresso_db_update = get_option('espresso_db_update');
406
+		}
407
+		// check that option is an array
408
+		if ( ! is_array($espresso_db_update)) {
409
+			// if option is FALSE, then it never existed
410
+			if ($espresso_db_update === false) {
411
+				// make $espresso_db_update an array and save option with autoload OFF
412
+				$espresso_db_update = array();
413
+				add_option('espresso_db_update', $espresso_db_update, '', 'no');
414
+			} else {
415
+				// option is NOT FALSE but also is NOT an array, so make it an array and save it
416
+				$espresso_db_update = array($espresso_db_update => array());
417
+				update_option('espresso_db_update', $espresso_db_update);
418
+			}
419
+		} else {
420
+			$corrected_db_update = array();
421
+			//if IS an array, but is it an array where KEYS are version numbers, and values are arrays?
422
+			foreach ($espresso_db_update as $should_be_version_string => $should_be_array) {
423
+				if (is_int($should_be_version_string) && ! is_array($should_be_array)) {
424
+					//the key is an int, and the value IS NOT an array
425
+					//so it must be numerically-indexed, where values are versions installed...
426
+					//fix it!
427
+					$version_string = $should_be_array;
428
+					$corrected_db_update[$version_string] = array('unknown-date');
429
+				} else {
430
+					//ok it checks out
431
+					$corrected_db_update[$should_be_version_string] = $should_be_array;
432
+				}
433
+			}
434
+			$espresso_db_update = $corrected_db_update;
435
+			update_option('espresso_db_update', $espresso_db_update);
436
+		}
437
+		do_action('FHEE__EE_System__manage_fix_espresso_db_upgrade_option__complete', $espresso_db_update);
438
+		return $espresso_db_update;
439
+	}
440
+
441
+
442
+
443
+	/**
444
+	 * Does the traditional work of setting up the plugin's database and adding default data.
445
+	 * If migration script/process did not exist, this is what would happen on every activation/reactivation/upgrade.
446
+	 * NOTE: if we're in maintenance mode (which would be the case if we detect there are data
447
+	 * migration scripts that need to be run and a version change happens), enqueues core for database initialization,
448
+	 * so that it will be done when migrations are finished
449
+	 *
450
+	 * @param boolean $initialize_addons_too if true, we double-check addons' database tables etc too;
451
+	 * @param boolean $verify_schema         if true will re-check the database tables have the correct schema.
452
+	 *                                       This is a resource-intensive job
453
+	 *                                       so we prefer to only do it when necessary
454
+	 * @return void
455
+	 * @throws EE_Error
456
+	 */
457
+	public function initialize_db_if_no_migrations_required($initialize_addons_too = false, $verify_schema = true)
458
+	{
459
+		$request_type = $this->detect_req_type();
460
+		//only initialize system if we're not in maintenance mode.
461
+		if (EE_Maintenance_Mode::instance()->level() !== EE_Maintenance_Mode::level_2_complete_maintenance) {
462
+			update_option('ee_flush_rewrite_rules', true);
463
+			if ($verify_schema) {
464
+				EEH_Activation::initialize_db_and_folders();
465
+			}
466
+			EEH_Activation::initialize_db_content();
467
+			EEH_Activation::system_initialization();
468
+			if ($initialize_addons_too) {
469
+				$this->initialize_addons();
470
+			}
471
+		} else {
472
+			EE_Data_Migration_Manager::instance()->enqueue_db_initialization_for('Core');
473
+		}
474
+		if ($request_type === EE_System::req_type_new_activation
475
+			|| $request_type === EE_System::req_type_reactivation
476
+			|| (
477
+				$request_type === EE_System::req_type_upgrade
478
+				&& $this->is_major_version_change()
479
+			)
480
+		) {
481
+			add_action('AHEE__EE_System__initialize_last', array($this, 'redirect_to_about_ee'), 9);
482
+		}
483
+	}
484
+
485
+
486
+
487
+	/**
488
+	 * Initializes the db for all registered addons
489
+	 *
490
+	 * @throws EE_Error
491
+	 */
492
+	public function initialize_addons()
493
+	{
494
+		//foreach registered addon, make sure its db is up-to-date too
495
+		foreach ($this->registry->addons as $addon) {
496
+			$addon->initialize_db_if_no_migrations_required();
497
+		}
498
+	}
499
+
500
+
501
+
502
+	/**
503
+	 * Adds the current code version to the saved wp option which stores a list of all ee versions ever installed.
504
+	 *
505
+	 * @param    array  $version_history
506
+	 * @param    string $current_version_to_add version to be added to the version history
507
+	 * @return    boolean success as to whether or not this option was changed
508
+	 */
509
+	public function update_list_of_installed_versions($version_history = null, $current_version_to_add = null)
510
+	{
511
+		if ( ! $version_history) {
512
+			$version_history = $this->fix_espresso_db_upgrade_option($version_history);
513
+		}
514
+		if ($current_version_to_add === null) {
515
+			$current_version_to_add = espresso_version();
516
+		}
517
+		$version_history[$current_version_to_add][] = date('Y-m-d H:i:s', time());
518
+		// re-save
519
+		return update_option('espresso_db_update', $version_history);
520
+	}
521
+
522
+
523
+
524
+	/**
525
+	 * Detects if the current version indicated in the has existed in the list of
526
+	 * previously-installed versions of EE (espresso_db_update). Does NOT modify it (ie, no side-effect)
527
+	 *
528
+	 * @param array $espresso_db_update array from the wp option stored under the name 'espresso_db_update'.
529
+	 *                                  If not supplied, fetches it from the options table.
530
+	 *                                  Also, caches its result so later parts of the code can also know whether
531
+	 *                                  there's been an update or not. This way we can add the current version to
532
+	 *                                  espresso_db_update, but still know if this is a new install or not
533
+	 * @return int one of the constants on EE_System::req_type_
534
+	 */
535
+	public function detect_req_type($espresso_db_update = null)
536
+	{
537
+		if ($this->_req_type === null) {
538
+			$espresso_db_update = ! empty($espresso_db_update) ? $espresso_db_update
539
+				: $this->fix_espresso_db_upgrade_option();
540
+			$this->_req_type = EE_System::detect_req_type_given_activation_history($espresso_db_update,
541
+				'ee_espresso_activation', espresso_version());
542
+			$this->_major_version_change = $this->_detect_major_version_change($espresso_db_update);
543
+		}
544
+		return $this->_req_type;
545
+	}
546
+
547
+
548
+
549
+	/**
550
+	 * Returns whether or not there was a non-micro version change (ie, change in either
551
+	 * the first or second number in the version. Eg 4.9.0.rc.001 to 4.10.0.rc.000,
552
+	 * but not 4.9.0.rc.0001 to 4.9.1.rc.0001
553
+	 *
554
+	 * @param $activation_history
555
+	 * @return bool
556
+	 */
557
+	protected function _detect_major_version_change($activation_history)
558
+	{
559
+		$previous_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history);
560
+		$previous_version_parts = explode('.', $previous_version);
561
+		$current_version_parts = explode('.', espresso_version());
562
+		return isset($previous_version_parts[0], $previous_version_parts[1], $current_version_parts[0], $current_version_parts[1])
563
+			   && ($previous_version_parts[0] !== $current_version_parts[0]
564
+				   || $previous_version_parts[1] !== $current_version_parts[1]
565
+			   );
566
+	}
567
+
568
+
569
+
570
+	/**
571
+	 * Returns true if either the major or minor version of EE changed during this request.
572
+	 * 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
573
+	 *
574
+	 * @return bool
575
+	 */
576
+	public function is_major_version_change()
577
+	{
578
+		return $this->_major_version_change;
579
+	}
580
+
581
+
582
+
583
+	/**
584
+	 * Determines the request type for any ee addon, given three piece of info: the current array of activation
585
+	 * histories (for core that' 'espresso_db_update' wp option); the name of the WordPress option which is temporarily
586
+	 * set upon activation of the plugin (for core it's 'ee_espresso_activation'); and the version that this plugin was
587
+	 * just activated to (for core that will always be espresso_version())
588
+	 *
589
+	 * @param array  $activation_history_for_addon     the option's value which stores the activation history for this
590
+	 *                                                 ee plugin. for core that's 'espresso_db_update'
591
+	 * @param string $activation_indicator_option_name the name of the WordPress option that is temporarily set to
592
+	 *                                                 indicate that this plugin was just activated
593
+	 * @param string $version_to_upgrade_to            the version that was just upgraded to (for core that will be
594
+	 *                                                 espresso_version())
595
+	 * @return int one of the constants on EE_System::req_type_*
596
+	 */
597
+	public static function detect_req_type_given_activation_history(
598
+		$activation_history_for_addon,
599
+		$activation_indicator_option_name,
600
+		$version_to_upgrade_to
601
+	) {
602
+		$version_is_higher = self::_new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to);
603
+		if ($activation_history_for_addon) {
604
+			//it exists, so this isn't a completely new install
605
+			//check if this version already in that list of previously installed versions
606
+			if ( ! isset($activation_history_for_addon[$version_to_upgrade_to])) {
607
+				//it a version we haven't seen before
608
+				if ($version_is_higher === 1) {
609
+					$req_type = EE_System::req_type_upgrade;
610
+				} else {
611
+					$req_type = EE_System::req_type_downgrade;
612
+				}
613
+				delete_option($activation_indicator_option_name);
614
+			} else {
615
+				// its not an update. maybe a reactivation?
616
+				if (get_option($activation_indicator_option_name, false)) {
617
+					if ($version_is_higher === -1) {
618
+						$req_type = EE_System::req_type_downgrade;
619
+					} elseif ($version_is_higher === 0) {
620
+						//we've seen this version before, but it's an activation. must be a reactivation
621
+						$req_type = EE_System::req_type_reactivation;
622
+					} else {//$version_is_higher === 1
623
+						$req_type = EE_System::req_type_upgrade;
624
+					}
625
+					delete_option($activation_indicator_option_name);
626
+				} else {
627
+					//we've seen this version before and the activation indicate doesn't show it was just activated
628
+					if ($version_is_higher === -1) {
629
+						$req_type = EE_System::req_type_downgrade;
630
+					} elseif ($version_is_higher === 0) {
631
+						//we've seen this version before and it's not an activation. its normal request
632
+						$req_type = EE_System::req_type_normal;
633
+					} else {//$version_is_higher === 1
634
+						$req_type = EE_System::req_type_upgrade;
635
+					}
636
+				}
637
+			}
638
+		} else {
639
+			//brand new install
640
+			$req_type = EE_System::req_type_new_activation;
641
+			delete_option($activation_indicator_option_name);
642
+		}
643
+		return $req_type;
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * Detects if the $version_to_upgrade_to is higher than the most recent version in
650
+	 * the $activation_history_for_addon
651
+	 *
652
+	 * @param array  $activation_history_for_addon (keys are versions, values are arrays of times activated,
653
+	 *                                             sometimes containing 'unknown-date'
654
+	 * @param string $version_to_upgrade_to        (current version)
655
+	 * @return int results of version_compare( $version_to_upgrade_to, $most_recently_active_version ).
656
+	 *                                             ie, -1 if $version_to_upgrade_to is LOWER (downgrade);
657
+	 *                                             0 if $version_to_upgrade_to MATCHES (reactivation or normal request);
658
+	 *                                             1 if $version_to_upgrade_to is HIGHER (upgrade) ;
659
+	 */
660
+	protected static function _new_version_is_higher($activation_history_for_addon, $version_to_upgrade_to)
661
+	{
662
+		//find the most recently-activated version
663
+		$most_recently_active_version = EE_System::_get_most_recently_active_version_from_activation_history($activation_history_for_addon);
664
+		return version_compare($version_to_upgrade_to, $most_recently_active_version);
665
+	}
666
+
667
+
668
+
669
+	/**
670
+	 * Gets the most recently active version listed in the activation history,
671
+	 * and if none are found (ie, it's a brand new install) returns '0.0.0.dev.000'.
672
+	 *
673
+	 * @param array $activation_history  (keys are versions, values are arrays of times activated,
674
+	 *                                   sometimes containing 'unknown-date'
675
+	 * @return string
676
+	 */
677
+	protected static function _get_most_recently_active_version_from_activation_history($activation_history)
678
+	{
679
+		$most_recently_active_version_activation = '1970-01-01 00:00:00';
680
+		$most_recently_active_version = '0.0.0.dev.000';
681
+		if (is_array($activation_history)) {
682
+			foreach ($activation_history as $version => $times_activated) {
683
+				//check there is a record of when this version was activated. Otherwise,
684
+				//mark it as unknown
685
+				if ( ! $times_activated) {
686
+					$times_activated = array('unknown-date');
687
+				}
688
+				if (is_string($times_activated)) {
689
+					$times_activated = array($times_activated);
690
+				}
691
+				foreach ($times_activated as $an_activation) {
692
+					if ($an_activation !== 'unknown-date' && $an_activation > $most_recently_active_version_activation) {
693
+						$most_recently_active_version = $version;
694
+						$most_recently_active_version_activation = $an_activation === 'unknown-date'
695
+							? '1970-01-01 00:00:00' : $an_activation;
696
+					}
697
+				}
698
+			}
699
+		}
700
+		return $most_recently_active_version;
701
+	}
702
+
703
+
704
+
705
+	/**
706
+	 * This redirects to the about EE page after activation
707
+	 *
708
+	 * @return void
709
+	 */
710
+	public function redirect_to_about_ee()
711
+	{
712
+		$notices = EE_Error::get_notices(false);
713
+		//if current user is an admin and it's not an ajax or rest request
714
+		if (
715
+			! (defined('DOING_AJAX') && DOING_AJAX)
716
+			&& ! (defined('REST_REQUEST') && REST_REQUEST)
717
+			&& ! isset($notices['errors'])
718
+			&& apply_filters(
719
+				'FHEE__EE_System__redirect_to_about_ee__do_redirect',
720
+				$this->registry->CAP->current_user_can('manage_options', 'espresso_about_default')
721
+			)
722
+		) {
723
+			$query_params = array('page' => 'espresso_about');
724
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_new_activation) {
725
+				$query_params['new_activation'] = true;
726
+			}
727
+			if (EE_System::instance()->detect_req_type() === EE_System::req_type_reactivation) {
728
+				$query_params['reactivation'] = true;
729
+			}
730
+			$url = add_query_arg($query_params, admin_url('admin.php'));
731
+			wp_safe_redirect($url);
732
+			exit();
733
+		}
734
+	}
735
+
736
+
737
+
738
+	/**
739
+	 * load_core_configuration
740
+	 * this is hooked into 'AHEE__EE_Bootstrap__load_core_configuration'
741
+	 * which runs during the WP 'plugins_loaded' action at priority 5
742
+	 *
743
+	 * @return void
744
+	 * @throws \ReflectionException
745
+	 */
746
+	public function load_core_configuration()
747
+	{
748
+		do_action('AHEE__EE_System__load_core_configuration__begin', $this);
749
+		$this->registry->load_core('EE_Load_Textdomain');
750
+		//load textdomain
751
+		EE_Load_Textdomain::load_textdomain();
752
+		// load and setup EE_Config and EE_Network_Config
753
+		$this->registry->load_core('Config');
754
+		$this->registry->load_core('Network_Config');
755
+		// setup autoloaders
756
+		// enable logging?
757
+		if ($this->registry->CFG->admin->use_full_logging) {
758
+			$this->registry->load_core('Log');
759
+		}
760
+		// check for activation errors
761
+		$activation_errors = get_option('ee_plugin_activation_errors', false);
762
+		if ($activation_errors) {
763
+			EE_Error::add_error($activation_errors, __FILE__, __FUNCTION__, __LINE__);
764
+			update_option('ee_plugin_activation_errors', false);
765
+		}
766
+		// get model names
767
+		$this->_parse_model_names();
768
+		//load caf stuff a chance to play during the activation process too.
769
+		$this->_maybe_brew_regular();
770
+		do_action('AHEE__EE_System__load_core_configuration__complete', $this);
771
+	}
772
+
773
+
774
+
775
+	/**
776
+	 * cycles through all of the models/*.model.php files, and assembles an array of model names
777
+	 *
778
+	 * @return void
779
+	 * @throws ReflectionException
780
+	 */
781
+	private function _parse_model_names()
782
+	{
783
+		//get all the files in the EE_MODELS folder that end in .model.php
784
+		$models = glob(EE_MODELS . '*.model.php');
785
+		$model_names = array();
786
+		$non_abstract_db_models = array();
787
+		foreach ($models as $model) {
788
+			// get model classname
789
+			$classname = EEH_File::get_classname_from_filepath_with_standard_filename($model);
790
+			$short_name = str_replace('EEM_', '', $classname);
791
+			$reflectionClass = new ReflectionClass($classname);
792
+			if ($reflectionClass->isSubclassOf('EEM_Base') && ! $reflectionClass->isAbstract()) {
793
+				$non_abstract_db_models[$short_name] = $classname;
794
+			}
795
+			$model_names[$short_name] = $classname;
796
+		}
797
+		$this->registry->models = apply_filters('FHEE__EE_System__parse_model_names', $model_names);
798
+		$this->registry->non_abstract_db_models = apply_filters('FHEE__EE_System__parse_implemented_model_names',
799
+			$non_abstract_db_models);
800
+	}
801
+
802
+
803
+
804
+	/**
805
+	 * The purpose of this method is to simply check for a file named "caffeinated/brewing_regular.php" for any hooks
806
+	 * that need to be setup before our EE_System launches.
807
+	 *
808
+	 * @return void
809
+	 */
810
+	private function _maybe_brew_regular()
811
+	{
812
+		if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
813
+			require_once EE_CAFF_PATH . 'brewing_regular.php';
814
+		}
815
+	}
816
+
817
+
818
+
819
+	/**
820
+	 * register_shortcodes_modules_and_widgets
821
+	 * generate lists of shortcodes and modules, then verify paths and classes
822
+	 * This is hooked into 'AHEE__EE_Bootstrap__register_shortcodes_modules_and_widgets'
823
+	 * which runs during the WP 'plugins_loaded' action at priority 7
824
+	 *
825
+	 * @access public
826
+	 * @return void
827
+	 */
828
+	public function register_shortcodes_modules_and_widgets()
829
+	{
830
+		try {
831
+			// load, register, and add shortcodes the new way
832
+			new ShortcodesManager(
833
+			// and the old way, but we'll put it under control of the new system
834
+				EE_Config::getLegacyShortcodesManager()
835
+			);
836
+		} catch (Exception $exception) {
837
+			new ExceptionStackTraceDisplay($exception);
838
+		}
839
+		do_action('AHEE__EE_System__register_shortcodes_modules_and_widgets');
840
+		// check for addons using old hook point
841
+		if (has_action('AHEE__EE_System__register_shortcodes_modules_and_addons')) {
842
+			$this->_incompatible_addon_error();
843
+		}
844
+	}
845
+
846
+
847
+
848
+	/**
849
+	 * _incompatible_addon_error
850
+	 *
851
+	 * @access public
852
+	 * @return void
853
+	 */
854
+	private function _incompatible_addon_error()
855
+	{
856
+		// get array of classes hooking into here
857
+		$class_names = EEH_Class_Tools::get_class_names_for_all_callbacks_on_hook('AHEE__EE_System__register_shortcodes_modules_and_addons');
858
+		if ( ! empty($class_names)) {
859
+			$msg = __('The following plugins, addons, or modules appear to be incompatible with this version of Event Espresso and were automatically deactivated to avoid fatal errors:',
860
+				'event_espresso');
861
+			$msg .= '<ul>';
862
+			foreach ($class_names as $class_name) {
863
+				$msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
864
+						$class_name) . '</b></li>';
865
+			}
866
+			$msg .= '</ul>';
867
+			$msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
868
+				'event_espresso');
869
+			// save list of incompatible addons to wp-options for later use
870
+			add_option('ee_incompatible_addons', $class_names, '', 'no');
871
+			if (is_admin()) {
872
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
873
+			}
874
+		}
875
+	}
876
+
877
+
878
+
879
+	/**
880
+	 * brew_espresso
881
+	 * begins the process of setting hooks for initializing EE in the correct order
882
+	 * This is happening on the 'AHEE__EE_Bootstrap__brew_espresso' hook point
883
+	 * which runs during the WP 'plugins_loaded' action at priority 9
884
+	 *
885
+	 * @return void
886
+	 */
887
+	public function brew_espresso()
888
+	{
889
+		do_action('AHEE__EE_System__brew_espresso__begin', $this);
890
+		// load some final core systems
891
+		add_action('init', array($this, 'set_hooks_for_core'), 1);
892
+		add_action('init', array($this, 'perform_activations_upgrades_and_migrations'), 3);
893
+		add_action('init', array($this, 'load_CPTs_and_session'), 5);
894
+		add_action('init', array($this, 'load_controllers'), 7);
895
+		add_action('init', array($this, 'core_loaded_and_ready'), 9);
896
+		add_action('init', array($this, 'initialize'), 10);
897
+		add_action('init', array($this, 'initialize_last'), 100);
898
+		add_action('admin_bar_menu', array($this, 'espresso_toolbar_items'), 100);
899
+		if (is_admin() && apply_filters('FHEE__EE_System__brew_espresso__load_pue', true)) {
900
+			// pew pew pew
901
+			$this->registry->load_core('PUE');
902
+			do_action('AHEE__EE_System__brew_espresso__after_pue_init');
903
+		}
904
+		do_action('AHEE__EE_System__brew_espresso__complete', $this);
905
+	}
906
+
907
+
908
+
909
+	/**
910
+	 *    set_hooks_for_core
911
+	 *
912
+	 * @access public
913
+	 * @return    void
914
+	 * @throws EE_Error
915
+	 */
916
+	public function set_hooks_for_core()
917
+	{
918
+		$this->_deactivate_incompatible_addons();
919
+		do_action('AHEE__EE_System__set_hooks_for_core');
920
+		//caps need to be initialized on every request so that capability maps are set.
921
+		//@see https://events.codebasehq.com/projects/event-espresso/tickets/8674
922
+		$this->registry->CAP->init_caps();
923
+	}
924
+
925
+
926
+
927
+	/**
928
+	 * Using the information gathered in EE_System::_incompatible_addon_error,
929
+	 * deactivates any addons considered incompatible with the current version of EE
930
+	 */
931
+	private function _deactivate_incompatible_addons()
932
+	{
933
+		$incompatible_addons = get_option('ee_incompatible_addons', array());
934
+		if ( ! empty($incompatible_addons)) {
935
+			$active_plugins = get_option('active_plugins', array());
936
+			foreach ($active_plugins as $active_plugin) {
937
+				foreach ($incompatible_addons as $incompatible_addon) {
938
+					if (strpos($active_plugin, $incompatible_addon) !== false) {
939
+						unset($_GET['activate']);
940
+						espresso_deactivate_plugin($active_plugin);
941
+					}
942
+				}
943
+			}
944
+		}
945
+	}
946
+
947
+
948
+
949
+	/**
950
+	 *    perform_activations_upgrades_and_migrations
951
+	 *
952
+	 * @access public
953
+	 * @return    void
954
+	 */
955
+	public function perform_activations_upgrades_and_migrations()
956
+	{
957
+		//first check if we had previously attempted to setup EE's directories but failed
958
+		if (EEH_Activation::upload_directories_incomplete()) {
959
+			EEH_Activation::create_upload_directories();
960
+		}
961
+		do_action('AHEE__EE_System__perform_activations_upgrades_and_migrations');
962
+	}
963
+
964
+
965
+
966
+	/**
967
+	 *    load_CPTs_and_session
968
+	 *
969
+	 * @access public
970
+	 * @return    void
971
+	 */
972
+	public function load_CPTs_and_session()
973
+	{
974
+		do_action('AHEE__EE_System__load_CPTs_and_session__start');
975
+		// register Custom Post Types
976
+		$this->registry->load_core('Register_CPTs');
977
+		do_action('AHEE__EE_System__load_CPTs_and_session__complete');
978
+	}
979
+
980
+
981
+
982
+	/**
983
+	 * load_controllers
984
+	 * this is the best place to load any additional controllers that needs access to EE core.
985
+	 * it is expected that all basic core EE systems, that are not dependant on the current request are loaded at this
986
+	 * time
987
+	 *
988
+	 * @access public
989
+	 * @return void
990
+	 */
991
+	public function load_controllers()
992
+	{
993
+		do_action('AHEE__EE_System__load_controllers__start');
994
+		// let's get it started
995
+		if ( ! is_admin() && ! EE_Maintenance_Mode::instance()->level()) {
996
+			do_action('AHEE__EE_System__load_controllers__load_front_controllers');
997
+			$this->registry->load_core('Front_Controller');
998
+		} else if ( ! EE_FRONT_AJAX) {
999
+			do_action('AHEE__EE_System__load_controllers__load_admin_controllers');
1000
+			EE_Registry::instance()->load_core('Admin');
1001
+		}
1002
+		do_action('AHEE__EE_System__load_controllers__complete');
1003
+	}
1004
+
1005
+
1006
+
1007
+	/**
1008
+	 * core_loaded_and_ready
1009
+	 * all of the basic EE core should be loaded at this point and available regardless of M-Mode
1010
+	 *
1011
+	 * @access public
1012
+	 * @return void
1013
+	 */
1014
+	public function core_loaded_and_ready()
1015
+	{
1016
+		$this->registry->load_core('Session');
1017
+		do_action('AHEE__EE_System__core_loaded_and_ready');
1018
+		// load_espresso_template_tags
1019
+		if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1020
+			require_once(EE_PUBLIC . 'template_tags.php');
1021
+		}
1022
+		do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1023
+		$this->registry->create('EventEspresso\core\services\assets\Registry', array(), true);
1024
+	}
1025
+
1026
+
1027
+
1028
+	/**
1029
+	 * initialize
1030
+	 * this is the best place to begin initializing client code
1031
+	 *
1032
+	 * @access public
1033
+	 * @return void
1034
+	 */
1035
+	public function initialize()
1036
+	{
1037
+		do_action('AHEE__EE_System__initialize');
1038
+	}
1039
+
1040
+
1041
+
1042
+	/**
1043
+	 * initialize_last
1044
+	 * this is run really late during the WP init hook point, and ensures that mostly everything else that needs to
1045
+	 * initialize has done so
1046
+	 *
1047
+	 * @access public
1048
+	 * @return void
1049
+	 */
1050
+	public function initialize_last()
1051
+	{
1052
+		do_action('AHEE__EE_System__initialize_last');
1053
+	}
1054
+
1055
+
1056
+
1057
+	/**
1058
+	 * set_hooks_for_shortcodes_modules_and_addons
1059
+	 * this is the best place for other systems to set callbacks for hooking into other parts of EE
1060
+	 * this happens at the very beginning of the wp_loaded hook point
1061
+	 *
1062
+	 * @access public
1063
+	 * @return void
1064
+	 */
1065
+	public function set_hooks_for_shortcodes_modules_and_addons()
1066
+	{
1067
+		//		do_action( 'AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons' );
1068
+	}
1069
+
1070
+
1071
+
1072
+	/**
1073
+	 * do_not_cache
1074
+	 * sets no cache headers and defines no cache constants for WP plugins
1075
+	 *
1076
+	 * @access public
1077
+	 * @return void
1078
+	 */
1079
+	public static function do_not_cache()
1080
+	{
1081
+		// set no cache constants
1082
+		if ( ! defined('DONOTCACHEPAGE')) {
1083
+			define('DONOTCACHEPAGE', true);
1084
+		}
1085
+		if ( ! defined('DONOTCACHCEOBJECT')) {
1086
+			define('DONOTCACHCEOBJECT', true);
1087
+		}
1088
+		if ( ! defined('DONOTCACHEDB')) {
1089
+			define('DONOTCACHEDB', true);
1090
+		}
1091
+		// add no cache headers
1092
+		add_action('send_headers', array('EE_System', 'nocache_headers'), 10);
1093
+		// plus a little extra for nginx and Google Chrome
1094
+		add_filter('nocache_headers', array('EE_System', 'extra_nocache_headers'), 10, 1);
1095
+		// prevent browsers from prefetching of the rel='next' link, because it may contain content that interferes with the registration process
1096
+		remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');
1097
+	}
1098
+
1099
+
1100
+
1101
+	/**
1102
+	 *    extra_nocache_headers
1103
+	 *
1104
+	 * @access    public
1105
+	 * @param $headers
1106
+	 * @return    array
1107
+	 */
1108
+	public static function extra_nocache_headers($headers)
1109
+	{
1110
+		// for NGINX
1111
+		$headers['X-Accel-Expires'] = 0;
1112
+		// plus extra for Google Chrome since it doesn't seem to respect "no-cache", but WILL respect "no-store"
1113
+		$headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, max-age=0';
1114
+		return $headers;
1115
+	}
1116
+
1117
+
1118
+
1119
+	/**
1120
+	 *    nocache_headers
1121
+	 *
1122
+	 * @access    public
1123
+	 * @return    void
1124
+	 */
1125
+	public static function nocache_headers()
1126
+	{
1127
+		nocache_headers();
1128
+	}
1129
+
1130
+
1131
+
1132
+	/**
1133
+	 *    espresso_toolbar_items
1134
+	 *
1135
+	 * @access public
1136
+	 * @param  WP_Admin_Bar $admin_bar
1137
+	 * @return void
1138
+	 */
1139
+	public function espresso_toolbar_items(WP_Admin_Bar $admin_bar)
1140
+	{
1141
+		// if in full M-Mode, or its an AJAX request, or user is NOT an admin
1142
+		if (
1143
+			defined('DOING_AJAX')
1144
+			|| ! $this->registry->CAP->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level')
1145
+			|| EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance
1146
+		) {
1147
+			return;
1148
+		}
1149
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1150
+		$menu_class = 'espresso_menu_item_class';
1151
+		//we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL
1152
+		//because they're only defined in each of their respective constructors
1153
+		//and this might be a frontend request, in which case they aren't available
1154
+		$events_admin_url = admin_url('admin.php?page=espresso_events');
1155
+		$reg_admin_url = admin_url('admin.php?page=espresso_registrations');
1156
+		$extensions_admin_url = admin_url('admin.php?page=espresso_packages');
1157
+		//Top Level
1158
+		$admin_bar->add_menu(array(
1159
+			'id'    => 'espresso-toolbar',
1160
+			'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">'
1161
+					   . _x('Event Espresso', 'admin bar menu group label', 'event_espresso')
1162
+					   . '</span>',
1163
+			'href'  => $events_admin_url,
1164
+			'meta'  => array(
1165
+				'title' => __('Event Espresso', 'event_espresso'),
1166
+				'class' => $menu_class . 'first',
1167
+			),
1168
+		));
1169
+		//Events
1170
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events')) {
1171
+			$admin_bar->add_menu(array(
1172
+				'id'     => 'espresso-toolbar-events',
1173
+				'parent' => 'espresso-toolbar',
1174
+				'title'  => __('Events', 'event_espresso'),
1175
+				'href'   => $events_admin_url,
1176
+				'meta'   => array(
1177
+					'title'  => __('Events', 'event_espresso'),
1178
+					'target' => '',
1179
+					'class'  => $menu_class,
1180
+				),
1181
+			));
1182
+		}
1183
+		if ($this->registry->CAP->current_user_can('ee_edit_events', 'ee_admin_bar_menu_espresso-toolbar-events-new')) {
1184
+			//Events Add New
1185
+			$admin_bar->add_menu(array(
1186
+				'id'     => 'espresso-toolbar-events-new',
1187
+				'parent' => 'espresso-toolbar-events',
1188
+				'title'  => __('Add New', 'event_espresso'),
1189
+				'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'create_new'), $events_admin_url),
1190
+				'meta'   => array(
1191
+					'title'  => __('Add New', 'event_espresso'),
1192
+					'target' => '',
1193
+					'class'  => $menu_class,
1194
+				),
1195
+			));
1196
+		}
1197
+		if (is_single() && (get_post_type() === 'espresso_events')) {
1198
+			//Current post
1199
+			global $post;
1200
+			if ($this->registry->CAP->current_user_can('ee_edit_event',
1201
+				'ee_admin_bar_menu_espresso-toolbar-events-edit', $post->ID)
1202
+			) {
1203
+				//Events Edit Current Event
1204
+				$admin_bar->add_menu(array(
1205
+					'id'     => 'espresso-toolbar-events-edit',
1206
+					'parent' => 'espresso-toolbar-events',
1207
+					'title'  => __('Edit Event', 'event_espresso'),
1208
+					'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'edit', 'post' => $post->ID),
1209
+						$events_admin_url),
1210
+					'meta'   => array(
1211
+						'title'  => __('Edit Event', 'event_espresso'),
1212
+						'target' => '',
1213
+						'class'  => $menu_class,
1214
+					),
1215
+				));
1216
+			}
1217
+		}
1218
+		//Events View
1219
+		if ($this->registry->CAP->current_user_can('ee_read_events',
1220
+			'ee_admin_bar_menu_espresso-toolbar-events-view')
1221
+		) {
1222
+			$admin_bar->add_menu(array(
1223
+				'id'     => 'espresso-toolbar-events-view',
1224
+				'parent' => 'espresso-toolbar-events',
1225
+				'title'  => __('View', 'event_espresso'),
1226
+				'href'   => $events_admin_url,
1227
+				'meta'   => array(
1228
+					'title'  => __('View', 'event_espresso'),
1229
+					'target' => '',
1230
+					'class'  => $menu_class,
1231
+				),
1232
+			));
1233
+		}
1234
+		if ($this->registry->CAP->current_user_can('ee_read_events', 'ee_admin_bar_menu_espresso-toolbar-events-all')) {
1235
+			//Events View All
1236
+			$admin_bar->add_menu(array(
1237
+				'id'     => 'espresso-toolbar-events-all',
1238
+				'parent' => 'espresso-toolbar-events-view',
1239
+				'title'  => __('All', 'event_espresso'),
1240
+				'href'   => $events_admin_url,
1241
+				'meta'   => array(
1242
+					'title'  => __('All', 'event_espresso'),
1243
+					'target' => '',
1244
+					'class'  => $menu_class,
1245
+				),
1246
+			));
1247
+		}
1248
+		if ($this->registry->CAP->current_user_can('ee_read_events',
1249
+			'ee_admin_bar_menu_espresso-toolbar-events-today')
1250
+		) {
1251
+			//Events View Today
1252
+			$admin_bar->add_menu(array(
1253
+				'id'     => 'espresso-toolbar-events-today',
1254
+				'parent' => 'espresso-toolbar-events-view',
1255
+				'title'  => __('Today', 'event_espresso'),
1256
+				'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'),
1257
+					$events_admin_url),
1258
+				'meta'   => array(
1259
+					'title'  => __('Today', 'event_espresso'),
1260
+					'target' => '',
1261
+					'class'  => $menu_class,
1262
+				),
1263
+			));
1264
+		}
1265
+		if ($this->registry->CAP->current_user_can('ee_read_events',
1266
+			'ee_admin_bar_menu_espresso-toolbar-events-month')
1267
+		) {
1268
+			//Events View This Month
1269
+			$admin_bar->add_menu(array(
1270
+				'id'     => 'espresso-toolbar-events-month',
1271
+				'parent' => 'espresso-toolbar-events-view',
1272
+				'title'  => __('This Month', 'event_espresso'),
1273
+				'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'),
1274
+					$events_admin_url),
1275
+				'meta'   => array(
1276
+					'title'  => __('This Month', 'event_espresso'),
1277
+					'target' => '',
1278
+					'class'  => $menu_class,
1279
+				),
1280
+			));
1281
+		}
1282
+		//Registration Overview
1283
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1284
+			'ee_admin_bar_menu_espresso-toolbar-registrations')
1285
+		) {
1286
+			$admin_bar->add_menu(array(
1287
+				'id'     => 'espresso-toolbar-registrations',
1288
+				'parent' => 'espresso-toolbar',
1289
+				'title'  => __('Registrations', 'event_espresso'),
1290
+				'href'   => $reg_admin_url,
1291
+				'meta'   => array(
1292
+					'title'  => __('Registrations', 'event_espresso'),
1293
+					'target' => '',
1294
+					'class'  => $menu_class,
1295
+				),
1296
+			));
1297
+		}
1298
+		//Registration Overview Today
1299
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1300
+			'ee_admin_bar_menu_espresso-toolbar-registrations-today')
1301
+		) {
1302
+			$admin_bar->add_menu(array(
1303
+				'id'     => 'espresso-toolbar-registrations-today',
1304
+				'parent' => 'espresso-toolbar-registrations',
1305
+				'title'  => __('Today', 'event_espresso'),
1306
+				'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'today'),
1307
+					$reg_admin_url),
1308
+				'meta'   => array(
1309
+					'title'  => __('Today', 'event_espresso'),
1310
+					'target' => '',
1311
+					'class'  => $menu_class,
1312
+				),
1313
+			));
1314
+		}
1315
+		//Registration Overview Today Completed
1316
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1317
+			'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved')
1318
+		) {
1319
+			$admin_bar->add_menu(array(
1320
+				'id'     => 'espresso-toolbar-registrations-today-approved',
1321
+				'parent' => 'espresso-toolbar-registrations-today',
1322
+				'title'  => __('Approved', 'event_espresso'),
1323
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1324
+					'action'      => 'default',
1325
+					'status'      => 'today',
1326
+					'_reg_status' => EEM_Registration::status_id_approved,
1327
+				), $reg_admin_url),
1328
+				'meta'   => array(
1329
+					'title'  => __('Approved', 'event_espresso'),
1330
+					'target' => '',
1331
+					'class'  => $menu_class,
1332
+				),
1333
+			));
1334
+		}
1335
+		//Registration Overview Today Pending\
1336
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1337
+			'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending')
1338
+		) {
1339
+			$admin_bar->add_menu(array(
1340
+				'id'     => 'espresso-toolbar-registrations-today-pending',
1341
+				'parent' => 'espresso-toolbar-registrations-today',
1342
+				'title'  => __('Pending', 'event_espresso'),
1343
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1344
+					'action'     => 'default',
1345
+					'status'     => 'today',
1346
+					'reg_status' => EEM_Registration::status_id_pending_payment,
1347
+				), $reg_admin_url),
1348
+				'meta'   => array(
1349
+					'title'  => __('Pending Payment', 'event_espresso'),
1350
+					'target' => '',
1351
+					'class'  => $menu_class,
1352
+				),
1353
+			));
1354
+		}
1355
+		//Registration Overview Today Incomplete
1356
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1357
+			'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved')
1358
+		) {
1359
+			$admin_bar->add_menu(array(
1360
+				'id'     => 'espresso-toolbar-registrations-today-not-approved',
1361
+				'parent' => 'espresso-toolbar-registrations-today',
1362
+				'title'  => __('Not Approved', 'event_espresso'),
1363
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1364
+					'action'      => 'default',
1365
+					'status'      => 'today',
1366
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1367
+				), $reg_admin_url),
1368
+				'meta'   => array(
1369
+					'title'  => __('Not Approved', 'event_espresso'),
1370
+					'target' => '',
1371
+					'class'  => $menu_class,
1372
+				),
1373
+			));
1374
+		}
1375
+		//Registration Overview Today Incomplete
1376
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1377
+			'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled')
1378
+		) {
1379
+			$admin_bar->add_menu(array(
1380
+				'id'     => 'espresso-toolbar-registrations-today-cancelled',
1381
+				'parent' => 'espresso-toolbar-registrations-today',
1382
+				'title'  => __('Cancelled', 'event_espresso'),
1383
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1384
+					'action'      => 'default',
1385
+					'status'      => 'today',
1386
+					'_reg_status' => EEM_Registration::status_id_cancelled,
1387
+				), $reg_admin_url),
1388
+				'meta'   => array(
1389
+					'title'  => __('Cancelled', 'event_espresso'),
1390
+					'target' => '',
1391
+					'class'  => $menu_class,
1392
+				),
1393
+			));
1394
+		}
1395
+		//Registration Overview This Month
1396
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1397
+			'ee_admin_bar_menu_espresso-toolbar-registrations-month')
1398
+		) {
1399
+			$admin_bar->add_menu(array(
1400
+				'id'     => 'espresso-toolbar-registrations-month',
1401
+				'parent' => 'espresso-toolbar-registrations',
1402
+				'title'  => __('This Month', 'event_espresso'),
1403
+				'href'   => EEH_URL::add_query_args_and_nonce(array('action' => 'default', 'status' => 'month'),
1404
+					$reg_admin_url),
1405
+				'meta'   => array(
1406
+					'title'  => __('This Month', 'event_espresso'),
1407
+					'target' => '',
1408
+					'class'  => $menu_class,
1409
+				),
1410
+			));
1411
+		}
1412
+		//Registration Overview This Month Approved
1413
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1414
+			'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved')
1415
+		) {
1416
+			$admin_bar->add_menu(array(
1417
+				'id'     => 'espresso-toolbar-registrations-month-approved',
1418
+				'parent' => 'espresso-toolbar-registrations-month',
1419
+				'title'  => __('Approved', 'event_espresso'),
1420
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1421
+					'action'      => 'default',
1422
+					'status'      => 'month',
1423
+					'_reg_status' => EEM_Registration::status_id_approved,
1424
+				), $reg_admin_url),
1425
+				'meta'   => array(
1426
+					'title'  => __('Approved', 'event_espresso'),
1427
+					'target' => '',
1428
+					'class'  => $menu_class,
1429
+				),
1430
+			));
1431
+		}
1432
+		//Registration Overview This Month Pending
1433
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1434
+			'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending')
1435
+		) {
1436
+			$admin_bar->add_menu(array(
1437
+				'id'     => 'espresso-toolbar-registrations-month-pending',
1438
+				'parent' => 'espresso-toolbar-registrations-month',
1439
+				'title'  => __('Pending', 'event_espresso'),
1440
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1441
+					'action'      => 'default',
1442
+					'status'      => 'month',
1443
+					'_reg_status' => EEM_Registration::status_id_pending_payment,
1444
+				), $reg_admin_url),
1445
+				'meta'   => array(
1446
+					'title'  => __('Pending', 'event_espresso'),
1447
+					'target' => '',
1448
+					'class'  => $menu_class,
1449
+				),
1450
+			));
1451
+		}
1452
+		//Registration Overview This Month Not Approved
1453
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1454
+			'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved')
1455
+		) {
1456
+			$admin_bar->add_menu(array(
1457
+				'id'     => 'espresso-toolbar-registrations-month-not-approved',
1458
+				'parent' => 'espresso-toolbar-registrations-month',
1459
+				'title'  => __('Not Approved', 'event_espresso'),
1460
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1461
+					'action'      => 'default',
1462
+					'status'      => 'month',
1463
+					'_reg_status' => EEM_Registration::status_id_not_approved,
1464
+				), $reg_admin_url),
1465
+				'meta'   => array(
1466
+					'title'  => __('Not Approved', 'event_espresso'),
1467
+					'target' => '',
1468
+					'class'  => $menu_class,
1469
+				),
1470
+			));
1471
+		}
1472
+		//Registration Overview This Month Cancelled
1473
+		if ($this->registry->CAP->current_user_can('ee_read_registrations',
1474
+			'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled')
1475
+		) {
1476
+			$admin_bar->add_menu(array(
1477
+				'id'     => 'espresso-toolbar-registrations-month-cancelled',
1478
+				'parent' => 'espresso-toolbar-registrations-month',
1479
+				'title'  => __('Cancelled', 'event_espresso'),
1480
+				'href'   => EEH_URL::add_query_args_and_nonce(array(
1481
+					'action'      => 'default',
1482
+					'status'      => 'month',
1483
+					'_reg_status' => EEM_Registration::status_id_cancelled,
1484
+				), $reg_admin_url),
1485
+				'meta'   => array(
1486
+					'title'  => __('Cancelled', 'event_espresso'),
1487
+					'target' => '',
1488
+					'class'  => $menu_class,
1489
+				),
1490
+			));
1491
+		}
1492
+		//Extensions & Services
1493
+		if ($this->registry->CAP->current_user_can('ee_read_ee',
1494
+			'ee_admin_bar_menu_espresso-toolbar-extensions-and-services')
1495
+		) {
1496
+			$admin_bar->add_menu(array(
1497
+				'id'     => 'espresso-toolbar-extensions-and-services',
1498
+				'parent' => 'espresso-toolbar',
1499
+				'title'  => __('Extensions & Services', 'event_espresso'),
1500
+				'href'   => $extensions_admin_url,
1501
+				'meta'   => array(
1502
+					'title'  => __('Extensions & Services', 'event_espresso'),
1503
+					'target' => '',
1504
+					'class'  => $menu_class,
1505
+				),
1506
+			));
1507
+		}
1508
+	}
1509
+
1510
+
1511
+
1512
+	/**
1513
+	 * simply hooks into "wp_list_pages_exclude" filter (for wp_list_pages method) and makes sure EE critical pages are
1514
+	 * never returned with the function.
1515
+	 *
1516
+	 * @param  array $exclude_array any existing pages being excluded are in this array.
1517
+	 * @return array
1518
+	 */
1519
+	public function remove_pages_from_wp_list_pages($exclude_array)
1520
+	{
1521
+		return array_merge($exclude_array, $this->registry->CFG->core->get_critical_pages_array());
1522
+	}
1523 1523
 
1524 1524
 
1525 1525
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
     {
262 262
         // set autoloaders for all of the classes implementing EEI_Plugin_API
263 263
         // which provide helpers for EE plugin authors to more easily register certain components with EE.
264
-        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES . 'plugin_api');
264
+        EEH_Autoloader::instance()->register_autoloaders_for_each_file_in_folder(EE_LIBRARIES.'plugin_api');
265 265
     }
266 266
 
267 267
 
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
                 && in_array($_GET['action'], array('activate', 'activate-selected'), true)
296 296
             )
297 297
         ) {
298
-            include_once EE_THIRD_PARTY . 'wp-api-basic-auth' . DS . 'basic-auth.php';
298
+            include_once EE_THIRD_PARTY.'wp-api-basic-auth'.DS.'basic-auth.php';
299 299
         }
300 300
         do_action('AHEE__EE_System__load_espresso_addons__complete');
301 301
     }
@@ -781,7 +781,7 @@  discard block
 block discarded – undo
781 781
     private function _parse_model_names()
782 782
     {
783 783
         //get all the files in the EE_MODELS folder that end in .model.php
784
-        $models = glob(EE_MODELS . '*.model.php');
784
+        $models = glob(EE_MODELS.'*.model.php');
785 785
         $model_names = array();
786 786
         $non_abstract_db_models = array();
787 787
         foreach ($models as $model) {
@@ -809,8 +809,8 @@  discard block
 block discarded – undo
809 809
      */
810 810
     private function _maybe_brew_regular()
811 811
     {
812
-        if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH . 'brewing_regular.php')) {
813
-            require_once EE_CAFF_PATH . 'brewing_regular.php';
812
+        if (( ! defined('EE_DECAF') || EE_DECAF !== true) && is_readable(EE_CAFF_PATH.'brewing_regular.php')) {
813
+            require_once EE_CAFF_PATH.'brewing_regular.php';
814 814
         }
815 815
     }
816 816
 
@@ -860,8 +860,8 @@  discard block
 block discarded – undo
860 860
                 'event_espresso');
861 861
             $msg .= '<ul>';
862 862
             foreach ($class_names as $class_name) {
863
-                $msg .= '<li><b>Event Espresso - ' . str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
864
-                        $class_name) . '</b></li>';
863
+                $msg .= '<li><b>Event Espresso - '.str_replace(array('EE_', 'EEM_', 'EED_', 'EES_', 'EEW_'), '',
864
+                        $class_name).'</b></li>';
865 865
             }
866 866
             $msg .= '</ul>';
867 867
             $msg .= __('Compatibility issues can be avoided and/or resolved by keeping addons and plugins updated to the latest version.',
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
         $this->registry->load_core('Session');
1017 1017
         do_action('AHEE__EE_System__core_loaded_and_ready');
1018 1018
         // load_espresso_template_tags
1019
-        if (is_readable(EE_PUBLIC . 'template_tags.php')) {
1020
-            require_once(EE_PUBLIC . 'template_tags.php');
1019
+        if (is_readable(EE_PUBLIC.'template_tags.php')) {
1020
+            require_once(EE_PUBLIC.'template_tags.php');
1021 1021
         }
1022 1022
         do_action('AHEE__EE_System__set_hooks_for_shortcodes_modules_and_addons');
1023 1023
         $this->registry->create('EventEspresso\core\services\assets\Registry', array(), true);
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
             'href'  => $events_admin_url,
1164 1164
             'meta'  => array(
1165 1165
                 'title' => __('Event Espresso', 'event_espresso'),
1166
-                'class' => $menu_class . 'first',
1166
+                'class' => $menu_class.'first',
1167 1167
             ),
1168 1168
         ));
1169 1169
         //Events
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Number_Input_Display_Strategy.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -64,6 +64,9 @@
 block discarded – undo
64 64
     }
65 65
 
66 66
 
67
+    /**
68
+     * @param string $argument_label
69
+     */
67 70
     private function throwValidationException($argument_label, $argument_value)
68 71
     {
69 72
         throw new InvalidArgumentException(
Please login to merge, or discard this patch.
Indentation   +105 added lines, -105 removed lines patch added patch discarded remove patch
@@ -14,111 +14,111 @@
 block discarded – undo
14 14
 class EE_Number_Input_Display_Strategy extends EE_Display_Strategy_Base
15 15
 {
16 16
 
17
-    /**
18
-     * minimum value for number field
19
-     *
20
-     * @var int|null $min
21
-     */
22
-    protected $min;
23
-
24
-    /**
25
-     * maximum value for number field
26
-     *
27
-     * @var int|null $max
28
-     */
29
-    protected $max;
30
-
31
-
32
-    /**
33
-     * This is used to set the "step" attribute for the html5 number input.
34
-     * Controls the increments on the input when incrementing or decrementing the value.
35
-     * Note:  Although the step attribute allows for the string "any" to be used, Firefox and Chrome will interpret that
36
-     * to increment by 1.  So although "any" is accepted as a value, it is converted to 1.
37
-     * @var float
38
-     */
39
-    protected $step;
40
-
41
-
42
-    /**
43
-     * EE_Number_Input_Display_Strategy constructor.
44
-     * Null is the default value for the incoming arguments because 0 is a valid value.  So we use null
45
-     * to indicate NOT setting this attribute.
46
-     *
47
-     * @param int|null $min
48
-     * @param int|null $max
49
-     * @param int|null $step
50
-     * @throws InvalidArgumentException
51
-     */
52
-    public function __construct($min = null, $max = null, $step = null)
53
-    {
54
-        $this->min = is_numeric($min) || $min === null
55
-            ? $min
56
-            : $this->throwValidationException('min', $min);
57
-        $this->max = is_numeric($max) || $max === null
58
-            ? $max
59
-            : $this->throwValidationException('max', $max);
60
-        $step = $step === 'any' ? 1 : $step;
61
-        $this->step = is_numeric($step) || $step === null
62
-            ? $step
63
-            : $this->throwValidationException('step', $step);
64
-    }
65
-
66
-
67
-    private function throwValidationException($argument_label, $argument_value)
68
-    {
69
-        throw new InvalidArgumentException(
70
-            sprintf(
71
-                esc_html__(
72
-                    'The %1$s parameter value for %2$s must be numeric or null, %3$s was passed into the constructor.',
73
-                    'event_espresso'
74
-                ),
75
-                $argument_label,
76
-                __CLASS__,
77
-                $argument_value
78
-            )
79
-        );
80
-    }
81
-
82
-
83
-
84
-    /**
85
-     * @return string of html to display the field
86
-     */
87
-    public function display()
88
-    {
89
-        $input = $this->_opening_tag('input');
90
-        $input .= $this->_attributes_string(
91
-            array_merge(
92
-                $this->_standard_attributes_array(),
93
-                $this->getNumberInputAttributes()
94
-            )
95
-        );
96
-        $input .= $this->_close_tag();
97
-        return $input;
98
-    }
99
-
100
-
101
-    /**
102
-     * Return the attributes specific to this display strategy
103
-     * @return array
104
-     */
105
-    private function getNumberInputAttributes()
106
-    {
107
-        $attributes = array(
108
-            'type' => 'number',
109
-            'value' => $this->_input->raw_value_in_form()
110
-        );
111
-        if ($this->min !== null) {
112
-            $attributes['min'] = $this->min;
113
-        }
114
-        if ($this->max !== null) {
115
-            $attributes['max'] = $this->max;
116
-        }
117
-        if ($this->step !== null) {
118
-            $attributes['step'] = $this->step;
119
-        }
120
-        return $attributes;
121
-    }
17
+	/**
18
+	 * minimum value for number field
19
+	 *
20
+	 * @var int|null $min
21
+	 */
22
+	protected $min;
23
+
24
+	/**
25
+	 * maximum value for number field
26
+	 *
27
+	 * @var int|null $max
28
+	 */
29
+	protected $max;
30
+
31
+
32
+	/**
33
+	 * This is used to set the "step" attribute for the html5 number input.
34
+	 * Controls the increments on the input when incrementing or decrementing the value.
35
+	 * Note:  Although the step attribute allows for the string "any" to be used, Firefox and Chrome will interpret that
36
+	 * to increment by 1.  So although "any" is accepted as a value, it is converted to 1.
37
+	 * @var float
38
+	 */
39
+	protected $step;
40
+
41
+
42
+	/**
43
+	 * EE_Number_Input_Display_Strategy constructor.
44
+	 * Null is the default value for the incoming arguments because 0 is a valid value.  So we use null
45
+	 * to indicate NOT setting this attribute.
46
+	 *
47
+	 * @param int|null $min
48
+	 * @param int|null $max
49
+	 * @param int|null $step
50
+	 * @throws InvalidArgumentException
51
+	 */
52
+	public function __construct($min = null, $max = null, $step = null)
53
+	{
54
+		$this->min = is_numeric($min) || $min === null
55
+			? $min
56
+			: $this->throwValidationException('min', $min);
57
+		$this->max = is_numeric($max) || $max === null
58
+			? $max
59
+			: $this->throwValidationException('max', $max);
60
+		$step = $step === 'any' ? 1 : $step;
61
+		$this->step = is_numeric($step) || $step === null
62
+			? $step
63
+			: $this->throwValidationException('step', $step);
64
+	}
65
+
66
+
67
+	private function throwValidationException($argument_label, $argument_value)
68
+	{
69
+		throw new InvalidArgumentException(
70
+			sprintf(
71
+				esc_html__(
72
+					'The %1$s parameter value for %2$s must be numeric or null, %3$s was passed into the constructor.',
73
+					'event_espresso'
74
+				),
75
+				$argument_label,
76
+				__CLASS__,
77
+				$argument_value
78
+			)
79
+		);
80
+	}
81
+
82
+
83
+
84
+	/**
85
+	 * @return string of html to display the field
86
+	 */
87
+	public function display()
88
+	{
89
+		$input = $this->_opening_tag('input');
90
+		$input .= $this->_attributes_string(
91
+			array_merge(
92
+				$this->_standard_attributes_array(),
93
+				$this->getNumberInputAttributes()
94
+			)
95
+		);
96
+		$input .= $this->_close_tag();
97
+		return $input;
98
+	}
99
+
100
+
101
+	/**
102
+	 * Return the attributes specific to this display strategy
103
+	 * @return array
104
+	 */
105
+	private function getNumberInputAttributes()
106
+	{
107
+		$attributes = array(
108
+			'type' => 'number',
109
+			'value' => $this->_input->raw_value_in_form()
110
+		);
111
+		if ($this->min !== null) {
112
+			$attributes['min'] = $this->min;
113
+		}
114
+		if ($this->max !== null) {
115
+			$attributes['max'] = $this->max;
116
+		}
117
+		if ($this->step !== null) {
118
+			$attributes['step'] = $this->step;
119
+		}
120
+		return $attributes;
121
+	}
122 122
 
123 123
 }
124 124
 // End of file EE_Number_Input_Display_Strategy.php
Please login to merge, or discard this patch.