Completed
Branch BUG/3575-event-deletion-previe... (bbeda1)
by
unknown
06:40 queued 04:49
created
core/libraries/plugin_api/db/EEE_Base_Class.lib.php 2 patches
Indentation   +117 added lines, -117 removed lines patch added patch discarded remove patch
@@ -32,126 +32,126 @@
 block discarded – undo
32 32
 class EEE_Base_Class
33 33
 {
34 34
 
35
-    const extending_method_prefix = 'ext_';
36
-    const dynamic_callback_method_prefix = 'dynamic_callback_method_';
37
-    /**
38
-     * The model name that is extended (not classname)
39
-     *
40
-     * @var string
41
-     */
42
-    protected $_model_name_extended = null;
43
-    /**
44
-     * The model this extends
45
-     *
46
-     * @var EE_Base_Class
47
-     */
48
-    protected $_ = null;
35
+	const extending_method_prefix = 'ext_';
36
+	const dynamic_callback_method_prefix = 'dynamic_callback_method_';
37
+	/**
38
+	 * The model name that is extended (not classname)
39
+	 *
40
+	 * @var string
41
+	 */
42
+	protected $_model_name_extended = null;
43
+	/**
44
+	 * The model this extends
45
+	 *
46
+	 * @var EE_Base_Class
47
+	 */
48
+	protected $_ = null;
49 49
 
50
-    public function __construct()
51
-    {
52
-        if (! $this->_model_name_extended) {
53
-            throw new EE_Error(
54
-                sprintf(
55
-                    esc_html__(
56
-                        "When declaring a class extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
57
-                        "event_espresso"
58
-                    )
59
-                )
60
-            );
61
-        }
62
-        if (did_action('AHEE__EE_' . $this->_model_name_extended . '__construct__end')) {
63
-            throw new EE_Error(
64
-                sprintf(
65
-                    esc_html__(
66
-                        "Hooked in model object extension '%s' too late! The model object %s has already been used!",
67
-                        "event_espresso"
68
-                    ),
69
-                    get_class($this),
70
-                    $this->_model_name_extended
71
-                )
72
-            );
73
-        }
74
-        $this->_register_extending_methods();
75
-    }
50
+	public function __construct()
51
+	{
52
+		if (! $this->_model_name_extended) {
53
+			throw new EE_Error(
54
+				sprintf(
55
+					esc_html__(
56
+						"When declaring a class extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
57
+						"event_espresso"
58
+					)
59
+				)
60
+			);
61
+		}
62
+		if (did_action('AHEE__EE_' . $this->_model_name_extended . '__construct__end')) {
63
+			throw new EE_Error(
64
+				sprintf(
65
+					esc_html__(
66
+						"Hooked in model object extension '%s' too late! The model object %s has already been used!",
67
+						"event_espresso"
68
+					),
69
+					get_class($this),
70
+					$this->_model_name_extended
71
+				)
72
+			);
73
+		}
74
+		$this->_register_extending_methods();
75
+	}
76 76
 
77
-    /**
78
-     * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
79
-     * model extended. (Internally uses filters, and the __call magic method)
80
-     */
81
-    protected function _register_extending_methods()
82
-    {
83
-        $all_methods = get_class_methods(get_class($this));
84
-        foreach ($all_methods as $method_name) {
85
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
86
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
87
-                $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
88
-                add_filter(
89
-                    $callback_name,
90
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
91
-                    10,
92
-                    10
93
-                );
94
-            }
95
-        }
96
-    }
77
+	/**
78
+	 * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
79
+	 * model extended. (Internally uses filters, and the __call magic method)
80
+	 */
81
+	protected function _register_extending_methods()
82
+	{
83
+		$all_methods = get_class_methods(get_class($this));
84
+		foreach ($all_methods as $method_name) {
85
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
86
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
87
+				$callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
88
+				add_filter(
89
+					$callback_name,
90
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
91
+					10,
92
+					10
93
+				);
94
+			}
95
+		}
96
+	}
97 97
 
98
-    /**
99
-     * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
100
-     * model extended. (Internally uses filters, and the __call magic method)
101
-     */
102
-    public function deregister()
103
-    {
104
-        $all_methods = get_class_methods(get_class($this));
105
-        foreach ($all_methods as $method_name) {
106
-            if (strpos($method_name, self::extending_method_prefix) === 0) {
107
-                $method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
108
-                $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
109
-                remove_filter(
110
-                    $callback_name,
111
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
112
-                    10
113
-                );
114
-            }
115
-        }
116
-    }
98
+	/**
99
+	 * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
100
+	 * model extended. (Internally uses filters, and the __call magic method)
101
+	 */
102
+	public function deregister()
103
+	{
104
+		$all_methods = get_class_methods(get_class($this));
105
+		foreach ($all_methods as $method_name) {
106
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
107
+				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
108
+				$callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
109
+				remove_filter(
110
+					$callback_name,
111
+					array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
112
+					10
113
+				);
114
+			}
115
+		}
116
+	}
117 117
 
118 118
 
119
-    public function __call($callback_method_name, $args)
120
-    {
121
-        if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
122
-            // it's a dynamic callback for a method name
123
-            $method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
124
-            $original_return_val = $args[0];
125
-            $model_called = $args[1];
126
-            // phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
127
-            $this->_ = $model_called;
128
-            // phpcs:enable
129
-            $args_provided_to_method_on_model = $args[2];
130
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
131
-            if (method_exists($this, $extending_method)) {
132
-                return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
133
-            } else {
134
-                throw new EE_Error(
135
-                    sprintf(
136
-                        esc_html__(
137
-                            "An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
138
-                            "event_espresso"
139
-                        ),
140
-                        $this->_model_name_extended,
141
-                        get_class($this),
142
-                        $extending_method,
143
-                        $extending_method
144
-                    )
145
-                );
146
-            }
147
-        } else {
148
-            throw new EE_Error(
149
-                sprintf(
150
-                    esc_html__("There is no method named '%s' on '%s'", "event_espresso"),
151
-                    $callback_method_name,
152
-                    get_class($this)
153
-                )
154
-            );
155
-        }
156
-    }
119
+	public function __call($callback_method_name, $args)
120
+	{
121
+		if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
122
+			// it's a dynamic callback for a method name
123
+			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
124
+			$original_return_val = $args[0];
125
+			$model_called = $args[1];
126
+			// phpcs:disable WordPress.WP.I18n.SingleUnderscoreGetTextFunction
127
+			$this->_ = $model_called;
128
+			// phpcs:enable
129
+			$args_provided_to_method_on_model = $args[2];
130
+			$extending_method = self::extending_method_prefix . $method_called_on_model;
131
+			if (method_exists($this, $extending_method)) {
132
+				return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
133
+			} else {
134
+				throw new EE_Error(
135
+					sprintf(
136
+						esc_html__(
137
+							"An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)",
138
+							"event_espresso"
139
+						),
140
+						$this->_model_name_extended,
141
+						get_class($this),
142
+						$extending_method,
143
+						$extending_method
144
+					)
145
+				);
146
+			}
147
+		} else {
148
+			throw new EE_Error(
149
+				sprintf(
150
+					esc_html__("There is no method named '%s' on '%s'", "event_espresso"),
151
+					$callback_method_name,
152
+					get_class($this)
153
+				)
154
+			);
155
+		}
156
+	}
157 157
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
     public function __construct()
51 51
     {
52
-        if (! $this->_model_name_extended) {
52
+        if ( ! $this->_model_name_extended) {
53 53
             throw new EE_Error(
54 54
                 sprintf(
55 55
                     esc_html__(
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
                 )
60 60
             );
61 61
         }
62
-        if (did_action('AHEE__EE_' . $this->_model_name_extended . '__construct__end')) {
62
+        if (did_action('AHEE__EE_'.$this->_model_name_extended.'__construct__end')) {
63 63
             throw new EE_Error(
64 64
                 sprintf(
65 65
                     esc_html__(
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
                 $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
88 88
                 add_filter(
89 89
                     $callback_name,
90
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
90
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
91 91
                     10,
92 92
                     10
93 93
                 );
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
                 $callback_name = "FHEE__EE_{$this->_model_name_extended}__$method_name_on_model";
109 109
                 remove_filter(
110 110
                     $callback_name,
111
-                    array($this, self::dynamic_callback_method_prefix . $method_name_on_model),
111
+                    array($this, self::dynamic_callback_method_prefix.$method_name_on_model),
112 112
                     10
113 113
                 );
114 114
             }
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             $this->_ = $model_called;
128 128
             // phpcs:enable
129 129
             $args_provided_to_method_on_model = $args[2];
130
-            $extending_method = self::extending_method_prefix . $method_called_on_model;
130
+            $extending_method = self::extending_method_prefix.$method_called_on_model;
131 131
             if (method_exists($this, $extending_method)) {
132 132
                 return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
133 133
             } else {
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Addon.lib.php 2 patches
Indentation   +1250 added lines, -1250 removed lines patch added patch discarded remove patch
@@ -23,1254 +23,1254 @@
 block discarded – undo
23 23
 class EE_Register_Addon implements EEI_Plugin_API
24 24
 {
25 25
 
26
-    /**
27
-     * possibly truncated version of the EE core version string
28
-     *
29
-     * @var string
30
-     */
31
-    protected static $_core_version = '';
32
-
33
-    /**
34
-     * Holds values for registered addons
35
-     *
36
-     * @var array
37
-     */
38
-    protected static $_settings = array();
39
-
40
-    /**
41
-     * @var  array $_incompatible_addons keys are addon SLUGS
42
-     * (first argument passed to EE_Register_Addon::register()), keys are
43
-     * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
44
-     * Generally this should be used sparingly, as we don't want to muddle up
45
-     * EE core with knowledge of ALL the addons out there.
46
-     * If you want NO versions of an addon to run with a certain version of core,
47
-     * it's usually best to define the addon's "min_core_version" as part of its call
48
-     * to EE_Register_Addon::register(), rather than using this array with a super high value for its
49
-     * minimum plugin version.
50
-     * @access    protected
51
-     */
52
-    protected static $_incompatible_addons = array(
53
-        'Multi_Event_Registration' => '2.0.11.rc.002',
54
-        'Promotions'               => '1.0.0.rc.084',
55
-    );
56
-
57
-
58
-    /**
59
-     * We should always be comparing core to a version like '4.3.0.rc.000',
60
-     * not just '4.3.0'.
61
-     * So if the addon developer doesn't provide that full version string,
62
-     * fill in the blanks for them
63
-     *
64
-     * @param string $min_core_version
65
-     * @return string always like '4.3.0.rc.000'
66
-     */
67
-    protected static function _effective_version($min_core_version)
68
-    {
69
-        // versions: 4 . 3 . 1 . p . 123
70
-        // offsets:    0 . 1 . 2 . 3 . 4
71
-        $version_parts = explode('.', $min_core_version);
72
-        // check they specified the micro version (after 2nd period)
73
-        if (! isset($version_parts[2])) {
74
-            $version_parts[2] = '0';
75
-        }
76
-        // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
77
-        // soon we can assume that's 'rc', but this current version is 'alpha'
78
-        if (! isset($version_parts[3])) {
79
-            $version_parts[3] = 'dev';
80
-        }
81
-        if (! isset($version_parts[4])) {
82
-            $version_parts[4] = '000';
83
-        }
84
-        return implode('.', $version_parts);
85
-    }
86
-
87
-
88
-    /**
89
-     * Returns whether or not the min core version requirement of the addon is met
90
-     *
91
-     * @param string $min_core_version    the minimum core version required by the addon
92
-     * @param string $actual_core_version the actual core version, optional
93
-     * @return boolean
94
-     */
95
-    public static function _meets_min_core_version_requirement(
96
-        $min_core_version,
97
-        $actual_core_version = EVENT_ESPRESSO_VERSION
98
-    ) {
99
-        return version_compare(
100
-            self::_effective_version($actual_core_version),
101
-            self::_effective_version($min_core_version),
102
-            '>='
103
-        );
104
-    }
105
-
106
-
107
-    /**
108
-     * Method for registering new EE_Addons.
109
-     * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
110
-     * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
111
-     * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
112
-     * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
113
-     * 'activate_plugin', it registers the addon still, but its components are not registered
114
-     * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
115
-     * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
116
-     * (so that we can detect that the addon has activated on the subsequent request)
117
-     *
118
-     * @since    4.3.0
119
-     * @param string                  $addon_name                       [Required] the EE_Addon's name.
120
-     * @param  array                  $setup_args                       {
121
-     *                                                                  An array of arguments provided for registering
122
-     *                                                                  the message type.
123
-     * @type  string                  $class_name                       the addon's main file name.
124
-     *                                                                  If left blank, generated from the addon name,
125
-     *                                                                  changes something like "calendar" to
126
-     *                                                                  "EE_Calendar"
127
-     * @type string                   $min_core_version                 the minimum version of EE Core that the
128
-     *                                                                  addon will work with. eg "4.8.1.rc.084"
129
-     * @type string                   $version                          the "software" version for the addon. eg
130
-     *                                                                  "1.0.0.p" for a first stable release, or
131
-     *                                                                  "1.0.0.rc.043" for a version in progress
132
-     * @type string                   $main_file_path                   the full server path to the main file
133
-     *                                                                  loaded directly by WP
134
-     * @type DomainInterface $domain                                    child class of
135
-     *                                                                  EventEspresso\core\domain\DomainBase
136
-     * @type string                   $domain_fqcn                      Fully Qualified Class Name
137
-     *                                                                  for the addon's Domain class
138
-     *                                                                  (see EventEspresso\core\domain\Domain)
139
-     * @type string                   $admin_path                       full server path to the folder where the
140
-     *                                                                  addon\'s admin files reside
141
-     * @type string                   $admin_callback                   a method to be called when the EE Admin is
142
-     *                                                                  first invoked, can be used for hooking into
143
-     *                                                                  any admin page
144
-     * @type string                   $config_section                   the section name for this addon's
145
-     *                                                                  configuration settings section
146
-     *                                                                  (defaults to "addons")
147
-     * @type string                   $config_class                     the class name for this addon's
148
-     *                                                                  configuration settings object
149
-     * @type string                   $config_name                      the class name for this addon's
150
-     *                                                                  configuration settings object
151
-     * @type string                   $autoloader_paths                 [Required] an array of class names and the full
152
-     *                                                                  server paths to those files.
153
-     * @type string                   $autoloader_folders               an array of  "full server paths" for any
154
-     *                                                                  folders containing classes that might be
155
-     *                                                                  invoked by the addon
156
-     * @type string                   $dms_paths                        [Required] an array of full server paths to
157
-     *                                                                  folders that contain data migration scripts.
158
-     *                                                                  The key should be the EE_Addon class name that
159
-     *                                                                  this set of data migration scripts belongs to.
160
-     *                                                                  If the EE_Addon class is namespaced, then this
161
-     *                                                                  needs to be the Fully Qualified Class Name
162
-     * @type string                   $module_paths                     an array of full server paths to any
163
-     *                                                                  EED_Modules used by the addon
164
-     * @type string                   $shortcode_paths                  an array of full server paths to folders
165
-     *                                                                  that contain EES_Shortcodes
166
-     * @type string                   $widget_paths                     an array of full server paths to folders
167
-     *                                                                  that contain WP_Widgets
168
-     * @type string                   $pue_options
169
-     * @type array                    $capabilities                     an array indexed by role name
170
-     *                                                                  (i.e administrator,author ) and the values
171
-     *                                                                  are an array of caps to add to the role.
172
-     *                                                                  'administrator' => array(
173
-     *                                                                  'read_addon',
174
-     *                                                                  'edit_addon',
175
-     *                                                                  etc.
176
-     *                                                                  ).
177
-     * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
178
-     *                                                                  for any addons that need to register any
179
-     *                                                                  special meta mapped capabilities.  Should
180
-     *                                                                  be indexed where the key is the
181
-     *                                                                  EE_Meta_Capability_Map class name and the
182
-     *                                                                  values are the arguments sent to the class.
183
-     * @type array                    $model_paths                      array of folders containing DB models
184
-     * @see      EE_Register_Model
185
-     * @type array                    $class_paths                      array of folders containing DB classes
186
-     * @see      EE_Register_Model
187
-     * @type array                    $model_extension_paths            array of folders containing DB model
188
-     *                                                                  extensions
189
-     * @see      EE_Register_Model_Extension
190
-     * @type array                    $class_extension_paths            array of folders containing DB class
191
-     *                                                                  extensions
192
-     * @see      EE_Register_Model_Extension
193
-     * @type array message_types {
194
-     *                                                                  An array of message types with the key as
195
-     *                                                                  the message type name and the values as
196
-     *                                                                  below:
197
-     * @type string                   $mtfilename                       [Required] The filename of the message type
198
-     *                                                                  being registered. This will be the main
199
-     *                                                                  EE_{Message Type Name}_message_type class.
200
-     *                                                                  for example:
201
-     *                                                                  EE_Declined_Registration_message_type.class.php
202
-     * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
203
-     *                                                                  messages autoloader for the new message type.
204
-     * @type array                    $messengers_to_activate_with      An array of messengers that this message
205
-     *                                                                  type should activate with. Each value in
206
-     *                                                                  the
207
-     *                                                                  array
208
-     *                                                                  should match the name property of a
209
-     *                                                                  EE_messenger. Optional.
210
-     * @type array                    $messengers_to_validate_with      An array of messengers that this message
211
-     *                                                                  type should validate with. Each value in
212
-     *                                                                  the
213
-     *                                                                  array
214
-     *                                                                  should match the name property of an
215
-     *                                                                  EE_messenger.
216
-     *                                                                  Optional.
217
-     *                                                                  }
218
-     * @type array                    $custom_post_types
219
-     * @type array                    $custom_taxonomies
220
-     * @type array                    $payment_method_paths             each element is the folder containing the
221
-     *                                                                  EE_PMT_Base child class
222
-     *                                                                  (eg,
223
-     *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
224
-     *                                                                  which contains the files
225
-     *                                                                  EE_PMT_Payomatic.pm.php)
226
-     * @type array                    $default_terms
227
-     * @type array                    $namespace                        {
228
-     *                                                                  An array with two items for registering the
229
-     *                                                                  addon's namespace. (If, for some reason, you
230
-     *                                                                  require additional namespaces,
231
-     *                                                                  use
232
-     *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
233
-     *                                                                  directly)
234
-     * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
235
-     * @type string                   $FQNS                             the namespace prefix
236
-     * @type string                   $DIR                              a base directory for class files in the
237
-     *                                                                  namespace.
238
-     *                                                                  }
239
-     *                                                                  }
240
-     * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
241
-     *                                                                  privacy policy classes) or FQCNs (specific
242
-     *                                                                  classnames of privacy policy classes)
243
-     * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
244
-     *                                                                  privacy policy classes) or FQCNs (specific
245
-     *                                                                  classnames of privacy policy classes)
246
-     * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
247
-     *                                                                  privacy policy classes) or FQCNs (specific
248
-     *                                                                  classnames of privacy policy classes)
249
-     * @return void
250
-     * @throws DomainException
251
-     * @throws EE_Error
252
-     * @throws InvalidArgumentException
253
-     * @throws InvalidDataTypeException
254
-     * @throws InvalidInterfaceException
255
-     */
256
-    public static function register($addon_name = '', array $setup_args = array())
257
-    {
258
-        // required fields MUST be present, so let's make sure they are.
259
-        EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
260
-        // get class name for addon
261
-        $class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
262
-        // setup $_settings array from incoming values.
263
-        $addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
264
-        // setup PUE
265
-        EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
266
-        // does this addon work with this version of core or WordPress ?
267
-        // does this addon work with this version of core or WordPress ?
268
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
269
-            return;
270
-        }
271
-        // register namespaces
272
-        EE_Register_Addon::_setup_namespaces($addon_settings);
273
-        // check if this is an activation request
274
-        if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
275
-            // dont bother setting up the rest of the addon atm
276
-            return;
277
-        }
278
-        // we need cars
279
-        EE_Register_Addon::_setup_autoloaders($addon_name);
280
-        // register new models and extensions
281
-        EE_Register_Addon::_register_models_and_extensions($addon_name);
282
-        // setup DMS
283
-        EE_Register_Addon::_register_data_migration_scripts($addon_name);
284
-        // if config_class is present let's register config.
285
-        EE_Register_Addon::_register_config($addon_name);
286
-        // register admin pages
287
-        EE_Register_Addon::_register_admin_pages($addon_name);
288
-        // add to list of modules to be registered
289
-        EE_Register_Addon::_register_modules($addon_name);
290
-        // add to list of shortcodes to be registered
291
-        EE_Register_Addon::_register_shortcodes($addon_name);
292
-        // add to list of widgets to be registered
293
-        EE_Register_Addon::_register_widgets($addon_name);
294
-        // register capability related stuff.
295
-        EE_Register_Addon::_register_capabilities($addon_name);
296
-        // any message type to register?
297
-        EE_Register_Addon::_register_message_types($addon_name);
298
-        // any custom post type/ custom capabilities or default terms to register
299
-        EE_Register_Addon::_register_custom_post_types($addon_name);
300
-        // and any payment methods
301
-        EE_Register_Addon::_register_payment_methods($addon_name);
302
-        // and privacy policy generators
303
-        EE_Register_Addon::registerPrivacyPolicies($addon_name);
304
-        // and privacy policy generators
305
-        EE_Register_Addon::registerPersonalDataExporters($addon_name);
306
-        // and privacy policy generators
307
-        EE_Register_Addon::registerPersonalDataErasers($addon_name);
308
-        // load and instantiate main addon class
309
-        $addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
310
-        // delay calling after_registration hook on each addon until after all add-ons have been registered.
311
-        add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
312
-    }
313
-
314
-
315
-    /**
316
-     * @param string $addon_name
317
-     * @param array  $setup_args
318
-     * @return void
319
-     * @throws EE_Error
320
-     */
321
-    private static function _verify_parameters($addon_name, array $setup_args)
322
-    {
323
-        // required fields MUST be present, so let's make sure they are.
324
-        if (empty($addon_name) || ! is_array($setup_args)) {
325
-            throw new EE_Error(
326
-                esc_html__(
327
-                    '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.',
328
-                    'event_espresso'
329
-                )
330
-            );
331
-        }
332
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
333
-            throw new EE_Error(
334
-                sprintf(
335
-                    esc_html__(
336
-                        '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',
337
-                        'event_espresso'
338
-                    ),
339
-                    implode(',', array_keys($setup_args))
340
-                )
341
-            );
342
-        }
343
-        // check that addon has not already been registered with that name
344
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
345
-            throw new EE_Error(
346
-                sprintf(
347
-                    esc_html__(
348
-                        'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
349
-                        'event_espresso'
350
-                    ),
351
-                    $addon_name
352
-                )
353
-            );
354
-        }
355
-    }
356
-
357
-
358
-    /**
359
-     * @param string $addon_name
360
-     * @param array  $setup_args
361
-     * @return string
362
-     */
363
-    private static function _parse_class_name($addon_name, array $setup_args)
364
-    {
365
-        if (empty($setup_args['class_name'])) {
366
-            // generate one by first separating name with spaces
367
-            $class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
368
-            // capitalize, then replace spaces with underscores
369
-            $class_name = str_replace(' ', '_', ucwords($class_name));
370
-        } else {
371
-            $class_name = $setup_args['class_name'];
372
-        }
373
-        // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
374
-        return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
375
-            ? $class_name
376
-            : 'EE_' . $class_name;
377
-    }
378
-
379
-
380
-    /**
381
-     * @param string $class_name
382
-     * @param array  $setup_args
383
-     * @return array
384
-     */
385
-    private static function _get_addon_settings($class_name, array $setup_args)
386
-    {
387
-        // setup $_settings array from incoming values.
388
-        $addon_settings = array(
389
-            // generated from the addon name, changes something like "calendar" to "EE_Calendar"
390
-            'class_name'            => $class_name,
391
-            // the addon slug for use in URLs, etc
392
-            'plugin_slug'           => isset($setup_args['plugin_slug'])
393
-                ? (string) $setup_args['plugin_slug']
394
-                : '',
395
-            // page slug to be used when generating the "Settings" link on the WP plugin page
396
-            'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
397
-                ? (string) $setup_args['plugin_action_slug']
398
-                : '',
399
-            // the "software" version for the addon
400
-            'version'               => isset($setup_args['version'])
401
-                ? (string) $setup_args['version']
402
-                : '',
403
-            // the minimum version of EE Core that the addon will work with
404
-            'min_core_version'      => isset($setup_args['min_core_version'])
405
-                ? (string) $setup_args['min_core_version']
406
-                : '',
407
-            // the minimum version of WordPress that the addon will work with
408
-            'min_wp_version'        => isset($setup_args['min_wp_version'])
409
-                ? (string) $setup_args['min_wp_version']
410
-                : EE_MIN_WP_VER_REQUIRED,
411
-            // full server path to main file (file loaded directly by WP)
412
-            'main_file_path'        => isset($setup_args['main_file_path'])
413
-                ? (string) $setup_args['main_file_path']
414
-                : '',
415
-            // instance of \EventEspresso\core\domain\DomainInterface
416
-            'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
417
-                ? $setup_args['domain']
418
-                : null,
419
-            // Fully Qualified Class Name for the addon's Domain class
420
-            'domain_fqcn'           => isset($setup_args['domain_fqcn'])
421
-                ? (string) $setup_args['domain_fqcn']
422
-                : '',
423
-            // path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
424
-            'admin_path'            => isset($setup_args['admin_path'])
425
-                ? (string) $setup_args['admin_path'] : '',
426
-            // a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
427
-            'admin_callback'        => isset($setup_args['admin_callback'])
428
-                ? (string) $setup_args['admin_callback']
429
-                : '',
430
-            // the section name for this addon's configuration settings section (defaults to "addons")
431
-            'config_section'        => isset($setup_args['config_section'])
432
-                ? (string) $setup_args['config_section']
433
-                : 'addons',
434
-            // the class name for this addon's configuration settings object
435
-            'config_class'          => isset($setup_args['config_class'])
436
-                ? (string) $setup_args['config_class'] : '',
437
-            // the name given to the config for this addons' configuration settings object (optional)
438
-            'config_name'           => isset($setup_args['config_name'])
439
-                ? (string) $setup_args['config_name'] : '',
440
-            // an array of "class names" => "full server paths" for any classes that might be invoked by the addon
441
-            'autoloader_paths'      => isset($setup_args['autoloader_paths'])
442
-                ? (array) $setup_args['autoloader_paths']
443
-                : array(),
444
-            // an array of  "full server paths" for any folders containing classes that might be invoked by the addon
445
-            'autoloader_folders'    => isset($setup_args['autoloader_folders'])
446
-                ? (array) $setup_args['autoloader_folders']
447
-                : array(),
448
-            // array of full server paths to any EE_DMS data migration scripts used by the addon.
449
-            // The key should be the EE_Addon class name that this set of data migration scripts belongs to.
450
-            // If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
451
-            'dms_paths'             => isset($setup_args['dms_paths'])
452
-                ? (array) $setup_args['dms_paths']
453
-                : array(),
454
-            // array of full server paths to any EED_Modules used by the addon
455
-            'module_paths'          => isset($setup_args['module_paths'])
456
-                ? (array) $setup_args['module_paths']
457
-                : array(),
458
-            // array of full server paths to any EES_Shortcodes used by the addon
459
-            'shortcode_paths'       => isset($setup_args['shortcode_paths'])
460
-                ? (array) $setup_args['shortcode_paths']
461
-                : array(),
462
-            'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
463
-                ? (array) $setup_args['shortcode_fqcns']
464
-                : array(),
465
-            // array of full server paths to any WP_Widgets used by the addon
466
-            'widget_paths'          => isset($setup_args['widget_paths'])
467
-                ? (array) $setup_args['widget_paths']
468
-                : array(),
469
-            // array of PUE options used by the addon
470
-            'pue_options'           => isset($setup_args['pue_options'])
471
-                ? (array) $setup_args['pue_options']
472
-                : array(),
473
-            'message_types'         => isset($setup_args['message_types'])
474
-                ? (array) $setup_args['message_types']
475
-                : array(),
476
-            'capabilities'          => isset($setup_args['capabilities'])
477
-                ? (array) $setup_args['capabilities']
478
-                : array(),
479
-            'capability_maps'       => isset($setup_args['capability_maps'])
480
-                ? (array) $setup_args['capability_maps']
481
-                : array(),
482
-            'model_paths'           => isset($setup_args['model_paths'])
483
-                ? (array) $setup_args['model_paths']
484
-                : array(),
485
-            'class_paths'           => isset($setup_args['class_paths'])
486
-                ? (array) $setup_args['class_paths']
487
-                : array(),
488
-            'model_extension_paths' => isset($setup_args['model_extension_paths'])
489
-                ? (array) $setup_args['model_extension_paths']
490
-                : array(),
491
-            'class_extension_paths' => isset($setup_args['class_extension_paths'])
492
-                ? (array) $setup_args['class_extension_paths']
493
-                : array(),
494
-            'custom_post_types'     => isset($setup_args['custom_post_types'])
495
-                ? (array) $setup_args['custom_post_types']
496
-                : array(),
497
-            'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
498
-                ? (array) $setup_args['custom_taxonomies']
499
-                : array(),
500
-            'payment_method_paths'  => isset($setup_args['payment_method_paths'])
501
-                ? (array) $setup_args['payment_method_paths']
502
-                : array(),
503
-            'default_terms'         => isset($setup_args['default_terms'])
504
-                ? (array) $setup_args['default_terms']
505
-                : array(),
506
-            // if not empty, inserts a new table row after this plugin's row on the WP Plugins page
507
-            // that can be used for adding upgrading/marketing info
508
-            'plugins_page_row'      => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '',
509
-            'namespace'             => isset(
510
-                $setup_args['namespace']['FQNS'],
511
-                $setup_args['namespace']['DIR']
512
-            )
513
-                ? (array) $setup_args['namespace']
514
-                : array(),
515
-            'privacy_policies'      => isset($setup_args['privacy_policies'])
516
-                ? (array) $setup_args['privacy_policies']
517
-                : '',
518
-        );
519
-        // if plugin_action_slug is NOT set, but an admin page path IS set,
520
-        // then let's just use the plugin_slug since that will be used for linking to the admin page
521
-        $addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
522
-                                                && ! empty($addon_settings['admin_path'])
523
-            ? $addon_settings['plugin_slug']
524
-            : $addon_settings['plugin_action_slug'];
525
-        // full server path to main file (file loaded directly by WP)
526
-        $addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
527
-        return $addon_settings;
528
-    }
529
-
530
-
531
-    /**
532
-     * @param string $addon_name
533
-     * @param array  $addon_settings
534
-     * @return boolean
535
-     */
536
-    private static function _addon_is_compatible($addon_name, array $addon_settings)
537
-    {
538
-        global $wp_version;
539
-        $incompatibility_message = '';
540
-        // check whether this addon version is compatible with EE core
541
-        if (
542
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
543
-            && ! self::_meets_min_core_version_requirement(
544
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
545
-                $addon_settings['version']
546
-            )
547
-        ) {
548
-            $incompatibility_message = sprintf(
549
-                esc_html__(
550
-                    '%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.',
551
-                    'event_espresso'
552
-                ),
553
-                $addon_name,
554
-                '<br />',
555
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
556
-                '<span style="font-weight: bold; color: #D54E21;">',
557
-                '</span><br />'
558
-            );
559
-        } elseif (
560
-            ! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
561
-        ) {
562
-            $incompatibility_message = sprintf(
563
-                esc_html__(
564
-                    '%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".',
565
-                    'event_espresso'
566
-                ),
567
-                $addon_name,
568
-                self::_effective_version($addon_settings['min_core_version']),
569
-                self::_effective_version(espresso_version()),
570
-                '<br />',
571
-                '<span style="font-weight: bold; color: #D54E21;">',
572
-                '</span><br />'
573
-            );
574
-        } elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
575
-            $incompatibility_message = sprintf(
576
-                esc_html__(
577
-                    '%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.',
578
-                    'event_espresso'
579
-                ),
580
-                $addon_name,
581
-                $addon_settings['min_wp_version'],
582
-                '<br />',
583
-                '<span style="font-weight: bold; color: #D54E21;">',
584
-                '</span><br />'
585
-            );
586
-        }
587
-        if (! empty($incompatibility_message)) {
588
-            // remove 'activate' from the REQUEST
589
-            // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
590
-            /** @var RequestInterface $request */
591
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
592
-            $request->unSetRequestParam('activate', true);
593
-            if (current_user_can('activate_plugins')) {
594
-                // show an error message indicating the plugin didn't activate properly
595
-                EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
596
-            }
597
-            // BAIL FROM THE ADDON REGISTRATION PROCESS
598
-            return false;
599
-        }
600
-        // addon IS compatible
601
-        return true;
602
-    }
603
-
604
-
605
-    /**
606
-     * if plugin update engine is being used for auto-updates,
607
-     * then let's set that up now before going any further so that ALL addons can be updated
608
-     * (not needed if PUE is not being used)
609
-     *
610
-     * @param string $addon_name
611
-     * @param string $class_name
612
-     * @param array  $setup_args
613
-     * @return void
614
-     */
615
-    private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
616
-    {
617
-        if (! empty($setup_args['pue_options'])) {
618
-            self::$_settings[ $addon_name ]['pue_options'] = array(
619
-                'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
620
-                    ? (string) $setup_args['pue_options']['pue_plugin_slug']
621
-                    : 'espresso_' . strtolower($class_name),
622
-                'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
623
-                    ? (string) $setup_args['pue_options']['plugin_basename']
624
-                    : plugin_basename($setup_args['main_file_path']),
625
-                'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
626
-                    ? (string) $setup_args['pue_options']['checkPeriod']
627
-                    : '24',
628
-                'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
629
-                    ? (string) $setup_args['pue_options']['use_wp_update']
630
-                    : false,
631
-            );
632
-            add_action(
633
-                'AHEE__EE_System__brew_espresso__after_pue_init',
634
-                array('EE_Register_Addon', 'load_pue_update')
635
-            );
636
-        }
637
-    }
638
-
639
-
640
-    /**
641
-     * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
642
-     *
643
-     * @param array $addon_settings
644
-     * @return void
645
-     */
646
-    private static function _setup_namespaces(array $addon_settings)
647
-    {
648
-        //
649
-        if (
650
-            isset(
651
-                $addon_settings['namespace']['FQNS'],
652
-                $addon_settings['namespace']['DIR']
653
-            )
654
-        ) {
655
-            EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
656
-                $addon_settings['namespace']['FQNS'],
657
-                $addon_settings['namespace']['DIR']
658
-            );
659
-        }
660
-    }
661
-
662
-
663
-    /**
664
-     * @param string $addon_name
665
-     * @param array  $addon_settings
666
-     * @return bool
667
-     * @throws InvalidArgumentException
668
-     * @throws InvalidDataTypeException
669
-     * @throws InvalidInterfaceException
670
-     */
671
-    private static function _addon_activation($addon_name, array $addon_settings)
672
-    {
673
-        // this is an activation request
674
-        if (did_action('activate_plugin')) {
675
-            // to find if THIS is the addon that was activated, just check if we have already registered it or not
676
-            // (as the newly-activated addon wasn't around the first time addons were registered).
677
-            // Note: the presence of pue_options in the addon registration options will initialize the $_settings
678
-            // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
679
-            if (
680
-                ! isset(self::$_settings[ $addon_name ])
681
-                || (isset(self::$_settings[ $addon_name ])
682
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
683
-                )
684
-            ) {
685
-                self::$_settings[ $addon_name ] = $addon_settings;
686
-                $addon = self::_load_and_init_addon_class($addon_name);
687
-                $addon->set_activation_indicator_option();
688
-                // dont bother setting up the rest of the addon.
689
-                // we know it was just activated and the request will end soon
690
-            }
691
-            return true;
692
-        }
693
-        // make sure this was called in the right place!
694
-        if (
695
-            ! did_action('AHEE__EE_System__load_espresso_addons')
696
-            || did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
697
-        ) {
698
-            EE_Error::doing_it_wrong(
699
-                __METHOD__,
700
-                sprintf(
701
-                    esc_html__(
702
-                        '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.',
703
-                        'event_espresso'
704
-                    ),
705
-                    $addon_name
706
-                ),
707
-                '4.3.0'
708
-            );
709
-        }
710
-        // make sure addon settings are set correctly without overwriting anything existing
711
-        if (isset(self::$_settings[ $addon_name ])) {
712
-            self::$_settings[ $addon_name ] += $addon_settings;
713
-        } else {
714
-            self::$_settings[ $addon_name ] = $addon_settings;
715
-        }
716
-        return false;
717
-    }
718
-
719
-
720
-    /**
721
-     * @param string $addon_name
722
-     * @return void
723
-     * @throws EE_Error
724
-     */
725
-    private static function _setup_autoloaders($addon_name)
726
-    {
727
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
728
-            // setup autoloader for single file
729
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
730
-        }
731
-        // setup autoloaders for folders
732
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
733
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
734
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
735
-            }
736
-        }
737
-    }
738
-
739
-
740
-    /**
741
-     * register new models and extensions
742
-     *
743
-     * @param string $addon_name
744
-     * @return void
745
-     * @throws EE_Error
746
-     */
747
-    private static function _register_models_and_extensions($addon_name)
748
-    {
749
-        // register new models
750
-        if (
751
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
752
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
753
-        ) {
754
-            EE_Register_Model::register(
755
-                $addon_name,
756
-                array(
757
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
758
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
759
-                )
760
-            );
761
-        }
762
-        // register model extensions
763
-        if (
764
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
765
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
766
-        ) {
767
-            EE_Register_Model_Extensions::register(
768
-                $addon_name,
769
-                array(
770
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
771
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
772
-                )
773
-            );
774
-        }
775
-    }
776
-
777
-
778
-    /**
779
-     * @param string $addon_name
780
-     * @return void
781
-     * @throws EE_Error
782
-     */
783
-    private static function _register_data_migration_scripts($addon_name)
784
-    {
785
-        // setup DMS
786
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
787
-            EE_Register_Data_Migration_Scripts::register(
788
-                $addon_name,
789
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
790
-            );
791
-        }
792
-    }
793
-
794
-
795
-    /**
796
-     * @param string $addon_name
797
-     * @return void
798
-     * @throws EE_Error
799
-     */
800
-    private static function _register_config($addon_name)
801
-    {
802
-        // if config_class is present let's register config.
803
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
804
-            EE_Register_Config::register(
805
-                self::$_settings[ $addon_name ]['config_class'],
806
-                array(
807
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
808
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
809
-                )
810
-            );
811
-        }
812
-    }
813
-
814
-
815
-    /**
816
-     * @param string $addon_name
817
-     * @return void
818
-     * @throws EE_Error
819
-     */
820
-    private static function _register_admin_pages($addon_name)
821
-    {
822
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
823
-            EE_Register_Admin_Page::register(
824
-                $addon_name,
825
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
826
-            );
827
-        }
828
-    }
829
-
830
-
831
-    /**
832
-     * @param string $addon_name
833
-     * @return void
834
-     * @throws EE_Error
835
-     */
836
-    private static function _register_modules($addon_name)
837
-    {
838
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
839
-            EE_Register_Module::register(
840
-                $addon_name,
841
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
842
-            );
843
-        }
844
-    }
845
-
846
-
847
-    /**
848
-     * @param string $addon_name
849
-     * @return void
850
-     * @throws EE_Error
851
-     */
852
-    private static function _register_shortcodes($addon_name)
853
-    {
854
-        if (
855
-            ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
856
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
857
-        ) {
858
-            EE_Register_Shortcode::register(
859
-                $addon_name,
860
-                array(
861
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
862
-                        ? self::$_settings[ $addon_name ]['shortcode_paths'] : array(),
863
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
864
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns'] : array(),
865
-                )
866
-            );
867
-        }
868
-    }
869
-
870
-
871
-    /**
872
-     * @param string $addon_name
873
-     * @return void
874
-     * @throws EE_Error
875
-     */
876
-    private static function _register_widgets($addon_name)
877
-    {
878
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
879
-            EE_Register_Widget::register(
880
-                $addon_name,
881
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
882
-            );
883
-        }
884
-    }
885
-
886
-
887
-    /**
888
-     * @param string $addon_name
889
-     * @return void
890
-     * @throws EE_Error
891
-     */
892
-    private static function _register_capabilities($addon_name)
893
-    {
894
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
895
-            EE_Register_Capabilities::register(
896
-                $addon_name,
897
-                array(
898
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
899
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
900
-                )
901
-            );
902
-        }
903
-    }
904
-
905
-
906
-    /**
907
-     * @param string $addon_name
908
-     * @return void
909
-     */
910
-    private static function _register_message_types($addon_name)
911
-    {
912
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
913
-            add_action(
914
-                'EE_Brewing_Regular___messages_caf',
915
-                array('EE_Register_Addon', 'register_message_types')
916
-            );
917
-        }
918
-    }
919
-
920
-
921
-    /**
922
-     * @param string $addon_name
923
-     * @return void
924
-     * @throws EE_Error
925
-     */
926
-    private static function _register_custom_post_types($addon_name)
927
-    {
928
-        if (
929
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
930
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
931
-        ) {
932
-            EE_Register_CPT::register(
933
-                $addon_name,
934
-                array(
935
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
936
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
937
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
938
-                )
939
-            );
940
-        }
941
-    }
942
-
943
-
944
-    /**
945
-     * @param string $addon_name
946
-     * @return void
947
-     * @throws InvalidArgumentException
948
-     * @throws InvalidInterfaceException
949
-     * @throws InvalidDataTypeException
950
-     * @throws DomainException
951
-     * @throws EE_Error
952
-     */
953
-    private static function _register_payment_methods($addon_name)
954
-    {
955
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
956
-            EE_Register_Payment_Method::register(
957
-                $addon_name,
958
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
959
-            );
960
-        }
961
-    }
962
-
963
-
964
-    /**
965
-     * @param string $addon_name
966
-     * @return void
967
-     * @throws InvalidArgumentException
968
-     * @throws InvalidInterfaceException
969
-     * @throws InvalidDataTypeException
970
-     * @throws DomainException
971
-     */
972
-    private static function registerPrivacyPolicies($addon_name)
973
-    {
974
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
975
-            EE_Register_Privacy_Policy::register(
976
-                $addon_name,
977
-                self::$_settings[ $addon_name ]['privacy_policies']
978
-            );
979
-        }
980
-    }
981
-
982
-
983
-    /**
984
-     * @param string $addon_name
985
-     * @return void
986
-     */
987
-    private static function registerPersonalDataExporters($addon_name)
988
-    {
989
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
990
-            EE_Register_Personal_Data_Eraser::register(
991
-                $addon_name,
992
-                self::$_settings[ $addon_name ]['personal_data_exporters']
993
-            );
994
-        }
995
-    }
996
-
997
-
998
-    /**
999
-     * @param string $addon_name
1000
-     * @return void
1001
-     */
1002
-    private static function registerPersonalDataErasers($addon_name)
1003
-    {
1004
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1005
-            EE_Register_Personal_Data_Eraser::register(
1006
-                $addon_name,
1007
-                self::$_settings[ $addon_name ]['personal_data_erasers']
1008
-            );
1009
-        }
1010
-    }
1011
-
1012
-
1013
-    /**
1014
-     * Loads and instantiates the EE_Addon class and adds it onto the registry
1015
-     *
1016
-     * @param string $addon_name
1017
-     * @return EE_Addon
1018
-     * @throws InvalidArgumentException
1019
-     * @throws InvalidInterfaceException
1020
-     * @throws InvalidDataTypeException
1021
-     */
1022
-    private static function _load_and_init_addon_class($addon_name)
1023
-    {
1024
-        $addon = LoaderFactory::getLoader()->getShared(
1025
-            self::$_settings[ $addon_name ]['class_name'],
1026
-            array('EE_Registry::create(addon)' => true)
1027
-        );
1028
-        if (! $addon instanceof EE_Addon) {
1029
-            throw new DomainException(
1030
-                sprintf(
1031
-                    esc_html__(
1032
-                        'Failed to instantiate the %1$s class. PLease check that the class exists.',
1033
-                        'event_espresso'
1034
-                    ),
1035
-                    $addon_name
1036
-                )
1037
-            );
1038
-        }
1039
-        // setter inject dep map if required
1040
-        if ($addon->dependencyMap() === null) {
1041
-            $addon->setDependencyMap(LoaderFactory::getLoader()->getShared('EE_Dependency_Map'));
1042
-        }
1043
-        // setter inject domain if required
1044
-        EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1045
-
1046
-        $addon->set_name($addon_name);
1047
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1048
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1049
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1050
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1051
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1052
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1053
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1054
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1055
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1056
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1057
-        // setup the add-on's pue_slug if we have one.
1058
-        if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1059
-            $addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1060
-        }
1061
-        // unfortunately this can't be hooked in upon construction,
1062
-        // because we don't have the plugin's mainfile path upon construction.
1063
-        register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1064
-        // call any additional admin_callback functions during load_admin_controller hook
1065
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1066
-            add_action(
1067
-                'AHEE__EE_System__load_controllers__load_admin_controllers',
1068
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1069
-            );
1070
-        }
1071
-        return $addon;
1072
-    }
1073
-
1074
-
1075
-    /**
1076
-     * @param string   $addon_name
1077
-     * @param EE_Addon $addon
1078
-     * @since   4.10.13.p
1079
-     */
1080
-    private static function injectAddonDomain($addon_name, EE_Addon $addon)
1081
-    {
1082
-        if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1083
-            // using supplied Domain object
1084
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1085
-                ? self::$_settings[ $addon_name ]['domain']
1086
-                : null;
1087
-            // or construct one using Domain FQCN
1088
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1089
-                $domain = LoaderFactory::getLoader()->getShared(
1090
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1091
-                    [
1092
-                        new EventEspresso\core\domain\values\FilePath(
1093
-                            self::$_settings[ $addon_name ]['main_file_path']
1094
-                        ),
1095
-                        EventEspresso\core\domain\values\Version::fromString(
1096
-                            self::$_settings[ $addon_name ]['version']
1097
-                        ),
1098
-                    ]
1099
-                );
1100
-            }
1101
-            if ($domain instanceof DomainInterface) {
1102
-                $addon->setDomain($domain);
1103
-            }
1104
-        }
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     *    load_pue_update - Update notifications
1110
-     *
1111
-     * @return void
1112
-     * @throws InvalidArgumentException
1113
-     * @throws InvalidDataTypeException
1114
-     * @throws InvalidInterfaceException
1115
-     */
1116
-    public static function load_pue_update()
1117
-    {
1118
-        // load PUE client
1119
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1120
-        $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1121
-        // cycle thru settings
1122
-        foreach (self::$_settings as $settings) {
1123
-            if (! empty($settings['pue_options'])) {
1124
-                // initiate the class and start the plugin update engine!
1125
-                new PluginUpdateEngineChecker(
1126
-                    // host file URL
1127
-                    $license_server,
1128
-                    // plugin slug(s)
1129
-                    array(
1130
-                        'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1131
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1132
-                    ),
1133
-                    // options
1134
-                    array(
1135
-                        'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1136
-                        'lang_domain'       => 'event_espresso',
1137
-                        'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1138
-                        'option_key'        => 'ee_site_license_key',
1139
-                        'options_page_slug' => 'event_espresso',
1140
-                        'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1141
-                        // if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1142
-                        'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1143
-                    )
1144
-                );
1145
-            }
1146
-        }
1147
-    }
1148
-
1149
-
1150
-    /**
1151
-     * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1152
-     *
1153
-     * @since 4.4.0
1154
-     * @return void
1155
-     * @throws EE_Error
1156
-     */
1157
-    public static function register_message_types()
1158
-    {
1159
-        foreach (self::$_settings as $settings) {
1160
-            if (! empty($settings['message_types'])) {
1161
-                foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1162
-                    EE_Register_Message_Type::register($message_type, $message_type_settings);
1163
-                }
1164
-            }
1165
-        }
1166
-    }
1167
-
1168
-
1169
-    /**
1170
-     * This deregisters an addon that was previously registered with a specific addon_name.
1171
-     *
1172
-     * @param string $addon_name the name for the addon that was previously registered
1173
-     * @throws DomainException
1174
-     * @throws InvalidArgumentException
1175
-     * @throws InvalidDataTypeException
1176
-     * @throws InvalidInterfaceException
1177
-     *@since    4.3.0
1178
-     */
1179
-    public static function deregister($addon_name = '')
1180
-    {
1181
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1182
-            try {
1183
-                do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1184
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1185
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1186
-                    // setup DMS
1187
-                    EE_Register_Data_Migration_Scripts::deregister($addon_name);
1188
-                }
1189
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1190
-                    // register admin page
1191
-                    EE_Register_Admin_Page::deregister($addon_name);
1192
-                }
1193
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1194
-                    // add to list of modules to be registered
1195
-                    EE_Register_Module::deregister($addon_name);
1196
-                }
1197
-                if (
1198
-                    ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1199
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1200
-                ) {
1201
-                    // add to list of shortcodes to be registered
1202
-                    EE_Register_Shortcode::deregister($addon_name);
1203
-                }
1204
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1205
-                    // if config_class present let's register config.
1206
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1207
-                }
1208
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1209
-                    // add to list of widgets to be registered
1210
-                    EE_Register_Widget::deregister($addon_name);
1211
-                }
1212
-                if (
1213
-                    ! empty(self::$_settings[ $addon_name ]['model_paths'])
1214
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1215
-                ) {
1216
-                    // add to list of shortcodes to be registered
1217
-                    EE_Register_Model::deregister($addon_name);
1218
-                }
1219
-                if (
1220
-                    ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1221
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1222
-                ) {
1223
-                    // add to list of shortcodes to be registered
1224
-                    EE_Register_Model_Extensions::deregister($addon_name);
1225
-                }
1226
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1227
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1228
-                        EE_Register_Message_Type::deregister($message_type);
1229
-                    }
1230
-                }
1231
-                // deregister capabilities for addon
1232
-                if (
1233
-                    ! empty(self::$_settings[ $addon_name ]['capabilities'])
1234
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1235
-                ) {
1236
-                    EE_Register_Capabilities::deregister($addon_name);
1237
-                }
1238
-                // deregister custom_post_types for addon
1239
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1240
-                    EE_Register_CPT::deregister($addon_name);
1241
-                }
1242
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1243
-                    EE_Register_Payment_Method::deregister($addon_name);
1244
-                }
1245
-                $addon = EE_Registry::instance()->getAddon($class_name);
1246
-                if ($addon instanceof EE_Addon) {
1247
-                    remove_action(
1248
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1249
-                        array($addon, 'deactivation')
1250
-                    );
1251
-                    remove_action(
1252
-                        'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1253
-                        array($addon, 'initialize_db_if_no_migrations_required')
1254
-                    );
1255
-                    // remove `after_registration` call
1256
-                    remove_action(
1257
-                        'AHEE__EE_System__load_espresso_addons__complete',
1258
-                        array($addon, 'after_registration'),
1259
-                        999
1260
-                    );
1261
-                }
1262
-                EE_Registry::instance()->removeAddon($class_name);
1263
-                LoaderFactory::getLoader()->remove($class_name);
1264
-            } catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1265
-                // the add-on was not yet registered in the registry,
1266
-                // so RegistryContainer::__get() throws this exception.
1267
-                // also no need to worry about this or log it,
1268
-                // it's ok to deregister an add-on before its registered in the registry
1269
-            } catch (Exception $e) {
1270
-                new ExceptionLogger($e);
1271
-            }
1272
-            unset(self::$_settings[ $addon_name ]);
1273
-            do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1274
-        }
1275
-    }
26
+	/**
27
+	 * possibly truncated version of the EE core version string
28
+	 *
29
+	 * @var string
30
+	 */
31
+	protected static $_core_version = '';
32
+
33
+	/**
34
+	 * Holds values for registered addons
35
+	 *
36
+	 * @var array
37
+	 */
38
+	protected static $_settings = array();
39
+
40
+	/**
41
+	 * @var  array $_incompatible_addons keys are addon SLUGS
42
+	 * (first argument passed to EE_Register_Addon::register()), keys are
43
+	 * their MINIMUM VERSION (with all 5 parts. Eg 1.2.3.rc.004).
44
+	 * Generally this should be used sparingly, as we don't want to muddle up
45
+	 * EE core with knowledge of ALL the addons out there.
46
+	 * If you want NO versions of an addon to run with a certain version of core,
47
+	 * it's usually best to define the addon's "min_core_version" as part of its call
48
+	 * to EE_Register_Addon::register(), rather than using this array with a super high value for its
49
+	 * minimum plugin version.
50
+	 * @access    protected
51
+	 */
52
+	protected static $_incompatible_addons = array(
53
+		'Multi_Event_Registration' => '2.0.11.rc.002',
54
+		'Promotions'               => '1.0.0.rc.084',
55
+	);
56
+
57
+
58
+	/**
59
+	 * We should always be comparing core to a version like '4.3.0.rc.000',
60
+	 * not just '4.3.0'.
61
+	 * So if the addon developer doesn't provide that full version string,
62
+	 * fill in the blanks for them
63
+	 *
64
+	 * @param string $min_core_version
65
+	 * @return string always like '4.3.0.rc.000'
66
+	 */
67
+	protected static function _effective_version($min_core_version)
68
+	{
69
+		// versions: 4 . 3 . 1 . p . 123
70
+		// offsets:    0 . 1 . 2 . 3 . 4
71
+		$version_parts = explode('.', $min_core_version);
72
+		// check they specified the micro version (after 2nd period)
73
+		if (! isset($version_parts[2])) {
74
+			$version_parts[2] = '0';
75
+		}
76
+		// if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
77
+		// soon we can assume that's 'rc', but this current version is 'alpha'
78
+		if (! isset($version_parts[3])) {
79
+			$version_parts[3] = 'dev';
80
+		}
81
+		if (! isset($version_parts[4])) {
82
+			$version_parts[4] = '000';
83
+		}
84
+		return implode('.', $version_parts);
85
+	}
86
+
87
+
88
+	/**
89
+	 * Returns whether or not the min core version requirement of the addon is met
90
+	 *
91
+	 * @param string $min_core_version    the minimum core version required by the addon
92
+	 * @param string $actual_core_version the actual core version, optional
93
+	 * @return boolean
94
+	 */
95
+	public static function _meets_min_core_version_requirement(
96
+		$min_core_version,
97
+		$actual_core_version = EVENT_ESPRESSO_VERSION
98
+	) {
99
+		return version_compare(
100
+			self::_effective_version($actual_core_version),
101
+			self::_effective_version($min_core_version),
102
+			'>='
103
+		);
104
+	}
105
+
106
+
107
+	/**
108
+	 * Method for registering new EE_Addons.
109
+	 * Should be called AFTER AHEE__EE_System__load_espresso_addons but BEFORE
110
+	 * AHEE__EE_System___detect_if_activation_or_upgrade__begin in order to register all its components. However, it
111
+	 * may also be called after the 'activate_plugin' action (when an addon is activated), because an activating addon
112
+	 * won't be loaded by WP until after AHEE__EE_System__load_espresso_addons has fired. If its called after
113
+	 * 'activate_plugin', it registers the addon still, but its components are not registered
114
+	 * (they shouldn't be needed anyways, because it's just an activation request and they won't have a chance to do
115
+	 * anything anyways). Instead, it just sets the newly-activated addon's activation indicator wp option and returns
116
+	 * (so that we can detect that the addon has activated on the subsequent request)
117
+	 *
118
+	 * @since    4.3.0
119
+	 * @param string                  $addon_name                       [Required] the EE_Addon's name.
120
+	 * @param  array                  $setup_args                       {
121
+	 *                                                                  An array of arguments provided for registering
122
+	 *                                                                  the message type.
123
+	 * @type  string                  $class_name                       the addon's main file name.
124
+	 *                                                                  If left blank, generated from the addon name,
125
+	 *                                                                  changes something like "calendar" to
126
+	 *                                                                  "EE_Calendar"
127
+	 * @type string                   $min_core_version                 the minimum version of EE Core that the
128
+	 *                                                                  addon will work with. eg "4.8.1.rc.084"
129
+	 * @type string                   $version                          the "software" version for the addon. eg
130
+	 *                                                                  "1.0.0.p" for a first stable release, or
131
+	 *                                                                  "1.0.0.rc.043" for a version in progress
132
+	 * @type string                   $main_file_path                   the full server path to the main file
133
+	 *                                                                  loaded directly by WP
134
+	 * @type DomainInterface $domain                                    child class of
135
+	 *                                                                  EventEspresso\core\domain\DomainBase
136
+	 * @type string                   $domain_fqcn                      Fully Qualified Class Name
137
+	 *                                                                  for the addon's Domain class
138
+	 *                                                                  (see EventEspresso\core\domain\Domain)
139
+	 * @type string                   $admin_path                       full server path to the folder where the
140
+	 *                                                                  addon\'s admin files reside
141
+	 * @type string                   $admin_callback                   a method to be called when the EE Admin is
142
+	 *                                                                  first invoked, can be used for hooking into
143
+	 *                                                                  any admin page
144
+	 * @type string                   $config_section                   the section name for this addon's
145
+	 *                                                                  configuration settings section
146
+	 *                                                                  (defaults to "addons")
147
+	 * @type string                   $config_class                     the class name for this addon's
148
+	 *                                                                  configuration settings object
149
+	 * @type string                   $config_name                      the class name for this addon's
150
+	 *                                                                  configuration settings object
151
+	 * @type string                   $autoloader_paths                 [Required] an array of class names and the full
152
+	 *                                                                  server paths to those files.
153
+	 * @type string                   $autoloader_folders               an array of  "full server paths" for any
154
+	 *                                                                  folders containing classes that might be
155
+	 *                                                                  invoked by the addon
156
+	 * @type string                   $dms_paths                        [Required] an array of full server paths to
157
+	 *                                                                  folders that contain data migration scripts.
158
+	 *                                                                  The key should be the EE_Addon class name that
159
+	 *                                                                  this set of data migration scripts belongs to.
160
+	 *                                                                  If the EE_Addon class is namespaced, then this
161
+	 *                                                                  needs to be the Fully Qualified Class Name
162
+	 * @type string                   $module_paths                     an array of full server paths to any
163
+	 *                                                                  EED_Modules used by the addon
164
+	 * @type string                   $shortcode_paths                  an array of full server paths to folders
165
+	 *                                                                  that contain EES_Shortcodes
166
+	 * @type string                   $widget_paths                     an array of full server paths to folders
167
+	 *                                                                  that contain WP_Widgets
168
+	 * @type string                   $pue_options
169
+	 * @type array                    $capabilities                     an array indexed by role name
170
+	 *                                                                  (i.e administrator,author ) and the values
171
+	 *                                                                  are an array of caps to add to the role.
172
+	 *                                                                  'administrator' => array(
173
+	 *                                                                  'read_addon',
174
+	 *                                                                  'edit_addon',
175
+	 *                                                                  etc.
176
+	 *                                                                  ).
177
+	 * @type EE_Meta_Capability_Map[] $capability_maps                  an array of EE_Meta_Capability_Map object
178
+	 *                                                                  for any addons that need to register any
179
+	 *                                                                  special meta mapped capabilities.  Should
180
+	 *                                                                  be indexed where the key is the
181
+	 *                                                                  EE_Meta_Capability_Map class name and the
182
+	 *                                                                  values are the arguments sent to the class.
183
+	 * @type array                    $model_paths                      array of folders containing DB models
184
+	 * @see      EE_Register_Model
185
+	 * @type array                    $class_paths                      array of folders containing DB classes
186
+	 * @see      EE_Register_Model
187
+	 * @type array                    $model_extension_paths            array of folders containing DB model
188
+	 *                                                                  extensions
189
+	 * @see      EE_Register_Model_Extension
190
+	 * @type array                    $class_extension_paths            array of folders containing DB class
191
+	 *                                                                  extensions
192
+	 * @see      EE_Register_Model_Extension
193
+	 * @type array message_types {
194
+	 *                                                                  An array of message types with the key as
195
+	 *                                                                  the message type name and the values as
196
+	 *                                                                  below:
197
+	 * @type string                   $mtfilename                       [Required] The filename of the message type
198
+	 *                                                                  being registered. This will be the main
199
+	 *                                                                  EE_{Message Type Name}_message_type class.
200
+	 *                                                                  for example:
201
+	 *                                                                  EE_Declined_Registration_message_type.class.php
202
+	 * @type array                    $autoloadpaths                    [Required] An array of paths to add to the
203
+	 *                                                                  messages autoloader for the new message type.
204
+	 * @type array                    $messengers_to_activate_with      An array of messengers that this message
205
+	 *                                                                  type should activate with. Each value in
206
+	 *                                                                  the
207
+	 *                                                                  array
208
+	 *                                                                  should match the name property of a
209
+	 *                                                                  EE_messenger. Optional.
210
+	 * @type array                    $messengers_to_validate_with      An array of messengers that this message
211
+	 *                                                                  type should validate with. Each value in
212
+	 *                                                                  the
213
+	 *                                                                  array
214
+	 *                                                                  should match the name property of an
215
+	 *                                                                  EE_messenger.
216
+	 *                                                                  Optional.
217
+	 *                                                                  }
218
+	 * @type array                    $custom_post_types
219
+	 * @type array                    $custom_taxonomies
220
+	 * @type array                    $payment_method_paths             each element is the folder containing the
221
+	 *                                                                  EE_PMT_Base child class
222
+	 *                                                                  (eg,
223
+	 *                                                                  '/wp-content/plugins/my_plugin/Payomatic/'
224
+	 *                                                                  which contains the files
225
+	 *                                                                  EE_PMT_Payomatic.pm.php)
226
+	 * @type array                    $default_terms
227
+	 * @type array                    $namespace                        {
228
+	 *                                                                  An array with two items for registering the
229
+	 *                                                                  addon's namespace. (If, for some reason, you
230
+	 *                                                                  require additional namespaces,
231
+	 *                                                                  use
232
+	 *                                                                  EventEspresso\core\Psr4Autoloader::addNamespace()
233
+	 *                                                                  directly)
234
+	 * @see      EventEspresso\core\Psr4Autoloader::addNamespace()
235
+	 * @type string                   $FQNS                             the namespace prefix
236
+	 * @type string                   $DIR                              a base directory for class files in the
237
+	 *                                                                  namespace.
238
+	 *                                                                  }
239
+	 *                                                                  }
240
+	 * @type string                   $privacy_policies                 FQNSs (namespaces, each of which contains only
241
+	 *                                                                  privacy policy classes) or FQCNs (specific
242
+	 *                                                                  classnames of privacy policy classes)
243
+	 * @type string                   $personal_data_exporters          FQNSs (namespaces, each of which contains only
244
+	 *                                                                  privacy policy classes) or FQCNs (specific
245
+	 *                                                                  classnames of privacy policy classes)
246
+	 * @type string                   $personal_data_erasers            FQNSs (namespaces, each of which contains only
247
+	 *                                                                  privacy policy classes) or FQCNs (specific
248
+	 *                                                                  classnames of privacy policy classes)
249
+	 * @return void
250
+	 * @throws DomainException
251
+	 * @throws EE_Error
252
+	 * @throws InvalidArgumentException
253
+	 * @throws InvalidDataTypeException
254
+	 * @throws InvalidInterfaceException
255
+	 */
256
+	public static function register($addon_name = '', array $setup_args = array())
257
+	{
258
+		// required fields MUST be present, so let's make sure they are.
259
+		EE_Register_Addon::_verify_parameters($addon_name, $setup_args);
260
+		// get class name for addon
261
+		$class_name = EE_Register_Addon::_parse_class_name($addon_name, $setup_args);
262
+		// setup $_settings array from incoming values.
263
+		$addon_settings = EE_Register_Addon::_get_addon_settings($class_name, $setup_args);
264
+		// setup PUE
265
+		EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
266
+		// does this addon work with this version of core or WordPress ?
267
+		// does this addon work with this version of core or WordPress ?
268
+		if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
269
+			return;
270
+		}
271
+		// register namespaces
272
+		EE_Register_Addon::_setup_namespaces($addon_settings);
273
+		// check if this is an activation request
274
+		if (EE_Register_Addon::_addon_activation($addon_name, $addon_settings)) {
275
+			// dont bother setting up the rest of the addon atm
276
+			return;
277
+		}
278
+		// we need cars
279
+		EE_Register_Addon::_setup_autoloaders($addon_name);
280
+		// register new models and extensions
281
+		EE_Register_Addon::_register_models_and_extensions($addon_name);
282
+		// setup DMS
283
+		EE_Register_Addon::_register_data_migration_scripts($addon_name);
284
+		// if config_class is present let's register config.
285
+		EE_Register_Addon::_register_config($addon_name);
286
+		// register admin pages
287
+		EE_Register_Addon::_register_admin_pages($addon_name);
288
+		// add to list of modules to be registered
289
+		EE_Register_Addon::_register_modules($addon_name);
290
+		// add to list of shortcodes to be registered
291
+		EE_Register_Addon::_register_shortcodes($addon_name);
292
+		// add to list of widgets to be registered
293
+		EE_Register_Addon::_register_widgets($addon_name);
294
+		// register capability related stuff.
295
+		EE_Register_Addon::_register_capabilities($addon_name);
296
+		// any message type to register?
297
+		EE_Register_Addon::_register_message_types($addon_name);
298
+		// any custom post type/ custom capabilities or default terms to register
299
+		EE_Register_Addon::_register_custom_post_types($addon_name);
300
+		// and any payment methods
301
+		EE_Register_Addon::_register_payment_methods($addon_name);
302
+		// and privacy policy generators
303
+		EE_Register_Addon::registerPrivacyPolicies($addon_name);
304
+		// and privacy policy generators
305
+		EE_Register_Addon::registerPersonalDataExporters($addon_name);
306
+		// and privacy policy generators
307
+		EE_Register_Addon::registerPersonalDataErasers($addon_name);
308
+		// load and instantiate main addon class
309
+		$addon = EE_Register_Addon::_load_and_init_addon_class($addon_name);
310
+		// delay calling after_registration hook on each addon until after all add-ons have been registered.
311
+		add_action('AHEE__EE_System__load_espresso_addons__complete', array($addon, 'after_registration'), 999);
312
+	}
313
+
314
+
315
+	/**
316
+	 * @param string $addon_name
317
+	 * @param array  $setup_args
318
+	 * @return void
319
+	 * @throws EE_Error
320
+	 */
321
+	private static function _verify_parameters($addon_name, array $setup_args)
322
+	{
323
+		// required fields MUST be present, so let's make sure they are.
324
+		if (empty($addon_name) || ! is_array($setup_args)) {
325
+			throw new EE_Error(
326
+				esc_html__(
327
+					'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.',
328
+					'event_espresso'
329
+				)
330
+			);
331
+		}
332
+		if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
333
+			throw new EE_Error(
334
+				sprintf(
335
+					esc_html__(
336
+						'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',
337
+						'event_espresso'
338
+					),
339
+					implode(',', array_keys($setup_args))
340
+				)
341
+			);
342
+		}
343
+		// check that addon has not already been registered with that name
344
+		if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
345
+			throw new EE_Error(
346
+				sprintf(
347
+					esc_html__(
348
+						'An EE_Addon with the name "%s" has already been registered and each EE_Addon requires a unique name.',
349
+						'event_espresso'
350
+					),
351
+					$addon_name
352
+				)
353
+			);
354
+		}
355
+	}
356
+
357
+
358
+	/**
359
+	 * @param string $addon_name
360
+	 * @param array  $setup_args
361
+	 * @return string
362
+	 */
363
+	private static function _parse_class_name($addon_name, array $setup_args)
364
+	{
365
+		if (empty($setup_args['class_name'])) {
366
+			// generate one by first separating name with spaces
367
+			$class_name = str_replace(array('-', '_'), ' ', trim($addon_name));
368
+			// capitalize, then replace spaces with underscores
369
+			$class_name = str_replace(' ', '_', ucwords($class_name));
370
+		} else {
371
+			$class_name = $setup_args['class_name'];
372
+		}
373
+		// check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
374
+		return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
375
+			? $class_name
376
+			: 'EE_' . $class_name;
377
+	}
378
+
379
+
380
+	/**
381
+	 * @param string $class_name
382
+	 * @param array  $setup_args
383
+	 * @return array
384
+	 */
385
+	private static function _get_addon_settings($class_name, array $setup_args)
386
+	{
387
+		// setup $_settings array from incoming values.
388
+		$addon_settings = array(
389
+			// generated from the addon name, changes something like "calendar" to "EE_Calendar"
390
+			'class_name'            => $class_name,
391
+			// the addon slug for use in URLs, etc
392
+			'plugin_slug'           => isset($setup_args['plugin_slug'])
393
+				? (string) $setup_args['plugin_slug']
394
+				: '',
395
+			// page slug to be used when generating the "Settings" link on the WP plugin page
396
+			'plugin_action_slug'    => isset($setup_args['plugin_action_slug'])
397
+				? (string) $setup_args['plugin_action_slug']
398
+				: '',
399
+			// the "software" version for the addon
400
+			'version'               => isset($setup_args['version'])
401
+				? (string) $setup_args['version']
402
+				: '',
403
+			// the minimum version of EE Core that the addon will work with
404
+			'min_core_version'      => isset($setup_args['min_core_version'])
405
+				? (string) $setup_args['min_core_version']
406
+				: '',
407
+			// the minimum version of WordPress that the addon will work with
408
+			'min_wp_version'        => isset($setup_args['min_wp_version'])
409
+				? (string) $setup_args['min_wp_version']
410
+				: EE_MIN_WP_VER_REQUIRED,
411
+			// full server path to main file (file loaded directly by WP)
412
+			'main_file_path'        => isset($setup_args['main_file_path'])
413
+				? (string) $setup_args['main_file_path']
414
+				: '',
415
+			// instance of \EventEspresso\core\domain\DomainInterface
416
+			'domain'                => isset($setup_args['domain']) && $setup_args['domain'] instanceof DomainInterface
417
+				? $setup_args['domain']
418
+				: null,
419
+			// Fully Qualified Class Name for the addon's Domain class
420
+			'domain_fqcn'           => isset($setup_args['domain_fqcn'])
421
+				? (string) $setup_args['domain_fqcn']
422
+				: '',
423
+			// path to folder containing files for integrating with the EE core admin and/or setting up EE admin pages
424
+			'admin_path'            => isset($setup_args['admin_path'])
425
+				? (string) $setup_args['admin_path'] : '',
426
+			// a method to be called when the EE Admin is first invoked, can be used for hooking into any admin page
427
+			'admin_callback'        => isset($setup_args['admin_callback'])
428
+				? (string) $setup_args['admin_callback']
429
+				: '',
430
+			// the section name for this addon's configuration settings section (defaults to "addons")
431
+			'config_section'        => isset($setup_args['config_section'])
432
+				? (string) $setup_args['config_section']
433
+				: 'addons',
434
+			// the class name for this addon's configuration settings object
435
+			'config_class'          => isset($setup_args['config_class'])
436
+				? (string) $setup_args['config_class'] : '',
437
+			// the name given to the config for this addons' configuration settings object (optional)
438
+			'config_name'           => isset($setup_args['config_name'])
439
+				? (string) $setup_args['config_name'] : '',
440
+			// an array of "class names" => "full server paths" for any classes that might be invoked by the addon
441
+			'autoloader_paths'      => isset($setup_args['autoloader_paths'])
442
+				? (array) $setup_args['autoloader_paths']
443
+				: array(),
444
+			// an array of  "full server paths" for any folders containing classes that might be invoked by the addon
445
+			'autoloader_folders'    => isset($setup_args['autoloader_folders'])
446
+				? (array) $setup_args['autoloader_folders']
447
+				: array(),
448
+			// array of full server paths to any EE_DMS data migration scripts used by the addon.
449
+			// The key should be the EE_Addon class name that this set of data migration scripts belongs to.
450
+			// If the EE_Addon class is namespaced, then this needs to be the Fully Qualified Class Name
451
+			'dms_paths'             => isset($setup_args['dms_paths'])
452
+				? (array) $setup_args['dms_paths']
453
+				: array(),
454
+			// array of full server paths to any EED_Modules used by the addon
455
+			'module_paths'          => isset($setup_args['module_paths'])
456
+				? (array) $setup_args['module_paths']
457
+				: array(),
458
+			// array of full server paths to any EES_Shortcodes used by the addon
459
+			'shortcode_paths'       => isset($setup_args['shortcode_paths'])
460
+				? (array) $setup_args['shortcode_paths']
461
+				: array(),
462
+			'shortcode_fqcns'       => isset($setup_args['shortcode_fqcns'])
463
+				? (array) $setup_args['shortcode_fqcns']
464
+				: array(),
465
+			// array of full server paths to any WP_Widgets used by the addon
466
+			'widget_paths'          => isset($setup_args['widget_paths'])
467
+				? (array) $setup_args['widget_paths']
468
+				: array(),
469
+			// array of PUE options used by the addon
470
+			'pue_options'           => isset($setup_args['pue_options'])
471
+				? (array) $setup_args['pue_options']
472
+				: array(),
473
+			'message_types'         => isset($setup_args['message_types'])
474
+				? (array) $setup_args['message_types']
475
+				: array(),
476
+			'capabilities'          => isset($setup_args['capabilities'])
477
+				? (array) $setup_args['capabilities']
478
+				: array(),
479
+			'capability_maps'       => isset($setup_args['capability_maps'])
480
+				? (array) $setup_args['capability_maps']
481
+				: array(),
482
+			'model_paths'           => isset($setup_args['model_paths'])
483
+				? (array) $setup_args['model_paths']
484
+				: array(),
485
+			'class_paths'           => isset($setup_args['class_paths'])
486
+				? (array) $setup_args['class_paths']
487
+				: array(),
488
+			'model_extension_paths' => isset($setup_args['model_extension_paths'])
489
+				? (array) $setup_args['model_extension_paths']
490
+				: array(),
491
+			'class_extension_paths' => isset($setup_args['class_extension_paths'])
492
+				? (array) $setup_args['class_extension_paths']
493
+				: array(),
494
+			'custom_post_types'     => isset($setup_args['custom_post_types'])
495
+				? (array) $setup_args['custom_post_types']
496
+				: array(),
497
+			'custom_taxonomies'     => isset($setup_args['custom_taxonomies'])
498
+				? (array) $setup_args['custom_taxonomies']
499
+				: array(),
500
+			'payment_method_paths'  => isset($setup_args['payment_method_paths'])
501
+				? (array) $setup_args['payment_method_paths']
502
+				: array(),
503
+			'default_terms'         => isset($setup_args['default_terms'])
504
+				? (array) $setup_args['default_terms']
505
+				: array(),
506
+			// if not empty, inserts a new table row after this plugin's row on the WP Plugins page
507
+			// that can be used for adding upgrading/marketing info
508
+			'plugins_page_row'      => isset($setup_args['plugins_page_row']) ? $setup_args['plugins_page_row'] : '',
509
+			'namespace'             => isset(
510
+				$setup_args['namespace']['FQNS'],
511
+				$setup_args['namespace']['DIR']
512
+			)
513
+				? (array) $setup_args['namespace']
514
+				: array(),
515
+			'privacy_policies'      => isset($setup_args['privacy_policies'])
516
+				? (array) $setup_args['privacy_policies']
517
+				: '',
518
+		);
519
+		// if plugin_action_slug is NOT set, but an admin page path IS set,
520
+		// then let's just use the plugin_slug since that will be used for linking to the admin page
521
+		$addon_settings['plugin_action_slug'] = empty($addon_settings['plugin_action_slug'])
522
+												&& ! empty($addon_settings['admin_path'])
523
+			? $addon_settings['plugin_slug']
524
+			: $addon_settings['plugin_action_slug'];
525
+		// full server path to main file (file loaded directly by WP)
526
+		$addon_settings['plugin_basename'] = plugin_basename($addon_settings['main_file_path']);
527
+		return $addon_settings;
528
+	}
529
+
530
+
531
+	/**
532
+	 * @param string $addon_name
533
+	 * @param array  $addon_settings
534
+	 * @return boolean
535
+	 */
536
+	private static function _addon_is_compatible($addon_name, array $addon_settings)
537
+	{
538
+		global $wp_version;
539
+		$incompatibility_message = '';
540
+		// check whether this addon version is compatible with EE core
541
+		if (
542
+			isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
543
+			&& ! self::_meets_min_core_version_requirement(
544
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
545
+				$addon_settings['version']
546
+			)
547
+		) {
548
+			$incompatibility_message = sprintf(
549
+				esc_html__(
550
+					'%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.',
551
+					'event_espresso'
552
+				),
553
+				$addon_name,
554
+				'<br />',
555
+				EE_Register_Addon::$_incompatible_addons[ $addon_name ],
556
+				'<span style="font-weight: bold; color: #D54E21;">',
557
+				'</span><br />'
558
+			);
559
+		} elseif (
560
+			! self::_meets_min_core_version_requirement($addon_settings['min_core_version'], espresso_version())
561
+		) {
562
+			$incompatibility_message = sprintf(
563
+				esc_html__(
564
+					'%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".',
565
+					'event_espresso'
566
+				),
567
+				$addon_name,
568
+				self::_effective_version($addon_settings['min_core_version']),
569
+				self::_effective_version(espresso_version()),
570
+				'<br />',
571
+				'<span style="font-weight: bold; color: #D54E21;">',
572
+				'</span><br />'
573
+			);
574
+		} elseif (version_compare($wp_version, $addon_settings['min_wp_version'], '<')) {
575
+			$incompatibility_message = sprintf(
576
+				esc_html__(
577
+					'%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.',
578
+					'event_espresso'
579
+				),
580
+				$addon_name,
581
+				$addon_settings['min_wp_version'],
582
+				'<br />',
583
+				'<span style="font-weight: bold; color: #D54E21;">',
584
+				'</span><br />'
585
+			);
586
+		}
587
+		if (! empty($incompatibility_message)) {
588
+			// remove 'activate' from the REQUEST
589
+			// so WP doesn't erroneously tell the user the plugin activated fine when it didn't
590
+			/** @var RequestInterface $request */
591
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
592
+			$request->unSetRequestParam('activate', true);
593
+			if (current_user_can('activate_plugins')) {
594
+				// show an error message indicating the plugin didn't activate properly
595
+				EE_Error::add_error($incompatibility_message, __FILE__, __FUNCTION__, __LINE__);
596
+			}
597
+			// BAIL FROM THE ADDON REGISTRATION PROCESS
598
+			return false;
599
+		}
600
+		// addon IS compatible
601
+		return true;
602
+	}
603
+
604
+
605
+	/**
606
+	 * if plugin update engine is being used for auto-updates,
607
+	 * then let's set that up now before going any further so that ALL addons can be updated
608
+	 * (not needed if PUE is not being used)
609
+	 *
610
+	 * @param string $addon_name
611
+	 * @param string $class_name
612
+	 * @param array  $setup_args
613
+	 * @return void
614
+	 */
615
+	private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
616
+	{
617
+		if (! empty($setup_args['pue_options'])) {
618
+			self::$_settings[ $addon_name ]['pue_options'] = array(
619
+				'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
620
+					? (string) $setup_args['pue_options']['pue_plugin_slug']
621
+					: 'espresso_' . strtolower($class_name),
622
+				'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
623
+					? (string) $setup_args['pue_options']['plugin_basename']
624
+					: plugin_basename($setup_args['main_file_path']),
625
+				'checkPeriod'     => isset($setup_args['pue_options']['checkPeriod'])
626
+					? (string) $setup_args['pue_options']['checkPeriod']
627
+					: '24',
628
+				'use_wp_update'   => isset($setup_args['pue_options']['use_wp_update'])
629
+					? (string) $setup_args['pue_options']['use_wp_update']
630
+					: false,
631
+			);
632
+			add_action(
633
+				'AHEE__EE_System__brew_espresso__after_pue_init',
634
+				array('EE_Register_Addon', 'load_pue_update')
635
+			);
636
+		}
637
+	}
638
+
639
+
640
+	/**
641
+	 * register namespaces right away before any other files or classes get loaded, but AFTER the version checks
642
+	 *
643
+	 * @param array $addon_settings
644
+	 * @return void
645
+	 */
646
+	private static function _setup_namespaces(array $addon_settings)
647
+	{
648
+		//
649
+		if (
650
+			isset(
651
+				$addon_settings['namespace']['FQNS'],
652
+				$addon_settings['namespace']['DIR']
653
+			)
654
+		) {
655
+			EE_Psr4AutoloaderInit::psr4_loader()->addNamespace(
656
+				$addon_settings['namespace']['FQNS'],
657
+				$addon_settings['namespace']['DIR']
658
+			);
659
+		}
660
+	}
661
+
662
+
663
+	/**
664
+	 * @param string $addon_name
665
+	 * @param array  $addon_settings
666
+	 * @return bool
667
+	 * @throws InvalidArgumentException
668
+	 * @throws InvalidDataTypeException
669
+	 * @throws InvalidInterfaceException
670
+	 */
671
+	private static function _addon_activation($addon_name, array $addon_settings)
672
+	{
673
+		// this is an activation request
674
+		if (did_action('activate_plugin')) {
675
+			// to find if THIS is the addon that was activated, just check if we have already registered it or not
676
+			// (as the newly-activated addon wasn't around the first time addons were registered).
677
+			// Note: the presence of pue_options in the addon registration options will initialize the $_settings
678
+			// property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
679
+			if (
680
+				! isset(self::$_settings[ $addon_name ])
681
+				|| (isset(self::$_settings[ $addon_name ])
682
+					&& ! isset(self::$_settings[ $addon_name ]['class_name'])
683
+				)
684
+			) {
685
+				self::$_settings[ $addon_name ] = $addon_settings;
686
+				$addon = self::_load_and_init_addon_class($addon_name);
687
+				$addon->set_activation_indicator_option();
688
+				// dont bother setting up the rest of the addon.
689
+				// we know it was just activated and the request will end soon
690
+			}
691
+			return true;
692
+		}
693
+		// make sure this was called in the right place!
694
+		if (
695
+			! did_action('AHEE__EE_System__load_espresso_addons')
696
+			|| did_action('AHEE__EE_System___detect_if_activation_or_upgrade__begin')
697
+		) {
698
+			EE_Error::doing_it_wrong(
699
+				__METHOD__,
700
+				sprintf(
701
+					esc_html__(
702
+						'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.',
703
+						'event_espresso'
704
+					),
705
+					$addon_name
706
+				),
707
+				'4.3.0'
708
+			);
709
+		}
710
+		// make sure addon settings are set correctly without overwriting anything existing
711
+		if (isset(self::$_settings[ $addon_name ])) {
712
+			self::$_settings[ $addon_name ] += $addon_settings;
713
+		} else {
714
+			self::$_settings[ $addon_name ] = $addon_settings;
715
+		}
716
+		return false;
717
+	}
718
+
719
+
720
+	/**
721
+	 * @param string $addon_name
722
+	 * @return void
723
+	 * @throws EE_Error
724
+	 */
725
+	private static function _setup_autoloaders($addon_name)
726
+	{
727
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
728
+			// setup autoloader for single file
729
+			EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
730
+		}
731
+		// setup autoloaders for folders
732
+		if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
733
+			foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
734
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
735
+			}
736
+		}
737
+	}
738
+
739
+
740
+	/**
741
+	 * register new models and extensions
742
+	 *
743
+	 * @param string $addon_name
744
+	 * @return void
745
+	 * @throws EE_Error
746
+	 */
747
+	private static function _register_models_and_extensions($addon_name)
748
+	{
749
+		// register new models
750
+		if (
751
+			! empty(self::$_settings[ $addon_name ]['model_paths'])
752
+			|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
753
+		) {
754
+			EE_Register_Model::register(
755
+				$addon_name,
756
+				array(
757
+					'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
758
+					'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
759
+				)
760
+			);
761
+		}
762
+		// register model extensions
763
+		if (
764
+			! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
765
+			|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
766
+		) {
767
+			EE_Register_Model_Extensions::register(
768
+				$addon_name,
769
+				array(
770
+					'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
771
+					'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
772
+				)
773
+			);
774
+		}
775
+	}
776
+
777
+
778
+	/**
779
+	 * @param string $addon_name
780
+	 * @return void
781
+	 * @throws EE_Error
782
+	 */
783
+	private static function _register_data_migration_scripts($addon_name)
784
+	{
785
+		// setup DMS
786
+		if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
787
+			EE_Register_Data_Migration_Scripts::register(
788
+				$addon_name,
789
+				array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
790
+			);
791
+		}
792
+	}
793
+
794
+
795
+	/**
796
+	 * @param string $addon_name
797
+	 * @return void
798
+	 * @throws EE_Error
799
+	 */
800
+	private static function _register_config($addon_name)
801
+	{
802
+		// if config_class is present let's register config.
803
+		if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
804
+			EE_Register_Config::register(
805
+				self::$_settings[ $addon_name ]['config_class'],
806
+				array(
807
+					'config_section' => self::$_settings[ $addon_name ]['config_section'],
808
+					'config_name'    => self::$_settings[ $addon_name ]['config_name'],
809
+				)
810
+			);
811
+		}
812
+	}
813
+
814
+
815
+	/**
816
+	 * @param string $addon_name
817
+	 * @return void
818
+	 * @throws EE_Error
819
+	 */
820
+	private static function _register_admin_pages($addon_name)
821
+	{
822
+		if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
823
+			EE_Register_Admin_Page::register(
824
+				$addon_name,
825
+				array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
826
+			);
827
+		}
828
+	}
829
+
830
+
831
+	/**
832
+	 * @param string $addon_name
833
+	 * @return void
834
+	 * @throws EE_Error
835
+	 */
836
+	private static function _register_modules($addon_name)
837
+	{
838
+		if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
839
+			EE_Register_Module::register(
840
+				$addon_name,
841
+				array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
842
+			);
843
+		}
844
+	}
845
+
846
+
847
+	/**
848
+	 * @param string $addon_name
849
+	 * @return void
850
+	 * @throws EE_Error
851
+	 */
852
+	private static function _register_shortcodes($addon_name)
853
+	{
854
+		if (
855
+			! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
856
+			|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
857
+		) {
858
+			EE_Register_Shortcode::register(
859
+				$addon_name,
860
+				array(
861
+					'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
862
+						? self::$_settings[ $addon_name ]['shortcode_paths'] : array(),
863
+					'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
864
+						? self::$_settings[ $addon_name ]['shortcode_fqcns'] : array(),
865
+				)
866
+			);
867
+		}
868
+	}
869
+
870
+
871
+	/**
872
+	 * @param string $addon_name
873
+	 * @return void
874
+	 * @throws EE_Error
875
+	 */
876
+	private static function _register_widgets($addon_name)
877
+	{
878
+		if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
879
+			EE_Register_Widget::register(
880
+				$addon_name,
881
+				array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
882
+			);
883
+		}
884
+	}
885
+
886
+
887
+	/**
888
+	 * @param string $addon_name
889
+	 * @return void
890
+	 * @throws EE_Error
891
+	 */
892
+	private static function _register_capabilities($addon_name)
893
+	{
894
+		if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
895
+			EE_Register_Capabilities::register(
896
+				$addon_name,
897
+				array(
898
+					'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
899
+					'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
900
+				)
901
+			);
902
+		}
903
+	}
904
+
905
+
906
+	/**
907
+	 * @param string $addon_name
908
+	 * @return void
909
+	 */
910
+	private static function _register_message_types($addon_name)
911
+	{
912
+		if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
913
+			add_action(
914
+				'EE_Brewing_Regular___messages_caf',
915
+				array('EE_Register_Addon', 'register_message_types')
916
+			);
917
+		}
918
+	}
919
+
920
+
921
+	/**
922
+	 * @param string $addon_name
923
+	 * @return void
924
+	 * @throws EE_Error
925
+	 */
926
+	private static function _register_custom_post_types($addon_name)
927
+	{
928
+		if (
929
+			! empty(self::$_settings[ $addon_name ]['custom_post_types'])
930
+			|| ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
931
+		) {
932
+			EE_Register_CPT::register(
933
+				$addon_name,
934
+				array(
935
+					'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
936
+					'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
937
+					'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
938
+				)
939
+			);
940
+		}
941
+	}
942
+
943
+
944
+	/**
945
+	 * @param string $addon_name
946
+	 * @return void
947
+	 * @throws InvalidArgumentException
948
+	 * @throws InvalidInterfaceException
949
+	 * @throws InvalidDataTypeException
950
+	 * @throws DomainException
951
+	 * @throws EE_Error
952
+	 */
953
+	private static function _register_payment_methods($addon_name)
954
+	{
955
+		if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
956
+			EE_Register_Payment_Method::register(
957
+				$addon_name,
958
+				array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
959
+			);
960
+		}
961
+	}
962
+
963
+
964
+	/**
965
+	 * @param string $addon_name
966
+	 * @return void
967
+	 * @throws InvalidArgumentException
968
+	 * @throws InvalidInterfaceException
969
+	 * @throws InvalidDataTypeException
970
+	 * @throws DomainException
971
+	 */
972
+	private static function registerPrivacyPolicies($addon_name)
973
+	{
974
+		if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
975
+			EE_Register_Privacy_Policy::register(
976
+				$addon_name,
977
+				self::$_settings[ $addon_name ]['privacy_policies']
978
+			);
979
+		}
980
+	}
981
+
982
+
983
+	/**
984
+	 * @param string $addon_name
985
+	 * @return void
986
+	 */
987
+	private static function registerPersonalDataExporters($addon_name)
988
+	{
989
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
990
+			EE_Register_Personal_Data_Eraser::register(
991
+				$addon_name,
992
+				self::$_settings[ $addon_name ]['personal_data_exporters']
993
+			);
994
+		}
995
+	}
996
+
997
+
998
+	/**
999
+	 * @param string $addon_name
1000
+	 * @return void
1001
+	 */
1002
+	private static function registerPersonalDataErasers($addon_name)
1003
+	{
1004
+		if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1005
+			EE_Register_Personal_Data_Eraser::register(
1006
+				$addon_name,
1007
+				self::$_settings[ $addon_name ]['personal_data_erasers']
1008
+			);
1009
+		}
1010
+	}
1011
+
1012
+
1013
+	/**
1014
+	 * Loads and instantiates the EE_Addon class and adds it onto the registry
1015
+	 *
1016
+	 * @param string $addon_name
1017
+	 * @return EE_Addon
1018
+	 * @throws InvalidArgumentException
1019
+	 * @throws InvalidInterfaceException
1020
+	 * @throws InvalidDataTypeException
1021
+	 */
1022
+	private static function _load_and_init_addon_class($addon_name)
1023
+	{
1024
+		$addon = LoaderFactory::getLoader()->getShared(
1025
+			self::$_settings[ $addon_name ]['class_name'],
1026
+			array('EE_Registry::create(addon)' => true)
1027
+		);
1028
+		if (! $addon instanceof EE_Addon) {
1029
+			throw new DomainException(
1030
+				sprintf(
1031
+					esc_html__(
1032
+						'Failed to instantiate the %1$s class. PLease check that the class exists.',
1033
+						'event_espresso'
1034
+					),
1035
+					$addon_name
1036
+				)
1037
+			);
1038
+		}
1039
+		// setter inject dep map if required
1040
+		if ($addon->dependencyMap() === null) {
1041
+			$addon->setDependencyMap(LoaderFactory::getLoader()->getShared('EE_Dependency_Map'));
1042
+		}
1043
+		// setter inject domain if required
1044
+		EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1045
+
1046
+		$addon->set_name($addon_name);
1047
+		$addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1048
+		$addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1049
+		$addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1050
+		$addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1051
+		$addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1052
+		$addon->set_version(self::$_settings[ $addon_name ]['version']);
1053
+		$addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1054
+		$addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1055
+		$addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1056
+		$addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1057
+		// setup the add-on's pue_slug if we have one.
1058
+		if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1059
+			$addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1060
+		}
1061
+		// unfortunately this can't be hooked in upon construction,
1062
+		// because we don't have the plugin's mainfile path upon construction.
1063
+		register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1064
+		// call any additional admin_callback functions during load_admin_controller hook
1065
+		if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1066
+			add_action(
1067
+				'AHEE__EE_System__load_controllers__load_admin_controllers',
1068
+				array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1069
+			);
1070
+		}
1071
+		return $addon;
1072
+	}
1073
+
1074
+
1075
+	/**
1076
+	 * @param string   $addon_name
1077
+	 * @param EE_Addon $addon
1078
+	 * @since   4.10.13.p
1079
+	 */
1080
+	private static function injectAddonDomain($addon_name, EE_Addon $addon)
1081
+	{
1082
+		if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1083
+			// using supplied Domain object
1084
+			$domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1085
+				? self::$_settings[ $addon_name ]['domain']
1086
+				: null;
1087
+			// or construct one using Domain FQCN
1088
+			if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1089
+				$domain = LoaderFactory::getLoader()->getShared(
1090
+					self::$_settings[ $addon_name ]['domain_fqcn'],
1091
+					[
1092
+						new EventEspresso\core\domain\values\FilePath(
1093
+							self::$_settings[ $addon_name ]['main_file_path']
1094
+						),
1095
+						EventEspresso\core\domain\values\Version::fromString(
1096
+							self::$_settings[ $addon_name ]['version']
1097
+						),
1098
+					]
1099
+				);
1100
+			}
1101
+			if ($domain instanceof DomainInterface) {
1102
+				$addon->setDomain($domain);
1103
+			}
1104
+		}
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 *    load_pue_update - Update notifications
1110
+	 *
1111
+	 * @return void
1112
+	 * @throws InvalidArgumentException
1113
+	 * @throws InvalidDataTypeException
1114
+	 * @throws InvalidInterfaceException
1115
+	 */
1116
+	public static function load_pue_update()
1117
+	{
1118
+		// load PUE client
1119
+		require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1120
+		$license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1121
+		// cycle thru settings
1122
+		foreach (self::$_settings as $settings) {
1123
+			if (! empty($settings['pue_options'])) {
1124
+				// initiate the class and start the plugin update engine!
1125
+				new PluginUpdateEngineChecker(
1126
+					// host file URL
1127
+					$license_server,
1128
+					// plugin slug(s)
1129
+					array(
1130
+						'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1131
+						'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1132
+					),
1133
+					// options
1134
+					array(
1135
+						'apikey'            => EE_Registry::instance()->NET_CFG->core->site_license_key,
1136
+						'lang_domain'       => 'event_espresso',
1137
+						'checkPeriod'       => $settings['pue_options']['checkPeriod'],
1138
+						'option_key'        => 'ee_site_license_key',
1139
+						'options_page_slug' => 'event_espresso',
1140
+						'plugin_basename'   => $settings['pue_options']['plugin_basename'],
1141
+						// if use_wp_update is TRUE it means you want FREE versions of the plugin to be updated from WP
1142
+						'use_wp_update'     => $settings['pue_options']['use_wp_update'],
1143
+					)
1144
+				);
1145
+			}
1146
+		}
1147
+	}
1148
+
1149
+
1150
+	/**
1151
+	 * Callback for EE_Brewing_Regular__messages_caf hook used to register message types.
1152
+	 *
1153
+	 * @since 4.4.0
1154
+	 * @return void
1155
+	 * @throws EE_Error
1156
+	 */
1157
+	public static function register_message_types()
1158
+	{
1159
+		foreach (self::$_settings as $settings) {
1160
+			if (! empty($settings['message_types'])) {
1161
+				foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1162
+					EE_Register_Message_Type::register($message_type, $message_type_settings);
1163
+				}
1164
+			}
1165
+		}
1166
+	}
1167
+
1168
+
1169
+	/**
1170
+	 * This deregisters an addon that was previously registered with a specific addon_name.
1171
+	 *
1172
+	 * @param string $addon_name the name for the addon that was previously registered
1173
+	 * @throws DomainException
1174
+	 * @throws InvalidArgumentException
1175
+	 * @throws InvalidDataTypeException
1176
+	 * @throws InvalidInterfaceException
1177
+	 *@since    4.3.0
1178
+	 */
1179
+	public static function deregister($addon_name = '')
1180
+	{
1181
+		if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1182
+			try {
1183
+				do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1184
+				$class_name = self::$_settings[ $addon_name ]['class_name'];
1185
+				if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1186
+					// setup DMS
1187
+					EE_Register_Data_Migration_Scripts::deregister($addon_name);
1188
+				}
1189
+				if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1190
+					// register admin page
1191
+					EE_Register_Admin_Page::deregister($addon_name);
1192
+				}
1193
+				if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1194
+					// add to list of modules to be registered
1195
+					EE_Register_Module::deregister($addon_name);
1196
+				}
1197
+				if (
1198
+					! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1199
+					|| ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1200
+				) {
1201
+					// add to list of shortcodes to be registered
1202
+					EE_Register_Shortcode::deregister($addon_name);
1203
+				}
1204
+				if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1205
+					// if config_class present let's register config.
1206
+					EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1207
+				}
1208
+				if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1209
+					// add to list of widgets to be registered
1210
+					EE_Register_Widget::deregister($addon_name);
1211
+				}
1212
+				if (
1213
+					! empty(self::$_settings[ $addon_name ]['model_paths'])
1214
+					|| ! empty(self::$_settings[ $addon_name ]['class_paths'])
1215
+				) {
1216
+					// add to list of shortcodes to be registered
1217
+					EE_Register_Model::deregister($addon_name);
1218
+				}
1219
+				if (
1220
+					! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1221
+					|| ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1222
+				) {
1223
+					// add to list of shortcodes to be registered
1224
+					EE_Register_Model_Extensions::deregister($addon_name);
1225
+				}
1226
+				if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1227
+					foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1228
+						EE_Register_Message_Type::deregister($message_type);
1229
+					}
1230
+				}
1231
+				// deregister capabilities for addon
1232
+				if (
1233
+					! empty(self::$_settings[ $addon_name ]['capabilities'])
1234
+					|| ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1235
+				) {
1236
+					EE_Register_Capabilities::deregister($addon_name);
1237
+				}
1238
+				// deregister custom_post_types for addon
1239
+				if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1240
+					EE_Register_CPT::deregister($addon_name);
1241
+				}
1242
+				if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1243
+					EE_Register_Payment_Method::deregister($addon_name);
1244
+				}
1245
+				$addon = EE_Registry::instance()->getAddon($class_name);
1246
+				if ($addon instanceof EE_Addon) {
1247
+					remove_action(
1248
+						'deactivate_' . $addon->get_main_plugin_file_basename(),
1249
+						array($addon, 'deactivation')
1250
+					);
1251
+					remove_action(
1252
+						'AHEE__EE_System__perform_activations_upgrades_and_migrations',
1253
+						array($addon, 'initialize_db_if_no_migrations_required')
1254
+					);
1255
+					// remove `after_registration` call
1256
+					remove_action(
1257
+						'AHEE__EE_System__load_espresso_addons__complete',
1258
+						array($addon, 'after_registration'),
1259
+						999
1260
+					);
1261
+				}
1262
+				EE_Registry::instance()->removeAddon($class_name);
1263
+				LoaderFactory::getLoader()->remove($class_name);
1264
+			} catch (OutOfBoundsException $addon_not_yet_registered_exception) {
1265
+				// the add-on was not yet registered in the registry,
1266
+				// so RegistryContainer::__get() throws this exception.
1267
+				// also no need to worry about this or log it,
1268
+				// it's ok to deregister an add-on before its registered in the registry
1269
+			} catch (Exception $e) {
1270
+				new ExceptionLogger($e);
1271
+			}
1272
+			unset(self::$_settings[ $addon_name ]);
1273
+			do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1274
+		}
1275
+	}
1276 1276
 }
Please login to merge, or discard this patch.
Spacing   +116 added lines, -116 removed lines patch added patch discarded remove patch
@@ -70,15 +70,15 @@  discard block
 block discarded – undo
70 70
         // offsets:    0 . 1 . 2 . 3 . 4
71 71
         $version_parts = explode('.', $min_core_version);
72 72
         // check they specified the micro version (after 2nd period)
73
-        if (! isset($version_parts[2])) {
73
+        if ( ! isset($version_parts[2])) {
74 74
             $version_parts[2] = '0';
75 75
         }
76 76
         // if they didn't specify the 'p', or 'rc' part. Just assume the lowest possible
77 77
         // soon we can assume that's 'rc', but this current version is 'alpha'
78
-        if (! isset($version_parts[3])) {
78
+        if ( ! isset($version_parts[3])) {
79 79
             $version_parts[3] = 'dev';
80 80
         }
81
-        if (! isset($version_parts[4])) {
81
+        if ( ! isset($version_parts[4])) {
82 82
             $version_parts[4] = '000';
83 83
         }
84 84
         return implode('.', $version_parts);
@@ -265,7 +265,7 @@  discard block
 block discarded – undo
265 265
         EE_Register_Addon::_parse_pue_options($addon_name, $class_name, $setup_args);
266 266
         // does this addon work with this version of core or WordPress ?
267 267
         // does this addon work with this version of core or WordPress ?
268
-        if (! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
268
+        if ( ! EE_Register_Addon::_addon_is_compatible($addon_name, $addon_settings)) {
269 269
             return;
270 270
         }
271 271
         // register namespaces
@@ -329,7 +329,7 @@  discard block
 block discarded – undo
329 329
                 )
330 330
             );
331 331
         }
332
-        if (! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
332
+        if ( ! isset($setup_args['main_file_path']) || empty($setup_args['main_file_path'])) {
333 333
             throw new EE_Error(
334 334
                 sprintf(
335 335
                     esc_html__(
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
             );
342 342
         }
343 343
         // check that addon has not already been registered with that name
344
-        if (isset(self::$_settings[ $addon_name ]) && ! did_action('activate_plugin')) {
344
+        if (isset(self::$_settings[$addon_name]) && ! did_action('activate_plugin')) {
345 345
             throw new EE_Error(
346 346
                 sprintf(
347 347
                     esc_html__(
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
         // check if classname is fully  qualified or is a legacy classname already prefixed with 'EE_'
374 374
         return strpos($class_name, '\\') || strpos($class_name, 'EE_') === 0
375 375
             ? $class_name
376
-            : 'EE_' . $class_name;
376
+            : 'EE_'.$class_name;
377 377
     }
378 378
 
379 379
 
@@ -539,9 +539,9 @@  discard block
 block discarded – undo
539 539
         $incompatibility_message = '';
540 540
         // check whether this addon version is compatible with EE core
541 541
         if (
542
-            isset(EE_Register_Addon::$_incompatible_addons[ $addon_name ])
542
+            isset(EE_Register_Addon::$_incompatible_addons[$addon_name])
543 543
             && ! self::_meets_min_core_version_requirement(
544
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
544
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
545 545
                 $addon_settings['version']
546 546
             )
547 547
         ) {
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
                 ),
553 553
                 $addon_name,
554 554
                 '<br />',
555
-                EE_Register_Addon::$_incompatible_addons[ $addon_name ],
555
+                EE_Register_Addon::$_incompatible_addons[$addon_name],
556 556
                 '<span style="font-weight: bold; color: #D54E21;">',
557 557
                 '</span><br />'
558 558
             );
@@ -584,7 +584,7 @@  discard block
 block discarded – undo
584 584
                 '</span><br />'
585 585
             );
586 586
         }
587
-        if (! empty($incompatibility_message)) {
587
+        if ( ! empty($incompatibility_message)) {
588 588
             // remove 'activate' from the REQUEST
589 589
             // so WP doesn't erroneously tell the user the plugin activated fine when it didn't
590 590
             /** @var RequestInterface $request */
@@ -614,11 +614,11 @@  discard block
 block discarded – undo
614 614
      */
615 615
     private static function _parse_pue_options($addon_name, $class_name, array $setup_args)
616 616
     {
617
-        if (! empty($setup_args['pue_options'])) {
618
-            self::$_settings[ $addon_name ]['pue_options'] = array(
617
+        if ( ! empty($setup_args['pue_options'])) {
618
+            self::$_settings[$addon_name]['pue_options'] = array(
619 619
                 'pue_plugin_slug' => isset($setup_args['pue_options']['pue_plugin_slug'])
620 620
                     ? (string) $setup_args['pue_options']['pue_plugin_slug']
621
-                    : 'espresso_' . strtolower($class_name),
621
+                    : 'espresso_'.strtolower($class_name),
622 622
                 'plugin_basename' => isset($setup_args['pue_options']['plugin_basename'])
623 623
                     ? (string) $setup_args['pue_options']['plugin_basename']
624 624
                     : plugin_basename($setup_args['main_file_path']),
@@ -677,12 +677,12 @@  discard block
 block discarded – undo
677 677
             // Note: the presence of pue_options in the addon registration options will initialize the $_settings
678 678
             // property for the add-on, but the add-on is only partially initialized.  Hence, the additional check.
679 679
             if (
680
-                ! isset(self::$_settings[ $addon_name ])
681
-                || (isset(self::$_settings[ $addon_name ])
682
-                    && ! isset(self::$_settings[ $addon_name ]['class_name'])
680
+                ! isset(self::$_settings[$addon_name])
681
+                || (isset(self::$_settings[$addon_name])
682
+                    && ! isset(self::$_settings[$addon_name]['class_name'])
683 683
                 )
684 684
             ) {
685
-                self::$_settings[ $addon_name ] = $addon_settings;
685
+                self::$_settings[$addon_name] = $addon_settings;
686 686
                 $addon = self::_load_and_init_addon_class($addon_name);
687 687
                 $addon->set_activation_indicator_option();
688 688
                 // dont bother setting up the rest of the addon.
@@ -708,10 +708,10 @@  discard block
 block discarded – undo
708 708
             );
709 709
         }
710 710
         // make sure addon settings are set correctly without overwriting anything existing
711
-        if (isset(self::$_settings[ $addon_name ])) {
712
-            self::$_settings[ $addon_name ] += $addon_settings;
711
+        if (isset(self::$_settings[$addon_name])) {
712
+            self::$_settings[$addon_name] += $addon_settings;
713 713
         } else {
714
-            self::$_settings[ $addon_name ] = $addon_settings;
714
+            self::$_settings[$addon_name] = $addon_settings;
715 715
         }
716 716
         return false;
717 717
     }
@@ -724,13 +724,13 @@  discard block
 block discarded – undo
724 724
      */
725 725
     private static function _setup_autoloaders($addon_name)
726 726
     {
727
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_paths'])) {
727
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_paths'])) {
728 728
             // setup autoloader for single file
729
-            EEH_Autoloader::instance()->register_autoloader(self::$_settings[ $addon_name ]['autoloader_paths']);
729
+            EEH_Autoloader::instance()->register_autoloader(self::$_settings[$addon_name]['autoloader_paths']);
730 730
         }
731 731
         // setup autoloaders for folders
732
-        if (! empty(self::$_settings[ $addon_name ]['autoloader_folders'])) {
733
-            foreach ((array) self::$_settings[ $addon_name ]['autoloader_folders'] as $autoloader_folder) {
732
+        if ( ! empty(self::$_settings[$addon_name]['autoloader_folders'])) {
733
+            foreach ((array) self::$_settings[$addon_name]['autoloader_folders'] as $autoloader_folder) {
734 734
                 EEH_Autoloader::register_autoloaders_for_each_file_in_folder($autoloader_folder);
735 735
             }
736 736
         }
@@ -748,27 +748,27 @@  discard block
 block discarded – undo
748 748
     {
749 749
         // register new models
750 750
         if (
751
-            ! empty(self::$_settings[ $addon_name ]['model_paths'])
752
-            || ! empty(self::$_settings[ $addon_name ]['class_paths'])
751
+            ! empty(self::$_settings[$addon_name]['model_paths'])
752
+            || ! empty(self::$_settings[$addon_name]['class_paths'])
753 753
         ) {
754 754
             EE_Register_Model::register(
755 755
                 $addon_name,
756 756
                 array(
757
-                    'model_paths' => self::$_settings[ $addon_name ]['model_paths'],
758
-                    'class_paths' => self::$_settings[ $addon_name ]['class_paths'],
757
+                    'model_paths' => self::$_settings[$addon_name]['model_paths'],
758
+                    'class_paths' => self::$_settings[$addon_name]['class_paths'],
759 759
                 )
760 760
             );
761 761
         }
762 762
         // register model extensions
763 763
         if (
764
-            ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
765
-            || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
764
+            ! empty(self::$_settings[$addon_name]['model_extension_paths'])
765
+            || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
766 766
         ) {
767 767
             EE_Register_Model_Extensions::register(
768 768
                 $addon_name,
769 769
                 array(
770
-                    'model_extension_paths' => self::$_settings[ $addon_name ]['model_extension_paths'],
771
-                    'class_extension_paths' => self::$_settings[ $addon_name ]['class_extension_paths'],
770
+                    'model_extension_paths' => self::$_settings[$addon_name]['model_extension_paths'],
771
+                    'class_extension_paths' => self::$_settings[$addon_name]['class_extension_paths'],
772 772
                 )
773 773
             );
774 774
         }
@@ -783,10 +783,10 @@  discard block
 block discarded – undo
783 783
     private static function _register_data_migration_scripts($addon_name)
784 784
     {
785 785
         // setup DMS
786
-        if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
786
+        if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
787 787
             EE_Register_Data_Migration_Scripts::register(
788 788
                 $addon_name,
789
-                array('dms_paths' => self::$_settings[ $addon_name ]['dms_paths'])
789
+                array('dms_paths' => self::$_settings[$addon_name]['dms_paths'])
790 790
             );
791 791
         }
792 792
     }
@@ -800,12 +800,12 @@  discard block
 block discarded – undo
800 800
     private static function _register_config($addon_name)
801 801
     {
802 802
         // if config_class is present let's register config.
803
-        if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
803
+        if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
804 804
             EE_Register_Config::register(
805
-                self::$_settings[ $addon_name ]['config_class'],
805
+                self::$_settings[$addon_name]['config_class'],
806 806
                 array(
807
-                    'config_section' => self::$_settings[ $addon_name ]['config_section'],
808
-                    'config_name'    => self::$_settings[ $addon_name ]['config_name'],
807
+                    'config_section' => self::$_settings[$addon_name]['config_section'],
808
+                    'config_name'    => self::$_settings[$addon_name]['config_name'],
809 809
                 )
810 810
             );
811 811
         }
@@ -819,10 +819,10 @@  discard block
 block discarded – undo
819 819
      */
820 820
     private static function _register_admin_pages($addon_name)
821 821
     {
822
-        if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
822
+        if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
823 823
             EE_Register_Admin_Page::register(
824 824
                 $addon_name,
825
-                array('page_path' => self::$_settings[ $addon_name ]['admin_path'])
825
+                array('page_path' => self::$_settings[$addon_name]['admin_path'])
826 826
             );
827 827
         }
828 828
     }
@@ -835,10 +835,10 @@  discard block
 block discarded – undo
835 835
      */
836 836
     private static function _register_modules($addon_name)
837 837
     {
838
-        if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
838
+        if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
839 839
             EE_Register_Module::register(
840 840
                 $addon_name,
841
-                array('module_paths' => self::$_settings[ $addon_name ]['module_paths'])
841
+                array('module_paths' => self::$_settings[$addon_name]['module_paths'])
842 842
             );
843 843
         }
844 844
     }
@@ -852,16 +852,16 @@  discard block
 block discarded – undo
852 852
     private static function _register_shortcodes($addon_name)
853 853
     {
854 854
         if (
855
-            ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
856
-            || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
855
+            ! empty(self::$_settings[$addon_name]['shortcode_paths'])
856
+            || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
857 857
         ) {
858 858
             EE_Register_Shortcode::register(
859 859
                 $addon_name,
860 860
                 array(
861
-                    'shortcode_paths' => isset(self::$_settings[ $addon_name ]['shortcode_paths'])
862
-                        ? self::$_settings[ $addon_name ]['shortcode_paths'] : array(),
863
-                    'shortcode_fqcns' => isset(self::$_settings[ $addon_name ]['shortcode_fqcns'])
864
-                        ? self::$_settings[ $addon_name ]['shortcode_fqcns'] : array(),
861
+                    'shortcode_paths' => isset(self::$_settings[$addon_name]['shortcode_paths'])
862
+                        ? self::$_settings[$addon_name]['shortcode_paths'] : array(),
863
+                    'shortcode_fqcns' => isset(self::$_settings[$addon_name]['shortcode_fqcns'])
864
+                        ? self::$_settings[$addon_name]['shortcode_fqcns'] : array(),
865 865
                 )
866 866
             );
867 867
         }
@@ -875,10 +875,10 @@  discard block
 block discarded – undo
875 875
      */
876 876
     private static function _register_widgets($addon_name)
877 877
     {
878
-        if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
878
+        if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
879 879
             EE_Register_Widget::register(
880 880
                 $addon_name,
881
-                array('widget_paths' => self::$_settings[ $addon_name ]['widget_paths'])
881
+                array('widget_paths' => self::$_settings[$addon_name]['widget_paths'])
882 882
             );
883 883
         }
884 884
     }
@@ -891,12 +891,12 @@  discard block
 block discarded – undo
891 891
      */
892 892
     private static function _register_capabilities($addon_name)
893 893
     {
894
-        if (! empty(self::$_settings[ $addon_name ]['capabilities'])) {
894
+        if ( ! empty(self::$_settings[$addon_name]['capabilities'])) {
895 895
             EE_Register_Capabilities::register(
896 896
                 $addon_name,
897 897
                 array(
898
-                    'capabilities'    => self::$_settings[ $addon_name ]['capabilities'],
899
-                    'capability_maps' => self::$_settings[ $addon_name ]['capability_maps'],
898
+                    'capabilities'    => self::$_settings[$addon_name]['capabilities'],
899
+                    'capability_maps' => self::$_settings[$addon_name]['capability_maps'],
900 900
                 )
901 901
             );
902 902
         }
@@ -909,7 +909,7 @@  discard block
 block discarded – undo
909 909
      */
910 910
     private static function _register_message_types($addon_name)
911 911
     {
912
-        if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
912
+        if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
913 913
             add_action(
914 914
                 'EE_Brewing_Regular___messages_caf',
915 915
                 array('EE_Register_Addon', 'register_message_types')
@@ -926,15 +926,15 @@  discard block
 block discarded – undo
926 926
     private static function _register_custom_post_types($addon_name)
927 927
     {
928 928
         if (
929
-            ! empty(self::$_settings[ $addon_name ]['custom_post_types'])
930
-            || ! empty(self::$_settings[ $addon_name ]['custom_taxonomies'])
929
+            ! empty(self::$_settings[$addon_name]['custom_post_types'])
930
+            || ! empty(self::$_settings[$addon_name]['custom_taxonomies'])
931 931
         ) {
932 932
             EE_Register_CPT::register(
933 933
                 $addon_name,
934 934
                 array(
935
-                    'cpts'          => self::$_settings[ $addon_name ]['custom_post_types'],
936
-                    'cts'           => self::$_settings[ $addon_name ]['custom_taxonomies'],
937
-                    'default_terms' => self::$_settings[ $addon_name ]['default_terms'],
935
+                    'cpts'          => self::$_settings[$addon_name]['custom_post_types'],
936
+                    'cts'           => self::$_settings[$addon_name]['custom_taxonomies'],
937
+                    'default_terms' => self::$_settings[$addon_name]['default_terms'],
938 938
                 )
939 939
             );
940 940
         }
@@ -952,10 +952,10 @@  discard block
 block discarded – undo
952 952
      */
953 953
     private static function _register_payment_methods($addon_name)
954 954
     {
955
-        if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
955
+        if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
956 956
             EE_Register_Payment_Method::register(
957 957
                 $addon_name,
958
-                array('payment_method_paths' => self::$_settings[ $addon_name ]['payment_method_paths'])
958
+                array('payment_method_paths' => self::$_settings[$addon_name]['payment_method_paths'])
959 959
             );
960 960
         }
961 961
     }
@@ -971,10 +971,10 @@  discard block
 block discarded – undo
971 971
      */
972 972
     private static function registerPrivacyPolicies($addon_name)
973 973
     {
974
-        if (! empty(self::$_settings[ $addon_name ]['privacy_policies'])) {
974
+        if ( ! empty(self::$_settings[$addon_name]['privacy_policies'])) {
975 975
             EE_Register_Privacy_Policy::register(
976 976
                 $addon_name,
977
-                self::$_settings[ $addon_name ]['privacy_policies']
977
+                self::$_settings[$addon_name]['privacy_policies']
978 978
             );
979 979
         }
980 980
     }
@@ -986,10 +986,10 @@  discard block
 block discarded – undo
986 986
      */
987 987
     private static function registerPersonalDataExporters($addon_name)
988 988
     {
989
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_exporters'])) {
989
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_exporters'])) {
990 990
             EE_Register_Personal_Data_Eraser::register(
991 991
                 $addon_name,
992
-                self::$_settings[ $addon_name ]['personal_data_exporters']
992
+                self::$_settings[$addon_name]['personal_data_exporters']
993 993
             );
994 994
         }
995 995
     }
@@ -1001,10 +1001,10 @@  discard block
 block discarded – undo
1001 1001
      */
1002 1002
     private static function registerPersonalDataErasers($addon_name)
1003 1003
     {
1004
-        if (! empty(self::$_settings[ $addon_name ]['personal_data_erasers'])) {
1004
+        if ( ! empty(self::$_settings[$addon_name]['personal_data_erasers'])) {
1005 1005
             EE_Register_Personal_Data_Eraser::register(
1006 1006
                 $addon_name,
1007
-                self::$_settings[ $addon_name ]['personal_data_erasers']
1007
+                self::$_settings[$addon_name]['personal_data_erasers']
1008 1008
             );
1009 1009
         }
1010 1010
     }
@@ -1022,10 +1022,10 @@  discard block
 block discarded – undo
1022 1022
     private static function _load_and_init_addon_class($addon_name)
1023 1023
     {
1024 1024
         $addon = LoaderFactory::getLoader()->getShared(
1025
-            self::$_settings[ $addon_name ]['class_name'],
1025
+            self::$_settings[$addon_name]['class_name'],
1026 1026
             array('EE_Registry::create(addon)' => true)
1027 1027
         );
1028
-        if (! $addon instanceof EE_Addon) {
1028
+        if ( ! $addon instanceof EE_Addon) {
1029 1029
             throw new DomainException(
1030 1030
                 sprintf(
1031 1031
                     esc_html__(
@@ -1044,28 +1044,28 @@  discard block
 block discarded – undo
1044 1044
         EE_Register_Addon::injectAddonDomain($addon_name, $addon);
1045 1045
 
1046 1046
         $addon->set_name($addon_name);
1047
-        $addon->set_plugin_slug(self::$_settings[ $addon_name ]['plugin_slug']);
1048
-        $addon->set_plugin_basename(self::$_settings[ $addon_name ]['plugin_basename']);
1049
-        $addon->set_main_plugin_file(self::$_settings[ $addon_name ]['main_file_path']);
1050
-        $addon->set_plugin_action_slug(self::$_settings[ $addon_name ]['plugin_action_slug']);
1051
-        $addon->set_plugins_page_row(self::$_settings[ $addon_name ]['plugins_page_row']);
1052
-        $addon->set_version(self::$_settings[ $addon_name ]['version']);
1053
-        $addon->set_min_core_version(self::_effective_version(self::$_settings[ $addon_name ]['min_core_version']));
1054
-        $addon->set_config_section(self::$_settings[ $addon_name ]['config_section']);
1055
-        $addon->set_config_class(self::$_settings[ $addon_name ]['config_class']);
1056
-        $addon->set_config_name(self::$_settings[ $addon_name ]['config_name']);
1047
+        $addon->set_plugin_slug(self::$_settings[$addon_name]['plugin_slug']);
1048
+        $addon->set_plugin_basename(self::$_settings[$addon_name]['plugin_basename']);
1049
+        $addon->set_main_plugin_file(self::$_settings[$addon_name]['main_file_path']);
1050
+        $addon->set_plugin_action_slug(self::$_settings[$addon_name]['plugin_action_slug']);
1051
+        $addon->set_plugins_page_row(self::$_settings[$addon_name]['plugins_page_row']);
1052
+        $addon->set_version(self::$_settings[$addon_name]['version']);
1053
+        $addon->set_min_core_version(self::_effective_version(self::$_settings[$addon_name]['min_core_version']));
1054
+        $addon->set_config_section(self::$_settings[$addon_name]['config_section']);
1055
+        $addon->set_config_class(self::$_settings[$addon_name]['config_class']);
1056
+        $addon->set_config_name(self::$_settings[$addon_name]['config_name']);
1057 1057
         // setup the add-on's pue_slug if we have one.
1058
-        if (! empty(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug'])) {
1059
-            $addon->setPueSlug(self::$_settings[ $addon_name ]['pue_options']['pue_plugin_slug']);
1058
+        if ( ! empty(self::$_settings[$addon_name]['pue_options']['pue_plugin_slug'])) {
1059
+            $addon->setPueSlug(self::$_settings[$addon_name]['pue_options']['pue_plugin_slug']);
1060 1060
         }
1061 1061
         // unfortunately this can't be hooked in upon construction,
1062 1062
         // because we don't have the plugin's mainfile path upon construction.
1063 1063
         register_deactivation_hook($addon->get_main_plugin_file(), array($addon, 'deactivation'));
1064 1064
         // call any additional admin_callback functions during load_admin_controller hook
1065
-        if (! empty(self::$_settings[ $addon_name ]['admin_callback'])) {
1065
+        if ( ! empty(self::$_settings[$addon_name]['admin_callback'])) {
1066 1066
             add_action(
1067 1067
                 'AHEE__EE_System__load_controllers__load_admin_controllers',
1068
-                array($addon, self::$_settings[ $addon_name ]['admin_callback'])
1068
+                array($addon, self::$_settings[$addon_name]['admin_callback'])
1069 1069
             );
1070 1070
         }
1071 1071
         return $addon;
@@ -1081,19 +1081,19 @@  discard block
 block discarded – undo
1081 1081
     {
1082 1082
         if ($addon instanceof RequiresDomainInterface && $addon->domain() === null) {
1083 1083
             // using supplied Domain object
1084
-            $domain = self::$_settings[ $addon_name ]['domain'] instanceof DomainInterface
1085
-                ? self::$_settings[ $addon_name ]['domain']
1084
+            $domain = self::$_settings[$addon_name]['domain'] instanceof DomainInterface
1085
+                ? self::$_settings[$addon_name]['domain']
1086 1086
                 : null;
1087 1087
             // or construct one using Domain FQCN
1088
-            if ($domain === null && self::$_settings[ $addon_name ]['domain_fqcn'] !== '') {
1088
+            if ($domain === null && self::$_settings[$addon_name]['domain_fqcn'] !== '') {
1089 1089
                 $domain = LoaderFactory::getLoader()->getShared(
1090
-                    self::$_settings[ $addon_name ]['domain_fqcn'],
1090
+                    self::$_settings[$addon_name]['domain_fqcn'],
1091 1091
                     [
1092 1092
                         new EventEspresso\core\domain\values\FilePath(
1093
-                            self::$_settings[ $addon_name ]['main_file_path']
1093
+                            self::$_settings[$addon_name]['main_file_path']
1094 1094
                         ),
1095 1095
                         EventEspresso\core\domain\values\Version::fromString(
1096
-                            self::$_settings[ $addon_name ]['version']
1096
+                            self::$_settings[$addon_name]['version']
1097 1097
                         ),
1098 1098
                     ]
1099 1099
                 );
@@ -1116,11 +1116,11 @@  discard block
 block discarded – undo
1116 1116
     public static function load_pue_update()
1117 1117
     {
1118 1118
         // load PUE client
1119
-        require_once EE_THIRD_PARTY . 'pue/pue-client.php';
1119
+        require_once EE_THIRD_PARTY.'pue/pue-client.php';
1120 1120
         $license_server = defined('PUE_UPDATES_ENDPOINT') ? PUE_UPDATES_ENDPOINT : 'https://eventespresso.com';
1121 1121
         // cycle thru settings
1122 1122
         foreach (self::$_settings as $settings) {
1123
-            if (! empty($settings['pue_options'])) {
1123
+            if ( ! empty($settings['pue_options'])) {
1124 1124
                 // initiate the class and start the plugin update engine!
1125 1125
                 new PluginUpdateEngineChecker(
1126 1126
                     // host file URL
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
                     // plugin slug(s)
1129 1129
                     array(
1130 1130
                         'premium'    => array('p' => $settings['pue_options']['pue_plugin_slug']),
1131
-                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'] . '-pr'),
1131
+                        'prerelease' => array('beta' => $settings['pue_options']['pue_plugin_slug'].'-pr'),
1132 1132
                     ),
1133 1133
                     // options
1134 1134
                     array(
@@ -1157,7 +1157,7 @@  discard block
 block discarded – undo
1157 1157
     public static function register_message_types()
1158 1158
     {
1159 1159
         foreach (self::$_settings as $settings) {
1160
-            if (! empty($settings['message_types'])) {
1160
+            if ( ! empty($settings['message_types'])) {
1161 1161
                 foreach ((array) $settings['message_types'] as $message_type => $message_type_settings) {
1162 1162
                     EE_Register_Message_Type::register($message_type, $message_type_settings);
1163 1163
                 }
@@ -1178,74 +1178,74 @@  discard block
 block discarded – undo
1178 1178
      */
1179 1179
     public static function deregister($addon_name = '')
1180 1180
     {
1181
-        if (isset(self::$_settings[ $addon_name ]['class_name'])) {
1181
+        if (isset(self::$_settings[$addon_name]['class_name'])) {
1182 1182
             try {
1183 1183
                 do_action('AHEE__EE_Register_Addon__deregister__before', $addon_name);
1184
-                $class_name = self::$_settings[ $addon_name ]['class_name'];
1185
-                if (! empty(self::$_settings[ $addon_name ]['dms_paths'])) {
1184
+                $class_name = self::$_settings[$addon_name]['class_name'];
1185
+                if ( ! empty(self::$_settings[$addon_name]['dms_paths'])) {
1186 1186
                     // setup DMS
1187 1187
                     EE_Register_Data_Migration_Scripts::deregister($addon_name);
1188 1188
                 }
1189
-                if (! empty(self::$_settings[ $addon_name ]['admin_path'])) {
1189
+                if ( ! empty(self::$_settings[$addon_name]['admin_path'])) {
1190 1190
                     // register admin page
1191 1191
                     EE_Register_Admin_Page::deregister($addon_name);
1192 1192
                 }
1193
-                if (! empty(self::$_settings[ $addon_name ]['module_paths'])) {
1193
+                if ( ! empty(self::$_settings[$addon_name]['module_paths'])) {
1194 1194
                     // add to list of modules to be registered
1195 1195
                     EE_Register_Module::deregister($addon_name);
1196 1196
                 }
1197 1197
                 if (
1198
-                    ! empty(self::$_settings[ $addon_name ]['shortcode_paths'])
1199
-                    || ! empty(self::$_settings[ $addon_name ]['shortcode_fqcns'])
1198
+                    ! empty(self::$_settings[$addon_name]['shortcode_paths'])
1199
+                    || ! empty(self::$_settings[$addon_name]['shortcode_fqcns'])
1200 1200
                 ) {
1201 1201
                     // add to list of shortcodes to be registered
1202 1202
                     EE_Register_Shortcode::deregister($addon_name);
1203 1203
                 }
1204
-                if (! empty(self::$_settings[ $addon_name ]['config_class'])) {
1204
+                if ( ! empty(self::$_settings[$addon_name]['config_class'])) {
1205 1205
                     // if config_class present let's register config.
1206
-                    EE_Register_Config::deregister(self::$_settings[ $addon_name ]['config_class']);
1206
+                    EE_Register_Config::deregister(self::$_settings[$addon_name]['config_class']);
1207 1207
                 }
1208
-                if (! empty(self::$_settings[ $addon_name ]['widget_paths'])) {
1208
+                if ( ! empty(self::$_settings[$addon_name]['widget_paths'])) {
1209 1209
                     // add to list of widgets to be registered
1210 1210
                     EE_Register_Widget::deregister($addon_name);
1211 1211
                 }
1212 1212
                 if (
1213
-                    ! empty(self::$_settings[ $addon_name ]['model_paths'])
1214
-                    || ! empty(self::$_settings[ $addon_name ]['class_paths'])
1213
+                    ! empty(self::$_settings[$addon_name]['model_paths'])
1214
+                    || ! empty(self::$_settings[$addon_name]['class_paths'])
1215 1215
                 ) {
1216 1216
                     // add to list of shortcodes to be registered
1217 1217
                     EE_Register_Model::deregister($addon_name);
1218 1218
                 }
1219 1219
                 if (
1220
-                    ! empty(self::$_settings[ $addon_name ]['model_extension_paths'])
1221
-                    || ! empty(self::$_settings[ $addon_name ]['class_extension_paths'])
1220
+                    ! empty(self::$_settings[$addon_name]['model_extension_paths'])
1221
+                    || ! empty(self::$_settings[$addon_name]['class_extension_paths'])
1222 1222
                 ) {
1223 1223
                     // add to list of shortcodes to be registered
1224 1224
                     EE_Register_Model_Extensions::deregister($addon_name);
1225 1225
                 }
1226
-                if (! empty(self::$_settings[ $addon_name ]['message_types'])) {
1227
-                    foreach ((array) self::$_settings[ $addon_name ]['message_types'] as $message_type => $message_type_settings) {
1226
+                if ( ! empty(self::$_settings[$addon_name]['message_types'])) {
1227
+                    foreach ((array) self::$_settings[$addon_name]['message_types'] as $message_type => $message_type_settings) {
1228 1228
                         EE_Register_Message_Type::deregister($message_type);
1229 1229
                     }
1230 1230
                 }
1231 1231
                 // deregister capabilities for addon
1232 1232
                 if (
1233
-                    ! empty(self::$_settings[ $addon_name ]['capabilities'])
1234
-                    || ! empty(self::$_settings[ $addon_name ]['capability_maps'])
1233
+                    ! empty(self::$_settings[$addon_name]['capabilities'])
1234
+                    || ! empty(self::$_settings[$addon_name]['capability_maps'])
1235 1235
                 ) {
1236 1236
                     EE_Register_Capabilities::deregister($addon_name);
1237 1237
                 }
1238 1238
                 // deregister custom_post_types for addon
1239
-                if (! empty(self::$_settings[ $addon_name ]['custom_post_types'])) {
1239
+                if ( ! empty(self::$_settings[$addon_name]['custom_post_types'])) {
1240 1240
                     EE_Register_CPT::deregister($addon_name);
1241 1241
                 }
1242
-                if (! empty(self::$_settings[ $addon_name ]['payment_method_paths'])) {
1242
+                if ( ! empty(self::$_settings[$addon_name]['payment_method_paths'])) {
1243 1243
                     EE_Register_Payment_Method::deregister($addon_name);
1244 1244
                 }
1245 1245
                 $addon = EE_Registry::instance()->getAddon($class_name);
1246 1246
                 if ($addon instanceof EE_Addon) {
1247 1247
                     remove_action(
1248
-                        'deactivate_' . $addon->get_main_plugin_file_basename(),
1248
+                        'deactivate_'.$addon->get_main_plugin_file_basename(),
1249 1249
                         array($addon, 'deactivation')
1250 1250
                     );
1251 1251
                     remove_action(
@@ -1269,7 +1269,7 @@  discard block
 block discarded – undo
1269 1269
             } catch (Exception $e) {
1270 1270
                 new ExceptionLogger($e);
1271 1271
             }
1272
-            unset(self::$_settings[ $addon_name ]);
1272
+            unset(self::$_settings[$addon_name]);
1273 1273
             do_action('AHEE__EE_Register_Addon__deregister__after', $addon_name);
1274 1274
         }
1275 1275
     }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_CPT.lib.php 2 patches
Indentation   +228 added lines, -228 removed lines patch added patch discarded remove patch
@@ -13,255 +13,255 @@
 block discarded – undo
13 13
 class EE_Register_CPT implements EEI_Plugin_API
14 14
 {
15 15
 
16
-    /**
17
-     * Holds values for registered variations
18
-     *
19
-     * @since 4.5.0
20
-     *
21
-     * @var array[][][]
22
-     */
23
-    protected static $_registry = [];
16
+	/**
17
+	 * Holds values for registered variations
18
+	 *
19
+	 * @since 4.5.0
20
+	 *
21
+	 * @var array[][][]
22
+	 */
23
+	protected static $_registry = [];
24 24
 
25 25
 
26
-    /**
27
-     * Used to register new CPTs and Taxonomies.
28
-     *
29
-     * @param string $identifier              reference used for the addon registering cpts and cts
30
-     * @param array  $setup_args              {
31
-     *                                        An array of required values for registering the cpts and taxonomies
32
-     * @type array   $cpts                    {
33
-     *                                        An array of cpts and their arguments.(short example below)
34
-     * @return void
35
-     * @throws  EE_Error
36
-     * @see CustomPostTypeDefinitions::setDefinitions for a more complete example.
37
-     *                                        'people' => array(
38
-     *                                        'singular_name' => esc_html__('People', 'event_espresso'),
39
-     *                                        'plural_name' => esc_html__('People', 'event_espresso'),
40
-     *                                        'singular_slug' => esc_html__('people', 'event_espresso'),
41
-     *                                        'plural_slug' => esc_html__('peoples', 'event_espresso'),
42
-     *                                        'class_name' => 'EE_People'
43
-     *                                        )
44
-     *                                        },
45
-     * @type array   $cts                     {
46
-     *                                        An array of custom taxonomies and their arguments (short example below).
47
-     * @see CustomTaxonomyDefinitions::setTaxonomies() for a more complete example.
48
-     *                                        'espresso_people_type' => array(
49
-     *                                        'singular_name' => esc_html__('People Type', 'event_espresso'),
50
-     *                                        'plural_name' => esc_html__('People Types', 'event_espresso'),
51
-     *                                        'args' => array()
52
-     *                                        )
53
-     *                                        },
54
-     * @type array   $default_terms           {
55
-     *                                        An array of terms to set as the default for a given taxonomy and the
56
-     *                                        custom post types applied to.
57
-     *                                        'taxonomy_name' => array(
58
-     *                                        'term' => array( 'cpt_a_name', 'cpt_b_name' )
59
-     *                                        )
60
-     *                                        }
61
-     *                                        }
62
-     */
63
-    public static function register($identifier = '', array $setup_args = [])
64
-    {
26
+	/**
27
+	 * Used to register new CPTs and Taxonomies.
28
+	 *
29
+	 * @param string $identifier              reference used for the addon registering cpts and cts
30
+	 * @param array  $setup_args              {
31
+	 *                                        An array of required values for registering the cpts and taxonomies
32
+	 * @type array   $cpts                    {
33
+	 *                                        An array of cpts and their arguments.(short example below)
34
+	 * @return void
35
+	 * @throws  EE_Error
36
+	 * @see CustomPostTypeDefinitions::setDefinitions for a more complete example.
37
+	 *                                        'people' => array(
38
+	 *                                        'singular_name' => esc_html__('People', 'event_espresso'),
39
+	 *                                        'plural_name' => esc_html__('People', 'event_espresso'),
40
+	 *                                        'singular_slug' => esc_html__('people', 'event_espresso'),
41
+	 *                                        'plural_slug' => esc_html__('peoples', 'event_espresso'),
42
+	 *                                        'class_name' => 'EE_People'
43
+	 *                                        )
44
+	 *                                        },
45
+	 * @type array   $cts                     {
46
+	 *                                        An array of custom taxonomies and their arguments (short example below).
47
+	 * @see CustomTaxonomyDefinitions::setTaxonomies() for a more complete example.
48
+	 *                                        'espresso_people_type' => array(
49
+	 *                                        'singular_name' => esc_html__('People Type', 'event_espresso'),
50
+	 *                                        'plural_name' => esc_html__('People Types', 'event_espresso'),
51
+	 *                                        'args' => array()
52
+	 *                                        )
53
+	 *                                        },
54
+	 * @type array   $default_terms           {
55
+	 *                                        An array of terms to set as the default for a given taxonomy and the
56
+	 *                                        custom post types applied to.
57
+	 *                                        'taxonomy_name' => array(
58
+	 *                                        'term' => array( 'cpt_a_name', 'cpt_b_name' )
59
+	 *                                        )
60
+	 *                                        }
61
+	 *                                        }
62
+	 */
63
+	public static function register($identifier = '', array $setup_args = [])
64
+	{
65 65
 
66
-        // check for required params
67
-        if (empty($identifier)) {
68
-            throw new EE_Error(
69
-                esc_html__(
70
-                    'In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered',
71
-                    'event_espresso'
72
-                )
73
-            );
74
-        }
66
+		// check for required params
67
+		if (empty($identifier)) {
68
+			throw new EE_Error(
69
+				esc_html__(
70
+					'In order to register custom post types and custom taxonomies, you must include a value to reference what had been registered',
71
+					'event_espresso'
72
+				)
73
+			);
74
+		}
75 75
 
76
-        if (! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) {
77
-            throw new EE_Error(
78
-                esc_html__(
79
-                    'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.',
80
-                    'event_espresso'
81
-                )
82
-            );
83
-        }
76
+		if (! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) {
77
+			throw new EE_Error(
78
+				esc_html__(
79
+					'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.',
80
+					'event_espresso'
81
+				)
82
+			);
83
+		}
84 84
 
85
-        // make sure we don't register twice
86
-        if (isset(self::$_registry[ $identifier ])) {
87
-            return;
88
-        }
85
+		// make sure we don't register twice
86
+		if (isset(self::$_registry[ $identifier ])) {
87
+			return;
88
+		}
89 89
 
90
-        // make sure cpt ref is unique.
91
-        if (isset(self::$_registry[ $identifier ])) {
92
-            $identifier = uniqid() . '_' . $identifier;
93
-        }
90
+		// make sure cpt ref is unique.
91
+		if (isset(self::$_registry[ $identifier ])) {
92
+			$identifier = uniqid() . '_' . $identifier;
93
+		}
94 94
 
95
-        // make sure this was called in the right place!
96
-        if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) {
97
-            EE_Error::doing_it_wrong(
98
-                __METHOD__,
99
-                sprintf(
100
-                    esc_html__(
101
-                        'EE_Register_CPT has been called and given a reference of "%s".  It may or may not work because it should be called on or before "AHEE__EE_System__load_CPTs_and_session__complete" action hook.',
102
-                        'event_espresso'
103
-                    ),
104
-                    $identifier
105
-                ),
106
-                '4.5.0'
107
-            );
108
-        }
109
-        // validate incoming args
110
-        $validated = [
111
-            'cpts'          => isset($setup_args['cpts'])
112
-                ? (array) $setup_args['cpts']
113
-                : [],
114
-            'cts'           => isset($setup_args['cts'])
115
-                ? (array) $setup_args['cts']
116
-                : [],
117
-            'default_terms' => isset($setup_args['default_terms'])
118
-                ? (array) $setup_args['default_terms']
119
-                : [],
120
-        ];
95
+		// make sure this was called in the right place!
96
+		if (did_action('AHEE__EE_System__load_CPTs_and_session__complete')) {
97
+			EE_Error::doing_it_wrong(
98
+				__METHOD__,
99
+				sprintf(
100
+					esc_html__(
101
+						'EE_Register_CPT has been called and given a reference of "%s".  It may or may not work because it should be called on or before "AHEE__EE_System__load_CPTs_and_session__complete" action hook.',
102
+						'event_espresso'
103
+					),
104
+					$identifier
105
+				),
106
+				'4.5.0'
107
+			);
108
+		}
109
+		// validate incoming args
110
+		$validated = [
111
+			'cpts'          => isset($setup_args['cpts'])
112
+				? (array) $setup_args['cpts']
113
+				: [],
114
+			'cts'           => isset($setup_args['cts'])
115
+				? (array) $setup_args['cts']
116
+				: [],
117
+			'default_terms' => isset($setup_args['default_terms'])
118
+				? (array) $setup_args['default_terms']
119
+				: [],
120
+		];
121 121
 
122
-        self::$_registry[ $identifier ] = $validated;
122
+		self::$_registry[ $identifier ] = $validated;
123 123
 
124
-        // hook into to cpt system
125
-        add_filter(
126
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
127
-            [__CLASS__, 'filterCustomPostTypeDefinitions'],
128
-            5
129
-        );
130
-        add_filter(
131
-            'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
132
-            [__CLASS__, 'filterCustomTaxonomyDefinitions'],
133
-            5
134
-        );
135
-        add_action(
136
-            'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end',
137
-            [__CLASS__, 'registerCustomTaxonomyTerm'],
138
-            5
139
-        );
140
-    }
124
+		// hook into to cpt system
125
+		add_filter(
126
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes',
127
+			[__CLASS__, 'filterCustomPostTypeDefinitions'],
128
+			5
129
+		);
130
+		add_filter(
131
+			'FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies',
132
+			[__CLASS__, 'filterCustomTaxonomyDefinitions'],
133
+			5
134
+		);
135
+		add_action(
136
+			'AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end',
137
+			[__CLASS__, 'registerCustomTaxonomyTerm'],
138
+			5
139
+		);
140
+	}
141 141
 
142 142
 
143
-    /**
144
-     * Callback for
145
-     * FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes
146
-     * that adds additional custom post types to be registered.
147
-     *
148
-     * @param array $custom_post_type_definitions array of cpts that are already set
149
-     * @return array new array of cpts and their registration information
150
-     */
151
-    public static function filterCustomPostTypeDefinitions(array $custom_post_type_definitions)
152
-    {
153
-        foreach (self::$_registry as $registries) {
154
-            foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
155
-                $custom_post_type_definitions[ $cpt_name ] = $cpt_settings;
156
-            }
157
-        }
158
-        return $custom_post_type_definitions;
159
-    }
143
+	/**
144
+	 * Callback for
145
+	 * FHEE__EventEspresso_core_domain_entities_custom_post_types_CustomPostTypeDefinitions__getCustomPostTypes
146
+	 * that adds additional custom post types to be registered.
147
+	 *
148
+	 * @param array $custom_post_type_definitions array of cpts that are already set
149
+	 * @return array new array of cpts and their registration information
150
+	 */
151
+	public static function filterCustomPostTypeDefinitions(array $custom_post_type_definitions)
152
+	{
153
+		foreach (self::$_registry as $registries) {
154
+			foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
155
+				$custom_post_type_definitions[ $cpt_name ] = $cpt_settings;
156
+			}
157
+		}
158
+		return $custom_post_type_definitions;
159
+	}
160 160
 
161 161
 
162
-    /**
163
-     * Callback for
164
-     * FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies
165
-     * that adds additional custom taxonomies to be registered.
166
-     *
167
-     * @param array $custom_taxonomy_definitions array of cts that are already set.
168
-     * @return array new array of cts and their registration information.
169
-     */
170
-    public static function filterCustomTaxonomyDefinitions(array $custom_taxonomy_definitions)
171
-    {
172
-        foreach (self::$_registry as $registries) {
173
-            foreach ($registries['cts'] as $ct_name => $ct_settings) {
174
-                $custom_taxonomy_definitions[ $ct_name ] = $ct_settings;
175
-            }
176
-        }
177
-        return $custom_taxonomy_definitions;
178
-    }
162
+	/**
163
+	 * Callback for
164
+	 * FHEE__EventEspresso_core_domain_entities_custom_post_types_TaxonomyDefinitions__getTaxonomies
165
+	 * that adds additional custom taxonomies to be registered.
166
+	 *
167
+	 * @param array $custom_taxonomy_definitions array of cts that are already set.
168
+	 * @return array new array of cts and their registration information.
169
+	 */
170
+	public static function filterCustomTaxonomyDefinitions(array $custom_taxonomy_definitions)
171
+	{
172
+		foreach (self::$_registry as $registries) {
173
+			foreach ($registries['cts'] as $ct_name => $ct_settings) {
174
+				$custom_taxonomy_definitions[ $ct_name ] = $ct_settings;
175
+			}
176
+		}
177
+		return $custom_taxonomy_definitions;
178
+	}
179 179
 
180 180
 
181
-    /**
182
-     * Callback for
183
-     * AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end
184
-     * which is used to set the default terms
185
-     *
186
-     * @param RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms
187
-     * @return void
188
-     */
189
-    public static function registerCustomTaxonomyTerm(RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms)
190
-    {
191
-        foreach (self::$_registry as $registries) {
192
-            foreach ($registries['default_terms'] as $taxonomy => $terms) {
193
-                foreach ($terms as $term => $cpts) {
194
-                    $register_custom_taxonomy_terms->registerCustomTaxonomyTerm(
195
-                        $taxonomy,
196
-                        $term,
197
-                        $cpts
198
-                    );
199
-                }
200
-            }
201
-        }
202
-    }
181
+	/**
182
+	 * Callback for
183
+	 * AHEE__EventEspresso_core_domain_services_custom_post_types_RegisterCustomTaxonomyTerms__construct_end
184
+	 * which is used to set the default terms
185
+	 *
186
+	 * @param RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms
187
+	 * @return void
188
+	 */
189
+	public static function registerCustomTaxonomyTerm(RegisterCustomTaxonomyTerms $register_custom_taxonomy_terms)
190
+	{
191
+		foreach (self::$_registry as $registries) {
192
+			foreach ($registries['default_terms'] as $taxonomy => $terms) {
193
+				foreach ($terms as $term => $cpts) {
194
+					$register_custom_taxonomy_terms->registerCustomTaxonomyTerm(
195
+						$taxonomy,
196
+						$term,
197
+						$cpts
198
+					);
199
+				}
200
+			}
201
+		}
202
+	}
203 203
 
204 204
 
205
-    /**
206
-     * @param array $cpts array of cpts that are already set
207
-     * @return array new array of cpts and their registration information
208
-     * @deprecated 4.9.62.p
209
-     */
210
-    public static function filter_cpts(array $cpts)
211
-    {
212
-        foreach (self::$_registry as $registries) {
213
-            foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
214
-                $cpts[ $cpt_name ] = $cpt_settings;
215
-            }
216
-        }
217
-        return $cpts;
218
-    }
205
+	/**
206
+	 * @param array $cpts array of cpts that are already set
207
+	 * @return array new array of cpts and their registration information
208
+	 * @deprecated 4.9.62.p
209
+	 */
210
+	public static function filter_cpts(array $cpts)
211
+	{
212
+		foreach (self::$_registry as $registries) {
213
+			foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
214
+				$cpts[ $cpt_name ] = $cpt_settings;
215
+			}
216
+		}
217
+		return $cpts;
218
+	}
219 219
 
220 220
 
221
-    /**
222
-     * @param array $cts array of cts that are already set.
223
-     * @return array new array of cts and their registration information.
224
-     * @deprecated 4.9.62.p
225
-     */
226
-    public static function filter_cts(array $cts)
227
-    {
228
-        foreach (self::$_registry as $registries) {
229
-            foreach ($registries['cts'] as $ct_name => $ct_settings) {
230
-                $cts[ $ct_name ] = $ct_settings;
231
-            }
232
-        }
233
-        return $cts;
234
-    }
221
+	/**
222
+	 * @param array $cts array of cts that are already set.
223
+	 * @return array new array of cts and their registration information.
224
+	 * @deprecated 4.9.62.p
225
+	 */
226
+	public static function filter_cts(array $cts)
227
+	{
228
+		foreach (self::$_registry as $registries) {
229
+			foreach ($registries['cts'] as $ct_name => $ct_settings) {
230
+				$cts[ $ct_name ] = $ct_settings;
231
+			}
232
+		}
233
+		return $cts;
234
+	}
235 235
 
236 236
 
237
-    /**
238
-     * @param EE_Register_CPTs $cpt_class
239
-     * @return void
240
-     * @deprecated 4.9.62.p
241
-     */
242
-    public static function default_terms(EE_Register_CPTs $cpt_class)
243
-    {
244
-        foreach (self::$_registry as $registries) {
245
-            foreach ($registries['default_terms'] as $taxonomy => $terms) {
246
-                foreach ($terms as $term => $cpts) {
247
-                    $cpt_class->set_default_term($taxonomy, $term, $cpts);
248
-                }
249
-            }
250
-        }
251
-    }
237
+	/**
238
+	 * @param EE_Register_CPTs $cpt_class
239
+	 * @return void
240
+	 * @deprecated 4.9.62.p
241
+	 */
242
+	public static function default_terms(EE_Register_CPTs $cpt_class)
243
+	{
244
+		foreach (self::$_registry as $registries) {
245
+			foreach ($registries['default_terms'] as $taxonomy => $terms) {
246
+				foreach ($terms as $term => $cpts) {
247
+					$cpt_class->set_default_term($taxonomy, $term, $cpts);
248
+				}
249
+			}
250
+		}
251
+	}
252 252
 
253 253
 
254
-    /**
255
-     * This deregisters whats been registered on this class (for the given slug).
256
-     *
257
-     * @param string $identifier The reference for the item registered to be removed.
258
-     *
259
-     * @return void
260
-     * @since 4.5.0
261
-     *
262
-     */
263
-    public static function deregister($identifier = '')
264
-    {
265
-        unset(self::$_registry[ $identifier ]);
266
-    }
254
+	/**
255
+	 * This deregisters whats been registered on this class (for the given slug).
256
+	 *
257
+	 * @param string $identifier The reference for the item registered to be removed.
258
+	 *
259
+	 * @return void
260
+	 * @since 4.5.0
261
+	 *
262
+	 */
263
+	public static function deregister($identifier = '')
264
+	{
265
+		unset(self::$_registry[ $identifier ]);
266
+	}
267 267
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
             );
74 74
         }
75 75
 
76
-        if (! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) {
76
+        if ( ! is_array($setup_args) || (empty($setup_args['cpts']) && empty($setup_args['cts']))) {
77 77
             throw new EE_Error(
78 78
                 esc_html__(
79 79
                     'In order to register custom post types or custom taxonomies, you must include an array containing either an array of custom post types to register (key "cpts"), an array of custom taxonomies ("cts") or both.',
@@ -83,13 +83,13 @@  discard block
 block discarded – undo
83 83
         }
84 84
 
85 85
         // make sure we don't register twice
86
-        if (isset(self::$_registry[ $identifier ])) {
86
+        if (isset(self::$_registry[$identifier])) {
87 87
             return;
88 88
         }
89 89
 
90 90
         // make sure cpt ref is unique.
91
-        if (isset(self::$_registry[ $identifier ])) {
92
-            $identifier = uniqid() . '_' . $identifier;
91
+        if (isset(self::$_registry[$identifier])) {
92
+            $identifier = uniqid().'_'.$identifier;
93 93
         }
94 94
 
95 95
         // make sure this was called in the right place!
@@ -119,7 +119,7 @@  discard block
 block discarded – undo
119 119
                 : [],
120 120
         ];
121 121
 
122
-        self::$_registry[ $identifier ] = $validated;
122
+        self::$_registry[$identifier] = $validated;
123 123
 
124 124
         // hook into to cpt system
125 125
         add_filter(
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
     {
153 153
         foreach (self::$_registry as $registries) {
154 154
             foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
155
-                $custom_post_type_definitions[ $cpt_name ] = $cpt_settings;
155
+                $custom_post_type_definitions[$cpt_name] = $cpt_settings;
156 156
             }
157 157
         }
158 158
         return $custom_post_type_definitions;
@@ -171,7 +171,7 @@  discard block
 block discarded – undo
171 171
     {
172 172
         foreach (self::$_registry as $registries) {
173 173
             foreach ($registries['cts'] as $ct_name => $ct_settings) {
174
-                $custom_taxonomy_definitions[ $ct_name ] = $ct_settings;
174
+                $custom_taxonomy_definitions[$ct_name] = $ct_settings;
175 175
             }
176 176
         }
177 177
         return $custom_taxonomy_definitions;
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
     {
212 212
         foreach (self::$_registry as $registries) {
213 213
             foreach ($registries['cpts'] as $cpt_name => $cpt_settings) {
214
-                $cpts[ $cpt_name ] = $cpt_settings;
214
+                $cpts[$cpt_name] = $cpt_settings;
215 215
             }
216 216
         }
217 217
         return $cpts;
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
     {
228 228
         foreach (self::$_registry as $registries) {
229 229
             foreach ($registries['cts'] as $ct_name => $ct_settings) {
230
-                $cts[ $ct_name ] = $ct_settings;
230
+                $cts[$ct_name] = $ct_settings;
231 231
             }
232 232
         }
233 233
         return $cts;
@@ -262,6 +262,6 @@  discard block
 block discarded – undo
262 262
      */
263 263
     public static function deregister($identifier = '')
264 264
     {
265
-        unset(self::$_registry[ $identifier ]);
265
+        unset(self::$_registry[$identifier]);
266 266
     }
267 267
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Admin_Page.lib.php 2 patches
Indentation   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -12,139 +12,139 @@
 block discarded – undo
12 12
 {
13 13
 
14 14
 
15
-    /**
16
-     * Holds registered EE_Admin_Pages
17
-     *
18
-     * @var array
19
-     */
20
-    protected static $_ee_admin_page_registry = [];
21
-
22
-
23
-    /**
24
-     * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE
25
-     * Admin Page loader system).
26
-     *
27
-     * @param string $identifier                                      This string represents the basename of the Admin
28
-     *                                                                Page init. The init file must use this basename
29
-     *                                                                in its name and class (i.e.
30
-     *                                                                {page_basename}_Admin_Page_Init.core.php).
31
-     * @param array  $setup_args                                      {              An array of configuration options
32
-     *                                                                that will be used in different circumstances
33
-     *
34
-     * @type  string $page_path                                       This is the path where the registered admin pages
35
-     *        reside ( used to setup autoloaders).
36
-     *
37
-     *    }
38
-     * @return void
39
-     * @throws EE_Error
40
-     * @since 4.3.0
41
-     *
42
-     */
43
-    public static function register($identifier = '', array $setup_args = [])
44
-    {
45
-
46
-        // check that an admin_page has not already been registered with that name
47
-        if (isset(self::$_ee_admin_page_registry[ $identifier ])) {
48
-            throw new EE_Error(
49
-                sprintf(
50
-                    esc_html__(
51
-                        'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.',
52
-                        'event_espresso'
53
-                    ),
54
-                    $identifier
55
-                )
56
-            );
57
-        }
58
-
59
-        // required fields MUST be present, so let's make sure they are.
60
-        if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['page_path'])) {
61
-            throw new EE_Error(
62
-                esc_html__(
63
-                    'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)',
64
-                    'event_espresso'
65
-                )
66
-            );
67
-        }
68
-
69
-        // make sure we don't register twice
70
-        if (isset(self::$_ee_admin_page_registry[ $identifier ])) {
71
-            return;
72
-        }
73
-
74
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
75
-            EE_Error::doing_it_wrong(
76
-                __METHOD__,
77
-                sprintf(
78
-                    esc_html__(
79
-                        'An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.',
80
-                        'event_espresso'
81
-                    ),
82
-                    $identifier
83
-                ),
84
-                '4.3'
85
-            );
86
-        }
87
-
88
-        // add incoming stuff to our registry property
89
-        self::$_ee_admin_page_registry[ $identifier ] = [
90
-            'page_path' => $setup_args['page_path'],
91
-            'config'    => $setup_args,
92
-        ];
93
-
94
-        // add filters
95
-
96
-        add_filter(
97
-            'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
98
-            ['EE_Register_Admin_Page', 'set_page_basename'],
99
-            10
100
-        );
101
-        add_filter('FHEE__EEH_Autoloader__load_admin_core', ['EE_Register_Admin_Page', 'set_page_path'], 10);
102
-    }
103
-
104
-
105
-    /**
106
-     * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
107
-     * page being deregistered is loaded.
108
-     *
109
-     * @param string $identifier Use whatever string was used to register the admin page.
110
-     * @return  void
111
-     * @since    4.3.0
112
-     *
113
-     */
114
-    public static function deregister($identifier = '')
115
-    {
116
-        unset(self::$_ee_admin_page_registry[ $identifier ]);
117
-    }
118
-
119
-
120
-    /**
121
-     * set_page_basename
122
-     *
123
-     * @param $installed_refs
124
-     * @return mixed
125
-     */
126
-    public static function set_page_basename($installed_refs)
127
-    {
128
-        if (! empty(self::$_ee_admin_page_registry)) {
129
-            foreach (self::$_ee_admin_page_registry as $basename => $args) {
130
-                $installed_refs[ $basename ] = $args['page_path'];
131
-            }
132
-        }
133
-        return $installed_refs;
134
-    }
135
-
136
-
137
-    /**
138
-     * set_page_path
139
-     *
140
-     * @param $paths
141
-     * @return mixed
142
-     */
143
-    public static function set_page_path($paths)
144
-    {
145
-        foreach (self::$_ee_admin_page_registry as $basename => $args) {
146
-            $paths[ $basename ] = $args['page_path'];
147
-        }
148
-        return $paths;
149
-    }
15
+	/**
16
+	 * Holds registered EE_Admin_Pages
17
+	 *
18
+	 * @var array
19
+	 */
20
+	protected static $_ee_admin_page_registry = [];
21
+
22
+
23
+	/**
24
+	 * The purpose of this method is to provide an easy way for addons to register their admin pages (using the EE
25
+	 * Admin Page loader system).
26
+	 *
27
+	 * @param string $identifier                                      This string represents the basename of the Admin
28
+	 *                                                                Page init. The init file must use this basename
29
+	 *                                                                in its name and class (i.e.
30
+	 *                                                                {page_basename}_Admin_Page_Init.core.php).
31
+	 * @param array  $setup_args                                      {              An array of configuration options
32
+	 *                                                                that will be used in different circumstances
33
+	 *
34
+	 * @type  string $page_path                                       This is the path where the registered admin pages
35
+	 *        reside ( used to setup autoloaders).
36
+	 *
37
+	 *    }
38
+	 * @return void
39
+	 * @throws EE_Error
40
+	 * @since 4.3.0
41
+	 *
42
+	 */
43
+	public static function register($identifier = '', array $setup_args = [])
44
+	{
45
+
46
+		// check that an admin_page has not already been registered with that name
47
+		if (isset(self::$_ee_admin_page_registry[ $identifier ])) {
48
+			throw new EE_Error(
49
+				sprintf(
50
+					esc_html__(
51
+						'An Admin Page with the name "%s" has already been registered and each Admin Page requires a unique name.',
52
+						'event_espresso'
53
+					),
54
+					$identifier
55
+				)
56
+			);
57
+		}
58
+
59
+		// required fields MUST be present, so let's make sure they are.
60
+		if (empty($identifier) || ! is_array($setup_args) || empty($setup_args['page_path'])) {
61
+			throw new EE_Error(
62
+				esc_html__(
63
+					'In order to register an Admin Page with EE_Register_Admin_Page::register(), you must include the "page_basename" (the class name of the page), and an array containing the following keys: "page_path" (the path where the registered admin pages reside)',
64
+					'event_espresso'
65
+				)
66
+			);
67
+		}
68
+
69
+		// make sure we don't register twice
70
+		if (isset(self::$_ee_admin_page_registry[ $identifier ])) {
71
+			return;
72
+		}
73
+
74
+		if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
75
+			EE_Error::doing_it_wrong(
76
+				__METHOD__,
77
+				sprintf(
78
+					esc_html__(
79
+						'An attempt was made to register "%s" as an EE Admin page has failed because it was not registered at the correct time.  Please use the "AHEE__EE_Admin__loaded" hook to register Admin pages.',
80
+						'event_espresso'
81
+					),
82
+					$identifier
83
+				),
84
+				'4.3'
85
+			);
86
+		}
87
+
88
+		// add incoming stuff to our registry property
89
+		self::$_ee_admin_page_registry[ $identifier ] = [
90
+			'page_path' => $setup_args['page_path'],
91
+			'config'    => $setup_args,
92
+		];
93
+
94
+		// add filters
95
+
96
+		add_filter(
97
+			'FHEE__EE_Admin_Page_Loader___get_installed_pages__installed_refs',
98
+			['EE_Register_Admin_Page', 'set_page_basename'],
99
+			10
100
+		);
101
+		add_filter('FHEE__EEH_Autoloader__load_admin_core', ['EE_Register_Admin_Page', 'set_page_path'], 10);
102
+	}
103
+
104
+
105
+	/**
106
+	 * This deregisters a EE_Admin page that is already registered.  Note, this MUST be loaded after the
107
+	 * page being deregistered is loaded.
108
+	 *
109
+	 * @param string $identifier Use whatever string was used to register the admin page.
110
+	 * @return  void
111
+	 * @since    4.3.0
112
+	 *
113
+	 */
114
+	public static function deregister($identifier = '')
115
+	{
116
+		unset(self::$_ee_admin_page_registry[ $identifier ]);
117
+	}
118
+
119
+
120
+	/**
121
+	 * set_page_basename
122
+	 *
123
+	 * @param $installed_refs
124
+	 * @return mixed
125
+	 */
126
+	public static function set_page_basename($installed_refs)
127
+	{
128
+		if (! empty(self::$_ee_admin_page_registry)) {
129
+			foreach (self::$_ee_admin_page_registry as $basename => $args) {
130
+				$installed_refs[ $basename ] = $args['page_path'];
131
+			}
132
+		}
133
+		return $installed_refs;
134
+	}
135
+
136
+
137
+	/**
138
+	 * set_page_path
139
+	 *
140
+	 * @param $paths
141
+	 * @return mixed
142
+	 */
143
+	public static function set_page_path($paths)
144
+	{
145
+		foreach (self::$_ee_admin_page_registry as $basename => $args) {
146
+			$paths[ $basename ] = $args['page_path'];
147
+		}
148
+		return $paths;
149
+	}
150 150
 }
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     {
45 45
 
46 46
         // check that an admin_page has not already been registered with that name
47
-        if (isset(self::$_ee_admin_page_registry[ $identifier ])) {
47
+        if (isset(self::$_ee_admin_page_registry[$identifier])) {
48 48
             throw new EE_Error(
49 49
                 sprintf(
50 50
                     esc_html__(
@@ -67,11 +67,11 @@  discard block
 block discarded – undo
67 67
         }
68 68
 
69 69
         // make sure we don't register twice
70
-        if (isset(self::$_ee_admin_page_registry[ $identifier ])) {
70
+        if (isset(self::$_ee_admin_page_registry[$identifier])) {
71 71
             return;
72 72
         }
73 73
 
74
-        if (! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
74
+        if ( ! did_action('AHEE__EE_System__load_espresso_addons') || did_action('AHEE__EE_Admin__loaded')) {
75 75
             EE_Error::doing_it_wrong(
76 76
                 __METHOD__,
77 77
                 sprintf(
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
         }
87 87
 
88 88
         // add incoming stuff to our registry property
89
-        self::$_ee_admin_page_registry[ $identifier ] = [
89
+        self::$_ee_admin_page_registry[$identifier] = [
90 90
             'page_path' => $setup_args['page_path'],
91 91
             'config'    => $setup_args,
92 92
         ];
@@ -113,7 +113,7 @@  discard block
 block discarded – undo
113 113
      */
114 114
     public static function deregister($identifier = '')
115 115
     {
116
-        unset(self::$_ee_admin_page_registry[ $identifier ]);
116
+        unset(self::$_ee_admin_page_registry[$identifier]);
117 117
     }
118 118
 
119 119
 
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
      */
126 126
     public static function set_page_basename($installed_refs)
127 127
     {
128
-        if (! empty(self::$_ee_admin_page_registry)) {
128
+        if ( ! empty(self::$_ee_admin_page_registry)) {
129 129
             foreach (self::$_ee_admin_page_registry as $basename => $args) {
130
-                $installed_refs[ $basename ] = $args['page_path'];
130
+                $installed_refs[$basename] = $args['page_path'];
131 131
             }
132 132
         }
133 133
         return $installed_refs;
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     public static function set_page_path($paths)
144 144
     {
145 145
         foreach (self::$_ee_admin_page_registry as $basename => $args) {
146
-            $paths[ $basename ] = $args['page_path'];
146
+            $paths[$basename] = $args['page_path'];
147 147
         }
148 148
         return $paths;
149 149
     }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Event_Meta_Shortcodes.lib.php 1 patch
Indentation   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -32,42 +32,42 @@
 block discarded – undo
32 32
 {
33 33
 
34 34
 
35
-    public function __construct()
36
-    {
37
-        parent::__construct();
38
-    }
35
+	public function __construct()
36
+	{
37
+		parent::__construct();
38
+	}
39 39
 
40 40
 
41
-    protected function _init_props()
42
-    {
43
-        $this->label = esc_html__('Event Meta Shortcodes', 'event_espresso');
44
-        $this->description = esc_html__('All shortcodes related to Event Meta data', 'event_espresso');
45
-        $this->_shortcodes = array();
46
-    }
41
+	protected function _init_props()
42
+	{
43
+		$this->label = esc_html__('Event Meta Shortcodes', 'event_espresso');
44
+		$this->description = esc_html__('All shortcodes related to Event Meta data', 'event_espresso');
45
+		$this->_shortcodes = array();
46
+	}
47 47
 
48 48
 
49
-    /**
50
-     * We have to overload the parent parser method because of the dynamic nature of custom event meta
51
-     *
52
-     * @param  string $shortcode Incoming shortcode
53
-     * @param  mixed (array|object) $data      incoming data object/array
54
-     * @return string            parsed code.
55
-     */
56
-    public function parser($shortcode, $data, $extra_data = array())
57
-    {
49
+	/**
50
+	 * We have to overload the parent parser method because of the dynamic nature of custom event meta
51
+	 *
52
+	 * @param  string $shortcode Incoming shortcode
53
+	 * @param  mixed (array|object) $data      incoming data object/array
54
+	 * @return string            parsed code.
55
+	 */
56
+	public function parser($shortcode, $data, $extra_data = array())
57
+	{
58 58
 
59
-        // all shortcodes will be checked in the post_meta table (assuming the shortcode matches the post_meta key);
60
-        if (empty($this->_data['ID'])) {
61
-            return '';
62
-        } // need the event id to do anything!
59
+		// all shortcodes will be checked in the post_meta table (assuming the shortcode matches the post_meta key);
60
+		if (empty($this->_data['ID'])) {
61
+			return '';
62
+		} // need the event id to do anything!
63 63
 
64
-        $meta = get_post_meta($this->_data['ID'], $shortcode, true);
64
+		$meta = get_post_meta($this->_data['ID'], $shortcode, true);
65 65
 
66
-        return ! empty($meta) ? $meta : '';
67
-    }
66
+		return ! empty($meta) ? $meta : '';
67
+	}
68 68
 
69 69
 
70
-    protected function _parser($shortcode)
71
-    {
72
-    }
70
+	protected function _parser($shortcode)
71
+	{
72
+	}
73 73
 }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Ticket_Shortcodes.lib.php 2 patches
Indentation   +119 added lines, -119 removed lines patch added patch discarded remove patch
@@ -19,123 +19,123 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * Will hold the EE_Ticket if available
24
-     *
25
-     * @var EE_Ticket
26
-     */
27
-    protected $_ticket;
28
-
29
-
30
-    protected function _init_props()
31
-    {
32
-        $this->label = esc_html__('Ticket Shortcodes', 'event_espresso');
33
-        $this->description = esc_html__('All shortcodes specific to ticket related data', 'event_espresso');
34
-        $this->_shortcodes = array(
35
-            '[TICKET_ID]'               => esc_html__('Will be replaced by the ticket ID of a ticket', 'event_espresso'),
36
-            '[TICKET_NAME]'             => esc_html__('The name of the ticket', 'event_espresso'),
37
-            '[TICKET_DESCRIPTION]'      => esc_html__('The description of the ticket', 'event_espresso'),
38
-            '[TICKET_PRICE]'            => esc_html__('The price of the ticket', 'event_espresso'),
39
-            '[TICKET_PRICE_WITH_TAXES]' => esc_html__(
40
-                'The price of the ticket including any taxes that might be on the ticket',
41
-                'event_espresso'
42
-            ),
43
-            '[TKT_QTY_PURCHASED]'       => esc_html__(
44
-                'The total quantity of the current ticket in the list that has been purchased in this transaction',
45
-                'event_espresso'
46
-            ),
47
-            '[TKT_USES_*]'              => esc_html__(
48
-                'This attribute based shortcode parses to show the number of uses the ticket has.  The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite.  Options are:',
49
-                'event_espresso'
50
-            ) .
51
-                                           '<p><ul>' .
52
-                                           '<li><strong>symbol</strong>:' . esc_html__(
53
-                                               'This returns the &infin; symbol.',
54
-                                               'event_espresso'
55
-                                           ) . '</li>' .
56
-                                           '<li><strong>text</strong>:' . esc_html__(
57
-                                               'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.',
58
-                                               'event_espresso'
59
-                                           ) . '</li>' .
60
-                                           '<li><strong>{custom}</strong>:' . esc_html__(
61
-                                               'You can put anything you want as a string instead and that will be used.  So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".',
62
-                                               'event_espresso'
63
-                                           ) . '</li>' .
64
-                                           '</ul></p>',
65
-        );
66
-    }
67
-
68
-
69
-    protected function _parser($shortcode)
70
-    {
71
-
72
-        $this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null;
73
-
74
-        $aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
75
-        $aee = ! $aee instanceof EE_Messages_Addressee && is_array(
76
-            $this->_extra_data
77
-        ) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
78
-            ? $this->_extra_data['data'] : $aee;
79
-
80
-
81
-        // possible EE_Line_Item may be incoming data
82
-        $this->_ticket = empty($this->_ticket)
83
-                         && $this->_data instanceof EE_Line_Item
84
-                         && $aee instanceof EE_Messages_Addressee
85
-                         && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'])
86
-                         && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket
87
-            ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']
88
-            : $this->_ticket;
89
-
90
-        // if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
91
-        if (empty($this->_ticket)) {
92
-            $this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
93
-                ? $aee->reg_obj->ticket() : null;
94
-        }
95
-
96
-
97
-        // If there is no event object by now then get out.
98
-        if (! $this->_ticket instanceof EE_Ticket) {
99
-            return '';
100
-        }
101
-
102
-        switch ($shortcode) {
103
-            case '[TICKET_ID]':
104
-                return $this->_ticket->ID();
105
-                break;
106
-
107
-            case '[TICKET_NAME]':
108
-                return $this->_ticket->get('TKT_name');
109
-                break;
110
-
111
-            case '[TICKET_DESCRIPTION]':
112
-                return $this->_ticket->get('TKT_description');
113
-                break;
114
-
115
-            case '[TICKET_PRICE]':
116
-                return EEH_Template::format_currency($this->_ticket->get('TKT_price'));
117
-                break;
118
-
119
-            case '[TICKET_PRICE_WITH_TAXES]':
120
-                return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes());
121
-                break;
122
-
123
-            case '[TKT_QTY_PURCHASED]':
124
-                return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : '';
125
-                break;
126
-        }
127
-
128
-        if (strpos($shortcode, '[TKT_USES_*') !== false) {
129
-            $attrs = $this->_get_shortcode_attrs($shortcode);
130
-            $schema = empty($attrs['schema']) ? null : $attrs['schema'];
131
-            return $this->_ticket->get_pretty('TKT_uses', $schema);
132
-        }
133
-        return '';
134
-    }
135
-
136
-
137
-    public function get_ticket_set()
138
-    {
139
-        return $this->_ticket;
140
-    }
22
+	/**
23
+	 * Will hold the EE_Ticket if available
24
+	 *
25
+	 * @var EE_Ticket
26
+	 */
27
+	protected $_ticket;
28
+
29
+
30
+	protected function _init_props()
31
+	{
32
+		$this->label = esc_html__('Ticket Shortcodes', 'event_espresso');
33
+		$this->description = esc_html__('All shortcodes specific to ticket related data', 'event_espresso');
34
+		$this->_shortcodes = array(
35
+			'[TICKET_ID]'               => esc_html__('Will be replaced by the ticket ID of a ticket', 'event_espresso'),
36
+			'[TICKET_NAME]'             => esc_html__('The name of the ticket', 'event_espresso'),
37
+			'[TICKET_DESCRIPTION]'      => esc_html__('The description of the ticket', 'event_espresso'),
38
+			'[TICKET_PRICE]'            => esc_html__('The price of the ticket', 'event_espresso'),
39
+			'[TICKET_PRICE_WITH_TAXES]' => esc_html__(
40
+				'The price of the ticket including any taxes that might be on the ticket',
41
+				'event_espresso'
42
+			),
43
+			'[TKT_QTY_PURCHASED]'       => esc_html__(
44
+				'The total quantity of the current ticket in the list that has been purchased in this transaction',
45
+				'event_espresso'
46
+			),
47
+			'[TKT_USES_*]'              => esc_html__(
48
+				'This attribute based shortcode parses to show the number of uses the ticket has.  The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite.  Options are:',
49
+				'event_espresso'
50
+			) .
51
+										   '<p><ul>' .
52
+										   '<li><strong>symbol</strong>:' . esc_html__(
53
+											   'This returns the &infin; symbol.',
54
+											   'event_espresso'
55
+										   ) . '</li>' .
56
+										   '<li><strong>text</strong>:' . esc_html__(
57
+											   'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.',
58
+											   'event_espresso'
59
+										   ) . '</li>' .
60
+										   '<li><strong>{custom}</strong>:' . esc_html__(
61
+											   'You can put anything you want as a string instead and that will be used.  So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".',
62
+											   'event_espresso'
63
+										   ) . '</li>' .
64
+										   '</ul></p>',
65
+		);
66
+	}
67
+
68
+
69
+	protected function _parser($shortcode)
70
+	{
71
+
72
+		$this->_ticket = $this->_data instanceof EE_Ticket ? $this->_data : null;
73
+
74
+		$aee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
75
+		$aee = ! $aee instanceof EE_Messages_Addressee && is_array(
76
+			$this->_extra_data
77
+		) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
78
+			? $this->_extra_data['data'] : $aee;
79
+
80
+
81
+		// possible EE_Line_Item may be incoming data
82
+		$this->_ticket = empty($this->_ticket)
83
+						 && $this->_data instanceof EE_Line_Item
84
+						 && $aee instanceof EE_Messages_Addressee
85
+						 && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'])
86
+						 && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket
87
+			? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']
88
+			: $this->_ticket;
89
+
90
+		// if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
91
+		if (empty($this->_ticket)) {
92
+			$this->_ticket = $aee instanceof EE_Messages_Addressee && $aee->reg_obj instanceof EE_Registration
93
+				? $aee->reg_obj->ticket() : null;
94
+		}
95
+
96
+
97
+		// If there is no event object by now then get out.
98
+		if (! $this->_ticket instanceof EE_Ticket) {
99
+			return '';
100
+		}
101
+
102
+		switch ($shortcode) {
103
+			case '[TICKET_ID]':
104
+				return $this->_ticket->ID();
105
+				break;
106
+
107
+			case '[TICKET_NAME]':
108
+				return $this->_ticket->get('TKT_name');
109
+				break;
110
+
111
+			case '[TICKET_DESCRIPTION]':
112
+				return $this->_ticket->get('TKT_description');
113
+				break;
114
+
115
+			case '[TICKET_PRICE]':
116
+				return EEH_Template::format_currency($this->_ticket->get('TKT_price'));
117
+				break;
118
+
119
+			case '[TICKET_PRICE_WITH_TAXES]':
120
+				return EEH_Template::format_currency($this->_ticket->get_ticket_total_with_taxes());
121
+				break;
122
+
123
+			case '[TKT_QTY_PURCHASED]':
124
+				return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : '';
125
+				break;
126
+		}
127
+
128
+		if (strpos($shortcode, '[TKT_USES_*') !== false) {
129
+			$attrs = $this->_get_shortcode_attrs($shortcode);
130
+			$schema = empty($attrs['schema']) ? null : $attrs['schema'];
131
+			return $this->_ticket->get_pretty('TKT_uses', $schema);
132
+		}
133
+		return '';
134
+	}
135
+
136
+
137
+	public function get_ticket_set()
138
+	{
139
+		return $this->_ticket;
140
+	}
141 141
 }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -47,20 +47,20 @@  discard block
 block discarded – undo
47 47
             '[TKT_USES_*]'              => esc_html__(
48 48
                 'This attribute based shortcode parses to show the number of uses the ticket has.  The optional "schema" attribute can be used to indicate what schema is used when the uses is infinite.  Options are:',
49 49
                 'event_espresso'
50
-            ) .
51
-                                           '<p><ul>' .
52
-                                           '<li><strong>symbol</strong>:' . esc_html__(
50
+            ).
51
+                                           '<p><ul>'.
52
+                                           '<li><strong>symbol</strong>:'.esc_html__(
53 53
                                                'This returns the &infin; symbol.',
54 54
                                                'event_espresso'
55
-                                           ) . '</li>' .
56
-                                           '<li><strong>text</strong>:' . esc_html__(
55
+                                           ).'</li>'.
56
+                                           '<li><strong>text</strong>:'.esc_html__(
57 57
                                                'This returns the word, "Unlimited". This is also the default if the "schema" attribute is not used.',
58 58
                                                'event_espresso'
59
-                                           ) . '</li>' .
60
-                                           '<li><strong>{custom}</strong>:' . esc_html__(
59
+                                           ).'</li>'.
60
+                                           '<li><strong>{custom}</strong>:'.esc_html__(
61 61
                                                'You can put anything you want as a string instead and that will be used.  So you could have the world "any" and whenever uses for a ticket is infinity, this shortcode will parse to "any".',
62 62
                                                'event_espresso'
63
-                                           ) . '</li>' .
63
+                                           ).'</li>'.
64 64
                                            '</ul></p>',
65 65
         );
66 66
     }
@@ -82,9 +82,9 @@  discard block
 block discarded – undo
82 82
         $this->_ticket = empty($this->_ticket)
83 83
                          && $this->_data instanceof EE_Line_Item
84 84
                          && $aee instanceof EE_Messages_Addressee
85
-                         && ! empty($aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'])
86
-                         && $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket'] instanceof EE_Ticket
87
-            ? $aee->line_items_with_children[ $this->_data->ID() ]['EE_Ticket']
85
+                         && ! empty($aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'])
86
+                         && $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket'] instanceof EE_Ticket
87
+            ? $aee->line_items_with_children[$this->_data->ID()]['EE_Ticket']
88 88
             : $this->_ticket;
89 89
 
90 90
         // if still no ticket, then let's see if there is a reg_obj.  If there IS, then we'll try and grab the ticket from the reg_obj instead.
@@ -95,7 +95,7 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
         // If there is no event object by now then get out.
98
-        if (! $this->_ticket instanceof EE_Ticket) {
98
+        if ( ! $this->_ticket instanceof EE_Ticket) {
99 99
             return '';
100 100
         }
101 101
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
                 break;
122 122
 
123 123
             case '[TKT_QTY_PURCHASED]':
124
-                return $aee instanceof EE_Messages_Addressee ? $aee->tickets[ $this->_ticket->ID() ]['count'] : '';
124
+                return $aee instanceof EE_Messages_Addressee ? $aee->tickets[$this->_ticket->ID()]['count'] : '';
125 125
                 break;
126 126
         }
127 127
 
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Payment_List_Shortcodes.lib.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -20,88 +20,88 @@
 block discarded – undo
20 20
 {
21 21
 
22 22
 
23
-    protected function _init_props()
24
-    {
25
-        $this->label = esc_html__('Payment List Shortcodes', 'event_espresso');
26
-        $this->description = esc_html__('All shortcodes specific to payment lists', 'event_espresso');
27
-        $this->_shortcodes = array(
28
-            '[PAYMENT_LIST_*]' => esc_html__(
29
-                'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults.  Attributes that are available are:',
30
-                'event_espresso'
31
-            )
32
-                                  . '<p><ul>' .
33
-                                  '<li><strong>no_payments</strong>:' . sprintf(
34
-                                      esc_html__(
35
-                                          'Indicate with this attribute what will be used if there are no payments present.  Default is: "%sNo approved payments have been received.%s"',
36
-                                          'event_espresso'
37
-                                      ),
38
-                                      htmlspecialchars('<td class="aln-cntr" colspan="6">'),
39
-                                      htmlspecialchars('</td>')
40
-                                  ) . '</li>' .
41
-                                  '</ul></p>',
42
-        );
43
-    }
44
-
45
-
46
-    protected function _parser($shortcode)
47
-    {
48
-
49
-        if (strpos($shortcode, '[PAYMENT_LIST_*') !== false) {
50
-            return $this->_get_payment_list($shortcode);
51
-        }
52
-        return '';
53
-    }
54
-
55
-
56
-    /**
57
-     * verify incoming data contains what is needed for retrieving and parsing each payment for transaction.
58
-     *
59
-     * @since 4.5.0
60
-     *
61
-     * @param string $shortcode The incoming shortcode.
62
-     *
63
-     * @return string parsed ticket line item list.
64
-     */
65
-    private function _get_payment_list($shortcode)
66
-    {
67
-        $this->_validate_list_requirements();
68
-
69
-
70
-        if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
71
-            return '';
72
-        }
73
-
74
-        $valid_shortcodes = array('payment');
75
-
76
-        $addressee_obj = $this->_data['data'];
77
-        $templates = $this->_extra_data['template'];
78
-        $payments = apply_filters(
79
-            'FHEE__Payment_List_Shortcodes___get_payments_list__payments',
80
-            $addressee_obj->payments
81
-        );
82
-
83
-        // let's get any attributes that may be present and set the defaults.
84
-        $atts = $this->_get_shortcode_attrs($shortcode);
85
-
86
-        $no_payments_msg = empty($atts['no_payments']) ? esc_html__(
87
-            'No approved payments have been received.',
88
-            'event_espresso'
89
-        ) : $atts['no_payments'];
90
-
91
-        // made it here so we have an array of paymnets, so we should have what we need.
92
-        $payment_content = empty($payments) ? $no_payments_msg : '';
93
-
94
-        $payments = (array) $payments;
95
-
96
-        foreach ($payments as $payment) {
97
-            $payment_content .= $this->_shortcode_helper->parse_payment_list_template(
98
-                $templates['payment_list'],
99
-                $payment,
100
-                $valid_shortcodes,
101
-                $this->_extra_data
102
-            );
103
-        }
104
-
105
-        return $payment_content;
106
-    }
23
+	protected function _init_props()
24
+	{
25
+		$this->label = esc_html__('Payment List Shortcodes', 'event_espresso');
26
+		$this->description = esc_html__('All shortcodes specific to payment lists', 'event_espresso');
27
+		$this->_shortcodes = array(
28
+			'[PAYMENT_LIST_*]' => esc_html__(
29
+				'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults.  Attributes that are available are:',
30
+				'event_espresso'
31
+			)
32
+								  . '<p><ul>' .
33
+								  '<li><strong>no_payments</strong>:' . sprintf(
34
+									  esc_html__(
35
+										  'Indicate with this attribute what will be used if there are no payments present.  Default is: "%sNo approved payments have been received.%s"',
36
+										  'event_espresso'
37
+									  ),
38
+									  htmlspecialchars('<td class="aln-cntr" colspan="6">'),
39
+									  htmlspecialchars('</td>')
40
+								  ) . '</li>' .
41
+								  '</ul></p>',
42
+		);
43
+	}
44
+
45
+
46
+	protected function _parser($shortcode)
47
+	{
48
+
49
+		if (strpos($shortcode, '[PAYMENT_LIST_*') !== false) {
50
+			return $this->_get_payment_list($shortcode);
51
+		}
52
+		return '';
53
+	}
54
+
55
+
56
+	/**
57
+	 * verify incoming data contains what is needed for retrieving and parsing each payment for transaction.
58
+	 *
59
+	 * @since 4.5.0
60
+	 *
61
+	 * @param string $shortcode The incoming shortcode.
62
+	 *
63
+	 * @return string parsed ticket line item list.
64
+	 */
65
+	private function _get_payment_list($shortcode)
66
+	{
67
+		$this->_validate_list_requirements();
68
+
69
+
70
+		if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
71
+			return '';
72
+		}
73
+
74
+		$valid_shortcodes = array('payment');
75
+
76
+		$addressee_obj = $this->_data['data'];
77
+		$templates = $this->_extra_data['template'];
78
+		$payments = apply_filters(
79
+			'FHEE__Payment_List_Shortcodes___get_payments_list__payments',
80
+			$addressee_obj->payments
81
+		);
82
+
83
+		// let's get any attributes that may be present and set the defaults.
84
+		$atts = $this->_get_shortcode_attrs($shortcode);
85
+
86
+		$no_payments_msg = empty($atts['no_payments']) ? esc_html__(
87
+			'No approved payments have been received.',
88
+			'event_espresso'
89
+		) : $atts['no_payments'];
90
+
91
+		// made it here so we have an array of paymnets, so we should have what we need.
92
+		$payment_content = empty($payments) ? $no_payments_msg : '';
93
+
94
+		$payments = (array) $payments;
95
+
96
+		foreach ($payments as $payment) {
97
+			$payment_content .= $this->_shortcode_helper->parse_payment_list_template(
98
+				$templates['payment_list'],
99
+				$payment,
100
+				$valid_shortcodes,
101
+				$this->_extra_data
102
+			);
103
+		}
104
+
105
+		return $payment_content;
106
+	}
107 107
 }
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -29,15 +29,15 @@  discard block
 block discarded – undo
29 29
                 'Outputs a list of payment items. Note, this is a dynamic shortcode in that it accepts some attributes for setting certain defaults.  Attributes that are available are:',
30 30
                 'event_espresso'
31 31
             )
32
-                                  . '<p><ul>' .
33
-                                  '<li><strong>no_payments</strong>:' . sprintf(
32
+                                  . '<p><ul>'.
33
+                                  '<li><strong>no_payments</strong>:'.sprintf(
34 34
                                       esc_html__(
35 35
                                           'Indicate with this attribute what will be used if there are no payments present.  Default is: "%sNo approved payments have been received.%s"',
36 36
                                           'event_espresso'
37 37
                                       ),
38 38
                                       htmlspecialchars('<td class="aln-cntr" colspan="6">'),
39 39
                                       htmlspecialchars('</td>')
40
-                                  ) . '</li>' .
40
+                                  ).'</li>'.
41 41
                                   '</ul></p>',
42 42
         );
43 43
     }
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
         $this->_validate_list_requirements();
68 68
 
69 69
 
70
-        if (! $this->_data['data'] instanceof EE_Messages_Addressee) {
70
+        if ( ! $this->_data['data'] instanceof EE_Messages_Addressee) {
71 71
             return '';
72 72
         }
73 73
 
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Messenger_Shortcodes.lib.php 2 patches
Indentation   +149 added lines, -149 removed lines patch added patch discarded remove patch
@@ -24,157 +24,157 @@
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * Hold array of active messengers indexed by messenger name.
29
-     *
30
-     * @since 4.5.0
31
-     *
32
-     * @var EE_messenger[]
33
-     */
34
-    protected $_active_messengers = array();
35
-
36
-
37
-    protected function _init_props()
38
-    {
39
-        $this->label = esc_html__('Messenger Shortcodes', 'event_espresso');
40
-        $this->description = esc_html__('All shortcodes that are messenger specific.', 'event_espresso');
41
-        /** @type EE_Message_Resource_Manager $message_resource_manager */
42
-        $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
43
-        // add messages about what happens  when the messenger is active.
44
-        $this->_active_messengers = $message_resource_manager->active_messengers();
45
-
46
-        $this->_shortcodes['[DISPLAY_HTML_URL]'] = esc_html__(
47
-            'This will return a link to view the template in a browser if the html messenger is active.',
48
-            'event_espresso'
49
-        );
50
-        $this->_shortcodes['[DISPLAY_PDF_URL]'] = esc_html__(
51
-            'This will return a link to generate a pdf for the template if the pdf messenger is active.',
52
-            'event_espresso'
53
-        );
54
-        $this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = esc_html__(
55
-            'This will return html for a download pdf button trigger if the pdf messenger is active.',
56
-            'event_espresso'
57
-        );
58
-
59
-        /** @var RequestInterface $request */
60
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
61
-        $action = $request->getRequestParam('action');
62
-        // show error message about buttons/urls not working as expected if messenger deactivated.
63
-        if ($action === 'update_message_template' && is_admin()) {
64
-            if (! isset($this->_active_messengers['pdf'])) {
65
-                EE_Error::add_attention(
66
-                    esc_html__(
67
-                        'Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.',
68
-                        'event_espresso'
69
-                    )
70
-                );
71
-            }
72
-
73
-            if (! isset($this->_active_messengers['html'])) {
74
-                EE_Error::add_attention(
75
-                    esc_html__(
76
-                        'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.',
77
-                        'event_espresso'
78
-                    )
79
-                );
80
-            }
81
-        }
82
-    }
83
-
84
-
85
-    protected function _parser($shortcode)
86
-    {
87
-        // make sure we end up with a copy of the EE_Messages_Addressee object
88
-        $recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
89
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && is_array(
90
-            $this->_data
91
-        ) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data']
92
-            : $recipient;
93
-        $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
94
-            ? $this->_extra_data['data'] : $recipient;
95
-
96
-        if (! $recipient instanceof EE_Messages_Addressee) {
97
-            return '';
98
-        }
99
-
100
-        switch ($shortcode) {
101
-            case '[DISPLAY_HTML_URL]':
102
-                return isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : '';
103
-                break;
104
-            case '[DISPLAY_PDF_URL]':
105
-                return isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : '';
106
-                break;
107
-            case '[DISPLAY_PDF_BUTTON]':
108
-                return isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : '';
109
-                break;
110
-        }
111
-        return '';
112
-    }
113
-
114
-
115
-    /**
116
-     * This method takes the incoming data and figures out from it what the message type is and evt_id/grp_id and uses
117
-     * that to generate the html for a button in the template.
118
-     *
119
-     * @since 4.5.0
120
-     *
121
-     * @param EE_Messages_Addressee $recipient
122
-     * @param string                $sending_messenger 'html' or 'pdf'
123
-     *
124
-     * @return string                Generated html
125
-     */
126
-    private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger)
127
-    {
128
-        $download_text = $sending_messenger == 'pdf'
129
-            ? esc_html__('Download PDF', 'event_espresso')
130
-            : esc_html__(
131
-                'Show HTML',
132
-                'event_espresso'
133
-            );
134
-        $content = '
27
+	/**
28
+	 * Hold array of active messengers indexed by messenger name.
29
+	 *
30
+	 * @since 4.5.0
31
+	 *
32
+	 * @var EE_messenger[]
33
+	 */
34
+	protected $_active_messengers = array();
35
+
36
+
37
+	protected function _init_props()
38
+	{
39
+		$this->label = esc_html__('Messenger Shortcodes', 'event_espresso');
40
+		$this->description = esc_html__('All shortcodes that are messenger specific.', 'event_espresso');
41
+		/** @type EE_Message_Resource_Manager $message_resource_manager */
42
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
43
+		// add messages about what happens  when the messenger is active.
44
+		$this->_active_messengers = $message_resource_manager->active_messengers();
45
+
46
+		$this->_shortcodes['[DISPLAY_HTML_URL]'] = esc_html__(
47
+			'This will return a link to view the template in a browser if the html messenger is active.',
48
+			'event_espresso'
49
+		);
50
+		$this->_shortcodes['[DISPLAY_PDF_URL]'] = esc_html__(
51
+			'This will return a link to generate a pdf for the template if the pdf messenger is active.',
52
+			'event_espresso'
53
+		);
54
+		$this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = esc_html__(
55
+			'This will return html for a download pdf button trigger if the pdf messenger is active.',
56
+			'event_espresso'
57
+		);
58
+
59
+		/** @var RequestInterface $request */
60
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
61
+		$action = $request->getRequestParam('action');
62
+		// show error message about buttons/urls not working as expected if messenger deactivated.
63
+		if ($action === 'update_message_template' && is_admin()) {
64
+			if (! isset($this->_active_messengers['pdf'])) {
65
+				EE_Error::add_attention(
66
+					esc_html__(
67
+						'Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.',
68
+						'event_espresso'
69
+					)
70
+				);
71
+			}
72
+
73
+			if (! isset($this->_active_messengers['html'])) {
74
+				EE_Error::add_attention(
75
+					esc_html__(
76
+						'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.',
77
+						'event_espresso'
78
+					)
79
+				);
80
+			}
81
+		}
82
+	}
83
+
84
+
85
+	protected function _parser($shortcode)
86
+	{
87
+		// make sure we end up with a copy of the EE_Messages_Addressee object
88
+		$recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
89
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && is_array(
90
+			$this->_data
91
+		) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data']
92
+			: $recipient;
93
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
94
+			? $this->_extra_data['data'] : $recipient;
95
+
96
+		if (! $recipient instanceof EE_Messages_Addressee) {
97
+			return '';
98
+		}
99
+
100
+		switch ($shortcode) {
101
+			case '[DISPLAY_HTML_URL]':
102
+				return isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : '';
103
+				break;
104
+			case '[DISPLAY_PDF_URL]':
105
+				return isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : '';
106
+				break;
107
+			case '[DISPLAY_PDF_BUTTON]':
108
+				return isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : '';
109
+				break;
110
+		}
111
+		return '';
112
+	}
113
+
114
+
115
+	/**
116
+	 * This method takes the incoming data and figures out from it what the message type is and evt_id/grp_id and uses
117
+	 * that to generate the html for a button in the template.
118
+	 *
119
+	 * @since 4.5.0
120
+	 *
121
+	 * @param EE_Messages_Addressee $recipient
122
+	 * @param string                $sending_messenger 'html' or 'pdf'
123
+	 *
124
+	 * @return string                Generated html
125
+	 */
126
+	private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger)
127
+	{
128
+		$download_text = $sending_messenger == 'pdf'
129
+			? esc_html__('Download PDF', 'event_espresso')
130
+			: esc_html__(
131
+				'Show HTML',
132
+				'event_espresso'
133
+			);
134
+		$content = '
135 135
 <form method="post" action="' . $this->_get_url($recipient, $sending_messenger) . '" >
136 136
 	<input class="print_button" type="submit" value="' . $download_text . '" />
137 137
 </form>
138 138
 		';
139
-        return $content;
140
-    }
141
-
142
-
143
-    /**
144
-     * This method takes the incoming data and figures out from it what the message type is and
145
-     * evt_id/grp_id and uses that to generate the url for displaying the template in a browser.
146
-     *
147
-     * @since 4.5.0
148
-     *
149
-     * @param EE_Messages_Addressee $recipient
150
-     * @param string                $sending_messenger
151
-     *
152
-     * @return string The generated url for displaying the link.
153
-     * @throws EE_Error
154
-     */
155
-    private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger)
156
-    {
157
-
158
-        $reg = $recipient->reg_obj;
159
-        $reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg;
160
-
161
-
162
-        if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) {
163
-            EE_Registry::instance()->load_helper('MSG_Template');
164
-            try {
165
-                return EEH_MSG_Template::get_url_trigger(
166
-                    $this->_message_type,
167
-                    $this->_message,
168
-                    $reg,
169
-                    $sending_messenger
170
-                );
171
-            } catch (EE_Error $e) {
172
-                if (WP_DEBUG) {
173
-                    $e->get_error();
174
-                }
175
-            }
176
-        }
177
-
178
-        return '';
179
-    }
139
+		return $content;
140
+	}
141
+
142
+
143
+	/**
144
+	 * This method takes the incoming data and figures out from it what the message type is and
145
+	 * evt_id/grp_id and uses that to generate the url for displaying the template in a browser.
146
+	 *
147
+	 * @since 4.5.0
148
+	 *
149
+	 * @param EE_Messages_Addressee $recipient
150
+	 * @param string                $sending_messenger
151
+	 *
152
+	 * @return string The generated url for displaying the link.
153
+	 * @throws EE_Error
154
+	 */
155
+	private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger)
156
+	{
157
+
158
+		$reg = $recipient->reg_obj;
159
+		$reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg;
160
+
161
+
162
+		if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) {
163
+			EE_Registry::instance()->load_helper('MSG_Template');
164
+			try {
165
+				return EEH_MSG_Template::get_url_trigger(
166
+					$this->_message_type,
167
+					$this->_message,
168
+					$reg,
169
+					$sending_messenger
170
+				);
171
+			} catch (EE_Error $e) {
172
+				if (WP_DEBUG) {
173
+					$e->get_error();
174
+				}
175
+			}
176
+		}
177
+
178
+		return '';
179
+	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -61,7 +61,7 @@  discard block
 block discarded – undo
61 61
         $action = $request->getRequestParam('action');
62 62
         // show error message about buttons/urls not working as expected if messenger deactivated.
63 63
         if ($action === 'update_message_template' && is_admin()) {
64
-            if (! isset($this->_active_messengers['pdf'])) {
64
+            if ( ! isset($this->_active_messengers['pdf'])) {
65 65
                 EE_Error::add_attention(
66 66
                     esc_html__(
67 67
                         'Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.',
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
                 );
71 71
             }
72 72
 
73
-            if (! isset($this->_active_messengers['html'])) {
73
+            if ( ! isset($this->_active_messengers['html'])) {
74 74
                 EE_Error::add_attention(
75 75
                     esc_html__(
76 76
                         'Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.',
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee
94 94
             ? $this->_extra_data['data'] : $recipient;
95 95
 
96
-        if (! $recipient instanceof EE_Messages_Addressee) {
96
+        if ( ! $recipient instanceof EE_Messages_Addressee) {
97 97
             return '';
98 98
         }
99 99
 
@@ -132,8 +132,8 @@  discard block
 block discarded – undo
132 132
                 'event_espresso'
133 133
             );
134 134
         $content = '
135
-<form method="post" action="' . $this->_get_url($recipient, $sending_messenger) . '" >
136
-	<input class="print_button" type="submit" value="' . $download_text . '" />
135
+<form method="post" action="' . $this->_get_url($recipient, $sending_messenger).'" >
136
+	<input class="print_button" type="submit" value="' . $download_text.'" />
137 137
 </form>
138 138
 		';
139 139
         return $content;
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_PMT_Base.lib.php 2 patches
Indentation   +810 added lines, -810 removed lines patch added patch discarded remove patch
@@ -22,814 +22,814 @@
 block discarded – undo
22 22
 abstract class EE_PMT_Base
23 23
 {
24 24
 
25
-    const onsite = 'on-site';
26
-    const offsite = 'off-site';
27
-    const offline = 'off-line';
28
-
29
-    /**
30
-     * @var EE_Payment_Method
31
-     */
32
-    protected $_pm_instance = null;
33
-
34
-    /**
35
-     * @var boolean
36
-     */
37
-    protected $_requires_https = false;
38
-
39
-    /**
40
-     * @var boolean
41
-     */
42
-    protected $_has_billing_form;
43
-
44
-    /**
45
-     * @var EE_Gateway
46
-     */
47
-    protected $_gateway = null;
48
-
49
-    /**
50
-     * @var EE_Payment_Method_Form
51
-     */
52
-    protected $_settings_form = null;
53
-
54
-    /**
55
-     * @var EE_Form_Section_Proper
56
-     */
57
-    protected $_billing_form = null;
58
-
59
-    /**
60
-     * @var boolean
61
-     */
62
-    protected $_cache_billing_form = true;
63
-
64
-    /**
65
-     * String of the absolute path to the folder containing this file, with a trailing slash.
66
-     * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
67
-     *
68
-     * @var string
69
-     */
70
-    protected $_file_folder = null;
71
-
72
-    /**
73
-     * String to the absolute URL to this file (useful for getting its web-accessible resources
74
-     * like images, js, or css)
75
-     *
76
-     * @var string
77
-     */
78
-    protected $_file_url = null;
79
-
80
-    /**
81
-     * Pretty name for the payment method
82
-     *
83
-     * @var string
84
-     */
85
-    protected $_pretty_name = null;
86
-
87
-    /**
88
-     *
89
-     * @var string
90
-     */
91
-    protected $_default_button_url = null;
92
-
93
-    /**
94
-     *
95
-     * @var string
96
-     */
97
-    protected $_default_description = null;
98
-
99
-
100
-    /**
101
-     *
102
-     * @param EE_Payment_Method $pm_instance
103
-     * @throws EE_Error
104
-     * @return EE_PMT_Base
105
-     */
106
-    public function __construct($pm_instance = null)
107
-    {
108
-        if ($pm_instance instanceof EE_Payment_Method) {
109
-            $this->set_instance($pm_instance);
110
-        }
111
-        if ($this->_gateway) {
112
-            $this->_gateway->set_payment_model(EEM_Payment::instance());
113
-            $this->_gateway->set_payment_log(EEM_Change_Log::instance());
114
-            $this->_gateway->set_template_helper(new EEH_Template());
115
-            $this->_gateway->set_line_item_helper(new EEH_Line_Item());
116
-            $this->_gateway->set_money_helper(new EEH_Money());
117
-            $this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
118
-            $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
119
-            do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
120
-        }
121
-        if (! isset($this->_has_billing_form)) {
122
-            // by default, On Site gateways have a billing form
123
-            if ($this->payment_occurs() == EE_PMT_Base::onsite) {
124
-                $this->set_has_billing_form(true);
125
-            } else {
126
-                $this->set_has_billing_form(false);
127
-            }
128
-        }
129
-
130
-        if (! $this->_pretty_name) {
131
-            throw new EE_Error(
132
-                sprintf(
133
-                    esc_html__(
134
-                        "You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
135
-                        "event_espresso"
136
-                    )
137
-                )
138
-            );
139
-        }
140
-        // if the child didn't specify a default button, use the credit card one
141
-        if ($this->_default_button_url === null) {
142
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
143
-        }
144
-    }
145
-
146
-
147
-    /**
148
-     * @param boolean $has_billing_form
149
-     */
150
-    public function set_has_billing_form($has_billing_form)
151
-    {
152
-        $this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
153
-    }
154
-
155
-
156
-    /**
157
-     * sets the file_folder property
158
-     */
159
-    protected function _set_file_folder()
160
-    {
161
-        $reflector = new ReflectionClass(get_class($this));
162
-        $fn = $reflector->getFileName();
163
-        $this->_file_folder = dirname($fn) . '/';
164
-    }
165
-
166
-
167
-    /**
168
-     * sets the file URL with a trailing slash for this PMT
169
-     */
170
-    protected function _set_file_url()
171
-    {
172
-        $plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR);
173
-        $file_folder_fixed = str_replace('\\', '/', $this->file_folder());
174
-        $file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
175
-        $this->_file_url = set_url_scheme($file_path);
176
-    }
177
-
178
-    /**
179
-     * Gets the default description on all payment methods of this type
180
-     *
181
-     * @return string
182
-     */
183
-    public function default_description()
184
-    {
185
-        return $this->_default_description;
186
-    }
187
-
188
-
189
-    /**
190
-     * Returns the folder containing the PMT child class, with a trailing slash
191
-     *
192
-     * @return string
193
-     */
194
-    public function file_folder()
195
-    {
196
-        if (! $this->_file_folder) {
197
-            $this->_set_file_folder();
198
-        }
199
-        return $this->_file_folder;
200
-    }
201
-
202
-
203
-    /**
204
-     * @return string
205
-     */
206
-    public function file_url()
207
-    {
208
-        if (! $this->_file_url) {
209
-            $this->_set_file_url();
210
-        }
211
-        return $this->_file_url;
212
-    }
213
-
214
-
215
-    /**
216
-     * Sets the payment method instance this payment method type is for.
217
-     * Its important teh payment method instance is set before
218
-     *
219
-     * @param EE_Payment_Method $payment_method_instance
220
-     */
221
-    public function set_instance($payment_method_instance)
222
-    {
223
-        $this->_pm_instance = $payment_method_instance;
224
-        // if they have already requested the settings form, make sure its
225
-        // data matches this model object
226
-        if ($this->_settings_form) {
227
-            $this->settings_form()->populate_model_obj($payment_method_instance);
228
-        }
229
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
230
-            $this->_gateway->set_settings($payment_method_instance->settings_array());
231
-        }
232
-    }
233
-
234
-
235
-    /**
236
-     * Gets teh form for displaying to admins where they setup the payment method
237
-     *
238
-     * @return EE_Payment_Method_Form
239
-     */
240
-    public function settings_form()
241
-    {
242
-        if (! $this->_settings_form) {
243
-            $this->_settings_form = $this->generate_new_settings_form();
244
-            $this->_settings_form->set_payment_method_type($this);
245
-            // if we have already assigned a model object to this pmt, make
246
-            // sure its reflected in teh form we just generated
247
-            if ($this->_pm_instance) {
248
-                $this->_settings_form->populate_model_obj($this->_pm_instance);
249
-            }
250
-        }
251
-        return $this->_settings_form;
252
-    }
253
-
254
-
255
-    /**
256
-     * Gets the form for all the settings related to this payment method type
257
-     *
258
-     * @return EE_Payment_Method_Form
259
-     */
260
-    abstract public function generate_new_settings_form();
261
-
262
-
263
-    /**
264
-     * Sets the form for settings. This may be useful if we have already received
265
-     * a form submission and have form data it in, and want to use it anytime we're showing
266
-     * this payment method type's settings form later in the request
267
-     *
268
-     * @param EE_Payment_Method_Form $form
269
-     */
270
-    public function set_settings_form($form)
271
-    {
272
-        $this->_settings_form = $form;
273
-    }
274
-
275
-
276
-    /**
277
-     * @return boolean
278
-     */
279
-    public function has_billing_form()
280
-    {
281
-        return $this->_has_billing_form;
282
-    }
283
-
284
-
285
-    /**
286
-     * Gets the form for displaying to attendees where they can enter their billing info
287
-     * which will be sent to teh gateway (can be null)
288
-     *
289
-     * @param \EE_Transaction $transaction
290
-     * @param array           $extra_args
291
-     * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
292
-     */
293
-    public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
294
-    {
295
-        // has billing form already been regenerated ? or overwrite cache?
296
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
297
-            $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
298
-        }
299
-        // if we know who the attendee is, and this is a billing form
300
-        // that uses attendee info, populate it
301
-        if (
302
-            apply_filters(
303
-                'FHEE__populate_billing_form_fields_from_attendee',
304
-                ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
305
-                && $transaction instanceof EE_Transaction
306
-                && $transaction->primary_registration() instanceof EE_Registration
307
-                && $transaction->primary_registration()->attendee() instanceof EE_Attendee
308
-                ),
309
-                $this->_billing_form,
310
-                $transaction
311
-            )
312
-        ) {
313
-            $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
314
-        }
315
-        return $this->_billing_form;
316
-    }
317
-
318
-
319
-    /**
320
-     * Creates the billing form for this payment method type
321
-     *
322
-     * @param \EE_Transaction $transaction
323
-     * @return \EE_Billing_Info_Form
324
-     */
325
-    abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
326
-
327
-
328
-    /**
329
-     * apply_billing_form_debug_settings
330
-     * applies debug data to the form
331
-     *
332
-     * @param \EE_Billing_Info_Form $billing_form
333
-     * @return \EE_Billing_Info_Form
334
-     */
335
-    public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
336
-    {
337
-        return $billing_form;
338
-    }
339
-
340
-
341
-    /**
342
-     * Sets the billing form for this payment method type. You may want to use this
343
-     * if you have form
344
-     *
345
-     * @param EE_Payment_Method $form
346
-     */
347
-    public function set_billing_form($form)
348
-    {
349
-        $this->_billing_form = $form;
350
-    }
351
-
352
-
353
-    /**
354
-     * Returns whether or not this payment method requires HTTPS to be used
355
-     *
356
-     * @return boolean
357
-     */
358
-    public function requires_https()
359
-    {
360
-        return $this->_requires_https;
361
-    }
362
-
363
-
364
-    /**
365
-     *
366
-     * @param EE_Transaction       $transaction
367
-     * @param float                $amount
368
-     * @param EE_Billing_Info_Form $billing_info
369
-     * @param string               $return_url
370
-     * @param string               $fail_url
371
-     * @param string               $method
372
-     * @param bool                 $by_admin
373
-     * @return EE_Payment
374
-     * @throws EE_Error
375
-     */
376
-    public function process_payment(
377
-        EE_Transaction $transaction,
378
-        $amount = null,
379
-        $billing_info = null,
380
-        $return_url = null,
381
-        $fail_url = '',
382
-        $method = 'CART',
383
-        $by_admin = false
384
-    ) {
385
-        // @todo: add surcharge for the payment method, if any
386
-        if ($this->_gateway) {
387
-            // there is a gateway, so we're going to make a payment object
388
-            // but wait! do they already have a payment in progress that we thought was failed?
389
-            $duplicate_properties = array(
390
-                'STS_ID'               => EEM_Payment::status_id_failed,
391
-                'TXN_ID'               => $transaction->ID(),
392
-                'PMD_ID'               => $this->_pm_instance->ID(),
393
-                'PAY_source'           => $method,
394
-                'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
395
-                'PAY_gateway_response' => null,
396
-            );
397
-            $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
398
-            // if we didn't already have a payment in progress for the same thing,
399
-            // then we actually want to make a new payment
400
-            if (! $payment instanceof EE_Payment) {
401
-                $payment = EE_Payment::new_instance(
402
-                    array_merge(
403
-                        $duplicate_properties,
404
-                        array(
405
-                            'PAY_timestamp'       => time(),
406
-                            'PAY_txn_id_chq_nmbr' => null,
407
-                            'PAY_po_number'       => null,
408
-                            'PAY_extra_accntng'   => null,
409
-                            'PAY_details'         => null,
410
-                        )
411
-                    )
412
-                );
413
-            }
414
-            // make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
415
-            $payment->save();
416
-            $billing_values = $this->_get_billing_values_from_form($billing_info);
417
-
418
-            //  Offsite Gateway
419
-            if ($this->_gateway instanceof EE_Offsite_Gateway) {
420
-                $payment = $this->_gateway->set_redirection_info(
421
-                    $payment,
422
-                    $billing_values,
423
-                    $return_url,
424
-                    EE_Config::instance()->core->txn_page_url(
425
-                        array(
426
-                            'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
427
-                            'ee_payment_method' => $this->_pm_instance->slug(),
428
-                        )
429
-                    ),
430
-                    $fail_url
431
-                );
432
-                $payment->save();
433
-                //  Onsite Gateway
434
-            } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
435
-                $payment = $this->_gateway->do_direct_payment($payment, $billing_values);
436
-                $payment->save();
437
-            } else {
438
-                throw new EE_Error(
439
-                    sprintf(
440
-                        esc_html__(
441
-                            'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
442
-                            'event_espresso'
443
-                        ),
444
-                        get_class($this),
445
-                        gettype($this->_gateway)
446
-                    )
447
-                );
448
-            }
449
-        } else {
450
-            // no gateway provided
451
-            // there is no payment. Must be an offline gateway
452
-            // create a payment object anyways, but dont save it
453
-            $payment = EE_Payment::new_instance(
454
-                array(
455
-                    'STS_ID'        => EEM_Payment::status_id_pending,
456
-                    'TXN_ID'        => $transaction->ID(),
457
-                    'PMD_ID'        => $transaction->payment_method_ID(),
458
-                    'PAY_amount'    => 0.00,
459
-                    'PAY_timestamp' => time(),
460
-                )
461
-            );
462
-        }
463
-
464
-        // if there is billing info, clean it and save it now
465
-        if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
466
-            $this->_save_billing_info_to_attendee($billing_info, $transaction);
467
-        }
468
-
469
-        return $payment;
470
-    }
471
-
472
-    /**
473
-     * Gets the values we want to pass onto the gateway. Normally these
474
-     * are just the 'pretty' values, but there may be times the data may need
475
-     * a  little massaging. Proper subsections will become arrays of inputs
476
-     *
477
-     * @param EE_Billing_Info_Form $billing_form
478
-     * @return array
479
-     */
480
-    protected function _get_billing_values_from_form($billing_form)
481
-    {
482
-        if ($billing_form instanceof EE_Form_Section_Proper) {
483
-            return $billing_form->input_pretty_values(true);
484
-        } else {
485
-            return null;
486
-        }
487
-    }
488
-
489
-
490
-    /**
491
-     * Handles an instant payment notification when the transaction is known (by default).
492
-     *
493
-     * @param array          $req_data
494
-     * @param EE_Transaction $transaction
495
-     * @return EE_Payment
496
-     * @throws EE_Error
497
-     */
498
-    public function handle_ipn($req_data, $transaction)
499
-    {
500
-        $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
501
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
502
-            throw new EE_Error(
503
-                sprintf(
504
-                    esc_html__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
505
-                    print_r($this->_gateway, true)
506
-                )
507
-            );
508
-        }
509
-        $payment = $this->_gateway->handle_payment_update($req_data, $transaction);
510
-        return $payment;
511
-    }
512
-
513
-
514
-    /**
515
-     * Saves the billing info onto the attendee of the primary registrant on this transaction, and
516
-     * cleans it first.
517
-     *
518
-     * @param EE_Billing_Attendee_Info_Form $billing_form
519
-     * @param EE_Transaction                $transaction
520
-     * @return boolean success
521
-     */
522
-    protected function _save_billing_info_to_attendee($billing_form, $transaction)
523
-    {
524
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
525
-            EE_Error::add_error(
526
-                esc_html__("Cannot save billing info because no transaction was specified", "event_espresso"),
527
-                __FILE__,
528
-                __FUNCTION__,
529
-                __LINE__
530
-            );
531
-            return false;
532
-        }
533
-        $primary_reg = $transaction->primary_registration();
534
-        if (! $primary_reg) {
535
-            EE_Error::add_error(
536
-                esc_html__("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
537
-                __FILE__,
538
-                __FUNCTION__,
539
-                __LINE__
540
-            );
541
-            return false;
542
-        }
543
-        $attendee = $primary_reg->attendee();
544
-        if (! $attendee) {
545
-            EE_Error::add_error(
546
-                esc_html__(
547
-                    "Cannot save billing info because the transaction's primary registration has no attendee!",
548
-                    "event_espresso"
549
-                ),
550
-                __FILE__,
551
-                __FUNCTION__,
552
-                __LINE__
553
-            );
554
-            return false;
555
-        }
556
-        return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
557
-    }
558
-
559
-
560
-    /**
561
-     * Gets the payment this IPN is for. Children may often want to
562
-     * override this to inspect the request
563
-     *
564
-     * @param EE_Transaction $transaction
565
-     * @param array          $req_data
566
-     * @return EE_Payment
567
-     */
568
-    protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
569
-    {
570
-        return $transaction->last_payment();
571
-    }
572
-
573
-
574
-    /**
575
-     * In case generic code cannot provide the payment processor with a specific payment method
576
-     * and transaction, it will try calling this method on each activate payment method.
577
-     * If the payment method is able to identify the request as being for it, it should fetch
578
-     * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
579
-     * handle the IPN
580
-     *
581
-     * @param array $req_data
582
-     * @return EE_Payment only if this payment method can find the info its needs from $req_data
583
-     * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
584
-     * @throws EE_Error
585
-     */
586
-    public function handle_unclaimed_ipn($req_data = array())
587
-    {
588
-        throw new EE_Error(
589
-            sprintf(esc_html__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
590
-        );
591
-    }
592
-
593
-
594
-    /**
595
-     * Logic to be accomplished when the payment attempt is complete.
596
-     * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
597
-     * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
598
-     * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
599
-     * of the payment). Fed a transaction because it's always assumed to be the last payment that
600
-     * we're dealing with. Returns that last payment (if there is one)
601
-     *
602
-     * @param EE_Transaction $transaction
603
-     * @return EE_Payment
604
-     */
605
-    public function finalize_payment_for($transaction)
606
-    {
607
-        return $transaction->last_payment();
608
-    }
609
-
610
-
611
-    /**
612
-     * Whether or not this payment method's gateway supports sending refund requests
613
-     *
614
-     * @return boolean
615
-     */
616
-    public function supports_sending_refunds()
617
-    {
618
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
619
-            return $this->_gateway->supports_sending_refunds();
620
-        } else {
621
-            return false;
622
-        }
623
-    }
624
-
625
-
626
-    /**
627
-     *
628
-     * @param EE_Payment $payment
629
-     * @param array      $refund_info
630
-     * @throws EE_Error
631
-     * @return EE_Payment
632
-     */
633
-    public function process_refund(EE_Payment $payment, $refund_info = array())
634
-    {
635
-        if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
636
-            return $this->_gateway->do_direct_refund($payment, $refund_info);
637
-        } else {
638
-            throw new EE_Error(
639
-                sprintf(
640
-                    esc_html__('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
641
-                    get_class($this)
642
-                )
643
-            );
644
-        }
645
-    }
646
-
647
-
648
-    /**
649
-     * Returns one the class's constants onsite,offsite, or offline, depending on this
650
-     * payment method's gateway.
651
-     *
652
-     * @return string
653
-     * @throws EE_Error
654
-     */
655
-    public function payment_occurs()
656
-    {
657
-        if (! $this->_gateway) {
658
-            return EE_PMT_Base::offline;
659
-        } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
660
-            return EE_PMT_Base::onsite;
661
-        } elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
662
-            return EE_PMT_Base::offsite;
663
-        } else {
664
-            throw new EE_Error(
665
-                sprintf(
666
-                    esc_html__(
667
-                        "Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
668
-                        "event_espresso"
669
-                    ),
670
-                    get_class($this)
671
-                )
672
-            );
673
-        }
674
-    }
675
-
676
-
677
-    /**
678
-     * For adding any html output ab ove the payment overview.
679
-     * Many gateways won't want ot display anything, so this function just returns an empty string.
680
-     * Other gateways may want to override this, such as offline gateways.
681
-     *
682
-     * @param EE_Payment $payment
683
-     * @return string
684
-     */
685
-    public function payment_overview_content(EE_Payment $payment)
686
-    {
687
-        return EEH_Template::display_template(
688
-            EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
689
-            array('payment_method' => $this->_pm_instance, 'payment' => $payment),
690
-            true
691
-        );
692
-    }
693
-
694
-
695
-    /**
696
-     * @return array where keys are the help tab name,
697
-     * values are: array {
698
-     * @type string $title         i18n name for the help tab
699
-     * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
700
-     * @type array  $template_args any arguments you want passed to the template file while rendering.
701
-     *                Keys will be variable names and values with be their values.
702
-     */
703
-    public function help_tabs_config()
704
-    {
705
-        return array();
706
-    }
707
-
708
-
709
-    /**
710
-     * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
711
-     * the payment method's table's PMT_type column)
712
-     *
713
-     * @return string
714
-     */
715
-    public function system_name()
716
-    {
717
-        $classname = get_class($this);
718
-        return str_replace("EE_PMT_", '', $classname);
719
-    }
720
-
721
-
722
-    /**
723
-     * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding
724
-     * this method.
725
-     * @return string
726
-     */
727
-    public function defaultFrontendName()
728
-    {
729
-        return $this->pretty_name();
730
-    }
731
-
732
-
733
-    /**
734
-     * A pretty i18n version of the PMT name
735
-     *
736
-     * @return string
737
-     */
738
-    public function pretty_name()
739
-    {
740
-        return $this->_pretty_name;
741
-    }
742
-
743
-
744
-    /**
745
-     * Gets the default absolute URL to the payment method type's button
746
-     *
747
-     * @return string
748
-     */
749
-    public function default_button_url()
750
-    {
751
-        return $this->_default_button_url;
752
-    }
753
-
754
-
755
-    /**
756
-     * Gets the gateway used by this payment method (if any)
757
-     *
758
-     * @return EE_Gateway
759
-     */
760
-    public function get_gateway()
761
-    {
762
-        return $this->_gateway;
763
-    }
764
-
765
-
766
-    /**
767
-     * @return string html for the link to a help tab
768
-     */
769
-    public function get_help_tab_link()
770
-    {
771
-        return EEH_Template::get_help_tab_link(
772
-            $this->get_help_tab_name(),
773
-            'espresso_payment_settings',
774
-            'default'
775
-        );
776
-    }
777
-
778
-
779
-    /**
780
-     * Returns the name of the help tab for this PMT
781
-     *
782
-     * @return string
783
-     */
784
-    public function get_help_tab_name()
785
-    {
786
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
787
-    }
788
-
789
-    /**
790
-     * The name of the wp capability that should be associated with the usage of
791
-     * this PMT by an admin
792
-     *
793
-     * @return string
794
-     */
795
-    public function cap_name()
796
-    {
797
-        return 'ee_payment_method_' . strtolower($this->system_name());
798
-    }
799
-
800
-    /**
801
-     * Called by client code to tell the gateway that if it wants to change
802
-     * the transaction or line items or registrations related to teh payment it already
803
-     * processed (we think, but possibly not) that now's the time to do it.
804
-     * It is expected that gateways will store any info they need for this on the PAY_details,
805
-     * or maybe an extra meta value
806
-     *
807
-     * @param EE_Payment $payment
808
-     * @return void
809
-     */
810
-    public function update_txn_based_on_payment($payment)
811
-    {
812
-        if ($this->_gateway instanceof EE_Gateway) {
813
-            $this->_gateway->update_txn_based_on_payment($payment);
814
-        }
815
-    }
816
-
817
-    /**
818
-     * Returns a string of HTML describing this payment method type for an admin,
819
-     * primarily intended for them to read before activating it.
820
-     * The easiest way to set this is to create a folder 'templates' alongside
821
-     * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
822
-     * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
823
-     * then you'd create a file named "templates" in the same folder as it, and name the file
824
-     * "foo_bar_intro.template.php", and its content will be returned by this method
825
-     *
826
-     * @return string
827
-     */
828
-    public function introductory_html()
829
-    {
830
-        return EEH_Template::locate_template(
831
-            $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
832
-            array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
833
-        );
834
-    }
25
+	const onsite = 'on-site';
26
+	const offsite = 'off-site';
27
+	const offline = 'off-line';
28
+
29
+	/**
30
+	 * @var EE_Payment_Method
31
+	 */
32
+	protected $_pm_instance = null;
33
+
34
+	/**
35
+	 * @var boolean
36
+	 */
37
+	protected $_requires_https = false;
38
+
39
+	/**
40
+	 * @var boolean
41
+	 */
42
+	protected $_has_billing_form;
43
+
44
+	/**
45
+	 * @var EE_Gateway
46
+	 */
47
+	protected $_gateway = null;
48
+
49
+	/**
50
+	 * @var EE_Payment_Method_Form
51
+	 */
52
+	protected $_settings_form = null;
53
+
54
+	/**
55
+	 * @var EE_Form_Section_Proper
56
+	 */
57
+	protected $_billing_form = null;
58
+
59
+	/**
60
+	 * @var boolean
61
+	 */
62
+	protected $_cache_billing_form = true;
63
+
64
+	/**
65
+	 * String of the absolute path to the folder containing this file, with a trailing slash.
66
+	 * eg '/public_html/wp-site/wp-content/plugins/event-espresso/payment_methods/Invoice/'
67
+	 *
68
+	 * @var string
69
+	 */
70
+	protected $_file_folder = null;
71
+
72
+	/**
73
+	 * String to the absolute URL to this file (useful for getting its web-accessible resources
74
+	 * like images, js, or css)
75
+	 *
76
+	 * @var string
77
+	 */
78
+	protected $_file_url = null;
79
+
80
+	/**
81
+	 * Pretty name for the payment method
82
+	 *
83
+	 * @var string
84
+	 */
85
+	protected $_pretty_name = null;
86
+
87
+	/**
88
+	 *
89
+	 * @var string
90
+	 */
91
+	protected $_default_button_url = null;
92
+
93
+	/**
94
+	 *
95
+	 * @var string
96
+	 */
97
+	protected $_default_description = null;
98
+
99
+
100
+	/**
101
+	 *
102
+	 * @param EE_Payment_Method $pm_instance
103
+	 * @throws EE_Error
104
+	 * @return EE_PMT_Base
105
+	 */
106
+	public function __construct($pm_instance = null)
107
+	{
108
+		if ($pm_instance instanceof EE_Payment_Method) {
109
+			$this->set_instance($pm_instance);
110
+		}
111
+		if ($this->_gateway) {
112
+			$this->_gateway->set_payment_model(EEM_Payment::instance());
113
+			$this->_gateway->set_payment_log(EEM_Change_Log::instance());
114
+			$this->_gateway->set_template_helper(new EEH_Template());
115
+			$this->_gateway->set_line_item_helper(new EEH_Line_Item());
116
+			$this->_gateway->set_money_helper(new EEH_Money());
117
+			$this->_gateway->set_gateway_data_formatter(new GatewayDataFormatter());
118
+			$this->_gateway->set_unsupported_character_remover(new AsciiOnly());
119
+			do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
120
+		}
121
+		if (! isset($this->_has_billing_form)) {
122
+			// by default, On Site gateways have a billing form
123
+			if ($this->payment_occurs() == EE_PMT_Base::onsite) {
124
+				$this->set_has_billing_form(true);
125
+			} else {
126
+				$this->set_has_billing_form(false);
127
+			}
128
+		}
129
+
130
+		if (! $this->_pretty_name) {
131
+			throw new EE_Error(
132
+				sprintf(
133
+					esc_html__(
134
+						"You must set the pretty name for the Payment Method Type in the constructor (_pretty_name), and please make it internationalized",
135
+						"event_espresso"
136
+					)
137
+				)
138
+			);
139
+		}
140
+		// if the child didn't specify a default button, use the credit card one
141
+		if ($this->_default_button_url === null) {
142
+			$this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
143
+		}
144
+	}
145
+
146
+
147
+	/**
148
+	 * @param boolean $has_billing_form
149
+	 */
150
+	public function set_has_billing_form($has_billing_form)
151
+	{
152
+		$this->_has_billing_form = filter_var($has_billing_form, FILTER_VALIDATE_BOOLEAN);
153
+	}
154
+
155
+
156
+	/**
157
+	 * sets the file_folder property
158
+	 */
159
+	protected function _set_file_folder()
160
+	{
161
+		$reflector = new ReflectionClass(get_class($this));
162
+		$fn = $reflector->getFileName();
163
+		$this->_file_folder = dirname($fn) . '/';
164
+	}
165
+
166
+
167
+	/**
168
+	 * sets the file URL with a trailing slash for this PMT
169
+	 */
170
+	protected function _set_file_url()
171
+	{
172
+		$plugins_dir_fixed = str_replace('\\', '/', WP_PLUGIN_DIR);
173
+		$file_folder_fixed = str_replace('\\', '/', $this->file_folder());
174
+		$file_path = str_replace($plugins_dir_fixed, WP_PLUGIN_URL, $file_folder_fixed);
175
+		$this->_file_url = set_url_scheme($file_path);
176
+	}
177
+
178
+	/**
179
+	 * Gets the default description on all payment methods of this type
180
+	 *
181
+	 * @return string
182
+	 */
183
+	public function default_description()
184
+	{
185
+		return $this->_default_description;
186
+	}
187
+
188
+
189
+	/**
190
+	 * Returns the folder containing the PMT child class, with a trailing slash
191
+	 *
192
+	 * @return string
193
+	 */
194
+	public function file_folder()
195
+	{
196
+		if (! $this->_file_folder) {
197
+			$this->_set_file_folder();
198
+		}
199
+		return $this->_file_folder;
200
+	}
201
+
202
+
203
+	/**
204
+	 * @return string
205
+	 */
206
+	public function file_url()
207
+	{
208
+		if (! $this->_file_url) {
209
+			$this->_set_file_url();
210
+		}
211
+		return $this->_file_url;
212
+	}
213
+
214
+
215
+	/**
216
+	 * Sets the payment method instance this payment method type is for.
217
+	 * Its important teh payment method instance is set before
218
+	 *
219
+	 * @param EE_Payment_Method $payment_method_instance
220
+	 */
221
+	public function set_instance($payment_method_instance)
222
+	{
223
+		$this->_pm_instance = $payment_method_instance;
224
+		// if they have already requested the settings form, make sure its
225
+		// data matches this model object
226
+		if ($this->_settings_form) {
227
+			$this->settings_form()->populate_model_obj($payment_method_instance);
228
+		}
229
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
230
+			$this->_gateway->set_settings($payment_method_instance->settings_array());
231
+		}
232
+	}
233
+
234
+
235
+	/**
236
+	 * Gets teh form for displaying to admins where they setup the payment method
237
+	 *
238
+	 * @return EE_Payment_Method_Form
239
+	 */
240
+	public function settings_form()
241
+	{
242
+		if (! $this->_settings_form) {
243
+			$this->_settings_form = $this->generate_new_settings_form();
244
+			$this->_settings_form->set_payment_method_type($this);
245
+			// if we have already assigned a model object to this pmt, make
246
+			// sure its reflected in teh form we just generated
247
+			if ($this->_pm_instance) {
248
+				$this->_settings_form->populate_model_obj($this->_pm_instance);
249
+			}
250
+		}
251
+		return $this->_settings_form;
252
+	}
253
+
254
+
255
+	/**
256
+	 * Gets the form for all the settings related to this payment method type
257
+	 *
258
+	 * @return EE_Payment_Method_Form
259
+	 */
260
+	abstract public function generate_new_settings_form();
261
+
262
+
263
+	/**
264
+	 * Sets the form for settings. This may be useful if we have already received
265
+	 * a form submission and have form data it in, and want to use it anytime we're showing
266
+	 * this payment method type's settings form later in the request
267
+	 *
268
+	 * @param EE_Payment_Method_Form $form
269
+	 */
270
+	public function set_settings_form($form)
271
+	{
272
+		$this->_settings_form = $form;
273
+	}
274
+
275
+
276
+	/**
277
+	 * @return boolean
278
+	 */
279
+	public function has_billing_form()
280
+	{
281
+		return $this->_has_billing_form;
282
+	}
283
+
284
+
285
+	/**
286
+	 * Gets the form for displaying to attendees where they can enter their billing info
287
+	 * which will be sent to teh gateway (can be null)
288
+	 *
289
+	 * @param \EE_Transaction $transaction
290
+	 * @param array           $extra_args
291
+	 * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
292
+	 */
293
+	public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
294
+	{
295
+		// has billing form already been regenerated ? or overwrite cache?
296
+		if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
297
+			$this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
298
+		}
299
+		// if we know who the attendee is, and this is a billing form
300
+		// that uses attendee info, populate it
301
+		if (
302
+			apply_filters(
303
+				'FHEE__populate_billing_form_fields_from_attendee',
304
+				($this->_billing_form instanceof EE_Billing_Attendee_Info_Form
305
+				&& $transaction instanceof EE_Transaction
306
+				&& $transaction->primary_registration() instanceof EE_Registration
307
+				&& $transaction->primary_registration()->attendee() instanceof EE_Attendee
308
+				),
309
+				$this->_billing_form,
310
+				$transaction
311
+			)
312
+		) {
313
+			$this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
314
+		}
315
+		return $this->_billing_form;
316
+	}
317
+
318
+
319
+	/**
320
+	 * Creates the billing form for this payment method type
321
+	 *
322
+	 * @param \EE_Transaction $transaction
323
+	 * @return \EE_Billing_Info_Form
324
+	 */
325
+	abstract public function generate_new_billing_form(EE_Transaction $transaction = null);
326
+
327
+
328
+	/**
329
+	 * apply_billing_form_debug_settings
330
+	 * applies debug data to the form
331
+	 *
332
+	 * @param \EE_Billing_Info_Form $billing_form
333
+	 * @return \EE_Billing_Info_Form
334
+	 */
335
+	public function apply_billing_form_debug_settings(EE_Billing_Info_Form $billing_form)
336
+	{
337
+		return $billing_form;
338
+	}
339
+
340
+
341
+	/**
342
+	 * Sets the billing form for this payment method type. You may want to use this
343
+	 * if you have form
344
+	 *
345
+	 * @param EE_Payment_Method $form
346
+	 */
347
+	public function set_billing_form($form)
348
+	{
349
+		$this->_billing_form = $form;
350
+	}
351
+
352
+
353
+	/**
354
+	 * Returns whether or not this payment method requires HTTPS to be used
355
+	 *
356
+	 * @return boolean
357
+	 */
358
+	public function requires_https()
359
+	{
360
+		return $this->_requires_https;
361
+	}
362
+
363
+
364
+	/**
365
+	 *
366
+	 * @param EE_Transaction       $transaction
367
+	 * @param float                $amount
368
+	 * @param EE_Billing_Info_Form $billing_info
369
+	 * @param string               $return_url
370
+	 * @param string               $fail_url
371
+	 * @param string               $method
372
+	 * @param bool                 $by_admin
373
+	 * @return EE_Payment
374
+	 * @throws EE_Error
375
+	 */
376
+	public function process_payment(
377
+		EE_Transaction $transaction,
378
+		$amount = null,
379
+		$billing_info = null,
380
+		$return_url = null,
381
+		$fail_url = '',
382
+		$method = 'CART',
383
+		$by_admin = false
384
+	) {
385
+		// @todo: add surcharge for the payment method, if any
386
+		if ($this->_gateway) {
387
+			// there is a gateway, so we're going to make a payment object
388
+			// but wait! do they already have a payment in progress that we thought was failed?
389
+			$duplicate_properties = array(
390
+				'STS_ID'               => EEM_Payment::status_id_failed,
391
+				'TXN_ID'               => $transaction->ID(),
392
+				'PMD_ID'               => $this->_pm_instance->ID(),
393
+				'PAY_source'           => $method,
394
+				'PAY_amount'           => $amount !== null ? $amount : $transaction->remaining(),
395
+				'PAY_gateway_response' => null,
396
+			);
397
+			$payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
398
+			// if we didn't already have a payment in progress for the same thing,
399
+			// then we actually want to make a new payment
400
+			if (! $payment instanceof EE_Payment) {
401
+				$payment = EE_Payment::new_instance(
402
+					array_merge(
403
+						$duplicate_properties,
404
+						array(
405
+							'PAY_timestamp'       => time(),
406
+							'PAY_txn_id_chq_nmbr' => null,
407
+							'PAY_po_number'       => null,
408
+							'PAY_extra_accntng'   => null,
409
+							'PAY_details'         => null,
410
+						)
411
+					)
412
+				);
413
+			}
414
+			// make sure the payment has been saved to show we started it, and so it has an ID should the gateway try to log it
415
+			$payment->save();
416
+			$billing_values = $this->_get_billing_values_from_form($billing_info);
417
+
418
+			//  Offsite Gateway
419
+			if ($this->_gateway instanceof EE_Offsite_Gateway) {
420
+				$payment = $this->_gateway->set_redirection_info(
421
+					$payment,
422
+					$billing_values,
423
+					$return_url,
424
+					EE_Config::instance()->core->txn_page_url(
425
+						array(
426
+							'e_reg_url_link'    => $transaction->primary_registration()->reg_url_link(),
427
+							'ee_payment_method' => $this->_pm_instance->slug(),
428
+						)
429
+					),
430
+					$fail_url
431
+				);
432
+				$payment->save();
433
+				//  Onsite Gateway
434
+			} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
435
+				$payment = $this->_gateway->do_direct_payment($payment, $billing_values);
436
+				$payment->save();
437
+			} else {
438
+				throw new EE_Error(
439
+					sprintf(
440
+						esc_html__(
441
+							'Gateway for payment method type "%s" is "%s", not a subclass of either EE_Offsite_Gateway or EE_Onsite_Gateway, or null (to indicate NO gateway)',
442
+							'event_espresso'
443
+						),
444
+						get_class($this),
445
+						gettype($this->_gateway)
446
+					)
447
+				);
448
+			}
449
+		} else {
450
+			// no gateway provided
451
+			// there is no payment. Must be an offline gateway
452
+			// create a payment object anyways, but dont save it
453
+			$payment = EE_Payment::new_instance(
454
+				array(
455
+					'STS_ID'        => EEM_Payment::status_id_pending,
456
+					'TXN_ID'        => $transaction->ID(),
457
+					'PMD_ID'        => $transaction->payment_method_ID(),
458
+					'PAY_amount'    => 0.00,
459
+					'PAY_timestamp' => time(),
460
+				)
461
+			);
462
+		}
463
+
464
+		// if there is billing info, clean it and save it now
465
+		if ($billing_info instanceof EE_Billing_Attendee_Info_Form) {
466
+			$this->_save_billing_info_to_attendee($billing_info, $transaction);
467
+		}
468
+
469
+		return $payment;
470
+	}
471
+
472
+	/**
473
+	 * Gets the values we want to pass onto the gateway. Normally these
474
+	 * are just the 'pretty' values, but there may be times the data may need
475
+	 * a  little massaging. Proper subsections will become arrays of inputs
476
+	 *
477
+	 * @param EE_Billing_Info_Form $billing_form
478
+	 * @return array
479
+	 */
480
+	protected function _get_billing_values_from_form($billing_form)
481
+	{
482
+		if ($billing_form instanceof EE_Form_Section_Proper) {
483
+			return $billing_form->input_pretty_values(true);
484
+		} else {
485
+			return null;
486
+		}
487
+	}
488
+
489
+
490
+	/**
491
+	 * Handles an instant payment notification when the transaction is known (by default).
492
+	 *
493
+	 * @param array          $req_data
494
+	 * @param EE_Transaction $transaction
495
+	 * @return EE_Payment
496
+	 * @throws EE_Error
497
+	 */
498
+	public function handle_ipn($req_data, $transaction)
499
+	{
500
+		$transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
501
+		if (! $this->_gateway instanceof EE_Offsite_Gateway) {
502
+			throw new EE_Error(
503
+				sprintf(
504
+					esc_html__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
505
+					print_r($this->_gateway, true)
506
+				)
507
+			);
508
+		}
509
+		$payment = $this->_gateway->handle_payment_update($req_data, $transaction);
510
+		return $payment;
511
+	}
512
+
513
+
514
+	/**
515
+	 * Saves the billing info onto the attendee of the primary registrant on this transaction, and
516
+	 * cleans it first.
517
+	 *
518
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
519
+	 * @param EE_Transaction                $transaction
520
+	 * @return boolean success
521
+	 */
522
+	protected function _save_billing_info_to_attendee($billing_form, $transaction)
523
+	{
524
+		if (! $transaction || ! $transaction instanceof EE_Transaction) {
525
+			EE_Error::add_error(
526
+				esc_html__("Cannot save billing info because no transaction was specified", "event_espresso"),
527
+				__FILE__,
528
+				__FUNCTION__,
529
+				__LINE__
530
+			);
531
+			return false;
532
+		}
533
+		$primary_reg = $transaction->primary_registration();
534
+		if (! $primary_reg) {
535
+			EE_Error::add_error(
536
+				esc_html__("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
537
+				__FILE__,
538
+				__FUNCTION__,
539
+				__LINE__
540
+			);
541
+			return false;
542
+		}
543
+		$attendee = $primary_reg->attendee();
544
+		if (! $attendee) {
545
+			EE_Error::add_error(
546
+				esc_html__(
547
+					"Cannot save billing info because the transaction's primary registration has no attendee!",
548
+					"event_espresso"
549
+				),
550
+				__FILE__,
551
+				__FUNCTION__,
552
+				__LINE__
553
+			);
554
+			return false;
555
+		}
556
+		return $attendee->save_and_clean_billing_info_for_payment_method($billing_form, $transaction->payment_method());
557
+	}
558
+
559
+
560
+	/**
561
+	 * Gets the payment this IPN is for. Children may often want to
562
+	 * override this to inspect the request
563
+	 *
564
+	 * @param EE_Transaction $transaction
565
+	 * @param array          $req_data
566
+	 * @return EE_Payment
567
+	 */
568
+	protected function find_payment_for_ipn(EE_Transaction $transaction, $req_data = array())
569
+	{
570
+		return $transaction->last_payment();
571
+	}
572
+
573
+
574
+	/**
575
+	 * In case generic code cannot provide the payment processor with a specific payment method
576
+	 * and transaction, it will try calling this method on each activate payment method.
577
+	 * If the payment method is able to identify the request as being for it, it should fetch
578
+	 * the payment its for and return it. If not, it should throw an EE_Error to indicate it cannot
579
+	 * handle the IPN
580
+	 *
581
+	 * @param array $req_data
582
+	 * @return EE_Payment only if this payment method can find the info its needs from $req_data
583
+	 * and identifies the IPN as being for this payment method (not just fo ra payment method of this type)
584
+	 * @throws EE_Error
585
+	 */
586
+	public function handle_unclaimed_ipn($req_data = array())
587
+	{
588
+		throw new EE_Error(
589
+			sprintf(esc_html__("Payment Method '%s' cannot handle unclaimed IPNs", "event_espresso"), get_class($this))
590
+		);
591
+	}
592
+
593
+
594
+	/**
595
+	 * Logic to be accomplished when the payment attempt is complete.
596
+	 * Most payment methods don't need to do anything at this point; but some, like Mijireh, do.
597
+	 * (Mijireh is an offsite gateway which doesn't send an IPN. So when the user returns to EE from
598
+	 * mijireh, this method needs to be called so the Mijireh PM can ping Mijireh to know the status
599
+	 * of the payment). Fed a transaction because it's always assumed to be the last payment that
600
+	 * we're dealing with. Returns that last payment (if there is one)
601
+	 *
602
+	 * @param EE_Transaction $transaction
603
+	 * @return EE_Payment
604
+	 */
605
+	public function finalize_payment_for($transaction)
606
+	{
607
+		return $transaction->last_payment();
608
+	}
609
+
610
+
611
+	/**
612
+	 * Whether or not this payment method's gateway supports sending refund requests
613
+	 *
614
+	 * @return boolean
615
+	 */
616
+	public function supports_sending_refunds()
617
+	{
618
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
619
+			return $this->_gateway->supports_sending_refunds();
620
+		} else {
621
+			return false;
622
+		}
623
+	}
624
+
625
+
626
+	/**
627
+	 *
628
+	 * @param EE_Payment $payment
629
+	 * @param array      $refund_info
630
+	 * @throws EE_Error
631
+	 * @return EE_Payment
632
+	 */
633
+	public function process_refund(EE_Payment $payment, $refund_info = array())
634
+	{
635
+		if ($this->_gateway && $this->_gateway instanceof EE_Gateway) {
636
+			return $this->_gateway->do_direct_refund($payment, $refund_info);
637
+		} else {
638
+			throw new EE_Error(
639
+				sprintf(
640
+					esc_html__('Payment Method Type "%s" does not support sending refund requests', 'event_espresso'),
641
+					get_class($this)
642
+				)
643
+			);
644
+		}
645
+	}
646
+
647
+
648
+	/**
649
+	 * Returns one the class's constants onsite,offsite, or offline, depending on this
650
+	 * payment method's gateway.
651
+	 *
652
+	 * @return string
653
+	 * @throws EE_Error
654
+	 */
655
+	public function payment_occurs()
656
+	{
657
+		if (! $this->_gateway) {
658
+			return EE_PMT_Base::offline;
659
+		} elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
660
+			return EE_PMT_Base::onsite;
661
+		} elseif ($this->_gateway instanceof EE_Offsite_Gateway) {
662
+			return EE_PMT_Base::offsite;
663
+		} else {
664
+			throw new EE_Error(
665
+				sprintf(
666
+					esc_html__(
667
+						"Payment method type '%s's gateway isn't an instance of EE_Onsite_Gateway, EE_Offsite_Gateway, or null. It must be one of those",
668
+						"event_espresso"
669
+					),
670
+					get_class($this)
671
+				)
672
+			);
673
+		}
674
+	}
675
+
676
+
677
+	/**
678
+	 * For adding any html output ab ove the payment overview.
679
+	 * Many gateways won't want ot display anything, so this function just returns an empty string.
680
+	 * Other gateways may want to override this, such as offline gateways.
681
+	 *
682
+	 * @param EE_Payment $payment
683
+	 * @return string
684
+	 */
685
+	public function payment_overview_content(EE_Payment $payment)
686
+	{
687
+		return EEH_Template::display_template(
688
+			EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
689
+			array('payment_method' => $this->_pm_instance, 'payment' => $payment),
690
+			true
691
+		);
692
+	}
693
+
694
+
695
+	/**
696
+	 * @return array where keys are the help tab name,
697
+	 * values are: array {
698
+	 * @type string $title         i18n name for the help tab
699
+	 * @type string $filename      name of the file located in ./help_tabs/ (ie, in a folder next to this file)
700
+	 * @type array  $template_args any arguments you want passed to the template file while rendering.
701
+	 *                Keys will be variable names and values with be their values.
702
+	 */
703
+	public function help_tabs_config()
704
+	{
705
+		return array();
706
+	}
707
+
708
+
709
+	/**
710
+	 * The system name for this PMT (eg AIM, Paypal_Pro, Invoice... what gets put into
711
+	 * the payment method's table's PMT_type column)
712
+	 *
713
+	 * @return string
714
+	 */
715
+	public function system_name()
716
+	{
717
+		$classname = get_class($this);
718
+		return str_replace("EE_PMT_", '', $classname);
719
+	}
720
+
721
+
722
+	/**
723
+	 * A pretty i18n version of the PMT name. Often the same as the "pretty_name", but you can change it by overriding
724
+	 * this method.
725
+	 * @return string
726
+	 */
727
+	public function defaultFrontendName()
728
+	{
729
+		return $this->pretty_name();
730
+	}
731
+
732
+
733
+	/**
734
+	 * A pretty i18n version of the PMT name
735
+	 *
736
+	 * @return string
737
+	 */
738
+	public function pretty_name()
739
+	{
740
+		return $this->_pretty_name;
741
+	}
742
+
743
+
744
+	/**
745
+	 * Gets the default absolute URL to the payment method type's button
746
+	 *
747
+	 * @return string
748
+	 */
749
+	public function default_button_url()
750
+	{
751
+		return $this->_default_button_url;
752
+	}
753
+
754
+
755
+	/**
756
+	 * Gets the gateway used by this payment method (if any)
757
+	 *
758
+	 * @return EE_Gateway
759
+	 */
760
+	public function get_gateway()
761
+	{
762
+		return $this->_gateway;
763
+	}
764
+
765
+
766
+	/**
767
+	 * @return string html for the link to a help tab
768
+	 */
769
+	public function get_help_tab_link()
770
+	{
771
+		return EEH_Template::get_help_tab_link(
772
+			$this->get_help_tab_name(),
773
+			'espresso_payment_settings',
774
+			'default'
775
+		);
776
+	}
777
+
778
+
779
+	/**
780
+	 * Returns the name of the help tab for this PMT
781
+	 *
782
+	 * @return string
783
+	 */
784
+	public function get_help_tab_name()
785
+	{
786
+		return 'ee_' . strtolower($this->system_name()) . '_help_tab';
787
+	}
788
+
789
+	/**
790
+	 * The name of the wp capability that should be associated with the usage of
791
+	 * this PMT by an admin
792
+	 *
793
+	 * @return string
794
+	 */
795
+	public function cap_name()
796
+	{
797
+		return 'ee_payment_method_' . strtolower($this->system_name());
798
+	}
799
+
800
+	/**
801
+	 * Called by client code to tell the gateway that if it wants to change
802
+	 * the transaction or line items or registrations related to teh payment it already
803
+	 * processed (we think, but possibly not) that now's the time to do it.
804
+	 * It is expected that gateways will store any info they need for this on the PAY_details,
805
+	 * or maybe an extra meta value
806
+	 *
807
+	 * @param EE_Payment $payment
808
+	 * @return void
809
+	 */
810
+	public function update_txn_based_on_payment($payment)
811
+	{
812
+		if ($this->_gateway instanceof EE_Gateway) {
813
+			$this->_gateway->update_txn_based_on_payment($payment);
814
+		}
815
+	}
816
+
817
+	/**
818
+	 * Returns a string of HTML describing this payment method type for an admin,
819
+	 * primarily intended for them to read before activating it.
820
+	 * The easiest way to set this is to create a folder 'templates' alongside
821
+	 * your EE_PMT_{System_Name} file, and in it create a file named "{system_name}_intro.template.php".
822
+	 * Eg, if your payment method file is named "EE_PMT_Foo_Bar.pm.php",
823
+	 * then you'd create a file named "templates" in the same folder as it, and name the file
824
+	 * "foo_bar_intro.template.php", and its content will be returned by this method
825
+	 *
826
+	 * @return string
827
+	 */
828
+	public function introductory_html()
829
+	{
830
+		return EEH_Template::locate_template(
831
+			$this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
832
+			array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
833
+		);
834
+	}
835 835
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             $this->_gateway->set_unsupported_character_remover(new AsciiOnly());
119 119
             do_action('AHEE__EE_PMT_Base___construct__done_initializing_gateway_class', $this, $this->_gateway);
120 120
         }
121
-        if (! isset($this->_has_billing_form)) {
121
+        if ( ! isset($this->_has_billing_form)) {
122 122
             // by default, On Site gateways have a billing form
123 123
             if ($this->payment_occurs() == EE_PMT_Base::onsite) {
124 124
                 $this->set_has_billing_form(true);
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
             }
128 128
         }
129 129
 
130
-        if (! $this->_pretty_name) {
130
+        if ( ! $this->_pretty_name) {
131 131
             throw new EE_Error(
132 132
                 sprintf(
133 133
                     esc_html__(
@@ -139,7 +139,7 @@  discard block
 block discarded – undo
139 139
         }
140 140
         // if the child didn't specify a default button, use the credit card one
141 141
         if ($this->_default_button_url === null) {
142
-            $this->_default_button_url = EE_PLUGIN_DIR_URL . 'payment_methods/pay-by-credit-card.png';
142
+            $this->_default_button_url = EE_PLUGIN_DIR_URL.'payment_methods/pay-by-credit-card.png';
143 143
         }
144 144
     }
145 145
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
     {
161 161
         $reflector = new ReflectionClass(get_class($this));
162 162
         $fn = $reflector->getFileName();
163
-        $this->_file_folder = dirname($fn) . '/';
163
+        $this->_file_folder = dirname($fn).'/';
164 164
     }
165 165
 
166 166
 
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
      */
194 194
     public function file_folder()
195 195
     {
196
-        if (! $this->_file_folder) {
196
+        if ( ! $this->_file_folder) {
197 197
             $this->_set_file_folder();
198 198
         }
199 199
         return $this->_file_folder;
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
      */
206 206
     public function file_url()
207 207
     {
208
-        if (! $this->_file_url) {
208
+        if ( ! $this->_file_url) {
209 209
             $this->_set_file_url();
210 210
         }
211 211
         return $this->_file_url;
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
      */
240 240
     public function settings_form()
241 241
     {
242
-        if (! $this->_settings_form) {
242
+        if ( ! $this->_settings_form) {
243 243
             $this->_settings_form = $this->generate_new_settings_form();
244 244
             $this->_settings_form->set_payment_method_type($this);
245 245
             // if we have already assigned a model object to this pmt, make
@@ -293,7 +293,7 @@  discard block
 block discarded – undo
293 293
     public function billing_form(EE_Transaction $transaction = null, $extra_args = array())
294 294
     {
295 295
         // has billing form already been regenerated ? or overwrite cache?
296
-        if (! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
296
+        if ( ! $this->_billing_form instanceof EE_Billing_Info_Form || ! $this->_cache_billing_form) {
297 297
             $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
298 298
         }
299 299
         // if we know who the attendee is, and this is a billing form
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
             $payment = EEM_Payment::instance()->get_one(array($duplicate_properties));
398 398
             // if we didn't already have a payment in progress for the same thing,
399 399
             // then we actually want to make a new payment
400
-            if (! $payment instanceof EE_Payment) {
400
+            if ( ! $payment instanceof EE_Payment) {
401 401
                 $payment = EE_Payment::new_instance(
402 402
                     array_merge(
403 403
                         $duplicate_properties,
@@ -498,7 +498,7 @@  discard block
 block discarded – undo
498 498
     public function handle_ipn($req_data, $transaction)
499 499
     {
500 500
         $transaction = EEM_Transaction::instance()->ensure_is_obj($transaction);
501
-        if (! $this->_gateway instanceof EE_Offsite_Gateway) {
501
+        if ( ! $this->_gateway instanceof EE_Offsite_Gateway) {
502 502
             throw new EE_Error(
503 503
                 sprintf(
504 504
                     esc_html__("Could not handle IPN because '%s' is not an offsite gateway", "event_espresso"),
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
      */
522 522
     protected function _save_billing_info_to_attendee($billing_form, $transaction)
523 523
     {
524
-        if (! $transaction || ! $transaction instanceof EE_Transaction) {
524
+        if ( ! $transaction || ! $transaction instanceof EE_Transaction) {
525 525
             EE_Error::add_error(
526 526
                 esc_html__("Cannot save billing info because no transaction was specified", "event_espresso"),
527 527
                 __FILE__,
@@ -531,7 +531,7 @@  discard block
 block discarded – undo
531 531
             return false;
532 532
         }
533 533
         $primary_reg = $transaction->primary_registration();
534
-        if (! $primary_reg) {
534
+        if ( ! $primary_reg) {
535 535
             EE_Error::add_error(
536 536
                 esc_html__("Cannot save billing info because the transaction has no primary registration", "event_espresso"),
537 537
                 __FILE__,
@@ -541,7 +541,7 @@  discard block
 block discarded – undo
541 541
             return false;
542 542
         }
543 543
         $attendee = $primary_reg->attendee();
544
-        if (! $attendee) {
544
+        if ( ! $attendee) {
545 545
             EE_Error::add_error(
546 546
                 esc_html__(
547 547
                     "Cannot save billing info because the transaction's primary registration has no attendee!",
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
      */
655 655
     public function payment_occurs()
656 656
     {
657
-        if (! $this->_gateway) {
657
+        if ( ! $this->_gateway) {
658 658
             return EE_PMT_Base::offline;
659 659
         } elseif ($this->_gateway instanceof EE_Onsite_Gateway) {
660 660
             return EE_PMT_Base::onsite;
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
     public function payment_overview_content(EE_Payment $payment)
686 686
     {
687 687
         return EEH_Template::display_template(
688
-            EE_LIBRARIES . 'payment_methods/templates/payment_details_content.template.php',
688
+            EE_LIBRARIES.'payment_methods/templates/payment_details_content.template.php',
689 689
             array('payment_method' => $this->_pm_instance, 'payment' => $payment),
690 690
             true
691 691
         );
@@ -783,7 +783,7 @@  discard block
 block discarded – undo
783 783
      */
784 784
     public function get_help_tab_name()
785 785
     {
786
-        return 'ee_' . strtolower($this->system_name()) . '_help_tab';
786
+        return 'ee_'.strtolower($this->system_name()).'_help_tab';
787 787
     }
788 788
 
789 789
     /**
@@ -794,7 +794,7 @@  discard block
 block discarded – undo
794 794
      */
795 795
     public function cap_name()
796 796
     {
797
-        return 'ee_payment_method_' . strtolower($this->system_name());
797
+        return 'ee_payment_method_'.strtolower($this->system_name());
798 798
     }
799 799
 
800 800
     /**
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
     public function introductory_html()
829 829
     {
830 830
         return EEH_Template::locate_template(
831
-            $this->file_folder() . 'templates/' . strtolower($this->system_name()) . '_intro.template.php',
831
+            $this->file_folder().'templates/'.strtolower($this->system_name()).'_intro.template.php',
832 832
             array('pmt_obj' => $this, 'pm_instance' => $this->_pm_instance)
833 833
         );
834 834
     }
Please login to merge, or discard this patch.