Completed
Branch BUG-10738-inconsistency-in-ses... (cda363)
by
unknown
13:38 queued 12s
created
core/services/loaders/LoaderDecoratorInterface.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -9,20 +9,20 @@
 block discarded – undo
9 9
 interface LoaderDecoratorInterface
10 10
 {
11 11
 
12
-    /**
13
-     * @param string $fqcn
14
-     * @param array  $arguments
15
-     * @param bool   $shared
16
-     * @return mixed
17
-     */
18
-    public function load($fqcn, $arguments = array(), $shared = true);
12
+	/**
13
+	 * @param string $fqcn
14
+	 * @param array  $arguments
15
+	 * @param bool   $shared
16
+	 * @return mixed
17
+	 */
18
+	public function load($fqcn, $arguments = array(), $shared = true);
19 19
 
20 20
 
21 21
 
22
-    /**
23
-     * calls reset() on loader if method exists
24
-     */
25
-    public function reset();
22
+	/**
23
+	 * calls reset() on loader if method exists
24
+	 */
25
+	public function reset();
26 26
 
27 27
 }
28 28
 // End of file LoaderInterface.php
Please login to merge, or discard this patch.
core/db_models/EEM_WP_User.model.php 2 patches
Indentation   +123 added lines, -123 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\services\orm\ModelFieldFactory;
4 4
 
5 5
 if (! defined('EVENT_ESPRESSO_VERSION')) {
6
-    exit('No direct script access allowed');
6
+	exit('No direct script access allowed');
7 7
 }
8 8
 
9 9
 
@@ -19,128 +19,128 @@  discard block
 block discarded – undo
19 19
 class EEM_WP_User extends EEM_Base
20 20
 {
21 21
 
22
-    /**
23
-     * private instance of the EEM_WP_User object
24
-     *
25
-     * @type EEM_WP_User
26
-     */
27
-    protected static $_instance;
28
-
29
-
30
-
31
-    /**
32
-     *    constructor
33
-     *
34
-     * @param null              $timezone
35
-     * @param ModelFieldFactory $model_field_factory
36
-     * @throws EE_Error
37
-     * @throws InvalidArgumentException
38
-     */
39
-    protected function __construct($timezone = null, ModelFieldFactory $model_field_factory)
40
-    {
41
-        $this->singular_item = __('WP_User', 'event_espresso');
42
-        $this->plural_item = __('WP_Users', 'event_espresso');
43
-        global $wpdb;
44
-        $this->_tables = array(
45
-            'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true),
46
-        );
47
-        $this->_fields = array(
48
-            'WP_User' => array(
49
-                'ID'                  => $model_field_factory->createPrimaryKeyIntField(
50
-                    'ID',
51
-                    __('WP_User ID', 'event_espresso')
52
-                ),
53
-                'user_login'          => $model_field_factory->createPlainTextField(
54
-                    'user_login',
55
-                    __('User Login', 'event_espresso'),
56
-                    false
57
-                ),
58
-                'user_pass'           => $model_field_factory->createPlainTextField(
59
-                    'user_pass',
60
-                    __('User Password', 'event_espresso'),
61
-                    false
62
-                ),
63
-                'user_nicename'       => $model_field_factory->createPlainTextField(
64
-                    'user_nicename',
65
-                    __(' User Nice Name', 'event_espresso'),
66
-                    false
67
-                ),
68
-                'user_email'          => $model_field_factory->createEmailField(
69
-                    'user_email',
70
-                    __('User Email', 'event_espresso'),
71
-                    false,
72
-                    null
73
-                ),
74
-                'user_registered'     => $model_field_factory->createDatetimeField(
75
-                    'user_registered',
76
-                    __('Date User Registered', 'event_espresso'),
77
-                    $timezone
78
-                ),
79
-                'user_activation_key' => $model_field_factory->createPlainTextField(
80
-                    'user_activation_key',
81
-                    __('User Activation Key', 'event_espresso'),
82
-                    false
83
-                ),
84
-                'user_status'         => $model_field_factory->createIntegerField(
85
-                    'user_status',
86
-                    __('User Status', 'event_espresso')
87
-                ),
88
-                'display_name'        => $model_field_factory->createPlainTextField(
89
-                    'display_name',
90
-                    __('Display Name', 'event_espresso'),
91
-                    false
92
-                ),
93
-            ),
94
-        );
95
-        $this->_model_relations = array(
96
-            'Attendee'       => new EE_Has_Many_Relation(),
97
-            // all models are related to the change log
98
-            // 'Change_Log'     => new EE_Has_Many_Relation(),
99
-            'Event'          => new EE_Has_Many_Relation(),
100
-            'Payment_Method' => new EE_Has_Many_Relation(),
101
-            'Price'          => new EE_Has_Many_Relation(),
102
-            'Price_Type'     => new EE_Has_Many_Relation(),
103
-            'Question'       => new EE_Has_Many_Relation(),
104
-            'Question_Group' => new EE_Has_Many_Relation(),
105
-            'Ticket'         => new EE_Has_Many_Relation(),
106
-            'Venue'          => new EE_Has_Many_Relation(),
107
-            'Message'        => new EE_Has_Many_Relation(),
108
-        );
109
-        $this->_wp_core_model = true;
110
-        $this->_caps_slug = 'users';
111
-        $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list';
112
-        $this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list';
113
-        foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
114
-            $this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User();
115
-        }
116
-        //@todo: account for create_users controls whether they can create users at all
117
-        parent::__construct($timezone);
118
-    }
119
-
120
-
121
-
122
-    /**
123
-     * We don't need a foreign key to the WP_User model, we just need its primary key
124
-     *
125
-     * @return string
126
-     * @throws EE_Error
127
-     */
128
-    public function wp_user_field_name()
129
-    {
130
-        return $this->primary_key_name();
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * This WP_User model IS owned, even though it doesn't have a foreign key to itself
137
-     *
138
-     * @return boolean
139
-     */
140
-    public function is_owned()
141
-    {
142
-        return true;
143
-    }
22
+	/**
23
+	 * private instance of the EEM_WP_User object
24
+	 *
25
+	 * @type EEM_WP_User
26
+	 */
27
+	protected static $_instance;
28
+
29
+
30
+
31
+	/**
32
+	 *    constructor
33
+	 *
34
+	 * @param null              $timezone
35
+	 * @param ModelFieldFactory $model_field_factory
36
+	 * @throws EE_Error
37
+	 * @throws InvalidArgumentException
38
+	 */
39
+	protected function __construct($timezone = null, ModelFieldFactory $model_field_factory)
40
+	{
41
+		$this->singular_item = __('WP_User', 'event_espresso');
42
+		$this->plural_item = __('WP_Users', 'event_espresso');
43
+		global $wpdb;
44
+		$this->_tables = array(
45
+			'WP_User' => new EE_Primary_Table($wpdb->users, 'ID', true),
46
+		);
47
+		$this->_fields = array(
48
+			'WP_User' => array(
49
+				'ID'                  => $model_field_factory->createPrimaryKeyIntField(
50
+					'ID',
51
+					__('WP_User ID', 'event_espresso')
52
+				),
53
+				'user_login'          => $model_field_factory->createPlainTextField(
54
+					'user_login',
55
+					__('User Login', 'event_espresso'),
56
+					false
57
+				),
58
+				'user_pass'           => $model_field_factory->createPlainTextField(
59
+					'user_pass',
60
+					__('User Password', 'event_espresso'),
61
+					false
62
+				),
63
+				'user_nicename'       => $model_field_factory->createPlainTextField(
64
+					'user_nicename',
65
+					__(' User Nice Name', 'event_espresso'),
66
+					false
67
+				),
68
+				'user_email'          => $model_field_factory->createEmailField(
69
+					'user_email',
70
+					__('User Email', 'event_espresso'),
71
+					false,
72
+					null
73
+				),
74
+				'user_registered'     => $model_field_factory->createDatetimeField(
75
+					'user_registered',
76
+					__('Date User Registered', 'event_espresso'),
77
+					$timezone
78
+				),
79
+				'user_activation_key' => $model_field_factory->createPlainTextField(
80
+					'user_activation_key',
81
+					__('User Activation Key', 'event_espresso'),
82
+					false
83
+				),
84
+				'user_status'         => $model_field_factory->createIntegerField(
85
+					'user_status',
86
+					__('User Status', 'event_espresso')
87
+				),
88
+				'display_name'        => $model_field_factory->createPlainTextField(
89
+					'display_name',
90
+					__('Display Name', 'event_espresso'),
91
+					false
92
+				),
93
+			),
94
+		);
95
+		$this->_model_relations = array(
96
+			'Attendee'       => new EE_Has_Many_Relation(),
97
+			// all models are related to the change log
98
+			// 'Change_Log'     => new EE_Has_Many_Relation(),
99
+			'Event'          => new EE_Has_Many_Relation(),
100
+			'Payment_Method' => new EE_Has_Many_Relation(),
101
+			'Price'          => new EE_Has_Many_Relation(),
102
+			'Price_Type'     => new EE_Has_Many_Relation(),
103
+			'Question'       => new EE_Has_Many_Relation(),
104
+			'Question_Group' => new EE_Has_Many_Relation(),
105
+			'Ticket'         => new EE_Has_Many_Relation(),
106
+			'Venue'          => new EE_Has_Many_Relation(),
107
+			'Message'        => new EE_Has_Many_Relation(),
108
+		);
109
+		$this->_wp_core_model = true;
110
+		$this->_caps_slug = 'users';
111
+		$this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read] = 'list';
112
+		$this->_cap_contexts_to_cap_action_map[EEM_Base::caps_read_admin] = 'list';
113
+		foreach ($this->_cap_contexts_to_cap_action_map as $context => $action) {
114
+			$this->_cap_restriction_generators[$context] = new EE_Restriction_Generator_WP_User();
115
+		}
116
+		//@todo: account for create_users controls whether they can create users at all
117
+		parent::__construct($timezone);
118
+	}
119
+
120
+
121
+
122
+	/**
123
+	 * We don't need a foreign key to the WP_User model, we just need its primary key
124
+	 *
125
+	 * @return string
126
+	 * @throws EE_Error
127
+	 */
128
+	public function wp_user_field_name()
129
+	{
130
+		return $this->primary_key_name();
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * This WP_User model IS owned, even though it doesn't have a foreign key to itself
137
+	 *
138
+	 * @return boolean
139
+	 */
140
+	public function is_owned()
141
+	{
142
+		return true;
143
+	}
144 144
 
145 145
 
146 146
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@
 block discarded – undo
2 2
 
3 3
 use EventEspresso\core\services\orm\ModelFieldFactory;
4 4
 
5
-if (! defined('EVENT_ESPRESSO_VERSION')) {
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
6 6
     exit('No direct script access allowed');
7 7
 }
8 8
 
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Base.form.php 1 patch
Indentation   +464 added lines, -464 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\libraries\form_sections\strategies\filter\FormHtmlFilter;
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
 
@@ -19,480 +19,480 @@  discard block
 block discarded – undo
19 19
 abstract class EE_Form_Section_Base
20 20
 {
21 21
 
22
-    /**
23
-     * the URL the form is submitted to
24
-     *
25
-     * @var string
26
-     */
27
-    protected $_action;
28
-
29
-    /**
30
-     * POST (default) or GET
31
-     *
32
-     * @var string
33
-     */
34
-    protected $_method;
35
-
36
-    /**
37
-     * html_id and html_name are derived from this by default
38
-     *
39
-     * @var string
40
-     */
41
-    protected $_name;
42
-
43
-    /**
44
-     * $_html_id
45
-     * @var string
46
-     */
47
-    protected $_html_id;
48
-
49
-    /**
50
-     * $_html_class
51
-     * @var string
52
-     */
53
-    protected $_html_class;
54
-
55
-    /**
56
-     * $_html_style
57
-     * @var string
58
-     */
59
-    protected $_html_style;
60
-
61
-    /**
62
-     * $_other_html_attributes
63
-     * @var string
64
-     */
65
-    protected $_other_html_attributes;
66
-
67
-    /**
68
-     * The form section of which this form section is a part
69
-     *
70
-     * @var EE_Form_Section_Proper
71
-     */
72
-    protected $_parent_section;
73
-
74
-    /**
75
-     * flag indicating that _construct_finalize has been called.
76
-     * If it has not been called and we try to use functions which require it, we call it
77
-     * with no parameters. But normally, _construct_finalize should be called by the instantiating class
78
-     *
79
-     * @var boolean
80
-     */
81
-    protected $_construction_finalized;
82
-
83
-    /**
84
-     * Strategy for parsing the form HTML upon display
85
-     *
86
-     * @var FormHtmlFilter
87
-     */
88
-    protected $_form_html_filter;
89
-
90
-
91
-
92
-    /**
93
-     * @param array $options_array {
94
-     * @type        $name          string the name for this form section, if you want to explicitly define it
95
-     *                             }
96
-     */
97
-    public function __construct($options_array = array())
98
-    {
99
-        // used by display strategies
100
-        // assign incoming values to properties
101
-        foreach ($options_array as $key => $value) {
102
-            $key = '_' . $key;
103
-            if (property_exists($this, $key) && empty($this->{$key})) {
104
-                $this->{$key} = $value;
105
-            }
106
-        }
107
-        // set parser which allows the form section's rendered HTML to be filtered
108
-        if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
109
-            $this->_form_html_filter = $options_array['form_html_filter'];
110
-        }
111
-    }
112
-
113
-
114
-
115
-    /**
116
-     * @param $parent_form_section
117
-     * @param $name
118
-     * @throws \EE_Error
119
-     */
120
-    protected function _construct_finalize($parent_form_section, $name)
121
-    {
122
-        $this->_construction_finalized = true;
123
-        $this->_parent_section = $parent_form_section;
124
-        if ($name !== null) {
125
-            $this->_name = $name;
126
-        }
127
-    }
128
-
129
-
130
-
131
-    /**
132
-     * make sure construction finalized was called, otherwise children might not be ready
133
-     *
134
-     * @return void
135
-     * @throws \EE_Error
136
-     */
137
-    public function ensure_construct_finalized_called()
138
-    {
139
-        if (! $this->_construction_finalized) {
140
-            $this->_construct_finalize($this->_parent_section, $this->_name);
141
-        }
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     * @return string
148
-     */
149
-    public function action()
150
-    {
151
-        return $this->_action;
152
-    }
153
-
154
-
155
-
156
-    /**
157
-     * @param string $action
158
-     */
159
-    public function set_action($action)
160
-    {
161
-        $this->_action = $action;
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * @return string
168
-     */
169
-    public function method()
170
-    {
171
-        return ! empty($this->_method) ? $this->_method : 'POST';
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * @param string $method
178
-     */
179
-    public function set_method($method)
180
-    {
181
-        switch ($method) {
182
-            case 'get' :
183
-            case 'GET' :
184
-                $this->_method = 'GET';
185
-                break;
186
-            default :
187
-                $this->_method = 'POST';
188
-        }
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * Sets the html_id to its default value, if none was specified in the constructor.
195
-     * Calculation involves using the name and the parent's html id
196
-     * return void
197
-     *
198
-     * @throws \EE_Error
199
-     */
200
-    protected function _set_default_html_id_if_empty()
201
-    {
202
-        if (! $this->_html_id) {
203
-            if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
204
-                $this->_html_id = $this->_parent_section->html_id()
205
-                                  . '-'
206
-                                  . $this->_prep_name_for_html_id($this->name());
207
-            } else {
208
-                $this->_html_id = $this->_prep_name_for_html_id($this->name());
209
-            }
210
-        }
211
-    }
212
-
213
-
214
-
215
-    /**
216
-     * _prep_name_for_html_id
217
-     *
218
-     * @param $name
219
-     * @return string
220
-     */
221
-    private function _prep_name_for_html_id($name)
222
-    {
223
-        return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name));
224
-    }
22
+	/**
23
+	 * the URL the form is submitted to
24
+	 *
25
+	 * @var string
26
+	 */
27
+	protected $_action;
28
+
29
+	/**
30
+	 * POST (default) or GET
31
+	 *
32
+	 * @var string
33
+	 */
34
+	protected $_method;
35
+
36
+	/**
37
+	 * html_id and html_name are derived from this by default
38
+	 *
39
+	 * @var string
40
+	 */
41
+	protected $_name;
42
+
43
+	/**
44
+	 * $_html_id
45
+	 * @var string
46
+	 */
47
+	protected $_html_id;
48
+
49
+	/**
50
+	 * $_html_class
51
+	 * @var string
52
+	 */
53
+	protected $_html_class;
54
+
55
+	/**
56
+	 * $_html_style
57
+	 * @var string
58
+	 */
59
+	protected $_html_style;
60
+
61
+	/**
62
+	 * $_other_html_attributes
63
+	 * @var string
64
+	 */
65
+	protected $_other_html_attributes;
66
+
67
+	/**
68
+	 * The form section of which this form section is a part
69
+	 *
70
+	 * @var EE_Form_Section_Proper
71
+	 */
72
+	protected $_parent_section;
73
+
74
+	/**
75
+	 * flag indicating that _construct_finalize has been called.
76
+	 * If it has not been called and we try to use functions which require it, we call it
77
+	 * with no parameters. But normally, _construct_finalize should be called by the instantiating class
78
+	 *
79
+	 * @var boolean
80
+	 */
81
+	protected $_construction_finalized;
82
+
83
+	/**
84
+	 * Strategy for parsing the form HTML upon display
85
+	 *
86
+	 * @var FormHtmlFilter
87
+	 */
88
+	protected $_form_html_filter;
89
+
90
+
91
+
92
+	/**
93
+	 * @param array $options_array {
94
+	 * @type        $name          string the name for this form section, if you want to explicitly define it
95
+	 *                             }
96
+	 */
97
+	public function __construct($options_array = array())
98
+	{
99
+		// used by display strategies
100
+		// assign incoming values to properties
101
+		foreach ($options_array as $key => $value) {
102
+			$key = '_' . $key;
103
+			if (property_exists($this, $key) && empty($this->{$key})) {
104
+				$this->{$key} = $value;
105
+			}
106
+		}
107
+		// set parser which allows the form section's rendered HTML to be filtered
108
+		if (isset($options_array['form_html_filter']) && $options_array['form_html_filter'] instanceof FormHtmlFilter) {
109
+			$this->_form_html_filter = $options_array['form_html_filter'];
110
+		}
111
+	}
112
+
113
+
114
+
115
+	/**
116
+	 * @param $parent_form_section
117
+	 * @param $name
118
+	 * @throws \EE_Error
119
+	 */
120
+	protected function _construct_finalize($parent_form_section, $name)
121
+	{
122
+		$this->_construction_finalized = true;
123
+		$this->_parent_section = $parent_form_section;
124
+		if ($name !== null) {
125
+			$this->_name = $name;
126
+		}
127
+	}
128
+
129
+
130
+
131
+	/**
132
+	 * make sure construction finalized was called, otherwise children might not be ready
133
+	 *
134
+	 * @return void
135
+	 * @throws \EE_Error
136
+	 */
137
+	public function ensure_construct_finalized_called()
138
+	{
139
+		if (! $this->_construction_finalized) {
140
+			$this->_construct_finalize($this->_parent_section, $this->_name);
141
+		}
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 * @return string
148
+	 */
149
+	public function action()
150
+	{
151
+		return $this->_action;
152
+	}
153
+
154
+
155
+
156
+	/**
157
+	 * @param string $action
158
+	 */
159
+	public function set_action($action)
160
+	{
161
+		$this->_action = $action;
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * @return string
168
+	 */
169
+	public function method()
170
+	{
171
+		return ! empty($this->_method) ? $this->_method : 'POST';
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * @param string $method
178
+	 */
179
+	public function set_method($method)
180
+	{
181
+		switch ($method) {
182
+			case 'get' :
183
+			case 'GET' :
184
+				$this->_method = 'GET';
185
+				break;
186
+			default :
187
+				$this->_method = 'POST';
188
+		}
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * Sets the html_id to its default value, if none was specified in the constructor.
195
+	 * Calculation involves using the name and the parent's html id
196
+	 * return void
197
+	 *
198
+	 * @throws \EE_Error
199
+	 */
200
+	protected function _set_default_html_id_if_empty()
201
+	{
202
+		if (! $this->_html_id) {
203
+			if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
204
+				$this->_html_id = $this->_parent_section->html_id()
205
+								  . '-'
206
+								  . $this->_prep_name_for_html_id($this->name());
207
+			} else {
208
+				$this->_html_id = $this->_prep_name_for_html_id($this->name());
209
+			}
210
+		}
211
+	}
212
+
213
+
214
+
215
+	/**
216
+	 * _prep_name_for_html_id
217
+	 *
218
+	 * @param $name
219
+	 * @return string
220
+	 */
221
+	private function _prep_name_for_html_id($name)
222
+	{
223
+		return sanitize_key(str_replace(array(' ', ' ', '_'), '-', $name));
224
+	}
225 225
 
226 226
 
227 227
 
228
-    /**
229
-     * Returns the HTML, JS, and CSS necessary to display this form section on a page.
230
-     * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
231
-     * and call get_html when you want to output the html. Calling get_html_and_js after
232
-     * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
233
-     * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
234
-     * and so might stop working anytime.
235
-     *
236
-     * @return string
237
-     */
238
-    public function get_html_and_js()
239
-    {
240
-        return $this->get_html();
241
-    }
228
+	/**
229
+	 * Returns the HTML, JS, and CSS necessary to display this form section on a page.
230
+	 * Note however, it's recommended that you instead call enqueue_js on the "wp_enqueue_scripts" action,
231
+	 * and call get_html when you want to output the html. Calling get_html_and_js after
232
+	 * "wp_enqueue_scripts" has already fired seems to work for now, but is contrary
233
+	 * to the instructions on https://developer.wordpress.org/reference/functions/wp_enqueue_script/
234
+	 * and so might stop working anytime.
235
+	 *
236
+	 * @return string
237
+	 */
238
+	public function get_html_and_js()
239
+	{
240
+		return $this->get_html();
241
+	}
242 242
 
243 243
 
244 244
 
245
-    /**
246
-     * Gets the HTML for displaying this form section
247
-     *
248
-     * @return string
249
-     */
250
-    public abstract function get_html();
245
+	/**
246
+	 * Gets the HTML for displaying this form section
247
+	 *
248
+	 * @return string
249
+	 */
250
+	public abstract function get_html();
251 251
 
252 252
 
253 253
 
254
-    /**
255
-     * @param bool $add_pound_sign
256
-     * @return string
257
-     */
258
-    public function html_id($add_pound_sign = false)
259
-    {
260
-        $this->_set_default_html_id_if_empty();
261
-        return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
262
-    }
254
+	/**
255
+	 * @param bool $add_pound_sign
256
+	 * @return string
257
+	 */
258
+	public function html_id($add_pound_sign = false)
259
+	{
260
+		$this->_set_default_html_id_if_empty();
261
+		return $add_pound_sign ? '#' . $this->_html_id : $this->_html_id;
262
+	}
263 263
 
264 264
 
265
-
266
-    /**
267
-     * @return string
268
-     */
269
-    public function html_class()
270
-    {
271
-        return $this->_html_class;
272
-    }
273
-
274
-
275
-
276
-    /**
277
-     * @return string
278
-     */
279
-    public function html_style()
280
-    {
281
-        return $this->_html_style;
282
-    }
283
-
284
-
285
-
286
-    /**
287
-     * @param mixed $html_class
288
-     */
289
-    public function set_html_class($html_class)
290
-    {
291
-        $this->_html_class = $html_class;
292
-    }
293
-
294
-
295
-
296
-    /**
297
-     * @param mixed $html_id
298
-     */
299
-    public function set_html_id($html_id)
300
-    {
301
-        $this->_html_id = $html_id;
302
-    }
303
-
304
-
305
-
306
-    /**
307
-     * @param mixed $html_style
308
-     */
309
-    public function set_html_style($html_style)
310
-    {
311
-        $this->_html_style = $html_style;
312
-    }
313
-
314
-
315
-
316
-    /**
317
-     * @param string $other_html_attributes
318
-     */
319
-    public function set_other_html_attributes($other_html_attributes)
320
-    {
321
-        $this->_other_html_attributes = $other_html_attributes;
322
-    }
323
-
324
-
325
-
326
-    /**
327
-     * @return string
328
-     */
329
-    public function other_html_attributes()
330
-    {
331
-        return $this->_other_html_attributes;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * Gets the name of the form section. This is not the same as the HTML name.
338
-     *
339
-     * @throws EE_Error
340
-     * @return string
341
-     */
342
-    public function name()
343
-    {
344
-        if (! $this->_construction_finalized) {
345
-            throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346
-                'event_espresso'), get_class($this)));
347
-        }
348
-        return $this->_name;
349
-    }
350
-
351
-
352
-
353
-    /**
354
-     * Gets the parent section
355
-     *
356
-     * @return EE_Form_Section_Proper
357
-     */
358
-    public function parent_section()
359
-    {
360
-        return $this->_parent_section;
361
-    }
362
-
363
-
364
-
365
-    /**
366
-     * returns HTML for generating the opening form HTML tag (<form>)
367
-     *
368
-     * @param string $action           the URL the form is submitted to
369
-     * @param string $method           POST (default) or GET
370
-     * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
371
-     * @return string
372
-     */
373
-    public function form_open($action = '', $method = '', $other_attributes = '')
374
-    {
375
-        if (! empty($action)) {
376
-            $this->set_action($action);
377
-        }
378
-        if (! empty($method)) {
379
-            $this->set_method($method);
380
-        }
381
-        $html = EEH_HTML::nl(1, 'form') . '<form';
382
-        $html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
383
-        $html .= ' action="' . $this->action() . '"';
384
-        $html .= ' method="' . $this->method() . '"';
385
-        $html .= $other_attributes . '>';
386
-        return $html;
387
-    }
388
-
389
-
390
-
391
-    /**
392
-     * ensures that html id for form either ends in "-form" or "-frm"
393
-     * so that id doesn't conflict/collide with other elements
394
-     *
395
-     * @param string $html_id
396
-     * @return string
397
-     */
398
-    protected function get_html_id_for_form($html_id)
399
-    {
400
-        $strlen = strlen($html_id);
401
-        $html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
402
-            ? $html_id
403
-            : $html_id . '-frm';
404
-        return $html_id;
405
-    }
406
-
407
-
408
-
409
-    /**
410
-     * returns HTML for generating the closing form HTML tag (</form>)
411
-     *
412
-     * @return string
413
-     */
414
-    public function form_close()
415
-    {
416
-        return EEH_HTML::nl(-1, 'form')
417
-               . '</form>'
418
-               . EEH_HTML::nl()
419
-               . '<!-- end of ee-'
420
-               . $this->html_id()
421
-               . '-form -->'
422
-               . EEH_HTML::nl();
423
-    }
424
-
425
-
426
-
427
-    /**
428
-     * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
429
-     * wp_enqueue_style; the scripts could have optionally been registered earlier)
430
-     * Default does nothing, but child classes can override
431
-     *
432
-     * @return void
433
-     */
434
-    public function enqueue_js()
435
-    {
436
-        //defaults to enqueue NO js or css
437
-    }
438
-
439
-
440
-
441
-    /**
442
-     * Adds any extra data needed by js. Eventually we'll call wp_localize_script
443
-     * with it, and it will be on each form section's 'other_data' property.
444
-     * By default nothing is added, but child classes can extend this method to add something.
445
-     * Eg, if you have an input that will cause a modal dialog to appear,
446
-     * here you could add an entry like 'modal_dialog_inputs' to this array
447
-     * to map between the input's html ID and the modal dialogue's ID, so that
448
-     * your JS code will know where to find the modal dialog when the input is pressed.
449
-     * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
450
-     *
451
-     * @param array $form_other_js_data
452
-     * @return array
453
-     */
454
-    public function get_other_js_data($form_other_js_data = array())
455
-    {
456
-        return $form_other_js_data;
457
-    }
458
-
459
-
460
-
461
-    /**
462
-     * This isn't just the name of an input, it's a path pointing to an input. The
463
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
464
-     * dot-dot-slash (../) means to ascend into the parent section.
465
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
466
-     * which will be returned.
467
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
468
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
469
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
470
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
471
-     * Etc
472
-     *
473
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
474
-     * @return EE_Form_Section_Base
475
-     */
476
-    public function find_section_from_path($form_section_path)
477
-    {
478
-        if (strpos($form_section_path, '/') === 0) {
479
-            $form_section_path = substr($form_section_path, strlen('/'));
480
-        }
481
-        if (empty($form_section_path)) {
482
-            return $this;
483
-        }
484
-        if (strpos($form_section_path, '../') === 0) {
485
-            $parent = $this->parent_section();
486
-            $form_section_path = substr($form_section_path, strlen('../'));
487
-            if ($parent instanceof EE_Form_Section_Base) {
488
-                return $parent->find_section_from_path($form_section_path);
489
-            } elseif (empty($form_section_path)) {
490
-                return $this;
491
-            }
492
-        }
493
-        //couldn't find it using simple parent following
494
-        return null;
495
-    }
265
+
266
+	/**
267
+	 * @return string
268
+	 */
269
+	public function html_class()
270
+	{
271
+		return $this->_html_class;
272
+	}
273
+
274
+
275
+
276
+	/**
277
+	 * @return string
278
+	 */
279
+	public function html_style()
280
+	{
281
+		return $this->_html_style;
282
+	}
283
+
284
+
285
+
286
+	/**
287
+	 * @param mixed $html_class
288
+	 */
289
+	public function set_html_class($html_class)
290
+	{
291
+		$this->_html_class = $html_class;
292
+	}
293
+
294
+
295
+
296
+	/**
297
+	 * @param mixed $html_id
298
+	 */
299
+	public function set_html_id($html_id)
300
+	{
301
+		$this->_html_id = $html_id;
302
+	}
303
+
304
+
305
+
306
+	/**
307
+	 * @param mixed $html_style
308
+	 */
309
+	public function set_html_style($html_style)
310
+	{
311
+		$this->_html_style = $html_style;
312
+	}
313
+
314
+
315
+
316
+	/**
317
+	 * @param string $other_html_attributes
318
+	 */
319
+	public function set_other_html_attributes($other_html_attributes)
320
+	{
321
+		$this->_other_html_attributes = $other_html_attributes;
322
+	}
323
+
324
+
325
+
326
+	/**
327
+	 * @return string
328
+	 */
329
+	public function other_html_attributes()
330
+	{
331
+		return $this->_other_html_attributes;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * Gets the name of the form section. This is not the same as the HTML name.
338
+	 *
339
+	 * @throws EE_Error
340
+	 * @return string
341
+	 */
342
+	public function name()
343
+	{
344
+		if (! $this->_construction_finalized) {
345
+			throw new EE_Error(sprintf(__('You cannot use the form section\s name until _construct_finalize has been called on it (when we set the name). It was called on a form section of type \'s\'',
346
+				'event_espresso'), get_class($this)));
347
+		}
348
+		return $this->_name;
349
+	}
350
+
351
+
352
+
353
+	/**
354
+	 * Gets the parent section
355
+	 *
356
+	 * @return EE_Form_Section_Proper
357
+	 */
358
+	public function parent_section()
359
+	{
360
+		return $this->_parent_section;
361
+	}
362
+
363
+
364
+
365
+	/**
366
+	 * returns HTML for generating the opening form HTML tag (<form>)
367
+	 *
368
+	 * @param string $action           the URL the form is submitted to
369
+	 * @param string $method           POST (default) or GET
370
+	 * @param string $other_attributes anything else added to the form open tag, MUST BE VALID HTML
371
+	 * @return string
372
+	 */
373
+	public function form_open($action = '', $method = '', $other_attributes = '')
374
+	{
375
+		if (! empty($action)) {
376
+			$this->set_action($action);
377
+		}
378
+		if (! empty($method)) {
379
+			$this->set_method($method);
380
+		}
381
+		$html = EEH_HTML::nl(1, 'form') . '<form';
382
+		$html .= $this->html_id() !== '' ? ' id="' . $this->get_html_id_for_form($this->html_id()) . '"' : '';
383
+		$html .= ' action="' . $this->action() . '"';
384
+		$html .= ' method="' . $this->method() . '"';
385
+		$html .= $other_attributes . '>';
386
+		return $html;
387
+	}
388
+
389
+
390
+
391
+	/**
392
+	 * ensures that html id for form either ends in "-form" or "-frm"
393
+	 * so that id doesn't conflict/collide with other elements
394
+	 *
395
+	 * @param string $html_id
396
+	 * @return string
397
+	 */
398
+	protected function get_html_id_for_form($html_id)
399
+	{
400
+		$strlen = strlen($html_id);
401
+		$html_id = strpos($html_id, '-form') === $strlen-5 || strpos($html_id, '-frm') === $strlen - 4
402
+			? $html_id
403
+			: $html_id . '-frm';
404
+		return $html_id;
405
+	}
406
+
407
+
408
+
409
+	/**
410
+	 * returns HTML for generating the closing form HTML tag (</form>)
411
+	 *
412
+	 * @return string
413
+	 */
414
+	public function form_close()
415
+	{
416
+		return EEH_HTML::nl(-1, 'form')
417
+			   . '</form>'
418
+			   . EEH_HTML::nl()
419
+			   . '<!-- end of ee-'
420
+			   . $this->html_id()
421
+			   . '-form -->'
422
+			   . EEH_HTML::nl();
423
+	}
424
+
425
+
426
+
427
+	/**
428
+	 * enqueues JS (and CSS) for the form (ie immediately call wp_enqueue_script and
429
+	 * wp_enqueue_style; the scripts could have optionally been registered earlier)
430
+	 * Default does nothing, but child classes can override
431
+	 *
432
+	 * @return void
433
+	 */
434
+	public function enqueue_js()
435
+	{
436
+		//defaults to enqueue NO js or css
437
+	}
438
+
439
+
440
+
441
+	/**
442
+	 * Adds any extra data needed by js. Eventually we'll call wp_localize_script
443
+	 * with it, and it will be on each form section's 'other_data' property.
444
+	 * By default nothing is added, but child classes can extend this method to add something.
445
+	 * Eg, if you have an input that will cause a modal dialog to appear,
446
+	 * here you could add an entry like 'modal_dialog_inputs' to this array
447
+	 * to map between the input's html ID and the modal dialogue's ID, so that
448
+	 * your JS code will know where to find the modal dialog when the input is pressed.
449
+	 * Eg $form_other_js_data['modal_dialog_inputs']['some-input-id']='modal-dialog-id';
450
+	 *
451
+	 * @param array $form_other_js_data
452
+	 * @return array
453
+	 */
454
+	public function get_other_js_data($form_other_js_data = array())
455
+	{
456
+		return $form_other_js_data;
457
+	}
458
+
459
+
460
+
461
+	/**
462
+	 * This isn't just the name of an input, it's a path pointing to an input. The
463
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
464
+	 * dot-dot-slash (../) means to ascend into the parent section.
465
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
466
+	 * which will be returned.
467
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
468
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
469
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
470
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
471
+	 * Etc
472
+	 *
473
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
474
+	 * @return EE_Form_Section_Base
475
+	 */
476
+	public function find_section_from_path($form_section_path)
477
+	{
478
+		if (strpos($form_section_path, '/') === 0) {
479
+			$form_section_path = substr($form_section_path, strlen('/'));
480
+		}
481
+		if (empty($form_section_path)) {
482
+			return $this;
483
+		}
484
+		if (strpos($form_section_path, '../') === 0) {
485
+			$parent = $this->parent_section();
486
+			$form_section_path = substr($form_section_path, strlen('../'));
487
+			if ($parent instanceof EE_Form_Section_Base) {
488
+				return $parent->find_section_from_path($form_section_path);
489
+			} elseif (empty($form_section_path)) {
490
+				return $this;
491
+			}
492
+		}
493
+		//couldn't find it using simple parent following
494
+		return null;
495
+	}
496 496
 
497 497
 
498 498
 }
Please login to merge, or discard this patch.
core/EE_Request_Handler.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 
276 276
 
277 277
     /**
278
-     * @param $string
278
+     * @param string $string
279 279
      * @return void
280 280
      */
281 281
     public function add_output($string)
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 
328 328
 
329 329
     /**
330
-     * @return    mixed
330
+     * @return    boolean
331 331
      */
332 332
     public function is_espresso_page()
333 333
     {
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
     /**
390 390
      * remove param
391 391
      *
392
-     * @param $key
392
+     * @param string $key
393 393
      * @return    void
394 394
      */
395 395
     public function un_set($key)
Please login to merge, or discard this patch.
Indentation   +383 added lines, -383 removed lines patch added patch discarded remove patch
@@ -13,389 +13,389 @@
 block discarded – undo
13 13
 final class EE_Request_Handler implements InterminableInterface
14 14
 {
15 15
 
16
-    /**
17
-     * @var EE_Request $request
18
-     */
19
-    private $request;
20
-
21
-    /**
22
-     * @var array $_notice
23
-     */
24
-    private $_notice = array();
25
-
26
-    /**
27
-     * rendered output to be returned to WP
28
-     *
29
-     * @var string $_output
30
-     */
31
-    private $_output = '';
32
-
33
-    /**
34
-     * whether current request is via AJAX
35
-     *
36
-     * @var boolean $ajax
37
-     */
38
-    public $ajax = false;
39
-
40
-    /**
41
-     * whether current request is via AJAX from the frontend of the site
42
-     *
43
-     * @var boolean $front_ajax
44
-     */
45
-    public $front_ajax = false;
46
-
47
-
48
-
49
-    /**
50
-     * @param  EE_Request $request
51
-     */
52
-    public function __construct(EE_Request $request)
53
-    {
54
-        $this->request = $request;
55
-        $this->ajax = $this->request->ajax;
56
-        $this->front_ajax = $this->request->front_ajax;
57
-        do_action('AHEE__EE_Request_Handler__construct__complete');
58
-    }
59
-
60
-
61
-
62
-    /**
63
-     * @param WP $wp
64
-     * @return void
65
-     * @throws EE_Error
66
-     * @throws ReflectionException
67
-     */
68
-    public function parse_request($wp = null)
69
-    {
70
-        //if somebody forgot to provide us with WP, that's ok because its global
71
-        if (! $wp instanceof WP) {
72
-            global $wp;
73
-        }
74
-        $this->set_request_vars($wp);
75
-    }
76
-
77
-
78
-
79
-    /**
80
-     * @param WP $wp
81
-     * @return void
82
-     * @throws EE_Error
83
-     * @throws ReflectionException
84
-     */
85
-    public function set_request_vars($wp = null)
86
-    {
87
-        if (! is_admin()) {
88
-            // set request post_id
89
-            $this->request->set('post_id', $this->get_post_id_from_request($wp));
90
-            // set request post name
91
-            $this->request->set('post_name', $this->get_post_name_from_request($wp));
92
-            // set request post_type
93
-            $this->request->set('post_type', $this->get_post_type_from_request($wp));
94
-            // true or false ? is this page being used by EE ?
95
-            $this->set_espresso_page();
96
-        }
97
-    }
98
-
99
-
100
-
101
-    /**
102
-     * @param WP $wp
103
-     * @return int
104
-     */
105
-    public function get_post_id_from_request($wp = null)
106
-    {
107
-        if (! $wp instanceof WP) {
108
-            global $wp;
109
-        }
110
-        $post_id = null;
111
-        if (isset($wp->query_vars['p'])) {
112
-            $post_id = $wp->query_vars['p'];
113
-        }
114
-        if (! $post_id && isset($wp->query_vars['page_id'])) {
115
-            $post_id = $wp->query_vars['page_id'];
116
-        }
117
-        if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) {
118
-            $post_id = basename($wp->request);
119
-        }
120
-        return $post_id;
121
-    }
122
-
123
-
124
-
125
-    /**
126
-     * @param WP $wp
127
-     * @return string
128
-     */
129
-    public function get_post_name_from_request($wp = null)
130
-    {
131
-        if (! $wp instanceof WP) {
132
-            global $wp;
133
-        }
134
-        $post_name = null;
135
-        if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
136
-            $post_name = $wp->query_vars['name'];
137
-        }
138
-        if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
139
-            $post_name = $wp->query_vars['pagename'];
140
-        }
141
-        if (! $post_name && $wp->request !== null && ! empty($wp->request)) {
142
-            $possible_post_name = basename($wp->request);
143
-            if (! is_numeric($possible_post_name)) {
144
-                /** @type WPDB $wpdb */
145
-                global $wpdb;
146
-                $SQL =
147
-                    "SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s";
148
-                $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));
149
-                if ($possible_post_name) {
150
-                    $post_name = $possible_post_name;
151
-                }
152
-            }
153
-        }
154
-        if (! $post_name && $this->get('post_id')) {
155
-            /** @type WPDB $wpdb */
156
-            global $wpdb;
157
-            $SQL =
158
-                "SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d";
159
-            $possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id')));
160
-            if ($possible_post_name) {
161
-                $post_name = $possible_post_name;
162
-            }
163
-        }
164
-        return $post_name;
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * @param WP $wp
171
-     * @return mixed
172
-     */
173
-    public function get_post_type_from_request($wp = null)
174
-    {
175
-        if (! $wp instanceof WP) {
176
-            global $wp;
177
-        }
178
-        return isset($wp->query_vars['post_type'])
179
-            ? $wp->query_vars['post_type']
180
-            : null;
181
-    }
182
-
183
-
184
-
185
-    /**
186
-     * Just a helper method for getting the url for the displayed page.
187
-     *
188
-     * @param  WP $wp
189
-     * @return string
190
-     */
191
-    public function get_current_page_permalink($wp = null)
192
-    {
193
-        $post_id = $this->get_post_id_from_request($wp);
194
-        if ($post_id) {
195
-            $current_page_permalink = get_permalink($post_id);
196
-        } else {
197
-            if (! $wp instanceof WP) {
198
-                global $wp;
199
-            }
200
-            if ($wp->request) {
201
-                $current_page_permalink = site_url($wp->request);
202
-            } else {
203
-                $current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));
204
-            }
205
-        }
206
-        return $current_page_permalink;
207
-    }
208
-
209
-
210
-
211
-    /**
212
-     * @return bool
213
-     * @throws EE_Error
214
-     * @throws ReflectionException
215
-     */
216
-    public function test_for_espresso_page()
217
-    {
218
-        global $wp;
219
-        /** @type EE_CPT_Strategy $EE_CPT_Strategy */
220
-        $EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy');
221
-        $espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();
222
-        if (is_array($espresso_CPT_taxonomies)) {
223
-            foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) {
224
-                if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) {
225
-                    return true;
226
-                }
227
-            }
228
-        }
229
-        // load espresso CPT endpoints
230
-        $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
231
-        $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
232
-        $post_types = (array)$this->get('post_type');
233
-        foreach ($post_types as $post_type) {
234
-            // was a post name passed ?
235
-            if (isset($post_type_CPT_endpoints[$post_type])) {
236
-                // kk we know this is an espresso page, but is it a specific post ?
237
-                if (! $this->get('post_name')) {
238
-                    // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
239
-                    $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')])
240
-                        ? $post_type_CPT_endpoints[$this->get('post_type')]
241
-                        : '';
242
-                    // if the post type matches on of our then set the endpoint
243
-                    if ($post_name) {
244
-                        $this->set('post_name', $post_name);
245
-                    }
246
-                }
247
-                return true;
248
-            }
249
-        }
250
-        return false;
251
-    }
252
-    /**
253
-     * @param $key
254
-     * @param $value
255
-     * @return    void
256
-     */
257
-    public function set_notice($key, $value)
258
-    {
259
-        $this->_notice[$key] = $value;
260
-    }
261
-
262
-
263
-
264
-    /**
265
-     * @param $key
266
-     * @return    mixed
267
-     */
268
-    public function get_notice($key)
269
-    {
270
-        return isset($this->_notice[$key])
271
-            ? $this->_notice[$key]
272
-            : null;
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     * @param $string
279
-     * @return void
280
-     */
281
-    public function add_output($string)
282
-    {
283
-        $this->_output .= $string;
284
-    }
285
-
286
-
287
-
288
-    /**
289
-     * @return string
290
-     */
291
-    public function get_output()
292
-    {
293
-        return $this->_output;
294
-    }
295
-
296
-
297
-
298
-    /**
299
-     * @param $item
300
-     * @param $key
301
-     */
302
-    public function sanitize_text_field_for_array_walk(&$item, &$key)
303
-    {
304
-        $item = strpos($item, 'email') !== false
305
-            ? sanitize_email($item)
306
-            : sanitize_text_field($item);
307
-    }
308
-
309
-
310
-
311
-    /**
312
-     * @param null|bool $value
313
-     * @return void
314
-     * @throws EE_Error
315
-     * @throws ReflectionException
316
-     */
317
-    public function set_espresso_page($value = null)
318
-    {
319
-        $this->request->set(
320
-            'is_espresso_page',
321
-            ! empty($value)
322
-                ? $value
323
-                : $this->test_for_espresso_page()
324
-        );
325
-    }
326
-
327
-
328
-
329
-    /**
330
-     * @return    mixed
331
-     */
332
-    public function is_espresso_page()
333
-    {
334
-        return $this->request->is_set('is_espresso_page');
335
-    }
336
-
337
-
338
-
339
-    /**
340
-     * returns contents of $_REQUEST
341
-     *
342
-     * @return array
343
-     */
344
-    public function params()
345
-    {
346
-        return $this->request->params();
347
-    }
348
-
349
-
350
-
351
-    /**
352
-     * @param      $key
353
-     * @param      $value
354
-     * @param bool $override_ee
355
-     * @return    void
356
-     */
357
-    public function set($key, $value, $override_ee = false)
358
-    {
359
-        $this->request->set($key, $value, $override_ee);
360
-    }
361
-
362
-
363
-
364
-    /**
365
-     * @param      $key
366
-     * @param null $default
367
-     * @return    mixed
368
-     */
369
-    public function get($key, $default = null)
370
-    {
371
-        return $this->request->get($key, $default);
372
-    }
373
-
374
-
375
-
376
-    /**
377
-     * check if param exists
378
-     *
379
-     * @param $key
380
-     * @return    boolean
381
-     */
382
-    public function is_set($key)
383
-    {
384
-        return $this->request->is_set($key);
385
-    }
386
-
387
-
388
-
389
-    /**
390
-     * remove param
391
-     *
392
-     * @param $key
393
-     * @return    void
394
-     */
395
-    public function un_set($key)
396
-    {
397
-        $this->request->un_set($key);
398
-    }
16
+	/**
17
+	 * @var EE_Request $request
18
+	 */
19
+	private $request;
20
+
21
+	/**
22
+	 * @var array $_notice
23
+	 */
24
+	private $_notice = array();
25
+
26
+	/**
27
+	 * rendered output to be returned to WP
28
+	 *
29
+	 * @var string $_output
30
+	 */
31
+	private $_output = '';
32
+
33
+	/**
34
+	 * whether current request is via AJAX
35
+	 *
36
+	 * @var boolean $ajax
37
+	 */
38
+	public $ajax = false;
39
+
40
+	/**
41
+	 * whether current request is via AJAX from the frontend of the site
42
+	 *
43
+	 * @var boolean $front_ajax
44
+	 */
45
+	public $front_ajax = false;
46
+
47
+
48
+
49
+	/**
50
+	 * @param  EE_Request $request
51
+	 */
52
+	public function __construct(EE_Request $request)
53
+	{
54
+		$this->request = $request;
55
+		$this->ajax = $this->request->ajax;
56
+		$this->front_ajax = $this->request->front_ajax;
57
+		do_action('AHEE__EE_Request_Handler__construct__complete');
58
+	}
59
+
60
+
61
+
62
+	/**
63
+	 * @param WP $wp
64
+	 * @return void
65
+	 * @throws EE_Error
66
+	 * @throws ReflectionException
67
+	 */
68
+	public function parse_request($wp = null)
69
+	{
70
+		//if somebody forgot to provide us with WP, that's ok because its global
71
+		if (! $wp instanceof WP) {
72
+			global $wp;
73
+		}
74
+		$this->set_request_vars($wp);
75
+	}
76
+
77
+
78
+
79
+	/**
80
+	 * @param WP $wp
81
+	 * @return void
82
+	 * @throws EE_Error
83
+	 * @throws ReflectionException
84
+	 */
85
+	public function set_request_vars($wp = null)
86
+	{
87
+		if (! is_admin()) {
88
+			// set request post_id
89
+			$this->request->set('post_id', $this->get_post_id_from_request($wp));
90
+			// set request post name
91
+			$this->request->set('post_name', $this->get_post_name_from_request($wp));
92
+			// set request post_type
93
+			$this->request->set('post_type', $this->get_post_type_from_request($wp));
94
+			// true or false ? is this page being used by EE ?
95
+			$this->set_espresso_page();
96
+		}
97
+	}
98
+
99
+
100
+
101
+	/**
102
+	 * @param WP $wp
103
+	 * @return int
104
+	 */
105
+	public function get_post_id_from_request($wp = null)
106
+	{
107
+		if (! $wp instanceof WP) {
108
+			global $wp;
109
+		}
110
+		$post_id = null;
111
+		if (isset($wp->query_vars['p'])) {
112
+			$post_id = $wp->query_vars['p'];
113
+		}
114
+		if (! $post_id && isset($wp->query_vars['page_id'])) {
115
+			$post_id = $wp->query_vars['page_id'];
116
+		}
117
+		if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) {
118
+			$post_id = basename($wp->request);
119
+		}
120
+		return $post_id;
121
+	}
122
+
123
+
124
+
125
+	/**
126
+	 * @param WP $wp
127
+	 * @return string
128
+	 */
129
+	public function get_post_name_from_request($wp = null)
130
+	{
131
+		if (! $wp instanceof WP) {
132
+			global $wp;
133
+		}
134
+		$post_name = null;
135
+		if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
136
+			$post_name = $wp->query_vars['name'];
137
+		}
138
+		if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
139
+			$post_name = $wp->query_vars['pagename'];
140
+		}
141
+		if (! $post_name && $wp->request !== null && ! empty($wp->request)) {
142
+			$possible_post_name = basename($wp->request);
143
+			if (! is_numeric($possible_post_name)) {
144
+				/** @type WPDB $wpdb */
145
+				global $wpdb;
146
+				$SQL =
147
+					"SELECT ID from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND post_name=%s";
148
+				$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));
149
+				if ($possible_post_name) {
150
+					$post_name = $possible_post_name;
151
+				}
152
+			}
153
+		}
154
+		if (! $post_name && $this->get('post_id')) {
155
+			/** @type WPDB $wpdb */
156
+			global $wpdb;
157
+			$SQL =
158
+				"SELECT post_name from {$wpdb->posts} WHERE post_status NOT IN ('auto-draft', 'inherit', 'trash') AND ID=%d";
159
+			$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id')));
160
+			if ($possible_post_name) {
161
+				$post_name = $possible_post_name;
162
+			}
163
+		}
164
+		return $post_name;
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * @param WP $wp
171
+	 * @return mixed
172
+	 */
173
+	public function get_post_type_from_request($wp = null)
174
+	{
175
+		if (! $wp instanceof WP) {
176
+			global $wp;
177
+		}
178
+		return isset($wp->query_vars['post_type'])
179
+			? $wp->query_vars['post_type']
180
+			: null;
181
+	}
182
+
183
+
184
+
185
+	/**
186
+	 * Just a helper method for getting the url for the displayed page.
187
+	 *
188
+	 * @param  WP $wp
189
+	 * @return string
190
+	 */
191
+	public function get_current_page_permalink($wp = null)
192
+	{
193
+		$post_id = $this->get_post_id_from_request($wp);
194
+		if ($post_id) {
195
+			$current_page_permalink = get_permalink($post_id);
196
+		} else {
197
+			if (! $wp instanceof WP) {
198
+				global $wp;
199
+			}
200
+			if ($wp->request) {
201
+				$current_page_permalink = site_url($wp->request);
202
+			} else {
203
+				$current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));
204
+			}
205
+		}
206
+		return $current_page_permalink;
207
+	}
208
+
209
+
210
+
211
+	/**
212
+	 * @return bool
213
+	 * @throws EE_Error
214
+	 * @throws ReflectionException
215
+	 */
216
+	public function test_for_espresso_page()
217
+	{
218
+		global $wp;
219
+		/** @type EE_CPT_Strategy $EE_CPT_Strategy */
220
+		$EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy');
221
+		$espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();
222
+		if (is_array($espresso_CPT_taxonomies)) {
223
+			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy => $details) {
224
+				if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) {
225
+					return true;
226
+				}
227
+			}
228
+		}
229
+		// load espresso CPT endpoints
230
+		$espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
231
+		$post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
232
+		$post_types = (array)$this->get('post_type');
233
+		foreach ($post_types as $post_type) {
234
+			// was a post name passed ?
235
+			if (isset($post_type_CPT_endpoints[$post_type])) {
236
+				// kk we know this is an espresso page, but is it a specific post ?
237
+				if (! $this->get('post_name')) {
238
+					// there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
239
+					$post_name = isset($post_type_CPT_endpoints[$this->get('post_type')])
240
+						? $post_type_CPT_endpoints[$this->get('post_type')]
241
+						: '';
242
+					// if the post type matches on of our then set the endpoint
243
+					if ($post_name) {
244
+						$this->set('post_name', $post_name);
245
+					}
246
+				}
247
+				return true;
248
+			}
249
+		}
250
+		return false;
251
+	}
252
+	/**
253
+	 * @param $key
254
+	 * @param $value
255
+	 * @return    void
256
+	 */
257
+	public function set_notice($key, $value)
258
+	{
259
+		$this->_notice[$key] = $value;
260
+	}
261
+
262
+
263
+
264
+	/**
265
+	 * @param $key
266
+	 * @return    mixed
267
+	 */
268
+	public function get_notice($key)
269
+	{
270
+		return isset($this->_notice[$key])
271
+			? $this->_notice[$key]
272
+			: null;
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 * @param $string
279
+	 * @return void
280
+	 */
281
+	public function add_output($string)
282
+	{
283
+		$this->_output .= $string;
284
+	}
285
+
286
+
287
+
288
+	/**
289
+	 * @return string
290
+	 */
291
+	public function get_output()
292
+	{
293
+		return $this->_output;
294
+	}
295
+
296
+
297
+
298
+	/**
299
+	 * @param $item
300
+	 * @param $key
301
+	 */
302
+	public function sanitize_text_field_for_array_walk(&$item, &$key)
303
+	{
304
+		$item = strpos($item, 'email') !== false
305
+			? sanitize_email($item)
306
+			: sanitize_text_field($item);
307
+	}
308
+
309
+
310
+
311
+	/**
312
+	 * @param null|bool $value
313
+	 * @return void
314
+	 * @throws EE_Error
315
+	 * @throws ReflectionException
316
+	 */
317
+	public function set_espresso_page($value = null)
318
+	{
319
+		$this->request->set(
320
+			'is_espresso_page',
321
+			! empty($value)
322
+				? $value
323
+				: $this->test_for_espresso_page()
324
+		);
325
+	}
326
+
327
+
328
+
329
+	/**
330
+	 * @return    mixed
331
+	 */
332
+	public function is_espresso_page()
333
+	{
334
+		return $this->request->is_set('is_espresso_page');
335
+	}
336
+
337
+
338
+
339
+	/**
340
+	 * returns contents of $_REQUEST
341
+	 *
342
+	 * @return array
343
+	 */
344
+	public function params()
345
+	{
346
+		return $this->request->params();
347
+	}
348
+
349
+
350
+
351
+	/**
352
+	 * @param      $key
353
+	 * @param      $value
354
+	 * @param bool $override_ee
355
+	 * @return    void
356
+	 */
357
+	public function set($key, $value, $override_ee = false)
358
+	{
359
+		$this->request->set($key, $value, $override_ee);
360
+	}
361
+
362
+
363
+
364
+	/**
365
+	 * @param      $key
366
+	 * @param null $default
367
+	 * @return    mixed
368
+	 */
369
+	public function get($key, $default = null)
370
+	{
371
+		return $this->request->get($key, $default);
372
+	}
373
+
374
+
375
+
376
+	/**
377
+	 * check if param exists
378
+	 *
379
+	 * @param $key
380
+	 * @return    boolean
381
+	 */
382
+	public function is_set($key)
383
+	{
384
+		return $this->request->is_set($key);
385
+	}
386
+
387
+
388
+
389
+	/**
390
+	 * remove param
391
+	 *
392
+	 * @param $key
393
+	 * @return    void
394
+	 */
395
+	public function un_set($key)
396
+	{
397
+		$this->request->un_set($key);
398
+	}
399 399
 
400 400
 
401 401
 
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -68,7 +68,7 @@  discard block
 block discarded – undo
68 68
     public function parse_request($wp = null)
69 69
     {
70 70
         //if somebody forgot to provide us with WP, that's ok because its global
71
-        if (! $wp instanceof WP) {
71
+        if ( ! $wp instanceof WP) {
72 72
             global $wp;
73 73
         }
74 74
         $this->set_request_vars($wp);
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
      */
85 85
     public function set_request_vars($wp = null)
86 86
     {
87
-        if (! is_admin()) {
87
+        if ( ! is_admin()) {
88 88
             // set request post_id
89 89
             $this->request->set('post_id', $this->get_post_id_from_request($wp));
90 90
             // set request post name
@@ -104,17 +104,17 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function get_post_id_from_request($wp = null)
106 106
     {
107
-        if (! $wp instanceof WP) {
107
+        if ( ! $wp instanceof WP) {
108 108
             global $wp;
109 109
         }
110 110
         $post_id = null;
111 111
         if (isset($wp->query_vars['p'])) {
112 112
             $post_id = $wp->query_vars['p'];
113 113
         }
114
-        if (! $post_id && isset($wp->query_vars['page_id'])) {
114
+        if ( ! $post_id && isset($wp->query_vars['page_id'])) {
115 115
             $post_id = $wp->query_vars['page_id'];
116 116
         }
117
-        if (! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) {
117
+        if ( ! $post_id && $wp->request !== null && is_numeric(basename($wp->request))) {
118 118
             $post_id = basename($wp->request);
119 119
         }
120 120
         return $post_id;
@@ -128,19 +128,19 @@  discard block
 block discarded – undo
128 128
      */
129 129
     public function get_post_name_from_request($wp = null)
130 130
     {
131
-        if (! $wp instanceof WP) {
131
+        if ( ! $wp instanceof WP) {
132 132
             global $wp;
133 133
         }
134 134
         $post_name = null;
135 135
         if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
136 136
             $post_name = $wp->query_vars['name'];
137 137
         }
138
-        if (! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
138
+        if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
139 139
             $post_name = $wp->query_vars['pagename'];
140 140
         }
141
-        if (! $post_name && $wp->request !== null && ! empty($wp->request)) {
141
+        if ( ! $post_name && $wp->request !== null && ! empty($wp->request)) {
142 142
             $possible_post_name = basename($wp->request);
143
-            if (! is_numeric($possible_post_name)) {
143
+            if ( ! is_numeric($possible_post_name)) {
144 144
                 /** @type WPDB $wpdb */
145 145
                 global $wpdb;
146 146
                 $SQL =
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
                 }
152 152
             }
153 153
         }
154
-        if (! $post_name && $this->get('post_id')) {
154
+        if ( ! $post_name && $this->get('post_id')) {
155 155
             /** @type WPDB $wpdb */
156 156
             global $wpdb;
157 157
             $SQL =
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
      */
173 173
     public function get_post_type_from_request($wp = null)
174 174
     {
175
-        if (! $wp instanceof WP) {
175
+        if ( ! $wp instanceof WP) {
176 176
             global $wp;
177 177
         }
178 178
         return isset($wp->query_vars['post_type'])
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
         if ($post_id) {
195 195
             $current_page_permalink = get_permalink($post_id);
196 196
         } else {
197
-            if (! $wp instanceof WP) {
197
+            if ( ! $wp instanceof WP) {
198 198
                 global $wp;
199 199
             }
200 200
             if ($wp->request) {
@@ -229,12 +229,12 @@  discard block
 block discarded – undo
229 229
         // load espresso CPT endpoints
230 230
         $espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
231 231
         $post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
232
-        $post_types = (array)$this->get('post_type');
232
+        $post_types = (array) $this->get('post_type');
233 233
         foreach ($post_types as $post_type) {
234 234
             // was a post name passed ?
235 235
             if (isset($post_type_CPT_endpoints[$post_type])) {
236 236
                 // kk we know this is an espresso page, but is it a specific post ?
237
-                if (! $this->get('post_name')) {
237
+                if ( ! $this->get('post_name')) {
238 238
                     // there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
239 239
                     $post_name = isset($post_type_CPT_endpoints[$this->get('post_type')])
240 240
                         ? $post_type_CPT_endpoints[$this->get('post_type')]
Please login to merge, or discard this patch.
core/request_stack/EE_Request.core.php 2 patches
Indentation   +283 added lines, -283 removed lines patch added patch discarded remove patch
@@ -15,289 +15,289 @@
 block discarded – undo
15 15
 class EE_Request implements InterminableInterface
16 16
 {
17 17
 
18
-    /**
19
-     * $_GET parameters
20
-     *
21
-     * @var array $_get
22
-     */
23
-    private $_get;
24
-
25
-    /**
26
-     * $_POST parameters
27
-     *
28
-     * @var    array $_post
29
-     */
30
-    private $_post;
31
-
32
-    /**
33
-     * $_COOKIE parameters
34
-     *
35
-     * @var array $_cookie
36
-     */
37
-    private $_cookie;
38
-
39
-    /**
40
-     * $_REQUEST parameters
41
-     *
42
-     * @var array $_params
43
-     */
44
-    private $_params;
45
-
46
-    /**
47
-     * whether current request is via AJAX
48
-     *
49
-     * @access public
50
-     */
51
-    public $ajax = false;
52
-
53
-    /**
54
-     * whether current request is via AJAX from the frontend of the site
55
-     *
56
-     * @access public
57
-     */
58
-    public $front_ajax = false;
59
-
60
-    /**
61
-     * IP address for request
62
-     *
63
-     * @var string $_ip_address
64
-     */
65
-    private $_ip_address;
66
-
67
-
68
-
69
-    /**
70
-     * class constructor
71
-     *
72
-     * @access    public
73
-     * @param array $get
74
-     * @param array $post
75
-     * @param array $cookie
76
-     */
77
-    public function __construct(array $get, array $post, array $cookie)
78
-    {
79
-        // grab request vars
80
-        $this->_get = (array)$get;
81
-        $this->_post = (array)$post;
82
-        $this->_cookie = (array)$cookie;
83
-        $this->_params = array_merge($this->_get, $this->_post);
84
-        // AJAX ???
85
-        $this->ajax = defined('DOING_AJAX') ? true : false;
86
-        $this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1;
87
-        // grab user IP
88
-        $this->_ip_address = $this->_visitor_ip();
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * @return array
95
-     */
96
-    public function get_params()
97
-    {
98
-        return $this->_get;
99
-    }
100
-
101
-
102
-
103
-    /**
104
-     * @return array
105
-     */
106
-    public function post_params()
107
-    {
108
-        return $this->_post;
109
-    }
110
-
111
-
112
-
113
-    /**
114
-     * @return array
115
-     */
116
-    public function cookie_params()
117
-    {
118
-        return $this->_cookie;
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * returns contents of $_REQUEST
125
-     *
126
-     * @return array
127
-     */
128
-    public function params()
129
-    {
130
-        return $this->_params;
131
-    }
132
-
133
-
134
-
135
-    /**
136
-     * @param      $key
137
-     * @param      $value
138
-     * @param bool $override_ee
139
-     * @return    void
140
-     */
141
-    public function set($key, $value, $override_ee = false)
142
-    {
143
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
144
-        if (
145
-            $key !== 'ee'
146
-            || ($key === 'ee' && empty($this->_params['ee']))
147
-            || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
148
-        ) {
149
-            $this->_params[$key] = $value;
150
-        }
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * returns   the value for a request param if the given key exists
157
-     *
158
-     * @param       $key
159
-     * @param null  $default
160
-     * @return mixed
161
-     */
162
-    public function get($key, $default = null)
163
-    {
164
-        return $this->request_parameter_drill_down($key, $default, 'get');
165
-    }
166
-
167
-
168
-
169
-    /**
170
-     * check if param exists
171
-     * @param       $key
172
-     * @return bool
173
-     */
174
-    public function is_set($key)
175
-    {
176
-        return $this->request_parameter_drill_down($key);
177
-    }
178
-
179
-
180
-
181
-    /**
182
-     * the supplied key can be a simple string to represent a "top-level" request parameter
183
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
184
-     * by using square brackets to surround keys for deeper array elements.
185
-     * For example :
186
-     * if the supplied $key was: "first[second][third]"
187
-     * then this will attempt to drill down into the request parameter array to find a value.
188
-     * Given the following request parameters:
189
-     *  array(
190
-     *      'first' => array(
191
-     *          'second' => array(
192
-     *              'third' => 'has a value'
193
-     *          )
194
-     *      )
195
-     *  )
196
-     * would return true
197
-     *
198
-     * @param string $is_set_or_get
199
-     * @param        $key
200
-     * @param null   $default
201
-     * @param array  $request_params
202
-     * @return bool|mixed|null
203
-     */
204
-    private function request_parameter_drill_down(
205
-        $key,
206
-        $default = null,
207
-        $is_set_or_get = 'is_set',
208
-        array $request_params = array()
209
-    ) {
210
-        $request_params = ! empty($request_params)
211
-            ? $request_params
212
-            : $this->_params;
213
-        // does incoming key represent an array like 'first[second][third]'  ?
214
-        if (strpos($key, '[') !== false) {
215
-            // turn it into an actual array
216
-            $key = str_replace(']', '', $key);
217
-            $keys = explode('[', $key);
218
-            $key = array_shift($keys);
219
-            // check if top level key exists
220
-            if (isset($request_params[$key])) {
221
-                // build a new key to pass along like: 'second[third]'
222
-                // or just 'second' depending on depth of keys
223
-                $key_string = array_shift($keys);
224
-                if (! empty($keys)) {
225
-                    $key_string .= '[' . implode('][', $keys) . ']';
226
-                }
227
-                return $this->request_parameter_drill_down(
228
-                    $key_string,
229
-                    $default,
230
-                    $is_set_or_get,
231
-                    $request_params[$key]
232
-                );
233
-            }
234
-        }
235
-        if ($is_set_or_get === 'is_set') {
236
-            return isset($request_params[$key]);
237
-        }
238
-        return isset($request_params[$key])
239
-            ? $request_params[$key]
240
-            : $default;
241
-    }
242
-
243
-
244
-
245
-    /**
246
-     * remove param
247
-     * @param      $key
248
-     * @param bool $unset_from_global_too
249
-     */
250
-    public function un_set($key, $unset_from_global_too = false)
251
-    {
252
-        unset($this->_params[$key]);
253
-        if ($unset_from_global_too) {
254
-            unset($_REQUEST[$key]);
255
-        }
256
-    }
257
-
258
-
259
-
260
-    /**
261
-     * @return string
262
-     */
263
-    public function ip_address()
264
-    {
265
-        return $this->_ip_address;
266
-    }
267
-
268
-
269
-
270
-    /**
271
-     * _visitor_ip
272
-     *    attempt to get IP address of current visitor from server
273
-     * plz see: http://stackoverflow.com/a/2031935/1475279
274
-     *
275
-     * @access public
276
-     * @return string
277
-     */
278
-    private function _visitor_ip()
279
-    {
280
-        $visitor_ip = '0.0.0.0';
281
-        $server_keys = array(
282
-            'HTTP_CLIENT_IP',
283
-            'HTTP_X_FORWARDED_FOR',
284
-            'HTTP_X_FORWARDED',
285
-            'HTTP_X_CLUSTER_CLIENT_IP',
286
-            'HTTP_FORWARDED_FOR',
287
-            'HTTP_FORWARDED',
288
-            'REMOTE_ADDR',
289
-        );
290
-        foreach ($server_keys as $key) {
291
-            if (isset($_SERVER[$key])) {
292
-                foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
293
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
294
-                        $visitor_ip = $ip;
295
-                    }
296
-                }
297
-            }
298
-        }
299
-        return $visitor_ip;
300
-    }
18
+	/**
19
+	 * $_GET parameters
20
+	 *
21
+	 * @var array $_get
22
+	 */
23
+	private $_get;
24
+
25
+	/**
26
+	 * $_POST parameters
27
+	 *
28
+	 * @var    array $_post
29
+	 */
30
+	private $_post;
31
+
32
+	/**
33
+	 * $_COOKIE parameters
34
+	 *
35
+	 * @var array $_cookie
36
+	 */
37
+	private $_cookie;
38
+
39
+	/**
40
+	 * $_REQUEST parameters
41
+	 *
42
+	 * @var array $_params
43
+	 */
44
+	private $_params;
45
+
46
+	/**
47
+	 * whether current request is via AJAX
48
+	 *
49
+	 * @access public
50
+	 */
51
+	public $ajax = false;
52
+
53
+	/**
54
+	 * whether current request is via AJAX from the frontend of the site
55
+	 *
56
+	 * @access public
57
+	 */
58
+	public $front_ajax = false;
59
+
60
+	/**
61
+	 * IP address for request
62
+	 *
63
+	 * @var string $_ip_address
64
+	 */
65
+	private $_ip_address;
66
+
67
+
68
+
69
+	/**
70
+	 * class constructor
71
+	 *
72
+	 * @access    public
73
+	 * @param array $get
74
+	 * @param array $post
75
+	 * @param array $cookie
76
+	 */
77
+	public function __construct(array $get, array $post, array $cookie)
78
+	{
79
+		// grab request vars
80
+		$this->_get = (array)$get;
81
+		$this->_post = (array)$post;
82
+		$this->_cookie = (array)$cookie;
83
+		$this->_params = array_merge($this->_get, $this->_post);
84
+		// AJAX ???
85
+		$this->ajax = defined('DOING_AJAX') ? true : false;
86
+		$this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1;
87
+		// grab user IP
88
+		$this->_ip_address = $this->_visitor_ip();
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * @return array
95
+	 */
96
+	public function get_params()
97
+	{
98
+		return $this->_get;
99
+	}
100
+
101
+
102
+
103
+	/**
104
+	 * @return array
105
+	 */
106
+	public function post_params()
107
+	{
108
+		return $this->_post;
109
+	}
110
+
111
+
112
+
113
+	/**
114
+	 * @return array
115
+	 */
116
+	public function cookie_params()
117
+	{
118
+		return $this->_cookie;
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * returns contents of $_REQUEST
125
+	 *
126
+	 * @return array
127
+	 */
128
+	public function params()
129
+	{
130
+		return $this->_params;
131
+	}
132
+
133
+
134
+
135
+	/**
136
+	 * @param      $key
137
+	 * @param      $value
138
+	 * @param bool $override_ee
139
+	 * @return    void
140
+	 */
141
+	public function set($key, $value, $override_ee = false)
142
+	{
143
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
144
+		if (
145
+			$key !== 'ee'
146
+			|| ($key === 'ee' && empty($this->_params['ee']))
147
+			|| ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
148
+		) {
149
+			$this->_params[$key] = $value;
150
+		}
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * returns   the value for a request param if the given key exists
157
+	 *
158
+	 * @param       $key
159
+	 * @param null  $default
160
+	 * @return mixed
161
+	 */
162
+	public function get($key, $default = null)
163
+	{
164
+		return $this->request_parameter_drill_down($key, $default, 'get');
165
+	}
166
+
167
+
168
+
169
+	/**
170
+	 * check if param exists
171
+	 * @param       $key
172
+	 * @return bool
173
+	 */
174
+	public function is_set($key)
175
+	{
176
+		return $this->request_parameter_drill_down($key);
177
+	}
178
+
179
+
180
+
181
+	/**
182
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
183
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
184
+	 * by using square brackets to surround keys for deeper array elements.
185
+	 * For example :
186
+	 * if the supplied $key was: "first[second][third]"
187
+	 * then this will attempt to drill down into the request parameter array to find a value.
188
+	 * Given the following request parameters:
189
+	 *  array(
190
+	 *      'first' => array(
191
+	 *          'second' => array(
192
+	 *              'third' => 'has a value'
193
+	 *          )
194
+	 *      )
195
+	 *  )
196
+	 * would return true
197
+	 *
198
+	 * @param string $is_set_or_get
199
+	 * @param        $key
200
+	 * @param null   $default
201
+	 * @param array  $request_params
202
+	 * @return bool|mixed|null
203
+	 */
204
+	private function request_parameter_drill_down(
205
+		$key,
206
+		$default = null,
207
+		$is_set_or_get = 'is_set',
208
+		array $request_params = array()
209
+	) {
210
+		$request_params = ! empty($request_params)
211
+			? $request_params
212
+			: $this->_params;
213
+		// does incoming key represent an array like 'first[second][third]'  ?
214
+		if (strpos($key, '[') !== false) {
215
+			// turn it into an actual array
216
+			$key = str_replace(']', '', $key);
217
+			$keys = explode('[', $key);
218
+			$key = array_shift($keys);
219
+			// check if top level key exists
220
+			if (isset($request_params[$key])) {
221
+				// build a new key to pass along like: 'second[third]'
222
+				// or just 'second' depending on depth of keys
223
+				$key_string = array_shift($keys);
224
+				if (! empty($keys)) {
225
+					$key_string .= '[' . implode('][', $keys) . ']';
226
+				}
227
+				return $this->request_parameter_drill_down(
228
+					$key_string,
229
+					$default,
230
+					$is_set_or_get,
231
+					$request_params[$key]
232
+				);
233
+			}
234
+		}
235
+		if ($is_set_or_get === 'is_set') {
236
+			return isset($request_params[$key]);
237
+		}
238
+		return isset($request_params[$key])
239
+			? $request_params[$key]
240
+			: $default;
241
+	}
242
+
243
+
244
+
245
+	/**
246
+	 * remove param
247
+	 * @param      $key
248
+	 * @param bool $unset_from_global_too
249
+	 */
250
+	public function un_set($key, $unset_from_global_too = false)
251
+	{
252
+		unset($this->_params[$key]);
253
+		if ($unset_from_global_too) {
254
+			unset($_REQUEST[$key]);
255
+		}
256
+	}
257
+
258
+
259
+
260
+	/**
261
+	 * @return string
262
+	 */
263
+	public function ip_address()
264
+	{
265
+		return $this->_ip_address;
266
+	}
267
+
268
+
269
+
270
+	/**
271
+	 * _visitor_ip
272
+	 *    attempt to get IP address of current visitor from server
273
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
274
+	 *
275
+	 * @access public
276
+	 * @return string
277
+	 */
278
+	private function _visitor_ip()
279
+	{
280
+		$visitor_ip = '0.0.0.0';
281
+		$server_keys = array(
282
+			'HTTP_CLIENT_IP',
283
+			'HTTP_X_FORWARDED_FOR',
284
+			'HTTP_X_FORWARDED',
285
+			'HTTP_X_CLUSTER_CLIENT_IP',
286
+			'HTTP_FORWARDED_FOR',
287
+			'HTTP_FORWARDED',
288
+			'REMOTE_ADDR',
289
+		);
290
+		foreach ($server_keys as $key) {
291
+			if (isset($_SERVER[$key])) {
292
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
293
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
294
+						$visitor_ip = $ip;
295
+					}
296
+				}
297
+			}
298
+		}
299
+		return $visitor_ip;
300
+	}
301 301
 
302 302
 
303 303
 
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -77,13 +77,13 @@  discard block
 block discarded – undo
77 77
     public function __construct(array $get, array $post, array $cookie)
78 78
     {
79 79
         // grab request vars
80
-        $this->_get = (array)$get;
81
-        $this->_post = (array)$post;
82
-        $this->_cookie = (array)$cookie;
80
+        $this->_get = (array) $get;
81
+        $this->_post = (array) $post;
82
+        $this->_cookie = (array) $cookie;
83 83
         $this->_params = array_merge($this->_get, $this->_post);
84 84
         // AJAX ???
85 85
         $this->ajax = defined('DOING_AJAX') ? true : false;
86
-        $this->front_ajax = $this->is_set('ee_front_ajax') && (int)$this->get('ee_front_ajax') === 1;
86
+        $this->front_ajax = $this->is_set('ee_front_ajax') && (int) $this->get('ee_front_ajax') === 1;
87 87
         // grab user IP
88 88
         $this->_ip_address = $this->_visitor_ip();
89 89
     }
@@ -221,8 +221,8 @@  discard block
 block discarded – undo
221 221
                 // build a new key to pass along like: 'second[third]'
222 222
                 // or just 'second' depending on depth of keys
223 223
                 $key_string = array_shift($keys);
224
-                if (! empty($keys)) {
225
-                    $key_string .= '[' . implode('][', $keys) . ']';
224
+                if ( ! empty($keys)) {
225
+                    $key_string .= '['.implode('][', $keys).']';
226 226
                 }
227 227
                 return $this->request_parameter_drill_down(
228 228
                     $key_string,
Please login to merge, or discard this patch.
core/services/loaders/Loader.php 1 patch
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -22,103 +22,103 @@
 block discarded – undo
22 22
 {
23 23
 
24 24
 
25
-    /**
26
-     * @var LoaderDecoratorInterface $new_loader
27
-     */
28
-    private $new_loader;
29
-
30
-
31
-    /**
32
-     * @var LoaderDecoratorInterface $shared_loader
33
-     */
34
-    private $shared_loader;
35
-
36
-
37
-
38
-    /**
39
-     * Loader constructor.
40
-     *
41
-     * @param LoaderDecoratorInterface|null $new_loader
42
-     * @param LoaderDecoratorInterface|null $shared_loader
43
-     * @throws InvalidInterfaceException
44
-     * @throws InvalidArgumentException
45
-     * @throws InvalidDataTypeException
46
-     */
47
-    public function __construct(LoaderDecoratorInterface $new_loader, LoaderDecoratorInterface $shared_loader)
48
-    {
49
-        $this->new_loader = $new_loader;
50
-        $this->shared_loader = $shared_loader;
51
-    }
52
-
53
-
54
-
55
-    /**
56
-     * @return LoaderDecoratorInterface
57
-     */
58
-    public function getNewLoader()
59
-    {
60
-        return $this->new_loader;
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * @return LoaderDecoratorInterface
67
-     */
68
-    public function getSharedLoader()
69
-    {
70
-        return $this->shared_loader;
71
-    }
72
-
73
-
74
-
75
-    /**
76
-     * @param string $fqcn
77
-     * @param array  $arguments
78
-     * @param bool   $shared
79
-     * @return mixed
80
-     */
81
-    public function load($fqcn, $arguments = array(), $shared = true)
82
-    {
83
-        return $shared
84
-            ? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
85
-            : $this->getNewLoader()->load($fqcn, $arguments, $shared);
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * @param string $fqcn
92
-     * @param array  $arguments
93
-     * @return mixed
94
-     */
95
-    public function getNew($fqcn, $arguments = array())
96
-    {
97
-        return $this->getNewLoader()->load($fqcn, $arguments, false);
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * @param string $fqcn
104
-     * @param array  $arguments
105
-     * @return mixed
106
-     */
107
-    public function getShared($fqcn, $arguments = array())
108
-    {
109
-        return $this->getSharedLoader()->load($fqcn, $arguments, true);
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * calls reset() on loaders if that method exists
116
-     */
117
-    public function reset()
118
-    {
119
-        $this->new_loader->reset();
120
-        $this->shared_loader->reset();
121
-    }
25
+	/**
26
+	 * @var LoaderDecoratorInterface $new_loader
27
+	 */
28
+	private $new_loader;
29
+
30
+
31
+	/**
32
+	 * @var LoaderDecoratorInterface $shared_loader
33
+	 */
34
+	private $shared_loader;
35
+
36
+
37
+
38
+	/**
39
+	 * Loader constructor.
40
+	 *
41
+	 * @param LoaderDecoratorInterface|null $new_loader
42
+	 * @param LoaderDecoratorInterface|null $shared_loader
43
+	 * @throws InvalidInterfaceException
44
+	 * @throws InvalidArgumentException
45
+	 * @throws InvalidDataTypeException
46
+	 */
47
+	public function __construct(LoaderDecoratorInterface $new_loader, LoaderDecoratorInterface $shared_loader)
48
+	{
49
+		$this->new_loader = $new_loader;
50
+		$this->shared_loader = $shared_loader;
51
+	}
52
+
53
+
54
+
55
+	/**
56
+	 * @return LoaderDecoratorInterface
57
+	 */
58
+	public function getNewLoader()
59
+	{
60
+		return $this->new_loader;
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * @return LoaderDecoratorInterface
67
+	 */
68
+	public function getSharedLoader()
69
+	{
70
+		return $this->shared_loader;
71
+	}
72
+
73
+
74
+
75
+	/**
76
+	 * @param string $fqcn
77
+	 * @param array  $arguments
78
+	 * @param bool   $shared
79
+	 * @return mixed
80
+	 */
81
+	public function load($fqcn, $arguments = array(), $shared = true)
82
+	{
83
+		return $shared
84
+			? $this->getSharedLoader()->load($fqcn, $arguments, $shared)
85
+			: $this->getNewLoader()->load($fqcn, $arguments, $shared);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * @param string $fqcn
92
+	 * @param array  $arguments
93
+	 * @return mixed
94
+	 */
95
+	public function getNew($fqcn, $arguments = array())
96
+	{
97
+		return $this->getNewLoader()->load($fqcn, $arguments, false);
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * @param string $fqcn
104
+	 * @param array  $arguments
105
+	 * @return mixed
106
+	 */
107
+	public function getShared($fqcn, $arguments = array())
108
+	{
109
+		return $this->getSharedLoader()->load($fqcn, $arguments, true);
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * calls reset() on loaders if that method exists
116
+	 */
117
+	public function reset()
118
+	{
119
+		$this->new_loader->reset();
120
+		$this->shared_loader->reset();
121
+	}
122 122
 
123 123
 }
124 124
 // End of file Loader.php
Please login to merge, or discard this patch.
core/libraries/batch/JobHandlers/DatetimeOffsetFix.php 2 patches
Indentation   +301 added lines, -301 removed lines patch added patch discarded remove patch
@@ -18,305 +18,305 @@
 block discarded – undo
18 18
 class DatetimeOffsetFix extends JobHandler
19 19
 {
20 20
 
21
-    /**
22
-     * Key for the option used to track which models have been processed when doing the batches.
23
-     */
24
-    const MODELS_TO_PROCESS_OPTION_KEY = 'ee_models_processed_for_datetime_offset_fix';
25
-
26
-
27
-    const COUNT_OF_MODELS_PROCESSED = 'ee_count_of_ee_models_processed_for_datetime_offset_fixed';
28
-
29
-    /**
30
-     * Key for the option used to track what the current offset is that will be applied when this tool is executed.
31
-     */
32
-    const OFFSET_TO_APPLY_OPTION_KEY = 'ee_datetime_offset_fix_offset_to_apply';
33
-
34
-
35
-    /**
36
-     * String labelling the datetime offset fix type for change-log entries.
37
-     */
38
-    const DATETIME_OFFSET_FIX_CHANGELOG_TYPE = 'datetime_offset_fix';
39
-
40
-
41
-    /**
42
-     * String labelling a datetime offset fix error for change-log entries.
43
-     */
44
-    const DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE = 'datetime_offset_fix_error';
45
-
46
-    /**
47
-     * @var EEM_Base[]
48
-     */
49
-    protected $models_with_datetime_fields = array();
50
-
51
-
52
-    /**
53
-     * Performs any necessary setup for starting the job. This is also a good
54
-     * place to setup the $job_arguments which will be used for subsequent HTTP requests
55
-     * when continue_job will be called
56
-     *
57
-     * @param JobParameters $job_parameters
58
-     * @throws BatchRequestException
59
-     * @return JobStepResponse
60
-     */
61
-    public function create_job(JobParameters $job_parameters)
62
-    {
63
-        $models_with_datetime_fields = $this->getModelsWithDatetimeFields();
64
-        //we'll be doing each model as a batch.
65
-        $job_parameters->set_job_size(count($models_with_datetime_fields));
66
-        return new JobStepResponse(
67
-            $job_parameters,
68
-            esc_html__('Starting Datetime Offset Fix', 'event_espresso')
69
-        );
70
-    }
71
-
72
-    /**
73
-     * Performs another step of the job
74
-     *
75
-     * @param JobParameters $job_parameters
76
-     * @param int           $batch_size
77
-     * @return JobStepResponse
78
-     * @throws \EE_Error
79
-     */
80
-    public function continue_job(JobParameters $job_parameters, $batch_size = 50)
81
-    {
82
-        $models_to_process = $this->getModelsWithDatetimeFields();
83
-        //let's pop off the a model and do the query to apply the offset.
84
-        $model_to_process = array_pop($models_to_process);
85
-        //update our record
86
-        $this->setModelsToProcess($models_to_process);
87
-        $this->processModel($model_to_process);
88
-        $this->updateCountOfModelsProcessed();
89
-        $job_parameters->set_units_processed($this->getCountOfModelsProcessed());
90
-        if (count($models_to_process) > 0) {
91
-            $job_parameters->set_status(JobParameters::status_continue);
92
-        } else {
93
-            $job_parameters->set_status(JobParameters::status_complete);
94
-        }
95
-        return new JobStepResponse(
96
-            $job_parameters,
97
-            sprintf(
98
-                esc_html__('Updated the offset for all datetime fields on the %s model.', 'event_espresso'),
99
-                $model_to_process
100
-            )
101
-        );
102
-    }
103
-
104
-    /**
105
-     * Performs any clean-up logic when we know the job is completed
106
-     *
107
-     * @param JobParameters $job_parameters
108
-     * @return JobStepResponse
109
-     * @throws BatchRequestException
110
-     */
111
-    public function cleanup_job(JobParameters $job_parameters)
112
-    {
113
-        //delete important saved options.
114
-        delete_option(self::MODELS_TO_PROCESS_OPTION_KEY);
115
-        delete_option(self::COUNT_OF_MODELS_PROCESSED);
116
-        return new JobStepResponse($job_parameters, esc_html__(
117
-            'Offset has been applied to all affected fields.',
118
-            'event_espresso'
119
-        ));
120
-    }
121
-
122
-
123
-    /**
124
-     * Contains the logic for processing a model and applying the datetime offset to affected fields on that model.
125
-     * @param string $model_class_name
126
-     * @throws \EE_Error
127
-     */
128
-    protected function processModel($model_class_name)
129
-    {
130
-        global $wpdb;
131
-        /** @var EEM_Base $model */
132
-        $model = $model_class_name::instance();
133
-        $original_offset = self::getOffset();
134
-        $sql_date_function = $original_offset > 0 ? 'DATE_ADD' : 'DATE_SUB';
135
-        $offset = abs($original_offset) * 60;
136
-        //since some affected models might have two tables, we have to get our tables and set up a query for each table.
137
-        foreach ($model->get_tables() as $table) {
138
-            $query = 'UPDATE ' . $table->get_table_name();
139
-            $fields_affected = array();
140
-            $inner_query = array();
141
-            foreach ($model->_get_fields_for_table($table->get_table_alias()) as $model_field) {
142
-                if ($model_field instanceof EE_Datetime_Field) {
143
-                    $inner_query[] = $model_field->get_table_column() . ' = '
144
-                                     . $sql_date_function . '('
145
-                                     . $model_field->get_table_column()
146
-                                     . ", INTERVAL $offset MINUTE)";
147
-                    $fields_affected[] = $model_field;
148
-                }
149
-            }
150
-            if (! $fields_affected) {
151
-                continue;
152
-            }
153
-            //k convert innerquery to string
154
-            $query .= ' SET ' . implode(',', $inner_query);
155
-            //execute query
156
-            $result = $wpdb->query($query);
157
-            //record log
158
-            if ($result !== false) {
159
-                $this->recordChangeLog($model, $original_offset, $table, $fields_affected);
160
-            } else {
161
-                //record error.
162
-                $error_message = $wpdb->last_error;
163
-                //handle the edgecases where last_error might be empty.
164
-                if (! $error_message) {
165
-                    $error_message = esc_html__('Unknown mysql error occured.', 'event_espresso');
166
-                }
167
-                $this->recordChangeLog($model, $original_offset, $table, $fields_affected, $error_message);
168
-            }
169
-        }
170
-    }
171
-
172
-
173
-    /**
174
-     * Records a changelog entry using the given information.
175
-     *
176
-     * @param EEM_Base              $model
177
-     * @param float                 $offset
178
-     * @param EE_Table_Base         $table
179
-     * @param EE_Model_Field_Base[] $model_fields_affected
180
-     * @param string                $error_message   If present then there was an error so let's record that instead.
181
-     * @throws \EE_Error
182
-     */
183
-    private function recordChangeLog(
184
-        EEM_Base $model,
185
-        $offset,
186
-        EE_Table_Base $table,
187
-        $model_fields_affected,
188
-        $error_message = ''
189
-    ) {
190
-        //setup $fields list.
191
-        $fields = array();
192
-        /** @var EE_Datetime_Field $model_field */
193
-        foreach ($model_fields_affected as $model_field) {
194
-            if (! $model_field instanceof EE_Datetime_Field) {
195
-                continue;
196
-            }
197
-            $fields[] = $model_field->get_name();
198
-        }
199
-        //setup the message for the changelog entry.
200
-        $message = $error_message
201
-            ? sprintf(
202
-                esc_html__(
203
-                    'The %1$s table for the %2$s model did not have the offset of %3$f applied to its fields (%4$s), because of the following error:%5$s',
204
-                    'event_espresso'
205
-                ),
206
-                $table->get_table_name(),
207
-                $model->get_this_model_name(),
208
-                $offset,
209
-                implode(',', $fields),
210
-                $error_message
211
-            )
212
-            : sprintf(
213
-                esc_html__(
214
-                    'The %1$s table for the %2$s model has had the offset of %3$f applied to its following fields: %4$s',
215
-                    'event_espresso'
216
-                ),
217
-                $table->get_table_name(),
218
-                $model->get_this_model_name(),
219
-                $offset,
220
-                implode(',', $fields)
221
-            );
222
-        //write to the log
223
-        $changelog = EE_Change_Log::new_instance(array(
224
-            'LOG_type' => $error_message
225
-                ? self::DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE
226
-                : self::DATETIME_OFFSET_FIX_CHANGELOG_TYPE,
227
-            'LOG_message' => $message
228
-        ));
229
-        $changelog->save();
230
-    }
231
-
232
-
233
-    /**
234
-     * Returns an array of models that have datetime fields.
235
-     * This array is added to a short lived transient cache to keep having to build this list to a minimum.
236
-     * @return array  an array of model class names.
237
-     */
238
-    private function getModelsWithDatetimeFields()
239
-    {
240
-        $this->getModelsToProcess();
241
-        if (! empty($this->models_with_datetime_fields)) {
242
-            return $this->models_with_datetime_fields;
243
-        }
244
-
245
-        $all_non_abstract_models = EE_Registry::instance()->non_abstract_db_models;
246
-        foreach ($all_non_abstract_models as $non_abstract_model) {
247
-            //get model instance
248
-            /** @var EEM_Base $non_abstract_model */
249
-            $non_abstract_model = $non_abstract_model::instance();
250
-            if ($non_abstract_model->get_a_field_of_type('EE_Datetime_Field') instanceof EE_Datetime_Field) {
251
-                $this->models_with_datetime_fields[] = get_class($non_abstract_model);
252
-            }
253
-        }
254
-        $this->setModelsToProcess($this->models_with_datetime_fields);
255
-        return $this->models_with_datetime_fields;
256
-    }
257
-
258
-
259
-    /**
260
-     * This simply records the models that have been processed with our tracking option.
261
-     * @param array $models_to_set  array of model class names.
262
-     */
263
-    private function setModelsToProcess($models_to_set)
264
-    {
265
-        update_option(self::MODELS_TO_PROCESS_OPTION_KEY, $models_to_set);
266
-    }
267
-
268
-
269
-    /**
270
-     * Used to keep track of how many models have been processed for the batch
271
-     * @param $count
272
-     */
273
-    private function updateCountOfModelsProcessed($count = 1)
274
-    {
275
-        $count = $this->getCountOfModelsProcessed() + (int) $count;
276
-        update_option(self::COUNT_OF_MODELS_PROCESSED, $count);
277
-    }
278
-
279
-
280
-    /**
281
-     * Retrieve the tracked number of models processed between requests.
282
-     * @return int
283
-     */
284
-    private function getCountOfModelsProcessed()
285
-    {
286
-        return (int) get_option(self::COUNT_OF_MODELS_PROCESSED, 0);
287
-    }
288
-
289
-
290
-    /**
291
-     * Returns the models that are left to process.
292
-     * @return array  an array of model class names.
293
-     */
294
-    private function getModelsToProcess()
295
-    {
296
-        if (empty($this->models_with_datetime_fields)) {
297
-            $this->models_with_datetime_fields = get_option(self::MODELS_TO_PROCESS_OPTION_KEY, array());
298
-        }
299
-        return $this->models_with_datetime_fields;
300
-    }
301
-
302
-
303
-    /**
304
-     * Used to record the offset that will be applied to dates and times for EE_Datetime_Field columns.
305
-     * @param float $offset
306
-     */
307
-    public static function updateOffset($offset)
308
-    {
309
-        update_option(self::OFFSET_TO_APPLY_OPTION_KEY, $offset);
310
-    }
311
-
312
-
313
-    /**
314
-     * Used to retrieve the saved offset that will be applied to dates and times for EE_Datetime_Field columns.
315
-     *
316
-     * @return float
317
-     */
318
-    public static function getOffset()
319
-    {
320
-        return (float) get_option(self::OFFSET_TO_APPLY_OPTION_KEY, 0);
321
-    }
21
+	/**
22
+	 * Key for the option used to track which models have been processed when doing the batches.
23
+	 */
24
+	const MODELS_TO_PROCESS_OPTION_KEY = 'ee_models_processed_for_datetime_offset_fix';
25
+
26
+
27
+	const COUNT_OF_MODELS_PROCESSED = 'ee_count_of_ee_models_processed_for_datetime_offset_fixed';
28
+
29
+	/**
30
+	 * Key for the option used to track what the current offset is that will be applied when this tool is executed.
31
+	 */
32
+	const OFFSET_TO_APPLY_OPTION_KEY = 'ee_datetime_offset_fix_offset_to_apply';
33
+
34
+
35
+	/**
36
+	 * String labelling the datetime offset fix type for change-log entries.
37
+	 */
38
+	const DATETIME_OFFSET_FIX_CHANGELOG_TYPE = 'datetime_offset_fix';
39
+
40
+
41
+	/**
42
+	 * String labelling a datetime offset fix error for change-log entries.
43
+	 */
44
+	const DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE = 'datetime_offset_fix_error';
45
+
46
+	/**
47
+	 * @var EEM_Base[]
48
+	 */
49
+	protected $models_with_datetime_fields = array();
50
+
51
+
52
+	/**
53
+	 * Performs any necessary setup for starting the job. This is also a good
54
+	 * place to setup the $job_arguments which will be used for subsequent HTTP requests
55
+	 * when continue_job will be called
56
+	 *
57
+	 * @param JobParameters $job_parameters
58
+	 * @throws BatchRequestException
59
+	 * @return JobStepResponse
60
+	 */
61
+	public function create_job(JobParameters $job_parameters)
62
+	{
63
+		$models_with_datetime_fields = $this->getModelsWithDatetimeFields();
64
+		//we'll be doing each model as a batch.
65
+		$job_parameters->set_job_size(count($models_with_datetime_fields));
66
+		return new JobStepResponse(
67
+			$job_parameters,
68
+			esc_html__('Starting Datetime Offset Fix', 'event_espresso')
69
+		);
70
+	}
71
+
72
+	/**
73
+	 * Performs another step of the job
74
+	 *
75
+	 * @param JobParameters $job_parameters
76
+	 * @param int           $batch_size
77
+	 * @return JobStepResponse
78
+	 * @throws \EE_Error
79
+	 */
80
+	public function continue_job(JobParameters $job_parameters, $batch_size = 50)
81
+	{
82
+		$models_to_process = $this->getModelsWithDatetimeFields();
83
+		//let's pop off the a model and do the query to apply the offset.
84
+		$model_to_process = array_pop($models_to_process);
85
+		//update our record
86
+		$this->setModelsToProcess($models_to_process);
87
+		$this->processModel($model_to_process);
88
+		$this->updateCountOfModelsProcessed();
89
+		$job_parameters->set_units_processed($this->getCountOfModelsProcessed());
90
+		if (count($models_to_process) > 0) {
91
+			$job_parameters->set_status(JobParameters::status_continue);
92
+		} else {
93
+			$job_parameters->set_status(JobParameters::status_complete);
94
+		}
95
+		return new JobStepResponse(
96
+			$job_parameters,
97
+			sprintf(
98
+				esc_html__('Updated the offset for all datetime fields on the %s model.', 'event_espresso'),
99
+				$model_to_process
100
+			)
101
+		);
102
+	}
103
+
104
+	/**
105
+	 * Performs any clean-up logic when we know the job is completed
106
+	 *
107
+	 * @param JobParameters $job_parameters
108
+	 * @return JobStepResponse
109
+	 * @throws BatchRequestException
110
+	 */
111
+	public function cleanup_job(JobParameters $job_parameters)
112
+	{
113
+		//delete important saved options.
114
+		delete_option(self::MODELS_TO_PROCESS_OPTION_KEY);
115
+		delete_option(self::COUNT_OF_MODELS_PROCESSED);
116
+		return new JobStepResponse($job_parameters, esc_html__(
117
+			'Offset has been applied to all affected fields.',
118
+			'event_espresso'
119
+		));
120
+	}
121
+
122
+
123
+	/**
124
+	 * Contains the logic for processing a model and applying the datetime offset to affected fields on that model.
125
+	 * @param string $model_class_name
126
+	 * @throws \EE_Error
127
+	 */
128
+	protected function processModel($model_class_name)
129
+	{
130
+		global $wpdb;
131
+		/** @var EEM_Base $model */
132
+		$model = $model_class_name::instance();
133
+		$original_offset = self::getOffset();
134
+		$sql_date_function = $original_offset > 0 ? 'DATE_ADD' : 'DATE_SUB';
135
+		$offset = abs($original_offset) * 60;
136
+		//since some affected models might have two tables, we have to get our tables and set up a query for each table.
137
+		foreach ($model->get_tables() as $table) {
138
+			$query = 'UPDATE ' . $table->get_table_name();
139
+			$fields_affected = array();
140
+			$inner_query = array();
141
+			foreach ($model->_get_fields_for_table($table->get_table_alias()) as $model_field) {
142
+				if ($model_field instanceof EE_Datetime_Field) {
143
+					$inner_query[] = $model_field->get_table_column() . ' = '
144
+									 . $sql_date_function . '('
145
+									 . $model_field->get_table_column()
146
+									 . ", INTERVAL $offset MINUTE)";
147
+					$fields_affected[] = $model_field;
148
+				}
149
+			}
150
+			if (! $fields_affected) {
151
+				continue;
152
+			}
153
+			//k convert innerquery to string
154
+			$query .= ' SET ' . implode(',', $inner_query);
155
+			//execute query
156
+			$result = $wpdb->query($query);
157
+			//record log
158
+			if ($result !== false) {
159
+				$this->recordChangeLog($model, $original_offset, $table, $fields_affected);
160
+			} else {
161
+				//record error.
162
+				$error_message = $wpdb->last_error;
163
+				//handle the edgecases where last_error might be empty.
164
+				if (! $error_message) {
165
+					$error_message = esc_html__('Unknown mysql error occured.', 'event_espresso');
166
+				}
167
+				$this->recordChangeLog($model, $original_offset, $table, $fields_affected, $error_message);
168
+			}
169
+		}
170
+	}
171
+
172
+
173
+	/**
174
+	 * Records a changelog entry using the given information.
175
+	 *
176
+	 * @param EEM_Base              $model
177
+	 * @param float                 $offset
178
+	 * @param EE_Table_Base         $table
179
+	 * @param EE_Model_Field_Base[] $model_fields_affected
180
+	 * @param string                $error_message   If present then there was an error so let's record that instead.
181
+	 * @throws \EE_Error
182
+	 */
183
+	private function recordChangeLog(
184
+		EEM_Base $model,
185
+		$offset,
186
+		EE_Table_Base $table,
187
+		$model_fields_affected,
188
+		$error_message = ''
189
+	) {
190
+		//setup $fields list.
191
+		$fields = array();
192
+		/** @var EE_Datetime_Field $model_field */
193
+		foreach ($model_fields_affected as $model_field) {
194
+			if (! $model_field instanceof EE_Datetime_Field) {
195
+				continue;
196
+			}
197
+			$fields[] = $model_field->get_name();
198
+		}
199
+		//setup the message for the changelog entry.
200
+		$message = $error_message
201
+			? sprintf(
202
+				esc_html__(
203
+					'The %1$s table for the %2$s model did not have the offset of %3$f applied to its fields (%4$s), because of the following error:%5$s',
204
+					'event_espresso'
205
+				),
206
+				$table->get_table_name(),
207
+				$model->get_this_model_name(),
208
+				$offset,
209
+				implode(',', $fields),
210
+				$error_message
211
+			)
212
+			: sprintf(
213
+				esc_html__(
214
+					'The %1$s table for the %2$s model has had the offset of %3$f applied to its following fields: %4$s',
215
+					'event_espresso'
216
+				),
217
+				$table->get_table_name(),
218
+				$model->get_this_model_name(),
219
+				$offset,
220
+				implode(',', $fields)
221
+			);
222
+		//write to the log
223
+		$changelog = EE_Change_Log::new_instance(array(
224
+			'LOG_type' => $error_message
225
+				? self::DATETIME_OFFSET_FIX_CHANGELOG_ERROR_TYPE
226
+				: self::DATETIME_OFFSET_FIX_CHANGELOG_TYPE,
227
+			'LOG_message' => $message
228
+		));
229
+		$changelog->save();
230
+	}
231
+
232
+
233
+	/**
234
+	 * Returns an array of models that have datetime fields.
235
+	 * This array is added to a short lived transient cache to keep having to build this list to a minimum.
236
+	 * @return array  an array of model class names.
237
+	 */
238
+	private function getModelsWithDatetimeFields()
239
+	{
240
+		$this->getModelsToProcess();
241
+		if (! empty($this->models_with_datetime_fields)) {
242
+			return $this->models_with_datetime_fields;
243
+		}
244
+
245
+		$all_non_abstract_models = EE_Registry::instance()->non_abstract_db_models;
246
+		foreach ($all_non_abstract_models as $non_abstract_model) {
247
+			//get model instance
248
+			/** @var EEM_Base $non_abstract_model */
249
+			$non_abstract_model = $non_abstract_model::instance();
250
+			if ($non_abstract_model->get_a_field_of_type('EE_Datetime_Field') instanceof EE_Datetime_Field) {
251
+				$this->models_with_datetime_fields[] = get_class($non_abstract_model);
252
+			}
253
+		}
254
+		$this->setModelsToProcess($this->models_with_datetime_fields);
255
+		return $this->models_with_datetime_fields;
256
+	}
257
+
258
+
259
+	/**
260
+	 * This simply records the models that have been processed with our tracking option.
261
+	 * @param array $models_to_set  array of model class names.
262
+	 */
263
+	private function setModelsToProcess($models_to_set)
264
+	{
265
+		update_option(self::MODELS_TO_PROCESS_OPTION_KEY, $models_to_set);
266
+	}
267
+
268
+
269
+	/**
270
+	 * Used to keep track of how many models have been processed for the batch
271
+	 * @param $count
272
+	 */
273
+	private function updateCountOfModelsProcessed($count = 1)
274
+	{
275
+		$count = $this->getCountOfModelsProcessed() + (int) $count;
276
+		update_option(self::COUNT_OF_MODELS_PROCESSED, $count);
277
+	}
278
+
279
+
280
+	/**
281
+	 * Retrieve the tracked number of models processed between requests.
282
+	 * @return int
283
+	 */
284
+	private function getCountOfModelsProcessed()
285
+	{
286
+		return (int) get_option(self::COUNT_OF_MODELS_PROCESSED, 0);
287
+	}
288
+
289
+
290
+	/**
291
+	 * Returns the models that are left to process.
292
+	 * @return array  an array of model class names.
293
+	 */
294
+	private function getModelsToProcess()
295
+	{
296
+		if (empty($this->models_with_datetime_fields)) {
297
+			$this->models_with_datetime_fields = get_option(self::MODELS_TO_PROCESS_OPTION_KEY, array());
298
+		}
299
+		return $this->models_with_datetime_fields;
300
+	}
301
+
302
+
303
+	/**
304
+	 * Used to record the offset that will be applied to dates and times for EE_Datetime_Field columns.
305
+	 * @param float $offset
306
+	 */
307
+	public static function updateOffset($offset)
308
+	{
309
+		update_option(self::OFFSET_TO_APPLY_OPTION_KEY, $offset);
310
+	}
311
+
312
+
313
+	/**
314
+	 * Used to retrieve the saved offset that will be applied to dates and times for EE_Datetime_Field columns.
315
+	 *
316
+	 * @return float
317
+	 */
318
+	public static function getOffset()
319
+	{
320
+		return (float) get_option(self::OFFSET_TO_APPLY_OPTION_KEY, 0);
321
+	}
322 322
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -135,23 +135,23 @@  discard block
 block discarded – undo
135 135
         $offset = abs($original_offset) * 60;
136 136
         //since some affected models might have two tables, we have to get our tables and set up a query for each table.
137 137
         foreach ($model->get_tables() as $table) {
138
-            $query = 'UPDATE ' . $table->get_table_name();
138
+            $query = 'UPDATE '.$table->get_table_name();
139 139
             $fields_affected = array();
140 140
             $inner_query = array();
141 141
             foreach ($model->_get_fields_for_table($table->get_table_alias()) as $model_field) {
142 142
                 if ($model_field instanceof EE_Datetime_Field) {
143
-                    $inner_query[] = $model_field->get_table_column() . ' = '
144
-                                     . $sql_date_function . '('
143
+                    $inner_query[] = $model_field->get_table_column().' = '
144
+                                     . $sql_date_function.'('
145 145
                                      . $model_field->get_table_column()
146 146
                                      . ", INTERVAL $offset MINUTE)";
147 147
                     $fields_affected[] = $model_field;
148 148
                 }
149 149
             }
150
-            if (! $fields_affected) {
150
+            if ( ! $fields_affected) {
151 151
                 continue;
152 152
             }
153 153
             //k convert innerquery to string
154
-            $query .= ' SET ' . implode(',', $inner_query);
154
+            $query .= ' SET '.implode(',', $inner_query);
155 155
             //execute query
156 156
             $result = $wpdb->query($query);
157 157
             //record log
@@ -161,7 +161,7 @@  discard block
 block discarded – undo
161 161
                 //record error.
162 162
                 $error_message = $wpdb->last_error;
163 163
                 //handle the edgecases where last_error might be empty.
164
-                if (! $error_message) {
164
+                if ( ! $error_message) {
165 165
                     $error_message = esc_html__('Unknown mysql error occured.', 'event_espresso');
166 166
                 }
167 167
                 $this->recordChangeLog($model, $original_offset, $table, $fields_affected, $error_message);
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
         $fields = array();
192 192
         /** @var EE_Datetime_Field $model_field */
193 193
         foreach ($model_fields_affected as $model_field) {
194
-            if (! $model_field instanceof EE_Datetime_Field) {
194
+            if ( ! $model_field instanceof EE_Datetime_Field) {
195 195
                 continue;
196 196
             }
197 197
             $fields[] = $model_field->get_name();
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
     private function getModelsWithDatetimeFields()
239 239
     {
240 240
         $this->getModelsToProcess();
241
-        if (! empty($this->models_with_datetime_fields)) {
241
+        if ( ! empty($this->models_with_datetime_fields)) {
242 242
             return $this->models_with_datetime_fields;
243 243
         }
244 244
 
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Shortcode.lib.php 2 patches
Indentation   +144 added lines, -144 removed lines patch added patch discarded remove patch
@@ -20,159 +20,159 @@
 block discarded – undo
20 20
 class EE_Register_Shortcode implements EEI_Plugin_API
21 21
 {
22 22
 
23
-    /**
24
-     * Holds values for registered shortcodes
25
-     *
26
-     * @var array
27
-     */
28
-    protected static $_settings = array();
23
+	/**
24
+	 * Holds values for registered shortcodes
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected static $_settings = array();
29 29
 
30 30
 
31
-    /**
32
-     *    Method for registering new EE_Shortcodes
33
-     *
34
-     * @since    4.3.0
35
-     * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
36
-     * @param string $shortcode_id a unique identifier for this set of modules Required.
37
-     * @param  array $setup_args   an array of arguments provided for registering shortcodes Required.
38
-     *               @type array shortcode_paths        an array of full server paths to folders containing any
39
-     *                                                  EES_Shortcodes
40
-     *               @type array shortcode_fqcns        an array of fully qualified class names for any new shortcode
41
-     *                                                  classes to register.  Shortcode classes should extend
42
-     *                                                  EspressoShortcode and be properly namespaced so they are
43
-     *                                                  autoloaded.
44
-     * @throws EE_Error
45
-     * @return void
46
-     */
47
-    public static function register($shortcode_id = null, $setup_args = array())
48
-    {
49
-        //required fields MUST be present, so let's make sure they are.
50
-        if (empty($shortcode_id)
51
-            || ! is_array($setup_args)
52
-            || (
53
-                empty($setup_args['shortcode_paths']))
54
-                && empty($setup_args['shortcode_fqcns'])
55
-            ) {
56
-            throw new EE_Error(
57
-                esc_html__(
58
-                    'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)',
59
-                    'event_espresso'
60
-                )
61
-            );
62
-        }
31
+	/**
32
+	 *    Method for registering new EE_Shortcodes
33
+	 *
34
+	 * @since    4.3.0
35
+	 * @since    4.9.46.rc.025  for the new `shortcode_fqcns` array argument.
36
+	 * @param string $shortcode_id a unique identifier for this set of modules Required.
37
+	 * @param  array $setup_args   an array of arguments provided for registering shortcodes Required.
38
+	 *               @type array shortcode_paths        an array of full server paths to folders containing any
39
+	 *                                                  EES_Shortcodes
40
+	 *               @type array shortcode_fqcns        an array of fully qualified class names for any new shortcode
41
+	 *                                                  classes to register.  Shortcode classes should extend
42
+	 *                                                  EspressoShortcode and be properly namespaced so they are
43
+	 *                                                  autoloaded.
44
+	 * @throws EE_Error
45
+	 * @return void
46
+	 */
47
+	public static function register($shortcode_id = null, $setup_args = array())
48
+	{
49
+		//required fields MUST be present, so let's make sure they are.
50
+		if (empty($shortcode_id)
51
+			|| ! is_array($setup_args)
52
+			|| (
53
+				empty($setup_args['shortcode_paths']))
54
+				&& empty($setup_args['shortcode_fqcns'])
55
+			) {
56
+			throw new EE_Error(
57
+				esc_html__(
58
+					'In order to register Modules with EE_Register_Shortcode::register(), you must include a "shortcode_id" (a unique identifier for this set of shortcodes), and an array containing the following keys: "shortcode_paths" (an array of full server paths to folders that contain shortcodes, or to the shortcode files themselves)',
59
+					'event_espresso'
60
+				)
61
+			);
62
+		}
63 63
 
64
-        //make sure we don't register twice
65
-        if (isset(self::$_settings[$shortcode_id])) {
66
-            return;
67
-        }
64
+		//make sure we don't register twice
65
+		if (isset(self::$_settings[$shortcode_id])) {
66
+			return;
67
+		}
68 68
 
69
-        //make sure this was called in the right place!
70
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
71
-            || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
72
-        ) {
73
-            EE_Error::doing_it_wrong(
74
-                __METHOD__,
75
-                esc_html__(
76
-                    'An attempt to register shortcodes 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 shortcodes.',
77
-                    'event_espresso'
78
-                ),
79
-                '4.3.0'
80
-            );
81
-        }
82
-        //setup $_settings array from incoming values.
83
-        self::$_settings[$shortcode_id] = array(
84
-            // array of full server paths to any EES_Shortcodes used by the shortcode
85
-            'shortcode_paths' => isset($setup_args['shortcode_paths'])
86
-                ? (array) $setup_args['shortcode_paths']
87
-                : array(),
88
-            'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
89
-                ? (array) $setup_args['shortcode_fqcns']
90
-                : array()
91
-        );
92
-        // add to list of shortcodes to be registered
93
-        add_filter(
94
-            'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
95
-            array('EE_Register_Shortcode', 'add_shortcodes')
96
-        );
69
+		//make sure this was called in the right place!
70
+		if (! did_action('AHEE__EE_System__load_espresso_addons')
71
+			|| did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
72
+		) {
73
+			EE_Error::doing_it_wrong(
74
+				__METHOD__,
75
+				esc_html__(
76
+					'An attempt to register shortcodes 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 shortcodes.',
77
+					'event_espresso'
78
+				),
79
+				'4.3.0'
80
+			);
81
+		}
82
+		//setup $_settings array from incoming values.
83
+		self::$_settings[$shortcode_id] = array(
84
+			// array of full server paths to any EES_Shortcodes used by the shortcode
85
+			'shortcode_paths' => isset($setup_args['shortcode_paths'])
86
+				? (array) $setup_args['shortcode_paths']
87
+				: array(),
88
+			'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
89
+				? (array) $setup_args['shortcode_fqcns']
90
+				: array()
91
+		);
92
+		// add to list of shortcodes to be registered
93
+		add_filter(
94
+			'FHEE__EE_Config__register_shortcodes__shortcodes_to_register',
95
+			array('EE_Register_Shortcode', 'add_shortcodes')
96
+		);
97 97
 
98
-        add_filter(
99
-            'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
100
-            array('EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection')
101
-        );
102
-    }
98
+		add_filter(
99
+			'FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection',
100
+			array('EE_Register_Shortcode', 'instantiateAndAddToShortcodeCollection')
101
+		);
102
+	}
103 103
 
104 104
 
105
-    /**
106
-     * Filters the list of shortcodes to add ours.
107
-     * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
108
-     * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...)
109
-     *
110
-     * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
111
-     * @return array
112
-     */
113
-    public static function add_shortcodes($shortcodes_to_register)
114
-    {
115
-        foreach (self::$_settings as $settings) {
116
-            $shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']);
117
-        }
118
-        return $shortcodes_to_register;
119
-    }
105
+	/**
106
+	 * Filters the list of shortcodes to add ours.
107
+	 * and they're just full filepaths to FOLDERS containing a shortcode class file. Eg.
108
+	 * array('espresso_monkey'=>'/public_html/wonder-site/wp-content/plugins/ee4/shortcodes/espresso_monkey',...)
109
+	 *
110
+	 * @param array $shortcodes_to_register array of paths to all shortcodes that require registering
111
+	 * @return array
112
+	 */
113
+	public static function add_shortcodes($shortcodes_to_register)
114
+	{
115
+		foreach (self::$_settings as $settings) {
116
+			$shortcodes_to_register = array_merge($shortcodes_to_register, $settings['shortcode_paths']);
117
+		}
118
+		return $shortcodes_to_register;
119
+	}
120 120
 
121 121
 
122
-    /**
123
-     * Hooks into FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection
124
-     * and registers any provided shortcode fully qualified class names.
125
-     * @param CollectionInterface $shortcodes_collection
126
-     * @return CollectionInterface
127
-     * @throws InvalidArgumentException
128
-     * @throws InvalidClassException
129
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
130
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
131
-     */
132
-    public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
133
-    {
134
-        foreach (self::$_settings as $settings) {
135
-            if (! empty($settings['shortcode_fqcns'])) {
136
-                foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
137
-                    if (! class_exists($shortcode_fqcn)) {
138
-                        throw new InvalidClassException(
139
-                            sprintf(
140
-                                esc_html__(
141
-                                    'Are you sure %s is the right fully qualified class name for the shortcode class?',
142
-                                    'event_espresso'
143
-                                ),
144
-                                $shortcode_fqcn
145
-                            )
146
-                        );
147
-                    }
148
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
149
-                        //register dependencies
150
-                        EE_Dependency_Map::register_dependencies(
151
-                            $shortcode_fqcn,
152
-                            array(
153
-                                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
154
-                            )
155
-                        );
156
-                    }
157
-                    $shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
158
-                }
159
-            }
160
-        }
161
-        return $shortcodes_collection;
162
-    }
122
+	/**
123
+	 * Hooks into FHEE__EventEspresso_core_services_shortcodes_ShortcodesManager__registerShortcodes__shortcode_collection
124
+	 * and registers any provided shortcode fully qualified class names.
125
+	 * @param CollectionInterface $shortcodes_collection
126
+	 * @return CollectionInterface
127
+	 * @throws InvalidArgumentException
128
+	 * @throws InvalidClassException
129
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
130
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
131
+	 */
132
+	public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
133
+	{
134
+		foreach (self::$_settings as $settings) {
135
+			if (! empty($settings['shortcode_fqcns'])) {
136
+				foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
137
+					if (! class_exists($shortcode_fqcn)) {
138
+						throw new InvalidClassException(
139
+							sprintf(
140
+								esc_html__(
141
+									'Are you sure %s is the right fully qualified class name for the shortcode class?',
142
+									'event_espresso'
143
+								),
144
+								$shortcode_fqcn
145
+							)
146
+						);
147
+					}
148
+					if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
149
+						//register dependencies
150
+						EE_Dependency_Map::register_dependencies(
151
+							$shortcode_fqcn,
152
+							array(
153
+								'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
154
+							)
155
+						);
156
+					}
157
+					$shortcodes_collection->add(LoaderFactory::getLoader()->getShared($shortcode_fqcn));
158
+				}
159
+			}
160
+		}
161
+		return $shortcodes_collection;
162
+	}
163 163
 
164 164
 
165
-    /**
166
-     * This deregisters a shortcode that was previously registered with a specific $shortcode_id.
167
-     *
168
-     * @since    4.3.0
169
-     * @param string $shortcode_id the name for the shortcode that was previously registered
170
-     * @return void
171
-     */
172
-    public static function deregister($shortcode_id = null)
173
-    {
174
-        if (isset(self::$_settings[$shortcode_id])) {
175
-            unset(self::$_settings[$shortcode_id]);
176
-        }
177
-    }
165
+	/**
166
+	 * This deregisters a shortcode that was previously registered with a specific $shortcode_id.
167
+	 *
168
+	 * @since    4.3.0
169
+	 * @param string $shortcode_id the name for the shortcode that was previously registered
170
+	 * @return void
171
+	 */
172
+	public static function deregister($shortcode_id = null)
173
+	{
174
+		if (isset(self::$_settings[$shortcode_id])) {
175
+			unset(self::$_settings[$shortcode_id]);
176
+		}
177
+	}
178 178
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         }
68 68
 
69 69
         //make sure this was called in the right place!
70
-        if (! did_action('AHEE__EE_System__load_espresso_addons')
70
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons')
71 71
             || did_action('AHEE__EE_System__register_shortcodes_modules_and_widgets')
72 72
         ) {
73 73
             EE_Error::doing_it_wrong(
@@ -132,9 +132,9 @@  discard block
 block discarded – undo
132 132
     public static function instantiateAndAddToShortcodeCollection(CollectionInterface $shortcodes_collection)
133 133
     {
134 134
         foreach (self::$_settings as $settings) {
135
-            if (! empty($settings['shortcode_fqcns'])) {
135
+            if ( ! empty($settings['shortcode_fqcns'])) {
136 136
                 foreach ($settings['shortcode_fqcns'] as $shortcode_fqcn) {
137
-                    if (! class_exists($shortcode_fqcn)) {
137
+                    if ( ! class_exists($shortcode_fqcn)) {
138 138
                         throw new InvalidClassException(
139 139
                             sprintf(
140 140
                                 esc_html__(
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
                             )
146 146
                         );
147 147
                     }
148
-                    if (! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
148
+                    if ( ! EE_Dependency_Map::instance()->has_dependency_for_class($shortcode_fqcn)) {
149 149
                         //register dependencies
150 150
                         EE_Dependency_Map::register_dependencies(
151 151
                             $shortcode_fqcn,
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
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,108 +346,108 @@  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
             'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
409 409
                 ? (array) $setup_args['shortcode_fqcns']
410 410
                 : array(),
411 411
             // array of full server paths to any WP_Widgets used by the addon
412 412
             'widget_paths'          => isset($setup_args['widget_paths'])
413
-                ? (array)$setup_args['widget_paths']
413
+                ? (array) $setup_args['widget_paths']
414 414
                 : array(),
415 415
             // array of PUE options used by the addon
416 416
             'pue_options'           => isset($setup_args['pue_options'])
417
-                ? (array)$setup_args['pue_options']
417
+                ? (array) $setup_args['pue_options']
418 418
                 : array(),
419 419
             'message_types'         => isset($setup_args['message_types'])
420
-                ? (array)$setup_args['message_types']
420
+                ? (array) $setup_args['message_types']
421 421
                 : array(),
422 422
             'capabilities'          => isset($setup_args['capabilities'])
423
-                ? (array)$setup_args['capabilities']
423
+                ? (array) $setup_args['capabilities']
424 424
                 : array(),
425 425
             'capability_maps'       => isset($setup_args['capability_maps'])
426
-                ? (array)$setup_args['capability_maps']
426
+                ? (array) $setup_args['capability_maps']
427 427
                 : array(),
428 428
             'model_paths'           => isset($setup_args['model_paths'])
429
-                ? (array)$setup_args['model_paths']
429
+                ? (array) $setup_args['model_paths']
430 430
                 : array(),
431 431
             'class_paths'           => isset($setup_args['class_paths'])
432
-                ? (array)$setup_args['class_paths']
432
+                ? (array) $setup_args['class_paths']
433 433
                 : array(),
434 434
             'model_extension_paths' => isset($setup_args['model_extension_paths'])
435
-                ? (array)$setup_args['model_extension_paths']
435
+                ? (array) $setup_args['model_extension_paths']
436 436
                 : array(),
437 437
             'class_extension_paths' => isset($setup_args['class_extension_paths'])
438
-                ? (array)$setup_args['class_extension_paths']
438
+                ? (array) $setup_args['class_extension_paths']
439 439
                 : array(),
440 440
             'custom_post_types'     => isset($setup_args['custom_post_types'])
441
-                ? (array)$setup_args['custom_post_types']
441
+                ? (array) $setup_args['custom_post_types']
442 442
                 : array(),
443 443
             'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
444
-                ? (array)$setup_args['custom_taxonomies']
444
+                ? (array) $setup_args['custom_taxonomies']
445 445
                 : array(),
446 446
             'payment_method_paths'  => isset($setup_args['payment_method_paths'])
447
-                ? (array)$setup_args['payment_method_paths']
447
+                ? (array) $setup_args['payment_method_paths']
448 448
                 : array(),
449 449
             'default_terms'         => isset($setup_args['default_terms'])
450
-                ? (array)$setup_args['default_terms']
450
+                ? (array) $setup_args['default_terms']
451 451
                 : array(),
452 452
             // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
453 453
             // that can be used for adding upgrading/marketing info
@@ -459,7 +459,7 @@  discard block
 block discarded – undo
459 459
                 $setup_args['namespace']['FQNS'],
460 460
                 $setup_args['namespace']['DIR']
461 461
             )
462
-                ? (array)$setup_args['namespace']
462
+                ? (array) $setup_args['namespace']
463 463
                 : array(),
464 464
         );
465 465
         // if plugin_action_slug is NOT set, but an admin page path IS set,
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
                 '</span><br />'
530 530
             );
531 531
         }
532
-        if (! empty($incompatibility_message)) {
532
+        if ( ! empty($incompatibility_message)) {
533 533
             // remove 'activate' from the REQUEST
534 534
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
535 535
             unset($_GET['activate'], $_REQUEST['activate']);
@@ -557,19 +557,19 @@  discard block
 block discarded – undo
557 557
      */
558 558
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
559 559
     {
560
-        if (! empty($setup_args['pue_options'])) {
560
+        if ( ! empty($setup_args['pue_options'])) {
561 561
             self::$_settings[$addon_name]['pue_options'] = array(
562 562
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
563
-                    ? (string)$setup_args['pue_options']['pue_plugin_slug']
564
-                    : 'espresso_' . strtolower($class_name),
563
+                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
564
+                    : 'espresso_'.strtolower($class_name),
565 565
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
566
-                    ? (string)$setup_args['pue_options']['plugin_basename']
566
+                    ? (string) $setup_args['pue_options']['plugin_basename']
567 567
                     : plugin_basename($setup_args['main_file_path']),
568 568
                 'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
569
-                    ? (string)$setup_args['pue_options']['checkPeriod']
569
+                    ? (string) $setup_args['pue_options']['checkPeriod']
570 570
                     : '24',
571 571
                 'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
572
-                    ? (string)$setup_args['pue_options']['use_wp_update']
572
+                    ? (string) $setup_args['pue_options']['use_wp_update']
573 573
                     : false,
574 574
             );
575 575
             add_action(
@@ -617,7 +617,7 @@  discard block
 block discarded – undo
617 617
             //(as the newly-activated addon wasn't around the first time addons were registered).
618 618
             //Note: the presence of pue_options in the addon registration options will initialize the $_settings
619 619
             //property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
620
-            if (! isset(self::$_settings[$addon_name])
620
+            if ( ! isset(self::$_settings[$addon_name])
621 621
                 || (isset(self::$_settings[$addon_name])
622 622
                     && ! isset(self::$_settings[$addon_name]['class_name'])
623 623
                 )
@@ -664,13 +664,13 @@  discard block
 block discarded – undo
664 664
      */
665 665
     private static function _setup_autoloaders($addon_name)
666 666
     {
667
-        if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
667
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
668 668
             // setup autoloader for single file
669 669
             EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
670 670
         }
671 671
         // setup autoloaders for folders
672
-        if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
673
-            foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
672
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
673
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
674 674
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
675 675
             }
676 676
         }
@@ -723,7 +723,7 @@  discard block
 block discarded – undo
723 723
     private static function _register_data_migration_scripts($addon_name)
724 724
     {
725 725
         // setup DMS
726
-        if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
726
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
727 727
             EE_Register_Data_Migration_Scripts::register(
728 728
                 $addon_name,
729 729
                 array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
     private static function _register_config($addon_name)
741 741
     {
742 742
         // if config_class is present let's register config.
743
-        if (! empty(self::$_settings[$addon_name]['config_class'])) {
743
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
744 744
             EE_Register_Config::register(
745 745
                 self::$_settings[$addon_name]['config_class'],
746 746
                 array(
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
      */
760 760
     private static function _register_admin_pages($addon_name)
761 761
     {
762
-        if (! empty(self::$_settings[$addon_name]['admin_path'])) {
762
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
763 763
             EE_Register_Admin_Page::register(
764 764
                 $addon_name,
765 765
                 array('page_path' => self::$_settings[$addon_name]['admin_path'])
@@ -775,7 +775,7 @@  discard block
 block discarded – undo
775 775
      */
776 776
     private static function _register_modules($addon_name)
777 777
     {
778
-        if (! empty(self::$_settings[$addon_name]['module_paths'])) {
778
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
779 779
             EE_Register_Module::register(
780 780
                 $addon_name,
781 781
                 array('module_paths' => self::$_settings[$addon_name]['module_paths'])
@@ -791,7 +791,7 @@  discard block
 block discarded – undo
791 791
      */
792 792
     private static function _register_shortcodes($addon_name)
793 793
     {
794
-        if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
794
+        if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
795 795
             || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
796 796
         ) {
797 797
             EE_Register_Shortcode::register(
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
      */
817 817
     private static function _register_widgets($addon_name)
818 818
     {
819
-        if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
819
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
820 820
             EE_Register_Widget::register(
821 821
                 $addon_name,
822 822
                 array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
@@ -832,7 +832,7 @@  discard block
 block discarded – undo
832 832
      */
833 833
     private static function _register_capabilities($addon_name)
834 834
     {
835
-        if (! empty(self::$_settings[$addon_name]['capabilities'])) {
835
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
836 836
             EE_Register_Capabilities::register(
837 837
                 $addon_name,
838 838
                 array(
@@ -851,7 +851,7 @@  discard block
 block discarded – undo
851 851
      */
852 852
     private static function _register_message_types($addon_name)
853 853
     {
854
-        if (! empty(self::$_settings[$addon_name]['message_types'])) {
854
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
855 855
             add_action(
856 856
                 'EE_Brewing_Regular___messages_caf',
857 857
                 array('EE_Register_Addon', 'register_message_types')
@@ -890,7 +890,7 @@  discard block
 block discarded – undo
890 890
      */
891 891
     private static function _register_payment_methods($addon_name)
892 892
     {
893
-        if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
893
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
894 894
             EE_Register_Payment_Method::register(
895 895
                 $addon_name,
896 896
                 array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
@@ -926,7 +926,7 @@  discard block
 block discarded – undo
926 926
         //the plugin mainfile's path upon construction.
927 927
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
928 928
         // call any additional admin_callback functions during load_admin_controller hook
929
-        if (! empty(self::$_settings[$addon_name]['admin_callback'])) {
929
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
930 930
             add_action(
931 931
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
932 932
                 array($addon, self::$_settings[$addon_name]['admin_callback'])
@@ -944,10 +944,10 @@  discard block
 block discarded – undo
944 944
     public static function load_pue_update()
945 945
     {
946 946
         // load PUE client
947
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
947
+        require_once EE_THIRD_PARTY.'pue'.DS.'pue-client.php';
948 948
         // cycle thru settings
949 949
         foreach (self::$_settings as $settings) {
950
-            if (! empty($settings['pue_options'])) {
950
+            if ( ! empty($settings['pue_options'])) {
951 951
                 // initiate the class and start the plugin update engine!
952 952
                 new PluginUpdateEngineChecker(
953 953
                 // host file URL
@@ -955,7 +955,7 @@  discard block
 block discarded – undo
955 955
                     // plugin slug(s)
956 956
                     array(
957 957
                         'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
958
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
958
+                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
959 959
                     ),
960 960
                     // options
961 961
                     array(
@@ -984,8 +984,8 @@  discard block
 block discarded – undo
984 984
     public static function register_message_types()
985 985
     {
986 986
         foreach (self::$_settings as $addon_name => $settings) {
987
-            if (! empty($settings['message_types'])) {
988
-                foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
987
+            if ( ! empty($settings['message_types'])) {
988
+                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
989 989
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
990 990
                 }
991 991
             }
@@ -1006,48 +1006,48 @@  discard block
 block discarded – undo
1006 1006
         if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) {
1007 1007
             do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1008 1008
             $class_name = self::$_settings[$addon_name]['class_name'];
1009
-            if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
1009
+            if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1010 1010
                 // setup DMS
1011 1011
                 EE_Register_Data_Migration_Scripts::deregister($addon_name);
1012 1012
             }
1013
-            if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1013
+            if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1014 1014
                 // register admin page
1015 1015
                 EE_Register_Admin_Page::deregister($addon_name);
1016 1016
             }
1017
-            if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1017
+            if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1018 1018
                 // add to list of modules to be registered
1019 1019
                 EE_Register_Module::deregister($addon_name);
1020 1020
             }
1021
-            if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
1021
+            if ( ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1022 1022
                 || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1023 1023
             ) {
1024 1024
                 // add to list of shortcodes to be registered
1025 1025
                 EE_Register_Shortcode::deregister($addon_name);
1026 1026
             }
1027
-            if (! empty(self::$_settings[$addon_name]['config_class'])) {
1027
+            if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1028 1028
                 // if config_class present let's register config.
1029 1029
                 EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1030 1030
             }
1031
-            if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1031
+            if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1032 1032
                 // add to list of widgets to be registered
1033 1033
                 EE_Register_Widget::deregister($addon_name);
1034 1034
             }
1035
-            if (! empty(self::$_settings[$addon_name]['model_paths'])
1035
+            if ( ! empty(self::$_settings[$addon_name]['model_paths'])
1036 1036
                 ||
1037 1037
                 ! empty(self::$_settings[$addon_name]['class_paths'])
1038 1038
             ) {
1039 1039
                 // add to list of shortcodes to be registered
1040 1040
                 EE_Register_Model::deregister($addon_name);
1041 1041
             }
1042
-            if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1042
+            if ( ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1043 1043
                 ||
1044 1044
                 ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1045 1045
             ) {
1046 1046
                 // add to list of shortcodes to be registered
1047 1047
                 EE_Register_Model_Extensions::deregister($addon_name);
1048 1048
             }
1049
-            if (! empty(self::$_settings[$addon_name]['message_types'])) {
1050
-                foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1049
+            if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1050
+                foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1051 1051
                     EE_Register_Message_Type::deregister($message_type);
1052 1052
                 }
1053 1053
             }
@@ -1059,14 +1059,14 @@  discard block
 block discarded – undo
1059 1059
                 EE_Register_Capabilities::deregister($addon_name);
1060 1060
             }
1061 1061
             //deregister custom_post_types for addon
1062
-            if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1062
+            if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1063 1063
                 EE_Register_CPT::deregister($addon_name);
1064 1064
             }
1065
-            if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1065
+            if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1066 1066
                 EE_Register_Payment_Method::deregister($addon_name);
1067 1067
             }
1068 1068
             remove_action(
1069
-                'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1069
+                'deactivate_'.EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1070 1070
                 array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')
1071 1071
             );
1072 1072
             remove_action(
Please login to merge, or discard this patch.
Indentation   +1012 added lines, -1012 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,1073 +19,1073 @@  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);
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 270
 
271
-        //delay calling after_registration hook on each addon until after all add-ons have been registered.
272
-        add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
273
-    }
271
+		//delay calling after_registration hook on each addon until after all add-ons have been registered.
272
+		add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
273
+	}
274 274
 
275 275
 
276
-    /**
277
-     * @param string $addon_name
278
-     * @param array  $setup_args
279
-     * @return void
280
-     * @throws \EE_Error
281
-     */
282
-    private static function _verify_parameters($addon_name, array $setup_args)
283
-    {
284
-        // required fields MUST be present, so let's make sure they are.
285
-        if (empty($addon_name) || ! is_array($setup_args)) {
286
-            throw new EE_Error(
287
-                __(
288
-                    '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.',
289
-                    'event_espresso'
290
-                )
291
-            );
292
-        }
293
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
294
-            throw new EE_Error(
295
-                sprintf(
296
-                    __(
297
-                        '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',
298
-                        'event_espresso'
299
-                    ),
300
-                    implode(',', array_keys($setup_args))
301
-                )
302
-            );
303
-        }
304
-        // check that addon has not already been registered with that name
305
-        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
306
-            throw new EE_Error(
307
-                sprintf(
308
-                    __(
309
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
310
-                        'event_espresso'
311
-                    ),
312
-                    $addon_name
313
-                )
314
-            );
315
-        }
316
-    }
276
+	/**
277
+	 * @param string $addon_name
278
+	 * @param array  $setup_args
279
+	 * @return void
280
+	 * @throws \EE_Error
281
+	 */
282
+	private static function _verify_parameters($addon_name, array $setup_args)
283
+	{
284
+		// required fields MUST be present, so let's make sure they are.
285
+		if (empty($addon_name) || ! is_array($setup_args)) {
286
+			throw new EE_Error(
287
+				__(
288
+					'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.',
289
+					'event_espresso'
290
+				)
291
+			);
292
+		}
293
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
294
+			throw new EE_Error(
295
+				sprintf(
296
+					__(
297
+						'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',
298
+						'event_espresso'
299
+					),
300
+					implode(',', array_keys($setup_args))
301
+				)
302
+			);
303
+		}
304
+		// check that addon has not already been registered with that name
305
+		if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
306
+			throw new EE_Error(
307
+				sprintf(
308
+					__(
309
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
310
+						'event_espresso'
311
+					),
312
+					$addon_name
313
+				)
314
+			);
315
+		}
316
+	}
317 317
 
318 318
 
319
-    /**
320
-     * @param string $addon_name
321
-     * @param array  $setup_args
322
-     * @return string
323
-     */
324
-    private static function _parse_class_name($addon_name, array $setup_args)
325
-    {
326
-        if (empty($setup_args['class_name'])) {
327
-            // generate one by first separating name with spaces
328
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
329
-            //capitalize, then replace spaces with underscores
330
-            $class_name = str_replace(' ', '_', ucwords($class_name));
331
-        } else {
332
-            $class_name = $setup_args['class_name'];
333
-        }
334
-        return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
335
-    }
319
+	/**
320
+	 * @param string $addon_name
321
+	 * @param array  $setup_args
322
+	 * @return string
323
+	 */
324
+	private static function _parse_class_name($addon_name, array $setup_args)
325
+	{
326
+		if (empty($setup_args['class_name'])) {
327
+			// generate one by first separating name with spaces
328
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
329
+			//capitalize, then replace spaces with underscores
330
+			$class_name = str_replace(' ', '_', ucwords($class_name));
331
+		} else {
332
+			$class_name = $setup_args['class_name'];
333
+		}
334
+		return strpos($class_name, 'EE_') === 0 ? $class_name : 'EE_' . $class_name;
335
+	}
336 336
 
337 337
 
338
-    /**
339
-     * @param string $class_name
340
-     * @param array  $setup_args
341
-     * @return array
342
-     */
343
-    private static function _get_addon_settings($class_name, array $setup_args)
344
-    {
345
-        //setup $_settings array from incoming values.
346
-        $addon_settings = array(
347
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
348
-            'class_name'            => $class_name,
349
-            // the addon slug for use in URLs, etc
350
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
351
-                ? (string)$setup_args['plugin_slug']
352
-                : '',
353
-            // page slug to be used when generating the "Settings" link on the WP plugin page
354
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
355
-                ? (string)$setup_args['plugin_action_slug']
356
-                : '',
357
-            // the "software" version for the addon
358
-            'version'               => isset($setup_args['version'])
359
-                ? (string)$setup_args['version']
360
-                : '',
361
-            // the minimum version of EE Core that the addon will work with
362
-            'min_core_version'      => isset($setup_args['min_core_version'])
363
-                ? (string)$setup_args['min_core_version']
364
-                : '',
365
-            // the minimum version of WordPress that the addon will work with
366
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
367
-                ? (string)$setup_args['min_wp_version']
368
-                : EE_MIN_WP_VER_REQUIRED,
369
-            // full server path to main file (file loaded directly by WP)
370
-            'main_file_path'        => isset($setup_args['main_file_path'])
371
-                ? (string)$setup_args['main_file_path']
372
-                : '',
373
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
374
-            'admin_path'            => isset($setup_args['admin_path'])
375
-                ? (string)$setup_args['admin_path'] : '',
376
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
377
-            'admin_callback'        => isset($setup_args['admin_callback'])
378
-                ? (string)$setup_args['admin_callback']
379
-                : '',
380
-            // the section name for this addon's configuration settings section (defaults to "addons")
381
-            'config_section'        => isset($setup_args['config_section'])
382
-                ? (string)$setup_args['config_section']
383
-                : 'addons',
384
-            // the class name for this addon's configuration settings object
385
-            'config_class'          => isset($setup_args['config_class'])
386
-                ? (string)$setup_args['config_class'] : '',
387
-            //the name given to the config for this addons' configuration settings object (optional)
388
-            'config_name'           => isset($setup_args['config_name'])
389
-                ? (string)$setup_args['config_name'] : '',
390
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
391
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
392
-                ? (array)$setup_args['autoloader_paths']
393
-                : array(),
394
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
395
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
396
-                ? (array)$setup_args['autoloader_folders']
397
-                : array(),
398
-            // array of full server paths to any EE_DMS data migration scripts used by the addon
399
-            'dms_paths'             => isset($setup_args['dms_paths'])
400
-                ? (array)$setup_args['dms_paths']
401
-                : array(),
402
-            // array of full server paths to any EED_Modules used by the addon
403
-            'module_paths'          => isset($setup_args['module_paths'])
404
-                ? (array)$setup_args['module_paths']
405
-                : array(),
406
-            // array of full server paths to any EES_Shortcodes used by the addon
407
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
408
-                ? (array)$setup_args['shortcode_paths']
409
-                : array(),
410
-            'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
411
-                ? (array) $setup_args['shortcode_fqcns']
412
-                : array(),
413
-            // array of full server paths to any WP_Widgets used by the addon
414
-            'widget_paths'          => isset($setup_args['widget_paths'])
415
-                ? (array)$setup_args['widget_paths']
416
-                : array(),
417
-            // array of PUE options used by the addon
418
-            'pue_options'           => isset($setup_args['pue_options'])
419
-                ? (array)$setup_args['pue_options']
420
-                : array(),
421
-            'message_types'         => isset($setup_args['message_types'])
422
-                ? (array)$setup_args['message_types']
423
-                : array(),
424
-            'capabilities'          => isset($setup_args['capabilities'])
425
-                ? (array)$setup_args['capabilities']
426
-                : array(),
427
-            'capability_maps'       => isset($setup_args['capability_maps'])
428
-                ? (array)$setup_args['capability_maps']
429
-                : array(),
430
-            'model_paths'           => isset($setup_args['model_paths'])
431
-                ? (array)$setup_args['model_paths']
432
-                : array(),
433
-            'class_paths'           => isset($setup_args['class_paths'])
434
-                ? (array)$setup_args['class_paths']
435
-                : array(),
436
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
437
-                ? (array)$setup_args['model_extension_paths']
438
-                : array(),
439
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
440
-                ? (array)$setup_args['class_extension_paths']
441
-                : array(),
442
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
443
-                ? (array)$setup_args['custom_post_types']
444
-                : array(),
445
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
446
-                ? (array)$setup_args['custom_taxonomies']
447
-                : array(),
448
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
449
-                ? (array)$setup_args['payment_method_paths']
450
-                : array(),
451
-            'default_terms'         => isset($setup_args['default_terms'])
452
-                ? (array)$setup_args['default_terms']
453
-                : array(),
454
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
455
-            // that can be used for adding upgrading/marketing info
456
-            'plugins_page_row'      => isset($setup_args['plugins_page_row'])
457
-                ? $setup_args['plugins_page_row']
458
-                : '',
459
-            'namespace'             => isset(
460
-                $setup_args['namespace'],
461
-                $setup_args['namespace']['FQNS'],
462
-                $setup_args['namespace']['DIR']
463
-            )
464
-                ? (array)$setup_args['namespace']
465
-                : array(),
466
-        );
467
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
468
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
469
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
470
-                                                && ! empty($addon_settings['admin_path'])
471
-            ? $addon_settings['plugin_slug']
472
-            : $addon_settings['plugin_action_slug'];
473
-        // full server path to main file (file loaded directly by WP)
474
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
475
-        return $addon_settings;
476
-    }
338
+	/**
339
+	 * @param string $class_name
340
+	 * @param array  $setup_args
341
+	 * @return array
342
+	 */
343
+	private static function _get_addon_settings($class_name, array $setup_args)
344
+	{
345
+		//setup $_settings array from incoming values.
346
+		$addon_settings = array(
347
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
348
+			'class_name'            => $class_name,
349
+			// the addon slug for use in URLs, etc
350
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
351
+				? (string)$setup_args['plugin_slug']
352
+				: '',
353
+			// page slug to be used when generating the "Settings" link on the WP plugin page
354
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
355
+				? (string)$setup_args['plugin_action_slug']
356
+				: '',
357
+			// the "software" version for the addon
358
+			'version'               => isset($setup_args['version'])
359
+				? (string)$setup_args['version']
360
+				: '',
361
+			// the minimum version of EE Core that the addon will work with
362
+			'min_core_version'      => isset($setup_args['min_core_version'])
363
+				? (string)$setup_args['min_core_version']
364
+				: '',
365
+			// the minimum version of WordPress that the addon will work with
366
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
367
+				? (string)$setup_args['min_wp_version']
368
+				: EE_MIN_WP_VER_REQUIRED,
369
+			// full server path to main file (file loaded directly by WP)
370
+			'main_file_path'        => isset($setup_args['main_file_path'])
371
+				? (string)$setup_args['main_file_path']
372
+				: '',
373
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
374
+			'admin_path'            => isset($setup_args['admin_path'])
375
+				? (string)$setup_args['admin_path'] : '',
376
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
377
+			'admin_callback'        => isset($setup_args['admin_callback'])
378
+				? (string)$setup_args['admin_callback']
379
+				: '',
380
+			// the section name for this addon's configuration settings section (defaults to "addons")
381
+			'config_section'        => isset($setup_args['config_section'])
382
+				? (string)$setup_args['config_section']
383
+				: 'addons',
384
+			// the class name for this addon's configuration settings object
385
+			'config_class'          => isset($setup_args['config_class'])
386
+				? (string)$setup_args['config_class'] : '',
387
+			//the name given to the config for this addons' configuration settings object (optional)
388
+			'config_name'           => isset($setup_args['config_name'])
389
+				? (string)$setup_args['config_name'] : '',
390
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
391
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
392
+				? (array)$setup_args['autoloader_paths']
393
+				: array(),
394
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
395
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
396
+				? (array)$setup_args['autoloader_folders']
397
+				: array(),
398
+			// array of full server paths to any EE_DMS data migration scripts used by the addon
399
+			'dms_paths'             => isset($setup_args['dms_paths'])
400
+				? (array)$setup_args['dms_paths']
401
+				: array(),
402
+			// array of full server paths to any EED_Modules used by the addon
403
+			'module_paths'          => isset($setup_args['module_paths'])
404
+				? (array)$setup_args['module_paths']
405
+				: array(),
406
+			// array of full server paths to any EES_Shortcodes used by the addon
407
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
408
+				? (array)$setup_args['shortcode_paths']
409
+				: array(),
410
+			'shortcode_fqcns' => isset($setup_args['shortcode_fqcns'])
411
+				? (array) $setup_args['shortcode_fqcns']
412
+				: array(),
413
+			// array of full server paths to any WP_Widgets used by the addon
414
+			'widget_paths'          => isset($setup_args['widget_paths'])
415
+				? (array)$setup_args['widget_paths']
416
+				: array(),
417
+			// array of PUE options used by the addon
418
+			'pue_options'           => isset($setup_args['pue_options'])
419
+				? (array)$setup_args['pue_options']
420
+				: array(),
421
+			'message_types'         => isset($setup_args['message_types'])
422
+				? (array)$setup_args['message_types']
423
+				: array(),
424
+			'capabilities'          => isset($setup_args['capabilities'])
425
+				? (array)$setup_args['capabilities']
426
+				: array(),
427
+			'capability_maps'       => isset($setup_args['capability_maps'])
428
+				? (array)$setup_args['capability_maps']
429
+				: array(),
430
+			'model_paths'           => isset($setup_args['model_paths'])
431
+				? (array)$setup_args['model_paths']
432
+				: array(),
433
+			'class_paths'           => isset($setup_args['class_paths'])
434
+				? (array)$setup_args['class_paths']
435
+				: array(),
436
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
437
+				? (array)$setup_args['model_extension_paths']
438
+				: array(),
439
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
440
+				? (array)$setup_args['class_extension_paths']
441
+				: array(),
442
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
443
+				? (array)$setup_args['custom_post_types']
444
+				: array(),
445
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
446
+				? (array)$setup_args['custom_taxonomies']
447
+				: array(),
448
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
449
+				? (array)$setup_args['payment_method_paths']
450
+				: array(),
451
+			'default_terms'         => isset($setup_args['default_terms'])
452
+				? (array)$setup_args['default_terms']
453
+				: array(),
454
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
455
+			// that can be used for adding upgrading/marketing info
456
+			'plugins_page_row'      => isset($setup_args['plugins_page_row'])
457
+				? $setup_args['plugins_page_row']
458
+				: '',
459
+			'namespace'             => isset(
460
+				$setup_args['namespace'],
461
+				$setup_args['namespace']['FQNS'],
462
+				$setup_args['namespace']['DIR']
463
+			)
464
+				? (array)$setup_args['namespace']
465
+				: array(),
466
+		);
467
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
468
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
469
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
470
+												&& ! empty($addon_settings['admin_path'])
471
+			? $addon_settings['plugin_slug']
472
+			: $addon_settings['plugin_action_slug'];
473
+		// full server path to main file (file loaded directly by WP)
474
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
475
+		return $addon_settings;
476
+	}
477 477
 
478 478
 
479
-    /**
480
-     * @param string $addon_name
481
-     * @param array  $addon_settings
482
-     * @return boolean
483
-     */
484
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
485
-    {
486
-        global $wp_version;
487
-        $incompatibility_message = '';
488
-        //check whether this addon version is compatible with EE core
489
-        if (
490
-            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
491
-            && ! self::_meets_min_core_version_requirement(
492
-                EE_Register_Addon::$_incompatible_addons[$addon_name],
493
-                $addon_settings['version']
494
-            )
495
-        ) {
496
-            $incompatibility_message = sprintf(
497
-                __(
498
-                    '%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.'
499
-                ),
500
-                $addon_name,
501
-                '<br />',
502
-                EE_Register_Addon::$_incompatible_addons[$addon_name],
503
-                '<span style="font-weight: bold; color: #D54E21;">',
504
-                '</span><br />'
505
-            );
506
-        } else if (
507
-        ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
508
-        ) {
509
-            $incompatibility_message = sprintf(
510
-                __(
511
-                    '%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".',
512
-                    'event_espresso'
513
-                ),
514
-                $addon_name,
515
-                self::_effective_version($addon_settings['min_core_version']),
516
-                self::_effective_version(espresso_version()),
517
-                '<br />',
518
-                '<span style="font-weight: bold; color: #D54E21;">',
519
-                '</span><br />'
520
-            );
521
-        } else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
522
-            $incompatibility_message = sprintf(
523
-                __(
524
-                    '%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.',
525
-                    'event_espresso'
526
-                ),
527
-                $addon_name,
528
-                $addon_settings['min_wp_version'],
529
-                '<br />',
530
-                '<span style="font-weight: bold; color: #D54E21;">',
531
-                '</span><br />'
532
-            );
533
-        }
534
-        if (! empty($incompatibility_message)) {
535
-            // remove 'activate' from the REQUEST
536
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
537
-            unset($_GET['activate'], $_REQUEST['activate']);
538
-            if (current_user_can('activate_plugins')) {
539
-                // show an error message indicating the plugin didn't activate properly
540
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
541
-            }
542
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
543
-            return false;
544
-        }
545
-        // addon IS compatible
546
-        return true;
547
-    }
479
+	/**
480
+	 * @param string $addon_name
481
+	 * @param array  $addon_settings
482
+	 * @return boolean
483
+	 */
484
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
485
+	{
486
+		global $wp_version;
487
+		$incompatibility_message = '';
488
+		//check whether this addon version is compatible with EE core
489
+		if (
490
+			isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
491
+			&& ! self::_meets_min_core_version_requirement(
492
+				EE_Register_Addon::$_incompatible_addons[$addon_name],
493
+				$addon_settings['version']
494
+			)
495
+		) {
496
+			$incompatibility_message = sprintf(
497
+				__(
498
+					'%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.'
499
+				),
500
+				$addon_name,
501
+				'<br />',
502
+				EE_Register_Addon::$_incompatible_addons[$addon_name],
503
+				'<span style="font-weight: bold; color: #D54E21;">',
504
+				'</span><br />'
505
+			);
506
+		} else if (
507
+		! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
508
+		) {
509
+			$incompatibility_message = sprintf(
510
+				__(
511
+					'%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".',
512
+					'event_espresso'
513
+				),
514
+				$addon_name,
515
+				self::_effective_version($addon_settings['min_core_version']),
516
+				self::_effective_version(espresso_version()),
517
+				'<br />',
518
+				'<span style="font-weight: bold; color: #D54E21;">',
519
+				'</span><br />'
520
+			);
521
+		} else if (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
522
+			$incompatibility_message = sprintf(
523
+				__(
524
+					'%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.',
525
+					'event_espresso'
526
+				),
527
+				$addon_name,
528
+				$addon_settings['min_wp_version'],
529
+				'<br />',
530
+				'<span style="font-weight: bold; color: #D54E21;">',
531
+				'</span><br />'
532
+			);
533
+		}
534
+		if (! empty($incompatibility_message)) {
535
+			// remove 'activate' from the REQUEST
536
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
537
+			unset($_GET['activate'], $_REQUEST['activate']);
538
+			if (current_user_can('activate_plugins')) {
539
+				// show an error message indicating the plugin didn't activate properly
540
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
541
+			}
542
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
543
+			return false;
544
+		}
545
+		// addon IS compatible
546
+		return true;
547
+	}
548 548
 
549 549
 
550
-    /**
551
-     * if plugin update engine is being used for auto-updates,
552
-     * then let's set that up now before going any further so that ALL addons can be updated
553
-     * (not needed if PUE is not being used)
554
-     *
555
-     * @param string $addon_name
556
-     * @param string $class_name
557
-     * @param array  $setup_args
558
-     * @return void
559
-     */
560
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
561
-    {
562
-        if (! empty($setup_args['pue_options'])) {
563
-            self::$_settings[$addon_name]['pue_options'] = array(
564
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
565
-                    ? (string)$setup_args['pue_options']['pue_plugin_slug']
566
-                    : 'espresso_' . strtolower($class_name),
567
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
568
-                    ? (string)$setup_args['pue_options']['plugin_basename']
569
-                    : plugin_basename($setup_args['main_file_path']),
570
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
571
-                    ? (string)$setup_args['pue_options']['checkPeriod']
572
-                    : '24',
573
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
574
-                    ? (string)$setup_args['pue_options']['use_wp_update']
575
-                    : false,
576
-            );
577
-            add_action(
578
-                'AHEE__EE_System__brew_espresso__after_pue_init',
579
-                array('EE_Register_Addon', 'load_pue_update')
580
-            );
581
-        }
582
-    }
550
+	/**
551
+	 * if plugin update engine is being used for auto-updates,
552
+	 * then let's set that up now before going any further so that ALL addons can be updated
553
+	 * (not needed if PUE is not being used)
554
+	 *
555
+	 * @param string $addon_name
556
+	 * @param string $class_name
557
+	 * @param array  $setup_args
558
+	 * @return void
559
+	 */
560
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
561
+	{
562
+		if (! empty($setup_args['pue_options'])) {
563
+			self::$_settings[$addon_name]['pue_options'] = array(
564
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
565
+					? (string)$setup_args['pue_options']['pue_plugin_slug']
566
+					: 'espresso_' . strtolower($class_name),
567
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
568
+					? (string)$setup_args['pue_options']['plugin_basename']
569
+					: plugin_basename($setup_args['main_file_path']),
570
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
571
+					? (string)$setup_args['pue_options']['checkPeriod']
572
+					: '24',
573
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
574
+					? (string)$setup_args['pue_options']['use_wp_update']
575
+					: false,
576
+			);
577
+			add_action(
578
+				'AHEE__EE_System__brew_espresso__after_pue_init',
579
+				array('EE_Register_Addon', 'load_pue_update')
580
+			);
581
+		}
582
+	}
583 583
 
584 584
 
585
-    /**
586
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
587
-     *
588
-     * @param array $addon_settings
589
-     * @return void
590
-     */
591
-    private static function _setup_namespaces(array $addon_settings)
592
-    {
593
-        //
594
-        if (
595
-        isset(
596
-            $addon_settings['namespace'],
597
-            $addon_settings['namespace']['FQNS'],
598
-            $addon_settings['namespace']['DIR']
599
-        )
600
-        ) {
601
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
602
-                $addon_settings['namespace']['FQNS'],
603
-                $addon_settings['namespace']['DIR']
604
-            );
605
-        }
606
-    }
585
+	/**
586
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
587
+	 *
588
+	 * @param array $addon_settings
589
+	 * @return void
590
+	 */
591
+	private static function _setup_namespaces(array $addon_settings)
592
+	{
593
+		//
594
+		if (
595
+		isset(
596
+			$addon_settings['namespace'],
597
+			$addon_settings['namespace']['FQNS'],
598
+			$addon_settings['namespace']['DIR']
599
+		)
600
+		) {
601
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
602
+				$addon_settings['namespace']['FQNS'],
603
+				$addon_settings['namespace']['DIR']
604
+			);
605
+		}
606
+	}
607 607
 
608 608
 
609
-    /**
610
-     * @param string $addon_name
611
-     * @param array  $addon_settings
612
-     * @return bool
613
-     */
614
-    private static function _addon_activation($addon_name, array $addon_settings)
615
-    {
616
-        // this is an activation request
617
-        if (did_action('activate_plugin')) {
618
-            //to find if THIS is the addon that was activated, just check if we have already registered it or not
619
-            //(as the newly-activated addon wasn't around the first time addons were registered).
620
-            //Note: the presence of pue_options in the addon registration options will initialize the $_settings
621
-            //property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
622
-            if (! isset(self::$_settings[$addon_name])
623
-                || (isset(self::$_settings[$addon_name])
624
-                    && ! isset(self::$_settings[$addon_name]['class_name'])
625
-                )
626
-            ) {
627
-                self::$_settings[$addon_name] = $addon_settings;
628
-                $addon                        = self::_load_and_init_addon_class($addon_name);
629
-                $addon->set_activation_indicator_option();
630
-                // dont bother setting up the rest of the addon.
631
-                // we know it was just activated and the request will end soon
632
-            }
633
-            return true;
634
-        }
635
-        // make sure this was called in the right place!
636
-        if (
637
-            ! did_action('AHEE__EE_System__load_espresso_addons')
638
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
639
-        ) {
640
-            EE_Error::doing_it_wrong(
641
-                __METHOD__,
642
-                sprintf(
643
-                    __(
644
-                        '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.',
645
-                        'event_espresso'
646
-                    ),
647
-                    $addon_name
648
-                ),
649
-                '4.3.0'
650
-            );
651
-        }
652
-        // make sure addon settings are set correctly without overwriting anything existing
653
-        if (isset(self::$_settings[$addon_name])) {
654
-            self::$_settings[$addon_name] += $addon_settings;
655
-        } else {
656
-            self::$_settings[$addon_name] = $addon_settings;
657
-        }
658
-        return false;
659
-    }
609
+	/**
610
+	 * @param string $addon_name
611
+	 * @param array  $addon_settings
612
+	 * @return bool
613
+	 */
614
+	private static function _addon_activation($addon_name, array $addon_settings)
615
+	{
616
+		// this is an activation request
617
+		if (did_action('activate_plugin')) {
618
+			//to find if THIS is the addon that was activated, just check if we have already registered it or not
619
+			//(as the newly-activated addon wasn't around the first time addons were registered).
620
+			//Note: the presence of pue_options in the addon registration options will initialize the $_settings
621
+			//property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
622
+			if (! isset(self::$_settings[$addon_name])
623
+				|| (isset(self::$_settings[$addon_name])
624
+					&& ! isset(self::$_settings[$addon_name]['class_name'])
625
+				)
626
+			) {
627
+				self::$_settings[$addon_name] = $addon_settings;
628
+				$addon                        = self::_load_and_init_addon_class($addon_name);
629
+				$addon->set_activation_indicator_option();
630
+				// dont bother setting up the rest of the addon.
631
+				// we know it was just activated and the request will end soon
632
+			}
633
+			return true;
634
+		}
635
+		// make sure this was called in the right place!
636
+		if (
637
+			! did_action('AHEE__EE_System__load_espresso_addons')
638
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
639
+		) {
640
+			EE_Error::doing_it_wrong(
641
+				__METHOD__,
642
+				sprintf(
643
+					__(
644
+						'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.',
645
+						'event_espresso'
646
+					),
647
+					$addon_name
648
+				),
649
+				'4.3.0'
650
+			);
651
+		}
652
+		// make sure addon settings are set correctly without overwriting anything existing
653
+		if (isset(self::$_settings[$addon_name])) {
654
+			self::$_settings[$addon_name] += $addon_settings;
655
+		} else {
656
+			self::$_settings[$addon_name] = $addon_settings;
657
+		}
658
+		return false;
659
+	}
660 660
 
661 661
 
662
-    /**
663
-     * @param string $addon_name
664
-     * @return void
665
-     * @throws \EE_Error
666
-     */
667
-    private static function _setup_autoloaders($addon_name)
668
-    {
669
-        if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
670
-            // setup autoloader for single file
671
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
672
-        }
673
-        // setup autoloaders for folders
674
-        if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
675
-            foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
676
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
677
-            }
678
-        }
679
-    }
662
+	/**
663
+	 * @param string $addon_name
664
+	 * @return void
665
+	 * @throws \EE_Error
666
+	 */
667
+	private static function _setup_autoloaders($addon_name)
668
+	{
669
+		if (! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
670
+			// setup autoloader for single file
671
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
672
+		}
673
+		// setup autoloaders for folders
674
+		if (! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
675
+			foreach ((array)self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
676
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
677
+			}
678
+		}
679
+	}
680 680
 
681 681
 
682
-    /**
683
-     * register new models and extensions
684
-     *
685
-     * @param string $addon_name
686
-     * @return void
687
-     * @throws \EE_Error
688
-     */
689
-    private static function _register_models_and_extensions($addon_name)
690
-    {
691
-        // register new models
692
-        if (
693
-            ! empty(self::$_settings[$addon_name]['model_paths'])
694
-            || ! empty(self::$_settings[$addon_name]['class_paths'])
695
-        ) {
696
-            EE_Register_Model::register(
697
-                $addon_name,
698
-                array(
699
-                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
700
-                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
701
-                )
702
-            );
703
-        }
704
-        // register model extensions
705
-        if (
706
-            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
707
-            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
708
-        ) {
709
-            EE_Register_Model_Extensions::register(
710
-                $addon_name,
711
-                array(
712
-                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
713
-                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
714
-                )
715
-            );
716
-        }
717
-    }
682
+	/**
683
+	 * register new models and extensions
684
+	 *
685
+	 * @param string $addon_name
686
+	 * @return void
687
+	 * @throws \EE_Error
688
+	 */
689
+	private static function _register_models_and_extensions($addon_name)
690
+	{
691
+		// register new models
692
+		if (
693
+			! empty(self::$_settings[$addon_name]['model_paths'])
694
+			|| ! empty(self::$_settings[$addon_name]['class_paths'])
695
+		) {
696
+			EE_Register_Model::register(
697
+				$addon_name,
698
+				array(
699
+					'model_paths' => self::$_settings[$addon_name]['model_paths'],
700
+					'class_paths' => self::$_settings[$addon_name]['class_paths'],
701
+				)
702
+			);
703
+		}
704
+		// register model extensions
705
+		if (
706
+			! empty(self::$_settings[$addon_name]['model_extension_paths'])
707
+			|| ! empty(self::$_settings[$addon_name]['class_extension_paths'])
708
+		) {
709
+			EE_Register_Model_Extensions::register(
710
+				$addon_name,
711
+				array(
712
+					'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
713
+					'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
714
+				)
715
+			);
716
+		}
717
+	}
718 718
 
719 719
 
720
-    /**
721
-     * @param string $addon_name
722
-     * @return void
723
-     * @throws \EE_Error
724
-     */
725
-    private static function _register_data_migration_scripts($addon_name)
726
-    {
727
-        // setup DMS
728
-        if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
729
-            EE_Register_Data_Migration_Scripts::register(
730
-                $addon_name,
731
-                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
732
-            );
733
-        }
734
-    }
720
+	/**
721
+	 * @param string $addon_name
722
+	 * @return void
723
+	 * @throws \EE_Error
724
+	 */
725
+	private static function _register_data_migration_scripts($addon_name)
726
+	{
727
+		// setup DMS
728
+		if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
729
+			EE_Register_Data_Migration_Scripts::register(
730
+				$addon_name,
731
+				array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
732
+			);
733
+		}
734
+	}
735 735
 
736 736
 
737
-    /**
738
-     * @param string $addon_name
739
-     * @return void
740
-     * @throws \EE_Error
741
-     */
742
-    private static function _register_config($addon_name)
743
-    {
744
-        // if config_class is present let's register config.
745
-        if (! empty(self::$_settings[$addon_name]['config_class'])) {
746
-            EE_Register_Config::register(
747
-                self::$_settings[$addon_name]['config_class'],
748
-                array(
749
-                    'config_section' => self::$_settings[$addon_name]['config_section'],
750
-                    'config_name'    => self::$_settings[$addon_name]['config_name'],
751
-                )
752
-            );
753
-        }
754
-    }
737
+	/**
738
+	 * @param string $addon_name
739
+	 * @return void
740
+	 * @throws \EE_Error
741
+	 */
742
+	private static function _register_config($addon_name)
743
+	{
744
+		// if config_class is present let's register config.
745
+		if (! empty(self::$_settings[$addon_name]['config_class'])) {
746
+			EE_Register_Config::register(
747
+				self::$_settings[$addon_name]['config_class'],
748
+				array(
749
+					'config_section' => self::$_settings[$addon_name]['config_section'],
750
+					'config_name'    => self::$_settings[$addon_name]['config_name'],
751
+				)
752
+			);
753
+		}
754
+	}
755 755
 
756 756
 
757
-    /**
758
-     * @param string $addon_name
759
-     * @return void
760
-     * @throws \EE_Error
761
-     */
762
-    private static function _register_admin_pages($addon_name)
763
-    {
764
-        if (! empty(self::$_settings[$addon_name]['admin_path'])) {
765
-            EE_Register_Admin_Page::register(
766
-                $addon_name,
767
-                array('page_path' => self::$_settings[$addon_name]['admin_path'])
768
-            );
769
-        }
770
-    }
757
+	/**
758
+	 * @param string $addon_name
759
+	 * @return void
760
+	 * @throws \EE_Error
761
+	 */
762
+	private static function _register_admin_pages($addon_name)
763
+	{
764
+		if (! empty(self::$_settings[$addon_name]['admin_path'])) {
765
+			EE_Register_Admin_Page::register(
766
+				$addon_name,
767
+				array('page_path' => self::$_settings[$addon_name]['admin_path'])
768
+			);
769
+		}
770
+	}
771 771
 
772 772
 
773
-    /**
774
-     * @param string $addon_name
775
-     * @return void
776
-     * @throws \EE_Error
777
-     */
778
-    private static function _register_modules($addon_name)
779
-    {
780
-        if (! empty(self::$_settings[$addon_name]['module_paths'])) {
781
-            EE_Register_Module::register(
782
-                $addon_name,
783
-                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
784
-            );
785
-        }
786
-    }
773
+	/**
774
+	 * @param string $addon_name
775
+	 * @return void
776
+	 * @throws \EE_Error
777
+	 */
778
+	private static function _register_modules($addon_name)
779
+	{
780
+		if (! empty(self::$_settings[$addon_name]['module_paths'])) {
781
+			EE_Register_Module::register(
782
+				$addon_name,
783
+				array('module_paths' => self::$_settings[$addon_name]['module_paths'])
784
+			);
785
+		}
786
+	}
787 787
 
788 788
 
789
-    /**
790
-     * @param string $addon_name
791
-     * @return void
792
-     * @throws \EE_Error
793
-     */
794
-    private static function _register_shortcodes($addon_name)
795
-    {
796
-        if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
797
-            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
798
-        ) {
799
-            EE_Register_Shortcode::register(
800
-                $addon_name,
801
-                array(
802
-                    'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
803
-                        ? self::$_settings[$addon_name]['shortcode_paths']
804
-                        : array(),
805
-                    'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
806
-                        ? self::$_settings[$addon_name]['shortcode_fqcns']
807
-                        : array()
808
-                )
809
-            );
810
-        }
811
-    }
789
+	/**
790
+	 * @param string $addon_name
791
+	 * @return void
792
+	 * @throws \EE_Error
793
+	 */
794
+	private static function _register_shortcodes($addon_name)
795
+	{
796
+		if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
797
+			|| ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
798
+		) {
799
+			EE_Register_Shortcode::register(
800
+				$addon_name,
801
+				array(
802
+					'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
803
+						? self::$_settings[$addon_name]['shortcode_paths']
804
+						: array(),
805
+					'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
806
+						? self::$_settings[$addon_name]['shortcode_fqcns']
807
+						: array()
808
+				)
809
+			);
810
+		}
811
+	}
812 812
 
813 813
 
814
-    /**
815
-     * @param string $addon_name
816
-     * @return void
817
-     * @throws \EE_Error
818
-     */
819
-    private static function _register_widgets($addon_name)
820
-    {
821
-        if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
822
-            EE_Register_Widget::register(
823
-                $addon_name,
824
-                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
825
-            );
826
-        }
827
-    }
814
+	/**
815
+	 * @param string $addon_name
816
+	 * @return void
817
+	 * @throws \EE_Error
818
+	 */
819
+	private static function _register_widgets($addon_name)
820
+	{
821
+		if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
822
+			EE_Register_Widget::register(
823
+				$addon_name,
824
+				array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
825
+			);
826
+		}
827
+	}
828 828
 
829 829
 
830
-    /**
831
-     * @param string $addon_name
832
-     * @return void
833
-     * @throws \EE_Error
834
-     */
835
-    private static function _register_capabilities($addon_name)
836
-    {
837
-        if (! empty(self::$_settings[$addon_name]['capabilities'])) {
838
-            EE_Register_Capabilities::register(
839
-                $addon_name,
840
-                array(
841
-                    'capabilities'       => self::$_settings[$addon_name]['capabilities'],
842
-                    'capability_maps'    => self::$_settings[$addon_name]['capability_maps'],
843
-                )
844
-            );
845
-        }
846
-    }
830
+	/**
831
+	 * @param string $addon_name
832
+	 * @return void
833
+	 * @throws \EE_Error
834
+	 */
835
+	private static function _register_capabilities($addon_name)
836
+	{
837
+		if (! empty(self::$_settings[$addon_name]['capabilities'])) {
838
+			EE_Register_Capabilities::register(
839
+				$addon_name,
840
+				array(
841
+					'capabilities'       => self::$_settings[$addon_name]['capabilities'],
842
+					'capability_maps'    => self::$_settings[$addon_name]['capability_maps'],
843
+				)
844
+			);
845
+		}
846
+	}
847 847
 
848 848
 
849
-    /**
850
-     * @param string $addon_name
851
-     * @return void
852
-     * @throws \EE_Error
853
-     */
854
-    private static function _register_message_types($addon_name)
855
-    {
856
-        if (! empty(self::$_settings[$addon_name]['message_types'])) {
857
-            add_action(
858
-                'EE_Brewing_Regular___messages_caf',
859
-                array('EE_Register_Addon', 'register_message_types')
860
-            );
861
-        }
862
-    }
849
+	/**
850
+	 * @param string $addon_name
851
+	 * @return void
852
+	 * @throws \EE_Error
853
+	 */
854
+	private static function _register_message_types($addon_name)
855
+	{
856
+		if (! empty(self::$_settings[$addon_name]['message_types'])) {
857
+			add_action(
858
+				'EE_Brewing_Regular___messages_caf',
859
+				array('EE_Register_Addon', 'register_message_types')
860
+			);
861
+		}
862
+	}
863 863
 
864 864
 
865
-    /**
866
-     * @param string $addon_name
867
-     * @return void
868
-     * @throws \EE_Error
869
-     */
870
-    private static function _register_custom_post_types($addon_name)
871
-    {
872
-        if (
873
-            ! empty(self::$_settings[$addon_name]['custom_post_types'])
874
-            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
875
-        ) {
876
-            EE_Register_CPT::register(
877
-                $addon_name,
878
-                array(
879
-                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
880
-                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
881
-                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
882
-                )
883
-            );
884
-        }
885
-    }
865
+	/**
866
+	 * @param string $addon_name
867
+	 * @return void
868
+	 * @throws \EE_Error
869
+	 */
870
+	private static function _register_custom_post_types($addon_name)
871
+	{
872
+		if (
873
+			! empty(self::$_settings[$addon_name]['custom_post_types'])
874
+			|| ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
875
+		) {
876
+			EE_Register_CPT::register(
877
+				$addon_name,
878
+				array(
879
+					'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
880
+					'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
881
+					'default_terms' => self::$_settings[$addon_name]['default_terms'],
882
+				)
883
+			);
884
+		}
885
+	}
886 886
 
887 887
 
888
-    /**
889
-     * @param string $addon_name
890
-     * @return void
891
-     * @throws \EE_Error
892
-     */
893
-    private static function _register_payment_methods($addon_name)
894
-    {
895
-        if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
896
-            EE_Register_Payment_Method::register(
897
-                $addon_name,
898
-                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
899
-            );
900
-        }
901
-    }
888
+	/**
889
+	 * @param string $addon_name
890
+	 * @return void
891
+	 * @throws \EE_Error
892
+	 */
893
+	private static function _register_payment_methods($addon_name)
894
+	{
895
+		if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
896
+			EE_Register_Payment_Method::register(
897
+				$addon_name,
898
+				array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
899
+			);
900
+		}
901
+	}
902 902
 
903 903
 
904
-    /**
905
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
906
-     *
907
-     * @param string $addon_name
908
-     * @return EE_Addon
909
-     */
910
-    private static function _load_and_init_addon_class($addon_name)
911
-    {
912
-        $addon = EE_Registry::instance()->load_addon(
913
-            dirname(self::$_settings[$addon_name]['main_file_path']),
914
-            self::$_settings[$addon_name]['class_name']
915
-        );
916
-        $addon->set_name($addon_name);
917
-        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
918
-        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
919
-        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
920
-        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
921
-        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
922
-        $addon->set_version(self::$_settings[$addon_name]['version']);
923
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
924
-        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
925
-        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
926
-        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
927
-        //unfortunately this can't be hooked in upon construction, because we don't have
928
-        //the plugin mainfile's path upon construction.
929
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
930
-        // call any additional admin_callback functions during load_admin_controller hook
931
-        if (! empty(self::$_settings[$addon_name]['admin_callback'])) {
932
-            add_action(
933
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
934
-                array($addon, self::$_settings[$addon_name]['admin_callback'])
935
-            );
936
-        }
937
-        return $addon;
938
-    }
904
+	/**
905
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
906
+	 *
907
+	 * @param string $addon_name
908
+	 * @return EE_Addon
909
+	 */
910
+	private static function _load_and_init_addon_class($addon_name)
911
+	{
912
+		$addon = EE_Registry::instance()->load_addon(
913
+			dirname(self::$_settings[$addon_name]['main_file_path']),
914
+			self::$_settings[$addon_name]['class_name']
915
+		);
916
+		$addon->set_name($addon_name);
917
+		$addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
918
+		$addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
919
+		$addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
920
+		$addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
921
+		$addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
922
+		$addon->set_version(self::$_settings[$addon_name]['version']);
923
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
924
+		$addon->set_config_section(self::$_settings[$addon_name]['config_section']);
925
+		$addon->set_config_class(self::$_settings[$addon_name]['config_class']);
926
+		$addon->set_config_name(self::$_settings[$addon_name]['config_name']);
927
+		//unfortunately this can't be hooked in upon construction, because we don't have
928
+		//the plugin mainfile's path upon construction.
929
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
930
+		// call any additional admin_callback functions during load_admin_controller hook
931
+		if (! empty(self::$_settings[$addon_name]['admin_callback'])) {
932
+			add_action(
933
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
934
+				array($addon, self::$_settings[$addon_name]['admin_callback'])
935
+			);
936
+		}
937
+		return $addon;
938
+	}
939 939
 
940 940
 
941
-    /**
942
-     *    load_pue_update - Update notifications
943
-     *
944
-     * @return    void
945
-     */
946
-    public static function load_pue_update()
947
-    {
948
-        // load PUE client
949
-        require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
950
-        // cycle thru settings
951
-        foreach (self::$_settings as $settings) {
952
-            if (! empty($settings['pue_options'])) {
953
-                // initiate the class and start the plugin update engine!
954
-                new PluginUpdateEngineChecker(
955
-                // host file URL
956
-                    'https://eventespresso.com',
957
-                    // plugin slug(s)
958
-                    array(
959
-                        'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
960
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
961
-                    ),
962
-                    // options
963
-                    array(
964
-                        'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
965
-                        'lang_domain'       => 'event_espresso',
966
-                        'checkPeriod'       => $settings['pue_options']['checkPeriod'],
967
-                        'option_key'        => 'site_license_key',
968
-                        'options_page_slug' => 'event_espresso',
969
-                        'plugin_basename'   => $settings['pue_options']['plugin_basename'],
970
-                        // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
971
-                        'use_wp_update'     => $settings['pue_options']['use_wp_update'],
972
-                    )
973
-                );
974
-            }
975
-        }
976
-    }
941
+	/**
942
+	 *    load_pue_update - Update notifications
943
+	 *
944
+	 * @return    void
945
+	 */
946
+	public static function load_pue_update()
947
+	{
948
+		// load PUE client
949
+		require_once EE_THIRD_PARTY . 'pue' . DS . 'pue-client.php';
950
+		// cycle thru settings
951
+		foreach (self::$_settings as $settings) {
952
+			if (! empty($settings['pue_options'])) {
953
+				// initiate the class and start the plugin update engine!
954
+				new PluginUpdateEngineChecker(
955
+				// host file URL
956
+					'https://eventespresso.com',
957
+					// plugin slug(s)
958
+					array(
959
+						'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
960
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
961
+					),
962
+					// options
963
+					array(
964
+						'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
965
+						'lang_domain'       => 'event_espresso',
966
+						'checkPeriod'       => $settings['pue_options']['checkPeriod'],
967
+						'option_key'        => 'site_license_key',
968
+						'options_page_slug' => 'event_espresso',
969
+						'plugin_basename'   => $settings['pue_options']['plugin_basename'],
970
+						// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
971
+						'use_wp_update'     => $settings['pue_options']['use_wp_update'],
972
+					)
973
+				);
974
+			}
975
+		}
976
+	}
977 977
 
978 978
 
979
-    /**
980
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
981
-     *
982
-     * @since 4.4.0
983
-     * @return void
984
-     * @throws \EE_Error
985
-     */
986
-    public static function register_message_types()
987
-    {
988
-        foreach (self::$_settings as $addon_name => $settings) {
989
-            if (! empty($settings['message_types'])) {
990
-                foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
991
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
992
-                }
993
-            }
994
-        }
995
-    }
979
+	/**
980
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
981
+	 *
982
+	 * @since 4.4.0
983
+	 * @return void
984
+	 * @throws \EE_Error
985
+	 */
986
+	public static function register_message_types()
987
+	{
988
+		foreach (self::$_settings as $addon_name => $settings) {
989
+			if (! empty($settings['message_types'])) {
990
+				foreach ((array)$settings['message_types'] as $message_type => $message_type_settings) {
991
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
992
+				}
993
+			}
994
+		}
995
+	}
996 996
 
997 997
 
998
-    /**
999
-     * This deregisters an addon that was previously registered with a specific addon_name.
1000
-     *
1001
-     * @since    4.3.0
1002
-     * @param string $addon_name the name for the addon that was previously registered
1003
-     * @throws EE_Error
1004
-     * @return void
1005
-     */
1006
-    public static function deregister($addon_name = null)
1007
-    {
1008
-        if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) {
1009
-            do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1010
-            $class_name = self::$_settings[$addon_name]['class_name'];
1011
-            if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
1012
-                // setup DMS
1013
-                EE_Register_Data_Migration_Scripts::deregister($addon_name);
1014
-            }
1015
-            if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1016
-                // register admin page
1017
-                EE_Register_Admin_Page::deregister($addon_name);
1018
-            }
1019
-            if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1020
-                // add to list of modules to be registered
1021
-                EE_Register_Module::deregister($addon_name);
1022
-            }
1023
-            if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
1024
-                || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1025
-            ) {
1026
-                // add to list of shortcodes to be registered
1027
-                EE_Register_Shortcode::deregister($addon_name);
1028
-            }
1029
-            if (! empty(self::$_settings[$addon_name]['config_class'])) {
1030
-                // if config_class present let's register config.
1031
-                EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1032
-            }
1033
-            if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1034
-                // add to list of widgets to be registered
1035
-                EE_Register_Widget::deregister($addon_name);
1036
-            }
1037
-            if (! empty(self::$_settings[$addon_name]['model_paths'])
1038
-                ||
1039
-                ! empty(self::$_settings[$addon_name]['class_paths'])
1040
-            ) {
1041
-                // add to list of shortcodes to be registered
1042
-                EE_Register_Model::deregister($addon_name);
1043
-            }
1044
-            if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1045
-                ||
1046
-                ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1047
-            ) {
1048
-                // add to list of shortcodes to be registered
1049
-                EE_Register_Model_Extensions::deregister($addon_name);
1050
-            }
1051
-            if (! empty(self::$_settings[$addon_name]['message_types'])) {
1052
-                foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1053
-                    EE_Register_Message_Type::deregister($message_type);
1054
-                }
1055
-            }
1056
-            //deregister capabilities for addon
1057
-            if (
1058
-                ! empty(self::$_settings[$addon_name]['capabilities'])
1059
-                || ! empty(self::$_settings[$addon_name]['capability_maps'])
1060
-            ) {
1061
-                EE_Register_Capabilities::deregister($addon_name);
1062
-            }
1063
-            //deregister custom_post_types for addon
1064
-            if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1065
-                EE_Register_CPT::deregister($addon_name);
1066
-            }
1067
-            if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1068
-                EE_Register_Payment_Method::deregister($addon_name);
1069
-            }
1070
-            remove_action(
1071
-                'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1072
-                array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')
1073
-            );
1074
-            remove_action(
1075
-                'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1076
-                array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')
1077
-            );
1078
-            //remove `after_registration` call
1079
-            remove_action(
1080
-                'AHEE__EE_System__load_espresso_addons__complete',
1081
-                array(EE_Registry::instance()->addons->{$class_name}, 'after_registration'),
1082
-                999
1083
-            );
1084
-            unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]);
998
+	/**
999
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1000
+	 *
1001
+	 * @since    4.3.0
1002
+	 * @param string $addon_name the name for the addon that was previously registered
1003
+	 * @throws EE_Error
1004
+	 * @return void
1005
+	 */
1006
+	public static function deregister($addon_name = null)
1007
+	{
1008
+		if (isset(self::$_settings[$addon_name], self::$_settings[$addon_name]['class_name'])) {
1009
+			do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1010
+			$class_name = self::$_settings[$addon_name]['class_name'];
1011
+			if (! empty(self::$_settings[$addon_name]['dms_paths'])) {
1012
+				// setup DMS
1013
+				EE_Register_Data_Migration_Scripts::deregister($addon_name);
1014
+			}
1015
+			if (! empty(self::$_settings[$addon_name]['admin_path'])) {
1016
+				// register admin page
1017
+				EE_Register_Admin_Page::deregister($addon_name);
1018
+			}
1019
+			if (! empty(self::$_settings[$addon_name]['module_paths'])) {
1020
+				// add to list of modules to be registered
1021
+				EE_Register_Module::deregister($addon_name);
1022
+			}
1023
+			if (! empty(self::$_settings[$addon_name]['shortcode_paths'])
1024
+				|| ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1025
+			) {
1026
+				// add to list of shortcodes to be registered
1027
+				EE_Register_Shortcode::deregister($addon_name);
1028
+			}
1029
+			if (! empty(self::$_settings[$addon_name]['config_class'])) {
1030
+				// if config_class present let's register config.
1031
+				EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1032
+			}
1033
+			if (! empty(self::$_settings[$addon_name]['widget_paths'])) {
1034
+				// add to list of widgets to be registered
1035
+				EE_Register_Widget::deregister($addon_name);
1036
+			}
1037
+			if (! empty(self::$_settings[$addon_name]['model_paths'])
1038
+				||
1039
+				! empty(self::$_settings[$addon_name]['class_paths'])
1040
+			) {
1041
+				// add to list of shortcodes to be registered
1042
+				EE_Register_Model::deregister($addon_name);
1043
+			}
1044
+			if (! empty(self::$_settings[$addon_name]['model_extension_paths'])
1045
+				||
1046
+				! empty(self::$_settings[$addon_name]['class_extension_paths'])
1047
+			) {
1048
+				// add to list of shortcodes to be registered
1049
+				EE_Register_Model_Extensions::deregister($addon_name);
1050
+			}
1051
+			if (! empty(self::$_settings[$addon_name]['message_types'])) {
1052
+				foreach ((array)self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1053
+					EE_Register_Message_Type::deregister($message_type);
1054
+				}
1055
+			}
1056
+			//deregister capabilities for addon
1057
+			if (
1058
+				! empty(self::$_settings[$addon_name]['capabilities'])
1059
+				|| ! empty(self::$_settings[$addon_name]['capability_maps'])
1060
+			) {
1061
+				EE_Register_Capabilities::deregister($addon_name);
1062
+			}
1063
+			//deregister custom_post_types for addon
1064
+			if (! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1065
+				EE_Register_CPT::deregister($addon_name);
1066
+			}
1067
+			if (! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1068
+				EE_Register_Payment_Method::deregister($addon_name);
1069
+			}
1070
+			remove_action(
1071
+				'deactivate_' . EE_Registry::instance()->addons->{$class_name}->get_main_plugin_file_basename(),
1072
+				array(EE_Registry::instance()->addons->{$class_name}, 'deactivation')
1073
+			);
1074
+			remove_action(
1075
+				'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1076
+				array(EE_Registry::instance()->addons->{$class_name}, 'initialize_db_if_no_migrations_required')
1077
+			);
1078
+			//remove `after_registration` call
1079
+			remove_action(
1080
+				'AHEE__EE_System__load_espresso_addons__complete',
1081
+				array(EE_Registry::instance()->addons->{$class_name}, 'after_registration'),
1082
+				999
1083
+			);
1084
+			unset(EE_Registry::instance()->addons->{$class_name}, self::$_settings[$addon_name]);
1085 1085
 
1086
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1087
-        }
1088
-    }
1086
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1087
+		}
1088
+	}
1089 1089
 
1090 1090
 
1091 1091
 }
Please login to merge, or discard this patch.