Completed
Branch models-cleanup/more-ee-base-cl... (91a157)
by
unknown
53:04 queued 43:29
created
core/domain/DomainBase.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -121,7 +121,7 @@
 block discarded – undo
121 121
 
122 122
 
123 123
     /**
124
-     * @return Version
124
+     * @return string
125 125
      */
126 126
     public function versionValueObject()
127 127
     {
Please login to merge, or discard this patch.
Indentation   +227 added lines, -227 removed lines patch added patch discarded remove patch
@@ -17,231 +17,231 @@
 block discarded – undo
17 17
 abstract class DomainBase implements DomainInterface
18 18
 {
19 19
 
20
-    const ASSETS_FOLDER = 'assets/';
21
-
22
-    /**
23
-     * Equivalent to `__FILE__` for main plugin file.
24
-     *
25
-     * @var FilePath
26
-     */
27
-    private $plugin_file;
28
-
29
-    /**
30
-     * String indicating version for plugin
31
-     *
32
-     * @var string
33
-     */
34
-    private $version;
35
-
36
-    /**
37
-     * @var string $plugin_basename
38
-     */
39
-    private $plugin_basename;
40
-
41
-    /**
42
-     * @var string $plugin_path
43
-     */
44
-    private $plugin_path;
45
-
46
-    /**
47
-     * @var string $plugin_url
48
-     */
49
-    private $plugin_url;
50
-
51
-    /**
52
-     * @var string $asset_namespace
53
-     */
54
-    private $asset_namespace;
55
-
56
-    /**
57
-     * @var string $assets_path
58
-     */
59
-    private $assets_path;
60
-
61
-    /**
62
-     * @var bool
63
-     */
64
-    protected $initialized = false;
65
-
66
-
67
-    /**
68
-     * Initializes internal properties.
69
-     *
70
-     * @param FilePath $plugin_file
71
-     * @param Version  $version
72
-     * @param string $asset_namespace
73
-     */
74
-    public function __construct(
75
-        FilePath $plugin_file,
76
-        Version $version,
77
-        string $asset_namespace = Domain::ASSET_NAMESPACE
78
-    ) {
79
-        $this->plugin_file = $plugin_file;
80
-        $this->version     = $version;
81
-        $this->initialize($asset_namespace);
82
-    }
83
-
84
-
85
-    /**
86
-     * @param string $asset_namespace
87
-     * @return void
88
-     * @since $VID:$
89
-     */
90
-    public function initialize($asset_namespace = Domain::ASSET_NAMESPACE)
91
-    {
92
-        if (! $this->initialized) {
93
-            $this->plugin_basename = plugin_basename($this->pluginFile());
94
-            $this->plugin_path     = plugin_dir_path($this->pluginFile());
95
-            $this->plugin_url      = plugin_dir_url($this->pluginFile());
96
-            $this->setAssetNamespace($asset_namespace);
97
-            $this->setDistributionAssetsPath();
98
-            $this->initialized = true;
99
-        }
100
-    }
101
-
102
-
103
-    /**
104
-     * @param string $asset_namespace
105
-     * @return void
106
-     */
107
-    public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE)
108
-    {
109
-        if (! $this->asset_namespace) {
110
-            $this->asset_namespace = sanitize_key(
111
-                // convert directory separators to dashes and remove file extension
112
-                str_replace(['/', '.php'], ['-', ''], $asset_namespace)
113
-            );
114
-        }
115
-    }
116
-
117
-
118
-    /**
119
-     * @throws DomainException
120
-     * @since $VID:$
121
-     */
122
-    private function setDistributionAssetsPath()
123
-    {
124
-        $assets_folder_paths = [
125
-            $this->plugin_path . DomainBase::ASSETS_FOLDER,
126
-            $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER,
127
-        ];
128
-        foreach ($assets_folder_paths as $assets_folder_path) {
129
-            if (is_readable($assets_folder_path)) {
130
-                $this->assets_path = trailingslashit($assets_folder_path);
131
-                // once we find a valid path, just break out of loop
132
-                break;
133
-            }
134
-        }
135
-    }
136
-
137
-
138
-    /**
139
-     * @return string
140
-     */
141
-    public function pluginFile(): string
142
-    {
143
-        return (string) $this->plugin_file;
144
-    }
145
-
146
-
147
-    /**
148
-     * @return FilePath
149
-     */
150
-    public function pluginFileObject(): FilePath
151
-    {
152
-        return $this->plugin_file;
153
-    }
154
-
155
-
156
-    /**
157
-     * @return string
158
-     */
159
-    public function pluginBasename(): string
160
-    {
161
-        return $this->plugin_basename;
162
-    }
163
-
164
-
165
-    /**
166
-     * @param string $additional_path
167
-     * @return string
168
-     */
169
-    public function pluginPath($additional_path = ''): string
170
-    {
171
-        return is_string($additional_path) && $additional_path !== ''
172
-            ? $this->plugin_path . $additional_path
173
-            : $this->plugin_path;
174
-    }
175
-
176
-
177
-    /**
178
-     * @param string $additional_path
179
-     * @return string
180
-     */
181
-    public function pluginUrl($additional_path = ''): string
182
-    {
183
-        return is_string($additional_path) && $additional_path !== ''
184
-            ? $this->plugin_url . $additional_path
185
-            : $this->plugin_url;
186
-    }
187
-
188
-
189
-    /**
190
-     * @return string
191
-     */
192
-    public function version(): string
193
-    {
194
-        return (string) $this->version;
195
-    }
196
-
197
-
198
-    /**
199
-     * @return Version
200
-     */
201
-    public function versionValueObject()
202
-    {
203
-        return $this->version;
204
-    }
205
-
206
-
207
-    /**
208
-     * @return string
209
-     */
210
-    public function distributionAssetsFolder(): string
211
-    {
212
-        return DomainBase::ASSETS_FOLDER;
213
-    }
214
-
215
-
216
-    /**
217
-     * @param string $additional_path
218
-     * @return string
219
-     */
220
-    public function distributionAssetsPath($additional_path = ''): string
221
-    {
222
-        return is_string($additional_path) && $additional_path !== ''
223
-            ? $this->assets_path . $additional_path
224
-            : $this->assets_path;
225
-    }
226
-
227
-
228
-    /**
229
-     * @param string $additional_path
230
-     * @return string
231
-     */
232
-    public function distributionAssetsUrl($additional_path = ''): string
233
-    {
234
-        return is_string($additional_path) && $additional_path !== ''
235
-            ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path
236
-            : $this->plugin_url . DomainBase::ASSETS_FOLDER;
237
-    }
238
-
239
-
240
-    /**
241
-     * @return string
242
-     */
243
-    public function assetNamespace(): string
244
-    {
245
-        return $this->asset_namespace;
246
-    }
20
+	const ASSETS_FOLDER = 'assets/';
21
+
22
+	/**
23
+	 * Equivalent to `__FILE__` for main plugin file.
24
+	 *
25
+	 * @var FilePath
26
+	 */
27
+	private $plugin_file;
28
+
29
+	/**
30
+	 * String indicating version for plugin
31
+	 *
32
+	 * @var string
33
+	 */
34
+	private $version;
35
+
36
+	/**
37
+	 * @var string $plugin_basename
38
+	 */
39
+	private $plugin_basename;
40
+
41
+	/**
42
+	 * @var string $plugin_path
43
+	 */
44
+	private $plugin_path;
45
+
46
+	/**
47
+	 * @var string $plugin_url
48
+	 */
49
+	private $plugin_url;
50
+
51
+	/**
52
+	 * @var string $asset_namespace
53
+	 */
54
+	private $asset_namespace;
55
+
56
+	/**
57
+	 * @var string $assets_path
58
+	 */
59
+	private $assets_path;
60
+
61
+	/**
62
+	 * @var bool
63
+	 */
64
+	protected $initialized = false;
65
+
66
+
67
+	/**
68
+	 * Initializes internal properties.
69
+	 *
70
+	 * @param FilePath $plugin_file
71
+	 * @param Version  $version
72
+	 * @param string $asset_namespace
73
+	 */
74
+	public function __construct(
75
+		FilePath $plugin_file,
76
+		Version $version,
77
+		string $asset_namespace = Domain::ASSET_NAMESPACE
78
+	) {
79
+		$this->plugin_file = $plugin_file;
80
+		$this->version     = $version;
81
+		$this->initialize($asset_namespace);
82
+	}
83
+
84
+
85
+	/**
86
+	 * @param string $asset_namespace
87
+	 * @return void
88
+	 * @since $VID:$
89
+	 */
90
+	public function initialize($asset_namespace = Domain::ASSET_NAMESPACE)
91
+	{
92
+		if (! $this->initialized) {
93
+			$this->plugin_basename = plugin_basename($this->pluginFile());
94
+			$this->plugin_path     = plugin_dir_path($this->pluginFile());
95
+			$this->plugin_url      = plugin_dir_url($this->pluginFile());
96
+			$this->setAssetNamespace($asset_namespace);
97
+			$this->setDistributionAssetsPath();
98
+			$this->initialized = true;
99
+		}
100
+	}
101
+
102
+
103
+	/**
104
+	 * @param string $asset_namespace
105
+	 * @return void
106
+	 */
107
+	public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE)
108
+	{
109
+		if (! $this->asset_namespace) {
110
+			$this->asset_namespace = sanitize_key(
111
+				// convert directory separators to dashes and remove file extension
112
+				str_replace(['/', '.php'], ['-', ''], $asset_namespace)
113
+			);
114
+		}
115
+	}
116
+
117
+
118
+	/**
119
+	 * @throws DomainException
120
+	 * @since $VID:$
121
+	 */
122
+	private function setDistributionAssetsPath()
123
+	{
124
+		$assets_folder_paths = [
125
+			$this->plugin_path . DomainBase::ASSETS_FOLDER,
126
+			$this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER,
127
+		];
128
+		foreach ($assets_folder_paths as $assets_folder_path) {
129
+			if (is_readable($assets_folder_path)) {
130
+				$this->assets_path = trailingslashit($assets_folder_path);
131
+				// once we find a valid path, just break out of loop
132
+				break;
133
+			}
134
+		}
135
+	}
136
+
137
+
138
+	/**
139
+	 * @return string
140
+	 */
141
+	public function pluginFile(): string
142
+	{
143
+		return (string) $this->plugin_file;
144
+	}
145
+
146
+
147
+	/**
148
+	 * @return FilePath
149
+	 */
150
+	public function pluginFileObject(): FilePath
151
+	{
152
+		return $this->plugin_file;
153
+	}
154
+
155
+
156
+	/**
157
+	 * @return string
158
+	 */
159
+	public function pluginBasename(): string
160
+	{
161
+		return $this->plugin_basename;
162
+	}
163
+
164
+
165
+	/**
166
+	 * @param string $additional_path
167
+	 * @return string
168
+	 */
169
+	public function pluginPath($additional_path = ''): string
170
+	{
171
+		return is_string($additional_path) && $additional_path !== ''
172
+			? $this->plugin_path . $additional_path
173
+			: $this->plugin_path;
174
+	}
175
+
176
+
177
+	/**
178
+	 * @param string $additional_path
179
+	 * @return string
180
+	 */
181
+	public function pluginUrl($additional_path = ''): string
182
+	{
183
+		return is_string($additional_path) && $additional_path !== ''
184
+			? $this->plugin_url . $additional_path
185
+			: $this->plugin_url;
186
+	}
187
+
188
+
189
+	/**
190
+	 * @return string
191
+	 */
192
+	public function version(): string
193
+	{
194
+		return (string) $this->version;
195
+	}
196
+
197
+
198
+	/**
199
+	 * @return Version
200
+	 */
201
+	public function versionValueObject()
202
+	{
203
+		return $this->version;
204
+	}
205
+
206
+
207
+	/**
208
+	 * @return string
209
+	 */
210
+	public function distributionAssetsFolder(): string
211
+	{
212
+		return DomainBase::ASSETS_FOLDER;
213
+	}
214
+
215
+
216
+	/**
217
+	 * @param string $additional_path
218
+	 * @return string
219
+	 */
220
+	public function distributionAssetsPath($additional_path = ''): string
221
+	{
222
+		return is_string($additional_path) && $additional_path !== ''
223
+			? $this->assets_path . $additional_path
224
+			: $this->assets_path;
225
+	}
226
+
227
+
228
+	/**
229
+	 * @param string $additional_path
230
+	 * @return string
231
+	 */
232
+	public function distributionAssetsUrl($additional_path = ''): string
233
+	{
234
+		return is_string($additional_path) && $additional_path !== ''
235
+			? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path
236
+			: $this->plugin_url . DomainBase::ASSETS_FOLDER;
237
+	}
238
+
239
+
240
+	/**
241
+	 * @return string
242
+	 */
243
+	public function assetNamespace(): string
244
+	{
245
+		return $this->asset_namespace;
246
+	}
247 247
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function initialize($asset_namespace = Domain::ASSET_NAMESPACE)
91 91
     {
92
-        if (! $this->initialized) {
92
+        if ( ! $this->initialized) {
93 93
             $this->plugin_basename = plugin_basename($this->pluginFile());
94 94
             $this->plugin_path     = plugin_dir_path($this->pluginFile());
95 95
             $this->plugin_url      = plugin_dir_url($this->pluginFile());
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
      */
107 107
     public function setAssetNamespace($asset_namespace = Domain::ASSET_NAMESPACE)
108 108
     {
109
-        if (! $this->asset_namespace) {
109
+        if ( ! $this->asset_namespace) {
110 110
             $this->asset_namespace = sanitize_key(
111 111
                 // convert directory separators to dashes and remove file extension
112 112
                 str_replace(['/', '.php'], ['-', ''], $asset_namespace)
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
     private function setDistributionAssetsPath()
123 123
     {
124 124
         $assets_folder_paths = [
125
-            $this->plugin_path . DomainBase::ASSETS_FOLDER,
126
-            $this->plugin_path . 'src/' . DomainBase::ASSETS_FOLDER,
125
+            $this->plugin_path.DomainBase::ASSETS_FOLDER,
126
+            $this->plugin_path.'src/'.DomainBase::ASSETS_FOLDER,
127 127
         ];
128 128
         foreach ($assets_folder_paths as $assets_folder_path) {
129 129
             if (is_readable($assets_folder_path)) {
@@ -169,7 +169,7 @@  discard block
 block discarded – undo
169 169
     public function pluginPath($additional_path = ''): string
170 170
     {
171 171
         return is_string($additional_path) && $additional_path !== ''
172
-            ? $this->plugin_path . $additional_path
172
+            ? $this->plugin_path.$additional_path
173 173
             : $this->plugin_path;
174 174
     }
175 175
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
     public function pluginUrl($additional_path = ''): string
182 182
     {
183 183
         return is_string($additional_path) && $additional_path !== ''
184
-            ? $this->plugin_url . $additional_path
184
+            ? $this->plugin_url.$additional_path
185 185
             : $this->plugin_url;
186 186
     }
187 187
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
     public function distributionAssetsPath($additional_path = ''): string
221 221
     {
222 222
         return is_string($additional_path) && $additional_path !== ''
223
-            ? $this->assets_path . $additional_path
223
+            ? $this->assets_path.$additional_path
224 224
             : $this->assets_path;
225 225
     }
226 226
 
@@ -232,8 +232,8 @@  discard block
 block discarded – undo
232 232
     public function distributionAssetsUrl($additional_path = ''): string
233 233
     {
234 234
         return is_string($additional_path) && $additional_path !== ''
235
-            ? $this->plugin_url . DomainBase::ASSETS_FOLDER . $additional_path
236
-            : $this->plugin_url . DomainBase::ASSETS_FOLDER;
235
+            ? $this->plugin_url.DomainBase::ASSETS_FOLDER.$additional_path
236
+            : $this->plugin_url.DomainBase::ASSETS_FOLDER;
237 237
     }
238 238
 
239 239
 
Please login to merge, or discard this patch.
core/domain/entities/contexts/RequestTypeContext.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -91,7 +91,7 @@
 block discarded – undo
91 91
     public function __construct($slug, $description)
92 92
     {
93 93
         parent::__construct($slug, $description);
94
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
94
+        if ( ! in_array($this->slug(), $this->validRequestTypes(), true)) {
95 95
             throw new InvalidArgumentException(
96 96
                 sprintf(
97 97
                     esc_html__(
Please login to merge, or discard this patch.
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -16,185 +16,185 @@
 block discarded – undo
16 16
 class RequestTypeContext extends Context
17 17
 {
18 18
 
19
-    /**
20
-     * indicates that the current request involves some form of activation
21
-     */
22
-    const ACTIVATION = 'activation-request';
23
-
24
-    /**
25
-     * indicates that the current request is for the admin but is not being made via AJAX
26
-     */
27
-    const ADMIN = 'non-ajax-admin-request';
28
-
29
-    /**
30
-     * indicates that the current request is for the admin AND is being made via AJAX
31
-     */
32
-    const AJAX_ADMIN = 'admin-ajax-request';
33
-
34
-    /**
35
-     * indicates that the current request is for the frontend AND is being made via AJAX
36
-     */
37
-    const AJAX_FRONT = 'frontend-ajax-request';
38
-
39
-    /**
40
-     * indicates that the current request is for the WP Heartbeat
41
-     */
42
-    const AJAX_HEARTBEAT = 'admin-ajax-heartbeat';
43
-
44
-    /**
45
-     * indicates that the current request is being made via AJAX, but is NOT for EE
46
-     */
47
-    const AJAX_OTHER = 'other-ajax-request';
48
-
49
-    /**
50
-     * indicates that the current request is for the EE REST API
51
-     */
52
-    const API = 'rest-api';
53
-
54
-    /**
55
-     * indicates that the current request is from the command line
56
-     */
57
-    const CLI = 'command-line';
58
-
59
-    /**
60
-     * indicates that the current request is for a WP_Cron
61
-     */
62
-    const CRON = 'wp-cron';
63
-
64
-    /**
65
-     * indicates that the current request is for a feed (ie: RSS)
66
-     */
67
-    const FEED = 'feed-request';
68
-
69
-    /**
70
-     * indicates that the current request is for the frontend but is not being made via AJAX
71
-     */
72
-    const FRONTEND = 'non-ajax-frontend-request';
73
-
74
-    /**
75
-     * indicates that the current request is for content that is to be displayed within an iframe
76
-     */
77
-    const IFRAME = 'iframe-request';
78
-
79
-    /**
80
-     * indicates that the current request is for the EE GraphQL manager
81
-     */
82
-    const GQL = 'graphql';
83
-
84
-    /**
85
-     * indicates that the current request is for the WP REST API
86
-     */
87
-    const WP_API = 'wp-rest-api';
88
-
89
-    /**
90
-     * indicates that the current request is a loopback sent from WP core to test for errors
91
-     */
92
-    const WP_SCRAPE = 'wordpress-scrape';
93
-
94
-    /**
95
-     * @var boolean $is_activation
96
-     */
97
-    private $is_activation = false;
98
-
99
-    /**
100
-     * @var boolean $is_unit_testing
101
-     */
102
-    private $is_unit_testing = false;
103
-
104
-    /**
105
-     * @var array $valid_request_types
106
-     */
107
-    private $valid_request_types = array();
108
-
109
-
110
-    /**
111
-     * RequestTypeContext constructor.
112
-     *
113
-     * @param string $slug
114
-     * @param string $description
115
-     * @throws InvalidArgumentException
116
-     */
117
-    public function __construct($slug, $description)
118
-    {
119
-        parent::__construct($slug, $description);
120
-        if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
121
-            throw new InvalidArgumentException(
122
-                sprintf(
123
-                    esc_html__(
124
-                        'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
125
-                        'event_espresso'
126
-                    ),
127
-                    '<br />',
128
-                    var_export($this->validRequestTypes(), true)
129
-                )
130
-            );
131
-        }
132
-    }
133
-
134
-
135
-    /**
136
-     * @return array
137
-     */
138
-    public function validRequestTypes()
139
-    {
140
-        if (empty($this->valid_request_types)) {
141
-            $this->valid_request_types = apply_filters(
142
-                'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
143
-                array(
144
-                    RequestTypeContext::ACTIVATION,
145
-                    RequestTypeContext::ADMIN,
146
-                    RequestTypeContext::AJAX_ADMIN,
147
-                    RequestTypeContext::AJAX_FRONT,
148
-                    RequestTypeContext::AJAX_HEARTBEAT,
149
-                    RequestTypeContext::AJAX_OTHER,
150
-                    RequestTypeContext::API,
151
-                    RequestTypeContext::CLI,
152
-                    RequestTypeContext::CRON,
153
-                    RequestTypeContext::FEED,
154
-                    RequestTypeContext::FRONTEND,
155
-                    RequestTypeContext::GQL,
156
-                    RequestTypeContext::IFRAME,
157
-                    RequestTypeContext::WP_API,
158
-                    RequestTypeContext::WP_SCRAPE,
159
-                )
160
-            );
161
-        }
162
-        return $this->valid_request_types;
163
-    }
164
-
165
-
166
-    /**
167
-     * @return bool
168
-     */
169
-    public function isActivation()
170
-    {
171
-        return $this->is_activation;
172
-    }
173
-
174
-
175
-    /**
176
-     * @param bool $is_activation
177
-     */
178
-    public function setIsActivation($is_activation = false)
179
-    {
180
-        $this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
181
-    }
182
-
183
-
184
-    /**
185
-     * @return bool
186
-     */
187
-    public function isUnitTesting()
188
-    {
189
-        return $this->is_unit_testing;
190
-    }
191
-
192
-
193
-    /**
194
-     * @param bool $is_unit_testing
195
-     */
196
-    public function setIsUnitTesting($is_unit_testing = false)
197
-    {
198
-        $this->is_unit_testing = filter_var($is_unit_testing, FILTER_VALIDATE_BOOLEAN);
199
-    }
19
+	/**
20
+	 * indicates that the current request involves some form of activation
21
+	 */
22
+	const ACTIVATION = 'activation-request';
23
+
24
+	/**
25
+	 * indicates that the current request is for the admin but is not being made via AJAX
26
+	 */
27
+	const ADMIN = 'non-ajax-admin-request';
28
+
29
+	/**
30
+	 * indicates that the current request is for the admin AND is being made via AJAX
31
+	 */
32
+	const AJAX_ADMIN = 'admin-ajax-request';
33
+
34
+	/**
35
+	 * indicates that the current request is for the frontend AND is being made via AJAX
36
+	 */
37
+	const AJAX_FRONT = 'frontend-ajax-request';
38
+
39
+	/**
40
+	 * indicates that the current request is for the WP Heartbeat
41
+	 */
42
+	const AJAX_HEARTBEAT = 'admin-ajax-heartbeat';
43
+
44
+	/**
45
+	 * indicates that the current request is being made via AJAX, but is NOT for EE
46
+	 */
47
+	const AJAX_OTHER = 'other-ajax-request';
48
+
49
+	/**
50
+	 * indicates that the current request is for the EE REST API
51
+	 */
52
+	const API = 'rest-api';
53
+
54
+	/**
55
+	 * indicates that the current request is from the command line
56
+	 */
57
+	const CLI = 'command-line';
58
+
59
+	/**
60
+	 * indicates that the current request is for a WP_Cron
61
+	 */
62
+	const CRON = 'wp-cron';
63
+
64
+	/**
65
+	 * indicates that the current request is for a feed (ie: RSS)
66
+	 */
67
+	const FEED = 'feed-request';
68
+
69
+	/**
70
+	 * indicates that the current request is for the frontend but is not being made via AJAX
71
+	 */
72
+	const FRONTEND = 'non-ajax-frontend-request';
73
+
74
+	/**
75
+	 * indicates that the current request is for content that is to be displayed within an iframe
76
+	 */
77
+	const IFRAME = 'iframe-request';
78
+
79
+	/**
80
+	 * indicates that the current request is for the EE GraphQL manager
81
+	 */
82
+	const GQL = 'graphql';
83
+
84
+	/**
85
+	 * indicates that the current request is for the WP REST API
86
+	 */
87
+	const WP_API = 'wp-rest-api';
88
+
89
+	/**
90
+	 * indicates that the current request is a loopback sent from WP core to test for errors
91
+	 */
92
+	const WP_SCRAPE = 'wordpress-scrape';
93
+
94
+	/**
95
+	 * @var boolean $is_activation
96
+	 */
97
+	private $is_activation = false;
98
+
99
+	/**
100
+	 * @var boolean $is_unit_testing
101
+	 */
102
+	private $is_unit_testing = false;
103
+
104
+	/**
105
+	 * @var array $valid_request_types
106
+	 */
107
+	private $valid_request_types = array();
108
+
109
+
110
+	/**
111
+	 * RequestTypeContext constructor.
112
+	 *
113
+	 * @param string $slug
114
+	 * @param string $description
115
+	 * @throws InvalidArgumentException
116
+	 */
117
+	public function __construct($slug, $description)
118
+	{
119
+		parent::__construct($slug, $description);
120
+		if (! in_array($this->slug(), $this->validRequestTypes(), true)) {
121
+			throw new InvalidArgumentException(
122
+				sprintf(
123
+					esc_html__(
124
+						'The RequestTypeContext slug must be one of the following values: %1$s %2$s',
125
+						'event_espresso'
126
+					),
127
+					'<br />',
128
+					var_export($this->validRequestTypes(), true)
129
+				)
130
+			);
131
+		}
132
+	}
133
+
134
+
135
+	/**
136
+	 * @return array
137
+	 */
138
+	public function validRequestTypes()
139
+	{
140
+		if (empty($this->valid_request_types)) {
141
+			$this->valid_request_types = apply_filters(
142
+				'FHEE__EventEspresso_core_domain_entities_contexts_RequestTypeContext__validRequestTypes',
143
+				array(
144
+					RequestTypeContext::ACTIVATION,
145
+					RequestTypeContext::ADMIN,
146
+					RequestTypeContext::AJAX_ADMIN,
147
+					RequestTypeContext::AJAX_FRONT,
148
+					RequestTypeContext::AJAX_HEARTBEAT,
149
+					RequestTypeContext::AJAX_OTHER,
150
+					RequestTypeContext::API,
151
+					RequestTypeContext::CLI,
152
+					RequestTypeContext::CRON,
153
+					RequestTypeContext::FEED,
154
+					RequestTypeContext::FRONTEND,
155
+					RequestTypeContext::GQL,
156
+					RequestTypeContext::IFRAME,
157
+					RequestTypeContext::WP_API,
158
+					RequestTypeContext::WP_SCRAPE,
159
+				)
160
+			);
161
+		}
162
+		return $this->valid_request_types;
163
+	}
164
+
165
+
166
+	/**
167
+	 * @return bool
168
+	 */
169
+	public function isActivation()
170
+	{
171
+		return $this->is_activation;
172
+	}
173
+
174
+
175
+	/**
176
+	 * @param bool $is_activation
177
+	 */
178
+	public function setIsActivation($is_activation = false)
179
+	{
180
+		$this->is_activation = filter_var($is_activation, FILTER_VALIDATE_BOOLEAN);
181
+	}
182
+
183
+
184
+	/**
185
+	 * @return bool
186
+	 */
187
+	public function isUnitTesting()
188
+	{
189
+		return $this->is_unit_testing;
190
+	}
191
+
192
+
193
+	/**
194
+	 * @param bool $is_unit_testing
195
+	 */
196
+	public function setIsUnitTesting($is_unit_testing = false)
197
+	{
198
+		$this->is_unit_testing = filter_var($is_unit_testing, FILTER_VALIDATE_BOOLEAN);
199
+	}
200 200
 }
Please login to merge, or discard this patch.
core/libraries/messages/validators/EE_Messages_Validator.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -505,7 +505,7 @@
 block discarded – undo
505 505
      *
506 506
      * @param  string $value            string to evaluate
507 507
      * @param  array  $valid_shortcodes array of shortcodes that are acceptable.
508
-     * @return mixed (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
508
+     * @return false|string (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
509 509
      */
510 510
     protected function _invalid_shortcodes($value, $valid_shortcodes)
511 511
     {
Please login to merge, or discard this patch.
Indentation   +624 added lines, -624 removed lines patch added patch discarded remove patch
@@ -17,628 +17,628 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * These properties just hold the name for the Messenger and Message Type (defined by child classes).
22
-     * These are used for retrieving objects etc.
23
-     *
24
-     * @var string
25
-     */
26
-    protected $_m_name;
27
-    protected $_mt_name;
28
-
29
-
30
-    /**
31
-     * This will hold any error messages from the validation process.
32
-     * The _errors property holds an associative array of error messages
33
-     * listing the field as the key and the message as the value.
34
-     *
35
-     * @var array()
36
-     */
37
-    private $_errors = array();
38
-
39
-
40
-    /**
41
-     * holds an array of fields being validated
42
-     *
43
-     * @var array
44
-     */
45
-    protected $_fields;
46
-
47
-
48
-    /**
49
-     * this will hold the incoming context
50
-     *
51
-     * @var string
52
-     */
53
-    protected $_context;
54
-
55
-
56
-    /**
57
-     * this holds an array of fields and the relevant validation information
58
-     * that the incoming fields data get validated against.
59
-     * This gets setup in the _set_props() method.
60
-     *
61
-     * @var array
62
-     */
63
-    protected $_validators;
64
-
65
-
66
-    /**
67
-     * holds the messenger object
68
-     *
69
-     * @var object
70
-     */
71
-    protected $_messenger;
72
-
73
-
74
-    /**
75
-     * holds the message type object
76
-     *
77
-     * @var object
78
-     */
79
-    protected $_message_type;
80
-
81
-
82
-    /**
83
-     * will hold any valid_shortcode modifications made by the _modify_validator() method.
84
-     *
85
-     * @var array
86
-     */
87
-    protected $_valid_shortcodes_modifier;
88
-
89
-
90
-    /**
91
-     * There may be times where a message type wants to include a shortcode group but exclude specific
92
-     * shortcodes.  If that's the case then it can set this property as an array of shortcodes to exclude and
93
-     * they will not be allowed.
94
-     * Array should be indexed by field and values are an array of specific shortcodes to exclude.
95
-     *
96
-     * @var array
97
-     */
98
-    protected $_specific_shortcode_excludes = array();
99
-
100
-
101
-    /**
102
-     * Runs the validator using the incoming fields array as the fields/values to check.
103
-     *
104
-     * @param array $fields The fields sent by the EEM object.
105
-     * @param       $context
106
-     * @throws EE_Error
107
-     * @throws ReflectionException
108
-     */
109
-    public function __construct($fields, $context)
110
-    {
111
-        // check that _m_name and _mt_name have been set by child class otherwise we get out.
112
-        if (empty($this->_m_name) || empty($this->_mt_name)) {
113
-            throw new EE_Error(
114
-                esc_html__(
115
-                    'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property.  Check that the child class is doing this',
116
-                    'event_espresso'
117
-                )
118
-            );
119
-        }
120
-        $this->_fields  = $fields;
121
-        $this->_context = $context;
122
-
123
-        // load messenger and message_type objects and the related shortcode objects.
124
-        $this->_load_objects();
125
-
126
-
127
-        // modify any messenger/message_type specific validation instructions.  This is what child classes define.
128
-        $this->_modify_validator();
129
-
130
-
131
-        // let's set validators property
132
-        $this->_set_validators();
133
-    }
134
-
135
-
136
-    /**
137
-     * Child classes instantiate this and use it to modify the _validator_config array property
138
-     * for the messenger using messengers set_validate_config() method.
139
-     * This is so we can specify specific validation instructions for a messenger/message_type combo
140
-     * that aren't handled by the defaults setup in the messenger.
141
-     *
142
-     * @abstract
143
-     * @access protected
144
-     * @return void
145
-     */
146
-    abstract protected function _modify_validator();
147
-
148
-
149
-    /**
150
-     * loads all objects used by validator
151
-     *
152
-     * @access private
153
-     * @throws \EE_Error
154
-     */
155
-    private function _load_objects()
156
-    {
157
-        // load messenger
158
-        $messenger = ucwords(str_replace('_', ' ', $this->_m_name));
159
-        $messenger = str_replace(' ', '_', $messenger);
160
-        $messenger = 'EE_' . $messenger . '_messenger';
161
-
162
-        if (! class_exists($messenger)) {
163
-            throw new EE_Error(
164
-                sprintf(
165
-                    esc_html__('There is no messenger class for the given string (%s)', 'event_espresso'),
166
-                    $this->_m_name
167
-                )
168
-            );
169
-        }
170
-
171
-        $this->_messenger = new $messenger();
172
-
173
-        // load message type
174
-        $message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
175
-        $message_type = str_replace(' ', '_', $message_type);
176
-        $message_type = 'EE_' . $message_type . '_message_type';
177
-
178
-        if (! class_exists($message_type)) {
179
-            throw new EE_Error(
180
-                sprintf(
181
-                    esc_html__('There is no message type class for the given string (%s)', 'event_espresso'),
182
-                    $this->_mt_name
183
-                )
184
-            );
185
-        }
186
-
187
-        $this->_message_type = new $message_type();
188
-    }
189
-
190
-
191
-    /**
192
-     * used to set the $_validators property
193
-     *
194
-     * @access private
195
-     * @return void
196
-     * @throws ReflectionException
197
-     */
198
-    private function _set_validators()
199
-    {
200
-        // let's get all valid shortcodes from mt and message type
201
-        // (messenger will have its set in the _validator_config property for the messenger)
202
-        $mt_codes = $this->_message_type->get_valid_shortcodes();
203
-
204
-
205
-        // get messenger validator_config
206
-        $msgr_validator = $this->_messenger->get_validator_config();
207
-
208
-
209
-        // we only want the valid shortcodes for the given context!
210
-        $context  = $this->_context;
211
-        $mt_codes = $mt_codes[ $context ];
212
-
213
-        // in this first loop we're just getting all shortcode group indexes from the msgr_validator
214
-        // into a single array (so we can get the appropriate shortcode objects for the groups)
215
-        $shortcode_groups = $mt_codes;
216
-        $groups_per_field = array();
217
-
218
-        foreach ($msgr_validator as $field => $config) {
219
-            if (empty($config) || ! isset($config['shortcodes'])) {
220
-                continue;
221
-            }  //Nothing to see here.
222
-            $groups_per_field[ $field ] = array_intersect($config['shortcodes'], $mt_codes);
223
-            $shortcode_groups         = array_merge($config['shortcodes'], $shortcode_groups);
224
-        }
225
-
226
-        $shortcode_groups = array_unique($shortcode_groups);
227
-
228
-        // okay now we've got our groups.
229
-        // Let's get the codes from the objects into an array indexed by group for easy retrieval later.
230
-        $codes_from_objs = array();
231
-
232
-        foreach ($shortcode_groups as $group) {
233
-            $ref       = ucwords(str_replace('_', ' ', $group));
234
-            $ref       = str_replace(' ', '_', $ref);
235
-            $classname = 'EE_' . $ref . '_Shortcodes';
236
-            if (class_exists($classname)) {
237
-                $a                       = new ReflectionClass($classname);
238
-                $obj                     = $a->newInstance();
239
-                $codes_from_objs[ $group ] = $obj->get_shortcodes();
240
-            }
241
-        }
242
-
243
-
244
-        // let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
245
-        $final_mt_codes = array();
246
-        foreach ($mt_codes as $group) {
247
-            $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[ $group ]);
248
-        }
249
-
250
-        $mt_codes = $final_mt_codes;
251
-
252
-
253
-        // k now in this next loop we're going to loop through $msgr_validator again
254
-        // and setup the _validators property from the data we've setup so far.
255
-        foreach ($msgr_validator as $field => $config) {
256
-            // if required shortcode is not in our list of codes for the given field, then we skip this field.
257
-            $required = isset($config['required'])
258
-                ? array_intersect($config['required'], array_keys($mt_codes))
259
-                : true;
260
-            if (empty($required)) {
261
-                continue;
262
-            }
263
-
264
-            if (isset($this->_valid_shortcodes_modifier[ $context ][ $field ])) {
265
-                // If we have an override then we use it to indicate the codes we want.
266
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
267
-                    $this->_valid_shortcodes_modifier[ $context ][ $field ],
268
-                    $codes_from_objs
269
-                );
270
-            } elseif (isset($groups_per_field[ $field ])) {
271
-                // if we have specific shortcodes for a field then we need to use them
272
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
273
-                    $groups_per_field[ $field ],
274
-                    $codes_from_objs
275
-                );
276
-            } elseif (empty($config)) {
277
-                // if empty config then we're assuming we're just going to use the shortcodes from the message type
278
-                // context
279
-                $this->_validators[ $field ]['shortcodes'] = $mt_codes;
280
-            } elseif (isset($config['specific_shortcodes'])) {
281
-                // if we have specific shortcodes then we need to use them
282
-                $this->_validators[ $field ]['shortcodes'] = $config['specific_shortcodes'];
283
-            } else {
284
-                // otherwise the shortcodes are what is set by the messenger for that field
285
-                foreach ($config['shortcodes'] as $group) {
286
-                    $this->_validators[ $field ]['shortcodes'] = isset($this->_validators[ $field ]['shortcodes'])
287
-                        ? array_merge($this->_validators[ $field ]['shortcodes'], $codes_from_objs[ $group ])
288
-                        : $codes_from_objs[ $group ];
289
-                }
290
-            }
291
-
292
-            // now let's just make sure that any excluded specific shortcodes are removed.
293
-            $specific_excludes = $this->get_specific_shortcode_excludes();
294
-            if (isset($specific_excludes[ $field ])) {
295
-                foreach ($specific_excludes[ $field ] as $sex) {
296
-                    if (isset($this->_validators[ $field ]['shortcodes'][ $sex ])) {
297
-                        unset($this->_validators[ $field ]['shortcodes'][ $sex ]);
298
-                    }
299
-                }
300
-            }
301
-
302
-            // hey! don't forget to include the type if present!
303
-            $this->_validators[ $field ]['type'] = isset($config['type']) ? $config['type'] : null;
304
-        }
305
-    }
306
-
307
-
308
-    /**
309
-     * This just returns the validators property that contains information
310
-     * about the various shortcodes and their availability with each field
311
-     *
312
-     * @return array
313
-     */
314
-    public function get_validators()
315
-    {
316
-        return $this->_validators;
317
-    }
318
-
319
-
320
-    /**
321
-     * This simply returns the specific shortcode_excludes property that is set.
322
-     *
323
-     * @since 4.5.0
324
-     * @return array
325
-     */
326
-    public function get_specific_shortcode_excludes()
327
-    {
328
-        // specific validator filter
329
-        $shortcode_excludes = apply_filters(
330
-            'FHEE__' . get_class($this) . '__get_specific_shortcode_excludes;',
331
-            $this->_specific_shortcode_excludes,
332
-            $this->_context
333
-        );
334
-        // global filter
335
-        return apply_filters(
336
-            'FHEE__EE_Messages_Validator__get_specific_shortcode_excludes',
337
-            $shortcode_excludes,
338
-            $this->_context,
339
-            $this
340
-        );
341
-    }
342
-
343
-
344
-    /**
345
-     * This is the main method that handles validation
346
-     * What it does is loop through the _fields (the ones that get validated)
347
-     * and checks them against the shortcodes array for the field and the 'type' indicated by the
348
-     *
349
-     * @access public
350
-     * @return mixed (bool|array)  if errors present we return the array otherwise true
351
-     */
352
-    public function validate()
353
-    {
354
-        // some defaults
355
-        $template_fields = $this->_messenger->get_template_fields();
356
-        // loop through the fields and check!
357
-        foreach ($this->_fields as $field => $value) {
358
-            $this->_errors[ $field ] = array();
359
-            $err_msg               = '';
360
-            $field_label           = '';
361
-            // if field is not present in the _validators array then we continue
362
-            if (! isset($this->_validators[ $field ])) {
363
-                unset($this->_errors[ $field ]);
364
-                continue;
365
-            }
366
-
367
-            // get the translated field label!
368
-            // first check if it's in the main fields list
369
-            if (isset($template_fields[ $field ])) {
370
-                if (empty($template_fields[ $field ])) {
371
-                    $field_label = $field;
372
-                } else {
373
-                    // most likely the field is found in the 'extra' array.
374
-                    $field_label = $template_fields[ $field ]['label'];
375
-                }
376
-            }
377
-
378
-            // if field label is empty OR is equal to the current field
379
-            // then we need to loop through the 'extra' fields in the template_fields config (if present)
380
-            if (isset($template_fields['extra']) && (empty($field_label) || $field_label === $field)) {
381
-                foreach ($template_fields['extra'] as $main_field => $secondary_field) {
382
-                    foreach ($secondary_field as $name => $values) {
383
-                        if ($name === $field) {
384
-                            $field_label = $values['label'];
385
-                        }
386
-
387
-                        // if we've got a 'main' secondary field, let's see if that matches what field we're on
388
-                        // which means it contains the label for this field.
389
-                        if ($name === 'main' && $main_field === $field_label) {
390
-                            $field_label = $values['label'];
391
-                        }
392
-                    }
393
-                }
394
-            }
395
-
396
-            // field is present. Let's validate shortcodes first (but only if shortcodes present).
397
-            if (
398
-                isset($this->_validators[ $field ]['shortcodes'])
399
-                && ! empty($this->_validators[ $field ]['shortcodes'])
400
-            ) {
401
-                $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[ $field ]['shortcodes']);
402
-                // if true then that means there is a returned error message
403
-                // that we'll need to add to the _errors array for this field.
404
-                if ($invalid_shortcodes) {
405
-                    $v_s     = array_keys($this->_validators[ $field ]['shortcodes']);
406
-                    $err_msg = sprintf(
407
-                        esc_html__(
408
-                            '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
409
-                            'event_espresso'
410
-                        ),
411
-                        '<strong>' . $field_label . '</strong>',
412
-                        $invalid_shortcodes,
413
-                        '<p>',
414
-                        '</p >'
415
-                    );
416
-                    $err_msg .= sprintf(
417
-                        esc_html__('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'),
418
-                        implode(', ', $v_s),
419
-                        '<strong>',
420
-                        '</strong>'
421
-                    );
422
-                }
423
-            }
424
-
425
-            // if there's a "type" to be validated then let's do that too.
426
-            if (isset($this->_validators[ $field ]['type']) && ! empty($this->_validators[ $field ]['type'])) {
427
-                switch ($this->_validators[ $field ]['type']) {
428
-                    case 'number':
429
-                        if (! is_numeric($value)) {
430
-                            $err_msg .= sprintf(
431
-                                esc_html__(
432
-                                    '%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
433
-                                    'event_espresso'
434
-                                ),
435
-                                $field_label,
436
-                                $value,
437
-                                '<p>',
438
-                                '</p >'
439
-                            );
440
-                        }
441
-                        break;
442
-                    case 'email':
443
-                        $valid_email = $this->_validate_email($value);
444
-                        if (! $valid_email) {
445
-                            $err_msg .= htmlentities(
446
-                                sprintf(
447
-                                    esc_html__(
448
-                                        'The %1$s field has at least one string that is not a valid email address record.  Valid emails are in the format: "Name <[email protected]>" or "[email protected]" and multiple emails can be separated by a comma.',
449
-                                        'event_espresso'
450
-                                    ),
451
-                                    $field_label
452
-                                )
453
-                            );
454
-                        }
455
-                        break;
456
-                    default:
457
-                        break;
458
-                }
459
-            }
460
-
461
-            // if $err_msg isn't empty let's setup the _errors array for this field.
462
-            if (! empty($err_msg)) {
463
-                $this->_errors[ $field ]['msg'] = $err_msg;
464
-            } else {
465
-                unset($this->_errors[ $field ]);
466
-            }
467
-        }
468
-
469
-        // if we have ANY errors, then we want to make sure we return the values
470
-        // for ALL the fields so the user doesn't have to retype them all.
471
-        if (! empty($this->_errors)) {
472
-            foreach ($this->_fields as $field => $value) {
473
-                $this->_errors[ $field ]['value'] = stripslashes($value);
474
-            }
475
-        }
476
-
477
-        // return any errors or just TRUE if everything validates
478
-        return empty($this->_errors) ? true : $this->_errors;
479
-    }
480
-
481
-
482
-    /**
483
-     * Reassembles and returns an array of valid shortcodes
484
-     * given the array of groups and array of shortcodes indexed by group.
485
-     *
486
-     * @param  array $groups          array of shortcode groups that we want shortcodes for
487
-     * @param  array $codes_from_objs All the codes available.
488
-     * @return array                   an array of actual shortcodes (that will be used for validation).
489
-     */
490
-    private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs)
491
-    {
492
-        $shortcodes = array();
493
-        foreach ($groups as $group) {
494
-            $shortcodes = array_merge($shortcodes, $codes_from_objs[ $group ]);
495
-        }
496
-        return $shortcodes;
497
-    }
498
-
499
-
500
-    /**
501
-     * Validates a string against a list of accepted shortcodes
502
-     * This function takes in an array of shortcodes
503
-     * and makes sure that the given string ONLY contains shortcodes in that array.
504
-     *
505
-     * @param  string $value            string to evaluate
506
-     * @param  array  $valid_shortcodes array of shortcodes that are acceptable.
507
-     * @return mixed (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
508
-     */
509
-    protected function _invalid_shortcodes($value, $valid_shortcodes)
510
-    {
511
-        // first we need to go through the string and get the shortcodes in the string
512
-        preg_match_all('/(\[.+?\])/', $value, $matches);
513
-        $incoming_shortcodes = (array) $matches[0];
514
-
515
-        // get a diff of the shortcodes in the string vs the valid shortcodes
516
-        $diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes));
517
-
518
-        // we need to account for custom codes so let's loop through the diff and remove any of those type of codes
519
-        foreach ($diff as $ind => $code) {
520
-            if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) {
521
-                // strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
522
-                $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
523
-                // does this exist in the $valid_shortcodes?  If so then unset.
524
-                if (isset($valid_shortcodes[ $dynamic_sc ])) {
525
-                    unset($diff[ $ind ]);
526
-                }
527
-            }
528
-        }
529
-
530
-        if (empty($diff)) {
531
-            return false;
532
-        } //there is no diff, we have no invalid shortcodes, so return
533
-
534
-        // made it here? then let's assemble the error message
535
-        $invalid_shortcodes = implode('</strong>,<strong>', $diff);
536
-        $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
537
-        return $invalid_shortcodes;
538
-    }
539
-
540
-
541
-    /**
542
-     * Validates an incoming string and makes sure we have valid emails in the string.
543
-     *
544
-     * @param  string $value incoming value to validate
545
-     * @return bool        true if the string validates, false if it doesn't
546
-     */
547
-    protected function _validate_email($value)
548
-    {
549
-        $validate = true;
550
-        $or_val   = $value;
551
-
552
-        // empty strings will validate because this is how a message template
553
-        // for a particular context can be "turned off" (if there is no email then no message)
554
-        if (empty($value)) {
555
-            return $validate;
556
-        }
557
-
558
-        // first determine if there ARE any shortcodes.
559
-        // If there are shortcodes and then later we find that there were no other valid emails
560
-        // but the field isn't empty...
561
-        // that means we've got extra commas that were left after stripping out shortcodes so probably still valid.
562
-        $has_shortcodes = preg_match('/(\[.+?\])/', $value);
563
-
564
-        // first we need to strip out all the shortcodes!
565
-        $value = preg_replace('/(\[.+?\])/', '', $value);
566
-
567
-        // if original value is not empty and new value is, then we've parsed out a shortcode
568
-        // and we now have an empty string which DOES validate.
569
-        // We also validate complete empty field for email because
570
-        // its possible that this message is being "turned off" for a particular context
571
-
572
-
573
-        if (! empty($or_val) && empty($value)) {
574
-            return $validate;
575
-        }
576
-
577
-        // trim any commas from beginning and end of string ( after whitespace trimmed );
578
-        $value = trim(trim($value), ',');
579
-
580
-
581
-        // next we need to split up the string if its comma delimited.
582
-        $emails = explode(',', $value);
583
-        $empty  = false; // used to indicate that there is an empty comma.
584
-        // now let's loop through the emails and do our checks
585
-        foreach ($emails as $email) {
586
-            if (empty($email)) {
587
-                $empty = true;
588
-                continue;
589
-            }
590
-
591
-            // trim whitespace
592
-            $email = trim($email);
593
-            // either its of type "[email protected]", or its of type "fname lname <[email protected]>"
594
-            if (is_email($email)) {
595
-                continue;
596
-            }
597
-            $matches  = array();
598
-            $validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? true : false;
599
-            if ($validate && is_email($matches[2])) {
600
-                continue;
601
-            }
602
-            return false;
603
-        }
604
-
605
-        $validate = $empty && ! $has_shortcodes ? false : $validate;
606
-
607
-        return $validate;
608
-    }
609
-
610
-
611
-    /**
612
-     * Magic getter
613
-     * Using this to provide back compat with add-ons referencing deprecated properties.
614
-     *
615
-     * @param string $property Property being requested
616
-     * @throws Exception
617
-     * @return mixed
618
-     */
619
-    public function __get($property)
620
-    {
621
-        $expected_properties_map = array(
622
-            /**
623
-             * @deprecated 4.9.0
624
-             */
625
-            '_MSGR'   => '_messenger',
626
-            /**
627
-             * @deprecated 4.9.0
628
-             */
629
-            '_MSGTYP' => '_message_type',
630
-        );
631
-
632
-        if (isset($expected_properties_map[ $property ])) {
633
-            return $this->{$expected_properties_map[ $property ]};
634
-        }
635
-
636
-        throw new Exception(
637
-            sprintf(
638
-                esc_html__('The property %1$s being requested on %2$s does not exist', 'event_espresso'),
639
-                $property,
640
-                get_class($this)
641
-            )
642
-        );
643
-    }
20
+	/**
21
+	 * These properties just hold the name for the Messenger and Message Type (defined by child classes).
22
+	 * These are used for retrieving objects etc.
23
+	 *
24
+	 * @var string
25
+	 */
26
+	protected $_m_name;
27
+	protected $_mt_name;
28
+
29
+
30
+	/**
31
+	 * This will hold any error messages from the validation process.
32
+	 * The _errors property holds an associative array of error messages
33
+	 * listing the field as the key and the message as the value.
34
+	 *
35
+	 * @var array()
36
+	 */
37
+	private $_errors = array();
38
+
39
+
40
+	/**
41
+	 * holds an array of fields being validated
42
+	 *
43
+	 * @var array
44
+	 */
45
+	protected $_fields;
46
+
47
+
48
+	/**
49
+	 * this will hold the incoming context
50
+	 *
51
+	 * @var string
52
+	 */
53
+	protected $_context;
54
+
55
+
56
+	/**
57
+	 * this holds an array of fields and the relevant validation information
58
+	 * that the incoming fields data get validated against.
59
+	 * This gets setup in the _set_props() method.
60
+	 *
61
+	 * @var array
62
+	 */
63
+	protected $_validators;
64
+
65
+
66
+	/**
67
+	 * holds the messenger object
68
+	 *
69
+	 * @var object
70
+	 */
71
+	protected $_messenger;
72
+
73
+
74
+	/**
75
+	 * holds the message type object
76
+	 *
77
+	 * @var object
78
+	 */
79
+	protected $_message_type;
80
+
81
+
82
+	/**
83
+	 * will hold any valid_shortcode modifications made by the _modify_validator() method.
84
+	 *
85
+	 * @var array
86
+	 */
87
+	protected $_valid_shortcodes_modifier;
88
+
89
+
90
+	/**
91
+	 * There may be times where a message type wants to include a shortcode group but exclude specific
92
+	 * shortcodes.  If that's the case then it can set this property as an array of shortcodes to exclude and
93
+	 * they will not be allowed.
94
+	 * Array should be indexed by field and values are an array of specific shortcodes to exclude.
95
+	 *
96
+	 * @var array
97
+	 */
98
+	protected $_specific_shortcode_excludes = array();
99
+
100
+
101
+	/**
102
+	 * Runs the validator using the incoming fields array as the fields/values to check.
103
+	 *
104
+	 * @param array $fields The fields sent by the EEM object.
105
+	 * @param       $context
106
+	 * @throws EE_Error
107
+	 * @throws ReflectionException
108
+	 */
109
+	public function __construct($fields, $context)
110
+	{
111
+		// check that _m_name and _mt_name have been set by child class otherwise we get out.
112
+		if (empty($this->_m_name) || empty($this->_mt_name)) {
113
+			throw new EE_Error(
114
+				esc_html__(
115
+					'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property.  Check that the child class is doing this',
116
+					'event_espresso'
117
+				)
118
+			);
119
+		}
120
+		$this->_fields  = $fields;
121
+		$this->_context = $context;
122
+
123
+		// load messenger and message_type objects and the related shortcode objects.
124
+		$this->_load_objects();
125
+
126
+
127
+		// modify any messenger/message_type specific validation instructions.  This is what child classes define.
128
+		$this->_modify_validator();
129
+
130
+
131
+		// let's set validators property
132
+		$this->_set_validators();
133
+	}
134
+
135
+
136
+	/**
137
+	 * Child classes instantiate this and use it to modify the _validator_config array property
138
+	 * for the messenger using messengers set_validate_config() method.
139
+	 * This is so we can specify specific validation instructions for a messenger/message_type combo
140
+	 * that aren't handled by the defaults setup in the messenger.
141
+	 *
142
+	 * @abstract
143
+	 * @access protected
144
+	 * @return void
145
+	 */
146
+	abstract protected function _modify_validator();
147
+
148
+
149
+	/**
150
+	 * loads all objects used by validator
151
+	 *
152
+	 * @access private
153
+	 * @throws \EE_Error
154
+	 */
155
+	private function _load_objects()
156
+	{
157
+		// load messenger
158
+		$messenger = ucwords(str_replace('_', ' ', $this->_m_name));
159
+		$messenger = str_replace(' ', '_', $messenger);
160
+		$messenger = 'EE_' . $messenger . '_messenger';
161
+
162
+		if (! class_exists($messenger)) {
163
+			throw new EE_Error(
164
+				sprintf(
165
+					esc_html__('There is no messenger class for the given string (%s)', 'event_espresso'),
166
+					$this->_m_name
167
+				)
168
+			);
169
+		}
170
+
171
+		$this->_messenger = new $messenger();
172
+
173
+		// load message type
174
+		$message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
175
+		$message_type = str_replace(' ', '_', $message_type);
176
+		$message_type = 'EE_' . $message_type . '_message_type';
177
+
178
+		if (! class_exists($message_type)) {
179
+			throw new EE_Error(
180
+				sprintf(
181
+					esc_html__('There is no message type class for the given string (%s)', 'event_espresso'),
182
+					$this->_mt_name
183
+				)
184
+			);
185
+		}
186
+
187
+		$this->_message_type = new $message_type();
188
+	}
189
+
190
+
191
+	/**
192
+	 * used to set the $_validators property
193
+	 *
194
+	 * @access private
195
+	 * @return void
196
+	 * @throws ReflectionException
197
+	 */
198
+	private function _set_validators()
199
+	{
200
+		// let's get all valid shortcodes from mt and message type
201
+		// (messenger will have its set in the _validator_config property for the messenger)
202
+		$mt_codes = $this->_message_type->get_valid_shortcodes();
203
+
204
+
205
+		// get messenger validator_config
206
+		$msgr_validator = $this->_messenger->get_validator_config();
207
+
208
+
209
+		// we only want the valid shortcodes for the given context!
210
+		$context  = $this->_context;
211
+		$mt_codes = $mt_codes[ $context ];
212
+
213
+		// in this first loop we're just getting all shortcode group indexes from the msgr_validator
214
+		// into a single array (so we can get the appropriate shortcode objects for the groups)
215
+		$shortcode_groups = $mt_codes;
216
+		$groups_per_field = array();
217
+
218
+		foreach ($msgr_validator as $field => $config) {
219
+			if (empty($config) || ! isset($config['shortcodes'])) {
220
+				continue;
221
+			}  //Nothing to see here.
222
+			$groups_per_field[ $field ] = array_intersect($config['shortcodes'], $mt_codes);
223
+			$shortcode_groups         = array_merge($config['shortcodes'], $shortcode_groups);
224
+		}
225
+
226
+		$shortcode_groups = array_unique($shortcode_groups);
227
+
228
+		// okay now we've got our groups.
229
+		// Let's get the codes from the objects into an array indexed by group for easy retrieval later.
230
+		$codes_from_objs = array();
231
+
232
+		foreach ($shortcode_groups as $group) {
233
+			$ref       = ucwords(str_replace('_', ' ', $group));
234
+			$ref       = str_replace(' ', '_', $ref);
235
+			$classname = 'EE_' . $ref . '_Shortcodes';
236
+			if (class_exists($classname)) {
237
+				$a                       = new ReflectionClass($classname);
238
+				$obj                     = $a->newInstance();
239
+				$codes_from_objs[ $group ] = $obj->get_shortcodes();
240
+			}
241
+		}
242
+
243
+
244
+		// let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
245
+		$final_mt_codes = array();
246
+		foreach ($mt_codes as $group) {
247
+			$final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[ $group ]);
248
+		}
249
+
250
+		$mt_codes = $final_mt_codes;
251
+
252
+
253
+		// k now in this next loop we're going to loop through $msgr_validator again
254
+		// and setup the _validators property from the data we've setup so far.
255
+		foreach ($msgr_validator as $field => $config) {
256
+			// if required shortcode is not in our list of codes for the given field, then we skip this field.
257
+			$required = isset($config['required'])
258
+				? array_intersect($config['required'], array_keys($mt_codes))
259
+				: true;
260
+			if (empty($required)) {
261
+				continue;
262
+			}
263
+
264
+			if (isset($this->_valid_shortcodes_modifier[ $context ][ $field ])) {
265
+				// If we have an override then we use it to indicate the codes we want.
266
+				$this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
267
+					$this->_valid_shortcodes_modifier[ $context ][ $field ],
268
+					$codes_from_objs
269
+				);
270
+			} elseif (isset($groups_per_field[ $field ])) {
271
+				// if we have specific shortcodes for a field then we need to use them
272
+				$this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
273
+					$groups_per_field[ $field ],
274
+					$codes_from_objs
275
+				);
276
+			} elseif (empty($config)) {
277
+				// if empty config then we're assuming we're just going to use the shortcodes from the message type
278
+				// context
279
+				$this->_validators[ $field ]['shortcodes'] = $mt_codes;
280
+			} elseif (isset($config['specific_shortcodes'])) {
281
+				// if we have specific shortcodes then we need to use them
282
+				$this->_validators[ $field ]['shortcodes'] = $config['specific_shortcodes'];
283
+			} else {
284
+				// otherwise the shortcodes are what is set by the messenger for that field
285
+				foreach ($config['shortcodes'] as $group) {
286
+					$this->_validators[ $field ]['shortcodes'] = isset($this->_validators[ $field ]['shortcodes'])
287
+						? array_merge($this->_validators[ $field ]['shortcodes'], $codes_from_objs[ $group ])
288
+						: $codes_from_objs[ $group ];
289
+				}
290
+			}
291
+
292
+			// now let's just make sure that any excluded specific shortcodes are removed.
293
+			$specific_excludes = $this->get_specific_shortcode_excludes();
294
+			if (isset($specific_excludes[ $field ])) {
295
+				foreach ($specific_excludes[ $field ] as $sex) {
296
+					if (isset($this->_validators[ $field ]['shortcodes'][ $sex ])) {
297
+						unset($this->_validators[ $field ]['shortcodes'][ $sex ]);
298
+					}
299
+				}
300
+			}
301
+
302
+			// hey! don't forget to include the type if present!
303
+			$this->_validators[ $field ]['type'] = isset($config['type']) ? $config['type'] : null;
304
+		}
305
+	}
306
+
307
+
308
+	/**
309
+	 * This just returns the validators property that contains information
310
+	 * about the various shortcodes and their availability with each field
311
+	 *
312
+	 * @return array
313
+	 */
314
+	public function get_validators()
315
+	{
316
+		return $this->_validators;
317
+	}
318
+
319
+
320
+	/**
321
+	 * This simply returns the specific shortcode_excludes property that is set.
322
+	 *
323
+	 * @since 4.5.0
324
+	 * @return array
325
+	 */
326
+	public function get_specific_shortcode_excludes()
327
+	{
328
+		// specific validator filter
329
+		$shortcode_excludes = apply_filters(
330
+			'FHEE__' . get_class($this) . '__get_specific_shortcode_excludes;',
331
+			$this->_specific_shortcode_excludes,
332
+			$this->_context
333
+		);
334
+		// global filter
335
+		return apply_filters(
336
+			'FHEE__EE_Messages_Validator__get_specific_shortcode_excludes',
337
+			$shortcode_excludes,
338
+			$this->_context,
339
+			$this
340
+		);
341
+	}
342
+
343
+
344
+	/**
345
+	 * This is the main method that handles validation
346
+	 * What it does is loop through the _fields (the ones that get validated)
347
+	 * and checks them against the shortcodes array for the field and the 'type' indicated by the
348
+	 *
349
+	 * @access public
350
+	 * @return mixed (bool|array)  if errors present we return the array otherwise true
351
+	 */
352
+	public function validate()
353
+	{
354
+		// some defaults
355
+		$template_fields = $this->_messenger->get_template_fields();
356
+		// loop through the fields and check!
357
+		foreach ($this->_fields as $field => $value) {
358
+			$this->_errors[ $field ] = array();
359
+			$err_msg               = '';
360
+			$field_label           = '';
361
+			// if field is not present in the _validators array then we continue
362
+			if (! isset($this->_validators[ $field ])) {
363
+				unset($this->_errors[ $field ]);
364
+				continue;
365
+			}
366
+
367
+			// get the translated field label!
368
+			// first check if it's in the main fields list
369
+			if (isset($template_fields[ $field ])) {
370
+				if (empty($template_fields[ $field ])) {
371
+					$field_label = $field;
372
+				} else {
373
+					// most likely the field is found in the 'extra' array.
374
+					$field_label = $template_fields[ $field ]['label'];
375
+				}
376
+			}
377
+
378
+			// if field label is empty OR is equal to the current field
379
+			// then we need to loop through the 'extra' fields in the template_fields config (if present)
380
+			if (isset($template_fields['extra']) && (empty($field_label) || $field_label === $field)) {
381
+				foreach ($template_fields['extra'] as $main_field => $secondary_field) {
382
+					foreach ($secondary_field as $name => $values) {
383
+						if ($name === $field) {
384
+							$field_label = $values['label'];
385
+						}
386
+
387
+						// if we've got a 'main' secondary field, let's see if that matches what field we're on
388
+						// which means it contains the label for this field.
389
+						if ($name === 'main' && $main_field === $field_label) {
390
+							$field_label = $values['label'];
391
+						}
392
+					}
393
+				}
394
+			}
395
+
396
+			// field is present. Let's validate shortcodes first (but only if shortcodes present).
397
+			if (
398
+				isset($this->_validators[ $field ]['shortcodes'])
399
+				&& ! empty($this->_validators[ $field ]['shortcodes'])
400
+			) {
401
+				$invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[ $field ]['shortcodes']);
402
+				// if true then that means there is a returned error message
403
+				// that we'll need to add to the _errors array for this field.
404
+				if ($invalid_shortcodes) {
405
+					$v_s     = array_keys($this->_validators[ $field ]['shortcodes']);
406
+					$err_msg = sprintf(
407
+						esc_html__(
408
+							'%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
409
+							'event_espresso'
410
+						),
411
+						'<strong>' . $field_label . '</strong>',
412
+						$invalid_shortcodes,
413
+						'<p>',
414
+						'</p >'
415
+					);
416
+					$err_msg .= sprintf(
417
+						esc_html__('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'),
418
+						implode(', ', $v_s),
419
+						'<strong>',
420
+						'</strong>'
421
+					);
422
+				}
423
+			}
424
+
425
+			// if there's a "type" to be validated then let's do that too.
426
+			if (isset($this->_validators[ $field ]['type']) && ! empty($this->_validators[ $field ]['type'])) {
427
+				switch ($this->_validators[ $field ]['type']) {
428
+					case 'number':
429
+						if (! is_numeric($value)) {
430
+							$err_msg .= sprintf(
431
+								esc_html__(
432
+									'%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
433
+									'event_espresso'
434
+								),
435
+								$field_label,
436
+								$value,
437
+								'<p>',
438
+								'</p >'
439
+							);
440
+						}
441
+						break;
442
+					case 'email':
443
+						$valid_email = $this->_validate_email($value);
444
+						if (! $valid_email) {
445
+							$err_msg .= htmlentities(
446
+								sprintf(
447
+									esc_html__(
448
+										'The %1$s field has at least one string that is not a valid email address record.  Valid emails are in the format: "Name <[email protected]>" or "[email protected]" and multiple emails can be separated by a comma.',
449
+										'event_espresso'
450
+									),
451
+									$field_label
452
+								)
453
+							);
454
+						}
455
+						break;
456
+					default:
457
+						break;
458
+				}
459
+			}
460
+
461
+			// if $err_msg isn't empty let's setup the _errors array for this field.
462
+			if (! empty($err_msg)) {
463
+				$this->_errors[ $field ]['msg'] = $err_msg;
464
+			} else {
465
+				unset($this->_errors[ $field ]);
466
+			}
467
+		}
468
+
469
+		// if we have ANY errors, then we want to make sure we return the values
470
+		// for ALL the fields so the user doesn't have to retype them all.
471
+		if (! empty($this->_errors)) {
472
+			foreach ($this->_fields as $field => $value) {
473
+				$this->_errors[ $field ]['value'] = stripslashes($value);
474
+			}
475
+		}
476
+
477
+		// return any errors or just TRUE if everything validates
478
+		return empty($this->_errors) ? true : $this->_errors;
479
+	}
480
+
481
+
482
+	/**
483
+	 * Reassembles and returns an array of valid shortcodes
484
+	 * given the array of groups and array of shortcodes indexed by group.
485
+	 *
486
+	 * @param  array $groups          array of shortcode groups that we want shortcodes for
487
+	 * @param  array $codes_from_objs All the codes available.
488
+	 * @return array                   an array of actual shortcodes (that will be used for validation).
489
+	 */
490
+	private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs)
491
+	{
492
+		$shortcodes = array();
493
+		foreach ($groups as $group) {
494
+			$shortcodes = array_merge($shortcodes, $codes_from_objs[ $group ]);
495
+		}
496
+		return $shortcodes;
497
+	}
498
+
499
+
500
+	/**
501
+	 * Validates a string against a list of accepted shortcodes
502
+	 * This function takes in an array of shortcodes
503
+	 * and makes sure that the given string ONLY contains shortcodes in that array.
504
+	 *
505
+	 * @param  string $value            string to evaluate
506
+	 * @param  array  $valid_shortcodes array of shortcodes that are acceptable.
507
+	 * @return mixed (bool|string)  return either a list of invalid shortcodes OR false if the shortcodes validate.
508
+	 */
509
+	protected function _invalid_shortcodes($value, $valid_shortcodes)
510
+	{
511
+		// first we need to go through the string and get the shortcodes in the string
512
+		preg_match_all('/(\[.+?\])/', $value, $matches);
513
+		$incoming_shortcodes = (array) $matches[0];
514
+
515
+		// get a diff of the shortcodes in the string vs the valid shortcodes
516
+		$diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes));
517
+
518
+		// we need to account for custom codes so let's loop through the diff and remove any of those type of codes
519
+		foreach ($diff as $ind => $code) {
520
+			if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) {
521
+				// strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
522
+				$dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
523
+				// does this exist in the $valid_shortcodes?  If so then unset.
524
+				if (isset($valid_shortcodes[ $dynamic_sc ])) {
525
+					unset($diff[ $ind ]);
526
+				}
527
+			}
528
+		}
529
+
530
+		if (empty($diff)) {
531
+			return false;
532
+		} //there is no diff, we have no invalid shortcodes, so return
533
+
534
+		// made it here? then let's assemble the error message
535
+		$invalid_shortcodes = implode('</strong>,<strong>', $diff);
536
+		$invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
537
+		return $invalid_shortcodes;
538
+	}
539
+
540
+
541
+	/**
542
+	 * Validates an incoming string and makes sure we have valid emails in the string.
543
+	 *
544
+	 * @param  string $value incoming value to validate
545
+	 * @return bool        true if the string validates, false if it doesn't
546
+	 */
547
+	protected function _validate_email($value)
548
+	{
549
+		$validate = true;
550
+		$or_val   = $value;
551
+
552
+		// empty strings will validate because this is how a message template
553
+		// for a particular context can be "turned off" (if there is no email then no message)
554
+		if (empty($value)) {
555
+			return $validate;
556
+		}
557
+
558
+		// first determine if there ARE any shortcodes.
559
+		// If there are shortcodes and then later we find that there were no other valid emails
560
+		// but the field isn't empty...
561
+		// that means we've got extra commas that were left after stripping out shortcodes so probably still valid.
562
+		$has_shortcodes = preg_match('/(\[.+?\])/', $value);
563
+
564
+		// first we need to strip out all the shortcodes!
565
+		$value = preg_replace('/(\[.+?\])/', '', $value);
566
+
567
+		// if original value is not empty and new value is, then we've parsed out a shortcode
568
+		// and we now have an empty string which DOES validate.
569
+		// We also validate complete empty field for email because
570
+		// its possible that this message is being "turned off" for a particular context
571
+
572
+
573
+		if (! empty($or_val) && empty($value)) {
574
+			return $validate;
575
+		}
576
+
577
+		// trim any commas from beginning and end of string ( after whitespace trimmed );
578
+		$value = trim(trim($value), ',');
579
+
580
+
581
+		// next we need to split up the string if its comma delimited.
582
+		$emails = explode(',', $value);
583
+		$empty  = false; // used to indicate that there is an empty comma.
584
+		// now let's loop through the emails and do our checks
585
+		foreach ($emails as $email) {
586
+			if (empty($email)) {
587
+				$empty = true;
588
+				continue;
589
+			}
590
+
591
+			// trim whitespace
592
+			$email = trim($email);
593
+			// either its of type "[email protected]", or its of type "fname lname <[email protected]>"
594
+			if (is_email($email)) {
595
+				continue;
596
+			}
597
+			$matches  = array();
598
+			$validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? true : false;
599
+			if ($validate && is_email($matches[2])) {
600
+				continue;
601
+			}
602
+			return false;
603
+		}
604
+
605
+		$validate = $empty && ! $has_shortcodes ? false : $validate;
606
+
607
+		return $validate;
608
+	}
609
+
610
+
611
+	/**
612
+	 * Magic getter
613
+	 * Using this to provide back compat with add-ons referencing deprecated properties.
614
+	 *
615
+	 * @param string $property Property being requested
616
+	 * @throws Exception
617
+	 * @return mixed
618
+	 */
619
+	public function __get($property)
620
+	{
621
+		$expected_properties_map = array(
622
+			/**
623
+			 * @deprecated 4.9.0
624
+			 */
625
+			'_MSGR'   => '_messenger',
626
+			/**
627
+			 * @deprecated 4.9.0
628
+			 */
629
+			'_MSGTYP' => '_message_type',
630
+		);
631
+
632
+		if (isset($expected_properties_map[ $property ])) {
633
+			return $this->{$expected_properties_map[ $property ]};
634
+		}
635
+
636
+		throw new Exception(
637
+			sprintf(
638
+				esc_html__('The property %1$s being requested on %2$s does not exist', 'event_espresso'),
639
+				$property,
640
+				get_class($this)
641
+			)
642
+		);
643
+	}
644 644
 }
Please login to merge, or discard this patch.
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -157,9 +157,9 @@  discard block
 block discarded – undo
157 157
         // load messenger
158 158
         $messenger = ucwords(str_replace('_', ' ', $this->_m_name));
159 159
         $messenger = str_replace(' ', '_', $messenger);
160
-        $messenger = 'EE_' . $messenger . '_messenger';
160
+        $messenger = 'EE_'.$messenger.'_messenger';
161 161
 
162
-        if (! class_exists($messenger)) {
162
+        if ( ! class_exists($messenger)) {
163 163
             throw new EE_Error(
164 164
                 sprintf(
165 165
                     esc_html__('There is no messenger class for the given string (%s)', 'event_espresso'),
@@ -173,9 +173,9 @@  discard block
 block discarded – undo
173 173
         // load message type
174 174
         $message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
175 175
         $message_type = str_replace(' ', '_', $message_type);
176
-        $message_type = 'EE_' . $message_type . '_message_type';
176
+        $message_type = 'EE_'.$message_type.'_message_type';
177 177
 
178
-        if (! class_exists($message_type)) {
178
+        if ( ! class_exists($message_type)) {
179 179
             throw new EE_Error(
180 180
                 sprintf(
181 181
                     esc_html__('There is no message type class for the given string (%s)', 'event_espresso'),
@@ -208,7 +208,7 @@  discard block
 block discarded – undo
208 208
 
209 209
         // we only want the valid shortcodes for the given context!
210 210
         $context  = $this->_context;
211
-        $mt_codes = $mt_codes[ $context ];
211
+        $mt_codes = $mt_codes[$context];
212 212
 
213 213
         // in this first loop we're just getting all shortcode group indexes from the msgr_validator
214 214
         // into a single array (so we can get the appropriate shortcode objects for the groups)
@@ -219,8 +219,8 @@  discard block
 block discarded – undo
219 219
             if (empty($config) || ! isset($config['shortcodes'])) {
220 220
                 continue;
221 221
             }  //Nothing to see here.
222
-            $groups_per_field[ $field ] = array_intersect($config['shortcodes'], $mt_codes);
223
-            $shortcode_groups         = array_merge($config['shortcodes'], $shortcode_groups);
222
+            $groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes);
223
+            $shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups);
224 224
         }
225 225
 
226 226
         $shortcode_groups = array_unique($shortcode_groups);
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
         foreach ($shortcode_groups as $group) {
233 233
             $ref       = ucwords(str_replace('_', ' ', $group));
234 234
             $ref       = str_replace(' ', '_', $ref);
235
-            $classname = 'EE_' . $ref . '_Shortcodes';
235
+            $classname = 'EE_'.$ref.'_Shortcodes';
236 236
             if (class_exists($classname)) {
237 237
                 $a                       = new ReflectionClass($classname);
238 238
                 $obj                     = $a->newInstance();
239
-                $codes_from_objs[ $group ] = $obj->get_shortcodes();
239
+                $codes_from_objs[$group] = $obj->get_shortcodes();
240 240
             }
241 241
         }
242 242
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
         // let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
245 245
         $final_mt_codes = array();
246 246
         foreach ($mt_codes as $group) {
247
-            $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[ $group ]);
247
+            $final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]);
248 248
         }
249 249
 
250 250
         $mt_codes = $final_mt_codes;
@@ -261,46 +261,46 @@  discard block
 block discarded – undo
261 261
                 continue;
262 262
             }
263 263
 
264
-            if (isset($this->_valid_shortcodes_modifier[ $context ][ $field ])) {
264
+            if (isset($this->_valid_shortcodes_modifier[$context][$field])) {
265 265
                 // If we have an override then we use it to indicate the codes we want.
266
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
267
-                    $this->_valid_shortcodes_modifier[ $context ][ $field ],
266
+                $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
267
+                    $this->_valid_shortcodes_modifier[$context][$field],
268 268
                     $codes_from_objs
269 269
                 );
270
-            } elseif (isset($groups_per_field[ $field ])) {
270
+            } elseif (isset($groups_per_field[$field])) {
271 271
                 // if we have specific shortcodes for a field then we need to use them
272
-                $this->_validators[ $field ]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
273
-                    $groups_per_field[ $field ],
272
+                $this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
273
+                    $groups_per_field[$field],
274 274
                     $codes_from_objs
275 275
                 );
276 276
             } elseif (empty($config)) {
277 277
                 // if empty config then we're assuming we're just going to use the shortcodes from the message type
278 278
                 // context
279
-                $this->_validators[ $field ]['shortcodes'] = $mt_codes;
279
+                $this->_validators[$field]['shortcodes'] = $mt_codes;
280 280
             } elseif (isset($config['specific_shortcodes'])) {
281 281
                 // if we have specific shortcodes then we need to use them
282
-                $this->_validators[ $field ]['shortcodes'] = $config['specific_shortcodes'];
282
+                $this->_validators[$field]['shortcodes'] = $config['specific_shortcodes'];
283 283
             } else {
284 284
                 // otherwise the shortcodes are what is set by the messenger for that field
285 285
                 foreach ($config['shortcodes'] as $group) {
286
-                    $this->_validators[ $field ]['shortcodes'] = isset($this->_validators[ $field ]['shortcodes'])
287
-                        ? array_merge($this->_validators[ $field ]['shortcodes'], $codes_from_objs[ $group ])
288
-                        : $codes_from_objs[ $group ];
286
+                    $this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes'])
287
+                        ? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group])
288
+                        : $codes_from_objs[$group];
289 289
                 }
290 290
             }
291 291
 
292 292
             // now let's just make sure that any excluded specific shortcodes are removed.
293 293
             $specific_excludes = $this->get_specific_shortcode_excludes();
294
-            if (isset($specific_excludes[ $field ])) {
295
-                foreach ($specific_excludes[ $field ] as $sex) {
296
-                    if (isset($this->_validators[ $field ]['shortcodes'][ $sex ])) {
297
-                        unset($this->_validators[ $field ]['shortcodes'][ $sex ]);
294
+            if (isset($specific_excludes[$field])) {
295
+                foreach ($specific_excludes[$field] as $sex) {
296
+                    if (isset($this->_validators[$field]['shortcodes'][$sex])) {
297
+                        unset($this->_validators[$field]['shortcodes'][$sex]);
298 298
                     }
299 299
                 }
300 300
             }
301 301
 
302 302
             // hey! don't forget to include the type if present!
303
-            $this->_validators[ $field ]['type'] = isset($config['type']) ? $config['type'] : null;
303
+            $this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : null;
304 304
         }
305 305
     }
306 306
 
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
     {
328 328
         // specific validator filter
329 329
         $shortcode_excludes = apply_filters(
330
-            'FHEE__' . get_class($this) . '__get_specific_shortcode_excludes;',
330
+            'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;',
331 331
             $this->_specific_shortcode_excludes,
332 332
             $this->_context
333 333
         );
@@ -355,23 +355,23 @@  discard block
 block discarded – undo
355 355
         $template_fields = $this->_messenger->get_template_fields();
356 356
         // loop through the fields and check!
357 357
         foreach ($this->_fields as $field => $value) {
358
-            $this->_errors[ $field ] = array();
358
+            $this->_errors[$field] = array();
359 359
             $err_msg               = '';
360 360
             $field_label           = '';
361 361
             // if field is not present in the _validators array then we continue
362
-            if (! isset($this->_validators[ $field ])) {
363
-                unset($this->_errors[ $field ]);
362
+            if ( ! isset($this->_validators[$field])) {
363
+                unset($this->_errors[$field]);
364 364
                 continue;
365 365
             }
366 366
 
367 367
             // get the translated field label!
368 368
             // first check if it's in the main fields list
369
-            if (isset($template_fields[ $field ])) {
370
-                if (empty($template_fields[ $field ])) {
369
+            if (isset($template_fields[$field])) {
370
+                if (empty($template_fields[$field])) {
371 371
                     $field_label = $field;
372 372
                 } else {
373 373
                     // most likely the field is found in the 'extra' array.
374
-                    $field_label = $template_fields[ $field ]['label'];
374
+                    $field_label = $template_fields[$field]['label'];
375 375
                 }
376 376
             }
377 377
 
@@ -395,20 +395,20 @@  discard block
 block discarded – undo
395 395
 
396 396
             // field is present. Let's validate shortcodes first (but only if shortcodes present).
397 397
             if (
398
-                isset($this->_validators[ $field ]['shortcodes'])
399
-                && ! empty($this->_validators[ $field ]['shortcodes'])
398
+                isset($this->_validators[$field]['shortcodes'])
399
+                && ! empty($this->_validators[$field]['shortcodes'])
400 400
             ) {
401
-                $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[ $field ]['shortcodes']);
401
+                $invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']);
402 402
                 // if true then that means there is a returned error message
403 403
                 // that we'll need to add to the _errors array for this field.
404 404
                 if ($invalid_shortcodes) {
405
-                    $v_s     = array_keys($this->_validators[ $field ]['shortcodes']);
405
+                    $v_s     = array_keys($this->_validators[$field]['shortcodes']);
406 406
                     $err_msg = sprintf(
407 407
                         esc_html__(
408 408
                             '%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
409 409
                             'event_espresso'
410 410
                         ),
411
-                        '<strong>' . $field_label . '</strong>',
411
+                        '<strong>'.$field_label.'</strong>',
412 412
                         $invalid_shortcodes,
413 413
                         '<p>',
414 414
                         '</p >'
@@ -423,10 +423,10 @@  discard block
 block discarded – undo
423 423
             }
424 424
 
425 425
             // if there's a "type" to be validated then let's do that too.
426
-            if (isset($this->_validators[ $field ]['type']) && ! empty($this->_validators[ $field ]['type'])) {
427
-                switch ($this->_validators[ $field ]['type']) {
426
+            if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) {
427
+                switch ($this->_validators[$field]['type']) {
428 428
                     case 'number':
429
-                        if (! is_numeric($value)) {
429
+                        if ( ! is_numeric($value)) {
430 430
                             $err_msg .= sprintf(
431 431
                                 esc_html__(
432 432
                                     '%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
@@ -441,7 +441,7 @@  discard block
 block discarded – undo
441 441
                         break;
442 442
                     case 'email':
443 443
                         $valid_email = $this->_validate_email($value);
444
-                        if (! $valid_email) {
444
+                        if ( ! $valid_email) {
445 445
                             $err_msg .= htmlentities(
446 446
                                 sprintf(
447 447
                                     esc_html__(
@@ -459,18 +459,18 @@  discard block
 block discarded – undo
459 459
             }
460 460
 
461 461
             // if $err_msg isn't empty let's setup the _errors array for this field.
462
-            if (! empty($err_msg)) {
463
-                $this->_errors[ $field ]['msg'] = $err_msg;
462
+            if ( ! empty($err_msg)) {
463
+                $this->_errors[$field]['msg'] = $err_msg;
464 464
             } else {
465
-                unset($this->_errors[ $field ]);
465
+                unset($this->_errors[$field]);
466 466
             }
467 467
         }
468 468
 
469 469
         // if we have ANY errors, then we want to make sure we return the values
470 470
         // for ALL the fields so the user doesn't have to retype them all.
471
-        if (! empty($this->_errors)) {
471
+        if ( ! empty($this->_errors)) {
472 472
             foreach ($this->_fields as $field => $value) {
473
-                $this->_errors[ $field ]['value'] = stripslashes($value);
473
+                $this->_errors[$field]['value'] = stripslashes($value);
474 474
             }
475 475
         }
476 476
 
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
     {
492 492
         $shortcodes = array();
493 493
         foreach ($groups as $group) {
494
-            $shortcodes = array_merge($shortcodes, $codes_from_objs[ $group ]);
494
+            $shortcodes = array_merge($shortcodes, $codes_from_objs[$group]);
495 495
         }
496 496
         return $shortcodes;
497 497
     }
@@ -521,8 +521,8 @@  discard block
 block discarded – undo
521 521
                 // strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
522 522
                 $dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
523 523
                 // does this exist in the $valid_shortcodes?  If so then unset.
524
-                if (isset($valid_shortcodes[ $dynamic_sc ])) {
525
-                    unset($diff[ $ind ]);
524
+                if (isset($valid_shortcodes[$dynamic_sc])) {
525
+                    unset($diff[$ind]);
526 526
                 }
527 527
             }
528 528
         }
@@ -533,7 +533,7 @@  discard block
 block discarded – undo
533 533
 
534 534
         // made it here? then let's assemble the error message
535 535
         $invalid_shortcodes = implode('</strong>,<strong>', $diff);
536
-        $invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
536
+        $invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>';
537 537
         return $invalid_shortcodes;
538 538
     }
539 539
 
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
         // its possible that this message is being "turned off" for a particular context
571 571
 
572 572
 
573
-        if (! empty($or_val) && empty($value)) {
573
+        if ( ! empty($or_val) && empty($value)) {
574 574
             return $validate;
575 575
         }
576 576
 
@@ -629,8 +629,8 @@  discard block
 block discarded – undo
629 629
             '_MSGTYP' => '_message_type',
630 630
         );
631 631
 
632
-        if (isset($expected_properties_map[ $property ])) {
633
-            return $this->{$expected_properties_map[ $property ]};
632
+        if (isset($expected_properties_map[$property])) {
633
+            return $this->{$expected_properties_map[$property]};
634 634
         }
635 635
 
636 636
         throw new Exception(
Please login to merge, or discard this patch.
core/db_models/fields/EE_Simple_HTML_Field.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -11,14 +11,14 @@
 block discarded – undo
11 11
 
12 12
 
13 13
 
14
-    /**
15
-     * removes all tags which a WP Post wouldn't allow in its content normally
16
-     *
17
-     * @param string $value
18
-     * @return string
19
-     */
20
-    public function prepare_for_set($value)
21
-    {
22
-        return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags()));
23
-    }
14
+	/**
15
+	 * removes all tags which a WP Post wouldn't allow in its content normally
16
+	 *
17
+	 * @param string $value
18
+	 * @return string
19
+	 */
20
+	public function prepare_for_set($value)
21
+	{
22
+		return parent::prepare_for_set(wp_kses("$value", EEH_HTML::get_simple_tags()));
23
+	}
24 24
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Attendee.class.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -603,7 +603,7 @@  discard block
 block discarded – undo
603 603
     /**
604 604
      * returns any events attached to this attendee ($_Event property);
605 605
      *
606
-     * @return array
606
+     * @return EE_Base_Class[]
607 607
      * @throws EE_Error
608 608
      */
609 609
     public function events()
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
      * used to save the billing info
619 619
      *
620 620
      * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
621
-     * @return EE_Form_Section_Proper|null
621
+     * @return null|EE_Billing_Info_Form
622 622
      * @throws EE_Error
623 623
      */
624 624
     public function billing_info_for_payment_method($payment_method)
Please login to merge, or discard this patch.
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -36,16 +36,16 @@  discard block
 block discarded – undo
36 36
      */
37 37
     protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38 38
     {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
39
+        if ( ! isset($fieldValues['ATT_full_name'])) {
40
+            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'].' ' : '';
41 41
             $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
42
+            $fieldValues['ATT_full_name'] = $fname.$lname;
43 43
         }
44
-        if (! isset($fieldValues['ATT_slug'])) {
44
+        if ( ! isset($fieldValues['ATT_slug'])) {
45 45
             // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46 46
             $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47 47
         }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
48
+        if ( ! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49 49
             $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50 50
         }
51 51
         parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
         $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
326 326
         foreach ($initial_address_fields as $address_field_name) {
327 327
             $address_fields_value = $this->get($address_field_name);
328
-            if (! empty($address_fields_value)) {
328
+            if ( ! empty($address_fields_value)) {
329 329
                 $full_address_array[] = $address_fields_value;
330 330
             }
331 331
         }
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
         }
341 341
         // lastly get the xip
342 342
         $zip_value = $this->zip();
343
-        if (! empty($zip_value)) {
343
+        if ( ! empty($zip_value)) {
344 344
             $full_address_array[] = $zip_value;
345 345
         }
346 346
         return $full_address_array;
@@ -622,18 +622,18 @@  discard block
 block discarded – undo
622 622
     public function billing_info_for_payment_method($payment_method)
623 623
     {
624 624
         $pm_type = $payment_method->type_obj();
625
-        if (! $pm_type instanceof EE_PMT_Base) {
625
+        if ( ! $pm_type instanceof EE_PMT_Base) {
626 626
             return null;
627 627
         }
628 628
         $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
629
-        if (! $billing_info) {
629
+        if ( ! $billing_info) {
630 630
             return null;
631 631
         }
632 632
         $billing_form = $pm_type->billing_form();
633 633
         // double-check the form isn't totally hidden, in which case pretend there is no form
634 634
         $form_totally_hidden = true;
635 635
         foreach ($billing_form->inputs_in_subsections() as $input) {
636
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
636
+            if ( ! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
637 637
                 $form_totally_hidden = false;
638 638
                 break;
639 639
             }
@@ -660,7 +660,7 @@  discard block
 block discarded – undo
660 660
     public function get_billing_info_postmeta_name($payment_method)
661 661
     {
662 662
         if ($payment_method->type_obj() instanceof EE_PMT_Base) {
663
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
663
+            return 'billing_info_'.$payment_method->type_obj()->system_name();
664 664
         }
665 665
         return null;
666 666
     }
@@ -677,7 +677,7 @@  discard block
 block discarded – undo
677 677
      */
678 678
     public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
679 679
     {
680
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
680
+        if ( ! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
681 681
             EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
682 682
             return false;
683 683
         }
Please login to merge, or discard this patch.
Indentation   +768 added lines, -768 removed lines patch added patch discarded remove patch
@@ -25,772 +25,772 @@
 block discarded – undo
25 25
 class EE_Attendee extends EE_CPT_Base implements EEI_Contact, EEI_Address, EEI_Admin_Links, EEI_Attendee
26 26
 {
27 27
 
28
-    /**
29
-     * Sets some dynamic defaults
30
-     *
31
-     * @param array  $fieldValues
32
-     * @param bool   $bydb
33
-     * @param string $timezone
34
-     * @param array  $date_formats
35
-     * @throws EE_Error
36
-     */
37
-    protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
-    {
39
-        if (! isset($fieldValues['ATT_full_name'])) {
40
-            $fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
-            $lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
-            $fieldValues['ATT_full_name'] = $fname . $lname;
43
-        }
44
-        if (! isset($fieldValues['ATT_slug'])) {
45
-            // $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
-            $fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
-        }
48
-        if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
-            $fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
-        }
51
-        parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
-    }
53
-
54
-
55
-    /**
56
-     * @param array  $props_n_values          incoming values
57
-     * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
-     *                                        used.)
59
-     * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
-     *                                        date_format and the second value is the time format
61
-     * @return EE_Attendee
62
-     * @throws EE_Error
63
-     */
64
-    public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
-    {
66
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
-    }
69
-
70
-
71
-    /**
72
-     * @param array  $props_n_values  incoming values from the database
73
-     * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
-     *                                the website will be used.
75
-     * @return EE_Attendee
76
-     */
77
-    public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
-    {
79
-        return new self($props_n_values, true, $timezone);
80
-    }
81
-
82
-
83
-    /**
84
-     *        Set Attendee First Name
85
-     *
86
-     * @access        public
87
-     * @param string $fname
88
-     * @throws EE_Error
89
-     */
90
-    public function set_fname($fname = '')
91
-    {
92
-        $this->set('ATT_fname', $fname);
93
-    }
94
-
95
-
96
-    /**
97
-     *        Set Attendee Last Name
98
-     *
99
-     * @access        public
100
-     * @param string $lname
101
-     * @throws EE_Error
102
-     */
103
-    public function set_lname($lname = '')
104
-    {
105
-        $this->set('ATT_lname', $lname);
106
-    }
107
-
108
-
109
-    /**
110
-     *        Set Attendee Address
111
-     *
112
-     * @access        public
113
-     * @param string $address
114
-     * @throws EE_Error
115
-     */
116
-    public function set_address($address = '')
117
-    {
118
-        $this->set('ATT_address', $address);
119
-    }
120
-
121
-
122
-    /**
123
-     *        Set Attendee Address2
124
-     *
125
-     * @access        public
126
-     * @param        string $address2
127
-     * @throws EE_Error
128
-     */
129
-    public function set_address2($address2 = '')
130
-    {
131
-        $this->set('ATT_address2', $address2);
132
-    }
133
-
134
-
135
-    /**
136
-     *        Set Attendee City
137
-     *
138
-     * @access        public
139
-     * @param        string $city
140
-     * @throws EE_Error
141
-     */
142
-    public function set_city($city = '')
143
-    {
144
-        $this->set('ATT_city', $city);
145
-    }
146
-
147
-
148
-    /**
149
-     *        Set Attendee State ID
150
-     *
151
-     * @access        public
152
-     * @param        int $STA_ID
153
-     * @throws EE_Error
154
-     */
155
-    public function set_state($STA_ID = 0)
156
-    {
157
-        $this->set('STA_ID', $STA_ID);
158
-    }
159
-
160
-
161
-    /**
162
-     *        Set Attendee Country ISO Code
163
-     *
164
-     * @access        public
165
-     * @param        string $CNT_ISO
166
-     * @throws EE_Error
167
-     */
168
-    public function set_country($CNT_ISO = '')
169
-    {
170
-        $this->set('CNT_ISO', $CNT_ISO);
171
-    }
172
-
173
-
174
-    /**
175
-     *        Set Attendee Zip/Postal Code
176
-     *
177
-     * @access        public
178
-     * @param        string $zip
179
-     * @throws EE_Error
180
-     */
181
-    public function set_zip($zip = '')
182
-    {
183
-        $this->set('ATT_zip', $zip);
184
-    }
185
-
186
-
187
-    /**
188
-     *        Set Attendee Email Address
189
-     *
190
-     * @access        public
191
-     * @param        string $email
192
-     * @throws EE_Error
193
-     */
194
-    public function set_email($email = '')
195
-    {
196
-        $this->set('ATT_email', $email);
197
-    }
198
-
199
-
200
-    /**
201
-     *        Set Attendee Phone
202
-     *
203
-     * @access        public
204
-     * @param        string $phone
205
-     * @throws EE_Error
206
-     */
207
-    public function set_phone($phone = '')
208
-    {
209
-        $this->set('ATT_phone', $phone);
210
-    }
211
-
212
-
213
-    /**
214
-     *        set deleted
215
-     *
216
-     * @access        public
217
-     * @param        bool $ATT_deleted
218
-     * @throws EE_Error
219
-     */
220
-    public function set_deleted($ATT_deleted = false)
221
-    {
222
-        $this->set('ATT_deleted', $ATT_deleted);
223
-    }
224
-
225
-
226
-    /**
227
-     * Returns the value for the post_author id saved with the cpt
228
-     *
229
-     * @since 4.5.0
230
-     * @return int
231
-     * @throws EE_Error
232
-     */
233
-    public function wp_user()
234
-    {
235
-        return $this->get('ATT_author');
236
-    }
237
-
238
-
239
-    /**
240
-     *        get Attendee First Name
241
-     *
242
-     * @access        public
243
-     * @return string
244
-     * @throws EE_Error
245
-     */
246
-    public function fname()
247
-    {
248
-        return $this->get('ATT_fname');
249
-    }
250
-
251
-
252
-    /**
253
-     * echoes out the attendee's first name
254
-     *
255
-     * @return void
256
-     * @throws EE_Error
257
-     */
258
-    public function e_full_name()
259
-    {
260
-        echo $this->full_name();
261
-    }
262
-
263
-
264
-    /**
265
-     * Returns the first and last name concatenated together with a space.
266
-     *
267
-     * @param bool $apply_html_entities
268
-     * @return string
269
-     * @throws EE_Error
270
-     */
271
-    public function full_name($apply_html_entities = false)
272
-    {
273
-        $full_name = array(
274
-            $this->fname(),
275
-            $this->lname(),
276
-        );
277
-        $full_name = array_filter($full_name);
278
-        $full_name = implode(' ', $full_name);
279
-        return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
-    }
281
-
282
-
283
-    /**
284
-     * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
-     * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
-     * attendee.
287
-     *
288
-     * @param bool $apply_html_entities
289
-     * @return string
290
-     * @throws EE_Error
291
-     */
292
-    public function ATT_full_name($apply_html_entities = false)
293
-    {
294
-        return $apply_html_entities
295
-            ? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
-            : $this->get('ATT_full_name');
297
-    }
298
-
299
-
300
-    /**
301
-     *        get Attendee Last Name
302
-     *
303
-     * @access        public
304
-     * @return string
305
-     * @throws EE_Error
306
-     */
307
-    public function lname()
308
-    {
309
-        return $this->get('ATT_lname');
310
-    }
311
-
312
-
313
-    /**
314
-     * get Attendee bio
315
-     *
316
-     * @access public
317
-     * @return string
318
-     * @throws EE_Error
319
-     */
320
-    public function bio()
321
-    {
322
-        return $this->get('ATT_bio');
323
-    }
324
-
325
-
326
-    /**
327
-     * get Attendee short bio
328
-     *
329
-     * @access public
330
-     * @return string
331
-     * @throws EE_Error
332
-     */
333
-    public function short_bio()
334
-    {
335
-        return $this->get('ATT_short_bio');
336
-    }
337
-
338
-
339
-    /**
340
-     * Gets the attendee's full address as an array so client code can decide hwo to display it
341
-     *
342
-     * @return array numerically indexed, with each part of the address that is known.
343
-     * Eg, if the user only responded to state and country,
344
-     * it would be array(0=>'Alabama',1=>'USA')
345
-     * @return array
346
-     * @throws EE_Error
347
-     */
348
-    public function full_address_as_array()
349
-    {
350
-        $full_address_array = array();
351
-        $initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
352
-        foreach ($initial_address_fields as $address_field_name) {
353
-            $address_fields_value = $this->get($address_field_name);
354
-            if (! empty($address_fields_value)) {
355
-                $full_address_array[] = $address_fields_value;
356
-            }
357
-        }
358
-        // now handle state and country
359
-        $state_obj = $this->state_obj();
360
-        if ($state_obj instanceof EE_State) {
361
-            $full_address_array[] = $state_obj->name();
362
-        }
363
-        $country_obj = $this->country_obj();
364
-        if ($country_obj instanceof EE_Country) {
365
-            $full_address_array[] = $country_obj->name();
366
-        }
367
-        // lastly get the xip
368
-        $zip_value = $this->zip();
369
-        if (! empty($zip_value)) {
370
-            $full_address_array[] = $zip_value;
371
-        }
372
-        return $full_address_array;
373
-    }
374
-
375
-
376
-    /**
377
-     *        get Attendee Address
378
-     *
379
-     * @return string
380
-     * @throws EE_Error
381
-     */
382
-    public function address()
383
-    {
384
-        return $this->get('ATT_address');
385
-    }
386
-
387
-
388
-    /**
389
-     *        get Attendee Address2
390
-     *
391
-     * @return string
392
-     * @throws EE_Error
393
-     */
394
-    public function address2()
395
-    {
396
-        return $this->get('ATT_address2');
397
-    }
398
-
399
-
400
-    /**
401
-     *        get Attendee City
402
-     *
403
-     * @return string
404
-     * @throws EE_Error
405
-     */
406
-    public function city()
407
-    {
408
-        return $this->get('ATT_city');
409
-    }
410
-
411
-
412
-    /**
413
-     *        get Attendee State ID
414
-     *
415
-     * @return string
416
-     * @throws EE_Error
417
-     */
418
-    public function state_ID()
419
-    {
420
-        return $this->get('STA_ID');
421
-    }
422
-
423
-
424
-    /**
425
-     * @return string
426
-     * @throws EE_Error
427
-     */
428
-    public function state_abbrev()
429
-    {
430
-        return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
431
-    }
432
-
433
-
434
-    /**
435
-     * Gets the state set to this attendee
436
-     *
437
-     * @return EE_State
438
-     * @throws EE_Error
439
-     */
440
-    public function state_obj()
441
-    {
442
-        return $this->get_first_related('State');
443
-    }
444
-
445
-
446
-    /**
447
-     * Returns the state's name, otherwise 'Unknown'
448
-     *
449
-     * @return string
450
-     * @throws EE_Error
451
-     */
452
-    public function state_name()
453
-    {
454
-        if ($this->state_obj()) {
455
-            return $this->state_obj()->name();
456
-        } else {
457
-            return '';
458
-        }
459
-    }
460
-
461
-
462
-    /**
463
-     * either displays the state abbreviation or the state name, as determined
464
-     * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
465
-     * defaults to abbreviation
466
-     *
467
-     * @return string
468
-     * @throws EE_Error
469
-     */
470
-    public function state()
471
-    {
472
-        if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
473
-            return $this->state_abbrev();
474
-        }
475
-        return $this->state_name();
476
-    }
477
-
478
-
479
-    /**
480
-     *    get Attendee Country ISO Code
481
-     *
482
-     * @return string
483
-     * @throws EE_Error
484
-     */
485
-    public function country_ID()
486
-    {
487
-        return $this->get('CNT_ISO');
488
-    }
489
-
490
-
491
-    /**
492
-     * Gets country set for this attendee
493
-     *
494
-     * @return EE_Country
495
-     * @throws EE_Error
496
-     */
497
-    public function country_obj()
498
-    {
499
-        return $this->get_first_related('Country');
500
-    }
501
-
502
-
503
-    /**
504
-     * Returns the country's name if known, otherwise 'Unknown'
505
-     *
506
-     * @return string
507
-     * @throws EE_Error
508
-     */
509
-    public function country_name()
510
-    {
511
-        if ($this->country_obj()) {
512
-            return $this->country_obj()->name();
513
-        }
514
-        return '';
515
-    }
516
-
517
-
518
-    /**
519
-     * either displays the country ISO2 code or the country name, as determined
520
-     * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
521
-     * defaults to abbreviation
522
-     *
523
-     * @return string
524
-     * @throws EE_Error
525
-     */
526
-    public function country()
527
-    {
528
-        if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
529
-            return $this->country_ID();
530
-        }
531
-        return $this->country_name();
532
-    }
533
-
534
-
535
-    /**
536
-     *        get Attendee Zip/Postal Code
537
-     *
538
-     * @return string
539
-     * @throws EE_Error
540
-     */
541
-    public function zip()
542
-    {
543
-        return $this->get('ATT_zip');
544
-    }
545
-
546
-
547
-    /**
548
-     *        get Attendee Email Address
549
-     *
550
-     * @return string
551
-     * @throws EE_Error
552
-     */
553
-    public function email()
554
-    {
555
-        return $this->get('ATT_email');
556
-    }
557
-
558
-
559
-    /**
560
-     *        get Attendee Phone #
561
-     *
562
-     * @return string
563
-     * @throws EE_Error
564
-     */
565
-    public function phone()
566
-    {
567
-        return $this->get('ATT_phone');
568
-    }
569
-
570
-
571
-    /**
572
-     *    get deleted
573
-     *
574
-     * @return        bool
575
-     * @throws EE_Error
576
-     */
577
-    public function deleted()
578
-    {
579
-        return $this->get('ATT_deleted');
580
-    }
581
-
582
-
583
-    /**
584
-     * Gets registrations of this attendee
585
-     *
586
-     * @param array $query_params
587
-     * @return EE_Registration[]
588
-     * @throws EE_Error
589
-     */
590
-    public function get_registrations($query_params = array())
591
-    {
592
-        return $this->get_many_related('Registration', $query_params);
593
-    }
594
-
595
-
596
-    /**
597
-     * Gets the most recent registration of this attendee
598
-     *
599
-     * @return EE_Registration
600
-     * @throws EE_Error
601
-     */
602
-    public function get_most_recent_registration()
603
-    {
604
-        return $this->get_first_related(
605
-            'Registration',
606
-            array('order_by' => array('REG_date' => 'DESC'))
607
-        ); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
608
-    }
609
-
610
-
611
-    /**
612
-     * Gets the most recent registration for this attend at this event
613
-     *
614
-     * @param int $event_id
615
-     * @return EE_Registration
616
-     * @throws EE_Error
617
-     */
618
-    public function get_most_recent_registration_for_event($event_id)
619
-    {
620
-        return $this->get_first_related(
621
-            'Registration',
622
-            array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
623
-        );
624
-    }
625
-
626
-
627
-    /**
628
-     * returns any events attached to this attendee ($_Event property);
629
-     *
630
-     * @return array
631
-     * @throws EE_Error
632
-     */
633
-    public function events()
634
-    {
635
-        return $this->get_many_related('Event');
636
-    }
637
-
638
-
639
-    /**
640
-     * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
641
-     * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
642
-     * used to save the billing info
643
-     *
644
-     * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
645
-     * @return EE_Form_Section_Proper|null
646
-     * @throws EE_Error
647
-     */
648
-    public function billing_info_for_payment_method($payment_method)
649
-    {
650
-        $pm_type = $payment_method->type_obj();
651
-        if (! $pm_type instanceof EE_PMT_Base) {
652
-            return null;
653
-        }
654
-        $billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
655
-        if (! $billing_info) {
656
-            return null;
657
-        }
658
-        $billing_form = $pm_type->billing_form();
659
-        // double-check the form isn't totally hidden, in which case pretend there is no form
660
-        $form_totally_hidden = true;
661
-        foreach ($billing_form->inputs_in_subsections() as $input) {
662
-            if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
663
-                $form_totally_hidden = false;
664
-                break;
665
-            }
666
-        }
667
-        if ($form_totally_hidden) {
668
-            return null;
669
-        }
670
-        if ($billing_form instanceof EE_Form_Section_Proper) {
671
-            $billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
672
-        }
673
-
674
-        return $billing_form;
675
-    }
676
-
677
-
678
-    /**
679
-     * Gets the postmeta key that holds this attendee's billing info for the
680
-     * specified payment method
681
-     *
682
-     * @param EE_Payment_Method $payment_method
683
-     * @return string
684
-     * @throws EE_Error
685
-     */
686
-    public function get_billing_info_postmeta_name($payment_method)
687
-    {
688
-        if ($payment_method->type_obj() instanceof EE_PMT_Base) {
689
-            return 'billing_info_' . $payment_method->type_obj()->system_name();
690
-        }
691
-        return null;
692
-    }
693
-
694
-
695
-    /**
696
-     * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
697
-     * retrieve it
698
-     *
699
-     * @param EE_Billing_Attendee_Info_Form $billing_form
700
-     * @param EE_Payment_Method             $payment_method
701
-     * @return boolean
702
-     * @throws EE_Error
703
-     */
704
-    public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
705
-    {
706
-        if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
707
-            EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
708
-            return false;
709
-        }
710
-        $billing_form->clean_sensitive_data();
711
-        return update_post_meta(
712
-            $this->ID(),
713
-            $this->get_billing_info_postmeta_name($payment_method),
714
-            $billing_form->input_values(true)
715
-        );
716
-    }
717
-
718
-
719
-    /**
720
-     * Return the link to the admin details for the object.
721
-     *
722
-     * @return string
723
-     * @throws EE_Error
724
-     * @throws InvalidArgumentException
725
-     * @throws InvalidDataTypeException
726
-     * @throws InvalidInterfaceException
727
-     * @throws ReflectionException
728
-     */
729
-    public function get_admin_details_link()
730
-    {
731
-        return $this->get_admin_edit_link();
732
-    }
733
-
734
-
735
-    /**
736
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
737
-     *
738
-     * @return string
739
-     * @throws EE_Error
740
-     * @throws InvalidArgumentException
741
-     * @throws ReflectionException
742
-     * @throws InvalidDataTypeException
743
-     * @throws InvalidInterfaceException
744
-     */
745
-    public function get_admin_edit_link()
746
-    {
747
-        EE_Registry::instance()->load_helper('URL');
748
-        return EEH_URL::add_query_args_and_nonce(
749
-            array(
750
-                'page'   => 'espresso_registrations',
751
-                'action' => 'edit_attendee',
752
-                'post'   => $this->ID(),
753
-            ),
754
-            admin_url('admin.php')
755
-        );
756
-    }
757
-
758
-
759
-    /**
760
-     * Returns the link to a settings page for the object.
761
-     *
762
-     * @return string
763
-     * @throws EE_Error
764
-     * @throws InvalidArgumentException
765
-     * @throws InvalidDataTypeException
766
-     * @throws InvalidInterfaceException
767
-     * @throws ReflectionException
768
-     */
769
-    public function get_admin_settings_link()
770
-    {
771
-        return $this->get_admin_edit_link();
772
-    }
773
-
774
-
775
-    /**
776
-     * Returns the link to the "overview" for the object (typically the "list table" view).
777
-     *
778
-     * @return string
779
-     * @throws EE_Error
780
-     * @throws InvalidArgumentException
781
-     * @throws ReflectionException
782
-     * @throws InvalidDataTypeException
783
-     * @throws InvalidInterfaceException
784
-     */
785
-    public function get_admin_overview_link()
786
-    {
787
-        EE_Registry::instance()->load_helper('URL');
788
-        return EEH_URL::add_query_args_and_nonce(
789
-            array(
790
-                'page'   => 'espresso_registrations',
791
-                'action' => 'contact_list',
792
-            ),
793
-            admin_url('admin.php')
794
-        );
795
-    }
28
+	/**
29
+	 * Sets some dynamic defaults
30
+	 *
31
+	 * @param array  $fieldValues
32
+	 * @param bool   $bydb
33
+	 * @param string $timezone
34
+	 * @param array  $date_formats
35
+	 * @throws EE_Error
36
+	 */
37
+	protected function __construct($fieldValues = null, $bydb = false, $timezone = null, $date_formats = array())
38
+	{
39
+		if (! isset($fieldValues['ATT_full_name'])) {
40
+			$fname = isset($fieldValues['ATT_fname']) ? $fieldValues['ATT_fname'] . ' ' : '';
41
+			$lname = isset($fieldValues['ATT_lname']) ? $fieldValues['ATT_lname'] : '';
42
+			$fieldValues['ATT_full_name'] = $fname . $lname;
43
+		}
44
+		if (! isset($fieldValues['ATT_slug'])) {
45
+			// $fieldValues['ATT_slug'] = sanitize_key(wp_generate_password(20));
46
+			$fieldValues['ATT_slug'] = sanitize_title($fieldValues['ATT_full_name']);
47
+		}
48
+		if (! isset($fieldValues['ATT_short_bio']) && isset($fieldValues['ATT_bio'])) {
49
+			$fieldValues['ATT_short_bio'] = substr($fieldValues['ATT_bio'], 0, 50);
50
+		}
51
+		parent::__construct($fieldValues, $bydb, $timezone, $date_formats);
52
+	}
53
+
54
+
55
+	/**
56
+	 * @param array  $props_n_values          incoming values
57
+	 * @param string $timezone                incoming timezone (if not set the timezone set for the website will be
58
+	 *                                        used.)
59
+	 * @param array  $date_formats            incoming date_formats in an array where the first value is the
60
+	 *                                        date_format and the second value is the time format
61
+	 * @return EE_Attendee
62
+	 * @throws EE_Error
63
+	 */
64
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array())
65
+	{
66
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
67
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
68
+	}
69
+
70
+
71
+	/**
72
+	 * @param array  $props_n_values  incoming values from the database
73
+	 * @param string $timezone        incoming timezone as set by the model.  If not set the timezone for
74
+	 *                                the website will be used.
75
+	 * @return EE_Attendee
76
+	 */
77
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null)
78
+	{
79
+		return new self($props_n_values, true, $timezone);
80
+	}
81
+
82
+
83
+	/**
84
+	 *        Set Attendee First Name
85
+	 *
86
+	 * @access        public
87
+	 * @param string $fname
88
+	 * @throws EE_Error
89
+	 */
90
+	public function set_fname($fname = '')
91
+	{
92
+		$this->set('ATT_fname', $fname);
93
+	}
94
+
95
+
96
+	/**
97
+	 *        Set Attendee Last Name
98
+	 *
99
+	 * @access        public
100
+	 * @param string $lname
101
+	 * @throws EE_Error
102
+	 */
103
+	public function set_lname($lname = '')
104
+	{
105
+		$this->set('ATT_lname', $lname);
106
+	}
107
+
108
+
109
+	/**
110
+	 *        Set Attendee Address
111
+	 *
112
+	 * @access        public
113
+	 * @param string $address
114
+	 * @throws EE_Error
115
+	 */
116
+	public function set_address($address = '')
117
+	{
118
+		$this->set('ATT_address', $address);
119
+	}
120
+
121
+
122
+	/**
123
+	 *        Set Attendee Address2
124
+	 *
125
+	 * @access        public
126
+	 * @param        string $address2
127
+	 * @throws EE_Error
128
+	 */
129
+	public function set_address2($address2 = '')
130
+	{
131
+		$this->set('ATT_address2', $address2);
132
+	}
133
+
134
+
135
+	/**
136
+	 *        Set Attendee City
137
+	 *
138
+	 * @access        public
139
+	 * @param        string $city
140
+	 * @throws EE_Error
141
+	 */
142
+	public function set_city($city = '')
143
+	{
144
+		$this->set('ATT_city', $city);
145
+	}
146
+
147
+
148
+	/**
149
+	 *        Set Attendee State ID
150
+	 *
151
+	 * @access        public
152
+	 * @param        int $STA_ID
153
+	 * @throws EE_Error
154
+	 */
155
+	public function set_state($STA_ID = 0)
156
+	{
157
+		$this->set('STA_ID', $STA_ID);
158
+	}
159
+
160
+
161
+	/**
162
+	 *        Set Attendee Country ISO Code
163
+	 *
164
+	 * @access        public
165
+	 * @param        string $CNT_ISO
166
+	 * @throws EE_Error
167
+	 */
168
+	public function set_country($CNT_ISO = '')
169
+	{
170
+		$this->set('CNT_ISO', $CNT_ISO);
171
+	}
172
+
173
+
174
+	/**
175
+	 *        Set Attendee Zip/Postal Code
176
+	 *
177
+	 * @access        public
178
+	 * @param        string $zip
179
+	 * @throws EE_Error
180
+	 */
181
+	public function set_zip($zip = '')
182
+	{
183
+		$this->set('ATT_zip', $zip);
184
+	}
185
+
186
+
187
+	/**
188
+	 *        Set Attendee Email Address
189
+	 *
190
+	 * @access        public
191
+	 * @param        string $email
192
+	 * @throws EE_Error
193
+	 */
194
+	public function set_email($email = '')
195
+	{
196
+		$this->set('ATT_email', $email);
197
+	}
198
+
199
+
200
+	/**
201
+	 *        Set Attendee Phone
202
+	 *
203
+	 * @access        public
204
+	 * @param        string $phone
205
+	 * @throws EE_Error
206
+	 */
207
+	public function set_phone($phone = '')
208
+	{
209
+		$this->set('ATT_phone', $phone);
210
+	}
211
+
212
+
213
+	/**
214
+	 *        set deleted
215
+	 *
216
+	 * @access        public
217
+	 * @param        bool $ATT_deleted
218
+	 * @throws EE_Error
219
+	 */
220
+	public function set_deleted($ATT_deleted = false)
221
+	{
222
+		$this->set('ATT_deleted', $ATT_deleted);
223
+	}
224
+
225
+
226
+	/**
227
+	 * Returns the value for the post_author id saved with the cpt
228
+	 *
229
+	 * @since 4.5.0
230
+	 * @return int
231
+	 * @throws EE_Error
232
+	 */
233
+	public function wp_user()
234
+	{
235
+		return $this->get('ATT_author');
236
+	}
237
+
238
+
239
+	/**
240
+	 *        get Attendee First Name
241
+	 *
242
+	 * @access        public
243
+	 * @return string
244
+	 * @throws EE_Error
245
+	 */
246
+	public function fname()
247
+	{
248
+		return $this->get('ATT_fname');
249
+	}
250
+
251
+
252
+	/**
253
+	 * echoes out the attendee's first name
254
+	 *
255
+	 * @return void
256
+	 * @throws EE_Error
257
+	 */
258
+	public function e_full_name()
259
+	{
260
+		echo $this->full_name();
261
+	}
262
+
263
+
264
+	/**
265
+	 * Returns the first and last name concatenated together with a space.
266
+	 *
267
+	 * @param bool $apply_html_entities
268
+	 * @return string
269
+	 * @throws EE_Error
270
+	 */
271
+	public function full_name($apply_html_entities = false)
272
+	{
273
+		$full_name = array(
274
+			$this->fname(),
275
+			$this->lname(),
276
+		);
277
+		$full_name = array_filter($full_name);
278
+		$full_name = implode(' ', $full_name);
279
+		return $apply_html_entities ? htmlentities($full_name, ENT_QUOTES, 'UTF-8') : $full_name;
280
+	}
281
+
282
+
283
+	/**
284
+	 * This returns the value of the `ATT_full_name` field which is usually equivalent to calling `full_name()` unless
285
+	 * the post_title field has been directly modified in the db for the post (espresso_attendees post type) for this
286
+	 * attendee.
287
+	 *
288
+	 * @param bool $apply_html_entities
289
+	 * @return string
290
+	 * @throws EE_Error
291
+	 */
292
+	public function ATT_full_name($apply_html_entities = false)
293
+	{
294
+		return $apply_html_entities
295
+			? htmlentities($this->get('ATT_full_name'), ENT_QUOTES, 'UTF-8')
296
+			: $this->get('ATT_full_name');
297
+	}
298
+
299
+
300
+	/**
301
+	 *        get Attendee Last Name
302
+	 *
303
+	 * @access        public
304
+	 * @return string
305
+	 * @throws EE_Error
306
+	 */
307
+	public function lname()
308
+	{
309
+		return $this->get('ATT_lname');
310
+	}
311
+
312
+
313
+	/**
314
+	 * get Attendee bio
315
+	 *
316
+	 * @access public
317
+	 * @return string
318
+	 * @throws EE_Error
319
+	 */
320
+	public function bio()
321
+	{
322
+		return $this->get('ATT_bio');
323
+	}
324
+
325
+
326
+	/**
327
+	 * get Attendee short bio
328
+	 *
329
+	 * @access public
330
+	 * @return string
331
+	 * @throws EE_Error
332
+	 */
333
+	public function short_bio()
334
+	{
335
+		return $this->get('ATT_short_bio');
336
+	}
337
+
338
+
339
+	/**
340
+	 * Gets the attendee's full address as an array so client code can decide hwo to display it
341
+	 *
342
+	 * @return array numerically indexed, with each part of the address that is known.
343
+	 * Eg, if the user only responded to state and country,
344
+	 * it would be array(0=>'Alabama',1=>'USA')
345
+	 * @return array
346
+	 * @throws EE_Error
347
+	 */
348
+	public function full_address_as_array()
349
+	{
350
+		$full_address_array = array();
351
+		$initial_address_fields = array('ATT_address', 'ATT_address2', 'ATT_city',);
352
+		foreach ($initial_address_fields as $address_field_name) {
353
+			$address_fields_value = $this->get($address_field_name);
354
+			if (! empty($address_fields_value)) {
355
+				$full_address_array[] = $address_fields_value;
356
+			}
357
+		}
358
+		// now handle state and country
359
+		$state_obj = $this->state_obj();
360
+		if ($state_obj instanceof EE_State) {
361
+			$full_address_array[] = $state_obj->name();
362
+		}
363
+		$country_obj = $this->country_obj();
364
+		if ($country_obj instanceof EE_Country) {
365
+			$full_address_array[] = $country_obj->name();
366
+		}
367
+		// lastly get the xip
368
+		$zip_value = $this->zip();
369
+		if (! empty($zip_value)) {
370
+			$full_address_array[] = $zip_value;
371
+		}
372
+		return $full_address_array;
373
+	}
374
+
375
+
376
+	/**
377
+	 *        get Attendee Address
378
+	 *
379
+	 * @return string
380
+	 * @throws EE_Error
381
+	 */
382
+	public function address()
383
+	{
384
+		return $this->get('ATT_address');
385
+	}
386
+
387
+
388
+	/**
389
+	 *        get Attendee Address2
390
+	 *
391
+	 * @return string
392
+	 * @throws EE_Error
393
+	 */
394
+	public function address2()
395
+	{
396
+		return $this->get('ATT_address2');
397
+	}
398
+
399
+
400
+	/**
401
+	 *        get Attendee City
402
+	 *
403
+	 * @return string
404
+	 * @throws EE_Error
405
+	 */
406
+	public function city()
407
+	{
408
+		return $this->get('ATT_city');
409
+	}
410
+
411
+
412
+	/**
413
+	 *        get Attendee State ID
414
+	 *
415
+	 * @return string
416
+	 * @throws EE_Error
417
+	 */
418
+	public function state_ID()
419
+	{
420
+		return $this->get('STA_ID');
421
+	}
422
+
423
+
424
+	/**
425
+	 * @return string
426
+	 * @throws EE_Error
427
+	 */
428
+	public function state_abbrev()
429
+	{
430
+		return $this->state_obj() instanceof EE_State ? $this->state_obj()->abbrev() : '';
431
+	}
432
+
433
+
434
+	/**
435
+	 * Gets the state set to this attendee
436
+	 *
437
+	 * @return EE_State
438
+	 * @throws EE_Error
439
+	 */
440
+	public function state_obj()
441
+	{
442
+		return $this->get_first_related('State');
443
+	}
444
+
445
+
446
+	/**
447
+	 * Returns the state's name, otherwise 'Unknown'
448
+	 *
449
+	 * @return string
450
+	 * @throws EE_Error
451
+	 */
452
+	public function state_name()
453
+	{
454
+		if ($this->state_obj()) {
455
+			return $this->state_obj()->name();
456
+		} else {
457
+			return '';
458
+		}
459
+	}
460
+
461
+
462
+	/**
463
+	 * either displays the state abbreviation or the state name, as determined
464
+	 * by the "FHEE__EEI_Address__state__use_abbreviation" filter.
465
+	 * defaults to abbreviation
466
+	 *
467
+	 * @return string
468
+	 * @throws EE_Error
469
+	 */
470
+	public function state()
471
+	{
472
+		if (apply_filters('FHEE__EEI_Address__state__use_abbreviation', true, $this->state_obj())) {
473
+			return $this->state_abbrev();
474
+		}
475
+		return $this->state_name();
476
+	}
477
+
478
+
479
+	/**
480
+	 *    get Attendee Country ISO Code
481
+	 *
482
+	 * @return string
483
+	 * @throws EE_Error
484
+	 */
485
+	public function country_ID()
486
+	{
487
+		return $this->get('CNT_ISO');
488
+	}
489
+
490
+
491
+	/**
492
+	 * Gets country set for this attendee
493
+	 *
494
+	 * @return EE_Country
495
+	 * @throws EE_Error
496
+	 */
497
+	public function country_obj()
498
+	{
499
+		return $this->get_first_related('Country');
500
+	}
501
+
502
+
503
+	/**
504
+	 * Returns the country's name if known, otherwise 'Unknown'
505
+	 *
506
+	 * @return string
507
+	 * @throws EE_Error
508
+	 */
509
+	public function country_name()
510
+	{
511
+		if ($this->country_obj()) {
512
+			return $this->country_obj()->name();
513
+		}
514
+		return '';
515
+	}
516
+
517
+
518
+	/**
519
+	 * either displays the country ISO2 code or the country name, as determined
520
+	 * by the "FHEE__EEI_Address__country__use_abbreviation" filter.
521
+	 * defaults to abbreviation
522
+	 *
523
+	 * @return string
524
+	 * @throws EE_Error
525
+	 */
526
+	public function country()
527
+	{
528
+		if (apply_filters('FHEE__EEI_Address__country__use_abbreviation', true, $this->country_obj())) {
529
+			return $this->country_ID();
530
+		}
531
+		return $this->country_name();
532
+	}
533
+
534
+
535
+	/**
536
+	 *        get Attendee Zip/Postal Code
537
+	 *
538
+	 * @return string
539
+	 * @throws EE_Error
540
+	 */
541
+	public function zip()
542
+	{
543
+		return $this->get('ATT_zip');
544
+	}
545
+
546
+
547
+	/**
548
+	 *        get Attendee Email Address
549
+	 *
550
+	 * @return string
551
+	 * @throws EE_Error
552
+	 */
553
+	public function email()
554
+	{
555
+		return $this->get('ATT_email');
556
+	}
557
+
558
+
559
+	/**
560
+	 *        get Attendee Phone #
561
+	 *
562
+	 * @return string
563
+	 * @throws EE_Error
564
+	 */
565
+	public function phone()
566
+	{
567
+		return $this->get('ATT_phone');
568
+	}
569
+
570
+
571
+	/**
572
+	 *    get deleted
573
+	 *
574
+	 * @return        bool
575
+	 * @throws EE_Error
576
+	 */
577
+	public function deleted()
578
+	{
579
+		return $this->get('ATT_deleted');
580
+	}
581
+
582
+
583
+	/**
584
+	 * Gets registrations of this attendee
585
+	 *
586
+	 * @param array $query_params
587
+	 * @return EE_Registration[]
588
+	 * @throws EE_Error
589
+	 */
590
+	public function get_registrations($query_params = array())
591
+	{
592
+		return $this->get_many_related('Registration', $query_params);
593
+	}
594
+
595
+
596
+	/**
597
+	 * Gets the most recent registration of this attendee
598
+	 *
599
+	 * @return EE_Registration
600
+	 * @throws EE_Error
601
+	 */
602
+	public function get_most_recent_registration()
603
+	{
604
+		return $this->get_first_related(
605
+			'Registration',
606
+			array('order_by' => array('REG_date' => 'DESC'))
607
+		); // null, 'REG_date', 'DESC', '=', 'OBJECT_K');
608
+	}
609
+
610
+
611
+	/**
612
+	 * Gets the most recent registration for this attend at this event
613
+	 *
614
+	 * @param int $event_id
615
+	 * @return EE_Registration
616
+	 * @throws EE_Error
617
+	 */
618
+	public function get_most_recent_registration_for_event($event_id)
619
+	{
620
+		return $this->get_first_related(
621
+			'Registration',
622
+			array(array('EVT_ID' => $event_id), 'order_by' => array('REG_date' => 'DESC'))
623
+		);
624
+	}
625
+
626
+
627
+	/**
628
+	 * returns any events attached to this attendee ($_Event property);
629
+	 *
630
+	 * @return array
631
+	 * @throws EE_Error
632
+	 */
633
+	public function events()
634
+	{
635
+		return $this->get_many_related('Event');
636
+	}
637
+
638
+
639
+	/**
640
+	 * Gets the billing info array where keys match espresso_reg_page_billing_inputs(),
641
+	 * and keys are their cleaned values. @see EE_Attendee::save_and_clean_billing_info_for_payment_method() which was
642
+	 * used to save the billing info
643
+	 *
644
+	 * @param EE_Payment_Method $payment_method the _gateway_name property on the gateway class
645
+	 * @return EE_Form_Section_Proper|null
646
+	 * @throws EE_Error
647
+	 */
648
+	public function billing_info_for_payment_method($payment_method)
649
+	{
650
+		$pm_type = $payment_method->type_obj();
651
+		if (! $pm_type instanceof EE_PMT_Base) {
652
+			return null;
653
+		}
654
+		$billing_info = $this->get_post_meta($this->get_billing_info_postmeta_name($payment_method), true);
655
+		if (! $billing_info) {
656
+			return null;
657
+		}
658
+		$billing_form = $pm_type->billing_form();
659
+		// double-check the form isn't totally hidden, in which case pretend there is no form
660
+		$form_totally_hidden = true;
661
+		foreach ($billing_form->inputs_in_subsections() as $input) {
662
+			if (! $input->get_display_strategy() instanceof EE_Hidden_Display_Strategy) {
663
+				$form_totally_hidden = false;
664
+				break;
665
+			}
666
+		}
667
+		if ($form_totally_hidden) {
668
+			return null;
669
+		}
670
+		if ($billing_form instanceof EE_Form_Section_Proper) {
671
+			$billing_form->receive_form_submission(array($billing_form->name() => $billing_info), false);
672
+		}
673
+
674
+		return $billing_form;
675
+	}
676
+
677
+
678
+	/**
679
+	 * Gets the postmeta key that holds this attendee's billing info for the
680
+	 * specified payment method
681
+	 *
682
+	 * @param EE_Payment_Method $payment_method
683
+	 * @return string
684
+	 * @throws EE_Error
685
+	 */
686
+	public function get_billing_info_postmeta_name($payment_method)
687
+	{
688
+		if ($payment_method->type_obj() instanceof EE_PMT_Base) {
689
+			return 'billing_info_' . $payment_method->type_obj()->system_name();
690
+		}
691
+		return null;
692
+	}
693
+
694
+
695
+	/**
696
+	 * Saves the billing info to the attendee. @see EE_Attendee::billing_info_for_payment_method() which is used to
697
+	 * retrieve it
698
+	 *
699
+	 * @param EE_Billing_Attendee_Info_Form $billing_form
700
+	 * @param EE_Payment_Method             $payment_method
701
+	 * @return boolean
702
+	 * @throws EE_Error
703
+	 */
704
+	public function save_and_clean_billing_info_for_payment_method($billing_form, $payment_method)
705
+	{
706
+		if (! $billing_form instanceof EE_Billing_Attendee_Info_Form) {
707
+			EE_Error::add_error(__('Cannot save billing info because there is none.', 'event_espresso'));
708
+			return false;
709
+		}
710
+		$billing_form->clean_sensitive_data();
711
+		return update_post_meta(
712
+			$this->ID(),
713
+			$this->get_billing_info_postmeta_name($payment_method),
714
+			$billing_form->input_values(true)
715
+		);
716
+	}
717
+
718
+
719
+	/**
720
+	 * Return the link to the admin details for the object.
721
+	 *
722
+	 * @return string
723
+	 * @throws EE_Error
724
+	 * @throws InvalidArgumentException
725
+	 * @throws InvalidDataTypeException
726
+	 * @throws InvalidInterfaceException
727
+	 * @throws ReflectionException
728
+	 */
729
+	public function get_admin_details_link()
730
+	{
731
+		return $this->get_admin_edit_link();
732
+	}
733
+
734
+
735
+	/**
736
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
737
+	 *
738
+	 * @return string
739
+	 * @throws EE_Error
740
+	 * @throws InvalidArgumentException
741
+	 * @throws ReflectionException
742
+	 * @throws InvalidDataTypeException
743
+	 * @throws InvalidInterfaceException
744
+	 */
745
+	public function get_admin_edit_link()
746
+	{
747
+		EE_Registry::instance()->load_helper('URL');
748
+		return EEH_URL::add_query_args_and_nonce(
749
+			array(
750
+				'page'   => 'espresso_registrations',
751
+				'action' => 'edit_attendee',
752
+				'post'   => $this->ID(),
753
+			),
754
+			admin_url('admin.php')
755
+		);
756
+	}
757
+
758
+
759
+	/**
760
+	 * Returns the link to a settings page for the object.
761
+	 *
762
+	 * @return string
763
+	 * @throws EE_Error
764
+	 * @throws InvalidArgumentException
765
+	 * @throws InvalidDataTypeException
766
+	 * @throws InvalidInterfaceException
767
+	 * @throws ReflectionException
768
+	 */
769
+	public function get_admin_settings_link()
770
+	{
771
+		return $this->get_admin_edit_link();
772
+	}
773
+
774
+
775
+	/**
776
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
777
+	 *
778
+	 * @return string
779
+	 * @throws EE_Error
780
+	 * @throws InvalidArgumentException
781
+	 * @throws ReflectionException
782
+	 * @throws InvalidDataTypeException
783
+	 * @throws InvalidInterfaceException
784
+	 */
785
+	public function get_admin_overview_link()
786
+	{
787
+		EE_Registry::instance()->load_helper('URL');
788
+		return EEH_URL::add_query_args_and_nonce(
789
+			array(
790
+				'page'   => 'espresso_registrations',
791
+				'action' => 'contact_list',
792
+			),
793
+			admin_url('admin.php')
794
+		);
795
+	}
796 796
 }
Please login to merge, or discard this patch.
core/db_classes/EE_WP_User.class.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@
 block discarded – undo
51 51
      */
52 52
     public function wp_user_obj()
53 53
     {
54
-        if (! $this->_wp_user_obj) {
54
+        if ( ! $this->_wp_user_obj) {
55 55
             $this->_wp_user_obj = get_user_by('ID', $this->ID());
56 56
         }
57 57
         return $this->_wp_user_obj;
Please login to merge, or discard this patch.
Indentation   +79 added lines, -79 removed lines patch added patch discarded remove patch
@@ -11,91 +11,91 @@
 block discarded – undo
11 11
 class EE_WP_User extends EE_Base_Class implements EEI_Admin_Links
12 12
 {
13 13
 
14
-    /**
15
-     * @var WP_User
16
-     */
17
-    protected $_wp_user_obj;
14
+	/**
15
+	 * @var WP_User
16
+	 */
17
+	protected $_wp_user_obj;
18 18
 
19
-    /**
20
-     * @param array $props_n_values
21
-     * @return EE_WP_User|mixed
22
-     */
23
-    public static function new_instance($props_n_values = array())
24
-    {
25
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__);
26
-        return $has_object ? $has_object : new self($props_n_values);
27
-    }
19
+	/**
20
+	 * @param array $props_n_values
21
+	 * @return EE_WP_User|mixed
22
+	 */
23
+	public static function new_instance($props_n_values = array())
24
+	{
25
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
26
+		return $has_object ? $has_object : new self($props_n_values);
27
+	}
28 28
 
29 29
 
30
-    /**
31
-     * @param array $props_n_values
32
-     * @return EE_WP_User
33
-     */
34
-    public static function new_instance_from_db($props_n_values = array())
35
-    {
36
-        return new self($props_n_values, true);
37
-    }
30
+	/**
31
+	 * @param array $props_n_values
32
+	 * @return EE_WP_User
33
+	 */
34
+	public static function new_instance_from_db($props_n_values = array())
35
+	{
36
+		return new self($props_n_values, true);
37
+	}
38 38
 
39
-    /**
40
-     * Return a normal WP_User object (caches the object for future calls)
41
-     *
42
-     * @return WP_User
43
-     */
44
-    public function wp_user_obj()
45
-    {
46
-        if (! $this->_wp_user_obj) {
47
-            $this->_wp_user_obj = get_user_by('ID', $this->ID());
48
-        }
49
-        return $this->_wp_user_obj;
50
-    }
39
+	/**
40
+	 * Return a normal WP_User object (caches the object for future calls)
41
+	 *
42
+	 * @return WP_User
43
+	 */
44
+	public function wp_user_obj()
45
+	{
46
+		if (! $this->_wp_user_obj) {
47
+			$this->_wp_user_obj = get_user_by('ID', $this->ID());
48
+		}
49
+		return $this->_wp_user_obj;
50
+	}
51 51
 
52
-    /**
53
-     * Return the link to the admin details for the object.
54
-     *
55
-     * @return string
56
-     */
57
-    public function get_admin_details_link()
58
-    {
59
-        return $this->get_admin_edit_link();
60
-    }
52
+	/**
53
+	 * Return the link to the admin details for the object.
54
+	 *
55
+	 * @return string
56
+	 */
57
+	public function get_admin_details_link()
58
+	{
59
+		return $this->get_admin_edit_link();
60
+	}
61 61
 
62
-    /**
63
-     * Returns the link to the editor for the object.  Sometimes this is the same as the details.
64
-     *
65
-     * @return string
66
-     */
67
-    public function get_admin_edit_link()
68
-    {
69
-        return esc_url(
70
-            add_query_arg(
71
-                'wp_http_referer',
72
-                urlencode(
73
-                    wp_unslash(
74
-                        $_SERVER['REQUEST_URI']
75
-                    )
76
-                ),
77
-                get_edit_user_link($this->ID())
78
-            )
79
-        );
80
-    }
62
+	/**
63
+	 * Returns the link to the editor for the object.  Sometimes this is the same as the details.
64
+	 *
65
+	 * @return string
66
+	 */
67
+	public function get_admin_edit_link()
68
+	{
69
+		return esc_url(
70
+			add_query_arg(
71
+				'wp_http_referer',
72
+				urlencode(
73
+					wp_unslash(
74
+						$_SERVER['REQUEST_URI']
75
+					)
76
+				),
77
+				get_edit_user_link($this->ID())
78
+			)
79
+		);
80
+	}
81 81
 
82
-    /**
83
-     * Returns the link to a settings page for the object.
84
-     *
85
-     * @return string
86
-     */
87
-    public function get_admin_settings_link()
88
-    {
89
-        return $this->get_admin_edit_link();
90
-    }
82
+	/**
83
+	 * Returns the link to a settings page for the object.
84
+	 *
85
+	 * @return string
86
+	 */
87
+	public function get_admin_settings_link()
88
+	{
89
+		return $this->get_admin_edit_link();
90
+	}
91 91
 
92
-    /**
93
-     * Returns the link to the "overview" for the object (typically the "list table" view).
94
-     *
95
-     * @return string
96
-     */
97
-    public function get_admin_overview_link()
98
-    {
99
-        return admin_url('users.php');
100
-    }
92
+	/**
93
+	 * Returns the link to the "overview" for the object (typically the "list table" view).
94
+	 *
95
+	 * @return string
96
+	 */
97
+	public function get_admin_overview_link()
98
+	{
99
+		return admin_url('users.php');
100
+	}
101 101
 }
Please login to merge, or discard this patch.
core/EE_Module_Request_Router.core.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -182,7 +182,7 @@  discard block
 block discarded – undo
182 182
      * this method instantiates modules and calls the method that was defined when the route was registered
183 183
      *
184 184
      * @param string $module_name
185
-     * @return EED_Module|object|null
185
+     * @return null|EED_Module
186 186
      * @throws ReflectionException
187 187
      */
188 188
     public static function module_factory($module_name)
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
 
253 253
 
254 254
     /**
255
-     * @param $current_route
255
+     * @param string $current_route
256 256
      * @return string
257 257
      */
258 258
     public function get_view($current_route)
Please login to merge, or discard this patch.
Indentation   +235 added lines, -235 removed lines patch added patch discarded remove patch
@@ -15,255 +15,255 @@
 block discarded – undo
15 15
 final class EE_Module_Request_Router implements InterminableInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @var EE_Request $request
20
-     */
21
-    private $request;
18
+	/**
19
+	 * @var EE_Request $request
20
+	 */
21
+	private $request;
22 22
 
23
-    /**
24
-     * @var array $_previous_routes
25
-     */
26
-    private static $_previous_routes = array();
23
+	/**
24
+	 * @var array $_previous_routes
25
+	 */
26
+	private static $_previous_routes = array();
27 27
 
28
-    /**
29
-     * @var WP_Query $WP_Query
30
-     */
31
-    public $WP_Query;
28
+	/**
29
+	 * @var WP_Query $WP_Query
30
+	 */
31
+	public $WP_Query;
32 32
 
33 33
 
34
-    /**
35
-     * EE_Module_Request_Router constructor.
36
-     *
37
-     * @param EE_Request $request
38
-     */
39
-    public function __construct(EE_Request $request)
40
-    {
41
-        $this->request = $request;
42
-    }
34
+	/**
35
+	 * EE_Module_Request_Router constructor.
36
+	 *
37
+	 * @param EE_Request $request
38
+	 */
39
+	public function __construct(EE_Request $request)
40
+	{
41
+		$this->request = $request;
42
+	}
43 43
 
44 44
 
45
-    /**
46
-     * on the first call  to this method, it checks the EE_Request_Handler for a "route"
47
-     * on subsequent calls to this method,
48
-     * instead of checking the EE_Request_Handler for a route, it checks the previous routes array,
49
-     * and checks if the last called route has any forwarding routes registered for it
50
-     *
51
-     * @param WP_Query $WP_Query
52
-     * @return NULL|string
53
-     * @throws EE_Error
54
-     * @throws ReflectionException
55
-     */
56
-    public function get_route(WP_Query $WP_Query)
57
-    {
58
-        $this->WP_Query = $WP_Query;
59
-        // assume this if first route being called
60
-        $previous_route = false;
61
-        // but is it really ???
62
-        if (! empty(self::$_previous_routes)) {
63
-            // get last run route
64
-            $previous_routes = array_values(self::$_previous_routes);
65
-            $previous_route = array_pop($previous_routes);
66
-        }
67
-        //  has another route already been run ?
68
-        if ($previous_route) {
69
-            // check if  forwarding has been set
70
-            $current_route = $this->get_forward($previous_route);
71
-            try {
72
-                // check for recursive forwarding
73
-                if (isset(self::$_previous_routes[ $current_route ])) {
74
-                    throw new EE_Error(
75
-                        sprintf(
76
-                            __(
77
-                                'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
78
-                                'event_espresso'
79
-                            ),
80
-                            $current_route
81
-                        )
82
-                    );
83
-                }
84
-            } catch (EE_Error $e) {
85
-                $e->get_error();
86
-                return null;
87
-            }
88
-        } else {
89
-            // first route called
90
-            $current_route = null;
91
-            // grab all routes
92
-            $routes = EE_Config::get_routes();
93
-            foreach ($routes as $key => $route) {
94
-                // first determine if route key uses w?ldc*rds
95
-                $uses_wildcards = strpos($key, '?') !== false
96
-                                  || strpos($key, '*') !== false;
97
-                // check request for module route
98
-                $route_found = $uses_wildcards
99
-                    ? $this->request->matches($key)
100
-                    : $this->request->is_set($key);
101
-                if ($route_found) {
102
-                    $current_route = $uses_wildcards
103
-                        ? $this->request->getMatch($key)
104
-                        : $this->request->get($key);
105
-                    $current_route = sanitize_text_field($current_route);
106
-                    if ($current_route) {
107
-                        $current_route = array($key, $current_route);
108
-                        break;
109
-                    }
110
-                }
111
-            }
112
-        }
113
-        // sorry, but I can't read what you route !
114
-        if (empty($current_route)) {
115
-            return null;
116
-        }
117
-        // add route to previous routes array
118
-        self::$_previous_routes[] = $current_route;
119
-        return $current_route;
120
-    }
45
+	/**
46
+	 * on the first call  to this method, it checks the EE_Request_Handler for a "route"
47
+	 * on subsequent calls to this method,
48
+	 * instead of checking the EE_Request_Handler for a route, it checks the previous routes array,
49
+	 * and checks if the last called route has any forwarding routes registered for it
50
+	 *
51
+	 * @param WP_Query $WP_Query
52
+	 * @return NULL|string
53
+	 * @throws EE_Error
54
+	 * @throws ReflectionException
55
+	 */
56
+	public function get_route(WP_Query $WP_Query)
57
+	{
58
+		$this->WP_Query = $WP_Query;
59
+		// assume this if first route being called
60
+		$previous_route = false;
61
+		// but is it really ???
62
+		if (! empty(self::$_previous_routes)) {
63
+			// get last run route
64
+			$previous_routes = array_values(self::$_previous_routes);
65
+			$previous_route = array_pop($previous_routes);
66
+		}
67
+		//  has another route already been run ?
68
+		if ($previous_route) {
69
+			// check if  forwarding has been set
70
+			$current_route = $this->get_forward($previous_route);
71
+			try {
72
+				// check for recursive forwarding
73
+				if (isset(self::$_previous_routes[ $current_route ])) {
74
+					throw new EE_Error(
75
+						sprintf(
76
+							__(
77
+								'An error occurred. The %s route has already been called, and therefore can not be forwarded to, because an infinite loop would be created and break the interweb.',
78
+								'event_espresso'
79
+							),
80
+							$current_route
81
+						)
82
+					);
83
+				}
84
+			} catch (EE_Error $e) {
85
+				$e->get_error();
86
+				return null;
87
+			}
88
+		} else {
89
+			// first route called
90
+			$current_route = null;
91
+			// grab all routes
92
+			$routes = EE_Config::get_routes();
93
+			foreach ($routes as $key => $route) {
94
+				// first determine if route key uses w?ldc*rds
95
+				$uses_wildcards = strpos($key, '?') !== false
96
+								  || strpos($key, '*') !== false;
97
+				// check request for module route
98
+				$route_found = $uses_wildcards
99
+					? $this->request->matches($key)
100
+					: $this->request->is_set($key);
101
+				if ($route_found) {
102
+					$current_route = $uses_wildcards
103
+						? $this->request->getMatch($key)
104
+						: $this->request->get($key);
105
+					$current_route = sanitize_text_field($current_route);
106
+					if ($current_route) {
107
+						$current_route = array($key, $current_route);
108
+						break;
109
+					}
110
+				}
111
+			}
112
+		}
113
+		// sorry, but I can't read what you route !
114
+		if (empty($current_route)) {
115
+			return null;
116
+		}
117
+		// add route to previous routes array
118
+		self::$_previous_routes[] = $current_route;
119
+		return $current_route;
120
+	}
121 121
 
122 122
 
123
-    /**
124
-     * this method simply takes a valid route, and resolves what module class method the route points to
125
-     *
126
-     * @param string $key
127
-     * @param string $current_route
128
-     * @return mixed EED_Module | boolean
129
-     * @throws EE_Error
130
-     * @throws ReflectionException
131
-     */
132
-    public function resolve_route($key, $current_route)
133
-    {
134
-        // get module method that route has been mapped to
135
-        $module_method = EE_Config::get_route($current_route, $key);
136
-        // verify result was returned
137
-        if (empty($module_method)) {
138
-            $msg = sprintf(
139
-                __('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
140
-                $current_route
141
-            );
142
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
143
-            return false;
144
-        }
145
-        // verify that result is an array
146
-        if (! is_array($module_method)) {
147
-            $msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
148
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
149
-            return false;
150
-        }
151
-        // grab module name
152
-        $module_name = $module_method[0];
153
-        // verify that a class method was registered properly
154
-        if (! isset($module_method[1])) {
155
-            $msg = sprintf(
156
-                __('A class method for the %s  route has not been properly registered.', 'event_espresso'),
157
-                $current_route
158
-            );
159
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
160
-            return false;
161
-        }
162
-        // grab method
163
-        $method = $module_method[1];
164
-        // verify that class exists
165
-        if (! class_exists($module_name)) {
166
-            $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
167
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
168
-            return false;
169
-        }
170
-        // verify that method exists
171
-        if (! method_exists($module_name, $method)) {
172
-            $msg = sprintf(
173
-                __('The class method %s for the %s route is in invalid.', 'event_espresso'),
174
-                $method,
175
-                $current_route
176
-            );
177
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
178
-            return false;
179
-        }
180
-        // instantiate module and call route method
181
-        return $this->_module_router($module_name, $method);
182
-    }
123
+	/**
124
+	 * this method simply takes a valid route, and resolves what module class method the route points to
125
+	 *
126
+	 * @param string $key
127
+	 * @param string $current_route
128
+	 * @return mixed EED_Module | boolean
129
+	 * @throws EE_Error
130
+	 * @throws ReflectionException
131
+	 */
132
+	public function resolve_route($key, $current_route)
133
+	{
134
+		// get module method that route has been mapped to
135
+		$module_method = EE_Config::get_route($current_route, $key);
136
+		// verify result was returned
137
+		if (empty($module_method)) {
138
+			$msg = sprintf(
139
+				__('The requested route %s could not be mapped to any registered modules.', 'event_espresso'),
140
+				$current_route
141
+			);
142
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
143
+			return false;
144
+		}
145
+		// verify that result is an array
146
+		if (! is_array($module_method)) {
147
+			$msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
148
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
149
+			return false;
150
+		}
151
+		// grab module name
152
+		$module_name = $module_method[0];
153
+		// verify that a class method was registered properly
154
+		if (! isset($module_method[1])) {
155
+			$msg = sprintf(
156
+				__('A class method for the %s  route has not been properly registered.', 'event_espresso'),
157
+				$current_route
158
+			);
159
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
160
+			return false;
161
+		}
162
+		// grab method
163
+		$method = $module_method[1];
164
+		// verify that class exists
165
+		if (! class_exists($module_name)) {
166
+			$msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
167
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
168
+			return false;
169
+		}
170
+		// verify that method exists
171
+		if (! method_exists($module_name, $method)) {
172
+			$msg = sprintf(
173
+				__('The class method %s for the %s route is in invalid.', 'event_espresso'),
174
+				$method,
175
+				$current_route
176
+			);
177
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
178
+			return false;
179
+		}
180
+		// instantiate module and call route method
181
+		return $this->_module_router($module_name, $method);
182
+	}
183 183
 
184 184
 
185
-    /**
186
-     * this method instantiates modules and calls the method that was defined when the route was registered
187
-     *
188
-     * @param string $module_name
189
-     * @return EED_Module|object|null
190
-     * @throws ReflectionException
191
-     */
192
-    public static function module_factory($module_name)
193
-    {
194
-        if ($module_name === 'EED_Module') {
195
-            EE_Error::add_error(
196
-                sprintf(
197
-                    __(
198
-                        'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
199
-                        'event_espresso'
200
-                    ),
201
-                    $module_name
202
-                ),
203
-                __FILE__,
204
-                __FUNCTION__,
205
-                __LINE__
206
-            );
207
-            return null;
208
-        }
209
-        // instantiate module class
210
-        $module = new $module_name();
211
-        // ensure that class is actually a module
212
-        if (! $module instanceof EED_Module) {
213
-            EE_Error::add_error(
214
-                sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215
-                __FILE__,
216
-                __FUNCTION__,
217
-                __LINE__
218
-            );
219
-            return null;
220
-        }
221
-        return $module;
222
-    }
185
+	/**
186
+	 * this method instantiates modules and calls the method that was defined when the route was registered
187
+	 *
188
+	 * @param string $module_name
189
+	 * @return EED_Module|object|null
190
+	 * @throws ReflectionException
191
+	 */
192
+	public static function module_factory($module_name)
193
+	{
194
+		if ($module_name === 'EED_Module') {
195
+			EE_Error::add_error(
196
+				sprintf(
197
+					__(
198
+						'EED_Module is an abstract parent class an can not be instantiated. Please provide a proper module name.',
199
+						'event_espresso'
200
+					),
201
+					$module_name
202
+				),
203
+				__FILE__,
204
+				__FUNCTION__,
205
+				__LINE__
206
+			);
207
+			return null;
208
+		}
209
+		// instantiate module class
210
+		$module = new $module_name();
211
+		// ensure that class is actually a module
212
+		if (! $module instanceof EED_Module) {
213
+			EE_Error::add_error(
214
+				sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215
+				__FILE__,
216
+				__FUNCTION__,
217
+				__LINE__
218
+			);
219
+			return null;
220
+		}
221
+		return $module;
222
+	}
223 223
 
224 224
 
225
-    /**
226
-     * this method instantiates modules and calls the method that was defined when the route was registered
227
-     *
228
-     * @param string $module_name
229
-     * @param string $method
230
-     * @return EED_Module|null
231
-     * @throws EE_Error
232
-     * @throws ReflectionException
233
-     */
234
-    private function _module_router($module_name, $method)
235
-    {
236
-        // instantiate module class
237
-        $module = EE_Module_Request_Router::module_factory($module_name);
238
-        if ($module instanceof EED_Module) {
239
-            // and call whatever action the route was for
240
-            try {
241
-                call_user_func(array($module, $method), $this->WP_Query);
242
-            } catch (EE_Error $e) {
243
-                $e->get_error();
244
-                return null;
245
-            }
246
-        }
247
-        return $module;
248
-    }
225
+	/**
226
+	 * this method instantiates modules and calls the method that was defined when the route was registered
227
+	 *
228
+	 * @param string $module_name
229
+	 * @param string $method
230
+	 * @return EED_Module|null
231
+	 * @throws EE_Error
232
+	 * @throws ReflectionException
233
+	 */
234
+	private function _module_router($module_name, $method)
235
+	{
236
+		// instantiate module class
237
+		$module = EE_Module_Request_Router::module_factory($module_name);
238
+		if ($module instanceof EED_Module) {
239
+			// and call whatever action the route was for
240
+			try {
241
+				call_user_func(array($module, $method), $this->WP_Query);
242
+			} catch (EE_Error $e) {
243
+				$e->get_error();
244
+				return null;
245
+			}
246
+		}
247
+		return $module;
248
+	}
249 249
 
250 250
 
251
-    /**
252
-     * @param $current_route
253
-     * @return string
254
-     */
255
-    public function get_forward($current_route)
256
-    {
257
-        return EE_Config::get_forward($current_route);
258
-    }
251
+	/**
252
+	 * @param $current_route
253
+	 * @return string
254
+	 */
255
+	public function get_forward($current_route)
256
+	{
257
+		return EE_Config::get_forward($current_route);
258
+	}
259 259
 
260 260
 
261
-    /**
262
-     * @param $current_route
263
-     * @return string
264
-     */
265
-    public function get_view($current_route)
266
-    {
267
-        return EE_Config::get_view($current_route);
268
-    }
261
+	/**
262
+	 * @param $current_route
263
+	 * @return string
264
+	 */
265
+	public function get_view($current_route)
266
+	{
267
+		return EE_Config::get_view($current_route);
268
+	}
269 269
 }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
         // assume this if first route being called
60 60
         $previous_route = false;
61 61
         // but is it really ???
62
-        if (! empty(self::$_previous_routes)) {
62
+        if ( ! empty(self::$_previous_routes)) {
63 63
             // get last run route
64 64
             $previous_routes = array_values(self::$_previous_routes);
65 65
             $previous_route = array_pop($previous_routes);
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
             $current_route = $this->get_forward($previous_route);
71 71
             try {
72 72
                 // check for recursive forwarding
73
-                if (isset(self::$_previous_routes[ $current_route ])) {
73
+                if (isset(self::$_previous_routes[$current_route])) {
74 74
                     throw new EE_Error(
75 75
                         sprintf(
76 76
                             __(
@@ -143,38 +143,38 @@  discard block
 block discarded – undo
143 143
             return false;
144 144
         }
145 145
         // verify that result is an array
146
-        if (! is_array($module_method)) {
146
+        if ( ! is_array($module_method)) {
147 147
             $msg = sprintf(__('The %s  route has not been properly registered.', 'event_espresso'), $current_route);
148
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
148
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
149 149
             return false;
150 150
         }
151 151
         // grab module name
152 152
         $module_name = $module_method[0];
153 153
         // verify that a class method was registered properly
154
-        if (! isset($module_method[1])) {
154
+        if ( ! isset($module_method[1])) {
155 155
             $msg = sprintf(
156 156
                 __('A class method for the %s  route has not been properly registered.', 'event_espresso'),
157 157
                 $current_route
158 158
             );
159
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
159
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
160 160
             return false;
161 161
         }
162 162
         // grab method
163 163
         $method = $module_method[1];
164 164
         // verify that class exists
165
-        if (! class_exists($module_name)) {
165
+        if ( ! class_exists($module_name)) {
166 166
             $msg = sprintf(__('The requested %s class could not be found.', 'event_espresso'), $module_name);
167 167
             EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
168 168
             return false;
169 169
         }
170 170
         // verify that method exists
171
-        if (! method_exists($module_name, $method)) {
171
+        if ( ! method_exists($module_name, $method)) {
172 172
             $msg = sprintf(
173 173
                 __('The class method %s for the %s route is in invalid.', 'event_espresso'),
174 174
                 $method,
175 175
                 $current_route
176 176
             );
177
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
177
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
178 178
             return false;
179 179
         }
180 180
         // instantiate module and call route method
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
         // instantiate module class
210 210
         $module = new $module_name();
211 211
         // ensure that class is actually a module
212
-        if (! $module instanceof EED_Module) {
212
+        if ( ! $module instanceof EED_Module) {
213 213
             EE_Error::add_error(
214 214
                 sprintf(__('The requested %s module is not of the class EED_Module.', 'event_espresso'), $module_name),
215 215
                 __FILE__,
Please login to merge, or discard this patch.
core/interfaces/EEI_Request_Decorator.interface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -9,24 +9,24 @@
 block discarded – undo
9 9
 interface EEI_Request_Decorator
10 10
 {
11 11
 
12
-    /**
13
-     * converts a Request to a Response
14
-     * can perform their logic either before or after the core application has run like so:
15
-     *    public function handle_request( EE_Request $request, EE_Response $response ) {
16
-     *        $this->request = $request;
17
-     *        $this->response = $response;
18
-     *      // logic performed BEFORE core app has run
19
-     *      $this->process_request_stack( $this->request, $this->response );
20
-     *      // logic performed AFTER core app has run
21
-     *      return $response;
22
-     *    }
23
-     *
24
-     * @deprecated 4.9.53
25
-     * @param    EE_Request $request
26
-     * @param    EE_Response   $response
27
-     * @return    EE_Response
28
-     */
29
-    public function handle_request(EE_Request $request, EE_Response $response);
12
+	/**
13
+	 * converts a Request to a Response
14
+	 * can perform their logic either before or after the core application has run like so:
15
+	 *    public function handle_request( EE_Request $request, EE_Response $response ) {
16
+	 *        $this->request = $request;
17
+	 *        $this->response = $response;
18
+	 *      // logic performed BEFORE core app has run
19
+	 *      $this->process_request_stack( $this->request, $this->response );
20
+	 *      // logic performed AFTER core app has run
21
+	 *      return $response;
22
+	 *    }
23
+	 *
24
+	 * @deprecated 4.9.53
25
+	 * @param    EE_Request $request
26
+	 * @param    EE_Response   $response
27
+	 * @return    EE_Response
28
+	 */
29
+	public function handle_request(EE_Request $request, EE_Response $response);
30 30
 
31 31
 
32 32
 }
Please login to merge, or discard this patch.
core/services/request/LegacyRequestInterface.php 1 patch
Indentation   +87 added lines, -87 removed lines patch added patch discarded remove patch
@@ -15,125 +15,125 @@
 block discarded – undo
15 15
 interface LegacyRequestInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @return array
20
-     */
21
-    public function get_params();
18
+	/**
19
+	 * @return array
20
+	 */
21
+	public function get_params();
22 22
 
23 23
 
24
-    /**
25
-     * @return array
26
-     */
27
-    public function post_params();
24
+	/**
25
+	 * @return array
26
+	 */
27
+	public function post_params();
28 28
 
29 29
 
30
-    /**
31
-     * @return array
32
-     */
33
-    public function cookie_params();
30
+	/**
31
+	 * @return array
32
+	 */
33
+	public function cookie_params();
34 34
 
35 35
 
36
-    /**
37
-     * @return array
38
-     */
39
-    public function server_params();
36
+	/**
37
+	 * @return array
38
+	 */
39
+	public function server_params();
40 40
 
41 41
 
42
-    /**
43
-     * returns contents of $_REQUEST
44
-     *
45
-     * @return array
46
-     */
47
-    public function params();
42
+	/**
43
+	 * returns contents of $_REQUEST
44
+	 *
45
+	 * @return array
46
+	 */
47
+	public function params();
48 48
 
49 49
 
50
-    /**
51
-     * @param      $key
52
-     * @param      $value
53
-     * @param bool $override_ee
54
-     * @return    void
55
-     */
56
-    public function set($key, $value, $override_ee = false);
50
+	/**
51
+	 * @param      $key
52
+	 * @param      $value
53
+	 * @param bool $override_ee
54
+	 * @return    void
55
+	 */
56
+	public function set($key, $value, $override_ee = false);
57 57
 
58 58
 
59
-    /**
60
-     * returns   the value for a request param if the given key exists
61
-     *
62
-     * @param       $key
63
-     * @param null  $default
64
-     * @return mixed
65
-     */
66
-    public function get($key, $default = null);
59
+	/**
60
+	 * returns   the value for a request param if the given key exists
61
+	 *
62
+	 * @param       $key
63
+	 * @param null  $default
64
+	 * @return mixed
65
+	 */
66
+	public function get($key, $default = null);
67 67
 
68 68
 
69
-    /**
70
-     * check if param exists
71
-     *
72
-     * @param       $key
73
-     * @return bool
74
-     */
75
-    public function is_set($key);
69
+	/**
70
+	 * check if param exists
71
+	 *
72
+	 * @param       $key
73
+	 * @return bool
74
+	 */
75
+	public function is_set($key);
76 76
 
77 77
 
78
-    /**
79
-     * remove param
80
-     *
81
-     * @param      $key
82
-     * @param bool $unset_from_global_too
83
-     */
84
-    public function un_set($key, $unset_from_global_too = false);
78
+	/**
79
+	 * remove param
80
+	 *
81
+	 * @param      $key
82
+	 * @param bool $unset_from_global_too
83
+	 */
84
+	public function un_set($key, $unset_from_global_too = false);
85 85
 
86 86
 
87
-    /**
88
-     * @return string
89
-     */
90
-    public function ip_address();
87
+	/**
88
+	 * @return string
89
+	 */
90
+	public function ip_address();
91 91
 
92 92
 
93
-    /**
94
-     * @return bool
95
-     */
96
-    public function isAdmin();
93
+	/**
94
+	 * @return bool
95
+	 */
96
+	public function isAdmin();
97 97
 
98 98
 
99
-    /**
100
-     * @return mixed
101
-     */
102
-    public function isAjax();
99
+	/**
100
+	 * @return mixed
101
+	 */
102
+	public function isAjax();
103 103
 
104 104
 
105
-    /**
106
-     * @return mixed
107
-     */
108
-    public function isFrontAjax();
105
+	/**
106
+	 * @return mixed
107
+	 */
108
+	public function isFrontAjax();
109 109
 
110 110
 
111
-    /**
112
-     * @return mixed|string
113
-     */
114
-    public function requestUri();
111
+	/**
112
+	 * @return mixed|string
113
+	 */
114
+	public function requestUri();
115 115
 
116 116
 
117
-    /**
118
-     * @return string
119
-     */
120
-    public function userAgent();
117
+	/**
118
+	 * @return string
119
+	 */
120
+	public function userAgent();
121 121
 
122 122
 
123
-    /**
124
-     * @param string $user_agent
125
-     */
126
-    public function setUserAgent($user_agent = '');
123
+	/**
124
+	 * @param string $user_agent
125
+	 */
126
+	public function setUserAgent($user_agent = '');
127 127
 
128 128
 
129
-    /**
130
-     * @return bool
131
-     */
132
-    public function isBot();
129
+	/**
130
+	 * @return bool
131
+	 */
132
+	public function isBot();
133 133
 
134 134
 
135
-    /**
136
-     * @param bool $is_bot
137
-     */
138
-    public function setIsBot($is_bot);
135
+	/**
136
+	 * @param bool $is_bot
137
+	 */
138
+	public function setIsBot($is_bot);
139 139
 }
Please login to merge, or discard this patch.