Completed
Branch BUG-10873-omise-gateway (b1c82f)
by
unknown
64:25 queued 53:44
created
message_type/newsletter/EE_Messages_Email_Newsletter_Validator.class.php 2 patches
Indentation   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@
 block discarded – undo
18 18
  * @author          Darren Ethier
19 19
  */
20 20
 class EE_Messages_Email_Newsletter_Validator extends EE_Messages_Validator {
21
-    public function __construct( $fields, $context ) {
22
-        $this->_m_name = 'email';
23
-        $this->_mt_name = 'newsletter';
21
+	public function __construct( $fields, $context ) {
22
+		$this->_m_name = 'email';
23
+		$this->_mt_name = 'newsletter';
24 24
 
25
-        parent::__construct( $fields, $context );
26
-    }
25
+		parent::__construct( $fields, $context );
26
+	}
27 27
 
28
-    /**
29
-     * custom validator (restricting what was originally set by the messenger)
30
-     */
31
-    protected function _modify_validator() {
32
-        if ( $this->_context == 'attendee' )
33
-            $this->_valid_shortcodes_modifier[$this->_context]['from'] = array('recipient_details', 'email', 'organization');
28
+	/**
29
+	 * custom validator (restricting what was originally set by the messenger)
30
+	 */
31
+	protected function _modify_validator() {
32
+		if ( $this->_context == 'attendee' )
33
+			$this->_valid_shortcodes_modifier[$this->_context]['from'] = array('recipient_details', 'email', 'organization');
34 34
 
35
-        //excluded shortcodes
36
-        $fields = array('to','from','subject','content','newsletter_content');
37
-        foreach ( $fields as $field ) {
38
-            $this->_specific_shortcode_excludes[$field] = array('[RECIPIENT_REGISTRATION_CODE]', '[EVENT_AUTHOR_FORMATTED_EMAIL]', '[EVENT_AUTHOR_EMAIL]');
39
-        }
40
-        $add_excludes = array( '[RECIPIENT_FNAME]', '[RECIPIENT_LNAME]', '[RECIPIENT_EMAIL]', '[COMPANY]', '[CO_ADD1]','[CO_ADD2]', '[CO_CITY]', '[CO_STATE]','[CO_ZIP]','[CO_LOGO]','[CO_PHONE]','[CO_LOGO_URL]','[CO_FACEBOOK_URL]','[CO_TWITTER_URL]','[CO_PINTEREST_URL]','[CO_GOOGLE_URL]','[CO_LINKEDIN_URL]','[CO_INSTAGRAM_URL]');
41
-        $this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'], $add_excludes);
42
-        $this->_specific_shortcode_excludes['content'] = array_merge( $this->_specific_shortcode_excludes['content'], array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]') );
43
-    }
35
+		//excluded shortcodes
36
+		$fields = array('to','from','subject','content','newsletter_content');
37
+		foreach ( $fields as $field ) {
38
+			$this->_specific_shortcode_excludes[$field] = array('[RECIPIENT_REGISTRATION_CODE]', '[EVENT_AUTHOR_FORMATTED_EMAIL]', '[EVENT_AUTHOR_EMAIL]');
39
+		}
40
+		$add_excludes = array( '[RECIPIENT_FNAME]', '[RECIPIENT_LNAME]', '[RECIPIENT_EMAIL]', '[COMPANY]', '[CO_ADD1]','[CO_ADD2]', '[CO_CITY]', '[CO_STATE]','[CO_ZIP]','[CO_LOGO]','[CO_PHONE]','[CO_LOGO_URL]','[CO_FACEBOOK_URL]','[CO_TWITTER_URL]','[CO_PINTEREST_URL]','[CO_GOOGLE_URL]','[CO_LINKEDIN_URL]','[CO_INSTAGRAM_URL]');
41
+		$this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'], $add_excludes);
42
+		$this->_specific_shortcode_excludes['content'] = array_merge( $this->_specific_shortcode_excludes['content'], array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]') );
43
+	}
44 44
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,27 +18,27 @@
 block discarded – undo
18 18
  * @author          Darren Ethier
19 19
  */
20 20
 class EE_Messages_Email_Newsletter_Validator extends EE_Messages_Validator {
21
-    public function __construct( $fields, $context ) {
21
+    public function __construct($fields, $context) {
22 22
         $this->_m_name = 'email';
23 23
         $this->_mt_name = 'newsletter';
24 24
 
25
-        parent::__construct( $fields, $context );
25
+        parent::__construct($fields, $context);
26 26
     }
27 27
 
28 28
     /**
29 29
      * custom validator (restricting what was originally set by the messenger)
30 30
      */
31 31
     protected function _modify_validator() {
32
-        if ( $this->_context == 'attendee' )
32
+        if ($this->_context == 'attendee')
33 33
             $this->_valid_shortcodes_modifier[$this->_context]['from'] = array('recipient_details', 'email', 'organization');
34 34
 
35 35
         //excluded shortcodes
36
-        $fields = array('to','from','subject','content','newsletter_content');
37
-        foreach ( $fields as $field ) {
36
+        $fields = array('to', 'from', 'subject', 'content', 'newsletter_content');
37
+        foreach ($fields as $field) {
38 38
             $this->_specific_shortcode_excludes[$field] = array('[RECIPIENT_REGISTRATION_CODE]', '[EVENT_AUTHOR_FORMATTED_EMAIL]', '[EVENT_AUTHOR_EMAIL]');
39 39
         }
40
-        $add_excludes = array( '[RECIPIENT_FNAME]', '[RECIPIENT_LNAME]', '[RECIPIENT_EMAIL]', '[COMPANY]', '[CO_ADD1]','[CO_ADD2]', '[CO_CITY]', '[CO_STATE]','[CO_ZIP]','[CO_LOGO]','[CO_PHONE]','[CO_LOGO_URL]','[CO_FACEBOOK_URL]','[CO_TWITTER_URL]','[CO_PINTEREST_URL]','[CO_GOOGLE_URL]','[CO_LINKEDIN_URL]','[CO_INSTAGRAM_URL]');
40
+        $add_excludes = array('[RECIPIENT_FNAME]', '[RECIPIENT_LNAME]', '[RECIPIENT_EMAIL]', '[COMPANY]', '[CO_ADD1]', '[CO_ADD2]', '[CO_CITY]', '[CO_STATE]', '[CO_ZIP]', '[CO_LOGO]', '[CO_PHONE]', '[CO_LOGO_URL]', '[CO_FACEBOOK_URL]', '[CO_TWITTER_URL]', '[CO_PINTEREST_URL]', '[CO_GOOGLE_URL]', '[CO_LINKEDIN_URL]', '[CO_INSTAGRAM_URL]');
41 41
         $this->_specific_shortcode_excludes['from'] = array_merge($this->_specific_shortcode_excludes['from'], $add_excludes);
42
-        $this->_specific_shortcode_excludes['content'] = array_merge( $this->_specific_shortcode_excludes['content'], array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]') );
42
+        $this->_specific_shortcode_excludes['content'] = array_merge($this->_specific_shortcode_excludes['content'], array('[DISPLAY_PDF_URL]', '[DISPLAY_PDF_BUTTON]'));
43 43
     }
44 44
 }
Please login to merge, or discard this patch.
core/request_stack/EE_Request.core.php 2 patches
Indentation   +322 added lines, -322 removed lines patch added patch discarded remove patch
@@ -16,328 +16,328 @@
 block discarded – undo
16 16
 class EE_Request implements InterminableInterface
17 17
 {
18 18
 
19
-    /**
20
-     * $_GET parameters
21
-     *
22
-     * @var array $_get
23
-     */
24
-    private $_get;
25
-
26
-    /**
27
-     * $_POST parameters
28
-     *
29
-     * @var    array $_post
30
-     */
31
-    private $_post;
32
-
33
-    /**
34
-     * $_COOKIE parameters
35
-     *
36
-     * @var array $_cookie
37
-     */
38
-    private $_cookie;
39
-
40
-    /**
41
-     * $_REQUEST parameters
42
-     *
43
-     * @var array $_params
44
-     */
45
-    private $_params;
46
-
47
-    /**
48
-     * whether current request is for the admin but NOT via AJAX
49
-     *
50
-     * @var boolean $admin
51
-     */
52
-    public $admin = false;
53
-
54
-    /**
55
-     * whether current request is via AJAX
56
-     *
57
-     * @var boolean $ajax
58
-     */
59
-    public $ajax = false;
60
-
61
-    /**
62
-     * whether current request is via AJAX from the frontend of the site
63
-     *
64
-     * @var boolean $front_ajax
65
-     */
66
-    public $front_ajax = false;
67
-
68
-    /**
69
-     * IP address for request
70
-     *
71
-     * @var string $_ip_address
72
-     */
73
-    private $_ip_address;
74
-
75
-
76
-
77
-    /**
78
-     * class constructor
79
-     *
80
-     * @access    public
81
-     * @param array $get
82
-     * @param array $post
83
-     * @param array $cookie
84
-     */
85
-    public function __construct(array $get, array $post, array $cookie)
86
-    {
87
-        // grab request vars
88
-        $this->_get    = $get;
89
-        $this->_post   = $post;
90
-        $this->_cookie = $cookie;
91
-        $this->_params = array_merge($this->_get, $this->_post);
92
-        // AJAX ???
93
-        $this->ajax       = defined('DOING_AJAX') && DOING_AJAX;
94
-        $this->front_ajax = $this->ajax
95
-                            && $this->is_set('ee_front_ajax')
96
-                            && filter_var($this->get('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN);
97
-        $this->admin      = is_admin() && ! $this->ajax;
98
-        // grab user IP
99
-        $this->_ip_address = $this->_visitor_ip();
100
-    }
101
-
102
-
103
-
104
-    /**
105
-     * @return array
106
-     */
107
-    public function get_params()
108
-    {
109
-        return $this->_get;
110
-    }
111
-
112
-
113
-
114
-    /**
115
-     * @return array
116
-     */
117
-    public function post_params()
118
-    {
119
-        return $this->_post;
120
-    }
121
-
122
-
123
-
124
-    /**
125
-     * @return array
126
-     */
127
-    public function cookie_params()
128
-    {
129
-        return $this->_cookie;
130
-    }
131
-
132
-
133
-
134
-    /**
135
-     * returns contents of $_REQUEST
136
-     *
137
-     * @return array
138
-     */
139
-    public function params()
140
-    {
141
-        return $this->_params;
142
-    }
143
-
144
-
145
-
146
-    /**
147
-     * @param      $key
148
-     * @param      $value
149
-     * @param bool $override_ee
150
-     * @return    void
151
-     */
152
-    public function set($key, $value, $override_ee = false)
153
-    {
154
-        // don't allow "ee" to be overwritten unless explicitly instructed to do so
155
-        if (
156
-            $key !== 'ee'
157
-            || ($key === 'ee' && empty($this->_params['ee']))
158
-            || ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
159
-        ) {
160
-            $this->_params[$key] = $value;
161
-        }
162
-    }
163
-
164
-
165
-
166
-    /**
167
-     * returns   the value for a request param if the given key exists
168
-     *
169
-     * @param       $key
170
-     * @param null  $default
171
-     * @return mixed
172
-     */
173
-    public function get($key, $default = null)
174
-    {
175
-        return $this->request_parameter_drill_down($key, $default, 'get');
176
-    }
177
-
178
-
179
-
180
-    /**
181
-     * check if param exists
182
-     *
183
-     * @param       $key
184
-     * @return bool
185
-     */
186
-    public function is_set($key)
187
-    {
188
-        return $this->request_parameter_drill_down($key);
189
-    }
190
-
191
-
192
-
193
-    /**
194
-     * the supplied key can be a simple string to represent a "top-level" request parameter
195
-     * or represent a key for a request parameter that is nested deeper within the request parameter array,
196
-     * by using square brackets to surround keys for deeper array elements.
197
-     * For example :
198
-     * if the supplied $key was: "first[second][third]"
199
-     * then this will attempt to drill down into the request parameter array to find a value.
200
-     * Given the following request parameters:
201
-     *  array(
202
-     *      'first' => array(
203
-     *          'second' => array(
204
-     *              'third' => 'has a value'
205
-     *          )
206
-     *      )
207
-     *  )
208
-     * would return true
209
-     *
210
-     * @param string $is_set_or_get
211
-     * @param        $key
212
-     * @param null   $default
213
-     * @param array  $request_params
214
-     * @return bool|mixed|null
215
-     */
216
-    private function request_parameter_drill_down(
217
-        $key,
218
-        $default = null,
219
-        $is_set_or_get = 'is_set',
220
-        array $request_params = array()
221
-    ) {
222
-        $request_params = ! empty($request_params)
223
-            ? $request_params
224
-            : $this->_params;
225
-        // does incoming key represent an array like 'first[second][third]'  ?
226
-        if (strpos($key, '[') !== false) {
227
-            // turn it into an actual array
228
-            $key  = str_replace(']', '', $key);
229
-            $keys = explode('[', $key);
230
-            $key  = array_shift($keys);
231
-            // check if top level key exists
232
-            if (isset($request_params[$key])) {
233
-                // build a new key to pass along like: 'second[third]'
234
-                // or just 'second' depending on depth of keys
235
-                $key_string = array_shift($keys);
236
-                if (! empty($keys)) {
237
-                    $key_string .= '[' . implode('][', $keys) . ']';
238
-                }
239
-                return $this->request_parameter_drill_down(
240
-                    $key_string,
241
-                    $default,
242
-                    $is_set_or_get,
243
-                    $request_params[$key]
244
-                );
245
-            }
246
-        }
247
-        if ($is_set_or_get === 'is_set') {
248
-            return isset($request_params[$key]);
249
-        }
250
-        return isset($request_params[$key])
251
-            ? $request_params[$key]
252
-            : $default;
253
-    }
254
-
255
-
256
-
257
-    /**
258
-     * remove param
259
-     *
260
-     * @param      $key
261
-     * @param bool $unset_from_global_too
262
-     */
263
-    public function un_set($key, $unset_from_global_too = false)
264
-    {
265
-        unset($this->_params[$key]);
266
-        if ($unset_from_global_too) {
267
-            unset($_REQUEST[$key]);
268
-        }
269
-    }
270
-
271
-
272
-
273
-    /**
274
-     * @return string
275
-     */
276
-    public function ip_address()
277
-    {
278
-        return $this->_ip_address;
279
-    }
280
-
281
-
282
-    /**
283
-     * @return bool
284
-     */
285
-    public function isAdmin()
286
-    {
287
-        return $this->admin;
288
-    }
289
-
290
-
291
-    /**
292
-     * @return mixed
293
-     */
294
-    public function isAjax()
295
-    {
296
-        return $this->ajax;
297
-    }
298
-
299
-
300
-    /**
301
-     * @return mixed
302
-     */
303
-    public function isFrontAjax()
304
-    {
305
-        return $this->front_ajax;
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * _visitor_ip
312
-     *    attempt to get IP address of current visitor from server
313
-     * plz see: http://stackoverflow.com/a/2031935/1475279
314
-     *
315
-     * @access public
316
-     * @return string
317
-     */
318
-    private function _visitor_ip()
319
-    {
320
-        $visitor_ip  = '0.0.0.0';
321
-        $server_keys = array(
322
-            'HTTP_CLIENT_IP',
323
-            'HTTP_X_FORWARDED_FOR',
324
-            'HTTP_X_FORWARDED',
325
-            'HTTP_X_CLUSTER_CLIENT_IP',
326
-            'HTTP_FORWARDED_FOR',
327
-            'HTTP_FORWARDED',
328
-            'REMOTE_ADDR',
329
-        );
330
-        foreach ($server_keys as $key) {
331
-            if (isset($_SERVER[$key])) {
332
-                foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
333
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
334
-                        $visitor_ip = $ip;
335
-                    }
336
-                }
337
-            }
338
-        }
339
-        return $visitor_ip;
340
-    }
19
+	/**
20
+	 * $_GET parameters
21
+	 *
22
+	 * @var array $_get
23
+	 */
24
+	private $_get;
25
+
26
+	/**
27
+	 * $_POST parameters
28
+	 *
29
+	 * @var    array $_post
30
+	 */
31
+	private $_post;
32
+
33
+	/**
34
+	 * $_COOKIE parameters
35
+	 *
36
+	 * @var array $_cookie
37
+	 */
38
+	private $_cookie;
39
+
40
+	/**
41
+	 * $_REQUEST parameters
42
+	 *
43
+	 * @var array $_params
44
+	 */
45
+	private $_params;
46
+
47
+	/**
48
+	 * whether current request is for the admin but NOT via AJAX
49
+	 *
50
+	 * @var boolean $admin
51
+	 */
52
+	public $admin = false;
53
+
54
+	/**
55
+	 * whether current request is via AJAX
56
+	 *
57
+	 * @var boolean $ajax
58
+	 */
59
+	public $ajax = false;
60
+
61
+	/**
62
+	 * whether current request is via AJAX from the frontend of the site
63
+	 *
64
+	 * @var boolean $front_ajax
65
+	 */
66
+	public $front_ajax = false;
67
+
68
+	/**
69
+	 * IP address for request
70
+	 *
71
+	 * @var string $_ip_address
72
+	 */
73
+	private $_ip_address;
74
+
75
+
76
+
77
+	/**
78
+	 * class constructor
79
+	 *
80
+	 * @access    public
81
+	 * @param array $get
82
+	 * @param array $post
83
+	 * @param array $cookie
84
+	 */
85
+	public function __construct(array $get, array $post, array $cookie)
86
+	{
87
+		// grab request vars
88
+		$this->_get    = $get;
89
+		$this->_post   = $post;
90
+		$this->_cookie = $cookie;
91
+		$this->_params = array_merge($this->_get, $this->_post);
92
+		// AJAX ???
93
+		$this->ajax       = defined('DOING_AJAX') && DOING_AJAX;
94
+		$this->front_ajax = $this->ajax
95
+							&& $this->is_set('ee_front_ajax')
96
+							&& filter_var($this->get('ee_front_ajax'), FILTER_VALIDATE_BOOLEAN);
97
+		$this->admin      = is_admin() && ! $this->ajax;
98
+		// grab user IP
99
+		$this->_ip_address = $this->_visitor_ip();
100
+	}
101
+
102
+
103
+
104
+	/**
105
+	 * @return array
106
+	 */
107
+	public function get_params()
108
+	{
109
+		return $this->_get;
110
+	}
111
+
112
+
113
+
114
+	/**
115
+	 * @return array
116
+	 */
117
+	public function post_params()
118
+	{
119
+		return $this->_post;
120
+	}
121
+
122
+
123
+
124
+	/**
125
+	 * @return array
126
+	 */
127
+	public function cookie_params()
128
+	{
129
+		return $this->_cookie;
130
+	}
131
+
132
+
133
+
134
+	/**
135
+	 * returns contents of $_REQUEST
136
+	 *
137
+	 * @return array
138
+	 */
139
+	public function params()
140
+	{
141
+		return $this->_params;
142
+	}
143
+
144
+
145
+
146
+	/**
147
+	 * @param      $key
148
+	 * @param      $value
149
+	 * @param bool $override_ee
150
+	 * @return    void
151
+	 */
152
+	public function set($key, $value, $override_ee = false)
153
+	{
154
+		// don't allow "ee" to be overwritten unless explicitly instructed to do so
155
+		if (
156
+			$key !== 'ee'
157
+			|| ($key === 'ee' && empty($this->_params['ee']))
158
+			|| ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
159
+		) {
160
+			$this->_params[$key] = $value;
161
+		}
162
+	}
163
+
164
+
165
+
166
+	/**
167
+	 * returns   the value for a request param if the given key exists
168
+	 *
169
+	 * @param       $key
170
+	 * @param null  $default
171
+	 * @return mixed
172
+	 */
173
+	public function get($key, $default = null)
174
+	{
175
+		return $this->request_parameter_drill_down($key, $default, 'get');
176
+	}
177
+
178
+
179
+
180
+	/**
181
+	 * check if param exists
182
+	 *
183
+	 * @param       $key
184
+	 * @return bool
185
+	 */
186
+	public function is_set($key)
187
+	{
188
+		return $this->request_parameter_drill_down($key);
189
+	}
190
+
191
+
192
+
193
+	/**
194
+	 * the supplied key can be a simple string to represent a "top-level" request parameter
195
+	 * or represent a key for a request parameter that is nested deeper within the request parameter array,
196
+	 * by using square brackets to surround keys for deeper array elements.
197
+	 * For example :
198
+	 * if the supplied $key was: "first[second][third]"
199
+	 * then this will attempt to drill down into the request parameter array to find a value.
200
+	 * Given the following request parameters:
201
+	 *  array(
202
+	 *      'first' => array(
203
+	 *          'second' => array(
204
+	 *              'third' => 'has a value'
205
+	 *          )
206
+	 *      )
207
+	 *  )
208
+	 * would return true
209
+	 *
210
+	 * @param string $is_set_or_get
211
+	 * @param        $key
212
+	 * @param null   $default
213
+	 * @param array  $request_params
214
+	 * @return bool|mixed|null
215
+	 */
216
+	private function request_parameter_drill_down(
217
+		$key,
218
+		$default = null,
219
+		$is_set_or_get = 'is_set',
220
+		array $request_params = array()
221
+	) {
222
+		$request_params = ! empty($request_params)
223
+			? $request_params
224
+			: $this->_params;
225
+		// does incoming key represent an array like 'first[second][third]'  ?
226
+		if (strpos($key, '[') !== false) {
227
+			// turn it into an actual array
228
+			$key  = str_replace(']', '', $key);
229
+			$keys = explode('[', $key);
230
+			$key  = array_shift($keys);
231
+			// check if top level key exists
232
+			if (isset($request_params[$key])) {
233
+				// build a new key to pass along like: 'second[third]'
234
+				// or just 'second' depending on depth of keys
235
+				$key_string = array_shift($keys);
236
+				if (! empty($keys)) {
237
+					$key_string .= '[' . implode('][', $keys) . ']';
238
+				}
239
+				return $this->request_parameter_drill_down(
240
+					$key_string,
241
+					$default,
242
+					$is_set_or_get,
243
+					$request_params[$key]
244
+				);
245
+			}
246
+		}
247
+		if ($is_set_or_get === 'is_set') {
248
+			return isset($request_params[$key]);
249
+		}
250
+		return isset($request_params[$key])
251
+			? $request_params[$key]
252
+			: $default;
253
+	}
254
+
255
+
256
+
257
+	/**
258
+	 * remove param
259
+	 *
260
+	 * @param      $key
261
+	 * @param bool $unset_from_global_too
262
+	 */
263
+	public function un_set($key, $unset_from_global_too = false)
264
+	{
265
+		unset($this->_params[$key]);
266
+		if ($unset_from_global_too) {
267
+			unset($_REQUEST[$key]);
268
+		}
269
+	}
270
+
271
+
272
+
273
+	/**
274
+	 * @return string
275
+	 */
276
+	public function ip_address()
277
+	{
278
+		return $this->_ip_address;
279
+	}
280
+
281
+
282
+	/**
283
+	 * @return bool
284
+	 */
285
+	public function isAdmin()
286
+	{
287
+		return $this->admin;
288
+	}
289
+
290
+
291
+	/**
292
+	 * @return mixed
293
+	 */
294
+	public function isAjax()
295
+	{
296
+		return $this->ajax;
297
+	}
298
+
299
+
300
+	/**
301
+	 * @return mixed
302
+	 */
303
+	public function isFrontAjax()
304
+	{
305
+		return $this->front_ajax;
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * _visitor_ip
312
+	 *    attempt to get IP address of current visitor from server
313
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
314
+	 *
315
+	 * @access public
316
+	 * @return string
317
+	 */
318
+	private function _visitor_ip()
319
+	{
320
+		$visitor_ip  = '0.0.0.0';
321
+		$server_keys = array(
322
+			'HTTP_CLIENT_IP',
323
+			'HTTP_X_FORWARDED_FOR',
324
+			'HTTP_X_FORWARDED',
325
+			'HTTP_X_CLUSTER_CLIENT_IP',
326
+			'HTTP_FORWARDED_FOR',
327
+			'HTTP_FORWARDED',
328
+			'REMOTE_ADDR',
329
+		);
330
+		foreach ($server_keys as $key) {
331
+			if (isset($_SERVER[$key])) {
332
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
333
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
334
+						$visitor_ip = $ip;
335
+					}
336
+				}
337
+			}
338
+		}
339
+		return $visitor_ip;
340
+	}
341 341
 
342 342
 
343 343
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -233,8 +233,8 @@
 block discarded – undo
233 233
                 // build a new key to pass along like: 'second[third]'
234 234
                 // or just 'second' depending on depth of keys
235 235
                 $key_string = array_shift($keys);
236
-                if (! empty($keys)) {
237
-                    $key_string .= '[' . implode('][', $keys) . ']';
236
+                if ( ! empty($keys)) {
237
+                    $key_string .= '['.implode('][', $keys).']';
238 238
                 }
239 239
                 return $this->request_parameter_drill_down(
240 240
                     $key_string,
Please login to merge, or discard this patch.
core/EE_Dependency_Map.core.php 1 patch
Indentation   +795 added lines, -795 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\services\loaders\LoaderInterface;
6 6
 
7 7
 if (! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('No direct script access allowed');
8
+	exit('No direct script access allowed');
9 9
 }
10 10
 
11 11
 
@@ -22,800 +22,800 @@  discard block
 block discarded – undo
22 22
 class EE_Dependency_Map
23 23
 {
24 24
 
25
-    /**
26
-     * This means that the requested class dependency is not present in the dependency map
27
-     */
28
-    const not_registered = 0;
29
-
30
-    /**
31
-     * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
32
-     */
33
-    const load_new_object = 1;
34
-
35
-    /**
36
-     * This instructs class loaders to return a previously instantiated and cached object for the requested class.
37
-     * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
38
-     */
39
-    const load_from_cache = 2;
40
-
41
-    /**
42
-     * When registering a dependency,
43
-     * this indicates to keep any existing dependencies that already exist,
44
-     * and simply discard any new dependencies declared in the incoming data
45
-     */
46
-    const KEEP_EXISTING_DEPENDENCIES = 0;
47
-
48
-    /**
49
-     * When registering a dependency,
50
-     * this indicates to overwrite any existing dependencies that already exist using the incoming data
51
-     */
52
-    const OVERWRITE_DEPENDENCIES = 1;
53
-
54
-
55
-
56
-    /**
57
-     * @type EE_Dependency_Map $_instance
58
-     */
59
-    protected static $_instance;
60
-
61
-    /**
62
-     * @type EE_Request $request
63
-     */
64
-    protected $_request;
65
-
66
-    /**
67
-     * @type EE_Response $response
68
-     */
69
-    protected $_response;
70
-
71
-    /**
72
-     * @type LoaderInterface $loader
73
-     */
74
-    protected $loader;
75
-
76
-    /**
77
-     * @type array $_dependency_map
78
-     */
79
-    protected $_dependency_map = array();
80
-
81
-    /**
82
-     * @type array $_class_loaders
83
-     */
84
-    protected $_class_loaders = array();
85
-
86
-    /**
87
-     * @type array $_aliases
88
-     */
89
-    protected $_aliases = array();
90
-
91
-
92
-
93
-    /**
94
-     * EE_Dependency_Map constructor.
95
-     *
96
-     * @param EE_Request  $request
97
-     * @param EE_Response $response
98
-     */
99
-    protected function __construct(EE_Request $request, EE_Response $response)
100
-    {
101
-        $this->_request = $request;
102
-        $this->_response = $response;
103
-        add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
104
-        do_action('EE_Dependency_Map____construct');
105
-    }
106
-
107
-
108
-
109
-    /**
110
-     * @throws InvalidDataTypeException
111
-     * @throws InvalidInterfaceException
112
-     * @throws InvalidArgumentException
113
-     */
114
-    public function initialize()
115
-    {
116
-        $this->_register_core_dependencies();
117
-        $this->_register_core_class_loaders();
118
-        $this->_register_core_aliases();
119
-    }
120
-
121
-
122
-
123
-    /**
124
-     * @singleton method used to instantiate class object
125
-     * @access    public
126
-     * @param EE_Request  $request
127
-     * @param EE_Response $response
128
-     * @return EE_Dependency_Map
129
-     */
130
-    public static function instance(EE_Request $request = null, EE_Response $response = null)
131
-    {
132
-        // check if class object is instantiated, and instantiated properly
133
-        if (! self::$_instance instanceof EE_Dependency_Map) {
134
-            self::$_instance = new EE_Dependency_Map($request, $response);
135
-        }
136
-        return self::$_instance;
137
-    }
138
-
139
-
140
-
141
-    /**
142
-     * @param LoaderInterface $loader
143
-     */
144
-    public function setLoader(LoaderInterface $loader)
145
-    {
146
-        $this->loader = $loader;
147
-    }
148
-
149
-
150
-
151
-    /**
152
-     * @param string $class
153
-     * @param array  $dependencies
154
-     * @param int    $overwrite
155
-     * @return bool
156
-     */
157
-    public static function register_dependencies(
158
-        $class,
159
-        array $dependencies,
160
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
161
-    ) {
162
-        return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
163
-    }
164
-
165
-
166
-
167
-    /**
168
-     * Assigns an array of class names and corresponding load sources (new or cached)
169
-     * to the class specified by the first parameter.
170
-     * IMPORTANT !!!
171
-     * The order of elements in the incoming $dependencies array MUST match
172
-     * the order of the constructor parameters for the class in question.
173
-     * This is especially important when overriding any existing dependencies that are registered.
174
-     * the third parameter controls whether any duplicate dependencies are overwritten or not.
175
-     *
176
-     * @param string $class
177
-     * @param array  $dependencies
178
-     * @param int    $overwrite
179
-     * @return bool
180
-     */
181
-    public function registerDependencies(
182
-        $class,
183
-        array $dependencies,
184
-        $overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
185
-    ) {
186
-        $class = trim($class, '\\');
187
-        $registered = false;
188
-        if (empty(self::$_instance->_dependency_map[ $class ])) {
189
-            self::$_instance->_dependency_map[ $class ] = array();
190
-        }
191
-        // we need to make sure that any aliases used when registering a dependency
192
-        // get resolved to the correct class name
193
-        foreach ((array)$dependencies as $dependency => $load_source) {
194
-            $alias = self::$_instance->get_alias($dependency);
195
-            if (
196
-                $overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
-                || ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
198
-            ) {
199
-                unset($dependencies[$dependency]);
200
-                $dependencies[$alias] = $load_source;
201
-                $registered = true;
202
-            }
203
-        }
204
-        // now add our two lists of dependencies together.
205
-        // using Union (+=) favours the arrays in precedence from left to right,
206
-        // so $dependencies is NOT overwritten because it is listed first
207
-        // ie: with A = B + C, entries in B take precedence over duplicate entries in C
208
-        // Union is way faster than array_merge() but should be used with caution...
209
-        // especially with numerically indexed arrays
210
-        $dependencies += self::$_instance->_dependency_map[ $class ];
211
-        // now we need to ensure that the resulting dependencies
212
-        // array only has the entries that are required for the class
213
-        // so first count how many dependencies were originally registered for the class
214
-        $dependency_count = count(self::$_instance->_dependency_map[ $class ]);
215
-        // if that count is non-zero (meaning dependencies were already registered)
216
-        self::$_instance->_dependency_map[ $class ] = $dependency_count
217
-            // then truncate the  final array to match that count
218
-            ? array_slice($dependencies, 0, $dependency_count)
219
-            // otherwise just take the incoming array because nothing previously existed
220
-            : $dependencies;
221
-        return $registered;
222
-    }
223
-
224
-
225
-
226
-    /**
227
-     * @param string $class_name
228
-     * @param string $loader
229
-     * @return bool
230
-     * @throws DomainException
231
-     */
232
-    public static function register_class_loader($class_name, $loader = 'load_core')
233
-    {
234
-        if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235
-            throw new DomainException(
236
-                esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237
-            );
238
-        }
239
-        // check that loader is callable or method starts with "load_" and exists in EE_Registry
240
-        if (
241
-            ! is_callable($loader)
242
-            && (
243
-                strpos($loader, 'load_') !== 0
244
-                || ! method_exists('EE_Registry', $loader)
245
-            )
246
-        ) {
247
-            throw new DomainException(
248
-                sprintf(
249
-                    esc_html__(
250
-                        '"%1$s" is not a valid loader method on EE_Registry.',
251
-                        'event_espresso'
252
-                    ),
253
-                    $loader
254
-                )
255
-            );
256
-        }
257
-        $class_name = self::$_instance->get_alias($class_name);
258
-        if (! isset(self::$_instance->_class_loaders[$class_name])) {
259
-            self::$_instance->_class_loaders[$class_name] = $loader;
260
-            return true;
261
-        }
262
-        return false;
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * @return array
269
-     */
270
-    public function dependency_map()
271
-    {
272
-        return $this->_dependency_map;
273
-    }
274
-
275
-
276
-
277
-    /**
278
-     * returns TRUE if dependency map contains a listing for the provided class name
279
-     *
280
-     * @param string $class_name
281
-     * @return boolean
282
-     */
283
-    public function has($class_name = '')
284
-    {
285
-        // all legacy models have the same dependencies
286
-        if (strpos($class_name, 'EEM_') === 0) {
287
-            $class_name = 'LEGACY_MODELS';
288
-        }
289
-        return isset($this->_dependency_map[$class_name]) ? true : false;
290
-    }
291
-
292
-
293
-
294
-    /**
295
-     * returns TRUE if dependency map contains a listing for the provided class name AND dependency
296
-     *
297
-     * @param string $class_name
298
-     * @param string $dependency
299
-     * @return bool
300
-     */
301
-    public function has_dependency_for_class($class_name = '', $dependency = '')
302
-    {
303
-        // all legacy models have the same dependencies
304
-        if (strpos($class_name, 'EEM_') === 0) {
305
-            $class_name = 'LEGACY_MODELS';
306
-        }
307
-        $dependency = $this->get_alias($dependency);
308
-        return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
309
-            ? true
310
-            : false;
311
-    }
312
-
313
-
314
-
315
-    /**
316
-     * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
317
-     *
318
-     * @param string $class_name
319
-     * @param string $dependency
320
-     * @return int
321
-     */
322
-    public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
323
-    {
324
-        // all legacy models have the same dependencies
325
-        if (strpos($class_name, 'EEM_') === 0) {
326
-            $class_name = 'LEGACY_MODELS';
327
-        }
328
-        $dependency = $this->get_alias($dependency);
329
-        return $this->has_dependency_for_class($class_name, $dependency)
330
-            ? $this->_dependency_map[$class_name][$dependency]
331
-            : EE_Dependency_Map::not_registered;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * @param string $class_name
338
-     * @return string | Closure
339
-     */
340
-    public function class_loader($class_name)
341
-    {
342
-        // all legacy models use load_model()
343
-        if(strpos($class_name, 'EEM_') === 0){
344
-            return 'load_model';
345
-        }
346
-        $class_name = $this->get_alias($class_name);
347
-        return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
348
-    }
349
-
350
-
351
-
352
-    /**
353
-     * @return array
354
-     */
355
-    public function class_loaders()
356
-    {
357
-        return $this->_class_loaders;
358
-    }
359
-
360
-
361
-
362
-    /**
363
-     * adds an alias for a classname
364
-     *
365
-     * @param string $class_name the class name that should be used (concrete class to replace interface)
366
-     * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
367
-     * @param string $for_class  the class that has the dependency (is type hinting for the interface)
368
-     */
369
-    public function add_alias($class_name, $alias, $for_class = '')
370
-    {
371
-        if ($for_class !== '') {
372
-            if (! isset($this->_aliases[$for_class])) {
373
-                $this->_aliases[$for_class] = array();
374
-            }
375
-            $this->_aliases[$for_class][$class_name] = $alias;
376
-        }
377
-        $this->_aliases[$class_name] = $alias;
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * returns TRUE if the provided class name has an alias
384
-     *
385
-     * @param string $class_name
386
-     * @param string $for_class
387
-     * @return bool
388
-     */
389
-    public function has_alias($class_name = '', $for_class = '')
390
-    {
391
-        return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
392
-               || (
393
-                   isset($this->_aliases[$class_name])
394
-                   && ! is_array($this->_aliases[$class_name])
395
-               );
396
-    }
397
-
398
-
399
-
400
-    /**
401
-     * returns alias for class name if one exists, otherwise returns the original classname
402
-     * functions recursively, so that multiple aliases can be used to drill down to a classname
403
-     *  for example:
404
-     *      if the following two entries were added to the _aliases array:
405
-     *          array(
406
-     *              'interface_alias'           => 'some\namespace\interface'
407
-     *              'some\namespace\interface'  => 'some\namespace\classname'
408
-     *          )
409
-     *      then one could use EE_Registry::instance()->create( 'interface_alias' )
410
-     *      to load an instance of 'some\namespace\classname'
411
-     *
412
-     * @param string $class_name
413
-     * @param string $for_class
414
-     * @return string
415
-     */
416
-    public function get_alias($class_name = '', $for_class = '')
417
-    {
418
-        if (! $this->has_alias($class_name, $for_class)) {
419
-            return $class_name;
420
-        }
421
-        if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
422
-            return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423
-        }
424
-        return $this->get_alias($this->_aliases[$class_name]);
425
-    }
426
-
427
-
428
-
429
-    /**
430
-     * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
-     * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
-     * This is done by using the following class constants:
433
-     *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
-     *        EE_Dependency_Map::load_new_object - generates a new object every time
435
-     */
436
-    protected function _register_core_dependencies()
437
-    {
438
-        $this->_dependency_map = array(
439
-            'EE_Request_Handler'                                                                                          => array(
440
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
441
-            ),
442
-            'EE_System'                                                                                                   => array(
443
-                'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
444
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
445
-                'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
446
-                'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
447
-                'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
448
-            ),
449
-            'EE_Session'                                                                                                  => array(
450
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
451
-                'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
452
-            ),
453
-            'EE_Cart'                                                                                                     => array(
454
-                'EE_Session' => EE_Dependency_Map::load_from_cache,
455
-            ),
456
-            'EE_Front_Controller'                                                                                         => array(
457
-                'EE_Registry'              => EE_Dependency_Map::load_from_cache,
458
-                'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
459
-                'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
460
-            ),
461
-            'EE_Messenger_Collection_Loader'                                                                              => array(
462
-                'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
463
-            ),
464
-            'EE_Message_Type_Collection_Loader'                                                                           => array(
465
-                'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
466
-            ),
467
-            'EE_Message_Resource_Manager'                                                                                 => array(
468
-                'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
469
-                'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
470
-                'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
471
-            ),
472
-            'EE_Message_Factory'                                                                                          => array(
473
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
474
-            ),
475
-            'EE_messages'                                                                                                 => array(
476
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
477
-            ),
478
-            'EE_Messages_Generator'                                                                                       => array(
479
-                'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
480
-                'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
481
-                'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
482
-                'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
483
-            ),
484
-            'EE_Messages_Processor'                                                                                       => array(
485
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
-            ),
487
-            'EE_Messages_Queue'                                                                                           => array(
488
-                'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
489
-            ),
490
-            'EE_Messages_Template_Defaults'                                                                               => array(
491
-                'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
492
-                'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
493
-            ),
494
-            'EE_Message_To_Generate_From_Request'                                                                         => array(
495
-                'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
496
-                'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
497
-            ),
498
-            'EventEspresso\core\services\commands\CommandBus'                                                             => array(
499
-                'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
500
-            ),
501
-            'EventEspresso\services\commands\CommandHandler'                                                              => array(
502
-                'EE_Registry'         => EE_Dependency_Map::load_from_cache,
503
-                'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
504
-            ),
505
-            'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
506
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
507
-            ),
508
-            'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
509
-                'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
510
-                'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
511
-            ),
512
-            'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
513
-                'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
514
-            ),
515
-            'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
516
-                'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
517
-            ),
518
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
519
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
520
-            ),
521
-            'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
522
-                'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
523
-            ),
524
-            'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
525
-                'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
526
-            ),
527
-            'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
528
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
529
-            ),
530
-            'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
531
-                'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
532
-            ),
533
-            'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
534
-                'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
535
-            ),
536
-            'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
537
-                'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
538
-            ),
539
-            'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
540
-                'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
541
-            ),
542
-            'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
543
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
-            ),
545
-            'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
546
-                'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
547
-            ),
548
-            'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
549
-                'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
550
-            ),
551
-            'EventEspresso\core\services\database\TableManager'                                                           => array(
552
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
553
-            ),
554
-            'EE_Data_Migration_Class_Base'                                                                                => array(
555
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
556
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
557
-            ),
558
-            'EE_DMS_Core_4_1_0'                                                                                           => array(
559
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
560
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
561
-            ),
562
-            'EE_DMS_Core_4_2_0'                                                                                           => array(
563
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
-            ),
566
-            'EE_DMS_Core_4_3_0'                                                                                           => array(
567
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
-            ),
570
-            'EE_DMS_Core_4_4_0'                                                                                           => array(
571
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
-            ),
574
-            'EE_DMS_Core_4_5_0'                                                                                           => array(
575
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
-            ),
578
-            'EE_DMS_Core_4_6_0'                                                                                           => array(
579
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
-            ),
582
-            'EE_DMS_Core_4_7_0'                                                                                           => array(
583
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
-            ),
586
-            'EE_DMS_Core_4_8_0'                                                                                           => array(
587
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
-            ),
590
-            'EE_DMS_Core_4_9_0'                                                                                           => array(
591
-                'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
-                'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
-            ),
594
-            'EventEspresso\core\services\assets\Registry'                                                                 => array(
595
-                'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
596
-                'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
597
-            ),
598
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
599
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
600
-            ),
601
-            'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
602
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
603
-            ),
604
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
605
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
606
-            ),
607
-            'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
608
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
609
-            ),
610
-            'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
611
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
-            ),
613
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
614
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
-            ),
616
-            'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
617
-                'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
-            ),
619
-            'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
620
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
621
-            ),
622
-            'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
623
-                'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
-            ),
625
-            'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
626
-                'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
627
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
628
-            ),
629
-            'EventEspresso\core\domain\values\EmailAddress'                              => array(
630
-                null,
631
-                'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
632
-            ),
633
-            'EventEspresso\core\services\orm\ModelFieldFactory' => array(
634
-                'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
635
-            ),
636
-            'LEGACY_MODELS'                                                   => array(
637
-                null,
638
-                'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
639
-            ),
640
-            'EE_Module_Request_Router' => array(
641
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
642
-            ),
643
-            'EE_Registration_Processor' => array(
644
-                'EE_Request' => EE_Dependency_Map::load_from_cache,
645
-            ),
646
-        );
647
-    }
648
-
649
-
650
-
651
-    /**
652
-     * Registers how core classes are loaded.
653
-     * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
654
-     *        'EE_Request_Handler' => 'load_core'
655
-     *        'EE_Messages_Queue'  => 'load_lib'
656
-     *        'EEH_Debug_Tools'    => 'load_helper'
657
-     * or, if greater control is required, by providing a custom closure. For example:
658
-     *        'Some_Class' => function () {
659
-     *            return new Some_Class();
660
-     *        },
661
-     * This is required for instantiating dependencies
662
-     * where an interface has been type hinted in a class constructor. For example:
663
-     *        'Required_Interface' => function () {
664
-     *            return new A_Class_That_Implements_Required_Interface();
665
-     *        },
666
-     *
667
-     * @throws InvalidInterfaceException
668
-     * @throws InvalidDataTypeException
669
-     * @throws InvalidArgumentException
670
-     */
671
-    protected function _register_core_class_loaders()
672
-    {
673
-        //for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
674
-        //be used in a closure.
675
-        $request = &$this->_request;
676
-        $response = &$this->_response;
677
-        // $loader = &$this->loader;
678
-        $this->_class_loaders = array(
679
-            //load_core
680
-            'EE_Capabilities'                      => 'load_core',
681
-            'EE_Encryption'                        => 'load_core',
682
-            'EE_Front_Controller'                  => 'load_core',
683
-            'EE_Module_Request_Router'             => 'load_core',
684
-            'EE_Registry'                          => 'load_core',
685
-            'EE_Request'                           => function () use (&$request) {
686
-                return $request;
687
-            },
688
-            'EE_Response'                          => function () use (&$response) {
689
-                return $response;
690
-            },
691
-            'EE_Request_Handler'                   => 'load_core',
692
-            'EE_Session'                           => 'load_core',
693
-            'EE_Cron_Tasks'                        => 'load_core',
694
-            'EE_System'                            => 'load_core',
695
-            'EE_Maintenance_Mode'                  => 'load_core',
696
-            'EE_Register_CPTs'                     => 'load_core',
697
-            'EE_Admin'                             => 'load_core',
698
-            //load_lib
699
-            'EE_Message_Resource_Manager'          => 'load_lib',
700
-            'EE_Message_Type_Collection'           => 'load_lib',
701
-            'EE_Message_Type_Collection_Loader'    => 'load_lib',
702
-            'EE_Messenger_Collection'              => 'load_lib',
703
-            'EE_Messenger_Collection_Loader'       => 'load_lib',
704
-            'EE_Messages_Processor'                => 'load_lib',
705
-            'EE_Message_Repository'                => 'load_lib',
706
-            'EE_Messages_Queue'                    => 'load_lib',
707
-            'EE_Messages_Data_Handler_Collection'  => 'load_lib',
708
-            'EE_Message_Template_Group_Collection' => 'load_lib',
709
-            'EE_Payment_Method_Manager'            => 'load_lib',
710
-            'EE_Messages_Generator'                => function () {
711
-                return EE_Registry::instance()->load_lib(
712
-                    'Messages_Generator',
713
-                    array(),
714
-                    false,
715
-                    false
716
-                );
717
-            },
718
-            'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
719
-                return EE_Registry::instance()->load_lib(
720
-                    'Messages_Template_Defaults',
721
-                    $arguments,
722
-                    false,
723
-                    false
724
-                );
725
-            },
726
-            //load_model
727
-            // 'EEM_Attendee'                         => 'load_model',
728
-            // 'EEM_Message_Template_Group'           => 'load_model',
729
-            // 'EEM_Message_Template'                 => 'load_model',
730
-            //load_helper
731
-            'EEH_Parse_Shortcodes'                 => function () {
732
-                if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
733
-                    return new EEH_Parse_Shortcodes();
734
-                }
735
-                return null;
736
-            },
737
-            'EE_Template_Config'                   => function () {
738
-                return EE_Config::instance()->template_settings;
739
-            },
740
-            'EE_Currency_Config'                   => function () {
741
-                return EE_Config::instance()->currency;
742
-            },
743
-            'EE_Registration_Config'                   => function () {
744
-                return EE_Config::instance()->registration;
745
-            },
746
-            'EventEspresso\core\services\loaders\Loader' => function () {
747
-                return LoaderFactory::getLoader();
748
-            },
749
-        );
750
-    }
751
-
752
-
753
-
754
-    /**
755
-     * can be used for supplying alternate names for classes,
756
-     * or for connecting interface names to instantiable classes
757
-     */
758
-    protected function _register_core_aliases()
759
-    {
760
-        $this->_aliases = array(
761
-            'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
762
-            'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
763
-            'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
764
-            'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
765
-            'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
766
-            'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
767
-            'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
768
-            'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
769
-            'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
770
-            'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
771
-            'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
772
-            'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
773
-            'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
774
-            'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
775
-            'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
776
-            'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
777
-            'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
778
-            'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
779
-            'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
780
-            'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
781
-            'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
782
-            'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
783
-            'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
784
-            'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
785
-            'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
786
-            'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
787
-            'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
788
-            'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
789
-            'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
790
-            'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
791
-            'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
792
-            'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
793
-            'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
794
-            'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
795
-            'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
796
-            'NoticesContainerInterface'                                            => 'EventEspresso\core\services\notices\NoticesContainerInterface',
797
-            'EventEspresso\core\services\notices\NoticesContainerInterface'        => 'EventEspresso\core\services\notices\NoticesContainer',
798
-        );
799
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
800
-            $this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
801
-        }
802
-    }
803
-
804
-
805
-
806
-    /**
807
-     * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
808
-     * request Primarily used by unit tests.
809
-     *
810
-     * @throws InvalidDataTypeException
811
-     * @throws InvalidInterfaceException
812
-     * @throws InvalidArgumentException
813
-     */
814
-    public function reset()
815
-    {
816
-        $this->_register_core_class_loaders();
817
-        $this->_register_core_dependencies();
818
-    }
25
+	/**
26
+	 * This means that the requested class dependency is not present in the dependency map
27
+	 */
28
+	const not_registered = 0;
29
+
30
+	/**
31
+	 * This instructs class loaders to ALWAYS return a newly instantiated object for the requested class.
32
+	 */
33
+	const load_new_object = 1;
34
+
35
+	/**
36
+	 * This instructs class loaders to return a previously instantiated and cached object for the requested class.
37
+	 * IF a previously instantiated object does not exist, a new one will be created and added to the cache.
38
+	 */
39
+	const load_from_cache = 2;
40
+
41
+	/**
42
+	 * When registering a dependency,
43
+	 * this indicates to keep any existing dependencies that already exist,
44
+	 * and simply discard any new dependencies declared in the incoming data
45
+	 */
46
+	const KEEP_EXISTING_DEPENDENCIES = 0;
47
+
48
+	/**
49
+	 * When registering a dependency,
50
+	 * this indicates to overwrite any existing dependencies that already exist using the incoming data
51
+	 */
52
+	const OVERWRITE_DEPENDENCIES = 1;
53
+
54
+
55
+
56
+	/**
57
+	 * @type EE_Dependency_Map $_instance
58
+	 */
59
+	protected static $_instance;
60
+
61
+	/**
62
+	 * @type EE_Request $request
63
+	 */
64
+	protected $_request;
65
+
66
+	/**
67
+	 * @type EE_Response $response
68
+	 */
69
+	protected $_response;
70
+
71
+	/**
72
+	 * @type LoaderInterface $loader
73
+	 */
74
+	protected $loader;
75
+
76
+	/**
77
+	 * @type array $_dependency_map
78
+	 */
79
+	protected $_dependency_map = array();
80
+
81
+	/**
82
+	 * @type array $_class_loaders
83
+	 */
84
+	protected $_class_loaders = array();
85
+
86
+	/**
87
+	 * @type array $_aliases
88
+	 */
89
+	protected $_aliases = array();
90
+
91
+
92
+
93
+	/**
94
+	 * EE_Dependency_Map constructor.
95
+	 *
96
+	 * @param EE_Request  $request
97
+	 * @param EE_Response $response
98
+	 */
99
+	protected function __construct(EE_Request $request, EE_Response $response)
100
+	{
101
+		$this->_request = $request;
102
+		$this->_response = $response;
103
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
104
+		do_action('EE_Dependency_Map____construct');
105
+	}
106
+
107
+
108
+
109
+	/**
110
+	 * @throws InvalidDataTypeException
111
+	 * @throws InvalidInterfaceException
112
+	 * @throws InvalidArgumentException
113
+	 */
114
+	public function initialize()
115
+	{
116
+		$this->_register_core_dependencies();
117
+		$this->_register_core_class_loaders();
118
+		$this->_register_core_aliases();
119
+	}
120
+
121
+
122
+
123
+	/**
124
+	 * @singleton method used to instantiate class object
125
+	 * @access    public
126
+	 * @param EE_Request  $request
127
+	 * @param EE_Response $response
128
+	 * @return EE_Dependency_Map
129
+	 */
130
+	public static function instance(EE_Request $request = null, EE_Response $response = null)
131
+	{
132
+		// check if class object is instantiated, and instantiated properly
133
+		if (! self::$_instance instanceof EE_Dependency_Map) {
134
+			self::$_instance = new EE_Dependency_Map($request, $response);
135
+		}
136
+		return self::$_instance;
137
+	}
138
+
139
+
140
+
141
+	/**
142
+	 * @param LoaderInterface $loader
143
+	 */
144
+	public function setLoader(LoaderInterface $loader)
145
+	{
146
+		$this->loader = $loader;
147
+	}
148
+
149
+
150
+
151
+	/**
152
+	 * @param string $class
153
+	 * @param array  $dependencies
154
+	 * @param int    $overwrite
155
+	 * @return bool
156
+	 */
157
+	public static function register_dependencies(
158
+		$class,
159
+		array $dependencies,
160
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
161
+	) {
162
+		return self::$_instance->registerDependencies($class, $dependencies, $overwrite);
163
+	}
164
+
165
+
166
+
167
+	/**
168
+	 * Assigns an array of class names and corresponding load sources (new or cached)
169
+	 * to the class specified by the first parameter.
170
+	 * IMPORTANT !!!
171
+	 * The order of elements in the incoming $dependencies array MUST match
172
+	 * the order of the constructor parameters for the class in question.
173
+	 * This is especially important when overriding any existing dependencies that are registered.
174
+	 * the third parameter controls whether any duplicate dependencies are overwritten or not.
175
+	 *
176
+	 * @param string $class
177
+	 * @param array  $dependencies
178
+	 * @param int    $overwrite
179
+	 * @return bool
180
+	 */
181
+	public function registerDependencies(
182
+		$class,
183
+		array $dependencies,
184
+		$overwrite = EE_Dependency_Map::KEEP_EXISTING_DEPENDENCIES
185
+	) {
186
+		$class = trim($class, '\\');
187
+		$registered = false;
188
+		if (empty(self::$_instance->_dependency_map[ $class ])) {
189
+			self::$_instance->_dependency_map[ $class ] = array();
190
+		}
191
+		// we need to make sure that any aliases used when registering a dependency
192
+		// get resolved to the correct class name
193
+		foreach ((array)$dependencies as $dependency => $load_source) {
194
+			$alias = self::$_instance->get_alias($dependency);
195
+			if (
196
+				$overwrite === EE_Dependency_Map::OVERWRITE_DEPENDENCIES
197
+				|| ! isset(self::$_instance->_dependency_map[ $class ][ $alias ])
198
+			) {
199
+				unset($dependencies[$dependency]);
200
+				$dependencies[$alias] = $load_source;
201
+				$registered = true;
202
+			}
203
+		}
204
+		// now add our two lists of dependencies together.
205
+		// using Union (+=) favours the arrays in precedence from left to right,
206
+		// so $dependencies is NOT overwritten because it is listed first
207
+		// ie: with A = B + C, entries in B take precedence over duplicate entries in C
208
+		// Union is way faster than array_merge() but should be used with caution...
209
+		// especially with numerically indexed arrays
210
+		$dependencies += self::$_instance->_dependency_map[ $class ];
211
+		// now we need to ensure that the resulting dependencies
212
+		// array only has the entries that are required for the class
213
+		// so first count how many dependencies were originally registered for the class
214
+		$dependency_count = count(self::$_instance->_dependency_map[ $class ]);
215
+		// if that count is non-zero (meaning dependencies were already registered)
216
+		self::$_instance->_dependency_map[ $class ] = $dependency_count
217
+			// then truncate the  final array to match that count
218
+			? array_slice($dependencies, 0, $dependency_count)
219
+			// otherwise just take the incoming array because nothing previously existed
220
+			: $dependencies;
221
+		return $registered;
222
+	}
223
+
224
+
225
+
226
+	/**
227
+	 * @param string $class_name
228
+	 * @param string $loader
229
+	 * @return bool
230
+	 * @throws DomainException
231
+	 */
232
+	public static function register_class_loader($class_name, $loader = 'load_core')
233
+	{
234
+		if (! $loader instanceof Closure && strpos($class_name, '\\') !== false) {
235
+			throw new DomainException(
236
+				esc_html__('Don\'t use class loaders for FQCNs.', 'event_espresso')
237
+			);
238
+		}
239
+		// check that loader is callable or method starts with "load_" and exists in EE_Registry
240
+		if (
241
+			! is_callable($loader)
242
+			&& (
243
+				strpos($loader, 'load_') !== 0
244
+				|| ! method_exists('EE_Registry', $loader)
245
+			)
246
+		) {
247
+			throw new DomainException(
248
+				sprintf(
249
+					esc_html__(
250
+						'"%1$s" is not a valid loader method on EE_Registry.',
251
+						'event_espresso'
252
+					),
253
+					$loader
254
+				)
255
+			);
256
+		}
257
+		$class_name = self::$_instance->get_alias($class_name);
258
+		if (! isset(self::$_instance->_class_loaders[$class_name])) {
259
+			self::$_instance->_class_loaders[$class_name] = $loader;
260
+			return true;
261
+		}
262
+		return false;
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * @return array
269
+	 */
270
+	public function dependency_map()
271
+	{
272
+		return $this->_dependency_map;
273
+	}
274
+
275
+
276
+
277
+	/**
278
+	 * returns TRUE if dependency map contains a listing for the provided class name
279
+	 *
280
+	 * @param string $class_name
281
+	 * @return boolean
282
+	 */
283
+	public function has($class_name = '')
284
+	{
285
+		// all legacy models have the same dependencies
286
+		if (strpos($class_name, 'EEM_') === 0) {
287
+			$class_name = 'LEGACY_MODELS';
288
+		}
289
+		return isset($this->_dependency_map[$class_name]) ? true : false;
290
+	}
291
+
292
+
293
+
294
+	/**
295
+	 * returns TRUE if dependency map contains a listing for the provided class name AND dependency
296
+	 *
297
+	 * @param string $class_name
298
+	 * @param string $dependency
299
+	 * @return bool
300
+	 */
301
+	public function has_dependency_for_class($class_name = '', $dependency = '')
302
+	{
303
+		// all legacy models have the same dependencies
304
+		if (strpos($class_name, 'EEM_') === 0) {
305
+			$class_name = 'LEGACY_MODELS';
306
+		}
307
+		$dependency = $this->get_alias($dependency);
308
+		return isset($this->_dependency_map[$class_name], $this->_dependency_map[$class_name][$dependency])
309
+			? true
310
+			: false;
311
+	}
312
+
313
+
314
+
315
+	/**
316
+	 * returns loading strategy for whether a previously cached dependency should be loaded or a new instance returned
317
+	 *
318
+	 * @param string $class_name
319
+	 * @param string $dependency
320
+	 * @return int
321
+	 */
322
+	public function loading_strategy_for_class_dependency($class_name = '', $dependency = '')
323
+	{
324
+		// all legacy models have the same dependencies
325
+		if (strpos($class_name, 'EEM_') === 0) {
326
+			$class_name = 'LEGACY_MODELS';
327
+		}
328
+		$dependency = $this->get_alias($dependency);
329
+		return $this->has_dependency_for_class($class_name, $dependency)
330
+			? $this->_dependency_map[$class_name][$dependency]
331
+			: EE_Dependency_Map::not_registered;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * @param string $class_name
338
+	 * @return string | Closure
339
+	 */
340
+	public function class_loader($class_name)
341
+	{
342
+		// all legacy models use load_model()
343
+		if(strpos($class_name, 'EEM_') === 0){
344
+			return 'load_model';
345
+		}
346
+		$class_name = $this->get_alias($class_name);
347
+		return isset($this->_class_loaders[$class_name]) ? $this->_class_loaders[$class_name] : '';
348
+	}
349
+
350
+
351
+
352
+	/**
353
+	 * @return array
354
+	 */
355
+	public function class_loaders()
356
+	{
357
+		return $this->_class_loaders;
358
+	}
359
+
360
+
361
+
362
+	/**
363
+	 * adds an alias for a classname
364
+	 *
365
+	 * @param string $class_name the class name that should be used (concrete class to replace interface)
366
+	 * @param string $alias      the class name that would be type hinted for (abstract parent or interface)
367
+	 * @param string $for_class  the class that has the dependency (is type hinting for the interface)
368
+	 */
369
+	public function add_alias($class_name, $alias, $for_class = '')
370
+	{
371
+		if ($for_class !== '') {
372
+			if (! isset($this->_aliases[$for_class])) {
373
+				$this->_aliases[$for_class] = array();
374
+			}
375
+			$this->_aliases[$for_class][$class_name] = $alias;
376
+		}
377
+		$this->_aliases[$class_name] = $alias;
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * returns TRUE if the provided class name has an alias
384
+	 *
385
+	 * @param string $class_name
386
+	 * @param string $for_class
387
+	 * @return bool
388
+	 */
389
+	public function has_alias($class_name = '', $for_class = '')
390
+	{
391
+		return isset($this->_aliases[$for_class], $this->_aliases[$for_class][$class_name])
392
+			   || (
393
+				   isset($this->_aliases[$class_name])
394
+				   && ! is_array($this->_aliases[$class_name])
395
+			   );
396
+	}
397
+
398
+
399
+
400
+	/**
401
+	 * returns alias for class name if one exists, otherwise returns the original classname
402
+	 * functions recursively, so that multiple aliases can be used to drill down to a classname
403
+	 *  for example:
404
+	 *      if the following two entries were added to the _aliases array:
405
+	 *          array(
406
+	 *              'interface_alias'           => 'some\namespace\interface'
407
+	 *              'some\namespace\interface'  => 'some\namespace\classname'
408
+	 *          )
409
+	 *      then one could use EE_Registry::instance()->create( 'interface_alias' )
410
+	 *      to load an instance of 'some\namespace\classname'
411
+	 *
412
+	 * @param string $class_name
413
+	 * @param string $for_class
414
+	 * @return string
415
+	 */
416
+	public function get_alias($class_name = '', $for_class = '')
417
+	{
418
+		if (! $this->has_alias($class_name, $for_class)) {
419
+			return $class_name;
420
+		}
421
+		if ($for_class !== '' && isset($this->_aliases[ $for_class ][ $class_name ])) {
422
+			return $this->get_alias($this->_aliases[$for_class][$class_name], $for_class);
423
+		}
424
+		return $this->get_alias($this->_aliases[$class_name]);
425
+	}
426
+
427
+
428
+
429
+	/**
430
+	 * Registers the core dependencies and whether a previously instantiated object should be loaded from the cache,
431
+	 * if one exists, or whether a new object should be generated every time the requested class is loaded.
432
+	 * This is done by using the following class constants:
433
+	 *        EE_Dependency_Map::load_from_cache - loads previously instantiated object
434
+	 *        EE_Dependency_Map::load_new_object - generates a new object every time
435
+	 */
436
+	protected function _register_core_dependencies()
437
+	{
438
+		$this->_dependency_map = array(
439
+			'EE_Request_Handler'                                                                                          => array(
440
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
441
+			),
442
+			'EE_System'                                                                                                   => array(
443
+				'EE_Registry'                                => EE_Dependency_Map::load_from_cache,
444
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
445
+				'EE_Capabilities'                            => EE_Dependency_Map::load_from_cache,
446
+				'EE_Request'                                 => EE_Dependency_Map::load_from_cache,
447
+				'EE_Maintenance_Mode'                        => EE_Dependency_Map::load_from_cache,
448
+			),
449
+			'EE_Session'                                                                                                  => array(
450
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
451
+				'EE_Encryption'                                           => EE_Dependency_Map::load_from_cache,
452
+			),
453
+			'EE_Cart'                                                                                                     => array(
454
+				'EE_Session' => EE_Dependency_Map::load_from_cache,
455
+			),
456
+			'EE_Front_Controller'                                                                                         => array(
457
+				'EE_Registry'              => EE_Dependency_Map::load_from_cache,
458
+				'EE_Request_Handler'       => EE_Dependency_Map::load_from_cache,
459
+				'EE_Module_Request_Router' => EE_Dependency_Map::load_from_cache,
460
+			),
461
+			'EE_Messenger_Collection_Loader'                                                                              => array(
462
+				'EE_Messenger_Collection' => EE_Dependency_Map::load_new_object,
463
+			),
464
+			'EE_Message_Type_Collection_Loader'                                                                           => array(
465
+				'EE_Message_Type_Collection' => EE_Dependency_Map::load_new_object,
466
+			),
467
+			'EE_Message_Resource_Manager'                                                                                 => array(
468
+				'EE_Messenger_Collection_Loader'    => EE_Dependency_Map::load_new_object,
469
+				'EE_Message_Type_Collection_Loader' => EE_Dependency_Map::load_new_object,
470
+				'EEM_Message_Template_Group'        => EE_Dependency_Map::load_from_cache,
471
+			),
472
+			'EE_Message_Factory'                                                                                          => array(
473
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
474
+			),
475
+			'EE_messages'                                                                                                 => array(
476
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
477
+			),
478
+			'EE_Messages_Generator'                                                                                       => array(
479
+				'EE_Messages_Queue'                    => EE_Dependency_Map::load_new_object,
480
+				'EE_Messages_Data_Handler_Collection'  => EE_Dependency_Map::load_new_object,
481
+				'EE_Message_Template_Group_Collection' => EE_Dependency_Map::load_new_object,
482
+				'EEH_Parse_Shortcodes'                 => EE_Dependency_Map::load_from_cache,
483
+			),
484
+			'EE_Messages_Processor'                                                                                       => array(
485
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
486
+			),
487
+			'EE_Messages_Queue'                                                                                           => array(
488
+				'EE_Message_Repository' => EE_Dependency_Map::load_new_object,
489
+			),
490
+			'EE_Messages_Template_Defaults'                                                                               => array(
491
+				'EEM_Message_Template_Group' => EE_Dependency_Map::load_from_cache,
492
+				'EEM_Message_Template'       => EE_Dependency_Map::load_from_cache,
493
+			),
494
+			'EE_Message_To_Generate_From_Request'                                                                         => array(
495
+				'EE_Message_Resource_Manager' => EE_Dependency_Map::load_from_cache,
496
+				'EE_Request_Handler'          => EE_Dependency_Map::load_from_cache,
497
+			),
498
+			'EventEspresso\core\services\commands\CommandBus'                                                             => array(
499
+				'EventEspresso\core\services\commands\CommandHandlerManager' => EE_Dependency_Map::load_from_cache,
500
+			),
501
+			'EventEspresso\services\commands\CommandHandler'                                                              => array(
502
+				'EE_Registry'         => EE_Dependency_Map::load_from_cache,
503
+				'CommandBusInterface' => EE_Dependency_Map::load_from_cache,
504
+			),
505
+			'EventEspresso\core\services\commands\CommandHandlerManager'                                                  => array(
506
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
507
+			),
508
+			'EventEspresso\core\services\commands\CompositeCommandHandler'                                                => array(
509
+				'EventEspresso\core\services\commands\CommandBus'     => EE_Dependency_Map::load_from_cache,
510
+				'EventEspresso\core\services\commands\CommandFactory' => EE_Dependency_Map::load_from_cache,
511
+			),
512
+			'EventEspresso\core\services\commands\CommandFactory'                                                         => array(
513
+				'EventEspresso\core\services\loaders\Loader' => EE_Dependency_Map::load_from_cache,
514
+			),
515
+			'EventEspresso\core\services\commands\middleware\CapChecker'                                                  => array(
516
+				'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker' => EE_Dependency_Map::load_from_cache,
517
+			),
518
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker'                                         => array(
519
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
520
+			),
521
+			'EventEspresso\core\domain\services\capabilities\RegistrationsCapChecker'                                     => array(
522
+				'EE_Capabilities' => EE_Dependency_Map::load_from_cache,
523
+			),
524
+			'EventEspresso\core\services\commands\registration\CreateRegistrationCommandHandler'                          => array(
525
+				'EventEspresso\core\domain\services\registration\CreateRegistrationService' => EE_Dependency_Map::load_from_cache,
526
+			),
527
+			'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommandHandler'                     => array(
528
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
529
+			),
530
+			'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommandHandler'                    => array(
531
+				'EventEspresso\core\domain\services\registration\CopyRegistrationService' => EE_Dependency_Map::load_from_cache,
532
+			),
533
+			'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler'         => array(
534
+				'EventEspresso\core\domain\services\registration\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
535
+			),
536
+			'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler' => array(
537
+				'EventEspresso\core\domain\services\registration\UpdateRegistrationService' => EE_Dependency_Map::load_from_cache,
538
+			),
539
+			'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommandHandler'                              => array(
540
+				'EventEspresso\core\domain\services\ticket\CreateTicketLineItemService' => EE_Dependency_Map::load_from_cache,
541
+			),
542
+			'EventEspresso\core\services\commands\ticket\CancelTicketLineItemCommandHandler'                              => array(
543
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
544
+			),
545
+			'EventEspresso\core\domain\services\registration\CancelRegistrationService'                                   => array(
546
+				'EventEspresso\core\domain\services\ticket\CancelTicketLineItemService' => EE_Dependency_Map::load_from_cache,
547
+			),
548
+			'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler'                                  => array(
549
+				'EEM_Attendee' => EE_Dependency_Map::load_from_cache,
550
+			),
551
+			'EventEspresso\core\services\database\TableManager'                                                           => array(
552
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
553
+			),
554
+			'EE_Data_Migration_Class_Base'                                                                                => array(
555
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
556
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
557
+			),
558
+			'EE_DMS_Core_4_1_0'                                                                                           => array(
559
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
560
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
561
+			),
562
+			'EE_DMS_Core_4_2_0'                                                                                           => array(
563
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
564
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
565
+			),
566
+			'EE_DMS_Core_4_3_0'                                                                                           => array(
567
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
568
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
569
+			),
570
+			'EE_DMS_Core_4_4_0'                                                                                           => array(
571
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
572
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
573
+			),
574
+			'EE_DMS_Core_4_5_0'                                                                                           => array(
575
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
576
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
577
+			),
578
+			'EE_DMS_Core_4_6_0'                                                                                           => array(
579
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
580
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
581
+			),
582
+			'EE_DMS_Core_4_7_0'                                                                                           => array(
583
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
584
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
585
+			),
586
+			'EE_DMS_Core_4_8_0'                                                                                           => array(
587
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
588
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
589
+			),
590
+			'EE_DMS_Core_4_9_0'                                                                                           => array(
591
+				'EventEspresso\core\services\database\TableAnalysis' => EE_Dependency_Map::load_from_cache,
592
+				'EventEspresso\core\services\database\TableManager'  => EE_Dependency_Map::load_from_cache,
593
+			),
594
+			'EventEspresso\core\services\assets\Registry'                                                                 => array(
595
+				'EE_Template_Config' => EE_Dependency_Map::load_from_cache,
596
+				'EE_Currency_Config' => EE_Dependency_Map::load_from_cache,
597
+			),
598
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCancelled'                                             => array(
599
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
600
+			),
601
+			'EventEspresso\core\domain\entities\shortcodes\EspressoCheckout'                                              => array(
602
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
603
+			),
604
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEventAttendees'                                        => array(
605
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
606
+			),
607
+			'EventEspresso\core\domain\entities\shortcodes\EspressoEvents'                                                => array(
608
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
609
+			),
610
+			'EventEspresso\core\domain\entities\shortcodes\EspressoThankYou'                                              => array(
611
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
612
+			),
613
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTicketSelector'                                        => array(
614
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
615
+			),
616
+			'EventEspresso\core\domain\entities\shortcodes\EspressoTxnPage'                                               => array(
617
+				'EventEspresso\core\services\cache\PostRelatedCacheManager' => EE_Dependency_Map::load_from_cache,
618
+			),
619
+			'EventEspresso\core\services\cache\BasicCacheManager'                        => array(
620
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
621
+			),
622
+			'EventEspresso\core\services\cache\PostRelatedCacheManager'                  => array(
623
+				'EventEspresso\core\services\cache\TransientCacheStorage' => EE_Dependency_Map::load_from_cache,
624
+			),
625
+			'EventEspresso\core\domain\services\validation\email\EmailValidationService' => array(
626
+				'EE_Registration_Config'                                  => EE_Dependency_Map::load_from_cache,
627
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
628
+			),
629
+			'EventEspresso\core\domain\values\EmailAddress'                              => array(
630
+				null,
631
+				'EventEspresso\core\domain\services\validation\email\EmailValidationService' => EE_Dependency_Map::load_from_cache,
632
+			),
633
+			'EventEspresso\core\services\orm\ModelFieldFactory' => array(
634
+				'EventEspresso\core\services\loaders\Loader'              => EE_Dependency_Map::load_from_cache,
635
+			),
636
+			'LEGACY_MODELS'                                                   => array(
637
+				null,
638
+				'EventEspresso\core\services\database\ModelFieldFactory' => EE_Dependency_Map::load_from_cache,
639
+			),
640
+			'EE_Module_Request_Router' => array(
641
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
642
+			),
643
+			'EE_Registration_Processor' => array(
644
+				'EE_Request' => EE_Dependency_Map::load_from_cache,
645
+			),
646
+		);
647
+	}
648
+
649
+
650
+
651
+	/**
652
+	 * Registers how core classes are loaded.
653
+	 * This can either be done by simply providing the name of one of the EE_Registry loader methods such as:
654
+	 *        'EE_Request_Handler' => 'load_core'
655
+	 *        'EE_Messages_Queue'  => 'load_lib'
656
+	 *        'EEH_Debug_Tools'    => 'load_helper'
657
+	 * or, if greater control is required, by providing a custom closure. For example:
658
+	 *        'Some_Class' => function () {
659
+	 *            return new Some_Class();
660
+	 *        },
661
+	 * This is required for instantiating dependencies
662
+	 * where an interface has been type hinted in a class constructor. For example:
663
+	 *        'Required_Interface' => function () {
664
+	 *            return new A_Class_That_Implements_Required_Interface();
665
+	 *        },
666
+	 *
667
+	 * @throws InvalidInterfaceException
668
+	 * @throws InvalidDataTypeException
669
+	 * @throws InvalidArgumentException
670
+	 */
671
+	protected function _register_core_class_loaders()
672
+	{
673
+		//for PHP5.3 compat, we need to register any properties called here in a variable because `$this` cannot
674
+		//be used in a closure.
675
+		$request = &$this->_request;
676
+		$response = &$this->_response;
677
+		// $loader = &$this->loader;
678
+		$this->_class_loaders = array(
679
+			//load_core
680
+			'EE_Capabilities'                      => 'load_core',
681
+			'EE_Encryption'                        => 'load_core',
682
+			'EE_Front_Controller'                  => 'load_core',
683
+			'EE_Module_Request_Router'             => 'load_core',
684
+			'EE_Registry'                          => 'load_core',
685
+			'EE_Request'                           => function () use (&$request) {
686
+				return $request;
687
+			},
688
+			'EE_Response'                          => function () use (&$response) {
689
+				return $response;
690
+			},
691
+			'EE_Request_Handler'                   => 'load_core',
692
+			'EE_Session'                           => 'load_core',
693
+			'EE_Cron_Tasks'                        => 'load_core',
694
+			'EE_System'                            => 'load_core',
695
+			'EE_Maintenance_Mode'                  => 'load_core',
696
+			'EE_Register_CPTs'                     => 'load_core',
697
+			'EE_Admin'                             => 'load_core',
698
+			//load_lib
699
+			'EE_Message_Resource_Manager'          => 'load_lib',
700
+			'EE_Message_Type_Collection'           => 'load_lib',
701
+			'EE_Message_Type_Collection_Loader'    => 'load_lib',
702
+			'EE_Messenger_Collection'              => 'load_lib',
703
+			'EE_Messenger_Collection_Loader'       => 'load_lib',
704
+			'EE_Messages_Processor'                => 'load_lib',
705
+			'EE_Message_Repository'                => 'load_lib',
706
+			'EE_Messages_Queue'                    => 'load_lib',
707
+			'EE_Messages_Data_Handler_Collection'  => 'load_lib',
708
+			'EE_Message_Template_Group_Collection' => 'load_lib',
709
+			'EE_Payment_Method_Manager'            => 'load_lib',
710
+			'EE_Messages_Generator'                => function () {
711
+				return EE_Registry::instance()->load_lib(
712
+					'Messages_Generator',
713
+					array(),
714
+					false,
715
+					false
716
+				);
717
+			},
718
+			'EE_Messages_Template_Defaults'        => function ($arguments = array()) {
719
+				return EE_Registry::instance()->load_lib(
720
+					'Messages_Template_Defaults',
721
+					$arguments,
722
+					false,
723
+					false
724
+				);
725
+			},
726
+			//load_model
727
+			// 'EEM_Attendee'                         => 'load_model',
728
+			// 'EEM_Message_Template_Group'           => 'load_model',
729
+			// 'EEM_Message_Template'                 => 'load_model',
730
+			//load_helper
731
+			'EEH_Parse_Shortcodes'                 => function () {
732
+				if (EE_Registry::instance()->load_helper('Parse_Shortcodes')) {
733
+					return new EEH_Parse_Shortcodes();
734
+				}
735
+				return null;
736
+			},
737
+			'EE_Template_Config'                   => function () {
738
+				return EE_Config::instance()->template_settings;
739
+			},
740
+			'EE_Currency_Config'                   => function () {
741
+				return EE_Config::instance()->currency;
742
+			},
743
+			'EE_Registration_Config'                   => function () {
744
+				return EE_Config::instance()->registration;
745
+			},
746
+			'EventEspresso\core\services\loaders\Loader' => function () {
747
+				return LoaderFactory::getLoader();
748
+			},
749
+		);
750
+	}
751
+
752
+
753
+
754
+	/**
755
+	 * can be used for supplying alternate names for classes,
756
+	 * or for connecting interface names to instantiable classes
757
+	 */
758
+	protected function _register_core_aliases()
759
+	{
760
+		$this->_aliases = array(
761
+			'CommandBusInterface'                                                          => 'EventEspresso\core\services\commands\CommandBusInterface',
762
+			'EventEspresso\core\services\commands\CommandBusInterface'                     => 'EventEspresso\core\services\commands\CommandBus',
763
+			'CommandHandlerManagerInterface'                                               => 'EventEspresso\core\services\commands\CommandHandlerManagerInterface',
764
+			'EventEspresso\core\services\commands\CommandHandlerManagerInterface'          => 'EventEspresso\core\services\commands\CommandHandlerManager',
765
+			'CapChecker'                                                                   => 'EventEspresso\core\services\commands\middleware\CapChecker',
766
+			'AddActionHook'                                                                => 'EventEspresso\core\services\commands\middleware\AddActionHook',
767
+			'CapabilitiesChecker'                                                          => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
768
+			'CapabilitiesCheckerInterface'                                                 => 'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface',
769
+			'EventEspresso\core\domain\services\capabilities\CapabilitiesCheckerInterface' => 'EventEspresso\core\domain\services\capabilities\CapabilitiesChecker',
770
+			'CreateRegistrationService'                                                    => 'EventEspresso\core\domain\services\registration\CreateRegistrationService',
771
+			'CreateRegCodeCommandHandler'                                                  => 'EventEspresso\core\services\commands\registration\CreateRegCodeCommand',
772
+			'CreateRegUrlLinkCommandHandler'                                               => 'EventEspresso\core\services\commands\registration\CreateRegUrlLinkCommand',
773
+			'CreateRegistrationCommandHandler'                                             => 'EventEspresso\core\services\commands\registration\CreateRegistrationCommand',
774
+			'CopyRegistrationDetailsCommandHandler'                                        => 'EventEspresso\core\services\commands\registration\CopyRegistrationDetailsCommand',
775
+			'CopyRegistrationPaymentsCommandHandler'                                       => 'EventEspresso\core\services\commands\registration\CopyRegistrationPaymentsCommand',
776
+			'CancelRegistrationAndTicketLineItemCommandHandler'                            => 'EventEspresso\core\services\commands\registration\CancelRegistrationAndTicketLineItemCommandHandler',
777
+			'UpdateRegistrationAndTransactionAfterChangeCommandHandler'                    => 'EventEspresso\core\services\commands\registration\UpdateRegistrationAndTransactionAfterChangeCommandHandler',
778
+			'CreateTicketLineItemCommandHandler'                                           => 'EventEspresso\core\services\commands\ticket\CreateTicketLineItemCommand',
779
+			'CreateTransactionCommandHandler'                                     => 'EventEspresso\core\services\commands\transaction\CreateTransactionCommandHandler',
780
+			'CreateAttendeeCommandHandler'                                        => 'EventEspresso\core\services\commands\attendee\CreateAttendeeCommandHandler',
781
+			'TableManager'                                                                 => 'EventEspresso\core\services\database\TableManager',
782
+			'TableAnalysis'                                                                => 'EventEspresso\core\services\database\TableAnalysis',
783
+			'EspressoShortcode'                                                            => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
784
+			'ShortcodeInterface'                                                           => 'EventEspresso\core\services\shortcodes\ShortcodeInterface',
785
+			'EventEspresso\core\services\shortcodes\ShortcodeInterface'                    => 'EventEspresso\core\services\shortcodes\EspressoShortcode',
786
+			'EventEspresso\core\services\cache\CacheStorageInterface'                      => 'EventEspresso\core\services\cache\TransientCacheStorage',
787
+			'LoaderInterface'                                                              => 'EventEspresso\core\services\loaders\LoaderInterface',
788
+			'EventEspresso\core\services\loaders\LoaderInterface'                          => 'EventEspresso\core\services\loaders\Loader',
789
+			'CommandFactoryInterface'                                                     => 'EventEspresso\core\services\commands\CommandFactoryInterface',
790
+			'EventEspresso\core\services\commands\CommandFactoryInterface'                => 'EventEspresso\core\services\commands\CommandFactory',
791
+			'EventEspresso\core\domain\services\session\SessionIdentifierInterface'       => 'EE_Session',
792
+			'EmailValidatorInterface'                                                     => 'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface',
793
+			'EventEspresso\core\domain\services\validation\email\EmailValidatorInterface' => 'EventEspresso\core\domain\services\validation\email\EmailValidationService',
794
+			'NoticeConverterInterface'                                            => 'EventEspresso\core\services\notices\NoticeConverterInterface',
795
+			'EventEspresso\core\services\notices\NoticeConverterInterface'        => 'EventEspresso\core\services\notices\ConvertNoticesToEeErrors',
796
+			'NoticesContainerInterface'                                            => 'EventEspresso\core\services\notices\NoticesContainerInterface',
797
+			'EventEspresso\core\services\notices\NoticesContainerInterface'        => 'EventEspresso\core\services\notices\NoticesContainer',
798
+		);
799
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
800
+			$this->_aliases['EventEspresso\core\services\notices\NoticeConverterInterface'] = 'EventEspresso\core\services\notices\ConvertNoticesToAdminNotices';
801
+		}
802
+	}
803
+
804
+
805
+
806
+	/**
807
+	 * This is used to reset the internal map and class_loaders to their original default state at the beginning of the
808
+	 * request Primarily used by unit tests.
809
+	 *
810
+	 * @throws InvalidDataTypeException
811
+	 * @throws InvalidInterfaceException
812
+	 * @throws InvalidArgumentException
813
+	 */
814
+	public function reset()
815
+	{
816
+		$this->_register_core_class_loaders();
817
+		$this->_register_core_dependencies();
818
+	}
819 819
 
820 820
 
821 821
 }
Please login to merge, or discard this patch.
core/business/EE_Registration_Processor.class.php 2 patches
Indentation   +775 added lines, -775 removed lines patch added patch discarded remove patch
@@ -27,781 +27,781 @@
 block discarded – undo
27 27
 class EE_Registration_Processor extends EE_Processor_Base
28 28
 {
29 29
 
30
-    /**
31
-     * @var EE_Registration_Processor $_instance
32
-     * @access    private
33
-     */
34
-    private static $_instance;
35
-
36
-    /**
37
-     * initial reg status at the beginning of this request.
38
-     * indexed by registration ID
39
-     *
40
-     * @var array
41
-     */
42
-    protected $_old_reg_status = array();
43
-
44
-    /**
45
-     * reg status at the end of the request after all processing.
46
-     * indexed by registration ID
47
-     *
48
-     * @var array
49
-     */
50
-    protected $_new_reg_status = array();
51
-
52
-    /**
53
-     * amounts paid at the end of the request after all processing.
54
-     * indexed by registration ID
55
-     *
56
-     * @var array
57
-     */
58
-    protected static $_amount_paid = array();
59
-
60
-    /**
61
-     * Cache of the reg final price for registrations corresponding to a ticket line item
62
-     *
63
-     * @deprecated
64
-     * @var array @see EEH_Line_Item::calculate_reg_final_prices_per_line_item()'s return value
65
-     */
66
-    protected $_reg_final_price_per_tkt_line_item;
67
-
68
-    /**
69
-     * @var EE_Request $request
70
-     */
71
-    protected $request;
72
-
73
-
74
-
75
-    /**
76
-     * @singleton method used to instantiate class object
77
-     * @param EE_Request|null $request
78
-     * @return EE_Registration_Processor instance
79
-     * @throws \InvalidArgumentException
80
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
81
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
82
-     */
83
-    public static function instance(EE_Request $request = null)
84
-    {
85
-        // check if class object is instantiated
86
-        if (! self::$_instance instanceof EE_Registration_Processor) {
87
-            if(! $request instanceof EE_Request) {
88
-                $request = LoaderFactory::getLoader()->getShared('EE_Request');
89
-            }
90
-            self::$_instance = new self($request);
91
-        }
92
-        return self::$_instance;
93
-    }
94
-
95
-
96
-    /**
97
-     * EE_Registration_Processor constructor.
98
-     *
99
-     * @param EE_Request $request
100
-     */
101
-    public function __construct(EE_Request $request)
102
-    {
103
-        $this->request = $request;
104
-    }
105
-
106
-
107
-
108
-    /**
109
-     * @param int $REG_ID
110
-     * @return string
111
-     */
112
-    public function old_reg_status($REG_ID)
113
-    {
114
-        return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
115
-    }
116
-
117
-
118
-
119
-    /**
120
-     * @param int    $REG_ID
121
-     * @param string $old_reg_status
122
-     */
123
-    public function set_old_reg_status($REG_ID, $old_reg_status)
124
-    {
125
-        // only set the first time
126
-        if (! isset($this->_old_reg_status[$REG_ID])) {
127
-            $this->_old_reg_status[$REG_ID] = $old_reg_status;
128
-        }
129
-    }
130
-
131
-
132
-
133
-    /**
134
-     * @param int $REG_ID
135
-     * @return string
136
-     */
137
-    public function new_reg_status($REG_ID)
138
-    {
139
-        return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
140
-    }
141
-
142
-
143
-
144
-    /**
145
-     * @param int    $REG_ID
146
-     * @param string $new_reg_status
147
-     */
148
-    public function set_new_reg_status($REG_ID, $new_reg_status)
149
-    {
150
-        $this->_new_reg_status[$REG_ID] = $new_reg_status;
151
-    }
152
-
153
-
154
-
155
-    /**
156
-     * reg_status_updated
157
-     *
158
-     * @param int $REG_ID
159
-     * @return bool
160
-     */
161
-    public function reg_status_updated($REG_ID)
162
-    {
163
-        return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID);
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     * @param EE_Registration $registration
170
-     * @throws EE_Error
171
-     * @throws EntityNotFoundException
172
-     * @throws InvalidArgumentException
173
-     * @throws InvalidDataTypeException
174
-     * @throws InvalidInterfaceException
175
-     * @throws ReflectionException
176
-     * @throws RuntimeException
177
-     */
178
-    public function update_registration_status_and_trigger_notifications(EE_Registration $registration)
179
-    {
180
-        $this->toggle_incomplete_registration_status_to_default($registration, false);
181
-        $this->toggle_registration_status_for_default_approved_events($registration, false);
182
-        $this->toggle_registration_status_if_no_monies_owing($registration, false);
183
-        $registration->save();
184
-        // trigger notifications
185
-        $this->trigger_registration_update_notifications($registration);
186
-    }
187
-
188
-
189
-
190
-    /**
191
-     *    manually_update_registration_status
192
-     *
193
-     * @access public
194
-     * @param EE_Registration $registration
195
-     * @param string          $new_reg_status
196
-     * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
197
-     *                              to client code
198
-     * @return bool
199
-     * @throws EE_Error
200
-     * @throws EntityNotFoundException
201
-     * @throws InvalidArgumentException
202
-     * @throws InvalidDataTypeException
203
-     * @throws InvalidInterfaceException
204
-     * @throws ReflectionException
205
-     * @throws RuntimeException
206
-     */
207
-    public function manually_update_registration_status(
208
-        EE_Registration $registration,
209
-        $new_reg_status = '',
210
-        $save = true
211
-    ) {
212
-        // set initial REG_Status
213
-        $this->set_old_reg_status($registration->ID(), $registration->status_ID());
214
-        // set incoming REG_Status
215
-        $this->set_new_reg_status($registration->ID(), $new_reg_status);
216
-        // toggle reg status but only if it has changed and the user can do so
217
-        if (
218
-            $this->reg_status_updated($registration->ID())
219
-            && (
220
-                (! $this->request->isAdmin() || $this->request->isFrontAjax())
221
-                || EE_Registry::instance()->CAP->current_user_can(
222
-                    'ee_edit_registration',
223
-                    'toggle_registration_status',
224
-                    $registration->ID()
225
-                )
226
-            )
227
-        ) {
228
-            // change status to new value
229
-            $updated = $registration->set_status($this->new_reg_status($registration->ID()));
230
-            if ($updated && $save) {
231
-                $registration->save();
232
-            }
233
-            return true;
234
-        }
235
-        return false;
236
-    }
237
-
238
-
239
-
240
-    /**
241
-     *    toggle_incomplete_registration_status_to_default
242
-     *        changes any incomplete registrations to either the event or global default registration status
243
-     *
244
-     * @access public
245
-     * @param EE_Registration $registration
246
-     * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
247
-     *                              to client code
248
-     * @param Context|null    $context
249
-     * @return void
250
-     * @throws EE_Error
251
-     * @throws InvalidArgumentException
252
-     * @throws ReflectionException
253
-     * @throws RuntimeException
254
-     * @throws EntityNotFoundException
255
-     * @throws InvalidDataTypeException
256
-     * @throws InvalidInterfaceException
257
-     */
258
-    public function toggle_incomplete_registration_status_to_default(
259
-        EE_Registration $registration,
260
-        $save = true,
261
-        Context $context = null
262
-    ) {
263
-        $existing_reg_status = $registration->status_ID();
264
-        // set initial REG_Status
265
-        $this->set_old_reg_status($registration->ID(), $existing_reg_status);
266
-        // is the registration currently incomplete ?
267
-        if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
268
-            // grab default reg status for the event, if set
269
-            $event_default_registration_status = $registration->event()->default_registration_status();
270
-            // if no default reg status is set for the event, then use the global value
271
-            $STS_ID = ! empty($event_default_registration_status)
272
-                ? $event_default_registration_status
273
-                : EE_Registry::instance()->CFG->registration->default_STS_ID;
274
-            // if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
275
-            $STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment
276
-                : $STS_ID;
277
-            // set incoming REG_Status
278
-            $this->set_new_reg_status($registration->ID(), $STS_ID);
279
-            $registration->set_status($STS_ID, false, $context);
280
-            if ($save) {
281
-                $registration->save();
282
-            }
283
-            // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
284
-            if (! EE_Processor_Base::$IPN) {
285
-                // otherwise, send out notifications
286
-                add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
287
-            }
288
-            // DEBUG LOG
289
-            //$this->log(
290
-            //	__CLASS__, __FUNCTION__, __LINE__,
291
-            //	$registration->transaction(),
292
-            //	array(
293
-            //		'IPN'                   => EE_Processor_Base::$IPN,
294
-            //		'deliver_notifications' => has_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ),
295
-            //	)
296
-            //);
297
-        }
298
-    }
299
-
300
-
301
-
302
-    /**
303
-     *    toggle_registration_status_for_default_approved_events
304
-     *
305
-     * @access public
306
-     * @param EE_Registration $registration
307
-     * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
308
-     *                              to client code
309
-     * @return bool
310
-     * @throws EE_Error
311
-     * @throws EntityNotFoundException
312
-     * @throws InvalidArgumentException
313
-     * @throws InvalidDataTypeException
314
-     * @throws InvalidInterfaceException
315
-     * @throws ReflectionException
316
-     * @throws RuntimeException
317
-     */
318
-    public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = true)
319
-    {
320
-        $reg_status = $registration->status_ID();
321
-        // set initial REG_Status
322
-        $this->set_old_reg_status($registration->ID(), $reg_status);
323
-        // if not already, toggle reg status to approved IF the event default reg status is approved
324
-        // ( as long as the registration wasn't cancelled or declined at some point )
325
-        if (
326
-            $reg_status !== EEM_Registration::status_id_cancelled
327
-            && $reg_status
328
-               !== EEM_Registration::status_id_declined
329
-            && $reg_status !== EEM_Registration::status_id_approved
330
-            && $registration->event()->default_registration_status() === EEM_Registration::status_id_approved
331
-        ) {
332
-            // set incoming REG_Status
333
-            $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
334
-            // toggle status to approved
335
-            $registration->set_status(EEM_Registration::status_id_approved);
336
-            if ($save) {
337
-                $registration->save();
338
-            }
339
-            // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
340
-            if (! EE_Processor_Base::$IPN) {
341
-                // otherwise, send out notifications
342
-                add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
343
-            }
344
-            // DEBUG LOG
345
-            //$this->log(
346
-            //	__CLASS__, __FUNCTION__, __LINE__,
347
-            //	$registration->transaction(),
348
-            //	array(
349
-            //		'IPN'                   => EE_Processor_Base::$IPN,
350
-            //		'deliver_notifications' => has_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ),
351
-            //	)
352
-            //);
353
-            return true;
354
-        }
355
-        return false;
356
-    }
357
-
358
-
359
-
360
-    /**
361
-     *    toggle_registration_statuses_if_no_monies_owing
362
-     *
363
-     * @access public
364
-     * @param EE_Registration $registration
365
-     * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
366
-     *                              to client code
367
-     * @param array           $additional_details
368
-     * @return bool
369
-     * @throws EE_Error
370
-     * @throws EntityNotFoundException
371
-     * @throws InvalidArgumentException
372
-     * @throws InvalidDataTypeException
373
-     * @throws InvalidInterfaceException
374
-     * @throws ReflectionException
375
-     * @throws RuntimeException
376
-     */
377
-    public function toggle_registration_status_if_no_monies_owing(
378
-        EE_Registration $registration,
379
-        $save = true,
380
-        array $additional_details = array()
381
-    ) {
382
-        // set initial REG_Status
383
-        $this->set_old_reg_status($registration->ID(), $registration->status_ID());
384
-        // was a payment just made ?
385
-        $payment    = isset($additional_details['payment_updates'], $additional_details['last_payment'])
386
-                      && $additional_details['payment_updates']
387
-                      && $additional_details['last_payment'] instanceof EE_Payment
388
-            ? $additional_details['last_payment']
389
-            : null;
390
-        $total_paid = array_sum(self::$_amount_paid);
391
-        // toggle reg status to approved IF
392
-        if (
393
-            // REG status is pending payment
394
-            $registration->status_ID() === EEM_Registration::status_id_pending_payment
395
-            // AND no monies are owing
396
-            && (
397
-                (
398
-                    $registration->transaction()->is_completed()
399
-                    || $registration->transaction()->is_overpaid()
400
-                    || $registration->transaction()->is_free()
401
-                    || apply_filters(
402
-                        'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing',
403
-                        false,
404
-                        $registration
405
-                    )
406
-                )
407
-                || (
408
-                    $payment instanceof EE_Payment && $payment->is_approved()
409
-                    && // this specific registration has not yet been paid for
410
-                    ! isset(self::$_amount_paid[$registration->ID()])
411
-                    && // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
412
-                    $payment->amount() - $total_paid >= $registration->final_price()
413
-                )
414
-            )
415
-        ) {
416
-            // mark as paid
417
-            self::$_amount_paid[$registration->ID()] = $registration->final_price();
418
-            // track new REG_Status
419
-            $this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
420
-            // toggle status to approved
421
-            $registration->set_status(EEM_Registration::status_id_approved);
422
-            if ($save) {
423
-                $registration->save();
424
-            }
425
-            // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
426
-            if (! EE_Processor_Base::$IPN) {
427
-                // otherwise, send out notifications
428
-                add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
429
-            }
430
-            // DEBUG LOG
431
-            //$this->log(
432
-            //	__CLASS__, __FUNCTION__, __LINE__,
433
-            //	$registration->transaction(),
434
-            //	array(
435
-            //		'IPN'                   => EE_Processor_Base::$IPN,
436
-            //		'deliver_notifications' => has_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ),
437
-            //	)
438
-            //);
439
-            return true;
440
-        }
441
-        return false;
442
-    }
443
-
444
-
445
-
446
-    /**
447
-     *    registration_status_changed
448
-     *
449
-     * @access public
450
-     * @param EE_Registration $registration
451
-     * @param array           $additional_details
452
-     * @return void
453
-     */
454
-    public function trigger_registration_update_notifications($registration, array $additional_details = array())
455
-    {
456
-        try {
457
-            if (! $registration instanceof EE_Registration) {
458
-                throw new EE_Error(
459
-                    esc_html__('An invalid registration was received.', 'event_espresso')
460
-                );
461
-            }
462
-            // EE_Registry::instance()->load_helper( 'Debug_Tools' );
463
-            // EEH_Debug_Tools::log(
464
-            // 	__CLASS__,
465
-            // 	__FUNCTION__,
466
-            // 	__LINE__,
467
-            // 	array( $registration->transaction(), $additional_details ),
468
-            // 	false,
469
-            // 	'EE_Transaction: ' . $registration->transaction()->ID()
470
-            // );
471
-            if (! $registration->is_primary_registrant()) {
472
-                return;
473
-            }
474
-            do_action(
475
-                'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
476
-                $registration,
477
-                $additional_details
478
-            );
479
-        } catch (Exception $e) {
480
-            EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
481
-        }
482
-    }
483
-
484
-
485
-
486
-    /**
487
-     * sets reg status based either on passed param or on transaction status and event pre-approval setting
488
-     *
489
-     * @param EE_Registration $registration
490
-     * @param array           $additional_details
491
-     * @return bool
492
-     * @throws EE_Error
493
-     * @throws EntityNotFoundException
494
-     * @throws InvalidArgumentException
495
-     * @throws InvalidDataTypeException
496
-     * @throws InvalidInterfaceException
497
-     * @throws ReflectionException
498
-     * @throws RuntimeException
499
-     */
500
-    public function update_registration_after_checkout_or_payment(
501
-        EE_Registration $registration,
502
-        array $additional_details = array()
503
-    ) {
504
-        // set initial REG_Status
505
-        $this->set_old_reg_status($registration->ID(), $registration->status_ID());
506
-        // if the registration status gets updated, then save the registration
507
-        if (
508
-            $this->toggle_registration_status_for_default_approved_events($registration, false)
509
-            || $this->toggle_registration_status_if_no_monies_owing(
510
-                $registration,
511
-                false,
512
-                $additional_details
513
-            )
514
-        ) {
515
-            $registration->save();
516
-        }
517
-        // set new  REG_Status
518
-        $this->set_new_reg_status($registration->ID(), $registration->status_ID());
519
-        return $this->reg_status_updated($registration->ID())
520
-               && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved;
521
-    }
522
-
523
-
524
-
525
-    /**
526
-     * Updates the registration' final prices based on the current line item tree (taking into account
527
-     * discounts, taxes, and other line items unrelated to tickets.)
528
-     *
529
-     * @param EE_Transaction $transaction
530
-     * @param boolean        $save_regs whether to immediately save registrations in this function or not
531
-     * @return void
532
-     * @throws EE_Error
533
-     * @throws InvalidArgumentException
534
-     * @throws InvalidDataTypeException
535
-     * @throws InvalidInterfaceException
536
-     * @throws RuntimeException
537
-     */
538
-    public function update_registration_final_prices($transaction, $save_regs = true)
539
-    {
540
-        $reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item(
541
-            $transaction->total_line_item()
542
-        );
543
-        foreach ($transaction->registrations() as $registration) {
544
-            /** @var EE_Line_Item $line_item */
545
-            $line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
546
-            if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
547
-                $registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
548
-                if ($save_regs) {
549
-                    $registration->save();
550
-                }
551
-            }
552
-        }
553
-        //and make sure there's no rounding problem
554
-        $this->fix_reg_final_price_rounding_issue($transaction);
555
-    }
556
-
557
-
558
-
559
-    /**
560
-     * Makes sure there is no rounding errors for the REG_final_prices.
561
-     * Eg, if we have 3 registrations for $1, and there is a $0.01 discount between the three of them,
562
-     * they will each be for $0.99333333, which gets rounded to $1 again.
563
-     * So the transaction total will be $2.99, but each registration will be for $1,
564
-     * so if each registrant paid individually they will have overpaid by $0.01.
565
-     * So in order to overcome this, we check for any difference, and if there is a difference
566
-     * we just grab one registrant at random and make them responsible for it.
567
-     * This should be used after setting REG_final_prices (it's done automatically as part of
568
-     * EE_Registration_Processor::update_registration_final_prices())
569
-     *
570
-     * @param EE_Transaction $transaction
571
-     * @return bool success verifying that there is NO difference after this method is done
572
-     * @throws EE_Error
573
-     * @throws InvalidArgumentException
574
-     * @throws InvalidDataTypeException
575
-     * @throws InvalidInterfaceException
576
-     */
577
-    public function fix_reg_final_price_rounding_issue($transaction)
578
-    {
579
-        $reg_final_price_sum = EEM_Registration::instance()->sum(
580
-            array(
581
-                array(
582
-                    'TXN_ID' => $transaction->ID(),
583
-                ),
584
-            ),
585
-            'REG_final_price'
586
-        );
587
-        $diff = $transaction->total() - $reg_final_price_sum;
588
-        //ok then, just grab one of the registrations
589
-        if ($diff !== 0) {
590
-            $a_reg   = EEM_Registration::instance()->get_one(
591
-                array(
592
-                    array(
593
-                        'TXN_ID' => $transaction->ID(),
594
-                    ),
595
-                )
596
-            );
597
-            return $a_reg instanceof EE_Registration
598
-                ? (bool) $a_reg->save(array('REG_final_price' => $a_reg->final_price() + $diff))
599
-                : false;
600
-        }
601
-        return true;
602
-    }
603
-
604
-
605
-
606
-    /**
607
-     * update_registration_after_being_canceled_or_declined
608
-     *
609
-     * @param EE_Registration $registration
610
-     * @param array           $closed_reg_statuses
611
-     * @param bool            $update_reg
612
-     * @return bool
613
-     * @throws EE_Error
614
-     * @throws RuntimeException
615
-     */
616
-    public function update_registration_after_being_canceled_or_declined(
617
-        EE_Registration $registration,
618
-        array $closed_reg_statuses = array(),
619
-        $update_reg = true
620
-    ) {
621
-        // these reg statuses should not be considered in any calculations involving monies owing
622
-        $closed_reg_statuses = ! empty($closed_reg_statuses)
623
-            ? $closed_reg_statuses
624
-            : EEM_Registration::closed_reg_statuses();
625
-        if (! in_array($registration->status_ID(), $closed_reg_statuses, true)) {
626
-            return false;
627
-        }
628
-        // release a reserved ticket by decrementing ticket and datetime reserved values
629
-        $registration->release_reserved_ticket(true);
630
-        $registration->set_final_price(0);
631
-        if ($update_reg) {
632
-            $registration->save();
633
-        }
634
-        return true;
635
-    }
636
-
637
-
638
-
639
-    /**
640
-     * update_canceled_or_declined_registration_after_being_reinstated
641
-     *
642
-     * @param EE_Registration $registration
643
-     * @param array           $closed_reg_statuses
644
-     * @param bool            $update_reg
645
-     * @return bool
646
-     * @throws EE_Error
647
-     * @throws RuntimeException
648
-     */
649
-    public function update_canceled_or_declined_registration_after_being_reinstated(
650
-        EE_Registration $registration,
651
-        array $closed_reg_statuses = array(),
652
-        $update_reg = true
653
-    ) {
654
-        // these reg statuses should not be considered in any calculations involving monies owing
655
-        $closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses
656
-            : EEM_Registration::closed_reg_statuses();
657
-        if (in_array($registration->status_ID(), $closed_reg_statuses, true)) {
658
-            return false;
659
-        }
660
-        $ticket = $registration->ticket();
661
-        if (! $ticket instanceof EE_Ticket) {
662
-            throw new EE_Error(
663
-                sprintf(
664
-                    esc_html__(
665
-                        'The Ticket for Registration %1$d was not found or is invalid.',
666
-                        'event_espresso'
667
-                    ),
668
-                    $registration->ticket_ID()
669
-                )
670
-            );
671
-        }
672
-        $registration->set_final_price($ticket->price());
673
-        if ($update_reg) {
674
-            $registration->save();
675
-        }
676
-        return true;
677
-    }
678
-
679
-
680
-
681
-    /**
682
-     * generate_ONE_registration_from_line_item
683
-     * Although a ticket line item may have a quantity greater than 1,
684
-     * this method will ONLY CREATE ONE REGISTRATION !!!
685
-     * Regardless of the ticket line item quantity.
686
-     * This means that any code calling this method is responsible for ensuring
687
-     * that the final registration count matches the ticket line item quantity.
688
-     * This was done to make it easier to match the number of registrations
689
-     * to the number of tickets in the cart, when the cart has been edited
690
-     * after SPCO has already been initialized. So if an additional ticket was added to the cart, you can simply pass
691
-     * the line item to this method to add a second ticket, and in this case, you would not want to add 2 tickets.
692
-     *
693
-     * @deprecated
694
-     * @since 4.9.1
695
-     * @param EE_Line_Item    $line_item
696
-     * @param \EE_Transaction $transaction
697
-     * @param int             $att_nmbr
698
-     * @param int             $total_ticket_count
699
-     * @return EE_Registration | null
700
-     * @throws \OutOfRangeException
701
-     * @throws \EventEspresso\core\exceptions\UnexpectedEntityException
702
-     * @throws \EE_Error
703
-     */
704
-    public function generate_ONE_registration_from_line_item(
705
-        EE_Line_Item $line_item,
706
-        EE_Transaction $transaction,
707
-        $att_nmbr = 1,
708
-        $total_ticket_count = 1
709
-    ) {
710
-        EE_Error::doing_it_wrong(
711
-            __CLASS__ . '::' . __FUNCTION__,
712
-            sprintf(
713
-                esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
714
-                '\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'
715
-            ),
716
-            '4.9.1',
717
-            '5.0.0'
718
-        );
719
-        // grab the related ticket object for this line_item
720
-        $ticket = $line_item->ticket();
721
-        if (! $ticket instanceof EE_Ticket) {
722
-            EE_Error::add_error(
723
-                sprintf(
724
-                    esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
725
-                    $line_item->ID()
726
-                ),
727
-                __FILE__,
728
-                __FUNCTION__,
729
-                __LINE__
730
-            );
731
-            return null;
732
-        }
733
-        $registration_service = new CreateRegistrationService();
734
-        // then generate a new registration from that
735
-        return $registration_service->create(
736
-            $ticket->get_related_event(),
737
-            $transaction,
738
-            $ticket,
739
-            $line_item,
740
-            $att_nmbr,
741
-            $total_ticket_count
742
-        );
743
-    }
744
-
745
-
746
-
747
-    /**
748
-     * generates reg_url_link
749
-     *
750
-     * @deprecated
751
-     * @since 4.9.1
752
-     * @param int                   $att_nmbr
753
-     * @param EE_Line_Item | string $item
754
-     * @return string
755
-     * @throws InvalidArgumentException
756
-     */
757
-    public function generate_reg_url_link($att_nmbr, $item)
758
-    {
759
-        EE_Error::doing_it_wrong(
760
-            __CLASS__ . '::' . __FUNCTION__,
761
-            sprintf(
762
-                esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
763
-                'EventEspresso\core\domain\entities\RegUrlLink'
764
-            ),
765
-            '4.9.1',
766
-            '5.0.0'
767
-        );
768
-        return new RegUrlLink($att_nmbr, $item);
769
-    }
770
-
771
-
772
-
773
-    /**
774
-     * generates reg code
775
-     *
776
-     * @deprecated
777
-     * @since 4.9.1
778
-     * @param EE_Registration $registration
779
-     * @return string
780
-     * @throws EE_Error
781
-     * @throws EntityNotFoundException
782
-     * @throws InvalidArgumentException
783
-     */
784
-    public function generate_reg_code(EE_Registration $registration)
785
-    {
786
-        EE_Error::doing_it_wrong(
787
-            __CLASS__ . '::' . __FUNCTION__,
788
-            sprintf(
789
-                esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
790
-                'EventEspresso\core\domain\entities\RegCode'
791
-            ),
792
-            '4.9.1',
793
-            '5.0.0'
794
-        );
795
-        return apply_filters(
796
-            'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code',
797
-            new RegCode(
798
-                RegUrlLink::fromRegistration($registration),
799
-                $registration->transaction(),
800
-                $registration->ticket()
801
-            ),
802
-            $registration
803
-        );
804
-    }
30
+	/**
31
+	 * @var EE_Registration_Processor $_instance
32
+	 * @access    private
33
+	 */
34
+	private static $_instance;
35
+
36
+	/**
37
+	 * initial reg status at the beginning of this request.
38
+	 * indexed by registration ID
39
+	 *
40
+	 * @var array
41
+	 */
42
+	protected $_old_reg_status = array();
43
+
44
+	/**
45
+	 * reg status at the end of the request after all processing.
46
+	 * indexed by registration ID
47
+	 *
48
+	 * @var array
49
+	 */
50
+	protected $_new_reg_status = array();
51
+
52
+	/**
53
+	 * amounts paid at the end of the request after all processing.
54
+	 * indexed by registration ID
55
+	 *
56
+	 * @var array
57
+	 */
58
+	protected static $_amount_paid = array();
59
+
60
+	/**
61
+	 * Cache of the reg final price for registrations corresponding to a ticket line item
62
+	 *
63
+	 * @deprecated
64
+	 * @var array @see EEH_Line_Item::calculate_reg_final_prices_per_line_item()'s return value
65
+	 */
66
+	protected $_reg_final_price_per_tkt_line_item;
67
+
68
+	/**
69
+	 * @var EE_Request $request
70
+	 */
71
+	protected $request;
72
+
73
+
74
+
75
+	/**
76
+	 * @singleton method used to instantiate class object
77
+	 * @param EE_Request|null $request
78
+	 * @return EE_Registration_Processor instance
79
+	 * @throws \InvalidArgumentException
80
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
81
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
82
+	 */
83
+	public static function instance(EE_Request $request = null)
84
+	{
85
+		// check if class object is instantiated
86
+		if (! self::$_instance instanceof EE_Registration_Processor) {
87
+			if(! $request instanceof EE_Request) {
88
+				$request = LoaderFactory::getLoader()->getShared('EE_Request');
89
+			}
90
+			self::$_instance = new self($request);
91
+		}
92
+		return self::$_instance;
93
+	}
94
+
95
+
96
+	/**
97
+	 * EE_Registration_Processor constructor.
98
+	 *
99
+	 * @param EE_Request $request
100
+	 */
101
+	public function __construct(EE_Request $request)
102
+	{
103
+		$this->request = $request;
104
+	}
105
+
106
+
107
+
108
+	/**
109
+	 * @param int $REG_ID
110
+	 * @return string
111
+	 */
112
+	public function old_reg_status($REG_ID)
113
+	{
114
+		return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
115
+	}
116
+
117
+
118
+
119
+	/**
120
+	 * @param int    $REG_ID
121
+	 * @param string $old_reg_status
122
+	 */
123
+	public function set_old_reg_status($REG_ID, $old_reg_status)
124
+	{
125
+		// only set the first time
126
+		if (! isset($this->_old_reg_status[$REG_ID])) {
127
+			$this->_old_reg_status[$REG_ID] = $old_reg_status;
128
+		}
129
+	}
130
+
131
+
132
+
133
+	/**
134
+	 * @param int $REG_ID
135
+	 * @return string
136
+	 */
137
+	public function new_reg_status($REG_ID)
138
+	{
139
+		return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
140
+	}
141
+
142
+
143
+
144
+	/**
145
+	 * @param int    $REG_ID
146
+	 * @param string $new_reg_status
147
+	 */
148
+	public function set_new_reg_status($REG_ID, $new_reg_status)
149
+	{
150
+		$this->_new_reg_status[$REG_ID] = $new_reg_status;
151
+	}
152
+
153
+
154
+
155
+	/**
156
+	 * reg_status_updated
157
+	 *
158
+	 * @param int $REG_ID
159
+	 * @return bool
160
+	 */
161
+	public function reg_status_updated($REG_ID)
162
+	{
163
+		return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID);
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 * @param EE_Registration $registration
170
+	 * @throws EE_Error
171
+	 * @throws EntityNotFoundException
172
+	 * @throws InvalidArgumentException
173
+	 * @throws InvalidDataTypeException
174
+	 * @throws InvalidInterfaceException
175
+	 * @throws ReflectionException
176
+	 * @throws RuntimeException
177
+	 */
178
+	public function update_registration_status_and_trigger_notifications(EE_Registration $registration)
179
+	{
180
+		$this->toggle_incomplete_registration_status_to_default($registration, false);
181
+		$this->toggle_registration_status_for_default_approved_events($registration, false);
182
+		$this->toggle_registration_status_if_no_monies_owing($registration, false);
183
+		$registration->save();
184
+		// trigger notifications
185
+		$this->trigger_registration_update_notifications($registration);
186
+	}
187
+
188
+
189
+
190
+	/**
191
+	 *    manually_update_registration_status
192
+	 *
193
+	 * @access public
194
+	 * @param EE_Registration $registration
195
+	 * @param string          $new_reg_status
196
+	 * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
197
+	 *                              to client code
198
+	 * @return bool
199
+	 * @throws EE_Error
200
+	 * @throws EntityNotFoundException
201
+	 * @throws InvalidArgumentException
202
+	 * @throws InvalidDataTypeException
203
+	 * @throws InvalidInterfaceException
204
+	 * @throws ReflectionException
205
+	 * @throws RuntimeException
206
+	 */
207
+	public function manually_update_registration_status(
208
+		EE_Registration $registration,
209
+		$new_reg_status = '',
210
+		$save = true
211
+	) {
212
+		// set initial REG_Status
213
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
214
+		// set incoming REG_Status
215
+		$this->set_new_reg_status($registration->ID(), $new_reg_status);
216
+		// toggle reg status but only if it has changed and the user can do so
217
+		if (
218
+			$this->reg_status_updated($registration->ID())
219
+			&& (
220
+				(! $this->request->isAdmin() || $this->request->isFrontAjax())
221
+				|| EE_Registry::instance()->CAP->current_user_can(
222
+					'ee_edit_registration',
223
+					'toggle_registration_status',
224
+					$registration->ID()
225
+				)
226
+			)
227
+		) {
228
+			// change status to new value
229
+			$updated = $registration->set_status($this->new_reg_status($registration->ID()));
230
+			if ($updated && $save) {
231
+				$registration->save();
232
+			}
233
+			return true;
234
+		}
235
+		return false;
236
+	}
237
+
238
+
239
+
240
+	/**
241
+	 *    toggle_incomplete_registration_status_to_default
242
+	 *        changes any incomplete registrations to either the event or global default registration status
243
+	 *
244
+	 * @access public
245
+	 * @param EE_Registration $registration
246
+	 * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
247
+	 *                              to client code
248
+	 * @param Context|null    $context
249
+	 * @return void
250
+	 * @throws EE_Error
251
+	 * @throws InvalidArgumentException
252
+	 * @throws ReflectionException
253
+	 * @throws RuntimeException
254
+	 * @throws EntityNotFoundException
255
+	 * @throws InvalidDataTypeException
256
+	 * @throws InvalidInterfaceException
257
+	 */
258
+	public function toggle_incomplete_registration_status_to_default(
259
+		EE_Registration $registration,
260
+		$save = true,
261
+		Context $context = null
262
+	) {
263
+		$existing_reg_status = $registration->status_ID();
264
+		// set initial REG_Status
265
+		$this->set_old_reg_status($registration->ID(), $existing_reg_status);
266
+		// is the registration currently incomplete ?
267
+		if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
268
+			// grab default reg status for the event, if set
269
+			$event_default_registration_status = $registration->event()->default_registration_status();
270
+			// if no default reg status is set for the event, then use the global value
271
+			$STS_ID = ! empty($event_default_registration_status)
272
+				? $event_default_registration_status
273
+				: EE_Registry::instance()->CFG->registration->default_STS_ID;
274
+			// if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
275
+			$STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment
276
+				: $STS_ID;
277
+			// set incoming REG_Status
278
+			$this->set_new_reg_status($registration->ID(), $STS_ID);
279
+			$registration->set_status($STS_ID, false, $context);
280
+			if ($save) {
281
+				$registration->save();
282
+			}
283
+			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
284
+			if (! EE_Processor_Base::$IPN) {
285
+				// otherwise, send out notifications
286
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
287
+			}
288
+			// DEBUG LOG
289
+			//$this->log(
290
+			//	__CLASS__, __FUNCTION__, __LINE__,
291
+			//	$registration->transaction(),
292
+			//	array(
293
+			//		'IPN'                   => EE_Processor_Base::$IPN,
294
+			//		'deliver_notifications' => has_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ),
295
+			//	)
296
+			//);
297
+		}
298
+	}
299
+
300
+
301
+
302
+	/**
303
+	 *    toggle_registration_status_for_default_approved_events
304
+	 *
305
+	 * @access public
306
+	 * @param EE_Registration $registration
307
+	 * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
308
+	 *                              to client code
309
+	 * @return bool
310
+	 * @throws EE_Error
311
+	 * @throws EntityNotFoundException
312
+	 * @throws InvalidArgumentException
313
+	 * @throws InvalidDataTypeException
314
+	 * @throws InvalidInterfaceException
315
+	 * @throws ReflectionException
316
+	 * @throws RuntimeException
317
+	 */
318
+	public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = true)
319
+	{
320
+		$reg_status = $registration->status_ID();
321
+		// set initial REG_Status
322
+		$this->set_old_reg_status($registration->ID(), $reg_status);
323
+		// if not already, toggle reg status to approved IF the event default reg status is approved
324
+		// ( as long as the registration wasn't cancelled or declined at some point )
325
+		if (
326
+			$reg_status !== EEM_Registration::status_id_cancelled
327
+			&& $reg_status
328
+			   !== EEM_Registration::status_id_declined
329
+			&& $reg_status !== EEM_Registration::status_id_approved
330
+			&& $registration->event()->default_registration_status() === EEM_Registration::status_id_approved
331
+		) {
332
+			// set incoming REG_Status
333
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
334
+			// toggle status to approved
335
+			$registration->set_status(EEM_Registration::status_id_approved);
336
+			if ($save) {
337
+				$registration->save();
338
+			}
339
+			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
340
+			if (! EE_Processor_Base::$IPN) {
341
+				// otherwise, send out notifications
342
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
343
+			}
344
+			// DEBUG LOG
345
+			//$this->log(
346
+			//	__CLASS__, __FUNCTION__, __LINE__,
347
+			//	$registration->transaction(),
348
+			//	array(
349
+			//		'IPN'                   => EE_Processor_Base::$IPN,
350
+			//		'deliver_notifications' => has_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ),
351
+			//	)
352
+			//);
353
+			return true;
354
+		}
355
+		return false;
356
+	}
357
+
358
+
359
+
360
+	/**
361
+	 *    toggle_registration_statuses_if_no_monies_owing
362
+	 *
363
+	 * @access public
364
+	 * @param EE_Registration $registration
365
+	 * @param bool            $save TRUE will save the registration if the status is updated, FALSE will leave that up
366
+	 *                              to client code
367
+	 * @param array           $additional_details
368
+	 * @return bool
369
+	 * @throws EE_Error
370
+	 * @throws EntityNotFoundException
371
+	 * @throws InvalidArgumentException
372
+	 * @throws InvalidDataTypeException
373
+	 * @throws InvalidInterfaceException
374
+	 * @throws ReflectionException
375
+	 * @throws RuntimeException
376
+	 */
377
+	public function toggle_registration_status_if_no_monies_owing(
378
+		EE_Registration $registration,
379
+		$save = true,
380
+		array $additional_details = array()
381
+	) {
382
+		// set initial REG_Status
383
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
384
+		// was a payment just made ?
385
+		$payment    = isset($additional_details['payment_updates'], $additional_details['last_payment'])
386
+					  && $additional_details['payment_updates']
387
+					  && $additional_details['last_payment'] instanceof EE_Payment
388
+			? $additional_details['last_payment']
389
+			: null;
390
+		$total_paid = array_sum(self::$_amount_paid);
391
+		// toggle reg status to approved IF
392
+		if (
393
+			// REG status is pending payment
394
+			$registration->status_ID() === EEM_Registration::status_id_pending_payment
395
+			// AND no monies are owing
396
+			&& (
397
+				(
398
+					$registration->transaction()->is_completed()
399
+					|| $registration->transaction()->is_overpaid()
400
+					|| $registration->transaction()->is_free()
401
+					|| apply_filters(
402
+						'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing',
403
+						false,
404
+						$registration
405
+					)
406
+				)
407
+				|| (
408
+					$payment instanceof EE_Payment && $payment->is_approved()
409
+					&& // this specific registration has not yet been paid for
410
+					! isset(self::$_amount_paid[$registration->ID()])
411
+					&& // payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
412
+					$payment->amount() - $total_paid >= $registration->final_price()
413
+				)
414
+			)
415
+		) {
416
+			// mark as paid
417
+			self::$_amount_paid[$registration->ID()] = $registration->final_price();
418
+			// track new REG_Status
419
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
420
+			// toggle status to approved
421
+			$registration->set_status(EEM_Registration::status_id_approved);
422
+			if ($save) {
423
+				$registration->save();
424
+			}
425
+			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
426
+			if (! EE_Processor_Base::$IPN) {
427
+				// otherwise, send out notifications
428
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
429
+			}
430
+			// DEBUG LOG
431
+			//$this->log(
432
+			//	__CLASS__, __FUNCTION__, __LINE__,
433
+			//	$registration->transaction(),
434
+			//	array(
435
+			//		'IPN'                   => EE_Processor_Base::$IPN,
436
+			//		'deliver_notifications' => has_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications' ),
437
+			//	)
438
+			//);
439
+			return true;
440
+		}
441
+		return false;
442
+	}
443
+
444
+
445
+
446
+	/**
447
+	 *    registration_status_changed
448
+	 *
449
+	 * @access public
450
+	 * @param EE_Registration $registration
451
+	 * @param array           $additional_details
452
+	 * @return void
453
+	 */
454
+	public function trigger_registration_update_notifications($registration, array $additional_details = array())
455
+	{
456
+		try {
457
+			if (! $registration instanceof EE_Registration) {
458
+				throw new EE_Error(
459
+					esc_html__('An invalid registration was received.', 'event_espresso')
460
+				);
461
+			}
462
+			// EE_Registry::instance()->load_helper( 'Debug_Tools' );
463
+			// EEH_Debug_Tools::log(
464
+			// 	__CLASS__,
465
+			// 	__FUNCTION__,
466
+			// 	__LINE__,
467
+			// 	array( $registration->transaction(), $additional_details ),
468
+			// 	false,
469
+			// 	'EE_Transaction: ' . $registration->transaction()->ID()
470
+			// );
471
+			if (! $registration->is_primary_registrant()) {
472
+				return;
473
+			}
474
+			do_action(
475
+				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
476
+				$registration,
477
+				$additional_details
478
+			);
479
+		} catch (Exception $e) {
480
+			EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
481
+		}
482
+	}
483
+
484
+
485
+
486
+	/**
487
+	 * sets reg status based either on passed param or on transaction status and event pre-approval setting
488
+	 *
489
+	 * @param EE_Registration $registration
490
+	 * @param array           $additional_details
491
+	 * @return bool
492
+	 * @throws EE_Error
493
+	 * @throws EntityNotFoundException
494
+	 * @throws InvalidArgumentException
495
+	 * @throws InvalidDataTypeException
496
+	 * @throws InvalidInterfaceException
497
+	 * @throws ReflectionException
498
+	 * @throws RuntimeException
499
+	 */
500
+	public function update_registration_after_checkout_or_payment(
501
+		EE_Registration $registration,
502
+		array $additional_details = array()
503
+	) {
504
+		// set initial REG_Status
505
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
506
+		// if the registration status gets updated, then save the registration
507
+		if (
508
+			$this->toggle_registration_status_for_default_approved_events($registration, false)
509
+			|| $this->toggle_registration_status_if_no_monies_owing(
510
+				$registration,
511
+				false,
512
+				$additional_details
513
+			)
514
+		) {
515
+			$registration->save();
516
+		}
517
+		// set new  REG_Status
518
+		$this->set_new_reg_status($registration->ID(), $registration->status_ID());
519
+		return $this->reg_status_updated($registration->ID())
520
+			   && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved;
521
+	}
522
+
523
+
524
+
525
+	/**
526
+	 * Updates the registration' final prices based on the current line item tree (taking into account
527
+	 * discounts, taxes, and other line items unrelated to tickets.)
528
+	 *
529
+	 * @param EE_Transaction $transaction
530
+	 * @param boolean        $save_regs whether to immediately save registrations in this function or not
531
+	 * @return void
532
+	 * @throws EE_Error
533
+	 * @throws InvalidArgumentException
534
+	 * @throws InvalidDataTypeException
535
+	 * @throws InvalidInterfaceException
536
+	 * @throws RuntimeException
537
+	 */
538
+	public function update_registration_final_prices($transaction, $save_regs = true)
539
+	{
540
+		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item(
541
+			$transaction->total_line_item()
542
+		);
543
+		foreach ($transaction->registrations() as $registration) {
544
+			/** @var EE_Line_Item $line_item */
545
+			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
546
+			if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
547
+				$registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
548
+				if ($save_regs) {
549
+					$registration->save();
550
+				}
551
+			}
552
+		}
553
+		//and make sure there's no rounding problem
554
+		$this->fix_reg_final_price_rounding_issue($transaction);
555
+	}
556
+
557
+
558
+
559
+	/**
560
+	 * Makes sure there is no rounding errors for the REG_final_prices.
561
+	 * Eg, if we have 3 registrations for $1, and there is a $0.01 discount between the three of them,
562
+	 * they will each be for $0.99333333, which gets rounded to $1 again.
563
+	 * So the transaction total will be $2.99, but each registration will be for $1,
564
+	 * so if each registrant paid individually they will have overpaid by $0.01.
565
+	 * So in order to overcome this, we check for any difference, and if there is a difference
566
+	 * we just grab one registrant at random and make them responsible for it.
567
+	 * This should be used after setting REG_final_prices (it's done automatically as part of
568
+	 * EE_Registration_Processor::update_registration_final_prices())
569
+	 *
570
+	 * @param EE_Transaction $transaction
571
+	 * @return bool success verifying that there is NO difference after this method is done
572
+	 * @throws EE_Error
573
+	 * @throws InvalidArgumentException
574
+	 * @throws InvalidDataTypeException
575
+	 * @throws InvalidInterfaceException
576
+	 */
577
+	public function fix_reg_final_price_rounding_issue($transaction)
578
+	{
579
+		$reg_final_price_sum = EEM_Registration::instance()->sum(
580
+			array(
581
+				array(
582
+					'TXN_ID' => $transaction->ID(),
583
+				),
584
+			),
585
+			'REG_final_price'
586
+		);
587
+		$diff = $transaction->total() - $reg_final_price_sum;
588
+		//ok then, just grab one of the registrations
589
+		if ($diff !== 0) {
590
+			$a_reg   = EEM_Registration::instance()->get_one(
591
+				array(
592
+					array(
593
+						'TXN_ID' => $transaction->ID(),
594
+					),
595
+				)
596
+			);
597
+			return $a_reg instanceof EE_Registration
598
+				? (bool) $a_reg->save(array('REG_final_price' => $a_reg->final_price() + $diff))
599
+				: false;
600
+		}
601
+		return true;
602
+	}
603
+
604
+
605
+
606
+	/**
607
+	 * update_registration_after_being_canceled_or_declined
608
+	 *
609
+	 * @param EE_Registration $registration
610
+	 * @param array           $closed_reg_statuses
611
+	 * @param bool            $update_reg
612
+	 * @return bool
613
+	 * @throws EE_Error
614
+	 * @throws RuntimeException
615
+	 */
616
+	public function update_registration_after_being_canceled_or_declined(
617
+		EE_Registration $registration,
618
+		array $closed_reg_statuses = array(),
619
+		$update_reg = true
620
+	) {
621
+		// these reg statuses should not be considered in any calculations involving monies owing
622
+		$closed_reg_statuses = ! empty($closed_reg_statuses)
623
+			? $closed_reg_statuses
624
+			: EEM_Registration::closed_reg_statuses();
625
+		if (! in_array($registration->status_ID(), $closed_reg_statuses, true)) {
626
+			return false;
627
+		}
628
+		// release a reserved ticket by decrementing ticket and datetime reserved values
629
+		$registration->release_reserved_ticket(true);
630
+		$registration->set_final_price(0);
631
+		if ($update_reg) {
632
+			$registration->save();
633
+		}
634
+		return true;
635
+	}
636
+
637
+
638
+
639
+	/**
640
+	 * update_canceled_or_declined_registration_after_being_reinstated
641
+	 *
642
+	 * @param EE_Registration $registration
643
+	 * @param array           $closed_reg_statuses
644
+	 * @param bool            $update_reg
645
+	 * @return bool
646
+	 * @throws EE_Error
647
+	 * @throws RuntimeException
648
+	 */
649
+	public function update_canceled_or_declined_registration_after_being_reinstated(
650
+		EE_Registration $registration,
651
+		array $closed_reg_statuses = array(),
652
+		$update_reg = true
653
+	) {
654
+		// these reg statuses should not be considered in any calculations involving monies owing
655
+		$closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses
656
+			: EEM_Registration::closed_reg_statuses();
657
+		if (in_array($registration->status_ID(), $closed_reg_statuses, true)) {
658
+			return false;
659
+		}
660
+		$ticket = $registration->ticket();
661
+		if (! $ticket instanceof EE_Ticket) {
662
+			throw new EE_Error(
663
+				sprintf(
664
+					esc_html__(
665
+						'The Ticket for Registration %1$d was not found or is invalid.',
666
+						'event_espresso'
667
+					),
668
+					$registration->ticket_ID()
669
+				)
670
+			);
671
+		}
672
+		$registration->set_final_price($ticket->price());
673
+		if ($update_reg) {
674
+			$registration->save();
675
+		}
676
+		return true;
677
+	}
678
+
679
+
680
+
681
+	/**
682
+	 * generate_ONE_registration_from_line_item
683
+	 * Although a ticket line item may have a quantity greater than 1,
684
+	 * this method will ONLY CREATE ONE REGISTRATION !!!
685
+	 * Regardless of the ticket line item quantity.
686
+	 * This means that any code calling this method is responsible for ensuring
687
+	 * that the final registration count matches the ticket line item quantity.
688
+	 * This was done to make it easier to match the number of registrations
689
+	 * to the number of tickets in the cart, when the cart has been edited
690
+	 * after SPCO has already been initialized. So if an additional ticket was added to the cart, you can simply pass
691
+	 * the line item to this method to add a second ticket, and in this case, you would not want to add 2 tickets.
692
+	 *
693
+	 * @deprecated
694
+	 * @since 4.9.1
695
+	 * @param EE_Line_Item    $line_item
696
+	 * @param \EE_Transaction $transaction
697
+	 * @param int             $att_nmbr
698
+	 * @param int             $total_ticket_count
699
+	 * @return EE_Registration | null
700
+	 * @throws \OutOfRangeException
701
+	 * @throws \EventEspresso\core\exceptions\UnexpectedEntityException
702
+	 * @throws \EE_Error
703
+	 */
704
+	public function generate_ONE_registration_from_line_item(
705
+		EE_Line_Item $line_item,
706
+		EE_Transaction $transaction,
707
+		$att_nmbr = 1,
708
+		$total_ticket_count = 1
709
+	) {
710
+		EE_Error::doing_it_wrong(
711
+			__CLASS__ . '::' . __FUNCTION__,
712
+			sprintf(
713
+				esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
714
+				'\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'
715
+			),
716
+			'4.9.1',
717
+			'5.0.0'
718
+		);
719
+		// grab the related ticket object for this line_item
720
+		$ticket = $line_item->ticket();
721
+		if (! $ticket instanceof EE_Ticket) {
722
+			EE_Error::add_error(
723
+				sprintf(
724
+					esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
725
+					$line_item->ID()
726
+				),
727
+				__FILE__,
728
+				__FUNCTION__,
729
+				__LINE__
730
+			);
731
+			return null;
732
+		}
733
+		$registration_service = new CreateRegistrationService();
734
+		// then generate a new registration from that
735
+		return $registration_service->create(
736
+			$ticket->get_related_event(),
737
+			$transaction,
738
+			$ticket,
739
+			$line_item,
740
+			$att_nmbr,
741
+			$total_ticket_count
742
+		);
743
+	}
744
+
745
+
746
+
747
+	/**
748
+	 * generates reg_url_link
749
+	 *
750
+	 * @deprecated
751
+	 * @since 4.9.1
752
+	 * @param int                   $att_nmbr
753
+	 * @param EE_Line_Item | string $item
754
+	 * @return string
755
+	 * @throws InvalidArgumentException
756
+	 */
757
+	public function generate_reg_url_link($att_nmbr, $item)
758
+	{
759
+		EE_Error::doing_it_wrong(
760
+			__CLASS__ . '::' . __FUNCTION__,
761
+			sprintf(
762
+				esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
763
+				'EventEspresso\core\domain\entities\RegUrlLink'
764
+			),
765
+			'4.9.1',
766
+			'5.0.0'
767
+		);
768
+		return new RegUrlLink($att_nmbr, $item);
769
+	}
770
+
771
+
772
+
773
+	/**
774
+	 * generates reg code
775
+	 *
776
+	 * @deprecated
777
+	 * @since 4.9.1
778
+	 * @param EE_Registration $registration
779
+	 * @return string
780
+	 * @throws EE_Error
781
+	 * @throws EntityNotFoundException
782
+	 * @throws InvalidArgumentException
783
+	 */
784
+	public function generate_reg_code(EE_Registration $registration)
785
+	{
786
+		EE_Error::doing_it_wrong(
787
+			__CLASS__ . '::' . __FUNCTION__,
788
+			sprintf(
789
+				esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
790
+				'EventEspresso\core\domain\entities\RegCode'
791
+			),
792
+			'4.9.1',
793
+			'5.0.0'
794
+		);
795
+		return apply_filters(
796
+			'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code',
797
+			new RegCode(
798
+				RegUrlLink::fromRegistration($registration),
799
+				$registration->transaction(),
800
+				$registration->ticket()
801
+			),
802
+			$registration
803
+		);
804
+	}
805 805
 
806 806
 
807 807
 
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -83,8 +83,8 @@  discard block
 block discarded – undo
83 83
     public static function instance(EE_Request $request = null)
84 84
     {
85 85
         // check if class object is instantiated
86
-        if (! self::$_instance instanceof EE_Registration_Processor) {
87
-            if(! $request instanceof EE_Request) {
86
+        if ( ! self::$_instance instanceof EE_Registration_Processor) {
87
+            if ( ! $request instanceof EE_Request) {
88 88
                 $request = LoaderFactory::getLoader()->getShared('EE_Request');
89 89
             }
90 90
             self::$_instance = new self($request);
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
     public function set_old_reg_status($REG_ID, $old_reg_status)
124 124
     {
125 125
         // only set the first time
126
-        if (! isset($this->_old_reg_status[$REG_ID])) {
126
+        if ( ! isset($this->_old_reg_status[$REG_ID])) {
127 127
             $this->_old_reg_status[$REG_ID] = $old_reg_status;
128 128
         }
129 129
     }
@@ -217,7 +217,7 @@  discard block
 block discarded – undo
217 217
         if (
218 218
             $this->reg_status_updated($registration->ID())
219 219
             && (
220
-                (! $this->request->isAdmin() || $this->request->isFrontAjax())
220
+                ( ! $this->request->isAdmin() || $this->request->isFrontAjax())
221 221
                 || EE_Registry::instance()->CAP->current_user_can(
222 222
                     'ee_edit_registration',
223 223
                     'toggle_registration_status',
@@ -281,7 +281,7 @@  discard block
 block discarded – undo
281 281
                 $registration->save();
282 282
             }
283 283
             // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
284
-            if (! EE_Processor_Base::$IPN) {
284
+            if ( ! EE_Processor_Base::$IPN) {
285 285
                 // otherwise, send out notifications
286 286
                 add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
287 287
             }
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
                 $registration->save();
338 338
             }
339 339
             // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
340
-            if (! EE_Processor_Base::$IPN) {
340
+            if ( ! EE_Processor_Base::$IPN) {
341 341
                 // otherwise, send out notifications
342 342
                 add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
343 343
             }
@@ -382,7 +382,7 @@  discard block
 block discarded – undo
382 382
         // set initial REG_Status
383 383
         $this->set_old_reg_status($registration->ID(), $registration->status_ID());
384 384
         // was a payment just made ?
385
-        $payment    = isset($additional_details['payment_updates'], $additional_details['last_payment'])
385
+        $payment = isset($additional_details['payment_updates'], $additional_details['last_payment'])
386 386
                       && $additional_details['payment_updates']
387 387
                       && $additional_details['last_payment'] instanceof EE_Payment
388 388
             ? $additional_details['last_payment']
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
                 $registration->save();
424 424
             }
425 425
             // don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
426
-            if (! EE_Processor_Base::$IPN) {
426
+            if ( ! EE_Processor_Base::$IPN) {
427 427
                 // otherwise, send out notifications
428 428
                 add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
429 429
             }
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
     public function trigger_registration_update_notifications($registration, array $additional_details = array())
455 455
     {
456 456
         try {
457
-            if (! $registration instanceof EE_Registration) {
457
+            if ( ! $registration instanceof EE_Registration) {
458 458
                 throw new EE_Error(
459 459
                     esc_html__('An invalid registration was received.', 'event_espresso')
460 460
                 );
@@ -468,7 +468,7 @@  discard block
 block discarded – undo
468 468
             // 	false,
469 469
             // 	'EE_Transaction: ' . $registration->transaction()->ID()
470 470
             // );
471
-            if (! $registration->is_primary_registrant()) {
471
+            if ( ! $registration->is_primary_registrant()) {
472 472
                 return;
473 473
             }
474 474
             do_action(
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
         $diff = $transaction->total() - $reg_final_price_sum;
588 588
         //ok then, just grab one of the registrations
589 589
         if ($diff !== 0) {
590
-            $a_reg   = EEM_Registration::instance()->get_one(
590
+            $a_reg = EEM_Registration::instance()->get_one(
591 591
                 array(
592 592
                     array(
593 593
                         'TXN_ID' => $transaction->ID(),
@@ -622,7 +622,7 @@  discard block
 block discarded – undo
622 622
         $closed_reg_statuses = ! empty($closed_reg_statuses)
623 623
             ? $closed_reg_statuses
624 624
             : EEM_Registration::closed_reg_statuses();
625
-        if (! in_array($registration->status_ID(), $closed_reg_statuses, true)) {
625
+        if ( ! in_array($registration->status_ID(), $closed_reg_statuses, true)) {
626 626
             return false;
627 627
         }
628 628
         // release a reserved ticket by decrementing ticket and datetime reserved values
@@ -658,7 +658,7 @@  discard block
 block discarded – undo
658 658
             return false;
659 659
         }
660 660
         $ticket = $registration->ticket();
661
-        if (! $ticket instanceof EE_Ticket) {
661
+        if ( ! $ticket instanceof EE_Ticket) {
662 662
             throw new EE_Error(
663 663
                 sprintf(
664 664
                     esc_html__(
@@ -708,7 +708,7 @@  discard block
 block discarded – undo
708 708
         $total_ticket_count = 1
709 709
     ) {
710 710
         EE_Error::doing_it_wrong(
711
-            __CLASS__ . '::' . __FUNCTION__,
711
+            __CLASS__.'::'.__FUNCTION__,
712 712
             sprintf(
713 713
                 esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
714 714
                 '\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
         );
719 719
         // grab the related ticket object for this line_item
720 720
         $ticket = $line_item->ticket();
721
-        if (! $ticket instanceof EE_Ticket) {
721
+        if ( ! $ticket instanceof EE_Ticket) {
722 722
             EE_Error::add_error(
723 723
                 sprintf(
724 724
                     esc_html__('Line item %s did not contain a valid ticket', 'event_espresso'),
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
     public function generate_reg_url_link($att_nmbr, $item)
758 758
     {
759 759
         EE_Error::doing_it_wrong(
760
-            __CLASS__ . '::' . __FUNCTION__,
760
+            __CLASS__.'::'.__FUNCTION__,
761 761
             sprintf(
762 762
                 esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
763 763
                 'EventEspresso\core\domain\entities\RegUrlLink'
@@ -784,7 +784,7 @@  discard block
 block discarded – undo
784 784
     public function generate_reg_code(EE_Registration $registration)
785 785
     {
786 786
         EE_Error::doing_it_wrong(
787
-            __CLASS__ . '::' . __FUNCTION__,
787
+            __CLASS__.'::'.__FUNCTION__,
788 788
             sprintf(
789 789
                 esc_html__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
790 790
                 'EventEspresso\core\domain\entities\RegCode'
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -777,7 +777,7 @@  discard block
 block discarded – undo
777 777
      * we know if we need to drop out.
778 778
      *
779 779
      * @access protected
780
-     * @return void
780
+     * @return false|null
781 781
      */
782 782
     protected function _verify_routes()
783 783
     {
@@ -856,7 +856,7 @@  discard block
 block discarded – undo
856 856
      * this method simply verifies a given route and makes sure its an actual route available for the loaded page
857 857
      *
858 858
      * @param  string $route the route name we're verifying
859
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
859
+     * @return boolean  (bool|Exception)      we'll throw an exception if this isn't a valid route.
860 860
      */
861 861
     protected function _verify_route($route)
862 862
     {
@@ -3843,7 +3843,7 @@  discard block
 block discarded – undo
3843 3843
 
3844 3844
 
3845 3845
     /**
3846
-     * @return mixed
3846
+     * @return string[]
3847 3847
      */
3848 3848
     public function default_espresso_metaboxes()
3849 3849
     {
@@ -3863,7 +3863,7 @@  discard block
 block discarded – undo
3863 3863
 
3864 3864
 
3865 3865
     /**
3866
-     * @return mixed
3866
+     * @return string
3867 3867
      */
3868 3868
     public function wp_page_slug()
3869 3869
     {
Please login to merge, or discard this patch.
Indentation   +3886 added lines, -3886 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\InterminableInterface;
2 2
 
3 3
 if (! defined('EVENT_ESPRESSO_VERSION')) {
4
-    exit('No direct script access allowed');
4
+	exit('No direct script access allowed');
5 5
 }
6 6
 /**
7 7
  * Event Espresso
@@ -30,3975 +30,3975 @@  discard block
 block discarded – undo
30 30
 {
31 31
 
32 32
 
33
-    //set in _init_page_props()
34
-    public $page_slug;
33
+	//set in _init_page_props()
34
+	public $page_slug;
35 35
 
36
-    public $page_label;
36
+	public $page_label;
37 37
 
38
-    public $page_folder;
38
+	public $page_folder;
39 39
 
40
-    //set in define_page_props()
41
-    protected $_admin_base_url;
40
+	//set in define_page_props()
41
+	protected $_admin_base_url;
42 42
 
43
-    protected $_admin_base_path;
43
+	protected $_admin_base_path;
44 44
 
45
-    protected $_admin_page_title;
45
+	protected $_admin_page_title;
46 46
 
47
-    protected $_labels;
47
+	protected $_labels;
48 48
 
49 49
 
50
-    //set early within EE_Admin_Init
51
-    protected $_wp_page_slug;
50
+	//set early within EE_Admin_Init
51
+	protected $_wp_page_slug;
52 52
 
53
-    //navtabs
54
-    protected $_nav_tabs;
53
+	//navtabs
54
+	protected $_nav_tabs;
55 55
 
56
-    protected $_default_nav_tab_name;
56
+	protected $_default_nav_tab_name;
57 57
 
58
-    //helptourstops
59
-    protected $_help_tour = array();
58
+	//helptourstops
59
+	protected $_help_tour = array();
60 60
 
61 61
 
62
-    //template variables (used by templates)
63
-    protected $_template_path;
62
+	//template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = array();
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = array();
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    //bools
80
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79
+	//bools
80
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    //list table args
85
-    protected $_view;
84
+	//list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    //action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	//action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    protected $_page_config;
93
+	protected $_page_config;
94 94
 
95
-    //the current page route and route config
96
-    protected $_route;
95
+	//the current page route and route config
96
+	protected $_route;
97 97
 
98
-    protected $_route_config;
98
+	protected $_route_config;
99 99
 
100
-    /**
101
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
102
-     * actions.
103
-     *
104
-     * @since 4.6.x
105
-     * @var array.
106
-     */
107
-    protected $_default_route_query_args;
100
+	/**
101
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
102
+	 * actions.
103
+	 *
104
+	 * @since 4.6.x
105
+	 * @var array.
106
+	 */
107
+	protected $_default_route_query_args;
108 108
 
109
-    //set via request page and action args.
110
-    protected $_current_page;
109
+	//set via request page and action args.
110
+	protected $_current_page;
111 111
 
112
-    protected $_current_view;
112
+	protected $_current_view;
113 113
 
114
-    protected $_current_page_view_url;
114
+	protected $_current_page_view_url;
115 115
 
116
-    //sanitized request action (and nonce)
116
+	//sanitized request action (and nonce)
117 117
 
118
-    /**
119
-     * @var string $_req_action
120
-     */
121
-    protected $_req_action;
118
+	/**
119
+	 * @var string $_req_action
120
+	 */
121
+	protected $_req_action;
122 122
 
123
-    /**
124
-     * @var string $_req_nonce
125
-     */
126
-    protected $_req_nonce;
123
+	/**
124
+	 * @var string $_req_nonce
125
+	 */
126
+	protected $_req_nonce;
127 127
 
128
-    //search related
129
-    protected $_search_btn_label;
128
+	//search related
129
+	protected $_search_btn_label;
130 130
 
131
-    protected $_search_box_callback;
131
+	protected $_search_box_callback;
132 132
 
133
-    /**
134
-     * WP Current Screen object
135
-     *
136
-     * @var WP_Screen
137
-     */
138
-    protected $_current_screen;
133
+	/**
134
+	 * WP Current Screen object
135
+	 *
136
+	 * @var WP_Screen
137
+	 */
138
+	protected $_current_screen;
139 139
 
140
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
141
-    protected $_hook_obj;
140
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
141
+	protected $_hook_obj;
142 142
 
143
-    //for holding incoming request data
144
-    protected $_req_data;
143
+	//for holding incoming request data
144
+	protected $_req_data;
145 145
 
146
-    // yes / no array for admin form fields
147
-    protected $_yes_no_values = array();
148
-
149
-    //some default things shared by all child classes
150
-    protected $_default_espresso_metaboxes;
151
-
152
-    /**
153
-     *    EE_Registry Object
154
-     *
155
-     * @var    EE_Registry
156
-     * @access    protected
157
-     */
158
-    protected $EE = null;
159
-
160
-
161
-
162
-    /**
163
-     * This is just a property that flags whether the given route is a caffeinated route or not.
164
-     *
165
-     * @var boolean
166
-     */
167
-    protected $_is_caf = false;
168
-
169
-
170
-
171
-    /**
172
-     * @Constructor
173
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
174
-     * @access public
175
-     */
176
-    public function __construct($routing = true)
177
-    {
178
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
179
-            $this->_is_caf = true;
180
-        }
181
-        $this->_yes_no_values = array(
182
-            array('id' => true, 'text' => __('Yes', 'event_espresso')),
183
-            array('id' => false, 'text' => __('No', 'event_espresso')),
184
-        );
185
-        //set the _req_data property.
186
-        $this->_req_data = array_merge($_GET, $_POST);
187
-        //routing enabled?
188
-        $this->_routing = $routing;
189
-        //set initial page props (child method)
190
-        $this->_init_page_props();
191
-        //set global defaults
192
-        $this->_set_defaults();
193
-        //set early because incoming requests could be ajax related and we need to register those hooks.
194
-        $this->_global_ajax_hooks();
195
-        $this->_ajax_hooks();
196
-        //other_page_hooks have to be early too.
197
-        $this->_do_other_page_hooks();
198
-        //This just allows us to have extending classes do something specific
199
-        // before the parent constructor runs _page_setup().
200
-        if (method_exists($this, '_before_page_setup')) {
201
-            $this->_before_page_setup();
202
-        }
203
-        //set up page dependencies
204
-        $this->_page_setup();
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * _init_page_props
211
-     * Child classes use to set at least the following properties:
212
-     * $page_slug.
213
-     * $page_label.
214
-     *
215
-     * @abstract
216
-     * @access protected
217
-     * @return void
218
-     */
219
-    abstract protected function _init_page_props();
220
-
221
-
222
-
223
-    /**
224
-     * _ajax_hooks
225
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
226
-     * Note: within the ajax callback methods.
227
-     *
228
-     * @abstract
229
-     * @access protected
230
-     * @return void
231
-     */
232
-    abstract protected function _ajax_hooks();
233
-
234
-
235
-
236
-    /**
237
-     * _define_page_props
238
-     * child classes define page properties in here.  Must include at least:
239
-     * $_admin_base_url = base_url for all admin pages
240
-     * $_admin_page_title = default admin_page_title for admin pages
241
-     * $_labels = array of default labels for various automatically generated elements:
242
-     *    array(
243
-     *        'buttons' => array(
244
-     *            'add' => __('label for add new button'),
245
-     *            'edit' => __('label for edit button'),
246
-     *            'delete' => __('label for delete button')
247
-     *            )
248
-     *        )
249
-     *
250
-     * @abstract
251
-     * @access protected
252
-     * @return void
253
-     */
254
-    abstract protected function _define_page_props();
255
-
256
-
257
-
258
-    /**
259
-     * _set_page_routes
260
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
261
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
262
-     * have a 'default' route. Here's the format
263
-     * $this->_page_routes = array(
264
-     *        'default' => array(
265
-     *            'func' => '_default_method_handling_route',
266
-     *            'args' => array('array','of','args'),
267
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
268
-     *            ajax request, backend processing)
269
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
270
-     *            headers route after.  The string you enter here should match the defined route reference for a
271
-     *            headers sent route.
272
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
273
-     *            this route.
274
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
275
-     *            checks).
276
-     *        ),
277
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
278
-     *        handling method.
279
-     *        )
280
-     * )
281
-     *
282
-     * @abstract
283
-     * @access protected
284
-     * @return void
285
-     */
286
-    abstract protected function _set_page_routes();
287
-
288
-
289
-
290
-    /**
291
-     * _set_page_config
292
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
293
-     * array corresponds to the page_route for the loaded page. Format:
294
-     * $this->_page_config = array(
295
-     *        'default' => array(
296
-     *            'labels' => array(
297
-     *                'buttons' => array(
298
-     *                    'add' => __('label for adding item'),
299
-     *                    'edit' => __('label for editing item'),
300
-     *                    'delete' => __('label for deleting item')
301
-     *                ),
302
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
303
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
304
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
305
-     *            _define_page_props() method
306
-     *            'nav' => array(
307
-     *                'label' => __('Label for Tab', 'event_espresso').
308
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
309
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
310
-     *                'order' => 10, //required to indicate tab position.
311
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
312
-     *                displayed then add this parameter.
313
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
314
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
315
-     *            metaboxes set for eventespresso admin pages.
316
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
317
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
318
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
319
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
320
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
321
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
322
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
323
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
324
-     *            want to display.
325
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
326
-     *                'tab_id' => array(
327
-     *                    'title' => 'tab_title',
328
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
329
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
330
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
331
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
332
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
333
-     *                    attempt to use the callback which should match the name of a method in the class
334
-     *                    ),
335
-     *                'tab2_id' => array(
336
-     *                    'title' => 'tab2 title',
337
-     *                    'filename' => 'file_name_2'
338
-     *                    'callback' => 'callback_method_for_content',
339
-     *                 ),
340
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
341
-     *            help tab area on an admin page. @link
342
-     *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
343
-     *            'help_tour' => array(
344
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
345
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
346
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
347
-     *            ),
348
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
349
-     *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
350
-     *            just set
351
-     *            'require_nonce' to FALSE
352
-     *            )
353
-     * )
354
-     *
355
-     * @abstract
356
-     * @access protected
357
-     * @return void
358
-     */
359
-    abstract protected function _set_page_config();
360
-
361
-
362
-
363
-
364
-
365
-    /** end sample help_tour methods **/
366
-    /**
367
-     * _add_screen_options
368
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
-     * to a particular view.
371
-     *
372
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
-     *         see also WP_Screen object documents...
374
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
-     * @abstract
376
-     * @access protected
377
-     * @return void
378
-     */
379
-    abstract protected function _add_screen_options();
380
-
381
-
382
-
383
-    /**
384
-     * _add_feature_pointers
385
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
386
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
387
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
388
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
389
-     * extended) also see:
390
-     *
391
-     * @link   http://eamann.com/tech/wordpress-portland/
392
-     * @abstract
393
-     * @access protected
394
-     * @return void
395
-     */
396
-    abstract protected function _add_feature_pointers();
397
-
398
-
399
-
400
-    /**
401
-     * load_scripts_styles
402
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
403
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
404
-     * scripts/styles per view by putting them in a dynamic function in this format
405
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
406
-     *
407
-     * @abstract
408
-     * @access public
409
-     * @return void
410
-     */
411
-    abstract public function load_scripts_styles();
412
-
413
-
414
-
415
-    /**
416
-     * admin_init
417
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
418
-     * all pages/views loaded by child class.
419
-     *
420
-     * @abstract
421
-     * @access public
422
-     * @return void
423
-     */
424
-    abstract public function admin_init();
425
-
426
-
427
-
428
-    /**
429
-     * admin_notices
430
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
431
-     * all pages/views loaded by child class.
432
-     *
433
-     * @abstract
434
-     * @access public
435
-     * @return void
436
-     */
437
-    abstract public function admin_notices();
438
-
439
-
440
-
441
-    /**
442
-     * admin_footer_scripts
443
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
-     * will apply to all pages/views loaded by child class.
445
-     *
446
-     * @access public
447
-     * @return void
448
-     */
449
-    abstract public function admin_footer_scripts();
450
-
451
-
452
-
453
-    /**
454
-     * admin_footer
455
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
456
-     * apply to all pages/views loaded by child class.
457
-     *
458
-     * @access  public
459
-     * @return void
460
-     */
461
-    public function admin_footer()
462
-    {
463
-    }
464
-
465
-
466
-
467
-    /**
468
-     * _global_ajax_hooks
469
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
470
-     * Note: within the ajax callback methods.
471
-     *
472
-     * @abstract
473
-     * @access protected
474
-     * @return void
475
-     */
476
-    protected function _global_ajax_hooks()
477
-    {
478
-        //for lazy loading of metabox content
479
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
480
-    }
481
-
482
-
483
-
484
-    public function ajax_metabox_content()
485
-    {
486
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
487
-        $url       = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
488
-        self::cached_rss_display($contentid, $url);
489
-        wp_die();
490
-    }
491
-
492
-
493
-
494
-    /**
495
-     * _page_setup
496
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
497
-     * doesn't match the object.
498
-     *
499
-     * @final
500
-     * @access protected
501
-     * @return void
502
-     */
503
-    final protected function _page_setup()
504
-    {
505
-        //requires?
506
-        //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
507
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
508
-        //next verify if we need to load anything...
509
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
510
-        $this->page_folder   = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
511
-        global $ee_menu_slugs;
512
-        $ee_menu_slugs = (array)$ee_menu_slugs;
513
-        if ((! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
514
-            return;
515
-        }
516
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
517
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
518
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1
519
-                ? $this->_req_data['action2'] : $this->_req_data['action'];
520
-        }
521
-        // then set blank or -1 action values to 'default'
522
-        $this->_req_action = isset($this->_req_data['action'])
523
-                             && ! empty($this->_req_data['action'])
524
-                             && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
525
-        //if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
526
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
527
-            ? $this->_req_data['route'] : $this->_req_action;
528
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
529
-        $this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route']
530
-            : $this->_req_action;
531
-        $this->_current_view = $this->_req_action;
532
-        $this->_req_nonce    = $this->_req_action . '_nonce';
533
-        $this->_define_page_props();
534
-        $this->_current_page_view_url = add_query_arg(
535
-            array('page' => $this->_current_page, 'action' => $this->_current_view),
536
-            $this->_admin_base_url
537
-        );
538
-        //default things
539
-        $this->_default_espresso_metaboxes = array(
540
-            '_espresso_news_post_box',
541
-            '_espresso_links_post_box',
542
-            '_espresso_ratings_request',
543
-            '_espresso_sponsors_post_box',
544
-        );
545
-        //set page configs
546
-        $this->_set_page_routes();
547
-        $this->_set_page_config();
548
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
549
-        if (isset($this->_req_data['wp_referer'])) {
550
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
551
-        }
552
-        //for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
553
-        if (method_exists($this, '_extend_page_config')) {
554
-            $this->_extend_page_config();
555
-        }
556
-        //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
557
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
558
-            $this->_extend_page_config_for_cpt();
559
-        }
560
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
561
-        $this->_page_routes = apply_filters(
562
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
563
-            $this->_page_routes,
564
-            $this
565
-        );
566
-        $this->_page_config = apply_filters(
567
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
568
-            $this->_page_config,
569
-            $this
570
-        );
571
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
-            add_action(
574
-                'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
-                10,
577
-                2
578
-            );
579
-        }
580
-        //next route only if routing enabled
581
-        if ($this->_routing && ! defined('DOING_AJAX')) {
582
-            $this->_verify_routes();
583
-            //next let's just check user_access and kill if no access
584
-            $this->check_user_access();
585
-            if ($this->_is_UI_request) {
586
-                //admin_init stuff - global, all views for this page class, specific view
587
-                add_action('admin_init', array($this, 'admin_init'), 10);
588
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
-                }
591
-            } else {
592
-                //hijack regular WP loading and route admin request immediately
593
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
-                $this->route_admin_request();
595
-            }
596
-        }
597
-    }
598
-
599
-
600
-
601
-    /**
602
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
603
-     *
604
-     * @access private
605
-     * @return void
606
-     */
607
-    private function _do_other_page_hooks()
608
-    {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
-        foreach ($registered_pages as $page) {
611
-            //now let's setup the file name and class that should be present
612
-            $classname = str_replace('.class.php', '', $page);
613
-            //autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
615
-                $error_msg[] = sprintf(
616
-                    esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'),
617
-                    $page
618
-                );
619
-                $error_msg[] = $error_msg[0]
620
-                               . "\r\n"
621
-                               . sprintf(
622
-                                   esc_html__(
623
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
624
-                                       'event_espresso'
625
-                                   ),
626
-                                   $page,
627
-                                   '<br />',
628
-                                   '<strong>' . $classname . '</strong>'
629
-                               );
630
-                throw new EE_Error(implode('||', $error_msg));
631
-            }
632
-            $a = new ReflectionClass($classname);
633
-            //notice we are passing the instance of this class to the hook object.
634
-            $hookobj[] = $a->newInstance($this);
635
-        }
636
-    }
637
-
638
-
639
-
640
-    public function load_page_dependencies()
641
-    {
642
-        try {
643
-            $this->_load_page_dependencies();
644
-        } catch (EE_Error $e) {
645
-            $e->get_error();
646
-        }
647
-    }
648
-
649
-
650
-
651
-    /**
652
-     * load_page_dependencies
653
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
654
-     *
655
-     * @access public
656
-     * @return void
657
-     */
658
-    protected function _load_page_dependencies()
659
-    {
660
-        //let's set the current_screen and screen options to override what WP set
661
-        $this->_current_screen = get_current_screen();
662
-        //load admin_notices - global, page class, and view specific
663
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
664
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
665
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
666
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
667
-        }
668
-        //load network admin_notices - global, page class, and view specific
669
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
670
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
671
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
672
-        }
673
-        //this will save any per_page screen options if they are present
674
-        $this->_set_per_page_screen_options();
675
-        //setup list table properties
676
-        $this->_set_list_table();
677
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
678
-        $this->_add_registered_meta_boxes();
679
-        $this->_add_screen_columns();
680
-        //add screen options - global, page child class, and view specific
681
-        $this->_add_global_screen_options();
682
-        $this->_add_screen_options();
683
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
684
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
685
-        }
686
-        //add help tab(s) and tours- set via page_config and qtips.
687
-        $this->_add_help_tour();
688
-        $this->_add_help_tabs();
689
-        $this->_add_qtips();
690
-        //add feature_pointers - global, page child class, and view specific
691
-        $this->_add_feature_pointers();
692
-        $this->_add_global_feature_pointers();
693
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
694
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
695
-        }
696
-        //enqueue scripts/styles - global, page class, and view specific
697
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
698
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
699
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
700
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
701
-        }
702
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
703
-        //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
704
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
705
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
706
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
707
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
708
-        }
709
-        //admin footer scripts
710
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
711
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
712
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
713
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
714
-        }
715
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
716
-        //targeted hook
717
-        do_action(
718
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action
719
-        );
720
-    }
721
-
722
-
723
-
724
-    /**
725
-     * _set_defaults
726
-     * This sets some global defaults for class properties.
727
-     */
728
-    private function _set_defaults()
729
-    {
730
-        $this->_current_screen      = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
731
-        $this->_nav_tabs            = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
732
-        $this->default_nav_tab_name = 'overview';
733
-        //init template args
734
-        $this->_template_args = array(
735
-            'admin_page_header'  => '',
736
-            'admin_page_content' => '',
737
-            'post_body_content'  => '',
738
-            'before_list_table'  => '',
739
-            'after_list_table'   => '',
740
-        );
741
-    }
742
-
743
-
744
-
745
-    /**
746
-     * route_admin_request
747
-     *
748
-     * @see    _route_admin_request()
749
-     * @access public
750
-     * @return void|exception error
751
-     */
752
-    public function route_admin_request()
753
-    {
754
-        try {
755
-            $this->_route_admin_request();
756
-        } catch (EE_Error $e) {
757
-            $e->get_error();
758
-        }
759
-    }
760
-
761
-
762
-
763
-    public function set_wp_page_slug($wp_page_slug)
764
-    {
765
-        $this->_wp_page_slug = $wp_page_slug;
766
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
767
-        if (is_network_admin()) {
768
-            $this->_wp_page_slug .= '-network';
769
-        }
770
-    }
771
-
772
-
773
-
774
-    /**
775
-     * _verify_routes
776
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
777
-     * we know if we need to drop out.
778
-     *
779
-     * @access protected
780
-     * @return void
781
-     */
782
-    protected function _verify_routes()
783
-    {
784
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
785
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
786
-            return false;
787
-        }
788
-        $this->_route = false;
789
-        $func         = false;
790
-        $args         = array();
791
-        // check that the page_routes array is not empty
792
-        if (empty($this->_page_routes)) {
793
-            // user error msg
794
-            $error_msg = sprintf(
795
-                __('No page routes have been set for the %s admin page.', 'event_espresso'),
796
-                $this->_admin_page_title
797
-            );
798
-            // developer error msg
799
-            $error_msg .= '||' . $error_msg . __(
800
-                    ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
801
-                    'event_espresso'
802
-                );
803
-            throw new EE_Error($error_msg);
804
-        }
805
-        // and that the requested page route exists
806
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
807
-            $this->_route        = $this->_page_routes[$this->_req_action];
808
-            $this->_route_config = isset($this->_page_config[$this->_req_action])
809
-                ? $this->_page_config[$this->_req_action] : array();
810
-        } else {
811
-            // user error msg
812
-            $error_msg = sprintf(
813
-                __('The requested page route does not exist for the %s admin page.', 'event_espresso'),
814
-                $this->_admin_page_title
815
-            );
816
-            // developer error msg
817
-            $error_msg .= '||' . $error_msg . sprintf(
818
-                    __(
819
-                        ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
820
-                        'event_espresso'
821
-                    ),
822
-                    $this->_req_action
823
-                );
824
-            throw new EE_Error($error_msg);
825
-        }
826
-        // and that a default route exists
827
-        if (! array_key_exists('default', $this->_page_routes)) {
828
-            // user error msg
829
-            $error_msg = sprintf(
830
-                __('A default page route has not been set for the % admin page.', 'event_espresso'),
831
-                $this->_admin_page_title
832
-            );
833
-            // developer error msg
834
-            $error_msg .= '||' . $error_msg . __(
835
-                    ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
836
-                    'event_espresso'
837
-                );
838
-            throw new EE_Error($error_msg);
839
-        }
840
-        //first lets' catch if the UI request has EVER been set.
841
-        if ($this->_is_UI_request === null) {
842
-            //lets set if this is a UI request or not.
843
-            $this->_is_UI_request = (! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
844
-                ? true : false;
845
-            //wait a minute... we might have a noheader in the route array
846
-            $this->_is_UI_request = is_array($this->_route)
847
-                                    && isset($this->_route['noheader'])
848
-                                    && $this->_route['noheader'] ? false : $this->_is_UI_request;
849
-        }
850
-        $this->_set_current_labels();
851
-    }
852
-
853
-
854
-
855
-    /**
856
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
857
-     *
858
-     * @param  string $route the route name we're verifying
859
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
860
-     */
861
-    protected function _verify_route($route)
862
-    {
863
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
864
-            return true;
865
-        } else {
866
-            // user error msg
867
-            $error_msg = sprintf(
868
-                __('The given page route does not exist for the %s admin page.', 'event_espresso'),
869
-                $this->_admin_page_title
870
-            );
871
-            // developer error msg
872
-            $error_msg .= '||' . $error_msg . sprintf(
873
-                    __(
874
-                        ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
875
-                        'event_espresso'
876
-                    ),
877
-                    $route
878
-                );
879
-            throw new EE_Error($error_msg);
880
-        }
881
-    }
882
-
883
-
884
-
885
-    /**
886
-     * perform nonce verification
887
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
888
-     * using this method (and save retyping!)
889
-     *
890
-     * @param  string $nonce     The nonce sent
891
-     * @param  string $nonce_ref The nonce reference string (name0)
892
-     * @return mixed (bool|die)
893
-     */
894
-    protected function _verify_nonce($nonce, $nonce_ref)
895
-    {
896
-        // verify nonce against expected value
897
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
898
-            // these are not the droids you are looking for !!!
899
-            $msg = sprintf(
900
-                __('%sNonce Fail.%s', 'event_espresso'),
901
-                '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
902
-                '</a>'
903
-            );
904
-            if (WP_DEBUG) {
905
-                $msg .= "\n  " . sprintf(
906
-                        __(
907
-                            'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
908
-                            'event_espresso'
909
-                        ),
910
-                        __CLASS__
911
-                    );
912
-            }
913
-            if (! defined('DOING_AJAX')) {
914
-                wp_die($msg);
915
-            } else {
916
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
917
-                $this->_return_json();
918
-            }
919
-        }
920
-    }
921
-
922
-
923
-
924
-    /**
925
-     * _route_admin_request()
926
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
927
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
928
-     * in the page routes and then will try to load the corresponding method.
929
-     *
930
-     * @access protected
931
-     * @return void
932
-     * @throws \EE_Error
933
-     */
934
-    protected function _route_admin_request()
935
-    {
936
-        if (! $this->_is_UI_request) {
937
-            $this->_verify_routes();
938
-        }
939
-        $nonce_check = isset($this->_route_config['require_nonce'])
940
-            ? $this->_route_config['require_nonce']
941
-            : true;
942
-        if ($this->_req_action !== 'default' && $nonce_check) {
943
-            // set nonce from post data
944
-            $nonce = isset($this->_req_data[$this->_req_nonce])
945
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
946
-                : '';
947
-            $this->_verify_nonce($nonce, $this->_req_nonce);
948
-        }
949
-        //set the nav_tabs array but ONLY if this is  UI_request
950
-        if ($this->_is_UI_request) {
951
-            $this->_set_nav_tabs();
952
-        }
953
-        // grab callback function
954
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
955
-        // check if callback has args
956
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
957
-        $error_msg = '';
958
-        // action right before calling route
959
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
960
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
961
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
962
-        }
963
-        // right before calling the route, let's remove _wp_http_referer from the
964
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
965
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
966
-        if (! empty($func)) {
967
-            if (is_array($func)) {
968
-                list($class, $method) = $func;
969
-            } elseif (strpos($func, '::') !== false) {
970
-                list($class, $method) = explode('::', $func);
971
-            } else {
972
-                $class  = $this;
973
-                $method = $func;
974
-            }
975
-            if (! (is_object($class) && $class === $this)) {
976
-                // send along this admin page object for access by addons.
977
-                $args['admin_page_object'] = $this;
978
-            }
979
-            if (
980
-                //is it a method on a class that doesn't work?
981
-                (
982
-                    (
983
-                        method_exists($class, $method)
984
-                        && call_user_func_array(array($class, $method), $args) === false
985
-                    )
986
-                    && (
987
-                        //is it a standalone function that doesn't work?
988
-                        function_exists($method)
989
-                        && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args))
990
-                           === false
991
-                    )
992
-                )
993
-                || (
994
-                    //is it neither a class method NOR a standalone function?
995
-                    ! method_exists($class, $method)
996
-                    && ! function_exists($method)
997
-                )
998
-            ) {
999
-                // user error msg
1000
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
1001
-                // developer error msg
1002
-                $error_msg .= '||';
1003
-                $error_msg .= sprintf(
1004
-                    __(
1005
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1006
-                        'event_espresso'
1007
-                    ),
1008
-                    $method
1009
-                );
1010
-            }
1011
-            if (! empty($error_msg)) {
1012
-                throw new EE_Error($error_msg);
1013
-            }
1014
-        }
1015
-        //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
1016
-        //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1017
-        if ($this->_is_UI_request === false
1018
-            && is_array($this->_route)
1019
-            && ! empty($this->_route['headers_sent_route'])
1020
-        ) {
1021
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1022
-        }
1023
-    }
1024
-
1025
-
1026
-
1027
-    /**
1028
-     * This method just allows the resetting of page properties in the case where a no headers
1029
-     * route redirects to a headers route in its route config.
1030
-     *
1031
-     * @since   4.3.0
1032
-     * @param  string $new_route New (non header) route to redirect to.
1033
-     * @return   void
1034
-     */
1035
-    protected function _reset_routing_properties($new_route)
1036
-    {
1037
-        $this->_is_UI_request = true;
1038
-        //now we set the current route to whatever the headers_sent_route is set at
1039
-        $this->_req_data['action'] = $new_route;
1040
-        //rerun page setup
1041
-        $this->_page_setup();
1042
-    }
1043
-
1044
-
1045
-
1046
-    /**
1047
-     * _add_query_arg
1048
-     * adds nonce to array of arguments then calls WP add_query_arg function
1049
-     *(internally just uses EEH_URL's function with the same name)
1050
-     *
1051
-     * @access public
1052
-     * @param array  $args
1053
-     * @param string $url
1054
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1055
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1056
-     *                                        Example usage: If the current page is:
1057
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1058
-     *                                        &action=default&event_id=20&month_range=March%202015
1059
-     *                                        &_wpnonce=5467821
1060
-     *                                        and you call:
1061
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1062
-     *                                        array(
1063
-     *                                        'action' => 'resend_something',
1064
-     *                                        'page=>espresso_registrations'
1065
-     *                                        ),
1066
-     *                                        $some_url,
1067
-     *                                        true
1068
-     *                                        );
1069
-     *                                        It will produce a url in this structure:
1070
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1071
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1072
-     *                                        month_range]=March%202015
1073
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1074
-     * @return string
1075
-     */
1076
-    public static function add_query_args_and_nonce(
1077
-        $args = array(),
1078
-        $url = false,
1079
-        $sticky = false,
1080
-        $exclude_nonce = false
1081
-    ) {
1082
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
1083
-        if ($sticky) {
1084
-            $request = $_REQUEST;
1085
-            unset($request['_wp_http_referer']);
1086
-            unset($request['wp_referer']);
1087
-            foreach ($request as $key => $value) {
1088
-                //do not add nonces
1089
-                if (strpos($key, 'nonce') !== false) {
1090
-                    continue;
1091
-                }
1092
-                $args['wp_referer[' . $key . ']'] = $value;
1093
-            }
1094
-        }
1095
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1096
-    }
1097
-
1098
-
1099
-
1100
-    /**
1101
-     * This returns a generated link that will load the related help tab.
1102
-     *
1103
-     * @param  string $help_tab_id the id for the connected help tab
1104
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1105
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1106
-     * @uses EEH_Template::get_help_tab_link()
1107
-     * @return string              generated link
1108
-     */
1109
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
1110
-    {
1111
-        return EEH_Template::get_help_tab_link(
1112
-            $help_tab_id,
1113
-            $this->page_slug,
1114
-            $this->_req_action,
1115
-            $icon_style,
1116
-            $help_text
1117
-        );
1118
-    }
1119
-
1120
-
1121
-
1122
-    /**
1123
-     * _add_help_tabs
1124
-     * Note child classes define their help tabs within the page_config array.
1125
-     *
1126
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1127
-     * @access protected
1128
-     * @return void
1129
-     */
1130
-    protected function _add_help_tabs()
1131
-    {
1132
-        $tour_buttons = '';
1133
-        if (isset($this->_page_config[$this->_req_action])) {
1134
-            $config = $this->_page_config[$this->_req_action];
1135
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1136
-            if (isset($this->_help_tour[$this->_req_action])) {
1137
-                $tb           = array();
1138
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1139
-                foreach ($this->_help_tour['tours'] as $tour) {
1140
-                    //if this is the end tour then we don't need to setup a button
1141
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1142
-                        continue;
1143
-                    }
1144
-                    $tb[] = '<button id="trigger-tour-'
1145
-                            . $tour->get_slug()
1146
-                            . '" class="button-primary trigger-ee-help-tour">'
1147
-                            . $tour->get_label()
1148
-                            . '</button>';
1149
-                }
1150
-                $tour_buttons .= implode('<br />', $tb);
1151
-                $tour_buttons .= '</div></div>';
1152
-            }
1153
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1154
-            if (is_array($config) && isset($config['help_sidebar'])) {
1155
-                //check that the callback given is valid
1156
-                if (! method_exists($this, $config['help_sidebar'])) {
1157
-                    throw new EE_Error(
1158
-                        sprintf(
1159
-                            __(
1160
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1161
-                                'event_espresso'
1162
-                            ),
1163
-                            $config['help_sidebar'],
1164
-                            get_class($this)
1165
-                        )
1166
-                    );
1167
-                }
1168
-                $content = apply_filters(
1169
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1170
-                    call_user_func(array($this, $config['help_sidebar']))
1171
-                );
1172
-                $content .= $tour_buttons; //add help tour buttons.
1173
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1174
-                $this->_current_screen->set_help_sidebar($content);
1175
-            }
1176
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1177
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1178
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1179
-            }
1180
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1181
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1182
-                $_ht['id']      = $this->page_slug;
1183
-                $_ht['title']   = __('Help Tours', 'event_espresso');
1184
-                $_ht['content'] = '<p>' . __(
1185
-                        'The buttons to the right allow you to start/restart any help tours available for this page',
1186
-                        'event_espresso'
1187
-                    ) . '</p>';
1188
-                $this->_current_screen->add_help_tab($_ht);
1189
-            }/**/
1190
-            if (! isset($config['help_tabs'])) {
1191
-                return;
1192
-            } //no help tabs for this route
1193
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1194
-                //we're here so there ARE help tabs!
1195
-                //make sure we've got what we need
1196
-                if (! isset($cfg['title'])) {
1197
-                    throw new EE_Error(
1198
-                        __(
1199
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1200
-                            'event_espresso'
1201
-                        )
1202
-                    );
1203
-                }
1204
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1205
-                    throw new EE_Error(
1206
-                        __(
1207
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1208
-                            'event_espresso'
1209
-                        )
1210
-                    );
1211
-                }
1212
-                //first priority goes to content.
1213
-                if (! empty($cfg['content'])) {
1214
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1215
-                    //second priority goes to filename
1216
-                } elseif (! empty($cfg['filename'])) {
1217
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1218
-                    //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1219
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1220
-                                                             . basename($this->_get_dir())
1221
-                                                             . '/help_tabs/'
1222
-                                                             . $cfg['filename']
1223
-                                                             . '.help_tab.php' : $file_path;
1224
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1225
-                    if (! is_readable($file_path) && ! isset($cfg['callback'])) {
1226
-                        EE_Error::add_error(
1227
-                            sprintf(
1228
-                                __(
1229
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1230
-                                    'event_espresso'
1231
-                                ),
1232
-                                $tab_id,
1233
-                                key($config),
1234
-                                $file_path
1235
-                            ),
1236
-                            __FILE__,
1237
-                            __FUNCTION__,
1238
-                            __LINE__
1239
-                        );
1240
-                        return;
1241
-                    }
1242
-                    $template_args['admin_page_obj'] = $this;
1243
-                    $content                         = EEH_Template::display_template($file_path, $template_args, true);
1244
-                } else {
1245
-                    $content = '';
1246
-                }
1247
-                //check if callback is valid
1248
-                if (empty($content) && (! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1249
-                    EE_Error::add_error(
1250
-                        sprintf(
1251
-                            __(
1252
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1253
-                                'event_espresso'
1254
-                            ),
1255
-                            $cfg['title']
1256
-                        ),
1257
-                        __FILE__,
1258
-                        __FUNCTION__,
1259
-                        __LINE__
1260
-                    );
1261
-                    return;
1262
-                }
1263
-                //setup config array for help tab method
1264
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1265
-                $_ht = array(
1266
-                    'id'       => $id,
1267
-                    'title'    => $cfg['title'],
1268
-                    'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1269
-                    'content'  => $content,
1270
-                );
1271
-                $this->_current_screen->add_help_tab($_ht);
1272
-            }
1273
-        }
1274
-    }
1275
-
1276
-
1277
-
1278
-    /**
1279
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1280
-     * an array with properties for setting up usage of the joyride plugin
1281
-     *
1282
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1283
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1284
-     *         _set_page_config() comments
1285
-     * @access protected
1286
-     * @return void
1287
-     */
1288
-    protected function _add_help_tour()
1289
-    {
1290
-        $tours            = array();
1291
-        $this->_help_tour = array();
1292
-        //exit early if help tours are turned off globally
1293
-        if (! EE_Registry::instance()->CFG->admin->help_tour_activation
1294
-            || (defined('EE_DISABLE_HELP_TOURS')
1295
-                && EE_DISABLE_HELP_TOURS)) {
1296
-            return;
1297
-        }
1298
-        //loop through _page_config to find any help_tour defined
1299
-        foreach ($this->_page_config as $route => $config) {
1300
-            //we're only going to set things up for this route
1301
-            if ($route !== $this->_req_action) {
1302
-                continue;
1303
-            }
1304
-            if (isset($config['help_tour'])) {
1305
-                foreach ($config['help_tour'] as $tour) {
1306
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1307
-                    //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1308
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1309
-                                                             . basename($this->_get_dir())
1310
-                                                             . '/help_tours/'
1311
-                                                             . $tour
1312
-                                                             . '.class.php' : $file_path;
1313
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1314
-                    if (! is_readable($file_path)) {
1315
-                        EE_Error::add_error(
1316
-                            sprintf(
1317
-                                __(
1318
-                                    'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1319
-                                    'event_espresso'
1320
-                                ),
1321
-                                $file_path,
1322
-                                $tour
1323
-                            ),
1324
-                            __FILE__,
1325
-                            __FUNCTION__,
1326
-                            __LINE__
1327
-                        );
1328
-                        return;
1329
-                    }
1330
-                    require_once $file_path;
1331
-                    if (! class_exists($tour)) {
1332
-                        $error_msg[] = sprintf(
1333
-                            __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1334
-                            $tour
1335
-                        );
1336
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1337
-                                __(
1338
-                                    'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1339
-                                    'event_espresso'
1340
-                                ),
1341
-                                $tour,
1342
-                                '<br />',
1343
-                                $tour,
1344
-                                $this->_req_action,
1345
-                                get_class($this)
1346
-                            );
1347
-                        throw new EE_Error(implode('||', $error_msg));
1348
-                    }
1349
-                    $a                          = new ReflectionClass($tour);
1350
-                    $tour_obj                   = $a->newInstance($this->_is_caf);
1351
-                    $tours[]                    = $tour_obj;
1352
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1353
-                }
1354
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1355
-                $end_stop_tour              = new EE_Help_Tour_final_stop($this->_is_caf);
1356
-                $tours[]                    = $end_stop_tour;
1357
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1358
-            }
1359
-        }
1360
-        if (! empty($tours)) {
1361
-            $this->_help_tour['tours'] = $tours;
1362
-        }
1363
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1364
-    }
1365
-
1366
-
1367
-
1368
-    /**
1369
-     * This simply sets up any qtips that have been defined in the page config
1370
-     *
1371
-     * @access protected
1372
-     * @return void
1373
-     */
1374
-    protected function _add_qtips()
1375
-    {
1376
-        if (isset($this->_route_config['qtips'])) {
1377
-            $qtips = (array)$this->_route_config['qtips'];
1378
-            //load qtip loader
1379
-            $path = array(
1380
-                $this->_get_dir() . '/qtips/',
1381
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1382
-            );
1383
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1384
-        }
1385
-    }
1386
-
1387
-
1388
-
1389
-    /**
1390
-     * _set_nav_tabs
1391
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1392
-     * wish to add additional tabs or modify accordingly.
1393
-     *
1394
-     * @access protected
1395
-     * @return void
1396
-     */
1397
-    protected function _set_nav_tabs()
1398
-    {
1399
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1400
-        $i = 0;
1401
-        foreach ($this->_page_config as $slug => $config) {
1402
-            if (! is_array($config)
1403
-                || (is_array($config)
1404
-                    && (isset($config['nav']) && ! $config['nav'])
1405
-                    || ! isset($config['nav']))) {
1406
-                continue;
1407
-            } //no nav tab for this config
1408
-            //check for persistent flag
1409
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1410
-                continue;
1411
-            } //nav tab is only to appear when route requested.
1412
-            if (! $this->check_user_access($slug, true)) {
1413
-                continue;
1414
-            } //no nav tab becasue current user does not have access.
1415
-            $css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1416
-            $this->_nav_tabs[$slug] = array(
1417
-                'url'       => isset($config['nav']['url'])
1418
-                    ? $config['nav']['url']
1419
-                    : self::add_query_args_and_nonce(
1420
-                        array('action' => $slug),
1421
-                        $this->_admin_base_url
1422
-                    ),
1423
-                'link_text' => isset($config['nav']['label'])
1424
-                    ? $config['nav']['label']
1425
-                    : ucwords(
1426
-                        str_replace('_', ' ', $slug)
1427
-                    ),
1428
-                'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1429
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1430
-            );
1431
-            $i++;
1432
-        }
1433
-        //if $this->_nav_tabs is empty then lets set the default
1434
-        if (empty($this->_nav_tabs)) {
1435
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1436
-                'url'       => $this->admin_base_url,
1437
-                'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1438
-                'css_class' => 'nav-tab-active',
1439
-                'order'     => 10,
1440
-            );
1441
-        }
1442
-        //now let's sort the tabs according to order
1443
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1444
-    }
1445
-
1446
-
1447
-
1448
-    /**
1449
-     * _set_current_labels
1450
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1451
-     * property array
1452
-     *
1453
-     * @access private
1454
-     * @return void
1455
-     */
1456
-    private function _set_current_labels()
1457
-    {
1458
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1459
-            foreach ($this->_route_config['labels'] as $label => $text) {
1460
-                if (is_array($text)) {
1461
-                    foreach ($text as $sublabel => $subtext) {
1462
-                        $this->_labels[$label][$sublabel] = $subtext;
1463
-                    }
1464
-                } else {
1465
-                    $this->_labels[$label] = $text;
1466
-                }
1467
-            }
1468
-        }
1469
-    }
1470
-
1471
-
1472
-
1473
-    /**
1474
-     *        verifies user access for this admin page
1475
-     *
1476
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1477
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1478
-     *                               return false if verify fail.
1479
-     * @return        BOOL|wp_die()
1480
-     */
1481
-    public function check_user_access($route_to_check = '', $verify_only = false)
1482
-    {
1483
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1484
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1485
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1486
-                          && is_array(
1487
-                              $this->_page_routes[$route_to_check]
1488
-                          )
1489
-                          && ! empty($this->_page_routes[$route_to_check]['capability'])
1490
-            ? $this->_page_routes[$route_to_check]['capability'] : null;
1491
-        if (empty($capability) && empty($route_to_check)) {
1492
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1493
-                : $this->_route['capability'];
1494
-        } else {
1495
-            $capability = empty($capability) ? 'manage_options' : $capability;
1496
-        }
1497
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1498
-        if ((! function_exists('is_admin')
1499
-             || ! EE_Registry::instance()->CAP->current_user_can(
1500
-                    $capability,
1501
-                    $this->page_slug
1502
-                    . '_'
1503
-                    . $route_to_check,
1504
-                    $id
1505
-                ))
1506
-            && ! defined('DOING_AJAX')) {
1507
-            if ($verify_only) {
1508
-                return false;
1509
-            } else {
1510
-                if (is_user_logged_in()) {
1511
-                    wp_die(__('You do not have access to this route.', 'event_espresso'));
1512
-                } else {
1513
-                    return false;
1514
-                }
1515
-            }
1516
-        }
1517
-        return true;
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * admin_init_global
1524
-     * This runs all the code that we want executed within the WP admin_init hook.
1525
-     * This method executes for ALL EE Admin pages.
1526
-     *
1527
-     * @access public
1528
-     * @return void
1529
-     */
1530
-    public function admin_init_global()
1531
-    {
1532
-    }
1533
-
1534
-
1535
-
1536
-    /**
1537
-     * wp_loaded_global
1538
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1539
-     * EE_Admin page and will execute on every EE Admin Page load
1540
-     *
1541
-     * @access public
1542
-     * @return void
1543
-     */
1544
-    public function wp_loaded()
1545
-    {
1546
-    }
1547
-
1548
-
1549
-
1550
-    /**
1551
-     * admin_notices
1552
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1553
-     * ALL EE_Admin pages.
1554
-     *
1555
-     * @access public
1556
-     * @return void
1557
-     */
1558
-    public function admin_notices_global()
1559
-    {
1560
-        $this->_display_no_javascript_warning();
1561
-        $this->_display_espresso_notices();
1562
-    }
1563
-
1564
-
1565
-
1566
-    public function network_admin_notices_global()
1567
-    {
1568
-        $this->_display_no_javascript_warning();
1569
-        $this->_display_espresso_notices();
1570
-    }
1571
-
1572
-
1573
-
1574
-    /**
1575
-     * admin_footer_scripts_global
1576
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1577
-     * will apply on ALL EE_Admin pages.
1578
-     *
1579
-     * @access public
1580
-     * @return void
1581
-     */
1582
-    public function admin_footer_scripts_global()
1583
-    {
1584
-        $this->_add_admin_page_ajax_loading_img();
1585
-        $this->_add_admin_page_overlay();
1586
-        //if metaboxes are present we need to add the nonce field
1587
-        if ((isset($this->_route_config['metaboxes'])
1588
-             || (isset($this->_route_config['has_metaboxes'])
1589
-                 && $this->_route_config['has_metaboxes'])
1590
-             || isset($this->_route_config['list_table']))) {
1591
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1592
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1593
-        }
1594
-    }
1595
-
1596
-
1597
-
1598
-    /**
1599
-     * admin_footer_global
1600
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on
1601
-     * ALL EE_Admin Pages.
1602
-     *
1603
-     * @access  public
1604
-     * @return  void
1605
-     */
1606
-    public function admin_footer_global()
1607
-    {
1608
-        //dialog container for dialog helper
1609
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1610
-        $d_cont .= '<div class="ee-notices"></div>';
1611
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1612
-        $d_cont .= '</div>';
1613
-        echo $d_cont;
1614
-        //help tour stuff?
1615
-        if (isset($this->_help_tour[$this->_req_action])) {
1616
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1617
-        }
1618
-        //current set timezone for timezone js
1619
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1620
-    }
1621
-
1622
-
1623
-
1624
-    /**
1625
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1626
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1627
-     * help popups then in your templates or your content you set "triggers" for the content using the
1628
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1629
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1630
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1631
-     * for the
1632
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1633
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1634
-     *    'help_trigger_id' => array(
1635
-     *        'title' => __('localized title for popup', 'event_espresso'),
1636
-     *        'content' => __('localized content for popup', 'event_espresso')
1637
-     *    )
1638
-     * );
1639
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1640
-     *
1641
-     * @access protected
1642
-     * @return string content
1643
-     */
1644
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1645
-    {
1646
-        $content       = '';
1647
-        $help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1648
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1649
-        //loop through the array and setup content
1650
-        foreach ($help_array as $trigger => $help) {
1651
-            //make sure the array is setup properly
1652
-            if (! isset($help['title']) || ! isset($help['content'])) {
1653
-                throw new EE_Error(
1654
-                    __(
1655
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1656
-                        'event_espresso'
1657
-                    )
1658
-                );
1659
-            }
1660
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1661
-            $template_args = array(
1662
-                'help_popup_id'      => $trigger,
1663
-                'help_popup_title'   => $help['title'],
1664
-                'help_popup_content' => $help['content'],
1665
-            );
1666
-            $content       .= EEH_Template::display_template($template_path, $template_args, true);
1667
-        }
1668
-        if ($display) {
1669
-            echo $content;
1670
-        } else {
1671
-            return $content;
1672
-        }
1673
-    }
1674
-
1675
-
1676
-
1677
-    /**
1678
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1679
-     *
1680
-     * @access private
1681
-     * @return array properly formatted array for help popup content
1682
-     */
1683
-    private function _get_help_content()
1684
-    {
1685
-        //what is the method we're looking for?
1686
-        $method_name = '_help_popup_content_' . $this->_req_action;
1687
-        //if method doesn't exist let's get out.
1688
-        if (! method_exists($this, $method_name)) {
1689
-            return array();
1690
-        }
1691
-        //k we're good to go let's retrieve the help array
1692
-        $help_array = call_user_func(array($this, $method_name));
1693
-        //make sure we've got an array!
1694
-        if (! is_array($help_array)) {
1695
-            throw new EE_Error(
1696
-                __(
1697
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1698
-                    'event_espresso'
1699
-                )
1700
-            );
1701
-        }
1702
-        return $help_array;
1703
-    }
1704
-
1705
-
1706
-
1707
-    /**
1708
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1709
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1710
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1711
-     *
1712
-     * @access protected
1713
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1714
-     * @param boolean $display    if false then we return the trigger string
1715
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1716
-     * @return string
1717
-     */
1718
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1719
-    {
1720
-        if (defined('DOING_AJAX')) {
1721
-            return;
1722
-        }
1723
-        //let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1724
-        $help_array   = $this->_get_help_content();
1725
-        $help_content = '';
1726
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1727
-            $help_array[$trigger_id] = array(
1728
-                'title'   => __('Missing Content', 'event_espresso'),
1729
-                'content' => __(
1730
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1731
-                    'event_espresso'
1732
-                ),
1733
-            );
1734
-            $help_content            = $this->_set_help_popup_content($help_array, false);
1735
-        }
1736
-        //let's setup the trigger
1737
-        $content = '<a class="ee-dialog" href="?height='
1738
-                   . $dimensions[0]
1739
-                   . '&width='
1740
-                   . $dimensions[1]
1741
-                   . '&inlineId='
1742
-                   . $trigger_id
1743
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1744
-        $content = $content . $help_content;
1745
-        if ($display) {
1746
-            echo $content;
1747
-        } else {
1748
-            return $content;
1749
-        }
1750
-    }
1751
-
1752
-
1753
-
1754
-    /**
1755
-     * _add_global_screen_options
1756
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1757
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1758
-     *
1759
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1760
-     *         see also WP_Screen object documents...
1761
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1762
-     * @abstract
1763
-     * @access private
1764
-     * @return void
1765
-     */
1766
-    private function _add_global_screen_options()
1767
-    {
1768
-    }
1769
-
1770
-
1771
-
1772
-    /**
1773
-     * _add_global_feature_pointers
1774
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1775
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1776
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1777
-     *
1778
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1779
-     *         extended) also see:
1780
-     * @link   http://eamann.com/tech/wordpress-portland/
1781
-     * @abstract
1782
-     * @access protected
1783
-     * @return void
1784
-     */
1785
-    private function _add_global_feature_pointers()
1786
-    {
1787
-    }
1788
-
1789
-
1790
-
1791
-    /**
1792
-     * load_global_scripts_styles
1793
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1794
-     *
1795
-     * @return void
1796
-     */
1797
-    public function load_global_scripts_styles()
1798
-    {
1799
-        /** STYLES **/
1800
-        // add debugging styles
1801
-        if (WP_DEBUG) {
1802
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1803
-        }
1804
-        // register all styles
1805
-        wp_register_style(
1806
-            'espresso-ui-theme',
1807
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1808
-            array(),
1809
-            EVENT_ESPRESSO_VERSION
1810
-        );
1811
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1812
-        //helpers styles
1813
-        wp_register_style(
1814
-            'ee-text-links',
1815
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1816
-            array(),
1817
-            EVENT_ESPRESSO_VERSION
1818
-        );
1819
-        /** SCRIPTS **/
1820
-        //register all scripts
1821
-        wp_register_script(
1822
-            'ee-dialog',
1823
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1824
-            array('jquery', 'jquery-ui-draggable'),
1825
-            EVENT_ESPRESSO_VERSION,
1826
-            true
1827
-        );
1828
-        wp_register_script(
1829
-            'ee_admin_js',
1830
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1831
-            array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1832
-            EVENT_ESPRESSO_VERSION,
1833
-            true
1834
-        );
1835
-        wp_register_script(
1836
-            'jquery-ui-timepicker-addon',
1837
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1838
-            array('jquery-ui-datepicker', 'jquery-ui-slider'),
1839
-            EVENT_ESPRESSO_VERSION,
1840
-            true
1841
-        );
1842
-        add_filter('FHEE_load_joyride', '__return_true');
1843
-        //script for sorting tables
1844
-        wp_register_script(
1845
-            'espresso_ajax_table_sorting',
1846
-            EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js",
1847
-            array('ee_admin_js', 'jquery-ui-sortable'),
1848
-            EVENT_ESPRESSO_VERSION,
1849
-            true
1850
-        );
1851
-        //script for parsing uri's
1852
-        wp_register_script(
1853
-            'ee-parse-uri',
1854
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1855
-            array(),
1856
-            EVENT_ESPRESSO_VERSION,
1857
-            true
1858
-        );
1859
-        //and parsing associative serialized form elements
1860
-        wp_register_script(
1861
-            'ee-serialize-full-array',
1862
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1863
-            array('jquery'),
1864
-            EVENT_ESPRESSO_VERSION,
1865
-            true
1866
-        );
1867
-        //helpers scripts
1868
-        wp_register_script(
1869
-            'ee-text-links',
1870
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1871
-            array('jquery'),
1872
-            EVENT_ESPRESSO_VERSION,
1873
-            true
1874
-        );
1875
-        wp_register_script(
1876
-            'ee-moment-core',
1877
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1878
-            array(),
1879
-            EVENT_ESPRESSO_VERSION,
1880
-            true
1881
-        );
1882
-        wp_register_script(
1883
-            'ee-moment',
1884
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1885
-            array('ee-moment-core'),
1886
-            EVENT_ESPRESSO_VERSION,
1887
-            true
1888
-        );
1889
-        wp_register_script(
1890
-            'ee-datepicker',
1891
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1892
-            array('jquery-ui-timepicker-addon', 'ee-moment'),
1893
-            EVENT_ESPRESSO_VERSION,
1894
-            true
1895
-        );
1896
-        //google charts
1897
-        wp_register_script(
1898
-            'google-charts',
1899
-            'https://www.gstatic.com/charts/loader.js',
1900
-            array(),
1901
-            EVENT_ESPRESSO_VERSION,
1902
-            false
1903
-        );
1904
-        // ENQUEUE ALL BASICS BY DEFAULT
1905
-        wp_enqueue_style('ee-admin-css');
1906
-        wp_enqueue_script('ee_admin_js');
1907
-        wp_enqueue_script('ee-accounting');
1908
-        wp_enqueue_script('jquery-validate');
1909
-        //taking care of metaboxes
1910
-        if (
1911
-            empty($this->_cpt_route)
1912
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1913
-        ) {
1914
-            wp_enqueue_script('dashboard');
1915
-        }
1916
-        // LOCALIZED DATA
1917
-        //localize script for ajax lazy loading
1918
-        $lazy_loader_container_ids = apply_filters(
1919
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1920
-            array('espresso_news_post_box_content')
1921
-        );
1922
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1923
-        /**
1924
-         * help tour stuff
1925
-         */
1926
-        if (! empty($this->_help_tour)) {
1927
-            //register the js for kicking things off
1928
-            wp_enqueue_script(
1929
-                'ee-help-tour',
1930
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1931
-                array('jquery-joyride'),
1932
-                EVENT_ESPRESSO_VERSION,
1933
-                true
1934
-            );
1935
-            //setup tours for the js tour object
1936
-            foreach ($this->_help_tour['tours'] as $tour) {
1937
-                $tours[] = array(
1938
-                    'id'      => $tour->get_slug(),
1939
-                    'options' => $tour->get_options(),
1940
-                );
1941
-            }
1942
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1943
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1944
-        }
1945
-    }
1946
-
1947
-
1948
-
1949
-    /**
1950
-     *        admin_footer_scripts_eei18n_js_strings
1951
-     *
1952
-     * @access        public
1953
-     * @return        void
1954
-     */
1955
-    public function admin_footer_scripts_eei18n_js_strings()
1956
-    {
1957
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1958
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __(
1959
-            'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1960
-            'event_espresso'
1961
-        );
1962
-        EE_Registry::$i18n_js_strings['January']        = __('January', 'event_espresso');
1963
-        EE_Registry::$i18n_js_strings['February']       = __('February', 'event_espresso');
1964
-        EE_Registry::$i18n_js_strings['March']          = __('March', 'event_espresso');
1965
-        EE_Registry::$i18n_js_strings['April']          = __('April', 'event_espresso');
1966
-        EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1967
-        EE_Registry::$i18n_js_strings['June']           = __('June', 'event_espresso');
1968
-        EE_Registry::$i18n_js_strings['July']           = __('July', 'event_espresso');
1969
-        EE_Registry::$i18n_js_strings['August']         = __('August', 'event_espresso');
1970
-        EE_Registry::$i18n_js_strings['September']      = __('September', 'event_espresso');
1971
-        EE_Registry::$i18n_js_strings['October']        = __('October', 'event_espresso');
1972
-        EE_Registry::$i18n_js_strings['November']       = __('November', 'event_espresso');
1973
-        EE_Registry::$i18n_js_strings['December']       = __('December', 'event_espresso');
1974
-        EE_Registry::$i18n_js_strings['Jan']            = __('Jan', 'event_espresso');
1975
-        EE_Registry::$i18n_js_strings['Feb']            = __('Feb', 'event_espresso');
1976
-        EE_Registry::$i18n_js_strings['Mar']            = __('Mar', 'event_espresso');
1977
-        EE_Registry::$i18n_js_strings['Apr']            = __('Apr', 'event_espresso');
1978
-        EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1979
-        EE_Registry::$i18n_js_strings['Jun']            = __('Jun', 'event_espresso');
1980
-        EE_Registry::$i18n_js_strings['Jul']            = __('Jul', 'event_espresso');
1981
-        EE_Registry::$i18n_js_strings['Aug']            = __('Aug', 'event_espresso');
1982
-        EE_Registry::$i18n_js_strings['Sep']            = __('Sep', 'event_espresso');
1983
-        EE_Registry::$i18n_js_strings['Oct']            = __('Oct', 'event_espresso');
1984
-        EE_Registry::$i18n_js_strings['Nov']            = __('Nov', 'event_espresso');
1985
-        EE_Registry::$i18n_js_strings['Dec']            = __('Dec', 'event_espresso');
1986
-        EE_Registry::$i18n_js_strings['Sunday']         = __('Sunday', 'event_espresso');
1987
-        EE_Registry::$i18n_js_strings['Monday']         = __('Monday', 'event_espresso');
1988
-        EE_Registry::$i18n_js_strings['Tuesday']        = __('Tuesday', 'event_espresso');
1989
-        EE_Registry::$i18n_js_strings['Wednesday']      = __('Wednesday', 'event_espresso');
1990
-        EE_Registry::$i18n_js_strings['Thursday']       = __('Thursday', 'event_espresso');
1991
-        EE_Registry::$i18n_js_strings['Friday']         = __('Friday', 'event_espresso');
1992
-        EE_Registry::$i18n_js_strings['Saturday']       = __('Saturday', 'event_espresso');
1993
-        EE_Registry::$i18n_js_strings['Sun']            = __('Sun', 'event_espresso');
1994
-        EE_Registry::$i18n_js_strings['Mon']            = __('Mon', 'event_espresso');
1995
-        EE_Registry::$i18n_js_strings['Tue']            = __('Tue', 'event_espresso');
1996
-        EE_Registry::$i18n_js_strings['Wed']            = __('Wed', 'event_espresso');
1997
-        EE_Registry::$i18n_js_strings['Thu']            = __('Thu', 'event_espresso');
1998
-        EE_Registry::$i18n_js_strings['Fri']            = __('Fri', 'event_espresso');
1999
-        EE_Registry::$i18n_js_strings['Sat']            = __('Sat', 'event_espresso');
2000
-    }
2001
-
2002
-
2003
-
2004
-    /**
2005
-     *        load enhanced xdebug styles for ppl with failing eyesight
2006
-     *
2007
-     * @access        public
2008
-     * @return        void
2009
-     */
2010
-    public function add_xdebug_style()
2011
-    {
2012
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2013
-    }
2014
-
2015
-
2016
-    /************************/
2017
-    /** LIST TABLE METHODS **/
2018
-    /************************/
2019
-    /**
2020
-     * this sets up the list table if the current view requires it.
2021
-     *
2022
-     * @access protected
2023
-     * @return void
2024
-     */
2025
-    protected function _set_list_table()
2026
-    {
2027
-        //first is this a list_table view?
2028
-        if (! isset($this->_route_config['list_table'])) {
2029
-            return;
2030
-        } //not a list_table view so get out.
2031
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
2032
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
2033
-            //user error msg
2034
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
2035
-            //developer error msg
2036
-            $error_msg .= '||' . sprintf(
2037
-                    __(
2038
-                        'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2039
-                        'event_espresso'
2040
-                    ),
2041
-                    $this->_req_action,
2042
-                    '_set_list_table_views_' . $this->_req_action
2043
-                );
2044
-            throw new EE_Error($error_msg);
2045
-        }
2046
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2047
-        $this->_views = apply_filters(
2048
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2049
-            $this->_views
2050
-        );
2051
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2052
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2053
-        $this->_set_list_table_view();
2054
-        $this->_set_list_table_object();
2055
-    }
2056
-
2057
-
2058
-
2059
-    /**
2060
-     *        set current view for List Table
2061
-     *
2062
-     * @access public
2063
-     * @return array
2064
-     */
2065
-    protected function _set_list_table_view()
2066
-    {
2067
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2068
-        // looking at active items or dumpster diving ?
2069
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2070
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2071
-        } else {
2072
-            $this->_view = sanitize_key($this->_req_data['status']);
2073
-        }
2074
-    }
2075
-
2076
-
2077
-
2078
-    /**
2079
-     * _set_list_table_object
2080
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2081
-     *
2082
-     * @throws \EE_Error
2083
-     */
2084
-    protected function _set_list_table_object()
2085
-    {
2086
-        if (isset($this->_route_config['list_table'])) {
2087
-            if (! class_exists($this->_route_config['list_table'])) {
2088
-                throw new EE_Error(
2089
-                    sprintf(
2090
-                        __(
2091
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2092
-                            'event_espresso'
2093
-                        ),
2094
-                        $this->_route_config['list_table'],
2095
-                        get_class($this)
2096
-                    )
2097
-                );
2098
-            }
2099
-            $list_table               = $this->_route_config['list_table'];
2100
-            $this->_list_table_object = new $list_table($this);
2101
-        }
2102
-    }
2103
-
2104
-
2105
-
2106
-    /**
2107
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2108
-     *
2109
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2110
-     *                                                    urls.  The array should be indexed by the view it is being
2111
-     *                                                    added to.
2112
-     * @return array
2113
-     */
2114
-    public function get_list_table_view_RLs($extra_query_args = array())
2115
-    {
2116
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2117
-        if (empty($this->_views)) {
2118
-            $this->_views = array();
2119
-        }
2120
-        // cycle thru views
2121
-        foreach ($this->_views as $key => $view) {
2122
-            $query_args = array();
2123
-            // check for current view
2124
-            $this->_views[$key]['class']               = $this->_view == $view['slug'] ? 'current' : '';
2125
-            $query_args['action']                      = $this->_req_action;
2126
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2127
-            $query_args['status']                      = $view['slug'];
2128
-            //merge any other arguments sent in.
2129
-            if (isset($extra_query_args[$view['slug']])) {
2130
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2131
-            }
2132
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2133
-        }
2134
-        return $this->_views;
2135
-    }
2136
-
2137
-
2138
-
2139
-    /**
2140
-     * _entries_per_page_dropdown
2141
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
2142
-     *
2143
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2144
-     *         WP does it.
2145
-     * @access protected
2146
-     * @param int $max_entries total number of rows in the table
2147
-     * @return string
2148
-     */
2149
-    protected function _entries_per_page_dropdown($max_entries = false)
2150
-    {
2151
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2152
-        $values   = array(10, 25, 50, 100);
2153
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2154
-        if ($max_entries) {
2155
-            $values[] = $max_entries;
2156
-            sort($values);
2157
-        }
2158
-        $entries_per_page_dropdown = '
146
+	// yes / no array for admin form fields
147
+	protected $_yes_no_values = array();
148
+
149
+	//some default things shared by all child classes
150
+	protected $_default_espresso_metaboxes;
151
+
152
+	/**
153
+	 *    EE_Registry Object
154
+	 *
155
+	 * @var    EE_Registry
156
+	 * @access    protected
157
+	 */
158
+	protected $EE = null;
159
+
160
+
161
+
162
+	/**
163
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
164
+	 *
165
+	 * @var boolean
166
+	 */
167
+	protected $_is_caf = false;
168
+
169
+
170
+
171
+	/**
172
+	 * @Constructor
173
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
174
+	 * @access public
175
+	 */
176
+	public function __construct($routing = true)
177
+	{
178
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
179
+			$this->_is_caf = true;
180
+		}
181
+		$this->_yes_no_values = array(
182
+			array('id' => true, 'text' => __('Yes', 'event_espresso')),
183
+			array('id' => false, 'text' => __('No', 'event_espresso')),
184
+		);
185
+		//set the _req_data property.
186
+		$this->_req_data = array_merge($_GET, $_POST);
187
+		//routing enabled?
188
+		$this->_routing = $routing;
189
+		//set initial page props (child method)
190
+		$this->_init_page_props();
191
+		//set global defaults
192
+		$this->_set_defaults();
193
+		//set early because incoming requests could be ajax related and we need to register those hooks.
194
+		$this->_global_ajax_hooks();
195
+		$this->_ajax_hooks();
196
+		//other_page_hooks have to be early too.
197
+		$this->_do_other_page_hooks();
198
+		//This just allows us to have extending classes do something specific
199
+		// before the parent constructor runs _page_setup().
200
+		if (method_exists($this, '_before_page_setup')) {
201
+			$this->_before_page_setup();
202
+		}
203
+		//set up page dependencies
204
+		$this->_page_setup();
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * _init_page_props
211
+	 * Child classes use to set at least the following properties:
212
+	 * $page_slug.
213
+	 * $page_label.
214
+	 *
215
+	 * @abstract
216
+	 * @access protected
217
+	 * @return void
218
+	 */
219
+	abstract protected function _init_page_props();
220
+
221
+
222
+
223
+	/**
224
+	 * _ajax_hooks
225
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
226
+	 * Note: within the ajax callback methods.
227
+	 *
228
+	 * @abstract
229
+	 * @access protected
230
+	 * @return void
231
+	 */
232
+	abstract protected function _ajax_hooks();
233
+
234
+
235
+
236
+	/**
237
+	 * _define_page_props
238
+	 * child classes define page properties in here.  Must include at least:
239
+	 * $_admin_base_url = base_url for all admin pages
240
+	 * $_admin_page_title = default admin_page_title for admin pages
241
+	 * $_labels = array of default labels for various automatically generated elements:
242
+	 *    array(
243
+	 *        'buttons' => array(
244
+	 *            'add' => __('label for add new button'),
245
+	 *            'edit' => __('label for edit button'),
246
+	 *            'delete' => __('label for delete button')
247
+	 *            )
248
+	 *        )
249
+	 *
250
+	 * @abstract
251
+	 * @access protected
252
+	 * @return void
253
+	 */
254
+	abstract protected function _define_page_props();
255
+
256
+
257
+
258
+	/**
259
+	 * _set_page_routes
260
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
261
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
262
+	 * have a 'default' route. Here's the format
263
+	 * $this->_page_routes = array(
264
+	 *        'default' => array(
265
+	 *            'func' => '_default_method_handling_route',
266
+	 *            'args' => array('array','of','args'),
267
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
268
+	 *            ajax request, backend processing)
269
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
270
+	 *            headers route after.  The string you enter here should match the defined route reference for a
271
+	 *            headers sent route.
272
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
273
+	 *            this route.
274
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
275
+	 *            checks).
276
+	 *        ),
277
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
278
+	 *        handling method.
279
+	 *        )
280
+	 * )
281
+	 *
282
+	 * @abstract
283
+	 * @access protected
284
+	 * @return void
285
+	 */
286
+	abstract protected function _set_page_routes();
287
+
288
+
289
+
290
+	/**
291
+	 * _set_page_config
292
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
293
+	 * array corresponds to the page_route for the loaded page. Format:
294
+	 * $this->_page_config = array(
295
+	 *        'default' => array(
296
+	 *            'labels' => array(
297
+	 *                'buttons' => array(
298
+	 *                    'add' => __('label for adding item'),
299
+	 *                    'edit' => __('label for editing item'),
300
+	 *                    'delete' => __('label for deleting item')
301
+	 *                ),
302
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
303
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
304
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
305
+	 *            _define_page_props() method
306
+	 *            'nav' => array(
307
+	 *                'label' => __('Label for Tab', 'event_espresso').
308
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
309
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
310
+	 *                'order' => 10, //required to indicate tab position.
311
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
312
+	 *                displayed then add this parameter.
313
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
314
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
315
+	 *            metaboxes set for eventespresso admin pages.
316
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
317
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
318
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
319
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
320
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
321
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
322
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
323
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
324
+	 *            want to display.
325
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
326
+	 *                'tab_id' => array(
327
+	 *                    'title' => 'tab_title',
328
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
329
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
330
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
331
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
332
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
333
+	 *                    attempt to use the callback which should match the name of a method in the class
334
+	 *                    ),
335
+	 *                'tab2_id' => array(
336
+	 *                    'title' => 'tab2 title',
337
+	 *                    'filename' => 'file_name_2'
338
+	 *                    'callback' => 'callback_method_for_content',
339
+	 *                 ),
340
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
341
+	 *            help tab area on an admin page. @link
342
+	 *            http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
343
+	 *            'help_tour' => array(
344
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located
345
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
346
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
347
+	 *            ),
348
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is
349
+	 *            true if it isn't present).  To remove the requirement for a nonce check when this route is visited
350
+	 *            just set
351
+	 *            'require_nonce' to FALSE
352
+	 *            )
353
+	 * )
354
+	 *
355
+	 * @abstract
356
+	 * @access protected
357
+	 * @return void
358
+	 */
359
+	abstract protected function _set_page_config();
360
+
361
+
362
+
363
+
364
+
365
+	/** end sample help_tour methods **/
366
+	/**
367
+	 * _add_screen_options
368
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
369
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
370
+	 * to a particular view.
371
+	 *
372
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
373
+	 *         see also WP_Screen object documents...
374
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
375
+	 * @abstract
376
+	 * @access protected
377
+	 * @return void
378
+	 */
379
+	abstract protected function _add_screen_options();
380
+
381
+
382
+
383
+	/**
384
+	 * _add_feature_pointers
385
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
386
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
387
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
388
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
389
+	 * extended) also see:
390
+	 *
391
+	 * @link   http://eamann.com/tech/wordpress-portland/
392
+	 * @abstract
393
+	 * @access protected
394
+	 * @return void
395
+	 */
396
+	abstract protected function _add_feature_pointers();
397
+
398
+
399
+
400
+	/**
401
+	 * load_scripts_styles
402
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
403
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
404
+	 * scripts/styles per view by putting them in a dynamic function in this format
405
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
406
+	 *
407
+	 * @abstract
408
+	 * @access public
409
+	 * @return void
410
+	 */
411
+	abstract public function load_scripts_styles();
412
+
413
+
414
+
415
+	/**
416
+	 * admin_init
417
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
418
+	 * all pages/views loaded by child class.
419
+	 *
420
+	 * @abstract
421
+	 * @access public
422
+	 * @return void
423
+	 */
424
+	abstract public function admin_init();
425
+
426
+
427
+
428
+	/**
429
+	 * admin_notices
430
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
431
+	 * all pages/views loaded by child class.
432
+	 *
433
+	 * @abstract
434
+	 * @access public
435
+	 * @return void
436
+	 */
437
+	abstract public function admin_notices();
438
+
439
+
440
+
441
+	/**
442
+	 * admin_footer_scripts
443
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
+	 * will apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @access public
447
+	 * @return void
448
+	 */
449
+	abstract public function admin_footer_scripts();
450
+
451
+
452
+
453
+	/**
454
+	 * admin_footer
455
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
456
+	 * apply to all pages/views loaded by child class.
457
+	 *
458
+	 * @access  public
459
+	 * @return void
460
+	 */
461
+	public function admin_footer()
462
+	{
463
+	}
464
+
465
+
466
+
467
+	/**
468
+	 * _global_ajax_hooks
469
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
470
+	 * Note: within the ajax callback methods.
471
+	 *
472
+	 * @abstract
473
+	 * @access protected
474
+	 * @return void
475
+	 */
476
+	protected function _global_ajax_hooks()
477
+	{
478
+		//for lazy loading of metabox content
479
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
480
+	}
481
+
482
+
483
+
484
+	public function ajax_metabox_content()
485
+	{
486
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
487
+		$url       = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
488
+		self::cached_rss_display($contentid, $url);
489
+		wp_die();
490
+	}
491
+
492
+
493
+
494
+	/**
495
+	 * _page_setup
496
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
497
+	 * doesn't match the object.
498
+	 *
499
+	 * @final
500
+	 * @access protected
501
+	 * @return void
502
+	 */
503
+	final protected function _page_setup()
504
+	{
505
+		//requires?
506
+		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
507
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
508
+		//next verify if we need to load anything...
509
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
510
+		$this->page_folder   = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
511
+		global $ee_menu_slugs;
512
+		$ee_menu_slugs = (array)$ee_menu_slugs;
513
+		if ((! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
514
+			return;
515
+		}
516
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
517
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
518
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1
519
+				? $this->_req_data['action2'] : $this->_req_data['action'];
520
+		}
521
+		// then set blank or -1 action values to 'default'
522
+		$this->_req_action = isset($this->_req_data['action'])
523
+							 && ! empty($this->_req_data['action'])
524
+							 && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
525
+		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
526
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route'])
527
+			? $this->_req_data['route'] : $this->_req_action;
528
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
529
+		$this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route']
530
+			: $this->_req_action;
531
+		$this->_current_view = $this->_req_action;
532
+		$this->_req_nonce    = $this->_req_action . '_nonce';
533
+		$this->_define_page_props();
534
+		$this->_current_page_view_url = add_query_arg(
535
+			array('page' => $this->_current_page, 'action' => $this->_current_view),
536
+			$this->_admin_base_url
537
+		);
538
+		//default things
539
+		$this->_default_espresso_metaboxes = array(
540
+			'_espresso_news_post_box',
541
+			'_espresso_links_post_box',
542
+			'_espresso_ratings_request',
543
+			'_espresso_sponsors_post_box',
544
+		);
545
+		//set page configs
546
+		$this->_set_page_routes();
547
+		$this->_set_page_config();
548
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
549
+		if (isset($this->_req_data['wp_referer'])) {
550
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
551
+		}
552
+		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
553
+		if (method_exists($this, '_extend_page_config')) {
554
+			$this->_extend_page_config();
555
+		}
556
+		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
557
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
558
+			$this->_extend_page_config_for_cpt();
559
+		}
560
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
561
+		$this->_page_routes = apply_filters(
562
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
563
+			$this->_page_routes,
564
+			$this
565
+		);
566
+		$this->_page_config = apply_filters(
567
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
568
+			$this->_page_config,
569
+			$this
570
+		);
571
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
573
+			add_action(
574
+				'AHEE__EE_Admin_Page__route_admin_request',
575
+				array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
576
+				10,
577
+				2
578
+			);
579
+		}
580
+		//next route only if routing enabled
581
+		if ($this->_routing && ! defined('DOING_AJAX')) {
582
+			$this->_verify_routes();
583
+			//next let's just check user_access and kill if no access
584
+			$this->check_user_access();
585
+			if ($this->_is_UI_request) {
586
+				//admin_init stuff - global, all views for this page class, specific view
587
+				add_action('admin_init', array($this, 'admin_init'), 10);
588
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
590
+				}
591
+			} else {
592
+				//hijack regular WP loading and route admin request immediately
593
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
594
+				$this->route_admin_request();
595
+			}
596
+		}
597
+	}
598
+
599
+
600
+
601
+	/**
602
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
603
+	 *
604
+	 * @access private
605
+	 * @return void
606
+	 */
607
+	private function _do_other_page_hooks()
608
+	{
609
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
610
+		foreach ($registered_pages as $page) {
611
+			//now let's setup the file name and class that should be present
612
+			$classname = str_replace('.class.php', '', $page);
613
+			//autoloaders should take care of loading file
614
+			if (! class_exists($classname)) {
615
+				$error_msg[] = sprintf(
616
+					esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'),
617
+					$page
618
+				);
619
+				$error_msg[] = $error_msg[0]
620
+							   . "\r\n"
621
+							   . sprintf(
622
+								   esc_html__(
623
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
624
+									   'event_espresso'
625
+								   ),
626
+								   $page,
627
+								   '<br />',
628
+								   '<strong>' . $classname . '</strong>'
629
+							   );
630
+				throw new EE_Error(implode('||', $error_msg));
631
+			}
632
+			$a = new ReflectionClass($classname);
633
+			//notice we are passing the instance of this class to the hook object.
634
+			$hookobj[] = $a->newInstance($this);
635
+		}
636
+	}
637
+
638
+
639
+
640
+	public function load_page_dependencies()
641
+	{
642
+		try {
643
+			$this->_load_page_dependencies();
644
+		} catch (EE_Error $e) {
645
+			$e->get_error();
646
+		}
647
+	}
648
+
649
+
650
+
651
+	/**
652
+	 * load_page_dependencies
653
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
654
+	 *
655
+	 * @access public
656
+	 * @return void
657
+	 */
658
+	protected function _load_page_dependencies()
659
+	{
660
+		//let's set the current_screen and screen options to override what WP set
661
+		$this->_current_screen = get_current_screen();
662
+		//load admin_notices - global, page class, and view specific
663
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
664
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
665
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
666
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
667
+		}
668
+		//load network admin_notices - global, page class, and view specific
669
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
670
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
671
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
672
+		}
673
+		//this will save any per_page screen options if they are present
674
+		$this->_set_per_page_screen_options();
675
+		//setup list table properties
676
+		$this->_set_list_table();
677
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
678
+		$this->_add_registered_meta_boxes();
679
+		$this->_add_screen_columns();
680
+		//add screen options - global, page child class, and view specific
681
+		$this->_add_global_screen_options();
682
+		$this->_add_screen_options();
683
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
684
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
685
+		}
686
+		//add help tab(s) and tours- set via page_config and qtips.
687
+		$this->_add_help_tour();
688
+		$this->_add_help_tabs();
689
+		$this->_add_qtips();
690
+		//add feature_pointers - global, page child class, and view specific
691
+		$this->_add_feature_pointers();
692
+		$this->_add_global_feature_pointers();
693
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
694
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
695
+		}
696
+		//enqueue scripts/styles - global, page class, and view specific
697
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
698
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
699
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
700
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
701
+		}
702
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
703
+		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
704
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
705
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
706
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
707
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
708
+		}
709
+		//admin footer scripts
710
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
711
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
712
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
713
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
714
+		}
715
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
716
+		//targeted hook
717
+		do_action(
718
+			'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action
719
+		);
720
+	}
721
+
722
+
723
+
724
+	/**
725
+	 * _set_defaults
726
+	 * This sets some global defaults for class properties.
727
+	 */
728
+	private function _set_defaults()
729
+	{
730
+		$this->_current_screen      = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
731
+		$this->_nav_tabs            = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
732
+		$this->default_nav_tab_name = 'overview';
733
+		//init template args
734
+		$this->_template_args = array(
735
+			'admin_page_header'  => '',
736
+			'admin_page_content' => '',
737
+			'post_body_content'  => '',
738
+			'before_list_table'  => '',
739
+			'after_list_table'   => '',
740
+		);
741
+	}
742
+
743
+
744
+
745
+	/**
746
+	 * route_admin_request
747
+	 *
748
+	 * @see    _route_admin_request()
749
+	 * @access public
750
+	 * @return void|exception error
751
+	 */
752
+	public function route_admin_request()
753
+	{
754
+		try {
755
+			$this->_route_admin_request();
756
+		} catch (EE_Error $e) {
757
+			$e->get_error();
758
+		}
759
+	}
760
+
761
+
762
+
763
+	public function set_wp_page_slug($wp_page_slug)
764
+	{
765
+		$this->_wp_page_slug = $wp_page_slug;
766
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
767
+		if (is_network_admin()) {
768
+			$this->_wp_page_slug .= '-network';
769
+		}
770
+	}
771
+
772
+
773
+
774
+	/**
775
+	 * _verify_routes
776
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
777
+	 * we know if we need to drop out.
778
+	 *
779
+	 * @access protected
780
+	 * @return void
781
+	 */
782
+	protected function _verify_routes()
783
+	{
784
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
785
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
786
+			return false;
787
+		}
788
+		$this->_route = false;
789
+		$func         = false;
790
+		$args         = array();
791
+		// check that the page_routes array is not empty
792
+		if (empty($this->_page_routes)) {
793
+			// user error msg
794
+			$error_msg = sprintf(
795
+				__('No page routes have been set for the %s admin page.', 'event_espresso'),
796
+				$this->_admin_page_title
797
+			);
798
+			// developer error msg
799
+			$error_msg .= '||' . $error_msg . __(
800
+					' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
801
+					'event_espresso'
802
+				);
803
+			throw new EE_Error($error_msg);
804
+		}
805
+		// and that the requested page route exists
806
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
807
+			$this->_route        = $this->_page_routes[$this->_req_action];
808
+			$this->_route_config = isset($this->_page_config[$this->_req_action])
809
+				? $this->_page_config[$this->_req_action] : array();
810
+		} else {
811
+			// user error msg
812
+			$error_msg = sprintf(
813
+				__('The requested page route does not exist for the %s admin page.', 'event_espresso'),
814
+				$this->_admin_page_title
815
+			);
816
+			// developer error msg
817
+			$error_msg .= '||' . $error_msg . sprintf(
818
+					__(
819
+						' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
820
+						'event_espresso'
821
+					),
822
+					$this->_req_action
823
+				);
824
+			throw new EE_Error($error_msg);
825
+		}
826
+		// and that a default route exists
827
+		if (! array_key_exists('default', $this->_page_routes)) {
828
+			// user error msg
829
+			$error_msg = sprintf(
830
+				__('A default page route has not been set for the % admin page.', 'event_espresso'),
831
+				$this->_admin_page_title
832
+			);
833
+			// developer error msg
834
+			$error_msg .= '||' . $error_msg . __(
835
+					' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
836
+					'event_espresso'
837
+				);
838
+			throw new EE_Error($error_msg);
839
+		}
840
+		//first lets' catch if the UI request has EVER been set.
841
+		if ($this->_is_UI_request === null) {
842
+			//lets set if this is a UI request or not.
843
+			$this->_is_UI_request = (! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
844
+				? true : false;
845
+			//wait a minute... we might have a noheader in the route array
846
+			$this->_is_UI_request = is_array($this->_route)
847
+									&& isset($this->_route['noheader'])
848
+									&& $this->_route['noheader'] ? false : $this->_is_UI_request;
849
+		}
850
+		$this->_set_current_labels();
851
+	}
852
+
853
+
854
+
855
+	/**
856
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
857
+	 *
858
+	 * @param  string $route the route name we're verifying
859
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
860
+	 */
861
+	protected function _verify_route($route)
862
+	{
863
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
864
+			return true;
865
+		} else {
866
+			// user error msg
867
+			$error_msg = sprintf(
868
+				__('The given page route does not exist for the %s admin page.', 'event_espresso'),
869
+				$this->_admin_page_title
870
+			);
871
+			// developer error msg
872
+			$error_msg .= '||' . $error_msg . sprintf(
873
+					__(
874
+						' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
875
+						'event_espresso'
876
+					),
877
+					$route
878
+				);
879
+			throw new EE_Error($error_msg);
880
+		}
881
+	}
882
+
883
+
884
+
885
+	/**
886
+	 * perform nonce verification
887
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
888
+	 * using this method (and save retyping!)
889
+	 *
890
+	 * @param  string $nonce     The nonce sent
891
+	 * @param  string $nonce_ref The nonce reference string (name0)
892
+	 * @return mixed (bool|die)
893
+	 */
894
+	protected function _verify_nonce($nonce, $nonce_ref)
895
+	{
896
+		// verify nonce against expected value
897
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
898
+			// these are not the droids you are looking for !!!
899
+			$msg = sprintf(
900
+				__('%sNonce Fail.%s', 'event_espresso'),
901
+				'<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">',
902
+				'</a>'
903
+			);
904
+			if (WP_DEBUG) {
905
+				$msg .= "\n  " . sprintf(
906
+						__(
907
+							'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
908
+							'event_espresso'
909
+						),
910
+						__CLASS__
911
+					);
912
+			}
913
+			if (! defined('DOING_AJAX')) {
914
+				wp_die($msg);
915
+			} else {
916
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
917
+				$this->_return_json();
918
+			}
919
+		}
920
+	}
921
+
922
+
923
+
924
+	/**
925
+	 * _route_admin_request()
926
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
927
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
928
+	 * in the page routes and then will try to load the corresponding method.
929
+	 *
930
+	 * @access protected
931
+	 * @return void
932
+	 * @throws \EE_Error
933
+	 */
934
+	protected function _route_admin_request()
935
+	{
936
+		if (! $this->_is_UI_request) {
937
+			$this->_verify_routes();
938
+		}
939
+		$nonce_check = isset($this->_route_config['require_nonce'])
940
+			? $this->_route_config['require_nonce']
941
+			: true;
942
+		if ($this->_req_action !== 'default' && $nonce_check) {
943
+			// set nonce from post data
944
+			$nonce = isset($this->_req_data[$this->_req_nonce])
945
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
946
+				: '';
947
+			$this->_verify_nonce($nonce, $this->_req_nonce);
948
+		}
949
+		//set the nav_tabs array but ONLY if this is  UI_request
950
+		if ($this->_is_UI_request) {
951
+			$this->_set_nav_tabs();
952
+		}
953
+		// grab callback function
954
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
955
+		// check if callback has args
956
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
957
+		$error_msg = '';
958
+		// action right before calling route
959
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
960
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
961
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
962
+		}
963
+		// right before calling the route, let's remove _wp_http_referer from the
964
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
965
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
966
+		if (! empty($func)) {
967
+			if (is_array($func)) {
968
+				list($class, $method) = $func;
969
+			} elseif (strpos($func, '::') !== false) {
970
+				list($class, $method) = explode('::', $func);
971
+			} else {
972
+				$class  = $this;
973
+				$method = $func;
974
+			}
975
+			if (! (is_object($class) && $class === $this)) {
976
+				// send along this admin page object for access by addons.
977
+				$args['admin_page_object'] = $this;
978
+			}
979
+			if (
980
+				//is it a method on a class that doesn't work?
981
+				(
982
+					(
983
+						method_exists($class, $method)
984
+						&& call_user_func_array(array($class, $method), $args) === false
985
+					)
986
+					&& (
987
+						//is it a standalone function that doesn't work?
988
+						function_exists($method)
989
+						&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args))
990
+						   === false
991
+					)
992
+				)
993
+				|| (
994
+					//is it neither a class method NOR a standalone function?
995
+					! method_exists($class, $method)
996
+					&& ! function_exists($method)
997
+				)
998
+			) {
999
+				// user error msg
1000
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
1001
+				// developer error msg
1002
+				$error_msg .= '||';
1003
+				$error_msg .= sprintf(
1004
+					__(
1005
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1006
+						'event_espresso'
1007
+					),
1008
+					$method
1009
+				);
1010
+			}
1011
+			if (! empty($error_msg)) {
1012
+				throw new EE_Error($error_msg);
1013
+			}
1014
+		}
1015
+		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
1016
+		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1017
+		if ($this->_is_UI_request === false
1018
+			&& is_array($this->_route)
1019
+			&& ! empty($this->_route['headers_sent_route'])
1020
+		) {
1021
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1022
+		}
1023
+	}
1024
+
1025
+
1026
+
1027
+	/**
1028
+	 * This method just allows the resetting of page properties in the case where a no headers
1029
+	 * route redirects to a headers route in its route config.
1030
+	 *
1031
+	 * @since   4.3.0
1032
+	 * @param  string $new_route New (non header) route to redirect to.
1033
+	 * @return   void
1034
+	 */
1035
+	protected function _reset_routing_properties($new_route)
1036
+	{
1037
+		$this->_is_UI_request = true;
1038
+		//now we set the current route to whatever the headers_sent_route is set at
1039
+		$this->_req_data['action'] = $new_route;
1040
+		//rerun page setup
1041
+		$this->_page_setup();
1042
+	}
1043
+
1044
+
1045
+
1046
+	/**
1047
+	 * _add_query_arg
1048
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1049
+	 *(internally just uses EEH_URL's function with the same name)
1050
+	 *
1051
+	 * @access public
1052
+	 * @param array  $args
1053
+	 * @param string $url
1054
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1055
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1056
+	 *                                        Example usage: If the current page is:
1057
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1058
+	 *                                        &action=default&event_id=20&month_range=March%202015
1059
+	 *                                        &_wpnonce=5467821
1060
+	 *                                        and you call:
1061
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1062
+	 *                                        array(
1063
+	 *                                        'action' => 'resend_something',
1064
+	 *                                        'page=>espresso_registrations'
1065
+	 *                                        ),
1066
+	 *                                        $some_url,
1067
+	 *                                        true
1068
+	 *                                        );
1069
+	 *                                        It will produce a url in this structure:
1070
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1071
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1072
+	 *                                        month_range]=March%202015
1073
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1074
+	 * @return string
1075
+	 */
1076
+	public static function add_query_args_and_nonce(
1077
+		$args = array(),
1078
+		$url = false,
1079
+		$sticky = false,
1080
+		$exclude_nonce = false
1081
+	) {
1082
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
1083
+		if ($sticky) {
1084
+			$request = $_REQUEST;
1085
+			unset($request['_wp_http_referer']);
1086
+			unset($request['wp_referer']);
1087
+			foreach ($request as $key => $value) {
1088
+				//do not add nonces
1089
+				if (strpos($key, 'nonce') !== false) {
1090
+					continue;
1091
+				}
1092
+				$args['wp_referer[' . $key . ']'] = $value;
1093
+			}
1094
+		}
1095
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1096
+	}
1097
+
1098
+
1099
+
1100
+	/**
1101
+	 * This returns a generated link that will load the related help tab.
1102
+	 *
1103
+	 * @param  string $help_tab_id the id for the connected help tab
1104
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
1105
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
1106
+	 * @uses EEH_Template::get_help_tab_link()
1107
+	 * @return string              generated link
1108
+	 */
1109
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
1110
+	{
1111
+		return EEH_Template::get_help_tab_link(
1112
+			$help_tab_id,
1113
+			$this->page_slug,
1114
+			$this->_req_action,
1115
+			$icon_style,
1116
+			$help_text
1117
+		);
1118
+	}
1119
+
1120
+
1121
+
1122
+	/**
1123
+	 * _add_help_tabs
1124
+	 * Note child classes define their help tabs within the page_config array.
1125
+	 *
1126
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1127
+	 * @access protected
1128
+	 * @return void
1129
+	 */
1130
+	protected function _add_help_tabs()
1131
+	{
1132
+		$tour_buttons = '';
1133
+		if (isset($this->_page_config[$this->_req_action])) {
1134
+			$config = $this->_page_config[$this->_req_action];
1135
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1136
+			if (isset($this->_help_tour[$this->_req_action])) {
1137
+				$tb           = array();
1138
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1139
+				foreach ($this->_help_tour['tours'] as $tour) {
1140
+					//if this is the end tour then we don't need to setup a button
1141
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1142
+						continue;
1143
+					}
1144
+					$tb[] = '<button id="trigger-tour-'
1145
+							. $tour->get_slug()
1146
+							. '" class="button-primary trigger-ee-help-tour">'
1147
+							. $tour->get_label()
1148
+							. '</button>';
1149
+				}
1150
+				$tour_buttons .= implode('<br />', $tb);
1151
+				$tour_buttons .= '</div></div>';
1152
+			}
1153
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1154
+			if (is_array($config) && isset($config['help_sidebar'])) {
1155
+				//check that the callback given is valid
1156
+				if (! method_exists($this, $config['help_sidebar'])) {
1157
+					throw new EE_Error(
1158
+						sprintf(
1159
+							__(
1160
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1161
+								'event_espresso'
1162
+							),
1163
+							$config['help_sidebar'],
1164
+							get_class($this)
1165
+						)
1166
+					);
1167
+				}
1168
+				$content = apply_filters(
1169
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1170
+					call_user_func(array($this, $config['help_sidebar']))
1171
+				);
1172
+				$content .= $tour_buttons; //add help tour buttons.
1173
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1174
+				$this->_current_screen->set_help_sidebar($content);
1175
+			}
1176
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1177
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1178
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1179
+			}
1180
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1181
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1182
+				$_ht['id']      = $this->page_slug;
1183
+				$_ht['title']   = __('Help Tours', 'event_espresso');
1184
+				$_ht['content'] = '<p>' . __(
1185
+						'The buttons to the right allow you to start/restart any help tours available for this page',
1186
+						'event_espresso'
1187
+					) . '</p>';
1188
+				$this->_current_screen->add_help_tab($_ht);
1189
+			}/**/
1190
+			if (! isset($config['help_tabs'])) {
1191
+				return;
1192
+			} //no help tabs for this route
1193
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1194
+				//we're here so there ARE help tabs!
1195
+				//make sure we've got what we need
1196
+				if (! isset($cfg['title'])) {
1197
+					throw new EE_Error(
1198
+						__(
1199
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1200
+							'event_espresso'
1201
+						)
1202
+					);
1203
+				}
1204
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1205
+					throw new EE_Error(
1206
+						__(
1207
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1208
+							'event_espresso'
1209
+						)
1210
+					);
1211
+				}
1212
+				//first priority goes to content.
1213
+				if (! empty($cfg['content'])) {
1214
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1215
+					//second priority goes to filename
1216
+				} elseif (! empty($cfg['filename'])) {
1217
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1218
+					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1219
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1220
+															 . basename($this->_get_dir())
1221
+															 . '/help_tabs/'
1222
+															 . $cfg['filename']
1223
+															 . '.help_tab.php' : $file_path;
1224
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1225
+					if (! is_readable($file_path) && ! isset($cfg['callback'])) {
1226
+						EE_Error::add_error(
1227
+							sprintf(
1228
+								__(
1229
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1230
+									'event_espresso'
1231
+								),
1232
+								$tab_id,
1233
+								key($config),
1234
+								$file_path
1235
+							),
1236
+							__FILE__,
1237
+							__FUNCTION__,
1238
+							__LINE__
1239
+						);
1240
+						return;
1241
+					}
1242
+					$template_args['admin_page_obj'] = $this;
1243
+					$content                         = EEH_Template::display_template($file_path, $template_args, true);
1244
+				} else {
1245
+					$content = '';
1246
+				}
1247
+				//check if callback is valid
1248
+				if (empty($content) && (! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1249
+					EE_Error::add_error(
1250
+						sprintf(
1251
+							__(
1252
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1253
+								'event_espresso'
1254
+							),
1255
+							$cfg['title']
1256
+						),
1257
+						__FILE__,
1258
+						__FUNCTION__,
1259
+						__LINE__
1260
+					);
1261
+					return;
1262
+				}
1263
+				//setup config array for help tab method
1264
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1265
+				$_ht = array(
1266
+					'id'       => $id,
1267
+					'title'    => $cfg['title'],
1268
+					'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1269
+					'content'  => $content,
1270
+				);
1271
+				$this->_current_screen->add_help_tab($_ht);
1272
+			}
1273
+		}
1274
+	}
1275
+
1276
+
1277
+
1278
+	/**
1279
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1280
+	 * an array with properties for setting up usage of the joyride plugin
1281
+	 *
1282
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1283
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1284
+	 *         _set_page_config() comments
1285
+	 * @access protected
1286
+	 * @return void
1287
+	 */
1288
+	protected function _add_help_tour()
1289
+	{
1290
+		$tours            = array();
1291
+		$this->_help_tour = array();
1292
+		//exit early if help tours are turned off globally
1293
+		if (! EE_Registry::instance()->CFG->admin->help_tour_activation
1294
+			|| (defined('EE_DISABLE_HELP_TOURS')
1295
+				&& EE_DISABLE_HELP_TOURS)) {
1296
+			return;
1297
+		}
1298
+		//loop through _page_config to find any help_tour defined
1299
+		foreach ($this->_page_config as $route => $config) {
1300
+			//we're only going to set things up for this route
1301
+			if ($route !== $this->_req_action) {
1302
+				continue;
1303
+			}
1304
+			if (isset($config['help_tour'])) {
1305
+				foreach ($config['help_tour'] as $tour) {
1306
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1307
+					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1308
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1309
+															 . basename($this->_get_dir())
1310
+															 . '/help_tours/'
1311
+															 . $tour
1312
+															 . '.class.php' : $file_path;
1313
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1314
+					if (! is_readable($file_path)) {
1315
+						EE_Error::add_error(
1316
+							sprintf(
1317
+								__(
1318
+									'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1319
+									'event_espresso'
1320
+								),
1321
+								$file_path,
1322
+								$tour
1323
+							),
1324
+							__FILE__,
1325
+							__FUNCTION__,
1326
+							__LINE__
1327
+						);
1328
+						return;
1329
+					}
1330
+					require_once $file_path;
1331
+					if (! class_exists($tour)) {
1332
+						$error_msg[] = sprintf(
1333
+							__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1334
+							$tour
1335
+						);
1336
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1337
+								__(
1338
+									'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1339
+									'event_espresso'
1340
+								),
1341
+								$tour,
1342
+								'<br />',
1343
+								$tour,
1344
+								$this->_req_action,
1345
+								get_class($this)
1346
+							);
1347
+						throw new EE_Error(implode('||', $error_msg));
1348
+					}
1349
+					$a                          = new ReflectionClass($tour);
1350
+					$tour_obj                   = $a->newInstance($this->_is_caf);
1351
+					$tours[]                    = $tour_obj;
1352
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1353
+				}
1354
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1355
+				$end_stop_tour              = new EE_Help_Tour_final_stop($this->_is_caf);
1356
+				$tours[]                    = $end_stop_tour;
1357
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1358
+			}
1359
+		}
1360
+		if (! empty($tours)) {
1361
+			$this->_help_tour['tours'] = $tours;
1362
+		}
1363
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1364
+	}
1365
+
1366
+
1367
+
1368
+	/**
1369
+	 * This simply sets up any qtips that have been defined in the page config
1370
+	 *
1371
+	 * @access protected
1372
+	 * @return void
1373
+	 */
1374
+	protected function _add_qtips()
1375
+	{
1376
+		if (isset($this->_route_config['qtips'])) {
1377
+			$qtips = (array)$this->_route_config['qtips'];
1378
+			//load qtip loader
1379
+			$path = array(
1380
+				$this->_get_dir() . '/qtips/',
1381
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1382
+			);
1383
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1384
+		}
1385
+	}
1386
+
1387
+
1388
+
1389
+	/**
1390
+	 * _set_nav_tabs
1391
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1392
+	 * wish to add additional tabs or modify accordingly.
1393
+	 *
1394
+	 * @access protected
1395
+	 * @return void
1396
+	 */
1397
+	protected function _set_nav_tabs()
1398
+	{
1399
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1400
+		$i = 0;
1401
+		foreach ($this->_page_config as $slug => $config) {
1402
+			if (! is_array($config)
1403
+				|| (is_array($config)
1404
+					&& (isset($config['nav']) && ! $config['nav'])
1405
+					|| ! isset($config['nav']))) {
1406
+				continue;
1407
+			} //no nav tab for this config
1408
+			//check for persistent flag
1409
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1410
+				continue;
1411
+			} //nav tab is only to appear when route requested.
1412
+			if (! $this->check_user_access($slug, true)) {
1413
+				continue;
1414
+			} //no nav tab becasue current user does not have access.
1415
+			$css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1416
+			$this->_nav_tabs[$slug] = array(
1417
+				'url'       => isset($config['nav']['url'])
1418
+					? $config['nav']['url']
1419
+					: self::add_query_args_and_nonce(
1420
+						array('action' => $slug),
1421
+						$this->_admin_base_url
1422
+					),
1423
+				'link_text' => isset($config['nav']['label'])
1424
+					? $config['nav']['label']
1425
+					: ucwords(
1426
+						str_replace('_', ' ', $slug)
1427
+					),
1428
+				'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1429
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1430
+			);
1431
+			$i++;
1432
+		}
1433
+		//if $this->_nav_tabs is empty then lets set the default
1434
+		if (empty($this->_nav_tabs)) {
1435
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1436
+				'url'       => $this->admin_base_url,
1437
+				'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1438
+				'css_class' => 'nav-tab-active',
1439
+				'order'     => 10,
1440
+			);
1441
+		}
1442
+		//now let's sort the tabs according to order
1443
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1444
+	}
1445
+
1446
+
1447
+
1448
+	/**
1449
+	 * _set_current_labels
1450
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1451
+	 * property array
1452
+	 *
1453
+	 * @access private
1454
+	 * @return void
1455
+	 */
1456
+	private function _set_current_labels()
1457
+	{
1458
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1459
+			foreach ($this->_route_config['labels'] as $label => $text) {
1460
+				if (is_array($text)) {
1461
+					foreach ($text as $sublabel => $subtext) {
1462
+						$this->_labels[$label][$sublabel] = $subtext;
1463
+					}
1464
+				} else {
1465
+					$this->_labels[$label] = $text;
1466
+				}
1467
+			}
1468
+		}
1469
+	}
1470
+
1471
+
1472
+
1473
+	/**
1474
+	 *        verifies user access for this admin page
1475
+	 *
1476
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1477
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1478
+	 *                               return false if verify fail.
1479
+	 * @return        BOOL|wp_die()
1480
+	 */
1481
+	public function check_user_access($route_to_check = '', $verify_only = false)
1482
+	{
1483
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1484
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1485
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check])
1486
+						  && is_array(
1487
+							  $this->_page_routes[$route_to_check]
1488
+						  )
1489
+						  && ! empty($this->_page_routes[$route_to_check]['capability'])
1490
+			? $this->_page_routes[$route_to_check]['capability'] : null;
1491
+		if (empty($capability) && empty($route_to_check)) {
1492
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1493
+				: $this->_route['capability'];
1494
+		} else {
1495
+			$capability = empty($capability) ? 'manage_options' : $capability;
1496
+		}
1497
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1498
+		if ((! function_exists('is_admin')
1499
+			 || ! EE_Registry::instance()->CAP->current_user_can(
1500
+					$capability,
1501
+					$this->page_slug
1502
+					. '_'
1503
+					. $route_to_check,
1504
+					$id
1505
+				))
1506
+			&& ! defined('DOING_AJAX')) {
1507
+			if ($verify_only) {
1508
+				return false;
1509
+			} else {
1510
+				if (is_user_logged_in()) {
1511
+					wp_die(__('You do not have access to this route.', 'event_espresso'));
1512
+				} else {
1513
+					return false;
1514
+				}
1515
+			}
1516
+		}
1517
+		return true;
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * admin_init_global
1524
+	 * This runs all the code that we want executed within the WP admin_init hook.
1525
+	 * This method executes for ALL EE Admin pages.
1526
+	 *
1527
+	 * @access public
1528
+	 * @return void
1529
+	 */
1530
+	public function admin_init_global()
1531
+	{
1532
+	}
1533
+
1534
+
1535
+
1536
+	/**
1537
+	 * wp_loaded_global
1538
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1539
+	 * EE_Admin page and will execute on every EE Admin Page load
1540
+	 *
1541
+	 * @access public
1542
+	 * @return void
1543
+	 */
1544
+	public function wp_loaded()
1545
+	{
1546
+	}
1547
+
1548
+
1549
+
1550
+	/**
1551
+	 * admin_notices
1552
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1553
+	 * ALL EE_Admin pages.
1554
+	 *
1555
+	 * @access public
1556
+	 * @return void
1557
+	 */
1558
+	public function admin_notices_global()
1559
+	{
1560
+		$this->_display_no_javascript_warning();
1561
+		$this->_display_espresso_notices();
1562
+	}
1563
+
1564
+
1565
+
1566
+	public function network_admin_notices_global()
1567
+	{
1568
+		$this->_display_no_javascript_warning();
1569
+		$this->_display_espresso_notices();
1570
+	}
1571
+
1572
+
1573
+
1574
+	/**
1575
+	 * admin_footer_scripts_global
1576
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1577
+	 * will apply on ALL EE_Admin pages.
1578
+	 *
1579
+	 * @access public
1580
+	 * @return void
1581
+	 */
1582
+	public function admin_footer_scripts_global()
1583
+	{
1584
+		$this->_add_admin_page_ajax_loading_img();
1585
+		$this->_add_admin_page_overlay();
1586
+		//if metaboxes are present we need to add the nonce field
1587
+		if ((isset($this->_route_config['metaboxes'])
1588
+			 || (isset($this->_route_config['has_metaboxes'])
1589
+				 && $this->_route_config['has_metaboxes'])
1590
+			 || isset($this->_route_config['list_table']))) {
1591
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1592
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1593
+		}
1594
+	}
1595
+
1596
+
1597
+
1598
+	/**
1599
+	 * admin_footer_global
1600
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on
1601
+	 * ALL EE_Admin Pages.
1602
+	 *
1603
+	 * @access  public
1604
+	 * @return  void
1605
+	 */
1606
+	public function admin_footer_global()
1607
+	{
1608
+		//dialog container for dialog helper
1609
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1610
+		$d_cont .= '<div class="ee-notices"></div>';
1611
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1612
+		$d_cont .= '</div>';
1613
+		echo $d_cont;
1614
+		//help tour stuff?
1615
+		if (isset($this->_help_tour[$this->_req_action])) {
1616
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1617
+		}
1618
+		//current set timezone for timezone js
1619
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1620
+	}
1621
+
1622
+
1623
+
1624
+	/**
1625
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1626
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1627
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1628
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1629
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1630
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1631
+	 * for the
1632
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1633
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1634
+	 *    'help_trigger_id' => array(
1635
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1636
+	 *        'content' => __('localized content for popup', 'event_espresso')
1637
+	 *    )
1638
+	 * );
1639
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1640
+	 *
1641
+	 * @access protected
1642
+	 * @return string content
1643
+	 */
1644
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1645
+	{
1646
+		$content       = '';
1647
+		$help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1648
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1649
+		//loop through the array and setup content
1650
+		foreach ($help_array as $trigger => $help) {
1651
+			//make sure the array is setup properly
1652
+			if (! isset($help['title']) || ! isset($help['content'])) {
1653
+				throw new EE_Error(
1654
+					__(
1655
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1656
+						'event_espresso'
1657
+					)
1658
+				);
1659
+			}
1660
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1661
+			$template_args = array(
1662
+				'help_popup_id'      => $trigger,
1663
+				'help_popup_title'   => $help['title'],
1664
+				'help_popup_content' => $help['content'],
1665
+			);
1666
+			$content       .= EEH_Template::display_template($template_path, $template_args, true);
1667
+		}
1668
+		if ($display) {
1669
+			echo $content;
1670
+		} else {
1671
+			return $content;
1672
+		}
1673
+	}
1674
+
1675
+
1676
+
1677
+	/**
1678
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1679
+	 *
1680
+	 * @access private
1681
+	 * @return array properly formatted array for help popup content
1682
+	 */
1683
+	private function _get_help_content()
1684
+	{
1685
+		//what is the method we're looking for?
1686
+		$method_name = '_help_popup_content_' . $this->_req_action;
1687
+		//if method doesn't exist let's get out.
1688
+		if (! method_exists($this, $method_name)) {
1689
+			return array();
1690
+		}
1691
+		//k we're good to go let's retrieve the help array
1692
+		$help_array = call_user_func(array($this, $method_name));
1693
+		//make sure we've got an array!
1694
+		if (! is_array($help_array)) {
1695
+			throw new EE_Error(
1696
+				__(
1697
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1698
+					'event_espresso'
1699
+				)
1700
+			);
1701
+		}
1702
+		return $help_array;
1703
+	}
1704
+
1705
+
1706
+
1707
+	/**
1708
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1709
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1710
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1711
+	 *
1712
+	 * @access protected
1713
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1714
+	 * @param boolean $display    if false then we return the trigger string
1715
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1716
+	 * @return string
1717
+	 */
1718
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1719
+	{
1720
+		if (defined('DOING_AJAX')) {
1721
+			return;
1722
+		}
1723
+		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1724
+		$help_array   = $this->_get_help_content();
1725
+		$help_content = '';
1726
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1727
+			$help_array[$trigger_id] = array(
1728
+				'title'   => __('Missing Content', 'event_espresso'),
1729
+				'content' => __(
1730
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1731
+					'event_espresso'
1732
+				),
1733
+			);
1734
+			$help_content            = $this->_set_help_popup_content($help_array, false);
1735
+		}
1736
+		//let's setup the trigger
1737
+		$content = '<a class="ee-dialog" href="?height='
1738
+				   . $dimensions[0]
1739
+				   . '&width='
1740
+				   . $dimensions[1]
1741
+				   . '&inlineId='
1742
+				   . $trigger_id
1743
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1744
+		$content = $content . $help_content;
1745
+		if ($display) {
1746
+			echo $content;
1747
+		} else {
1748
+			return $content;
1749
+		}
1750
+	}
1751
+
1752
+
1753
+
1754
+	/**
1755
+	 * _add_global_screen_options
1756
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1757
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1758
+	 *
1759
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1760
+	 *         see also WP_Screen object documents...
1761
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1762
+	 * @abstract
1763
+	 * @access private
1764
+	 * @return void
1765
+	 */
1766
+	private function _add_global_screen_options()
1767
+	{
1768
+	}
1769
+
1770
+
1771
+
1772
+	/**
1773
+	 * _add_global_feature_pointers
1774
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1775
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1776
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1777
+	 *
1778
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1779
+	 *         extended) also see:
1780
+	 * @link   http://eamann.com/tech/wordpress-portland/
1781
+	 * @abstract
1782
+	 * @access protected
1783
+	 * @return void
1784
+	 */
1785
+	private function _add_global_feature_pointers()
1786
+	{
1787
+	}
1788
+
1789
+
1790
+
1791
+	/**
1792
+	 * load_global_scripts_styles
1793
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1794
+	 *
1795
+	 * @return void
1796
+	 */
1797
+	public function load_global_scripts_styles()
1798
+	{
1799
+		/** STYLES **/
1800
+		// add debugging styles
1801
+		if (WP_DEBUG) {
1802
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1803
+		}
1804
+		// register all styles
1805
+		wp_register_style(
1806
+			'espresso-ui-theme',
1807
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1808
+			array(),
1809
+			EVENT_ESPRESSO_VERSION
1810
+		);
1811
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1812
+		//helpers styles
1813
+		wp_register_style(
1814
+			'ee-text-links',
1815
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1816
+			array(),
1817
+			EVENT_ESPRESSO_VERSION
1818
+		);
1819
+		/** SCRIPTS **/
1820
+		//register all scripts
1821
+		wp_register_script(
1822
+			'ee-dialog',
1823
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1824
+			array('jquery', 'jquery-ui-draggable'),
1825
+			EVENT_ESPRESSO_VERSION,
1826
+			true
1827
+		);
1828
+		wp_register_script(
1829
+			'ee_admin_js',
1830
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1831
+			array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1832
+			EVENT_ESPRESSO_VERSION,
1833
+			true
1834
+		);
1835
+		wp_register_script(
1836
+			'jquery-ui-timepicker-addon',
1837
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1838
+			array('jquery-ui-datepicker', 'jquery-ui-slider'),
1839
+			EVENT_ESPRESSO_VERSION,
1840
+			true
1841
+		);
1842
+		add_filter('FHEE_load_joyride', '__return_true');
1843
+		//script for sorting tables
1844
+		wp_register_script(
1845
+			'espresso_ajax_table_sorting',
1846
+			EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js",
1847
+			array('ee_admin_js', 'jquery-ui-sortable'),
1848
+			EVENT_ESPRESSO_VERSION,
1849
+			true
1850
+		);
1851
+		//script for parsing uri's
1852
+		wp_register_script(
1853
+			'ee-parse-uri',
1854
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1855
+			array(),
1856
+			EVENT_ESPRESSO_VERSION,
1857
+			true
1858
+		);
1859
+		//and parsing associative serialized form elements
1860
+		wp_register_script(
1861
+			'ee-serialize-full-array',
1862
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1863
+			array('jquery'),
1864
+			EVENT_ESPRESSO_VERSION,
1865
+			true
1866
+		);
1867
+		//helpers scripts
1868
+		wp_register_script(
1869
+			'ee-text-links',
1870
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1871
+			array('jquery'),
1872
+			EVENT_ESPRESSO_VERSION,
1873
+			true
1874
+		);
1875
+		wp_register_script(
1876
+			'ee-moment-core',
1877
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1878
+			array(),
1879
+			EVENT_ESPRESSO_VERSION,
1880
+			true
1881
+		);
1882
+		wp_register_script(
1883
+			'ee-moment',
1884
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1885
+			array('ee-moment-core'),
1886
+			EVENT_ESPRESSO_VERSION,
1887
+			true
1888
+		);
1889
+		wp_register_script(
1890
+			'ee-datepicker',
1891
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1892
+			array('jquery-ui-timepicker-addon', 'ee-moment'),
1893
+			EVENT_ESPRESSO_VERSION,
1894
+			true
1895
+		);
1896
+		//google charts
1897
+		wp_register_script(
1898
+			'google-charts',
1899
+			'https://www.gstatic.com/charts/loader.js',
1900
+			array(),
1901
+			EVENT_ESPRESSO_VERSION,
1902
+			false
1903
+		);
1904
+		// ENQUEUE ALL BASICS BY DEFAULT
1905
+		wp_enqueue_style('ee-admin-css');
1906
+		wp_enqueue_script('ee_admin_js');
1907
+		wp_enqueue_script('ee-accounting');
1908
+		wp_enqueue_script('jquery-validate');
1909
+		//taking care of metaboxes
1910
+		if (
1911
+			empty($this->_cpt_route)
1912
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1913
+		) {
1914
+			wp_enqueue_script('dashboard');
1915
+		}
1916
+		// LOCALIZED DATA
1917
+		//localize script for ajax lazy loading
1918
+		$lazy_loader_container_ids = apply_filters(
1919
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1920
+			array('espresso_news_post_box_content')
1921
+		);
1922
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1923
+		/**
1924
+		 * help tour stuff
1925
+		 */
1926
+		if (! empty($this->_help_tour)) {
1927
+			//register the js for kicking things off
1928
+			wp_enqueue_script(
1929
+				'ee-help-tour',
1930
+				EE_ADMIN_URL . 'assets/ee-help-tour.js',
1931
+				array('jquery-joyride'),
1932
+				EVENT_ESPRESSO_VERSION,
1933
+				true
1934
+			);
1935
+			//setup tours for the js tour object
1936
+			foreach ($this->_help_tour['tours'] as $tour) {
1937
+				$tours[] = array(
1938
+					'id'      => $tour->get_slug(),
1939
+					'options' => $tour->get_options(),
1940
+				);
1941
+			}
1942
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1943
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1944
+		}
1945
+	}
1946
+
1947
+
1948
+
1949
+	/**
1950
+	 *        admin_footer_scripts_eei18n_js_strings
1951
+	 *
1952
+	 * @access        public
1953
+	 * @return        void
1954
+	 */
1955
+	public function admin_footer_scripts_eei18n_js_strings()
1956
+	{
1957
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
1958
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __(
1959
+			'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
1960
+			'event_espresso'
1961
+		);
1962
+		EE_Registry::$i18n_js_strings['January']        = __('January', 'event_espresso');
1963
+		EE_Registry::$i18n_js_strings['February']       = __('February', 'event_espresso');
1964
+		EE_Registry::$i18n_js_strings['March']          = __('March', 'event_espresso');
1965
+		EE_Registry::$i18n_js_strings['April']          = __('April', 'event_espresso');
1966
+		EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1967
+		EE_Registry::$i18n_js_strings['June']           = __('June', 'event_espresso');
1968
+		EE_Registry::$i18n_js_strings['July']           = __('July', 'event_espresso');
1969
+		EE_Registry::$i18n_js_strings['August']         = __('August', 'event_espresso');
1970
+		EE_Registry::$i18n_js_strings['September']      = __('September', 'event_espresso');
1971
+		EE_Registry::$i18n_js_strings['October']        = __('October', 'event_espresso');
1972
+		EE_Registry::$i18n_js_strings['November']       = __('November', 'event_espresso');
1973
+		EE_Registry::$i18n_js_strings['December']       = __('December', 'event_espresso');
1974
+		EE_Registry::$i18n_js_strings['Jan']            = __('Jan', 'event_espresso');
1975
+		EE_Registry::$i18n_js_strings['Feb']            = __('Feb', 'event_espresso');
1976
+		EE_Registry::$i18n_js_strings['Mar']            = __('Mar', 'event_espresso');
1977
+		EE_Registry::$i18n_js_strings['Apr']            = __('Apr', 'event_espresso');
1978
+		EE_Registry::$i18n_js_strings['May']            = __('May', 'event_espresso');
1979
+		EE_Registry::$i18n_js_strings['Jun']            = __('Jun', 'event_espresso');
1980
+		EE_Registry::$i18n_js_strings['Jul']            = __('Jul', 'event_espresso');
1981
+		EE_Registry::$i18n_js_strings['Aug']            = __('Aug', 'event_espresso');
1982
+		EE_Registry::$i18n_js_strings['Sep']            = __('Sep', 'event_espresso');
1983
+		EE_Registry::$i18n_js_strings['Oct']            = __('Oct', 'event_espresso');
1984
+		EE_Registry::$i18n_js_strings['Nov']            = __('Nov', 'event_espresso');
1985
+		EE_Registry::$i18n_js_strings['Dec']            = __('Dec', 'event_espresso');
1986
+		EE_Registry::$i18n_js_strings['Sunday']         = __('Sunday', 'event_espresso');
1987
+		EE_Registry::$i18n_js_strings['Monday']         = __('Monday', 'event_espresso');
1988
+		EE_Registry::$i18n_js_strings['Tuesday']        = __('Tuesday', 'event_espresso');
1989
+		EE_Registry::$i18n_js_strings['Wednesday']      = __('Wednesday', 'event_espresso');
1990
+		EE_Registry::$i18n_js_strings['Thursday']       = __('Thursday', 'event_espresso');
1991
+		EE_Registry::$i18n_js_strings['Friday']         = __('Friday', 'event_espresso');
1992
+		EE_Registry::$i18n_js_strings['Saturday']       = __('Saturday', 'event_espresso');
1993
+		EE_Registry::$i18n_js_strings['Sun']            = __('Sun', 'event_espresso');
1994
+		EE_Registry::$i18n_js_strings['Mon']            = __('Mon', 'event_espresso');
1995
+		EE_Registry::$i18n_js_strings['Tue']            = __('Tue', 'event_espresso');
1996
+		EE_Registry::$i18n_js_strings['Wed']            = __('Wed', 'event_espresso');
1997
+		EE_Registry::$i18n_js_strings['Thu']            = __('Thu', 'event_espresso');
1998
+		EE_Registry::$i18n_js_strings['Fri']            = __('Fri', 'event_espresso');
1999
+		EE_Registry::$i18n_js_strings['Sat']            = __('Sat', 'event_espresso');
2000
+	}
2001
+
2002
+
2003
+
2004
+	/**
2005
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2006
+	 *
2007
+	 * @access        public
2008
+	 * @return        void
2009
+	 */
2010
+	public function add_xdebug_style()
2011
+	{
2012
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2013
+	}
2014
+
2015
+
2016
+	/************************/
2017
+	/** LIST TABLE METHODS **/
2018
+	/************************/
2019
+	/**
2020
+	 * this sets up the list table if the current view requires it.
2021
+	 *
2022
+	 * @access protected
2023
+	 * @return void
2024
+	 */
2025
+	protected function _set_list_table()
2026
+	{
2027
+		//first is this a list_table view?
2028
+		if (! isset($this->_route_config['list_table'])) {
2029
+			return;
2030
+		} //not a list_table view so get out.
2031
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
2032
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
2033
+			//user error msg
2034
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
2035
+			//developer error msg
2036
+			$error_msg .= '||' . sprintf(
2037
+					__(
2038
+						'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2039
+						'event_espresso'
2040
+					),
2041
+					$this->_req_action,
2042
+					'_set_list_table_views_' . $this->_req_action
2043
+				);
2044
+			throw new EE_Error($error_msg);
2045
+		}
2046
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2047
+		$this->_views = apply_filters(
2048
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2049
+			$this->_views
2050
+		);
2051
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2052
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2053
+		$this->_set_list_table_view();
2054
+		$this->_set_list_table_object();
2055
+	}
2056
+
2057
+
2058
+
2059
+	/**
2060
+	 *        set current view for List Table
2061
+	 *
2062
+	 * @access public
2063
+	 * @return array
2064
+	 */
2065
+	protected function _set_list_table_view()
2066
+	{
2067
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2068
+		// looking at active items or dumpster diving ?
2069
+		if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2070
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2071
+		} else {
2072
+			$this->_view = sanitize_key($this->_req_data['status']);
2073
+		}
2074
+	}
2075
+
2076
+
2077
+
2078
+	/**
2079
+	 * _set_list_table_object
2080
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2081
+	 *
2082
+	 * @throws \EE_Error
2083
+	 */
2084
+	protected function _set_list_table_object()
2085
+	{
2086
+		if (isset($this->_route_config['list_table'])) {
2087
+			if (! class_exists($this->_route_config['list_table'])) {
2088
+				throw new EE_Error(
2089
+					sprintf(
2090
+						__(
2091
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2092
+							'event_espresso'
2093
+						),
2094
+						$this->_route_config['list_table'],
2095
+						get_class($this)
2096
+					)
2097
+				);
2098
+			}
2099
+			$list_table               = $this->_route_config['list_table'];
2100
+			$this->_list_table_object = new $list_table($this);
2101
+		}
2102
+	}
2103
+
2104
+
2105
+
2106
+	/**
2107
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2108
+	 *
2109
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2110
+	 *                                                    urls.  The array should be indexed by the view it is being
2111
+	 *                                                    added to.
2112
+	 * @return array
2113
+	 */
2114
+	public function get_list_table_view_RLs($extra_query_args = array())
2115
+	{
2116
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2117
+		if (empty($this->_views)) {
2118
+			$this->_views = array();
2119
+		}
2120
+		// cycle thru views
2121
+		foreach ($this->_views as $key => $view) {
2122
+			$query_args = array();
2123
+			// check for current view
2124
+			$this->_views[$key]['class']               = $this->_view == $view['slug'] ? 'current' : '';
2125
+			$query_args['action']                      = $this->_req_action;
2126
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2127
+			$query_args['status']                      = $view['slug'];
2128
+			//merge any other arguments sent in.
2129
+			if (isset($extra_query_args[$view['slug']])) {
2130
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
2131
+			}
2132
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2133
+		}
2134
+		return $this->_views;
2135
+	}
2136
+
2137
+
2138
+
2139
+	/**
2140
+	 * _entries_per_page_dropdown
2141
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
2142
+	 *
2143
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2144
+	 *         WP does it.
2145
+	 * @access protected
2146
+	 * @param int $max_entries total number of rows in the table
2147
+	 * @return string
2148
+	 */
2149
+	protected function _entries_per_page_dropdown($max_entries = false)
2150
+	{
2151
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2152
+		$values   = array(10, 25, 50, 100);
2153
+		$per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2154
+		if ($max_entries) {
2155
+			$values[] = $max_entries;
2156
+			sort($values);
2157
+		}
2158
+		$entries_per_page_dropdown = '
2159 2159
 			<div id="entries-per-page-dv" class="alignleft actions">
2160 2160
 				<label class="hide-if-no-js">
2161 2161
 					Show
2162 2162
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2163
-        foreach ($values as $value) {
2164
-            if ($value < $max_entries) {
2165
-                $selected                  = $value == $per_page ? ' selected="' . $per_page . '"' : '';
2166
-                $entries_per_page_dropdown .= '
2163
+		foreach ($values as $value) {
2164
+			if ($value < $max_entries) {
2165
+				$selected                  = $value == $per_page ? ' selected="' . $per_page . '"' : '';
2166
+				$entries_per_page_dropdown .= '
2167 2167
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2168
-            }
2169
-        }
2170
-        $selected                  = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
2171
-        $entries_per_page_dropdown .= '
2168
+			}
2169
+		}
2170
+		$selected                  = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
2171
+		$entries_per_page_dropdown .= '
2172 2172
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2173
-        $entries_per_page_dropdown .= '
2173
+		$entries_per_page_dropdown .= '
2174 2174
 					</select>
2175 2175
 					entries
2176 2176
 				</label>
2177 2177
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2178 2178
 			</div>
2179 2179
 		';
2180
-        return $entries_per_page_dropdown;
2181
-    }
2182
-
2183
-
2184
-
2185
-    /**
2186
-     *        _set_search_attributes
2187
-     *
2188
-     * @access        protected
2189
-     * @return        void
2190
-     */
2191
-    public function _set_search_attributes()
2192
-    {
2193
-        $this->_template_args['search']['btn_label'] = sprintf(
2194
-            __('Search %s', 'event_espresso'),
2195
-            empty($this->_search_btn_label) ? $this->page_label
2196
-                : $this->_search_btn_label
2197
-        );
2198
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2199
-    }
2200
-
2201
-    /*** END LIST TABLE METHODS **/
2202
-    /*****************************/
2203
-    /**
2204
-     *        _add_registered_metaboxes
2205
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2206
-     *
2207
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2208
-     * @access private
2209
-     * @return void
2210
-     */
2211
-    private function _add_registered_meta_boxes()
2212
-    {
2213
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2214
-        //we only add meta boxes if the page_route calls for it
2215
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2216
-            && is_array(
2217
-                $this->_route_config['metaboxes']
2218
-            )
2219
-        ) {
2220
-            // this simply loops through the callbacks provided
2221
-            // and checks if there is a corresponding callback registered by the child
2222
-            // if there is then we go ahead and process the metabox loader.
2223
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2224
-                // first check for Closures
2225
-                if ($metabox_callback instanceof Closure) {
2226
-                    $result = $metabox_callback();
2227
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2228
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2229
-                } else {
2230
-                    $result = call_user_func(array($this, &$metabox_callback));
2231
-                }
2232
-                if ($result === false) {
2233
-                    // user error msg
2234
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
2235
-                    // developer error msg
2236
-                    $error_msg .= '||' . sprintf(
2237
-                            __(
2238
-                                'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2239
-                                'event_espresso'
2240
-                            ),
2241
-                            $metabox_callback
2242
-                        );
2243
-                    throw new EE_Error($error_msg);
2244
-                }
2245
-            }
2246
-        }
2247
-    }
2248
-
2249
-
2250
-
2251
-    /**
2252
-     * _add_screen_columns
2253
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2254
-     * the dynamic column template and we'll setup the column options for the page.
2255
-     *
2256
-     * @access private
2257
-     * @return void
2258
-     */
2259
-    private function _add_screen_columns()
2260
-    {
2261
-        if (
2262
-            is_array($this->_route_config)
2263
-            && isset($this->_route_config['columns'])
2264
-            && is_array($this->_route_config['columns'])
2265
-            && count($this->_route_config['columns']) === 2
2266
-        ) {
2267
-            add_screen_option(
2268
-                'layout_columns',
2269
-                array(
2270
-                    'max'     => (int)$this->_route_config['columns'][0],
2271
-                    'default' => (int)$this->_route_config['columns'][1],
2272
-                )
2273
-            );
2274
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2275
-            $screen_id                                           = $this->_current_screen->id;
2276
-            $screen_columns                                      = (int)get_user_option("screen_layout_$screen_id");
2277
-            $total_columns                                       = ! empty($screen_columns) ? $screen_columns
2278
-                : $this->_route_config['columns'][1];
2279
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2280
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2281
-            $this->_template_args['screen']                      = $this->_current_screen;
2282
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2283
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2284
-            //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2285
-            $this->_route_config['has_metaboxes'] = true;
2286
-        }
2287
-    }
2288
-
2289
-
2290
-
2291
-    /**********************************/
2292
-    /** GLOBALLY AVAILABLE METABOXES **/
2293
-    /**
2294
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2295
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2296
-     * these get loaded on.
2297
-     */
2298
-    private function _espresso_news_post_box()
2299
-    {
2300
-        $news_box_title = apply_filters(
2301
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2302
-            __('New @ Event Espresso', 'event_espresso')
2303
-        );
2304
-        add_meta_box(
2305
-            'espresso_news_post_box',
2306
-            $news_box_title,
2307
-            array(
2308
-                $this,
2309
-                'espresso_news_post_box',
2310
-            ),
2311
-            $this->_wp_page_slug,
2312
-            'side'
2313
-        );
2314
-    }
2315
-
2316
-
2317
-
2318
-    /**
2319
-     * Code for setting up espresso ratings request metabox.
2320
-     */
2321
-    protected function _espresso_ratings_request()
2322
-    {
2323
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2324
-            return '';
2325
-        }
2326
-        $ratings_box_title = apply_filters(
2327
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2328
-            __('Keep Event Espresso Decaf Free', 'event_espresso')
2329
-        );
2330
-        add_meta_box(
2331
-            'espresso_ratings_request',
2332
-            $ratings_box_title,
2333
-            array(
2334
-                $this,
2335
-                'espresso_ratings_request',
2336
-            ),
2337
-            $this->_wp_page_slug,
2338
-            'side'
2339
-        );
2340
-    }
2341
-
2342
-
2343
-
2344
-    /**
2345
-     * Code for setting up espresso ratings request metabox content.
2346
-     */
2347
-    public function espresso_ratings_request()
2348
-    {
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2350
-        EEH_Template::display_template($template_path, array());
2351
-    }
2352
-
2353
-
2354
-
2355
-    public static function cached_rss_display($rss_id, $url)
2356
-    {
2357
-        $loading    = '<p class="widget-loading hide-if-no-js">'
2358
-                      . __('Loading&#8230;')
2359
-                      . '</p><p class="hide-if-js">'
2360
-                      . __('This widget requires JavaScript.')
2361
-                      . '</p>';
2362
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2363
-        $pre        = '<div class="espresso-rss-display">' . "\n\t";
2364
-        $pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2365
-        $post       = '</div>' . "\n";
2366
-        $cache_key  = 'ee_rss_' . md5($rss_id);
2367
-        if (false != ($output = get_transient($cache_key))) {
2368
-            echo $pre . $output . $post;
2369
-            return true;
2370
-        }
2371
-        if (! $doing_ajax) {
2372
-            echo $pre . $loading . $post;
2373
-            return false;
2374
-        }
2375
-        ob_start();
2376
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2377
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2378
-        return true;
2379
-    }
2380
-
2381
-
2382
-
2383
-    public function espresso_news_post_box()
2384
-    {
2385
-        ?>
2180
+		return $entries_per_page_dropdown;
2181
+	}
2182
+
2183
+
2184
+
2185
+	/**
2186
+	 *        _set_search_attributes
2187
+	 *
2188
+	 * @access        protected
2189
+	 * @return        void
2190
+	 */
2191
+	public function _set_search_attributes()
2192
+	{
2193
+		$this->_template_args['search']['btn_label'] = sprintf(
2194
+			__('Search %s', 'event_espresso'),
2195
+			empty($this->_search_btn_label) ? $this->page_label
2196
+				: $this->_search_btn_label
2197
+		);
2198
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2199
+	}
2200
+
2201
+	/*** END LIST TABLE METHODS **/
2202
+	/*****************************/
2203
+	/**
2204
+	 *        _add_registered_metaboxes
2205
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2206
+	 *
2207
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2208
+	 * @access private
2209
+	 * @return void
2210
+	 */
2211
+	private function _add_registered_meta_boxes()
2212
+	{
2213
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2214
+		//we only add meta boxes if the page_route calls for it
2215
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2216
+			&& is_array(
2217
+				$this->_route_config['metaboxes']
2218
+			)
2219
+		) {
2220
+			// this simply loops through the callbacks provided
2221
+			// and checks if there is a corresponding callback registered by the child
2222
+			// if there is then we go ahead and process the metabox loader.
2223
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2224
+				// first check for Closures
2225
+				if ($metabox_callback instanceof Closure) {
2226
+					$result = $metabox_callback();
2227
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2228
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
2229
+				} else {
2230
+					$result = call_user_func(array($this, &$metabox_callback));
2231
+				}
2232
+				if ($result === false) {
2233
+					// user error msg
2234
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
2235
+					// developer error msg
2236
+					$error_msg .= '||' . sprintf(
2237
+							__(
2238
+								'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2239
+								'event_espresso'
2240
+							),
2241
+							$metabox_callback
2242
+						);
2243
+					throw new EE_Error($error_msg);
2244
+				}
2245
+			}
2246
+		}
2247
+	}
2248
+
2249
+
2250
+
2251
+	/**
2252
+	 * _add_screen_columns
2253
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2254
+	 * the dynamic column template and we'll setup the column options for the page.
2255
+	 *
2256
+	 * @access private
2257
+	 * @return void
2258
+	 */
2259
+	private function _add_screen_columns()
2260
+	{
2261
+		if (
2262
+			is_array($this->_route_config)
2263
+			&& isset($this->_route_config['columns'])
2264
+			&& is_array($this->_route_config['columns'])
2265
+			&& count($this->_route_config['columns']) === 2
2266
+		) {
2267
+			add_screen_option(
2268
+				'layout_columns',
2269
+				array(
2270
+					'max'     => (int)$this->_route_config['columns'][0],
2271
+					'default' => (int)$this->_route_config['columns'][1],
2272
+				)
2273
+			);
2274
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2275
+			$screen_id                                           = $this->_current_screen->id;
2276
+			$screen_columns                                      = (int)get_user_option("screen_layout_$screen_id");
2277
+			$total_columns                                       = ! empty($screen_columns) ? $screen_columns
2278
+				: $this->_route_config['columns'][1];
2279
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2280
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2281
+			$this->_template_args['screen']                      = $this->_current_screen;
2282
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2283
+																   . 'admin_details_metabox_column_wrapper.template.php';
2284
+			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2285
+			$this->_route_config['has_metaboxes'] = true;
2286
+		}
2287
+	}
2288
+
2289
+
2290
+
2291
+	/**********************************/
2292
+	/** GLOBALLY AVAILABLE METABOXES **/
2293
+	/**
2294
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2295
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2296
+	 * these get loaded on.
2297
+	 */
2298
+	private function _espresso_news_post_box()
2299
+	{
2300
+		$news_box_title = apply_filters(
2301
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2302
+			__('New @ Event Espresso', 'event_espresso')
2303
+		);
2304
+		add_meta_box(
2305
+			'espresso_news_post_box',
2306
+			$news_box_title,
2307
+			array(
2308
+				$this,
2309
+				'espresso_news_post_box',
2310
+			),
2311
+			$this->_wp_page_slug,
2312
+			'side'
2313
+		);
2314
+	}
2315
+
2316
+
2317
+
2318
+	/**
2319
+	 * Code for setting up espresso ratings request metabox.
2320
+	 */
2321
+	protected function _espresso_ratings_request()
2322
+	{
2323
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2324
+			return '';
2325
+		}
2326
+		$ratings_box_title = apply_filters(
2327
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2328
+			__('Keep Event Espresso Decaf Free', 'event_espresso')
2329
+		);
2330
+		add_meta_box(
2331
+			'espresso_ratings_request',
2332
+			$ratings_box_title,
2333
+			array(
2334
+				$this,
2335
+				'espresso_ratings_request',
2336
+			),
2337
+			$this->_wp_page_slug,
2338
+			'side'
2339
+		);
2340
+	}
2341
+
2342
+
2343
+
2344
+	/**
2345
+	 * Code for setting up espresso ratings request metabox content.
2346
+	 */
2347
+	public function espresso_ratings_request()
2348
+	{
2349
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2350
+		EEH_Template::display_template($template_path, array());
2351
+	}
2352
+
2353
+
2354
+
2355
+	public static function cached_rss_display($rss_id, $url)
2356
+	{
2357
+		$loading    = '<p class="widget-loading hide-if-no-js">'
2358
+					  . __('Loading&#8230;')
2359
+					  . '</p><p class="hide-if-js">'
2360
+					  . __('This widget requires JavaScript.')
2361
+					  . '</p>';
2362
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2363
+		$pre        = '<div class="espresso-rss-display">' . "\n\t";
2364
+		$pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2365
+		$post       = '</div>' . "\n";
2366
+		$cache_key  = 'ee_rss_' . md5($rss_id);
2367
+		if (false != ($output = get_transient($cache_key))) {
2368
+			echo $pre . $output . $post;
2369
+			return true;
2370
+		}
2371
+		if (! $doing_ajax) {
2372
+			echo $pre . $loading . $post;
2373
+			return false;
2374
+		}
2375
+		ob_start();
2376
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
2377
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2378
+		return true;
2379
+	}
2380
+
2381
+
2382
+
2383
+	public function espresso_news_post_box()
2384
+	{
2385
+		?>
2386 2386
         <div class="padding">
2387 2387
             <div id="espresso_news_post_box_content" class="infolinks">
2388 2388
                 <?php
2389
-                // Get RSS Feed(s)
2390
-                $feed_url = apply_filters(
2391
-                    'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2392
-                    'http://eventespresso.com/feed/'
2393
-                );
2394
-                $url      = urlencode($feed_url);
2395
-                self::cached_rss_display('espresso_news_post_box_content', $url);
2396
-                ?>
2389
+				// Get RSS Feed(s)
2390
+				$feed_url = apply_filters(
2391
+					'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2392
+					'http://eventespresso.com/feed/'
2393
+				);
2394
+				$url      = urlencode($feed_url);
2395
+				self::cached_rss_display('espresso_news_post_box_content', $url);
2396
+				?>
2397 2397
             </div>
2398 2398
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2399 2399
         </div>
2400 2400
         <?php
2401
-    }
2402
-
2403
-
2404
-
2405
-    private function _espresso_links_post_box()
2406
-    {
2407
-        //Hiding until we actually have content to put in here...
2408
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2409
-    }
2410
-
2411
-
2412
-
2413
-    public function espresso_links_post_box()
2414
-    {
2415
-        //Hiding until we actually have content to put in here...
2416
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2417
-        //EEH_Template::display_template( $templatepath );
2418
-    }
2419
-
2420
-
2421
-
2422
-    protected function _espresso_sponsors_post_box()
2423
-    {
2424
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2425
-        if ($show_sponsors) {
2426
-            add_meta_box(
2427
-                'espresso_sponsors_post_box',
2428
-                __('Event Espresso Highlights', 'event_espresso'),
2429
-                array($this, 'espresso_sponsors_post_box'),
2430
-                $this->_wp_page_slug,
2431
-                'side'
2432
-            );
2433
-        }
2434
-    }
2435
-
2436
-
2437
-
2438
-    public function espresso_sponsors_post_box()
2439
-    {
2440
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2441
-        EEH_Template::display_template($templatepath);
2442
-    }
2443
-
2444
-
2445
-
2446
-    private function _publish_post_box()
2447
-    {
2448
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2449
-        //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2450
-        if (! empty($this->_labels['publishbox'])) {
2451
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2452
-                : $this->_labels['publishbox'];
2453
-        } else {
2454
-            $box_label = __('Publish', 'event_espresso');
2455
-        }
2456
-        $box_label = apply_filters(
2457
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2458
-            $box_label,
2459
-            $this->_req_action,
2460
-            $this
2461
-        );
2462
-        add_meta_box(
2463
-            $meta_box_ref,
2464
-            $box_label,
2465
-            array($this, 'editor_overview'),
2466
-            $this->_current_screen->id,
2467
-            'side',
2468
-            'high'
2469
-        );
2470
-    }
2471
-
2472
-
2473
-
2474
-    public function editor_overview()
2475
-    {
2476
-        //if we have extra content set let's add it in if not make sure its empty
2477
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2478
-            ? $this->_template_args['publish_box_extra_content'] : '';
2479
-        $template_path                                     = EE_ADMIN_TEMPLATE
2480
-                                                             . 'admin_details_publish_metabox.template.php';
2481
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2482
-    }
2483
-
2484
-
2485
-    /** end of globally available metaboxes section **/
2486
-    /*************************************************/
2487
-    /**
2488
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2489
-     * protected method.
2490
-     *
2491
-     * @see   $this->_set_publish_post_box_vars for param details
2492
-     * @since 4.6.0
2493
-     */
2494
-    public function set_publish_post_box_vars(
2495
-        $name = null,
2496
-        $id = false,
2497
-        $delete = false,
2498
-        $save_close_redirect_URL = null,
2499
-        $both_btns = true
2500
-    ) {
2501
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2502
-    }
2503
-
2504
-
2505
-
2506
-    /**
2507
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2508
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2509
-     * save, and save and close buttons to work properly, then you will want to include a
2510
-     * values for the name and id arguments.
2511
-     *
2512
-     * @todo  Add in validation for name/id arguments.
2513
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2514
-     * @param    int     $id                      id attached to the item published
2515
-     * @param    string  $delete                  page route callback for the delete action
2516
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2517
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2518
-     *                                            the Save button
2519
-     * @throws \EE_Error
2520
-     */
2521
-    protected function _set_publish_post_box_vars(
2522
-        $name = '',
2523
-        $id = 0,
2524
-        $delete = '',
2525
-        $save_close_redirect_URL = '',
2526
-        $both_btns = true
2527
-    ) {
2528
-        // if Save & Close, use a custom redirect URL or default to the main page?
2529
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL
2530
-            : $this->_admin_base_url;
2531
-        // create the Save & Close and Save buttons
2532
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2533
-        //if we have extra content set let's add it in if not make sure its empty
2534
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2535
-            ? $this->_template_args['publish_box_extra_content'] : '';
2536
-        if ($delete && ! empty($id)) {
2537
-            //make sure we have a default if just true is sent.
2538
-            $delete           = ! empty($delete) ? $delete : 'delete';
2539
-            $delete_link_args = array($name => $id);
2540
-            $delete           = $this->get_action_link_or_button(
2541
-                $delete,
2542
-                $delete,
2543
-                $delete_link_args,
2544
-                'submitdelete deletion',
2545
-                '',
2546
-                false
2547
-            );
2548
-        }
2549
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2550
-        if (! empty($name) && ! empty($id)) {
2551
-            $hidden_field_arr[$name] = array(
2552
-                'type'  => 'hidden',
2553
-                'value' => $id,
2554
-            );
2555
-            $hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2556
-        } else {
2557
-            $hf = '';
2558
-        }
2559
-        // add hidden field
2560
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2561
-    }
2562
-
2563
-
2564
-
2565
-    /**
2566
-     *        displays an error message to ppl who have javascript disabled
2567
-     *
2568
-     * @access        private
2569
-     * @return        string
2570
-     */
2571
-    private function _display_no_javascript_warning()
2572
-    {
2573
-        ?>
2401
+	}
2402
+
2403
+
2404
+
2405
+	private function _espresso_links_post_box()
2406
+	{
2407
+		//Hiding until we actually have content to put in here...
2408
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2409
+	}
2410
+
2411
+
2412
+
2413
+	public function espresso_links_post_box()
2414
+	{
2415
+		//Hiding until we actually have content to put in here...
2416
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2417
+		//EEH_Template::display_template( $templatepath );
2418
+	}
2419
+
2420
+
2421
+
2422
+	protected function _espresso_sponsors_post_box()
2423
+	{
2424
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2425
+		if ($show_sponsors) {
2426
+			add_meta_box(
2427
+				'espresso_sponsors_post_box',
2428
+				__('Event Espresso Highlights', 'event_espresso'),
2429
+				array($this, 'espresso_sponsors_post_box'),
2430
+				$this->_wp_page_slug,
2431
+				'side'
2432
+			);
2433
+		}
2434
+	}
2435
+
2436
+
2437
+
2438
+	public function espresso_sponsors_post_box()
2439
+	{
2440
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2441
+		EEH_Template::display_template($templatepath);
2442
+	}
2443
+
2444
+
2445
+
2446
+	private function _publish_post_box()
2447
+	{
2448
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2449
+		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2450
+		if (! empty($this->_labels['publishbox'])) {
2451
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2452
+				: $this->_labels['publishbox'];
2453
+		} else {
2454
+			$box_label = __('Publish', 'event_espresso');
2455
+		}
2456
+		$box_label = apply_filters(
2457
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2458
+			$box_label,
2459
+			$this->_req_action,
2460
+			$this
2461
+		);
2462
+		add_meta_box(
2463
+			$meta_box_ref,
2464
+			$box_label,
2465
+			array($this, 'editor_overview'),
2466
+			$this->_current_screen->id,
2467
+			'side',
2468
+			'high'
2469
+		);
2470
+	}
2471
+
2472
+
2473
+
2474
+	public function editor_overview()
2475
+	{
2476
+		//if we have extra content set let's add it in if not make sure its empty
2477
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2478
+			? $this->_template_args['publish_box_extra_content'] : '';
2479
+		$template_path                                     = EE_ADMIN_TEMPLATE
2480
+															 . 'admin_details_publish_metabox.template.php';
2481
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2482
+	}
2483
+
2484
+
2485
+	/** end of globally available metaboxes section **/
2486
+	/*************************************************/
2487
+	/**
2488
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2489
+	 * protected method.
2490
+	 *
2491
+	 * @see   $this->_set_publish_post_box_vars for param details
2492
+	 * @since 4.6.0
2493
+	 */
2494
+	public function set_publish_post_box_vars(
2495
+		$name = null,
2496
+		$id = false,
2497
+		$delete = false,
2498
+		$save_close_redirect_URL = null,
2499
+		$both_btns = true
2500
+	) {
2501
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2502
+	}
2503
+
2504
+
2505
+
2506
+	/**
2507
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2508
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2509
+	 * save, and save and close buttons to work properly, then you will want to include a
2510
+	 * values for the name and id arguments.
2511
+	 *
2512
+	 * @todo  Add in validation for name/id arguments.
2513
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2514
+	 * @param    int     $id                      id attached to the item published
2515
+	 * @param    string  $delete                  page route callback for the delete action
2516
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2517
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just
2518
+	 *                                            the Save button
2519
+	 * @throws \EE_Error
2520
+	 */
2521
+	protected function _set_publish_post_box_vars(
2522
+		$name = '',
2523
+		$id = 0,
2524
+		$delete = '',
2525
+		$save_close_redirect_URL = '',
2526
+		$both_btns = true
2527
+	) {
2528
+		// if Save & Close, use a custom redirect URL or default to the main page?
2529
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL
2530
+			: $this->_admin_base_url;
2531
+		// create the Save & Close and Save buttons
2532
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2533
+		//if we have extra content set let's add it in if not make sure its empty
2534
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2535
+			? $this->_template_args['publish_box_extra_content'] : '';
2536
+		if ($delete && ! empty($id)) {
2537
+			//make sure we have a default if just true is sent.
2538
+			$delete           = ! empty($delete) ? $delete : 'delete';
2539
+			$delete_link_args = array($name => $id);
2540
+			$delete           = $this->get_action_link_or_button(
2541
+				$delete,
2542
+				$delete,
2543
+				$delete_link_args,
2544
+				'submitdelete deletion',
2545
+				'',
2546
+				false
2547
+			);
2548
+		}
2549
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2550
+		if (! empty($name) && ! empty($id)) {
2551
+			$hidden_field_arr[$name] = array(
2552
+				'type'  => 'hidden',
2553
+				'value' => $id,
2554
+			);
2555
+			$hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2556
+		} else {
2557
+			$hf = '';
2558
+		}
2559
+		// add hidden field
2560
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2561
+	}
2562
+
2563
+
2564
+
2565
+	/**
2566
+	 *        displays an error message to ppl who have javascript disabled
2567
+	 *
2568
+	 * @access        private
2569
+	 * @return        string
2570
+	 */
2571
+	private function _display_no_javascript_warning()
2572
+	{
2573
+		?>
2574 2574
         <noscript>
2575 2575
             <div id="no-js-message" class="error">
2576 2576
                 <p style="font-size:1.3em;">
2577 2577
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2578 2578
                     <?php esc_html_e(
2579
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2580
-                        'event_espresso'
2581
-                    ); ?>
2579
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2580
+						'event_espresso'
2581
+					); ?>
2582 2582
                 </p>
2583 2583
             </div>
2584 2584
         </noscript>
2585 2585
         <?php
2586
-    }
2586
+	}
2587 2587
 
2588 2588
 
2589 2589
 
2590
-    /**
2591
-     *        displays espresso success and/or error notices
2592
-     *
2593
-     * @access        private
2594
-     * @return        string
2595
-     */
2596
-    private function _display_espresso_notices()
2597
-    {
2598
-        $notices = $this->_get_transient(true);
2599
-        echo stripslashes($notices);
2600
-    }
2590
+	/**
2591
+	 *        displays espresso success and/or error notices
2592
+	 *
2593
+	 * @access        private
2594
+	 * @return        string
2595
+	 */
2596
+	private function _display_espresso_notices()
2597
+	{
2598
+		$notices = $this->_get_transient(true);
2599
+		echo stripslashes($notices);
2600
+	}
2601 2601
 
2602 2602
 
2603 2603
 
2604
-    /**
2605
-     *        spinny things pacify the masses
2606
-     *
2607
-     * @access private
2608
-     * @return string
2609
-     */
2610
-    protected function _add_admin_page_ajax_loading_img()
2611
-    {
2612
-        ?>
2604
+	/**
2605
+	 *        spinny things pacify the masses
2606
+	 *
2607
+	 * @access private
2608
+	 * @return string
2609
+	 */
2610
+	protected function _add_admin_page_ajax_loading_img()
2611
+	{
2612
+		?>
2613 2613
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2614 2614
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e(
2615
-                    'loading...',
2616
-                    'event_espresso'
2617
-                ); ?></span>
2615
+					'loading...',
2616
+					'event_espresso'
2617
+				); ?></span>
2618 2618
         </div>
2619 2619
         <?php
2620
-    }
2620
+	}
2621 2621
 
2622 2622
 
2623 2623
 
2624
-    /**
2625
-     *        add admin page overlay for modal boxes
2626
-     *
2627
-     * @access private
2628
-     * @return string
2629
-     */
2630
-    protected function _add_admin_page_overlay()
2631
-    {
2632
-        ?>
2624
+	/**
2625
+	 *        add admin page overlay for modal boxes
2626
+	 *
2627
+	 * @access private
2628
+	 * @return string
2629
+	 */
2630
+	protected function _add_admin_page_overlay()
2631
+	{
2632
+		?>
2633 2633
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2634 2634
         <?php
2635
-    }
2636
-
2637
-
2638
-
2639
-    /**
2640
-     * facade for add_meta_box
2641
-     *
2642
-     * @param string  $action        where the metabox get's displayed
2643
-     * @param string  $title         Title of Metabox (output in metabox header)
2644
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2645
-     *                               instead of the one created in here.
2646
-     * @param array   $callback_args an array of args supplied for the metabox
2647
-     * @param string  $column        what metabox column
2648
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2649
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2650
-     *                               created but just set our own callback for wp's add_meta_box.
2651
-     */
2652
-    public function _add_admin_page_meta_box(
2653
-        $action,
2654
-        $title,
2655
-        $callback,
2656
-        $callback_args,
2657
-        $column = 'normal',
2658
-        $priority = 'high',
2659
-        $create_func = true
2660
-    ) {
2661
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2662
-        //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2663
-        if (empty($callback_args) && $create_func) {
2664
-            $callback_args = array(
2665
-                'template_path' => $this->_template_path,
2666
-                'template_args' => $this->_template_args,
2667
-            );
2668
-        }
2669
-        //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2670
-        $call_back_func = $create_func ? create_function(
2671
-            '$post, $metabox',
2672
-            'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'
2673
-        ) : $callback;
2674
-        add_meta_box(
2675
-            str_replace('_', '-', $action) . '-mbox',
2676
-            $title,
2677
-            $call_back_func,
2678
-            $this->_wp_page_slug,
2679
-            $column,
2680
-            $priority,
2681
-            $callback_args
2682
-        );
2683
-    }
2684
-
2685
-
2686
-
2687
-    /**
2688
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2689
-     *
2690
-     * @return [type] [description]
2691
-     */
2692
-    public function display_admin_page_with_metabox_columns()
2693
-    {
2694
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2695
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2696
-            $this->_column_template_path,
2697
-            $this->_template_args,
2698
-            true
2699
-        );
2700
-        //the final wrapper
2701
-        $this->admin_page_wrapper();
2702
-    }
2703
-
2704
-
2705
-
2706
-    /**
2707
-     *        generates  HTML wrapper for an admin details page
2708
-     *
2709
-     * @access public
2710
-     * @return void
2711
-     */
2712
-    public function display_admin_page_with_sidebar()
2713
-    {
2714
-        $this->_display_admin_page(true);
2715
-    }
2716
-
2717
-
2718
-
2719
-    /**
2720
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2721
-     *
2722
-     * @access public
2723
-     * @return void
2724
-     */
2725
-    public function display_admin_page_with_no_sidebar()
2726
-    {
2727
-        $this->_display_admin_page();
2728
-    }
2729
-
2730
-
2731
-
2732
-    /**
2733
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2734
-     *
2735
-     * @access public
2736
-     * @return void
2737
-     */
2738
-    public function display_about_admin_page()
2739
-    {
2740
-        $this->_display_admin_page(false, true);
2741
-    }
2742
-
2743
-
2744
-
2745
-    /**
2746
-     * display_admin_page
2747
-     * contains the code for actually displaying an admin page
2748
-     *
2749
-     * @access private
2750
-     * @param  boolean $sidebar true with sidebar, false without
2751
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2752
-     * @return void
2753
-     */
2754
-    private function _display_admin_page($sidebar = false, $about = false)
2755
-    {
2756
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2757
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2758
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2759
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2760
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2761
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2762
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2763
-            ? 'poststuff'
2764
-            : 'espresso-default-admin';
2765
-        $template_path                                     = $sidebar
2766
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2767
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2768
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2769
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2770
-        }
2771
-        $template_path                                     = ! empty($this->_column_template_path)
2772
-            ? $this->_column_template_path : $template_path;
2773
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2774
-            ? $this->_template_args['admin_page_content'] : '';
2775
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2776
-            ? $this->_template_args['before_admin_page_content'] : '';
2777
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2778
-            ? $this->_template_args['after_admin_page_content'] : '';
2779
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2780
-            $template_path,
2781
-            $this->_template_args,
2782
-            true
2783
-        );
2784
-        // the final template wrapper
2785
-        $this->admin_page_wrapper($about);
2786
-    }
2787
-
2788
-
2789
-
2790
-    /**
2791
-     * This is used to display caf preview pages.
2792
-     *
2793
-     * @since 4.3.2
2794
-     * @param string $utm_campaign_source what is the key used for google analytics link
2795
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2796
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2797
-     * @return void
2798
-     * @throws \EE_Error
2799
-     */
2800
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2801
-    {
2802
-        //let's generate a default preview action button if there isn't one already present.
2803
-        $this->_labels['buttons']['buy_now']           = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2804
-        $buy_now_url                                   = add_query_arg(
2805
-            array(
2806
-                'ee_ver'       => 'ee4',
2807
-                'utm_source'   => 'ee4_plugin_admin',
2808
-                'utm_medium'   => 'link',
2809
-                'utm_campaign' => $utm_campaign_source,
2810
-                'utm_content'  => 'buy_now_button',
2811
-            ),
2812
-            'http://eventespresso.com/pricing/'
2813
-        );
2814
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2815
-            ? $this->get_action_link_or_button(
2816
-                '',
2817
-                'buy_now',
2818
-                array(),
2819
-                'button-primary button-large',
2820
-                $buy_now_url,
2821
-                true
2822
-            )
2823
-            : $this->_template_args['preview_action_button'];
2824
-        $template_path                                 = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2825
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2826
-            $template_path,
2827
-            $this->_template_args,
2828
-            true
2829
-        );
2830
-        $this->_display_admin_page($display_sidebar);
2831
-    }
2832
-
2833
-
2834
-
2835
-    /**
2836
-     * display_admin_list_table_page_with_sidebar
2837
-     * generates HTML wrapper for an admin_page with list_table
2838
-     *
2839
-     * @access public
2840
-     * @return void
2841
-     */
2842
-    public function display_admin_list_table_page_with_sidebar()
2843
-    {
2844
-        $this->_display_admin_list_table_page(true);
2845
-    }
2846
-
2847
-
2848
-
2849
-    /**
2850
-     * display_admin_list_table_page_with_no_sidebar
2851
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2852
-     *
2853
-     * @access public
2854
-     * @return void
2855
-     */
2856
-    public function display_admin_list_table_page_with_no_sidebar()
2857
-    {
2858
-        $this->_display_admin_list_table_page();
2859
-    }
2860
-
2861
-
2862
-
2863
-    /**
2864
-     * generates html wrapper for an admin_list_table page
2865
-     *
2866
-     * @access private
2867
-     * @param boolean $sidebar whether to display with sidebar or not.
2868
-     * @return void
2869
-     */
2870
-    private function _display_admin_list_table_page($sidebar = false)
2871
-    {
2872
-        //setup search attributes
2873
-        $this->_set_search_attributes();
2874
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2875
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2876
-        $this->_template_args['table_url']        = defined('DOING_AJAX')
2877
-            ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2878
-            : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2879
-        $this->_template_args['list_table']       = $this->_list_table_object;
2880
-        $this->_template_args['current_route']    = $this->_req_action;
2881
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2882
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2883
-        if (! empty($ajax_sorting_callback)) {
2884
-            $sortable_list_table_form_fields = wp_nonce_field(
2885
-                $ajax_sorting_callback . '_nonce',
2886
-                $ajax_sorting_callback . '_nonce',
2887
-                false,
2888
-                false
2889
-            );
2890
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2891
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2892
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2893
-                                                . $this->page_slug
2894
-                                                . '" />';
2895
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2896
-                                                . $ajax_sorting_callback
2897
-                                                . '" />';
2898
-        } else {
2899
-            $sortable_list_table_form_fields = '';
2900
-        }
2901
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2902
-        $hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
2903
-            ? $this->_template_args['list_table_hidden_fields'] : '';
2904
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2905
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2906
-                                                                    . $nonce_ref
2907
-                                                                    . '" value="'
2908
-                                                                    . wp_create_nonce($nonce_ref)
2909
-                                                                    . '">';
2910
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2911
-        //display message about search results?
2912
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2913
-            ? '<p class="ee-search-results">' . sprintf(
2914
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2915
-                trim($this->_req_data['s'], '%')
2916
-            ) . '</p>'
2917
-            : '';
2918
-        // filter before_list_table template arg
2919
-        $this->_template_args['before_list_table'] = apply_filters(
2920
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2921
-            $this->_template_args['before_list_table'],
2922
-            $this->page_slug,
2923
-            $this->_req_data,
2924
-            $this->_req_action
2925
-        );
2926
-        // convert to array and filter again
2927
-        // arrays are easier to inject new items in a specific location,
2928
-        // but would not be backwards compatible, so we have to add a new filter
2929
-        $this->_template_args['before_list_table'] = implode(
2930
-            " \n",
2931
-            (array)apply_filters(
2932
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2933
-                (array)$this->_template_args['before_list_table'],
2934
-                $this->page_slug,
2935
-                $this->_req_data,
2936
-                $this->_req_action
2937
-            )
2938
-        );
2939
-        // filter after_list_table template arg
2940
-        $this->_template_args['after_list_table'] = apply_filters(
2941
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2942
-            $this->_template_args['after_list_table'],
2943
-            $this->page_slug,
2944
-            $this->_req_data,
2945
-            $this->_req_action
2946
-        );
2947
-        // convert to array and filter again
2948
-        // arrays are easier to inject new items in a specific location,
2949
-        // but would not be backwards compatible, so we have to add a new filter
2950
-        $this->_template_args['after_list_table']   = implode(
2951
-            " \n",
2952
-            (array)apply_filters(
2953
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2954
-                (array)$this->_template_args['after_list_table'],
2955
-                $this->page_slug,
2956
-                $this->_req_data,
2957
-                $this->_req_action
2958
-            )
2959
-        );
2960
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2961
-            $template_path,
2962
-            $this->_template_args,
2963
-            true
2964
-        );
2965
-        // the final template wrapper
2966
-        if ($sidebar) {
2967
-            $this->display_admin_page_with_sidebar();
2968
-        } else {
2969
-            $this->display_admin_page_with_no_sidebar();
2970
-        }
2971
-    }
2972
-
2973
-
2974
-
2975
-    /**
2976
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2977
-     * html string for the legend.
2978
-     * $items are expected in an array in the following format:
2979
-     * $legend_items = array(
2980
-     *        'item_id' => array(
2981
-     *            'icon' => 'http://url_to_icon_being_described.png',
2982
-     *            'desc' => __('localized description of item');
2983
-     *        )
2984
-     * );
2985
-     *
2986
-     * @param  array $items see above for format of array
2987
-     * @return string        html string of legend
2988
-     */
2989
-    protected function _display_legend($items)
2990
-    {
2991
-        $this->_template_args['items'] = apply_filters(
2992
-            'FHEE__EE_Admin_Page___display_legend__items',
2993
-            (array)$items,
2994
-            $this
2995
-        );
2996
-        $legend_template               = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2997
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2998
-    }
2999
-
3000
-
3001
-    /**
3002
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3003
-     * The returned json object is created from an array in the following format:
3004
-     * array(
3005
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3006
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3007
-     *  'notices' => '', // - contains any EE_Error formatted notices
3008
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3009
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3010
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3011
-     *  that might be included in here)
3012
-     * )
3013
-     * The json object is populated by whatever is set in the $_template_args property.
3014
-     *
3015
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3016
-     *                                 instead of displayed.
3017
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3018
-     * @return void
3019
-     */
3020
-    protected function _return_json($sticky_notices = false, $notices_arguments = array())
3021
-    {
3022
-        //make sure any EE_Error notices have been handled.
3023
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3024
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3025
-        unset($this->_template_args['data']);
3026
-        $json = array(
3027
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3028
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3029
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3030
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3031
-            'notices'   => EE_Error::get_notices(),
3032
-            'content'   => isset($this->_template_args['admin_page_content'])
3033
-                ? $this->_template_args['admin_page_content'] : '',
3034
-            'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3035
-            'isEEajax'  => true
3036
-            //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3037
-        );
3038
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3039
-        if (null === error_get_last() || ! headers_sent()) {
3040
-            header('Content-Type: application/json; charset=UTF-8');
3041
-        }
3042
-        echo wp_json_encode($json);
3043
-        exit();
3044
-    }
3045
-
3046
-
3047
-
3048
-    /**
3049
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3050
-     *
3051
-     * @return void
3052
-     * @throws EE_Error
3053
-     */
3054
-    public function return_json()
3055
-    {
3056
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3057
-            $this->_return_json();
3058
-        } else {
3059
-            throw new EE_Error(
3060
-                sprintf(
3061
-                    __('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3062
-                    __FUNCTION__
3063
-                )
3064
-            );
3065
-        }
3066
-    }
3067
-
3068
-
3069
-
3070
-    /**
3071
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3072
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3073
-     *
3074
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3075
-     * @access   public
3076
-     */
3077
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3078
-    {
3079
-        $this->_hook_obj = $hook_obj;
3080
-    }
3081
-
3082
-
3083
-
3084
-    /**
3085
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3086
-     *
3087
-     * @access public
3088
-     * @param  boolean $about whether to use the special about page wrapper or default.
3089
-     * @return void
3090
-     */
3091
-    public function admin_page_wrapper($about = false)
3092
-    {
3093
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3094
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3095
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3096
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3097
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3098
-            'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
3099
-            isset($this->_template_args['before_admin_page_content'])
3100
-                ? $this->_template_args['before_admin_page_content'] : ''
3101
-        );
3102
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3103
-            'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
3104
-            isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content']
3105
-                : ''
3106
-        );
3107
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3108
-        // load settings page wrapper template
3109
-        $template_path = ! defined('DOING_AJAX')
3110
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3111
-            : EE_ADMIN_TEMPLATE
3112
-              . 'admin_wrapper_ajax.template.php';
3113
-        //about page?
3114
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
3115
-        if (defined('DOING_AJAX')) {
3116
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3117
-                $template_path,
3118
-                $this->_template_args,
3119
-                true
3120
-            );
3121
-            $this->_return_json();
3122
-        } else {
3123
-            EEH_Template::display_template($template_path, $this->_template_args);
3124
-        }
3125
-    }
3126
-
3127
-
3128
-
3129
-    /**
3130
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3131
-     *
3132
-     * @return string html
3133
-     */
3134
-    protected function _get_main_nav_tabs()
3135
-    {
3136
-        //let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
3137
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3138
-    }
3139
-
3140
-
3141
-
3142
-    /**
3143
-     *        sort nav tabs
3144
-     *
3145
-     * @access public
3146
-     * @param $a
3147
-     * @param $b
3148
-     * @return int
3149
-     */
3150
-    private function _sort_nav_tabs($a, $b)
3151
-    {
3152
-        if ($a['order'] == $b['order']) {
3153
-            return 0;
3154
-        }
3155
-        return ($a['order'] < $b['order']) ? -1 : 1;
3156
-    }
3157
-
3158
-
3159
-
3160
-    /**
3161
-     *    generates HTML for the forms used on admin pages
3162
-     *
3163
-     * @access protected
3164
-     * @param    array $input_vars - array of input field details
3165
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3166
-     *                             use)
3167
-     * @return string
3168
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3169
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3170
-     */
3171
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3172
-    {
3173
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3174
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3175
-        return $content;
3176
-    }
3177
-
3178
-
3179
-
3180
-    /**
3181
-     * generates the "Save" and "Save & Close" buttons for edit forms
3182
-     *
3183
-     * @access protected
3184
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3185
-     *                                   Close" button.
3186
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3187
-     *                                   'Save', [1] => 'save & close')
3188
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3189
-     *                                   via the "name" value in the button).  We can also use this to just dump
3190
-     *                                   default actions by submitting some other value.
3191
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3192
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3193
-     *                                   close (normal form handling).
3194
-     */
3195
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3196
-    {
3197
-        //make sure $text and $actions are in an array
3198
-        $text          = (array)$text;
3199
-        $actions       = (array)$actions;
3200
-        $referrer_url  = empty($referrer) ? '' : $referrer;
3201
-        $referrer_url  = ! $referrer
3202
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3203
-              . $_SERVER['REQUEST_URI']
3204
-              . '" />'
3205
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3206
-              . $referrer
3207
-              . '" />';
3208
-        $button_text   = ! empty($text)
3209
-            ? $text
3210
-            : array(
3211
-                __('Save', 'event_espresso'),
3212
-                __('Save and Close', 'event_espresso'),
3213
-            );
3214
-        $default_names = array('save', 'save_and_close');
3215
-        //add in a hidden index for the current page (so save and close redirects properly)
3216
-        $this->_template_args['save_buttons'] = $referrer_url;
3217
-        foreach ($button_text as $key => $button) {
3218
-            $ref                                  = $default_names[$key];
3219
-            $id                                   = $this->_current_view . '_' . $ref;
3220
-            $name                                 = ! empty($actions) ? $actions[$key] : $ref;
3221
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3222
-                                                     . $ref
3223
-                                                     . '" value="'
3224
-                                                     . $button
3225
-                                                     . '" name="'
3226
-                                                     . $name
3227
-                                                     . '" id="'
3228
-                                                     . $id
3229
-                                                     . '" />';
3230
-            if (! $both) {
3231
-                break;
3232
-            }
3233
-        }
3234
-    }
3235
-
3236
-
3237
-
3238
-    /**
3239
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3240
-     *
3241
-     * @see   $this->_set_add_edit_form_tags() for details on params
3242
-     * @since 4.6.0
3243
-     * @param string $route
3244
-     * @param array  $additional_hidden_fields
3245
-     */
3246
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3247
-    {
3248
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3249
-    }
3250
-
3251
-
3252
-
3253
-    /**
3254
-     * set form open and close tags on add/edit pages.
3255
-     *
3256
-     * @access protected
3257
-     * @param string $route                    the route you want the form to direct to
3258
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3259
-     * @return void
3260
-     */
3261
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3262
-    {
3263
-        if (empty($route)) {
3264
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
3265
-            $dev_msg  = $user_msg . "\n" . sprintf(
3266
-                    __('The $route argument is required for the %s->%s method.', 'event_espresso'),
3267
-                    __FUNCTION__,
3268
-                    __CLASS__
3269
-                );
3270
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3271
-        }
3272
-        // open form
3273
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3274
-                                                             . $this->_admin_base_url
3275
-                                                             . '" id="'
3276
-                                                             . $route
3277
-                                                             . '_event_form" >';
3278
-        // add nonce
3279
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3280
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3281
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3282
-        // add REQUIRED form action
3283
-        $hidden_fields = array(
3284
-            'action' => array('type' => 'hidden', 'value' => $route),
3285
-        );
3286
-        // merge arrays
3287
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields)
3288
-            : $hidden_fields;
3289
-        // generate form fields
3290
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3291
-        // add fields to form
3292
-        foreach ((array)$form_fields as $field_name => $form_field) {
3293
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3294
-        }
3295
-        // close form
3296
-        $this->_template_args['after_admin_page_content'] = '</form>';
3297
-    }
3298
-
3299
-
3300
-
3301
-    /**
3302
-     * Public Wrapper for _redirect_after_action() method since its
3303
-     * discovered it would be useful for external code to have access.
3304
-     *
3305
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3306
-     * @since 4.5.0
3307
-     */
3308
-    public function redirect_after_action(
3309
-        $success = false,
3310
-        $what = 'item',
3311
-        $action_desc = 'processed',
3312
-        $query_args = array(),
3313
-        $override_overwrite = false
3314
-    ) {
3315
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
3316
-    }
3317
-
3318
-
3319
-
3320
-    /**
3321
-     *    _redirect_after_action
3322
-     *
3323
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3324
-     * @param string $what               - what the action was performed on
3325
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3326
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3327
-     *                                   action is completed
3328
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3329
-     *                                   override this so that they show.
3330
-     * @access protected
3331
-     * @return void
3332
-     */
3333
-    protected function _redirect_after_action(
3334
-        $success = 0,
3335
-        $what = 'item',
3336
-        $action_desc = 'processed',
3337
-        $query_args = array(),
3338
-        $override_overwrite = false
3339
-    ) {
3340
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3341
-        //class name for actions/filters.
3342
-        $classname = get_class($this);
3343
-        //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
3344
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3345
-        $notices      = EE_Error::get_notices(false);
3346
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3347
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3348
-            EE_Error::overwrite_success();
3349
-        }
3350
-        if (! empty($what) && ! empty($action_desc)) {
3351
-            // how many records affected ? more than one record ? or just one ?
3352
-            if ($success > 1 && empty($notices['errors'])) {
3353
-                // set plural msg
3354
-                EE_Error::add_success(
3355
-                    sprintf(
3356
-                        __('The "%s" have been successfully %s.', 'event_espresso'),
3357
-                        $what,
3358
-                        $action_desc
3359
-                    ),
3360
-                    __FILE__,
3361
-                    __FUNCTION__,
3362
-                    __LINE__
3363
-                );
3364
-            } elseif ($success == 1 && empty($notices['errors'])) {
3365
-                // set singular msg
3366
-                EE_Error::add_success(
3367
-                    sprintf(
3368
-                        __('The "%s" has been successfully %s.', 'event_espresso'),
3369
-                        $what,
3370
-                        $action_desc
3371
-                    ),
3372
-                    __FILE__,
3373
-                    __FUNCTION__,
3374
-                    __LINE__
3375
-                );
3376
-            }
3377
-        }
3378
-        // check that $query_args isn't something crazy
3379
-        if (! is_array($query_args)) {
3380
-            $query_args = array();
3381
-        }
3382
-        /**
3383
-         * Allow injecting actions before the query_args are modified for possible different
3384
-         * redirections on save and close actions
3385
-         *
3386
-         * @since 4.2.0
3387
-         * @param array $query_args       The original query_args array coming into the
3388
-         *                                method.
3389
-         */
3390
-        do_action(
3391
-            'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action,
3392
-            $query_args
3393
-        );
3394
-        //calculate where we're going (if we have a "save and close" button pushed)
3395
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
3396
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3397
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3398
-            // regenerate query args array from referrer URL
3399
-            parse_str($parsed_url['query'], $query_args);
3400
-            // correct page and action will be in the query args now
3401
-            $redirect_url = admin_url('admin.php');
3402
-        }
3403
-        //merge any default query_args set in _default_route_query_args property
3404
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3405
-            $args_to_merge = array();
3406
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3407
-                //is there a wp_referer array in our _default_route_query_args property?
3408
-                if ($query_param == 'wp_referer') {
3409
-                    $query_value = (array)$query_value;
3410
-                    foreach ($query_value as $reference => $value) {
3411
-                        if (strpos($reference, 'nonce') !== false) {
3412
-                            continue;
3413
-                        }
3414
-                        //finally we will override any arguments in the referer with
3415
-                        //what might be set on the _default_route_query_args array.
3416
-                        if (isset($this->_default_route_query_args[$reference])) {
3417
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3418
-                        } else {
3419
-                            $args_to_merge[$reference] = urlencode($value);
3420
-                        }
3421
-                    }
3422
-                    continue;
3423
-                }
3424
-                $args_to_merge[$query_param] = $query_value;
3425
-            }
3426
-            //now let's merge these arguments but override with what was specifically sent in to the
3427
-            //redirect.
3428
-            $query_args = array_merge($args_to_merge, $query_args);
3429
-        }
3430
-        $this->_process_notices($query_args);
3431
-        // generate redirect url
3432
-        // if redirecting to anything other than the main page, add a nonce
3433
-        if (isset($query_args['action'])) {
3434
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
3435
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3436
-        }
3437
-        //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
3438
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3439
-        $redirect_url = apply_filters(
3440
-            'FHEE_redirect_' . $classname . $this->_req_action,
3441
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3442
-            $query_args
3443
-        );
3444
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3445
-        if (defined('DOING_AJAX')) {
3446
-            $default_data                    = array(
3447
-                'close'        => true,
3448
-                'redirect_url' => $redirect_url,
3449
-                'where'        => 'main',
3450
-                'what'         => 'append',
3451
-            );
3452
-            $this->_template_args['success'] = $success;
3453
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3454
-                $default_data,
3455
-                $this->_template_args['data']
3456
-            ) : $default_data;
3457
-            $this->_return_json();
3458
-        }
3459
-        wp_safe_redirect($redirect_url);
3460
-        exit();
3461
-    }
3462
-
3463
-
3464
-
3465
-    /**
3466
-     * process any notices before redirecting (or returning ajax request)
3467
-     * This method sets the $this->_template_args['notices'] attribute;
3468
-     *
3469
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
3470
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3471
-     *                                  page_routes haven't been defined yet.
3472
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3473
-     *                                  still save a transient for the notice.
3474
-     * @return void
3475
-     */
3476
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3477
-    {
3478
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
3479
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3480
-            $notices = EE_Error::get_notices(false);
3481
-            if (empty($this->_template_args['success'])) {
3482
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3483
-            }
3484
-            if (empty($this->_template_args['errors'])) {
3485
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3486
-            }
3487
-            if (empty($this->_template_args['attention'])) {
3488
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3489
-            }
3490
-        }
3491
-        $this->_template_args['notices'] = EE_Error::get_notices();
3492
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3493
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3494
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3495
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
3496
-        }
3497
-    }
3498
-
3499
-
3500
-
3501
-    /**
3502
-     * get_action_link_or_button
3503
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3504
-     *
3505
-     * @param string $action        use this to indicate which action the url is generated with.
3506
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3507
-     *                              property.
3508
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3509
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3510
-     * @param string $base_url      If this is not provided
3511
-     *                              the _admin_base_url will be used as the default for the button base_url.
3512
-     *                              Otherwise this value will be used.
3513
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3514
-     * @return string
3515
-     * @throws \EE_Error
3516
-     */
3517
-    public function get_action_link_or_button(
3518
-        $action,
3519
-        $type = 'add',
3520
-        $extra_request = array(),
3521
-        $class = 'button-primary',
3522
-        $base_url = '',
3523
-        $exclude_nonce = false
3524
-    ) {
3525
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3526
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3527
-            throw new EE_Error(
3528
-                sprintf(
3529
-                    __(
3530
-                        'There is no page route for given action for the button.  This action was given: %s',
3531
-                        'event_espresso'
3532
-                    ),
3533
-                    $action
3534
-                )
3535
-            );
3536
-        }
3537
-        if (! isset($this->_labels['buttons'][$type])) {
3538
-            throw new EE_Error(
3539
-                sprintf(
3540
-                    __(
3541
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3542
-                        'event_espresso'
3543
-                    ),
3544
-                    $type
3545
-                )
3546
-            );
3547
-        }
3548
-        //finally check user access for this button.
3549
-        $has_access = $this->check_user_access($action, true);
3550
-        if (! $has_access) {
3551
-            return '';
3552
-        }
3553
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3554
-        $query_args = array(
3555
-            'action' => $action,
3556
-        );
3557
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3558
-        if (! empty($extra_request)) {
3559
-            $query_args = array_merge($extra_request, $query_args);
3560
-        }
3561
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3562
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3563
-    }
3564
-
3565
-
3566
-
3567
-    /**
3568
-     * _per_page_screen_option
3569
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3570
-     *
3571
-     * @return void
3572
-     */
3573
-    protected function _per_page_screen_option()
3574
-    {
3575
-        $option = 'per_page';
3576
-        $args   = array(
3577
-            'label'   => $this->_admin_page_title,
3578
-            'default' => 10,
3579
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3580
-        );
3581
-        //ONLY add the screen option if the user has access to it.
3582
-        if ($this->check_user_access($this->_current_view, true)) {
3583
-            add_screen_option($option, $args);
3584
-        }
3585
-    }
3586
-
3587
-
3588
-
3589
-    /**
3590
-     * set_per_page_screen_option
3591
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3592
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3593
-     * admin_menu.
3594
-     *
3595
-     * @access private
3596
-     * @return void
3597
-     */
3598
-    private function _set_per_page_screen_options()
3599
-    {
3600
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3601
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3602
-            if (! $user = wp_get_current_user()) {
3603
-                return;
3604
-            }
3605
-            $option = $_POST['wp_screen_options']['option'];
3606
-            $value  = $_POST['wp_screen_options']['value'];
3607
-            if ($option != sanitize_key($option)) {
3608
-                return;
3609
-            }
3610
-            $map_option = $option;
3611
-            $option     = str_replace('-', '_', $option);
3612
-            switch ($map_option) {
3613
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3614
-                    $value = (int)$value;
3615
-                    if ($value < 1 || $value > 999) {
3616
-                        return;
3617
-                    }
3618
-                    break;
3619
-                default:
3620
-                    $value = apply_filters(
3621
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
-                        false,
3623
-                        $option,
3624
-                        $value
3625
-                    );
3626
-                    if (false === $value) {
3627
-                        return;
3628
-                    }
3629
-                    break;
3630
-            }
3631
-            update_user_meta($user->ID, $option, $value);
3632
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3633
-            exit;
3634
-        }
3635
-    }
3636
-
3637
-
3638
-
3639
-    /**
3640
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
-     *
3642
-     * @param array $data array that will be assigned to template args.
3643
-     */
3644
-    public function set_template_args($data)
3645
-    {
3646
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3647
-    }
3648
-
3649
-
3650
-
3651
-    /**
3652
-     * This makes available the WP transient system for temporarily moving data between routes
3653
-     *
3654
-     * @access protected
3655
-     * @param string $route             the route that should receive the transient
3656
-     * @param array  $data              the data that gets sent
3657
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3658
-     *                                  normal route transient.
3659
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3660
-     *                                  when we are adding a transient before page_routes have been defined.
3661
-     * @return void
3662
-     */
3663
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3664
-    {
3665
-        $user_id = get_current_user_id();
3666
-        if (! $skip_route_verify) {
3667
-            $this->_verify_route($route);
3668
-        }
3669
-        //now let's set the string for what kind of transient we're setting
3670
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3671
-        $data      = $notices ? array('notices' => $data) : $data;
3672
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3673
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3674
-        if ($existing) {
3675
-            $data = array_merge((array)$data, (array)$existing);
3676
-        }
3677
-        if (is_multisite() && is_network_admin()) {
3678
-            set_site_transient($transient, $data, 8);
3679
-        } else {
3680
-            set_transient($transient, $data, 8);
3681
-        }
3682
-    }
3683
-
3684
-
3685
-
3686
-    /**
3687
-     * this retrieves the temporary transient that has been set for moving data between routes.
3688
-     *
3689
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3690
-     * @return mixed data
3691
-     */
3692
-    protected function _get_transient($notices = false, $route = false)
3693
-    {
3694
-        $user_id   = get_current_user_id();
3695
-        $route     = ! $route ? $this->_req_action : $route;
3696
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3697
-        $data      = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3698
-        //delete transient after retrieval (just in case it hasn't expired);
3699
-        if (is_multisite() && is_network_admin()) {
3700
-            delete_site_transient($transient);
3701
-        } else {
3702
-            delete_transient($transient);
3703
-        }
3704
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3705
-    }
3706
-
3707
-
3708
-
3709
-    /**
3710
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3711
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3712
-     * default route callback on the EE_Admin page you want it run.)
3713
-     *
3714
-     * @return void
3715
-     */
3716
-    protected function _transient_garbage_collection()
3717
-    {
3718
-        global $wpdb;
3719
-        //retrieve all existing transients
3720
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3721
-        if ($results = $wpdb->get_results($query)) {
3722
-            foreach ($results as $result) {
3723
-                $transient = str_replace('_transient_', '', $result->option_name);
3724
-                get_transient($transient);
3725
-                if (is_multisite() && is_network_admin()) {
3726
-                    get_site_transient($transient);
3727
-                }
3728
-            }
3729
-        }
3730
-    }
3731
-
3732
-
3733
-
3734
-    /**
3735
-     * get_view
3736
-     *
3737
-     * @access public
3738
-     * @return string content of _view property
3739
-     */
3740
-    public function get_view()
3741
-    {
3742
-        return $this->_view;
3743
-    }
3744
-
3745
-
3746
-
3747
-    /**
3748
-     * getter for the protected $_views property
3749
-     *
3750
-     * @return array
3751
-     */
3752
-    public function get_views()
3753
-    {
3754
-        return $this->_views;
3755
-    }
3756
-
3757
-
3758
-
3759
-    /**
3760
-     * get_current_page
3761
-     *
3762
-     * @access public
3763
-     * @return string _current_page property value
3764
-     */
3765
-    public function get_current_page()
3766
-    {
3767
-        return $this->_current_page;
3768
-    }
3769
-
3770
-
3771
-
3772
-    /**
3773
-     * get_current_view
3774
-     *
3775
-     * @access public
3776
-     * @return string _current_view property value
3777
-     */
3778
-    public function get_current_view()
3779
-    {
3780
-        return $this->_current_view;
3781
-    }
3782
-
3783
-
3784
-
3785
-    /**
3786
-     * get_current_screen
3787
-     *
3788
-     * @access public
3789
-     * @return object The current WP_Screen object
3790
-     */
3791
-    public function get_current_screen()
3792
-    {
3793
-        return $this->_current_screen;
3794
-    }
3795
-
3796
-
3797
-
3798
-    /**
3799
-     * get_current_page_view_url
3800
-     *
3801
-     * @access public
3802
-     * @return string This returns the url for the current_page_view.
3803
-     */
3804
-    public function get_current_page_view_url()
3805
-    {
3806
-        return $this->_current_page_view_url;
3807
-    }
3808
-
3809
-
3810
-
3811
-    /**
3812
-     * just returns the _req_data property
3813
-     *
3814
-     * @return array
3815
-     */
3816
-    public function get_request_data()
3817
-    {
3818
-        return $this->_req_data;
3819
-    }
3820
-
3821
-
3822
-
3823
-    /**
3824
-     * returns the _req_data protected property
3825
-     *
3826
-     * @return string
3827
-     */
3828
-    public function get_req_action()
3829
-    {
3830
-        return $this->_req_action;
3831
-    }
3832
-
3833
-
3834
-
3835
-    /**
3836
-     * @return bool  value of $_is_caf property
3837
-     */
3838
-    public function is_caf()
3839
-    {
3840
-        return $this->_is_caf;
3841
-    }
3842
-
3843
-
3844
-
3845
-    /**
3846
-     * @return mixed
3847
-     */
3848
-    public function default_espresso_metaboxes()
3849
-    {
3850
-        return $this->_default_espresso_metaboxes;
3851
-    }
3852
-
3853
-
3854
-
3855
-    /**
3856
-     * @return mixed
3857
-     */
3858
-    public function admin_base_url()
3859
-    {
3860
-        return $this->_admin_base_url;
3861
-    }
2635
+	}
2636
+
2637
+
2638
+
2639
+	/**
2640
+	 * facade for add_meta_box
2641
+	 *
2642
+	 * @param string  $action        where the metabox get's displayed
2643
+	 * @param string  $title         Title of Metabox (output in metabox header)
2644
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2645
+	 *                               instead of the one created in here.
2646
+	 * @param array   $callback_args an array of args supplied for the metabox
2647
+	 * @param string  $column        what metabox column
2648
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2649
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2650
+	 *                               created but just set our own callback for wp's add_meta_box.
2651
+	 */
2652
+	public function _add_admin_page_meta_box(
2653
+		$action,
2654
+		$title,
2655
+		$callback,
2656
+		$callback_args,
2657
+		$column = 'normal',
2658
+		$priority = 'high',
2659
+		$create_func = true
2660
+	) {
2661
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2662
+		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2663
+		if (empty($callback_args) && $create_func) {
2664
+			$callback_args = array(
2665
+				'template_path' => $this->_template_path,
2666
+				'template_args' => $this->_template_args,
2667
+			);
2668
+		}
2669
+		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2670
+		$call_back_func = $create_func ? create_function(
2671
+			'$post, $metabox',
2672
+			'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'
2673
+		) : $callback;
2674
+		add_meta_box(
2675
+			str_replace('_', '-', $action) . '-mbox',
2676
+			$title,
2677
+			$call_back_func,
2678
+			$this->_wp_page_slug,
2679
+			$column,
2680
+			$priority,
2681
+			$callback_args
2682
+		);
2683
+	}
2684
+
2685
+
2686
+
2687
+	/**
2688
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2689
+	 *
2690
+	 * @return [type] [description]
2691
+	 */
2692
+	public function display_admin_page_with_metabox_columns()
2693
+	{
2694
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2695
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2696
+			$this->_column_template_path,
2697
+			$this->_template_args,
2698
+			true
2699
+		);
2700
+		//the final wrapper
2701
+		$this->admin_page_wrapper();
2702
+	}
2703
+
2704
+
2705
+
2706
+	/**
2707
+	 *        generates  HTML wrapper for an admin details page
2708
+	 *
2709
+	 * @access public
2710
+	 * @return void
2711
+	 */
2712
+	public function display_admin_page_with_sidebar()
2713
+	{
2714
+		$this->_display_admin_page(true);
2715
+	}
2716
+
2717
+
2718
+
2719
+	/**
2720
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2721
+	 *
2722
+	 * @access public
2723
+	 * @return void
2724
+	 */
2725
+	public function display_admin_page_with_no_sidebar()
2726
+	{
2727
+		$this->_display_admin_page();
2728
+	}
2729
+
2730
+
2731
+
2732
+	/**
2733
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2734
+	 *
2735
+	 * @access public
2736
+	 * @return void
2737
+	 */
2738
+	public function display_about_admin_page()
2739
+	{
2740
+		$this->_display_admin_page(false, true);
2741
+	}
2742
+
2743
+
2744
+
2745
+	/**
2746
+	 * display_admin_page
2747
+	 * contains the code for actually displaying an admin page
2748
+	 *
2749
+	 * @access private
2750
+	 * @param  boolean $sidebar true with sidebar, false without
2751
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2752
+	 * @return void
2753
+	 */
2754
+	private function _display_admin_page($sidebar = false, $about = false)
2755
+	{
2756
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2757
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2758
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2759
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2760
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2761
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2762
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2763
+			? 'poststuff'
2764
+			: 'espresso-default-admin';
2765
+		$template_path                                     = $sidebar
2766
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2767
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2768
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2769
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2770
+		}
2771
+		$template_path                                     = ! empty($this->_column_template_path)
2772
+			? $this->_column_template_path : $template_path;
2773
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2774
+			? $this->_template_args['admin_page_content'] : '';
2775
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2776
+			? $this->_template_args['before_admin_page_content'] : '';
2777
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2778
+			? $this->_template_args['after_admin_page_content'] : '';
2779
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2780
+			$template_path,
2781
+			$this->_template_args,
2782
+			true
2783
+		);
2784
+		// the final template wrapper
2785
+		$this->admin_page_wrapper($about);
2786
+	}
2787
+
2788
+
2789
+
2790
+	/**
2791
+	 * This is used to display caf preview pages.
2792
+	 *
2793
+	 * @since 4.3.2
2794
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2795
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2796
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2797
+	 * @return void
2798
+	 * @throws \EE_Error
2799
+	 */
2800
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2801
+	{
2802
+		//let's generate a default preview action button if there isn't one already present.
2803
+		$this->_labels['buttons']['buy_now']           = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2804
+		$buy_now_url                                   = add_query_arg(
2805
+			array(
2806
+				'ee_ver'       => 'ee4',
2807
+				'utm_source'   => 'ee4_plugin_admin',
2808
+				'utm_medium'   => 'link',
2809
+				'utm_campaign' => $utm_campaign_source,
2810
+				'utm_content'  => 'buy_now_button',
2811
+			),
2812
+			'http://eventespresso.com/pricing/'
2813
+		);
2814
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2815
+			? $this->get_action_link_or_button(
2816
+				'',
2817
+				'buy_now',
2818
+				array(),
2819
+				'button-primary button-large',
2820
+				$buy_now_url,
2821
+				true
2822
+			)
2823
+			: $this->_template_args['preview_action_button'];
2824
+		$template_path                                 = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2825
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2826
+			$template_path,
2827
+			$this->_template_args,
2828
+			true
2829
+		);
2830
+		$this->_display_admin_page($display_sidebar);
2831
+	}
2832
+
2833
+
2834
+
2835
+	/**
2836
+	 * display_admin_list_table_page_with_sidebar
2837
+	 * generates HTML wrapper for an admin_page with list_table
2838
+	 *
2839
+	 * @access public
2840
+	 * @return void
2841
+	 */
2842
+	public function display_admin_list_table_page_with_sidebar()
2843
+	{
2844
+		$this->_display_admin_list_table_page(true);
2845
+	}
2846
+
2847
+
2848
+
2849
+	/**
2850
+	 * display_admin_list_table_page_with_no_sidebar
2851
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2852
+	 *
2853
+	 * @access public
2854
+	 * @return void
2855
+	 */
2856
+	public function display_admin_list_table_page_with_no_sidebar()
2857
+	{
2858
+		$this->_display_admin_list_table_page();
2859
+	}
2860
+
2861
+
2862
+
2863
+	/**
2864
+	 * generates html wrapper for an admin_list_table page
2865
+	 *
2866
+	 * @access private
2867
+	 * @param boolean $sidebar whether to display with sidebar or not.
2868
+	 * @return void
2869
+	 */
2870
+	private function _display_admin_list_table_page($sidebar = false)
2871
+	{
2872
+		//setup search attributes
2873
+		$this->_set_search_attributes();
2874
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2875
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2876
+		$this->_template_args['table_url']        = defined('DOING_AJAX')
2877
+			? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2878
+			: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2879
+		$this->_template_args['list_table']       = $this->_list_table_object;
2880
+		$this->_template_args['current_route']    = $this->_req_action;
2881
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2882
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2883
+		if (! empty($ajax_sorting_callback)) {
2884
+			$sortable_list_table_form_fields = wp_nonce_field(
2885
+				$ajax_sorting_callback . '_nonce',
2886
+				$ajax_sorting_callback . '_nonce',
2887
+				false,
2888
+				false
2889
+			);
2890
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2891
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2892
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
2893
+												. $this->page_slug
2894
+												. '" />';
2895
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
2896
+												. $ajax_sorting_callback
2897
+												. '" />';
2898
+		} else {
2899
+			$sortable_list_table_form_fields = '';
2900
+		}
2901
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2902
+		$hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
2903
+			? $this->_template_args['list_table_hidden_fields'] : '';
2904
+		$nonce_ref                                               = $this->_req_action . '_nonce';
2905
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
2906
+																	. $nonce_ref
2907
+																	. '" value="'
2908
+																	. wp_create_nonce($nonce_ref)
2909
+																	. '">';
2910
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2911
+		//display message about search results?
2912
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2913
+			? '<p class="ee-search-results">' . sprintf(
2914
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2915
+				trim($this->_req_data['s'], '%')
2916
+			) . '</p>'
2917
+			: '';
2918
+		// filter before_list_table template arg
2919
+		$this->_template_args['before_list_table'] = apply_filters(
2920
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2921
+			$this->_template_args['before_list_table'],
2922
+			$this->page_slug,
2923
+			$this->_req_data,
2924
+			$this->_req_action
2925
+		);
2926
+		// convert to array and filter again
2927
+		// arrays are easier to inject new items in a specific location,
2928
+		// but would not be backwards compatible, so we have to add a new filter
2929
+		$this->_template_args['before_list_table'] = implode(
2930
+			" \n",
2931
+			(array)apply_filters(
2932
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2933
+				(array)$this->_template_args['before_list_table'],
2934
+				$this->page_slug,
2935
+				$this->_req_data,
2936
+				$this->_req_action
2937
+			)
2938
+		);
2939
+		// filter after_list_table template arg
2940
+		$this->_template_args['after_list_table'] = apply_filters(
2941
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2942
+			$this->_template_args['after_list_table'],
2943
+			$this->page_slug,
2944
+			$this->_req_data,
2945
+			$this->_req_action
2946
+		);
2947
+		// convert to array and filter again
2948
+		// arrays are easier to inject new items in a specific location,
2949
+		// but would not be backwards compatible, so we have to add a new filter
2950
+		$this->_template_args['after_list_table']   = implode(
2951
+			" \n",
2952
+			(array)apply_filters(
2953
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2954
+				(array)$this->_template_args['after_list_table'],
2955
+				$this->page_slug,
2956
+				$this->_req_data,
2957
+				$this->_req_action
2958
+			)
2959
+		);
2960
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2961
+			$template_path,
2962
+			$this->_template_args,
2963
+			true
2964
+		);
2965
+		// the final template wrapper
2966
+		if ($sidebar) {
2967
+			$this->display_admin_page_with_sidebar();
2968
+		} else {
2969
+			$this->display_admin_page_with_no_sidebar();
2970
+		}
2971
+	}
2972
+
2973
+
2974
+
2975
+	/**
2976
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
2977
+	 * html string for the legend.
2978
+	 * $items are expected in an array in the following format:
2979
+	 * $legend_items = array(
2980
+	 *        'item_id' => array(
2981
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2982
+	 *            'desc' => __('localized description of item');
2983
+	 *        )
2984
+	 * );
2985
+	 *
2986
+	 * @param  array $items see above for format of array
2987
+	 * @return string        html string of legend
2988
+	 */
2989
+	protected function _display_legend($items)
2990
+	{
2991
+		$this->_template_args['items'] = apply_filters(
2992
+			'FHEE__EE_Admin_Page___display_legend__items',
2993
+			(array)$items,
2994
+			$this
2995
+		);
2996
+		$legend_template               = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2997
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2998
+	}
2999
+
3000
+
3001
+	/**
3002
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3003
+	 * The returned json object is created from an array in the following format:
3004
+	 * array(
3005
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3006
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3007
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3008
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3009
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3010
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3011
+	 *  that might be included in here)
3012
+	 * )
3013
+	 * The json object is populated by whatever is set in the $_template_args property.
3014
+	 *
3015
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3016
+	 *                                 instead of displayed.
3017
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3018
+	 * @return void
3019
+	 */
3020
+	protected function _return_json($sticky_notices = false, $notices_arguments = array())
3021
+	{
3022
+		//make sure any EE_Error notices have been handled.
3023
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3024
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
3025
+		unset($this->_template_args['data']);
3026
+		$json = array(
3027
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3028
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3029
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3030
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3031
+			'notices'   => EE_Error::get_notices(),
3032
+			'content'   => isset($this->_template_args['admin_page_content'])
3033
+				? $this->_template_args['admin_page_content'] : '',
3034
+			'data'      => array_merge($data, array('template_args' => $this->_template_args)),
3035
+			'isEEajax'  => true
3036
+			//special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3037
+		);
3038
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3039
+		if (null === error_get_last() || ! headers_sent()) {
3040
+			header('Content-Type: application/json; charset=UTF-8');
3041
+		}
3042
+		echo wp_json_encode($json);
3043
+		exit();
3044
+	}
3045
+
3046
+
3047
+
3048
+	/**
3049
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3050
+	 *
3051
+	 * @return void
3052
+	 * @throws EE_Error
3053
+	 */
3054
+	public function return_json()
3055
+	{
3056
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3057
+			$this->_return_json();
3058
+		} else {
3059
+			throw new EE_Error(
3060
+				sprintf(
3061
+					__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3062
+					__FUNCTION__
3063
+				)
3064
+			);
3065
+		}
3066
+	}
3067
+
3068
+
3069
+
3070
+	/**
3071
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3072
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3073
+	 *
3074
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3075
+	 * @access   public
3076
+	 */
3077
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3078
+	{
3079
+		$this->_hook_obj = $hook_obj;
3080
+	}
3081
+
3082
+
3083
+
3084
+	/**
3085
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3086
+	 *
3087
+	 * @access public
3088
+	 * @param  boolean $about whether to use the special about page wrapper or default.
3089
+	 * @return void
3090
+	 */
3091
+	public function admin_page_wrapper($about = false)
3092
+	{
3093
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3094
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3095
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3096
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3097
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3098
+			'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
3099
+			isset($this->_template_args['before_admin_page_content'])
3100
+				? $this->_template_args['before_admin_page_content'] : ''
3101
+		);
3102
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3103
+			'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
3104
+			isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content']
3105
+				: ''
3106
+		);
3107
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3108
+		// load settings page wrapper template
3109
+		$template_path = ! defined('DOING_AJAX')
3110
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3111
+			: EE_ADMIN_TEMPLATE
3112
+			  . 'admin_wrapper_ajax.template.php';
3113
+		//about page?
3114
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
3115
+		if (defined('DOING_AJAX')) {
3116
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3117
+				$template_path,
3118
+				$this->_template_args,
3119
+				true
3120
+			);
3121
+			$this->_return_json();
3122
+		} else {
3123
+			EEH_Template::display_template($template_path, $this->_template_args);
3124
+		}
3125
+	}
3126
+
3127
+
3128
+
3129
+	/**
3130
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3131
+	 *
3132
+	 * @return string html
3133
+	 */
3134
+	protected function _get_main_nav_tabs()
3135
+	{
3136
+		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
3137
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3138
+	}
3139
+
3140
+
3141
+
3142
+	/**
3143
+	 *        sort nav tabs
3144
+	 *
3145
+	 * @access public
3146
+	 * @param $a
3147
+	 * @param $b
3148
+	 * @return int
3149
+	 */
3150
+	private function _sort_nav_tabs($a, $b)
3151
+	{
3152
+		if ($a['order'] == $b['order']) {
3153
+			return 0;
3154
+		}
3155
+		return ($a['order'] < $b['order']) ? -1 : 1;
3156
+	}
3157
+
3158
+
3159
+
3160
+	/**
3161
+	 *    generates HTML for the forms used on admin pages
3162
+	 *
3163
+	 * @access protected
3164
+	 * @param    array $input_vars - array of input field details
3165
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to
3166
+	 *                             use)
3167
+	 * @return string
3168
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3169
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3170
+	 */
3171
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
3172
+	{
3173
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3174
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3175
+		return $content;
3176
+	}
3177
+
3178
+
3179
+
3180
+	/**
3181
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3182
+	 *
3183
+	 * @access protected
3184
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3185
+	 *                                   Close" button.
3186
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3187
+	 *                                   'Save', [1] => 'save & close')
3188
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3189
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3190
+	 *                                   default actions by submitting some other value.
3191
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3192
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3193
+	 *                                   close (normal form handling).
3194
+	 */
3195
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3196
+	{
3197
+		//make sure $text and $actions are in an array
3198
+		$text          = (array)$text;
3199
+		$actions       = (array)$actions;
3200
+		$referrer_url  = empty($referrer) ? '' : $referrer;
3201
+		$referrer_url  = ! $referrer
3202
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3203
+			  . $_SERVER['REQUEST_URI']
3204
+			  . '" />'
3205
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3206
+			  . $referrer
3207
+			  . '" />';
3208
+		$button_text   = ! empty($text)
3209
+			? $text
3210
+			: array(
3211
+				__('Save', 'event_espresso'),
3212
+				__('Save and Close', 'event_espresso'),
3213
+			);
3214
+		$default_names = array('save', 'save_and_close');
3215
+		//add in a hidden index for the current page (so save and close redirects properly)
3216
+		$this->_template_args['save_buttons'] = $referrer_url;
3217
+		foreach ($button_text as $key => $button) {
3218
+			$ref                                  = $default_names[$key];
3219
+			$id                                   = $this->_current_view . '_' . $ref;
3220
+			$name                                 = ! empty($actions) ? $actions[$key] : $ref;
3221
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3222
+													 . $ref
3223
+													 . '" value="'
3224
+													 . $button
3225
+													 . '" name="'
3226
+													 . $name
3227
+													 . '" id="'
3228
+													 . $id
3229
+													 . '" />';
3230
+			if (! $both) {
3231
+				break;
3232
+			}
3233
+		}
3234
+	}
3235
+
3236
+
3237
+
3238
+	/**
3239
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3240
+	 *
3241
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3242
+	 * @since 4.6.0
3243
+	 * @param string $route
3244
+	 * @param array  $additional_hidden_fields
3245
+	 */
3246
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3247
+	{
3248
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3249
+	}
3250
+
3251
+
3252
+
3253
+	/**
3254
+	 * set form open and close tags on add/edit pages.
3255
+	 *
3256
+	 * @access protected
3257
+	 * @param string $route                    the route you want the form to direct to
3258
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3259
+	 * @return void
3260
+	 */
3261
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
3262
+	{
3263
+		if (empty($route)) {
3264
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
3265
+			$dev_msg  = $user_msg . "\n" . sprintf(
3266
+					__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3267
+					__FUNCTION__,
3268
+					__CLASS__
3269
+				);
3270
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3271
+		}
3272
+		// open form
3273
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3274
+															 . $this->_admin_base_url
3275
+															 . '" id="'
3276
+															 . $route
3277
+															 . '_event_form" >';
3278
+		// add nonce
3279
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3280
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3281
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3282
+		// add REQUIRED form action
3283
+		$hidden_fields = array(
3284
+			'action' => array('type' => 'hidden', 'value' => $route),
3285
+		);
3286
+		// merge arrays
3287
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields)
3288
+			: $hidden_fields;
3289
+		// generate form fields
3290
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3291
+		// add fields to form
3292
+		foreach ((array)$form_fields as $field_name => $form_field) {
3293
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3294
+		}
3295
+		// close form
3296
+		$this->_template_args['after_admin_page_content'] = '</form>';
3297
+	}
3298
+
3299
+
3300
+
3301
+	/**
3302
+	 * Public Wrapper for _redirect_after_action() method since its
3303
+	 * discovered it would be useful for external code to have access.
3304
+	 *
3305
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3306
+	 * @since 4.5.0
3307
+	 */
3308
+	public function redirect_after_action(
3309
+		$success = false,
3310
+		$what = 'item',
3311
+		$action_desc = 'processed',
3312
+		$query_args = array(),
3313
+		$override_overwrite = false
3314
+	) {
3315
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
3316
+	}
3317
+
3318
+
3319
+
3320
+	/**
3321
+	 *    _redirect_after_action
3322
+	 *
3323
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3324
+	 * @param string $what               - what the action was performed on
3325
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3326
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3327
+	 *                                   action is completed
3328
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3329
+	 *                                   override this so that they show.
3330
+	 * @access protected
3331
+	 * @return void
3332
+	 */
3333
+	protected function _redirect_after_action(
3334
+		$success = 0,
3335
+		$what = 'item',
3336
+		$action_desc = 'processed',
3337
+		$query_args = array(),
3338
+		$override_overwrite = false
3339
+	) {
3340
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3341
+		//class name for actions/filters.
3342
+		$classname = get_class($this);
3343
+		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
3344
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3345
+		$notices      = EE_Error::get_notices(false);
3346
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3347
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3348
+			EE_Error::overwrite_success();
3349
+		}
3350
+		if (! empty($what) && ! empty($action_desc)) {
3351
+			// how many records affected ? more than one record ? or just one ?
3352
+			if ($success > 1 && empty($notices['errors'])) {
3353
+				// set plural msg
3354
+				EE_Error::add_success(
3355
+					sprintf(
3356
+						__('The "%s" have been successfully %s.', 'event_espresso'),
3357
+						$what,
3358
+						$action_desc
3359
+					),
3360
+					__FILE__,
3361
+					__FUNCTION__,
3362
+					__LINE__
3363
+				);
3364
+			} elseif ($success == 1 && empty($notices['errors'])) {
3365
+				// set singular msg
3366
+				EE_Error::add_success(
3367
+					sprintf(
3368
+						__('The "%s" has been successfully %s.', 'event_espresso'),
3369
+						$what,
3370
+						$action_desc
3371
+					),
3372
+					__FILE__,
3373
+					__FUNCTION__,
3374
+					__LINE__
3375
+				);
3376
+			}
3377
+		}
3378
+		// check that $query_args isn't something crazy
3379
+		if (! is_array($query_args)) {
3380
+			$query_args = array();
3381
+		}
3382
+		/**
3383
+		 * Allow injecting actions before the query_args are modified for possible different
3384
+		 * redirections on save and close actions
3385
+		 *
3386
+		 * @since 4.2.0
3387
+		 * @param array $query_args       The original query_args array coming into the
3388
+		 *                                method.
3389
+		 */
3390
+		do_action(
3391
+			'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action,
3392
+			$query_args
3393
+		);
3394
+		//calculate where we're going (if we have a "save and close" button pushed)
3395
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
3396
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3397
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
3398
+			// regenerate query args array from referrer URL
3399
+			parse_str($parsed_url['query'], $query_args);
3400
+			// correct page and action will be in the query args now
3401
+			$redirect_url = admin_url('admin.php');
3402
+		}
3403
+		//merge any default query_args set in _default_route_query_args property
3404
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3405
+			$args_to_merge = array();
3406
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3407
+				//is there a wp_referer array in our _default_route_query_args property?
3408
+				if ($query_param == 'wp_referer') {
3409
+					$query_value = (array)$query_value;
3410
+					foreach ($query_value as $reference => $value) {
3411
+						if (strpos($reference, 'nonce') !== false) {
3412
+							continue;
3413
+						}
3414
+						//finally we will override any arguments in the referer with
3415
+						//what might be set on the _default_route_query_args array.
3416
+						if (isset($this->_default_route_query_args[$reference])) {
3417
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
3418
+						} else {
3419
+							$args_to_merge[$reference] = urlencode($value);
3420
+						}
3421
+					}
3422
+					continue;
3423
+				}
3424
+				$args_to_merge[$query_param] = $query_value;
3425
+			}
3426
+			//now let's merge these arguments but override with what was specifically sent in to the
3427
+			//redirect.
3428
+			$query_args = array_merge($args_to_merge, $query_args);
3429
+		}
3430
+		$this->_process_notices($query_args);
3431
+		// generate redirect url
3432
+		// if redirecting to anything other than the main page, add a nonce
3433
+		if (isset($query_args['action'])) {
3434
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
3435
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3436
+		}
3437
+		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
3438
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3439
+		$redirect_url = apply_filters(
3440
+			'FHEE_redirect_' . $classname . $this->_req_action,
3441
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3442
+			$query_args
3443
+		);
3444
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3445
+		if (defined('DOING_AJAX')) {
3446
+			$default_data                    = array(
3447
+				'close'        => true,
3448
+				'redirect_url' => $redirect_url,
3449
+				'where'        => 'main',
3450
+				'what'         => 'append',
3451
+			);
3452
+			$this->_template_args['success'] = $success;
3453
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3454
+				$default_data,
3455
+				$this->_template_args['data']
3456
+			) : $default_data;
3457
+			$this->_return_json();
3458
+		}
3459
+		wp_safe_redirect($redirect_url);
3460
+		exit();
3461
+	}
3462
+
3463
+
3464
+
3465
+	/**
3466
+	 * process any notices before redirecting (or returning ajax request)
3467
+	 * This method sets the $this->_template_args['notices'] attribute;
3468
+	 *
3469
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
3470
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and
3471
+	 *                                  page_routes haven't been defined yet.
3472
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we
3473
+	 *                                  still save a transient for the notice.
3474
+	 * @return void
3475
+	 */
3476
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
3477
+	{
3478
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
3479
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3480
+			$notices = EE_Error::get_notices(false);
3481
+			if (empty($this->_template_args['success'])) {
3482
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3483
+			}
3484
+			if (empty($this->_template_args['errors'])) {
3485
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3486
+			}
3487
+			if (empty($this->_template_args['attention'])) {
3488
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3489
+			}
3490
+		}
3491
+		$this->_template_args['notices'] = EE_Error::get_notices();
3492
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3493
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3494
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3495
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
3496
+		}
3497
+	}
3498
+
3499
+
3500
+
3501
+	/**
3502
+	 * get_action_link_or_button
3503
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3504
+	 *
3505
+	 * @param string $action        use this to indicate which action the url is generated with.
3506
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3507
+	 *                              property.
3508
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3509
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3510
+	 * @param string $base_url      If this is not provided
3511
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3512
+	 *                              Otherwise this value will be used.
3513
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3514
+	 * @return string
3515
+	 * @throws \EE_Error
3516
+	 */
3517
+	public function get_action_link_or_button(
3518
+		$action,
3519
+		$type = 'add',
3520
+		$extra_request = array(),
3521
+		$class = 'button-primary',
3522
+		$base_url = '',
3523
+		$exclude_nonce = false
3524
+	) {
3525
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3526
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
3527
+			throw new EE_Error(
3528
+				sprintf(
3529
+					__(
3530
+						'There is no page route for given action for the button.  This action was given: %s',
3531
+						'event_espresso'
3532
+					),
3533
+					$action
3534
+				)
3535
+			);
3536
+		}
3537
+		if (! isset($this->_labels['buttons'][$type])) {
3538
+			throw new EE_Error(
3539
+				sprintf(
3540
+					__(
3541
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3542
+						'event_espresso'
3543
+					),
3544
+					$type
3545
+				)
3546
+			);
3547
+		}
3548
+		//finally check user access for this button.
3549
+		$has_access = $this->check_user_access($action, true);
3550
+		if (! $has_access) {
3551
+			return '';
3552
+		}
3553
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3554
+		$query_args = array(
3555
+			'action' => $action,
3556
+		);
3557
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3558
+		if (! empty($extra_request)) {
3559
+			$query_args = array_merge($extra_request, $query_args);
3560
+		}
3561
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3562
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
3563
+	}
3564
+
3565
+
3566
+
3567
+	/**
3568
+	 * _per_page_screen_option
3569
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3570
+	 *
3571
+	 * @return void
3572
+	 */
3573
+	protected function _per_page_screen_option()
3574
+	{
3575
+		$option = 'per_page';
3576
+		$args   = array(
3577
+			'label'   => $this->_admin_page_title,
3578
+			'default' => 10,
3579
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3580
+		);
3581
+		//ONLY add the screen option if the user has access to it.
3582
+		if ($this->check_user_access($this->_current_view, true)) {
3583
+			add_screen_option($option, $args);
3584
+		}
3585
+	}
3586
+
3587
+
3588
+
3589
+	/**
3590
+	 * set_per_page_screen_option
3591
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3592
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3593
+	 * admin_menu.
3594
+	 *
3595
+	 * @access private
3596
+	 * @return void
3597
+	 */
3598
+	private function _set_per_page_screen_options()
3599
+	{
3600
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3601
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3602
+			if (! $user = wp_get_current_user()) {
3603
+				return;
3604
+			}
3605
+			$option = $_POST['wp_screen_options']['option'];
3606
+			$value  = $_POST['wp_screen_options']['value'];
3607
+			if ($option != sanitize_key($option)) {
3608
+				return;
3609
+			}
3610
+			$map_option = $option;
3611
+			$option     = str_replace('-', '_', $option);
3612
+			switch ($map_option) {
3613
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3614
+					$value = (int)$value;
3615
+					if ($value < 1 || $value > 999) {
3616
+						return;
3617
+					}
3618
+					break;
3619
+				default:
3620
+					$value = apply_filters(
3621
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3622
+						false,
3623
+						$option,
3624
+						$value
3625
+					);
3626
+					if (false === $value) {
3627
+						return;
3628
+					}
3629
+					break;
3630
+			}
3631
+			update_user_meta($user->ID, $option, $value);
3632
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3633
+			exit;
3634
+		}
3635
+	}
3636
+
3637
+
3638
+
3639
+	/**
3640
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3641
+	 *
3642
+	 * @param array $data array that will be assigned to template args.
3643
+	 */
3644
+	public function set_template_args($data)
3645
+	{
3646
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3647
+	}
3648
+
3649
+
3650
+
3651
+	/**
3652
+	 * This makes available the WP transient system for temporarily moving data between routes
3653
+	 *
3654
+	 * @access protected
3655
+	 * @param string $route             the route that should receive the transient
3656
+	 * @param array  $data              the data that gets sent
3657
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3658
+	 *                                  normal route transient.
3659
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3660
+	 *                                  when we are adding a transient before page_routes have been defined.
3661
+	 * @return void
3662
+	 */
3663
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3664
+	{
3665
+		$user_id = get_current_user_id();
3666
+		if (! $skip_route_verify) {
3667
+			$this->_verify_route($route);
3668
+		}
3669
+		//now let's set the string for what kind of transient we're setting
3670
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3671
+		$data      = $notices ? array('notices' => $data) : $data;
3672
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3673
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3674
+		if ($existing) {
3675
+			$data = array_merge((array)$data, (array)$existing);
3676
+		}
3677
+		if (is_multisite() && is_network_admin()) {
3678
+			set_site_transient($transient, $data, 8);
3679
+		} else {
3680
+			set_transient($transient, $data, 8);
3681
+		}
3682
+	}
3683
+
3684
+
3685
+
3686
+	/**
3687
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3688
+	 *
3689
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3690
+	 * @return mixed data
3691
+	 */
3692
+	protected function _get_transient($notices = false, $route = false)
3693
+	{
3694
+		$user_id   = get_current_user_id();
3695
+		$route     = ! $route ? $this->_req_action : $route;
3696
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3697
+		$data      = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3698
+		//delete transient after retrieval (just in case it hasn't expired);
3699
+		if (is_multisite() && is_network_admin()) {
3700
+			delete_site_transient($transient);
3701
+		} else {
3702
+			delete_transient($transient);
3703
+		}
3704
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3705
+	}
3706
+
3707
+
3708
+
3709
+	/**
3710
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3711
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3712
+	 * default route callback on the EE_Admin page you want it run.)
3713
+	 *
3714
+	 * @return void
3715
+	 */
3716
+	protected function _transient_garbage_collection()
3717
+	{
3718
+		global $wpdb;
3719
+		//retrieve all existing transients
3720
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3721
+		if ($results = $wpdb->get_results($query)) {
3722
+			foreach ($results as $result) {
3723
+				$transient = str_replace('_transient_', '', $result->option_name);
3724
+				get_transient($transient);
3725
+				if (is_multisite() && is_network_admin()) {
3726
+					get_site_transient($transient);
3727
+				}
3728
+			}
3729
+		}
3730
+	}
3731
+
3732
+
3733
+
3734
+	/**
3735
+	 * get_view
3736
+	 *
3737
+	 * @access public
3738
+	 * @return string content of _view property
3739
+	 */
3740
+	public function get_view()
3741
+	{
3742
+		return $this->_view;
3743
+	}
3744
+
3745
+
3746
+
3747
+	/**
3748
+	 * getter for the protected $_views property
3749
+	 *
3750
+	 * @return array
3751
+	 */
3752
+	public function get_views()
3753
+	{
3754
+		return $this->_views;
3755
+	}
3756
+
3757
+
3758
+
3759
+	/**
3760
+	 * get_current_page
3761
+	 *
3762
+	 * @access public
3763
+	 * @return string _current_page property value
3764
+	 */
3765
+	public function get_current_page()
3766
+	{
3767
+		return $this->_current_page;
3768
+	}
3769
+
3770
+
3771
+
3772
+	/**
3773
+	 * get_current_view
3774
+	 *
3775
+	 * @access public
3776
+	 * @return string _current_view property value
3777
+	 */
3778
+	public function get_current_view()
3779
+	{
3780
+		return $this->_current_view;
3781
+	}
3782
+
3783
+
3784
+
3785
+	/**
3786
+	 * get_current_screen
3787
+	 *
3788
+	 * @access public
3789
+	 * @return object The current WP_Screen object
3790
+	 */
3791
+	public function get_current_screen()
3792
+	{
3793
+		return $this->_current_screen;
3794
+	}
3795
+
3796
+
3797
+
3798
+	/**
3799
+	 * get_current_page_view_url
3800
+	 *
3801
+	 * @access public
3802
+	 * @return string This returns the url for the current_page_view.
3803
+	 */
3804
+	public function get_current_page_view_url()
3805
+	{
3806
+		return $this->_current_page_view_url;
3807
+	}
3808
+
3809
+
3810
+
3811
+	/**
3812
+	 * just returns the _req_data property
3813
+	 *
3814
+	 * @return array
3815
+	 */
3816
+	public function get_request_data()
3817
+	{
3818
+		return $this->_req_data;
3819
+	}
3820
+
3821
+
3822
+
3823
+	/**
3824
+	 * returns the _req_data protected property
3825
+	 *
3826
+	 * @return string
3827
+	 */
3828
+	public function get_req_action()
3829
+	{
3830
+		return $this->_req_action;
3831
+	}
3832
+
3833
+
3834
+
3835
+	/**
3836
+	 * @return bool  value of $_is_caf property
3837
+	 */
3838
+	public function is_caf()
3839
+	{
3840
+		return $this->_is_caf;
3841
+	}
3842
+
3843
+
3844
+
3845
+	/**
3846
+	 * @return mixed
3847
+	 */
3848
+	public function default_espresso_metaboxes()
3849
+	{
3850
+		return $this->_default_espresso_metaboxes;
3851
+	}
3852
+
3853
+
3854
+
3855
+	/**
3856
+	 * @return mixed
3857
+	 */
3858
+	public function admin_base_url()
3859
+	{
3860
+		return $this->_admin_base_url;
3861
+	}
3862 3862
 
3863 3863
 
3864 3864
 
3865
-    /**
3866
-     * @return mixed
3867
-     */
3868
-    public function wp_page_slug()
3869
-    {
3870
-        return $this->_wp_page_slug;
3871
-    }
3872
-
3873
-
3874
-
3875
-    /**
3876
-     * updates  espresso configuration settings
3877
-     *
3878
-     * @access    protected
3879
-     * @param string                   $tab
3880
-     * @param EE_Config_Base|EE_Config $config
3881
-     * @param string                   $file file where error occurred
3882
-     * @param string                   $func function  where error occurred
3883
-     * @param string                   $line line no where error occurred
3884
-     * @return boolean
3885
-     */
3886
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3887
-    {
3888
-        //remove any options that are NOT going to be saved with the config settings.
3889
-        if (isset($config->core->ee_ueip_optin)) {
3890
-            $config->core->ee_ueip_has_notified = true;
3891
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3892
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3893
-            update_option('ee_ueip_has_notified', true);
3894
-        }
3895
-        // and save it (note we're also doing the network save here)
3896
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3897
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3898
-        if ($config_saved && $net_saved) {
3899
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3900
-            return true;
3901
-        } else {
3902
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3903
-            return false;
3904
-        }
3905
-    }
3906
-
3907
-
3908
-
3909
-    /**
3910
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3911
-     *
3912
-     * @return array
3913
-     */
3914
-    public function get_yes_no_values()
3915
-    {
3916
-        return $this->_yes_no_values;
3917
-    }
3918
-
3919
-
3920
-
3921
-    protected function _get_dir()
3922
-    {
3923
-        $reflector = new ReflectionClass(get_class($this));
3924
-        return dirname($reflector->getFileName());
3925
-    }
3926
-
3927
-
3928
-
3929
-    /**
3930
-     * A helper for getting a "next link".
3931
-     *
3932
-     * @param string $url   The url to link to
3933
-     * @param string $class The class to use.
3934
-     * @return string
3935
-     */
3936
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3937
-    {
3938
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3939
-    }
3940
-
3941
-
3942
-
3943
-    /**
3944
-     * A helper for getting a "previous link".
3945
-     *
3946
-     * @param string $url   The url to link to
3947
-     * @param string $class The class to use.
3948
-     * @return string
3949
-     */
3950
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3951
-    {
3952
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3953
-    }
3954
-
3955
-
3956
-
3957
-
3958
-
3959
-
3960
-
3961
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3962
-
3963
-
3964
-    /**
3965
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3966
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
3967
-     * _req_data array.
3968
-     *
3969
-     * @return bool success/fail
3970
-     */
3971
-    protected function _process_resend_registration()
3972
-    {
3973
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3974
-        do_action(
3975
-            'AHEE__EE_Admin_Page___process_resend_registration',
3976
-            $this->_template_args['success'],
3977
-            $this->_req_data
3978
-        );
3979
-        return $this->_template_args['success'];
3980
-    }
3981
-
3982
-
3983
-
3984
-    /**
3985
-     * This automatically processes any payment message notifications when manual payment has been applied.
3986
-     *
3987
-     * @access protected
3988
-     * @param \EE_Payment $payment
3989
-     * @return bool success/fail
3990
-     */
3991
-    protected function _process_payment_notification(EE_Payment $payment)
3992
-    {
3993
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3994
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3995
-        $this->_template_args['success'] = apply_filters(
3996
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3997
-            false,
3998
-            $payment
3999
-        );
4000
-        return $this->_template_args['success'];
4001
-    }
3865
+	/**
3866
+	 * @return mixed
3867
+	 */
3868
+	public function wp_page_slug()
3869
+	{
3870
+		return $this->_wp_page_slug;
3871
+	}
3872
+
3873
+
3874
+
3875
+	/**
3876
+	 * updates  espresso configuration settings
3877
+	 *
3878
+	 * @access    protected
3879
+	 * @param string                   $tab
3880
+	 * @param EE_Config_Base|EE_Config $config
3881
+	 * @param string                   $file file where error occurred
3882
+	 * @param string                   $func function  where error occurred
3883
+	 * @param string                   $line line no where error occurred
3884
+	 * @return boolean
3885
+	 */
3886
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3887
+	{
3888
+		//remove any options that are NOT going to be saved with the config settings.
3889
+		if (isset($config->core->ee_ueip_optin)) {
3890
+			$config->core->ee_ueip_has_notified = true;
3891
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3892
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3893
+			update_option('ee_ueip_has_notified', true);
3894
+		}
3895
+		// and save it (note we're also doing the network save here)
3896
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3897
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3898
+		if ($config_saved && $net_saved) {
3899
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3900
+			return true;
3901
+		} else {
3902
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3903
+			return false;
3904
+		}
3905
+	}
3906
+
3907
+
3908
+
3909
+	/**
3910
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3911
+	 *
3912
+	 * @return array
3913
+	 */
3914
+	public function get_yes_no_values()
3915
+	{
3916
+		return $this->_yes_no_values;
3917
+	}
3918
+
3919
+
3920
+
3921
+	protected function _get_dir()
3922
+	{
3923
+		$reflector = new ReflectionClass(get_class($this));
3924
+		return dirname($reflector->getFileName());
3925
+	}
3926
+
3927
+
3928
+
3929
+	/**
3930
+	 * A helper for getting a "next link".
3931
+	 *
3932
+	 * @param string $url   The url to link to
3933
+	 * @param string $class The class to use.
3934
+	 * @return string
3935
+	 */
3936
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3937
+	{
3938
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3939
+	}
3940
+
3941
+
3942
+
3943
+	/**
3944
+	 * A helper for getting a "previous link".
3945
+	 *
3946
+	 * @param string $url   The url to link to
3947
+	 * @param string $class The class to use.
3948
+	 * @return string
3949
+	 */
3950
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3951
+	{
3952
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3953
+	}
3954
+
3955
+
3956
+
3957
+
3958
+
3959
+
3960
+
3961
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3962
+
3963
+
3964
+	/**
3965
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
3966
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
3967
+	 * _req_data array.
3968
+	 *
3969
+	 * @return bool success/fail
3970
+	 */
3971
+	protected function _process_resend_registration()
3972
+	{
3973
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3974
+		do_action(
3975
+			'AHEE__EE_Admin_Page___process_resend_registration',
3976
+			$this->_template_args['success'],
3977
+			$this->_req_data
3978
+		);
3979
+		return $this->_template_args['success'];
3980
+	}
3981
+
3982
+
3983
+
3984
+	/**
3985
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3986
+	 *
3987
+	 * @access protected
3988
+	 * @param \EE_Payment $payment
3989
+	 * @return bool success/fail
3990
+	 */
3991
+	protected function _process_payment_notification(EE_Payment $payment)
3992
+	{
3993
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3994
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3995
+		$this->_template_args['success'] = apply_filters(
3996
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
3997
+			false,
3998
+			$payment
3999
+		);
4000
+		return $this->_template_args['success'];
4001
+	}
4002 4002
 
4003 4003
 
4004 4004
 }
Please login to merge, or discard this patch.
Spacing   +195 added lines, -195 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\interfaces\InterminableInterface;
2 2
 
3
-if (! defined('EVENT_ESPRESSO_VERSION')) {
3
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
4 4
     exit('No direct script access allowed');
5 5
 }
6 6
 /**
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
510 510
         $this->page_folder   = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
511 511
         global $ee_menu_slugs;
512
-        $ee_menu_slugs = (array)$ee_menu_slugs;
513
-        if ((! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
512
+        $ee_menu_slugs = (array) $ee_menu_slugs;
513
+        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
514 514
             return;
515 515
         }
516 516
         // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
         $this->_req_action   = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route']
530 530
             : $this->_req_action;
531 531
         $this->_current_view = $this->_req_action;
532
-        $this->_req_nonce    = $this->_req_action . '_nonce';
532
+        $this->_req_nonce    = $this->_req_action.'_nonce';
533 533
         $this->_define_page_props();
534 534
         $this->_current_page_view_url = add_query_arg(
535 535
             array('page' => $this->_current_page, 'action' => $this->_current_view),
@@ -559,20 +559,20 @@  discard block
 block discarded – undo
559 559
         }
560 560
         //filter routes and page_config so addons can add their stuff. Filtering done per class
561 561
         $this->_page_routes = apply_filters(
562
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
562
+            'FHEE__'.get_class($this).'__page_setup__page_routes',
563 563
             $this->_page_routes,
564 564
             $this
565 565
         );
566 566
         $this->_page_config = apply_filters(
567
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
567
+            'FHEE__'.get_class($this).'__page_setup__page_config',
568 568
             $this->_page_config,
569 569
             $this
570 570
         );
571 571
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
572
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
572
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
573 573
             add_action(
574 574
                 'AHEE__EE_Admin_Page__route_admin_request',
575
-                array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view),
575
+                array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view),
576 576
                 10,
577 577
                 2
578 578
             );
@@ -585,8 +585,8 @@  discard block
 block discarded – undo
585 585
             if ($this->_is_UI_request) {
586 586
                 //admin_init stuff - global, all views for this page class, specific view
587 587
                 add_action('admin_init', array($this, 'admin_init'), 10);
588
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
589
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
588
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
589
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
590 590
                 }
591 591
             } else {
592 592
                 //hijack regular WP loading and route admin request immediately
@@ -606,12 +606,12 @@  discard block
 block discarded – undo
606 606
      */
607 607
     private function _do_other_page_hooks()
608 608
     {
609
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
609
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
610 610
         foreach ($registered_pages as $page) {
611 611
             //now let's setup the file name and class that should be present
612 612
             $classname = str_replace('.class.php', '', $page);
613 613
             //autoloaders should take care of loading file
614
-            if (! class_exists($classname)) {
614
+            if ( ! class_exists($classname)) {
615 615
                 $error_msg[] = sprintf(
616 616
                     esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'),
617 617
                     $page
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
                                    ),
626 626
                                    $page,
627 627
                                    '<br />',
628
-                                   '<strong>' . $classname . '</strong>'
628
+                                   '<strong>'.$classname.'</strong>'
629 629
                                );
630 630
                 throw new EE_Error(implode('||', $error_msg));
631 631
             }
@@ -662,13 +662,13 @@  discard block
 block discarded – undo
662 662
         //load admin_notices - global, page class, and view specific
663 663
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
664 664
         add_action('admin_notices', array($this, 'admin_notices'), 10);
665
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
666
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
665
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
666
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
667 667
         }
668 668
         //load network admin_notices - global, page class, and view specific
669 669
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
670
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
671
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
670
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
671
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
672 672
         }
673 673
         //this will save any per_page screen options if they are present
674 674
         $this->_set_per_page_screen_options();
@@ -680,8 +680,8 @@  discard block
 block discarded – undo
680 680
         //add screen options - global, page child class, and view specific
681 681
         $this->_add_global_screen_options();
682 682
         $this->_add_screen_options();
683
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
684
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
683
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
684
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
685 685
         }
686 686
         //add help tab(s) and tours- set via page_config and qtips.
687 687
         $this->_add_help_tour();
@@ -690,32 +690,32 @@  discard block
 block discarded – undo
690 690
         //add feature_pointers - global, page child class, and view specific
691 691
         $this->_add_feature_pointers();
692 692
         $this->_add_global_feature_pointers();
693
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
694
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
693
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
694
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
695 695
         }
696 696
         //enqueue scripts/styles - global, page class, and view specific
697 697
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
698 698
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
699
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
700
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
699
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
700
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
701 701
         }
702 702
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
703 703
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
704 704
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
705 705
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
706
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
707
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
706
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
707
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
708 708
         }
709 709
         //admin footer scripts
710 710
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
711 711
         add_action('admin_footer', array($this, 'admin_footer'), 100);
712
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
713
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
712
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
713
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
714 714
         }
715 715
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
716 716
         //targeted hook
717 717
         do_action(
718
-            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action
718
+            'FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action
719 719
         );
720 720
     }
721 721
 
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
     protected function _verify_routes()
783 783
     {
784 784
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
785
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
785
+        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
786 786
             return false;
787 787
         }
788 788
         $this->_route = false;
@@ -796,7 +796,7 @@  discard block
 block discarded – undo
796 796
                 $this->_admin_page_title
797 797
             );
798 798
             // developer error msg
799
-            $error_msg .= '||' . $error_msg . __(
799
+            $error_msg .= '||'.$error_msg.__(
800 800
                     ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
801 801
                     'event_espresso'
802 802
                 );
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
                 $this->_admin_page_title
815 815
             );
816 816
             // developer error msg
817
-            $error_msg .= '||' . $error_msg . sprintf(
817
+            $error_msg .= '||'.$error_msg.sprintf(
818 818
                     __(
819 819
                         ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
820 820
                         'event_espresso'
@@ -824,14 +824,14 @@  discard block
 block discarded – undo
824 824
             throw new EE_Error($error_msg);
825 825
         }
826 826
         // and that a default route exists
827
-        if (! array_key_exists('default', $this->_page_routes)) {
827
+        if ( ! array_key_exists('default', $this->_page_routes)) {
828 828
             // user error msg
829 829
             $error_msg = sprintf(
830 830
                 __('A default page route has not been set for the % admin page.', 'event_espresso'),
831 831
                 $this->_admin_page_title
832 832
             );
833 833
             // developer error msg
834
-            $error_msg .= '||' . $error_msg . __(
834
+            $error_msg .= '||'.$error_msg.__(
835 835
                     ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
836 836
                     'event_espresso'
837 837
                 );
@@ -840,7 +840,7 @@  discard block
 block discarded – undo
840 840
         //first lets' catch if the UI request has EVER been set.
841 841
         if ($this->_is_UI_request === null) {
842 842
             //lets set if this is a UI request or not.
843
-            $this->_is_UI_request = (! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
843
+            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true)
844 844
                 ? true : false;
845 845
             //wait a minute... we might have a noheader in the route array
846 846
             $this->_is_UI_request = is_array($this->_route)
@@ -869,7 +869,7 @@  discard block
 block discarded – undo
869 869
                 $this->_admin_page_title
870 870
             );
871 871
             // developer error msg
872
-            $error_msg .= '||' . $error_msg . sprintf(
872
+            $error_msg .= '||'.$error_msg.sprintf(
873 873
                     __(
874 874
                         ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
875 875
                         'event_espresso'
@@ -894,7 +894,7 @@  discard block
 block discarded – undo
894 894
     protected function _verify_nonce($nonce, $nonce_ref)
895 895
     {
896 896
         // verify nonce against expected value
897
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
897
+        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
898 898
             // these are not the droids you are looking for !!!
899 899
             $msg = sprintf(
900 900
                 __('%sNonce Fail.%s', 'event_espresso'),
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
                 '</a>'
903 903
             );
904 904
             if (WP_DEBUG) {
905
-                $msg .= "\n  " . sprintf(
905
+                $msg .= "\n  ".sprintf(
906 906
                         __(
907 907
                             'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
908 908
                             'event_espresso'
@@ -910,7 +910,7 @@  discard block
 block discarded – undo
910 910
                         __CLASS__
911 911
                     );
912 912
             }
913
-            if (! defined('DOING_AJAX')) {
913
+            if ( ! defined('DOING_AJAX')) {
914 914
                 wp_die($msg);
915 915
             } else {
916 916
                 EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
@@ -933,7 +933,7 @@  discard block
 block discarded – undo
933 933
      */
934 934
     protected function _route_admin_request()
935 935
     {
936
-        if (! $this->_is_UI_request) {
936
+        if ( ! $this->_is_UI_request) {
937 937
             $this->_verify_routes();
938 938
         }
939 939
         $nonce_check = isset($this->_route_config['require_nonce'])
@@ -957,13 +957,13 @@  discard block
 block discarded – undo
957 957
         $error_msg = '';
958 958
         // action right before calling route
959 959
         // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
960
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
960
+        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
961 961
             do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
962 962
         }
963 963
         // right before calling the route, let's remove _wp_http_referer from the
964 964
         // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
965 965
         $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
966
-        if (! empty($func)) {
966
+        if ( ! empty($func)) {
967 967
             if (is_array($func)) {
968 968
                 list($class, $method) = $func;
969 969
             } elseif (strpos($func, '::') !== false) {
@@ -972,7 +972,7 @@  discard block
 block discarded – undo
972 972
                 $class  = $this;
973 973
                 $method = $func;
974 974
             }
975
-            if (! (is_object($class) && $class === $this)) {
975
+            if ( ! (is_object($class) && $class === $this)) {
976 976
                 // send along this admin page object for access by addons.
977 977
                 $args['admin_page_object'] = $this;
978 978
             }
@@ -1008,7 +1008,7 @@  discard block
 block discarded – undo
1008 1008
                     $method
1009 1009
                 );
1010 1010
             }
1011
-            if (! empty($error_msg)) {
1011
+            if ( ! empty($error_msg)) {
1012 1012
                 throw new EE_Error($error_msg);
1013 1013
             }
1014 1014
         }
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
                 if (strpos($key, 'nonce') !== false) {
1090 1090
                     continue;
1091 1091
                 }
1092
-                $args['wp_referer[' . $key . ']'] = $value;
1092
+                $args['wp_referer['.$key.']'] = $value;
1093 1093
             }
1094 1094
         }
1095 1095
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1153,7 +1153,7 @@  discard block
 block discarded – undo
1153 1153
             // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1154 1154
             if (is_array($config) && isset($config['help_sidebar'])) {
1155 1155
                 //check that the callback given is valid
1156
-                if (! method_exists($this, $config['help_sidebar'])) {
1156
+                if ( ! method_exists($this, $config['help_sidebar'])) {
1157 1157
                     throw new EE_Error(
1158 1158
                         sprintf(
1159 1159
                             __(
@@ -1166,7 +1166,7 @@  discard block
 block discarded – undo
1166 1166
                     );
1167 1167
                 }
1168 1168
                 $content = apply_filters(
1169
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1169
+                    'FHEE__'.get_class($this).'__add_help_tabs__help_sidebar',
1170 1170
                     call_user_func(array($this, $config['help_sidebar']))
1171 1171
                 );
1172 1172
                 $content .= $tour_buttons; //add help tour buttons.
@@ -1174,26 +1174,26 @@  discard block
 block discarded – undo
1174 1174
                 $this->_current_screen->set_help_sidebar($content);
1175 1175
             }
1176 1176
             //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1177
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1177
+            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1178 1178
                 $this->_current_screen->set_help_sidebar($tour_buttons);
1179 1179
             }
1180 1180
             //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1181
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1181
+            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1182 1182
                 $_ht['id']      = $this->page_slug;
1183 1183
                 $_ht['title']   = __('Help Tours', 'event_espresso');
1184
-                $_ht['content'] = '<p>' . __(
1184
+                $_ht['content'] = '<p>'.__(
1185 1185
                         'The buttons to the right allow you to start/restart any help tours available for this page',
1186 1186
                         'event_espresso'
1187
-                    ) . '</p>';
1187
+                    ).'</p>';
1188 1188
                 $this->_current_screen->add_help_tab($_ht);
1189 1189
             }/**/
1190
-            if (! isset($config['help_tabs'])) {
1190
+            if ( ! isset($config['help_tabs'])) {
1191 1191
                 return;
1192 1192
             } //no help tabs for this route
1193
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1193
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1194 1194
                 //we're here so there ARE help tabs!
1195 1195
                 //make sure we've got what we need
1196
-                if (! isset($cfg['title'])) {
1196
+                if ( ! isset($cfg['title'])) {
1197 1197
                     throw new EE_Error(
1198 1198
                         __(
1199 1199
                             'The _page_config array is not set up properly for help tabs.  It is missing a title',
@@ -1201,7 +1201,7 @@  discard block
 block discarded – undo
1201 1201
                         )
1202 1202
                     );
1203 1203
                 }
1204
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1204
+                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1205 1205
                     throw new EE_Error(
1206 1206
                         __(
1207 1207
                             'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
@@ -1210,11 +1210,11 @@  discard block
 block discarded – undo
1210 1210
                     );
1211 1211
                 }
1212 1212
                 //first priority goes to content.
1213
-                if (! empty($cfg['content'])) {
1213
+                if ( ! empty($cfg['content'])) {
1214 1214
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1215 1215
                     //second priority goes to filename
1216
-                } elseif (! empty($cfg['filename'])) {
1217
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1216
+                } elseif ( ! empty($cfg['filename'])) {
1217
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1218 1218
                     //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1219 1219
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1220 1220
                                                              . basename($this->_get_dir())
@@ -1222,7 +1222,7 @@  discard block
 block discarded – undo
1222 1222
                                                              . $cfg['filename']
1223 1223
                                                              . '.help_tab.php' : $file_path;
1224 1224
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1225
-                    if (! is_readable($file_path) && ! isset($cfg['callback'])) {
1225
+                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1226 1226
                         EE_Error::add_error(
1227 1227
                             sprintf(
1228 1228
                                 __(
@@ -1245,7 +1245,7 @@  discard block
 block discarded – undo
1245 1245
                     $content = '';
1246 1246
                 }
1247 1247
                 //check if callback is valid
1248
-                if (empty($content) && (! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1248
+                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1249 1249
                     EE_Error::add_error(
1250 1250
                         sprintf(
1251 1251
                             __(
@@ -1261,7 +1261,7 @@  discard block
 block discarded – undo
1261 1261
                     return;
1262 1262
                 }
1263 1263
                 //setup config array for help tab method
1264
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1264
+                $id  = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1265 1265
                 $_ht = array(
1266 1266
                     'id'       => $id,
1267 1267
                     'title'    => $cfg['title'],
@@ -1290,7 +1290,7 @@  discard block
 block discarded – undo
1290 1290
         $tours            = array();
1291 1291
         $this->_help_tour = array();
1292 1292
         //exit early if help tours are turned off globally
1293
-        if (! EE_Registry::instance()->CFG->admin->help_tour_activation
1293
+        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation
1294 1294
             || (defined('EE_DISABLE_HELP_TOURS')
1295 1295
                 && EE_DISABLE_HELP_TOURS)) {
1296 1296
             return;
@@ -1303,7 +1303,7 @@  discard block
 block discarded – undo
1303 1303
             }
1304 1304
             if (isset($config['help_tour'])) {
1305 1305
                 foreach ($config['help_tour'] as $tour) {
1306
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1306
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1307 1307
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1308 1308
                     $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1309 1309
                                                              . basename($this->_get_dir())
@@ -1311,7 +1311,7 @@  discard block
 block discarded – undo
1311 1311
                                                              . $tour
1312 1312
                                                              . '.class.php' : $file_path;
1313 1313
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1314
-                    if (! is_readable($file_path)) {
1314
+                    if ( ! is_readable($file_path)) {
1315 1315
                         EE_Error::add_error(
1316 1316
                             sprintf(
1317 1317
                                 __(
@@ -1328,12 +1328,12 @@  discard block
 block discarded – undo
1328 1328
                         return;
1329 1329
                     }
1330 1330
                     require_once $file_path;
1331
-                    if (! class_exists($tour)) {
1331
+                    if ( ! class_exists($tour)) {
1332 1332
                         $error_msg[] = sprintf(
1333 1333
                             __('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1334 1334
                             $tour
1335 1335
                         );
1336
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(
1336
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(
1337 1337
                                 __(
1338 1338
                                     'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1339 1339
                                     'event_espresso'
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
                 $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1358 1358
             }
1359 1359
         }
1360
-        if (! empty($tours)) {
1360
+        if ( ! empty($tours)) {
1361 1361
             $this->_help_tour['tours'] = $tours;
1362 1362
         }
1363 1363
         //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
@@ -1374,11 +1374,11 @@  discard block
 block discarded – undo
1374 1374
     protected function _add_qtips()
1375 1375
     {
1376 1376
         if (isset($this->_route_config['qtips'])) {
1377
-            $qtips = (array)$this->_route_config['qtips'];
1377
+            $qtips = (array) $this->_route_config['qtips'];
1378 1378
             //load qtip loader
1379 1379
             $path = array(
1380
-                $this->_get_dir() . '/qtips/',
1381
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1380
+                $this->_get_dir().'/qtips/',
1381
+                EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1382 1382
             );
1383 1383
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1384 1384
         }
@@ -1399,7 +1399,7 @@  discard block
 block discarded – undo
1399 1399
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1400 1400
         $i = 0;
1401 1401
         foreach ($this->_page_config as $slug => $config) {
1402
-            if (! is_array($config)
1402
+            if ( ! is_array($config)
1403 1403
                 || (is_array($config)
1404 1404
                     && (isset($config['nav']) && ! $config['nav'])
1405 1405
                     || ! isset($config['nav']))) {
@@ -1409,10 +1409,10 @@  discard block
 block discarded – undo
1409 1409
             if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1410 1410
                 continue;
1411 1411
             } //nav tab is only to appear when route requested.
1412
-            if (! $this->check_user_access($slug, true)) {
1412
+            if ( ! $this->check_user_access($slug, true)) {
1413 1413
                 continue;
1414 1414
             } //no nav tab becasue current user does not have access.
1415
-            $css_class              = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1415
+            $css_class              = isset($config['css_class']) ? $config['css_class'].' ' : '';
1416 1416
             $this->_nav_tabs[$slug] = array(
1417 1417
                 'url'       => isset($config['nav']['url'])
1418 1418
                     ? $config['nav']['url']
@@ -1425,7 +1425,7 @@  discard block
 block discarded – undo
1425 1425
                     : ucwords(
1426 1426
                         str_replace('_', ' ', $slug)
1427 1427
                     ),
1428
-                'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1428
+                'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1429 1429
                 'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1430 1430
             );
1431 1431
             $i++;
@@ -1495,7 +1495,7 @@  discard block
 block discarded – undo
1495 1495
             $capability = empty($capability) ? 'manage_options' : $capability;
1496 1496
         }
1497 1497
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1498
-        if ((! function_exists('is_admin')
1498
+        if (( ! function_exists('is_admin')
1499 1499
              || ! EE_Registry::instance()->CAP->current_user_can(
1500 1500
                     $capability,
1501 1501
                     $this->page_slug
@@ -1606,7 +1606,7 @@  discard block
 block discarded – undo
1606 1606
     public function admin_footer_global()
1607 1607
     {
1608 1608
         //dialog container for dialog helper
1609
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1609
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1610 1610
         $d_cont .= '<div class="ee-notices"></div>';
1611 1611
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1612 1612
         $d_cont .= '</div>';
@@ -1616,7 +1616,7 @@  discard block
 block discarded – undo
1616 1616
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1617 1617
         }
1618 1618
         //current set timezone for timezone js
1619
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1619
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1620 1620
     }
1621 1621
 
1622 1622
 
@@ -1645,11 +1645,11 @@  discard block
 block discarded – undo
1645 1645
     {
1646 1646
         $content       = '';
1647 1647
         $help_array    = empty($help_array) ? $this->_get_help_content() : $help_array;
1648
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1648
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1649 1649
         //loop through the array and setup content
1650 1650
         foreach ($help_array as $trigger => $help) {
1651 1651
             //make sure the array is setup properly
1652
-            if (! isset($help['title']) || ! isset($help['content'])) {
1652
+            if ( ! isset($help['title']) || ! isset($help['content'])) {
1653 1653
                 throw new EE_Error(
1654 1654
                     __(
1655 1655
                         'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
@@ -1663,7 +1663,7 @@  discard block
 block discarded – undo
1663 1663
                 'help_popup_title'   => $help['title'],
1664 1664
                 'help_popup_content' => $help['content'],
1665 1665
             );
1666
-            $content       .= EEH_Template::display_template($template_path, $template_args, true);
1666
+            $content .= EEH_Template::display_template($template_path, $template_args, true);
1667 1667
         }
1668 1668
         if ($display) {
1669 1669
             echo $content;
@@ -1683,15 +1683,15 @@  discard block
 block discarded – undo
1683 1683
     private function _get_help_content()
1684 1684
     {
1685 1685
         //what is the method we're looking for?
1686
-        $method_name = '_help_popup_content_' . $this->_req_action;
1686
+        $method_name = '_help_popup_content_'.$this->_req_action;
1687 1687
         //if method doesn't exist let's get out.
1688
-        if (! method_exists($this, $method_name)) {
1688
+        if ( ! method_exists($this, $method_name)) {
1689 1689
             return array();
1690 1690
         }
1691 1691
         //k we're good to go let's retrieve the help array
1692 1692
         $help_array = call_user_func(array($this, $method_name));
1693 1693
         //make sure we've got an array!
1694
-        if (! is_array($help_array)) {
1694
+        if ( ! is_array($help_array)) {
1695 1695
             throw new EE_Error(
1696 1696
                 __(
1697 1697
                     'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
@@ -1731,7 +1731,7 @@  discard block
 block discarded – undo
1731 1731
                     'event_espresso'
1732 1732
                 ),
1733 1733
             );
1734
-            $help_content            = $this->_set_help_popup_content($help_array, false);
1734
+            $help_content = $this->_set_help_popup_content($help_array, false);
1735 1735
         }
1736 1736
         //let's setup the trigger
1737 1737
         $content = '<a class="ee-dialog" href="?height='
@@ -1741,7 +1741,7 @@  discard block
 block discarded – undo
1741 1741
                    . '&inlineId='
1742 1742
                    . $trigger_id
1743 1743
                    . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1744
-        $content = $content . $help_content;
1744
+        $content = $content.$help_content;
1745 1745
         if ($display) {
1746 1746
             echo $content;
1747 1747
         } else {
@@ -1804,15 +1804,15 @@  discard block
 block discarded – undo
1804 1804
         // register all styles
1805 1805
         wp_register_style(
1806 1806
             'espresso-ui-theme',
1807
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1807
+            EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1808 1808
             array(),
1809 1809
             EVENT_ESPRESSO_VERSION
1810 1810
         );
1811
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1811
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1812 1812
         //helpers styles
1813 1813
         wp_register_style(
1814 1814
             'ee-text-links',
1815
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1815
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css',
1816 1816
             array(),
1817 1817
             EVENT_ESPRESSO_VERSION
1818 1818
         );
@@ -1820,21 +1820,21 @@  discard block
 block discarded – undo
1820 1820
         //register all scripts
1821 1821
         wp_register_script(
1822 1822
             'ee-dialog',
1823
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1823
+            EE_ADMIN_URL.'assets/ee-dialog-helper.js',
1824 1824
             array('jquery', 'jquery-ui-draggable'),
1825 1825
             EVENT_ESPRESSO_VERSION,
1826 1826
             true
1827 1827
         );
1828 1828
         wp_register_script(
1829 1829
             'ee_admin_js',
1830
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1830
+            EE_ADMIN_URL.'assets/ee-admin-page.js',
1831 1831
             array('espresso_core', 'ee-parse-uri', 'ee-dialog'),
1832 1832
             EVENT_ESPRESSO_VERSION,
1833 1833
             true
1834 1834
         );
1835 1835
         wp_register_script(
1836 1836
             'jquery-ui-timepicker-addon',
1837
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1837
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js',
1838 1838
             array('jquery-ui-datepicker', 'jquery-ui-slider'),
1839 1839
             EVENT_ESPRESSO_VERSION,
1840 1840
             true
@@ -1843,7 +1843,7 @@  discard block
 block discarded – undo
1843 1843
         //script for sorting tables
1844 1844
         wp_register_script(
1845 1845
             'espresso_ajax_table_sorting',
1846
-            EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js",
1846
+            EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js",
1847 1847
             array('ee_admin_js', 'jquery-ui-sortable'),
1848 1848
             EVENT_ESPRESSO_VERSION,
1849 1849
             true
@@ -1851,7 +1851,7 @@  discard block
 block discarded – undo
1851 1851
         //script for parsing uri's
1852 1852
         wp_register_script(
1853 1853
             'ee-parse-uri',
1854
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1854
+            EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js',
1855 1855
             array(),
1856 1856
             EVENT_ESPRESSO_VERSION,
1857 1857
             true
@@ -1859,7 +1859,7 @@  discard block
 block discarded – undo
1859 1859
         //and parsing associative serialized form elements
1860 1860
         wp_register_script(
1861 1861
             'ee-serialize-full-array',
1862
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1862
+            EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js',
1863 1863
             array('jquery'),
1864 1864
             EVENT_ESPRESSO_VERSION,
1865 1865
             true
@@ -1867,28 +1867,28 @@  discard block
 block discarded – undo
1867 1867
         //helpers scripts
1868 1868
         wp_register_script(
1869 1869
             'ee-text-links',
1870
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1870
+            EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js',
1871 1871
             array('jquery'),
1872 1872
             EVENT_ESPRESSO_VERSION,
1873 1873
             true
1874 1874
         );
1875 1875
         wp_register_script(
1876 1876
             'ee-moment-core',
1877
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1877
+            EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js',
1878 1878
             array(),
1879 1879
             EVENT_ESPRESSO_VERSION,
1880 1880
             true
1881 1881
         );
1882 1882
         wp_register_script(
1883 1883
             'ee-moment',
1884
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1884
+            EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js',
1885 1885
             array('ee-moment-core'),
1886 1886
             EVENT_ESPRESSO_VERSION,
1887 1887
             true
1888 1888
         );
1889 1889
         wp_register_script(
1890 1890
             'ee-datepicker',
1891
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1891
+            EE_ADMIN_URL.'assets/ee-datepicker.js',
1892 1892
             array('jquery-ui-timepicker-addon', 'ee-moment'),
1893 1893
             EVENT_ESPRESSO_VERSION,
1894 1894
             true
@@ -1923,11 +1923,11 @@  discard block
 block discarded – undo
1923 1923
         /**
1924 1924
          * help tour stuff
1925 1925
          */
1926
-        if (! empty($this->_help_tour)) {
1926
+        if ( ! empty($this->_help_tour)) {
1927 1927
             //register the js for kicking things off
1928 1928
             wp_enqueue_script(
1929 1929
                 'ee-help-tour',
1930
-                EE_ADMIN_URL . 'assets/ee-help-tour.js',
1930
+                EE_ADMIN_URL.'assets/ee-help-tour.js',
1931 1931
                 array('jquery-joyride'),
1932 1932
                 EVENT_ESPRESSO_VERSION,
1933 1933
                 true
@@ -2025,30 +2025,30 @@  discard block
 block discarded – undo
2025 2025
     protected function _set_list_table()
2026 2026
     {
2027 2027
         //first is this a list_table view?
2028
-        if (! isset($this->_route_config['list_table'])) {
2028
+        if ( ! isset($this->_route_config['list_table'])) {
2029 2029
             return;
2030 2030
         } //not a list_table view so get out.
2031 2031
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
2032
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
2032
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
2033 2033
             //user error msg
2034 2034
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
2035 2035
             //developer error msg
2036
-            $error_msg .= '||' . sprintf(
2036
+            $error_msg .= '||'.sprintf(
2037 2037
                     __(
2038 2038
                         'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2039 2039
                         'event_espresso'
2040 2040
                     ),
2041 2041
                     $this->_req_action,
2042
-                    '_set_list_table_views_' . $this->_req_action
2042
+                    '_set_list_table_views_'.$this->_req_action
2043 2043
                 );
2044 2044
             throw new EE_Error($error_msg);
2045 2045
         }
2046 2046
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2047 2047
         $this->_views = apply_filters(
2048
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2048
+            'FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action,
2049 2049
             $this->_views
2050 2050
         );
2051
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2051
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
2052 2052
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2053 2053
         $this->_set_list_table_view();
2054 2054
         $this->_set_list_table_object();
@@ -2066,7 +2066,7 @@  discard block
 block discarded – undo
2066 2066
     {
2067 2067
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2068 2068
         // looking at active items or dumpster diving ?
2069
-        if (! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2069
+        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
2070 2070
             $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2071 2071
         } else {
2072 2072
             $this->_view = sanitize_key($this->_req_data['status']);
@@ -2084,7 +2084,7 @@  discard block
 block discarded – undo
2084 2084
     protected function _set_list_table_object()
2085 2085
     {
2086 2086
         if (isset($this->_route_config['list_table'])) {
2087
-            if (! class_exists($this->_route_config['list_table'])) {
2087
+            if ( ! class_exists($this->_route_config['list_table'])) {
2088 2088
                 throw new EE_Error(
2089 2089
                     sprintf(
2090 2090
                         __(
@@ -2123,7 +2123,7 @@  discard block
 block discarded – undo
2123 2123
             // check for current view
2124 2124
             $this->_views[$key]['class']               = $this->_view == $view['slug'] ? 'current' : '';
2125 2125
             $query_args['action']                      = $this->_req_action;
2126
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2126
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
2127 2127
             $query_args['status']                      = $view['slug'];
2128 2128
             //merge any other arguments sent in.
2129 2129
             if (isset($extra_query_args[$view['slug']])) {
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
     {
2151 2151
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2152 2152
         $values   = array(10, 25, 50, 100);
2153
-        $per_page = (! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2153
+        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
2154 2154
         if ($max_entries) {
2155 2155
             $values[] = $max_entries;
2156 2156
             sort($values);
@@ -2162,14 +2162,14 @@  discard block
 block discarded – undo
2162 2162
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2163 2163
         foreach ($values as $value) {
2164 2164
             if ($value < $max_entries) {
2165
-                $selected                  = $value == $per_page ? ' selected="' . $per_page . '"' : '';
2165
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
2166 2166
                 $entries_per_page_dropdown .= '
2167
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2167
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
2168 2168
             }
2169 2169
         }
2170
-        $selected                  = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
2170
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
2171 2171
         $entries_per_page_dropdown .= '
2172
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2172
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
2173 2173
         $entries_per_page_dropdown .= '
2174 2174
 					</select>
2175 2175
 					entries
@@ -2195,7 +2195,7 @@  discard block
 block discarded – undo
2195 2195
             empty($this->_search_btn_label) ? $this->page_label
2196 2196
                 : $this->_search_btn_label
2197 2197
         );
2198
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2198
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
2199 2199
     }
2200 2200
 
2201 2201
     /*** END LIST TABLE METHODS **/
@@ -2233,7 +2233,7 @@  discard block
 block discarded – undo
2233 2233
                     // user error msg
2234 2234
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
2235 2235
                     // developer error msg
2236
-                    $error_msg .= '||' . sprintf(
2236
+                    $error_msg .= '||'.sprintf(
2237 2237
                             __(
2238 2238
                                 'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2239 2239
                                 'event_espresso'
@@ -2267,16 +2267,16 @@  discard block
 block discarded – undo
2267 2267
             add_screen_option(
2268 2268
                 'layout_columns',
2269 2269
                 array(
2270
-                    'max'     => (int)$this->_route_config['columns'][0],
2271
-                    'default' => (int)$this->_route_config['columns'][1],
2270
+                    'max'     => (int) $this->_route_config['columns'][0],
2271
+                    'default' => (int) $this->_route_config['columns'][1],
2272 2272
                 )
2273 2273
             );
2274 2274
             $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2275 2275
             $screen_id                                           = $this->_current_screen->id;
2276
-            $screen_columns                                      = (int)get_user_option("screen_layout_$screen_id");
2276
+            $screen_columns                                      = (int) get_user_option("screen_layout_$screen_id");
2277 2277
             $total_columns                                       = ! empty($screen_columns) ? $screen_columns
2278 2278
                 : $this->_route_config['columns'][1];
2279
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2279
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
2280 2280
             $this->_template_args['current_page']                = $this->_wp_page_slug;
2281 2281
             $this->_template_args['screen']                      = $this->_current_screen;
2282 2282
             $this->_column_template_path                         = EE_ADMIN_TEMPLATE
@@ -2320,7 +2320,7 @@  discard block
 block discarded – undo
2320 2320
      */
2321 2321
     protected function _espresso_ratings_request()
2322 2322
     {
2323
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2323
+        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2324 2324
             return '';
2325 2325
         }
2326 2326
         $ratings_box_title = apply_filters(
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
      */
2347 2347
     public function espresso_ratings_request()
2348 2348
     {
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
2349
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
2350 2350
         EEH_Template::display_template($template_path, array());
2351 2351
     }
2352 2352
 
@@ -2354,22 +2354,22 @@  discard block
 block discarded – undo
2354 2354
 
2355 2355
     public static function cached_rss_display($rss_id, $url)
2356 2356
     {
2357
-        $loading    = '<p class="widget-loading hide-if-no-js">'
2357
+        $loading = '<p class="widget-loading hide-if-no-js">'
2358 2358
                       . __('Loading&#8230;')
2359 2359
                       . '</p><p class="hide-if-js">'
2360 2360
                       . __('This widget requires JavaScript.')
2361 2361
                       . '</p>';
2362 2362
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
2363
-        $pre        = '<div class="espresso-rss-display">' . "\n\t";
2364
-        $pre        .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2365
-        $post       = '</div>' . "\n";
2366
-        $cache_key  = 'ee_rss_' . md5($rss_id);
2363
+        $pre        = '<div class="espresso-rss-display">'."\n\t";
2364
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
2365
+        $post       = '</div>'."\n";
2366
+        $cache_key  = 'ee_rss_'.md5($rss_id);
2367 2367
         if (false != ($output = get_transient($cache_key))) {
2368
-            echo $pre . $output . $post;
2368
+            echo $pre.$output.$post;
2369 2369
             return true;
2370 2370
         }
2371
-        if (! $doing_ajax) {
2372
-            echo $pre . $loading . $post;
2371
+        if ( ! $doing_ajax) {
2372
+            echo $pre.$loading.$post;
2373 2373
             return false;
2374 2374
         }
2375 2375
         ob_start();
@@ -2391,7 +2391,7 @@  discard block
 block discarded – undo
2391 2391
                     'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2392 2392
                     'http://eventespresso.com/feed/'
2393 2393
                 );
2394
-                $url      = urlencode($feed_url);
2394
+                $url = urlencode($feed_url);
2395 2395
                 self::cached_rss_display('espresso_news_post_box_content', $url);
2396 2396
                 ?>
2397 2397
             </div>
@@ -2437,7 +2437,7 @@  discard block
 block discarded – undo
2437 2437
 
2438 2438
     public function espresso_sponsors_post_box()
2439 2439
     {
2440
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2440
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2441 2441
         EEH_Template::display_template($templatepath);
2442 2442
     }
2443 2443
 
@@ -2445,9 +2445,9 @@  discard block
 block discarded – undo
2445 2445
 
2446 2446
     private function _publish_post_box()
2447 2447
     {
2448
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2448
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2449 2449
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2450
-        if (! empty($this->_labels['publishbox'])) {
2450
+        if ( ! empty($this->_labels['publishbox'])) {
2451 2451
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action]
2452 2452
                 : $this->_labels['publishbox'];
2453 2453
         } else {
@@ -2547,12 +2547,12 @@  discard block
 block discarded – undo
2547 2547
             );
2548 2548
         }
2549 2549
         $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2550
-        if (! empty($name) && ! empty($id)) {
2550
+        if ( ! empty($name) && ! empty($id)) {
2551 2551
             $hidden_field_arr[$name] = array(
2552 2552
                 'type'  => 'hidden',
2553 2553
                 'value' => $id,
2554 2554
             );
2555
-            $hf                      = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2555
+            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2556 2556
         } else {
2557 2557
             $hf = '';
2558 2558
         }
@@ -2672,7 +2672,7 @@  discard block
 block discarded – undo
2672 2672
             'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'
2673 2673
         ) : $callback;
2674 2674
         add_meta_box(
2675
-            str_replace('_', '-', $action) . '-mbox',
2675
+            str_replace('_', '-', $action).'-mbox',
2676 2676
             $title,
2677 2677
             $call_back_func,
2678 2678
             $this->_wp_page_slug,
@@ -2764,9 +2764,9 @@  discard block
 block discarded – undo
2764 2764
             : 'espresso-default-admin';
2765 2765
         $template_path                                     = $sidebar
2766 2766
             ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2767
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2767
+            : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2768 2768
         if (defined('DOING_AJAX') && DOING_AJAX) {
2769
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2769
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2770 2770
         }
2771 2771
         $template_path                                     = ! empty($this->_column_template_path)
2772 2772
             ? $this->_column_template_path : $template_path;
@@ -2821,7 +2821,7 @@  discard block
 block discarded – undo
2821 2821
                 true
2822 2822
             )
2823 2823
             : $this->_template_args['preview_action_button'];
2824
-        $template_path                                 = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2824
+        $template_path                                 = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2825 2825
         $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2826 2826
             $template_path,
2827 2827
             $this->_template_args,
@@ -2872,7 +2872,7 @@  discard block
 block discarded – undo
2872 2872
         //setup search attributes
2873 2873
         $this->_set_search_attributes();
2874 2874
         $this->_template_args['current_page']     = $this->_wp_page_slug;
2875
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2875
+        $template_path                            = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2876 2876
         $this->_template_args['table_url']        = defined('DOING_AJAX')
2877 2877
             ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2878 2878
             : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2880,10 +2880,10 @@  discard block
 block discarded – undo
2880 2880
         $this->_template_args['current_route']    = $this->_req_action;
2881 2881
         $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2882 2882
         $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2883
-        if (! empty($ajax_sorting_callback)) {
2883
+        if ( ! empty($ajax_sorting_callback)) {
2884 2884
             $sortable_list_table_form_fields = wp_nonce_field(
2885
-                $ajax_sorting_callback . '_nonce',
2886
-                $ajax_sorting_callback . '_nonce',
2885
+                $ajax_sorting_callback.'_nonce',
2886
+                $ajax_sorting_callback.'_nonce',
2887 2887
                 false,
2888 2888
                 false
2889 2889
             );
@@ -2901,19 +2901,19 @@  discard block
 block discarded – undo
2901 2901
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2902 2902
         $hidden_form_fields                                      = isset($this->_template_args['list_table_hidden_fields'])
2903 2903
             ? $this->_template_args['list_table_hidden_fields'] : '';
2904
-        $nonce_ref                                               = $this->_req_action . '_nonce';
2905
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
2904
+        $nonce_ref                                               = $this->_req_action.'_nonce';
2905
+        $hidden_form_fields .= '<input type="hidden" name="'
2906 2906
                                                                     . $nonce_ref
2907 2907
                                                                     . '" value="'
2908 2908
                                                                     . wp_create_nonce($nonce_ref)
2909 2909
                                                                     . '">';
2910
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
2910
+        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2911 2911
         //display message about search results?
2912 2912
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2913
-            ? '<p class="ee-search-results">' . sprintf(
2913
+            ? '<p class="ee-search-results">'.sprintf(
2914 2914
                 esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2915 2915
                 trim($this->_req_data['s'], '%')
2916
-            ) . '</p>'
2916
+            ).'</p>'
2917 2917
             : '';
2918 2918
         // filter before_list_table template arg
2919 2919
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2928,9 +2928,9 @@  discard block
 block discarded – undo
2928 2928
         // but would not be backwards compatible, so we have to add a new filter
2929 2929
         $this->_template_args['before_list_table'] = implode(
2930 2930
             " \n",
2931
-            (array)apply_filters(
2931
+            (array) apply_filters(
2932 2932
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2933
-                (array)$this->_template_args['before_list_table'],
2933
+                (array) $this->_template_args['before_list_table'],
2934 2934
                 $this->page_slug,
2935 2935
                 $this->_req_data,
2936 2936
                 $this->_req_action
@@ -2947,11 +2947,11 @@  discard block
 block discarded – undo
2947 2947
         // convert to array and filter again
2948 2948
         // arrays are easier to inject new items in a specific location,
2949 2949
         // but would not be backwards compatible, so we have to add a new filter
2950
-        $this->_template_args['after_list_table']   = implode(
2950
+        $this->_template_args['after_list_table'] = implode(
2951 2951
             " \n",
2952
-            (array)apply_filters(
2952
+            (array) apply_filters(
2953 2953
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2954
-                (array)$this->_template_args['after_list_table'],
2954
+                (array) $this->_template_args['after_list_table'],
2955 2955
                 $this->page_slug,
2956 2956
                 $this->_req_data,
2957 2957
                 $this->_req_action
@@ -2990,10 +2990,10 @@  discard block
 block discarded – undo
2990 2990
     {
2991 2991
         $this->_template_args['items'] = apply_filters(
2992 2992
             'FHEE__EE_Admin_Page___display_legend__items',
2993
-            (array)$items,
2993
+            (array) $items,
2994 2994
             $this
2995 2995
         );
2996
-        $legend_template               = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2996
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2997 2997
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2998 2998
     }
2999 2999
 
@@ -3095,16 +3095,16 @@  discard block
 block discarded – undo
3095 3095
         $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3096 3096
         $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3097 3097
         $this->_template_args['before_admin_page_content'] = apply_filters(
3098
-            'FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
3098
+            'FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
3099 3099
             isset($this->_template_args['before_admin_page_content'])
3100 3100
                 ? $this->_template_args['before_admin_page_content'] : ''
3101 3101
         );
3102
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3103
-            'FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
3102
+        $this->_template_args['after_admin_page_content'] = apply_filters(
3103
+            'FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
3104 3104
             isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content']
3105 3105
                 : ''
3106 3106
         );
3107
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3107
+        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
3108 3108
         // load settings page wrapper template
3109 3109
         $template_path = ! defined('DOING_AJAX')
3110 3110
             ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
@@ -3195,8 +3195,8 @@  discard block
 block discarded – undo
3195 3195
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
3196 3196
     {
3197 3197
         //make sure $text and $actions are in an array
3198
-        $text          = (array)$text;
3199
-        $actions       = (array)$actions;
3198
+        $text          = (array) $text;
3199
+        $actions       = (array) $actions;
3200 3200
         $referrer_url  = empty($referrer) ? '' : $referrer;
3201 3201
         $referrer_url  = ! $referrer
3202 3202
             ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
@@ -3205,7 +3205,7 @@  discard block
 block discarded – undo
3205 3205
             : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3206 3206
               . $referrer
3207 3207
               . '" />';
3208
-        $button_text   = ! empty($text)
3208
+        $button_text = ! empty($text)
3209 3209
             ? $text
3210 3210
             : array(
3211 3211
                 __('Save', 'event_espresso'),
@@ -3216,7 +3216,7 @@  discard block
 block discarded – undo
3216 3216
         $this->_template_args['save_buttons'] = $referrer_url;
3217 3217
         foreach ($button_text as $key => $button) {
3218 3218
             $ref                                  = $default_names[$key];
3219
-            $id                                   = $this->_current_view . '_' . $ref;
3219
+            $id                                   = $this->_current_view.'_'.$ref;
3220 3220
             $name                                 = ! empty($actions) ? $actions[$key] : $ref;
3221 3221
             $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3222 3222
                                                      . $ref
@@ -3227,7 +3227,7 @@  discard block
 block discarded – undo
3227 3227
                                                      . '" id="'
3228 3228
                                                      . $id
3229 3229
                                                      . '" />';
3230
-            if (! $both) {
3230
+            if ( ! $both) {
3231 3231
                 break;
3232 3232
             }
3233 3233
         }
@@ -3262,12 +3262,12 @@  discard block
 block discarded – undo
3262 3262
     {
3263 3263
         if (empty($route)) {
3264 3264
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
3265
-            $dev_msg  = $user_msg . "\n" . sprintf(
3265
+            $dev_msg  = $user_msg."\n".sprintf(
3266 3266
                     __('The $route argument is required for the %s->%s method.', 'event_espresso'),
3267 3267
                     __FUNCTION__,
3268 3268
                     __CLASS__
3269 3269
                 );
3270
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3270
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
3271 3271
         }
3272 3272
         // open form
3273 3273
         $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
@@ -3276,9 +3276,9 @@  discard block
 block discarded – undo
3276 3276
                                                              . $route
3277 3277
                                                              . '_event_form" >';
3278 3278
         // add nonce
3279
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3279
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
3280 3280
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
3281
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3281
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
3282 3282
         // add REQUIRED form action
3283 3283
         $hidden_fields = array(
3284 3284
             'action' => array('type' => 'hidden', 'value' => $route),
@@ -3289,8 +3289,8 @@  discard block
 block discarded – undo
3289 3289
         // generate form fields
3290 3290
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3291 3291
         // add fields to form
3292
-        foreach ((array)$form_fields as $field_name => $form_field) {
3293
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3292
+        foreach ((array) $form_fields as $field_name => $form_field) {
3293
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
3294 3294
         }
3295 3295
         // close form
3296 3296
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -3344,10 +3344,10 @@  discard block
 block discarded – undo
3344 3344
         $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3345 3345
         $notices      = EE_Error::get_notices(false);
3346 3346
         // overwrite default success messages //BUT ONLY if overwrite not overridden
3347
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3347
+        if ( ! $override_overwrite || ! empty($notices['errors'])) {
3348 3348
             EE_Error::overwrite_success();
3349 3349
         }
3350
-        if (! empty($what) && ! empty($action_desc)) {
3350
+        if ( ! empty($what) && ! empty($action_desc)) {
3351 3351
             // how many records affected ? more than one record ? or just one ?
3352 3352
             if ($success > 1 && empty($notices['errors'])) {
3353 3353
                 // set plural msg
@@ -3376,7 +3376,7 @@  discard block
 block discarded – undo
3376 3376
             }
3377 3377
         }
3378 3378
         // check that $query_args isn't something crazy
3379
-        if (! is_array($query_args)) {
3379
+        if ( ! is_array($query_args)) {
3380 3380
             $query_args = array();
3381 3381
         }
3382 3382
         /**
@@ -3388,7 +3388,7 @@  discard block
 block discarded – undo
3388 3388
          *                                method.
3389 3389
          */
3390 3390
         do_action(
3391
-            'AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action,
3391
+            'AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action,
3392 3392
             $query_args
3393 3393
         );
3394 3394
         //calculate where we're going (if we have a "save and close" button pushed)
@@ -3401,12 +3401,12 @@  discard block
 block discarded – undo
3401 3401
             $redirect_url = admin_url('admin.php');
3402 3402
         }
3403 3403
         //merge any default query_args set in _default_route_query_args property
3404
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3404
+        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3405 3405
             $args_to_merge = array();
3406 3406
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
3407 3407
                 //is there a wp_referer array in our _default_route_query_args property?
3408 3408
                 if ($query_param == 'wp_referer') {
3409
-                    $query_value = (array)$query_value;
3409
+                    $query_value = (array) $query_value;
3410 3410
                     foreach ($query_value as $reference => $value) {
3411 3411
                         if (strpos($reference, 'nonce') !== false) {
3412 3412
                             continue;
@@ -3432,18 +3432,18 @@  discard block
 block discarded – undo
3432 3432
         // if redirecting to anything other than the main page, add a nonce
3433 3433
         if (isset($query_args['action'])) {
3434 3434
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
3435
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3435
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
3436 3436
         }
3437 3437
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
3438
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3438
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
3439 3439
         $redirect_url = apply_filters(
3440
-            'FHEE_redirect_' . $classname . $this->_req_action,
3440
+            'FHEE_redirect_'.$classname.$this->_req_action,
3441 3441
             self::add_query_args_and_nonce($query_args, $redirect_url),
3442 3442
             $query_args
3443 3443
         );
3444 3444
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3445 3445
         if (defined('DOING_AJAX')) {
3446
-            $default_data                    = array(
3446
+            $default_data = array(
3447 3447
                 'close'        => true,
3448 3448
                 'redirect_url' => $redirect_url,
3449 3449
                 'where'        => 'main',
@@ -3490,7 +3490,7 @@  discard block
 block discarded – undo
3490 3490
         }
3491 3491
         $this->_template_args['notices'] = EE_Error::get_notices();
3492 3492
         //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3493
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3493
+        if ( ! defined('DOING_AJAX') || $sticky_notices) {
3494 3494
             $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3495 3495
             $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
3496 3496
         }
@@ -3534,7 +3534,7 @@  discard block
 block discarded – undo
3534 3534
                 )
3535 3535
             );
3536 3536
         }
3537
-        if (! isset($this->_labels['buttons'][$type])) {
3537
+        if ( ! isset($this->_labels['buttons'][$type])) {
3538 3538
             throw new EE_Error(
3539 3539
                 sprintf(
3540 3540
                     __(
@@ -3547,7 +3547,7 @@  discard block
 block discarded – undo
3547 3547
         }
3548 3548
         //finally check user access for this button.
3549 3549
         $has_access = $this->check_user_access($action, true);
3550
-        if (! $has_access) {
3550
+        if ( ! $has_access) {
3551 3551
             return '';
3552 3552
         }
3553 3553
         $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
@@ -3555,7 +3555,7 @@  discard block
 block discarded – undo
3555 3555
             'action' => $action,
3556 3556
         );
3557 3557
         //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3558
-        if (! empty($extra_request)) {
3558
+        if ( ! empty($extra_request)) {
3559 3559
             $query_args = array_merge($extra_request, $query_args);
3560 3560
         }
3561 3561
         $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
@@ -3576,7 +3576,7 @@  discard block
 block discarded – undo
3576 3576
         $args   = array(
3577 3577
             'label'   => $this->_admin_page_title,
3578 3578
             'default' => 10,
3579
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3579
+            'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3580 3580
         );
3581 3581
         //ONLY add the screen option if the user has access to it.
3582 3582
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3599,7 +3599,7 @@  discard block
 block discarded – undo
3599 3599
     {
3600 3600
         if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3601 3601
             check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3602
-            if (! $user = wp_get_current_user()) {
3602
+            if ( ! $user = wp_get_current_user()) {
3603 3603
                 return;
3604 3604
             }
3605 3605
             $option = $_POST['wp_screen_options']['option'];
@@ -3610,8 +3610,8 @@  discard block
 block discarded – undo
3610 3610
             $map_option = $option;
3611 3611
             $option     = str_replace('-', '_', $option);
3612 3612
             switch ($map_option) {
3613
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3614
-                    $value = (int)$value;
3613
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3614
+                    $value = (int) $value;
3615 3615
                     if ($value < 1 || $value > 999) {
3616 3616
                         return;
3617 3617
                     }
@@ -3643,7 +3643,7 @@  discard block
 block discarded – undo
3643 3643
      */
3644 3644
     public function set_template_args($data)
3645 3645
     {
3646
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3646
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3647 3647
     }
3648 3648
 
3649 3649
 
@@ -3663,16 +3663,16 @@  discard block
 block discarded – undo
3663 3663
     protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3664 3664
     {
3665 3665
         $user_id = get_current_user_id();
3666
-        if (! $skip_route_verify) {
3666
+        if ( ! $skip_route_verify) {
3667 3667
             $this->_verify_route($route);
3668 3668
         }
3669 3669
         //now let's set the string for what kind of transient we're setting
3670
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3670
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3671 3671
         $data      = $notices ? array('notices' => $data) : $data;
3672 3672
         //is there already a transient for this route?  If there is then let's ADD to that transient
3673 3673
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3674 3674
         if ($existing) {
3675
-            $data = array_merge((array)$data, (array)$existing);
3675
+            $data = array_merge((array) $data, (array) $existing);
3676 3676
         }
3677 3677
         if (is_multisite() && is_network_admin()) {
3678 3678
             set_site_transient($transient, $data, 8);
@@ -3693,7 +3693,7 @@  discard block
 block discarded – undo
3693 3693
     {
3694 3694
         $user_id   = get_current_user_id();
3695 3695
         $route     = ! $route ? $this->_req_action : $route;
3696
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3696
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3697 3697
         $data      = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3698 3698
         //delete transient after retrieval (just in case it hasn't expired);
3699 3699
         if (is_multisite() && is_network_admin()) {
@@ -3935,7 +3935,7 @@  discard block
 block discarded – undo
3935 3935
      */
3936 3936
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3937 3937
     {
3938
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3938
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3939 3939
     }
3940 3940
 
3941 3941
 
@@ -3949,7 +3949,7 @@  discard block
 block discarded – undo
3949 3949
      */
3950 3950
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3951 3951
     {
3952
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3952
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3953 3953
     }
3954 3954
 
3955 3955
 
Please login to merge, or discard this patch.
caffeinated/admin/extend/support/Extend_Support_Admin_Page.core.php 2 patches
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -27,70 +27,70 @@  discard block
 block discarded – undo
27 27
 class Extend_Support_Admin_Page extends Support_Admin_Page
28 28
 {
29 29
 
30
-    public function __construct($routing = true)
31
-    {
32
-        parent::__construct($routing);
33
-        define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/');
34
-    }
35
-
36
-
37
-
38
-    protected function _extend_page_config()
39
-    {
40
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
41
-        //new routes and new configs (or overrides )
42
-        $new_page_routes    = array(
43
-            'faq' => array(
44
-                'func'       => '_faq',
45
-                'capability' => 'ee_read_ee',
46
-            ),
47
-        );
48
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
49
-        $new_page_config    = array(
50
-            'faq' => array(
51
-                'nav'           => array(
52
-                    'label' => __('FAQ', 'event_espresso'),
53
-                    'order' => 40,
54
-                ),
55
-                'metaboxes'     => array('_espresso_news_post_box', '_espresso_links_post_box'),
56
-                'require_nonce' => false,
57
-            ),
58
-        );
59
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
60
-        $this->_page_config['default']['metaboxes'][] = '_installation_boxes';
61
-    }
62
-
63
-
64
-
65
-    protected function _faq()
66
-    {
67
-        $template_path                              = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
68
-                                                      . 'support_admin_details_faq.template.php';
69
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', true);
70
-        $this->display_admin_page_with_sidebar();
71
-    }
72
-
73
-
74
-
75
-    protected function _installation_boxes()
76
-    {
77
-        $callback_args = array(
78
-            'template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
79
-                               . 'support_admin_details_additional_information.template.php',
80
-        );
81
-        add_meta_box(
82
-            'espresso_additional_information_support',
83
-            __('Additional Information', 'event_espresso'),
84
-            create_function(
85
-                '$post, $metabox',
86
-                'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);'
87
-            ),
88
-            $this->_current_screen->id,
89
-            'normal',
90
-            'high',
91
-            $callback_args
92
-        );
93
-    }
30
+	public function __construct($routing = true)
31
+	{
32
+		parent::__construct($routing);
33
+		define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/');
34
+	}
35
+
36
+
37
+
38
+	protected function _extend_page_config()
39
+	{
40
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
41
+		//new routes and new configs (or overrides )
42
+		$new_page_routes    = array(
43
+			'faq' => array(
44
+				'func'       => '_faq',
45
+				'capability' => 'ee_read_ee',
46
+			),
47
+		);
48
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
49
+		$new_page_config    = array(
50
+			'faq' => array(
51
+				'nav'           => array(
52
+					'label' => __('FAQ', 'event_espresso'),
53
+					'order' => 40,
54
+				),
55
+				'metaboxes'     => array('_espresso_news_post_box', '_espresso_links_post_box'),
56
+				'require_nonce' => false,
57
+			),
58
+		);
59
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
60
+		$this->_page_config['default']['metaboxes'][] = '_installation_boxes';
61
+	}
62
+
63
+
64
+
65
+	protected function _faq()
66
+	{
67
+		$template_path                              = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
68
+													  . 'support_admin_details_faq.template.php';
69
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', true);
70
+		$this->display_admin_page_with_sidebar();
71
+	}
72
+
73
+
74
+
75
+	protected function _installation_boxes()
76
+	{
77
+		$callback_args = array(
78
+			'template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH
79
+							   . 'support_admin_details_additional_information.template.php',
80
+		);
81
+		add_meta_box(
82
+			'espresso_additional_information_support',
83
+			__('Additional Information', 'event_espresso'),
84
+			create_function(
85
+				'$post, $metabox',
86
+				'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);'
87
+			),
88
+			$this->_current_screen->id,
89
+			'normal',
90
+			'high',
91
+			$callback_args
92
+		);
93
+	}
94 94
 
95 95
 
96 96
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -30,16 +30,16 @@  discard block
 block discarded – undo
30 30
     public function __construct($routing = true)
31 31
     {
32 32
         parent::__construct($routing);
33
-        define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/');
33
+        define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'support/templates/');
34 34
     }
35 35
 
36 36
 
37 37
 
38 38
     protected function _extend_page_config()
39 39
     {
40
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
40
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'support';
41 41
         //new routes and new configs (or overrides )
42
-        $new_page_routes    = array(
42
+        $new_page_routes = array(
43 43
             'faq' => array(
44 44
                 'func'       => '_faq',
45 45
                 'capability' => 'ee_read_ee',
Please login to merge, or discard this patch.
espresso.php 1 patch
Indentation   +192 added lines, -192 removed lines patch added patch discarded remove patch
@@ -38,217 +38,217 @@
 block discarded – undo
38 38
  * @since       4.0
39 39
  */
40 40
 if (function_exists('espresso_version')) {
41
-    if (! function_exists('espresso_duplicate_plugin_error')) {
42
-        /**
43
-         *    espresso_duplicate_plugin_error
44
-         *    displays if more than one version of EE is activated at the same time
45
-         */
46
-        function espresso_duplicate_plugin_error()
47
-        {
48
-            ?>
41
+	if (! function_exists('espresso_duplicate_plugin_error')) {
42
+		/**
43
+		 *    espresso_duplicate_plugin_error
44
+		 *    displays if more than one version of EE is activated at the same time
45
+		 */
46
+		function espresso_duplicate_plugin_error()
47
+		{
48
+			?>
49 49
             <div class="error">
50 50
                 <p>
51 51
                     <?php
52
-                    echo esc_html__(
53
-                        'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
-                        'event_espresso'
55
-                    ); ?>
52
+					echo esc_html__(
53
+						'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.',
54
+						'event_espresso'
55
+					); ?>
56 56
                 </p>
57 57
             </div>
58 58
             <?php
59
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
60
-        }
61
-    }
62
-    add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
59
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
60
+		}
61
+	}
62
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
63 63
 
64 64
 } else {
65
-    define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
-    if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
-        /**
68
-         * espresso_minimum_php_version_error
69
-         *
70
-         * @return void
71
-         */
72
-        function espresso_minimum_php_version_error()
73
-        {
74
-            ?>
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.9');
66
+	if (! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
67
+		/**
68
+		 * espresso_minimum_php_version_error
69
+		 *
70
+		 * @return void
71
+		 */
72
+		function espresso_minimum_php_version_error()
73
+		{
74
+			?>
75 75
             <div class="error">
76 76
                 <p>
77 77
                     <?php
78
-                    printf(
79
-                        esc_html__(
80
-                            'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
81
-                            'event_espresso'
82
-                        ),
83
-                        EE_MIN_PHP_VER_REQUIRED,
84
-                        PHP_VERSION,
85
-                        '<br/>',
86
-                        '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
-                    );
88
-                    ?>
78
+					printf(
79
+						esc_html__(
80
+							'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.',
81
+							'event_espresso'
82
+						),
83
+						EE_MIN_PHP_VER_REQUIRED,
84
+						PHP_VERSION,
85
+						'<br/>',
86
+						'<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>'
87
+					);
88
+					?>
89 89
                 </p>
90 90
             </div>
91 91
             <?php
92
-            espresso_deactivate_plugin(plugin_basename(__FILE__));
93
-        }
92
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
93
+		}
94 94
 
95
-        add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
-    } else {
97
-        define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
-        /**
99
-         * espresso_version
100
-         * Returns the plugin version
101
-         *
102
-         * @return string
103
-         */
104
-        function espresso_version()
105
-        {
106
-            return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.002');
107
-        }
95
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96
+	} else {
97
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
98
+		/**
99
+		 * espresso_version
100
+		 * Returns the plugin version
101
+		 *
102
+		 * @return string
103
+		 */
104
+		function espresso_version()
105
+		{
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.50.rc.002');
107
+		}
108 108
 
109
-        /**
110
-         * espresso_plugin_activation
111
-         * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
-         */
113
-        function espresso_plugin_activation()
114
-        {
115
-            update_option('ee_espresso_activation', true);
116
-        }
109
+		/**
110
+		 * espresso_plugin_activation
111
+		 * adds a wp-option to indicate that EE has been activated via the WP admin plugins page
112
+		 */
113
+		function espresso_plugin_activation()
114
+		{
115
+			update_option('ee_espresso_activation', true);
116
+		}
117 117
 
118
-        register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
-        /**
120
-         *    espresso_load_error_handling
121
-         *    this function loads EE's class for handling exceptions and errors
122
-         */
123
-        function espresso_load_error_handling()
124
-        {
125
-            static $error_handling_loaded = false;
126
-            if ($error_handling_loaded) {
127
-                return;
128
-            }
129
-            // load debugging tools
130
-            if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
-                require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
132
-                \EEH_Debug_Tools::instance();
133
-            }
134
-            // load error handling
135
-            if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
-                require_once EE_CORE . 'EE_Error.core.php';
137
-            } else {
138
-                wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
-            }
140
-            $error_handling_loaded = true;
141
-        }
118
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
119
+		/**
120
+		 *    espresso_load_error_handling
121
+		 *    this function loads EE's class for handling exceptions and errors
122
+		 */
123
+		function espresso_load_error_handling()
124
+		{
125
+			static $error_handling_loaded = false;
126
+			if ($error_handling_loaded) {
127
+				return;
128
+			}
129
+			// load debugging tools
130
+			if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) {
131
+				require_once   EE_HELPERS . 'EEH_Debug_Tools.helper.php';
132
+				\EEH_Debug_Tools::instance();
133
+			}
134
+			// load error handling
135
+			if (is_readable(EE_CORE . 'EE_Error.core.php')) {
136
+				require_once EE_CORE . 'EE_Error.core.php';
137
+			} else {
138
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
139
+			}
140
+			$error_handling_loaded = true;
141
+		}
142 142
 
143
-        /**
144
-         *    espresso_load_required
145
-         *    given a class name and path, this function will load that file or throw an exception
146
-         *
147
-         * @param    string $classname
148
-         * @param    string $full_path_to_file
149
-         * @throws    EE_Error
150
-         */
151
-        function espresso_load_required($classname, $full_path_to_file)
152
-        {
153
-            if (is_readable($full_path_to_file)) {
154
-                require_once $full_path_to_file;
155
-            } else {
156
-                throw new \EE_Error (
157
-                    sprintf(
158
-                        esc_html__(
159
-                            'The %s class file could not be located or is not readable due to file permissions.',
160
-                            'event_espresso'
161
-                        ),
162
-                        $classname
163
-                    )
164
-                );
165
-            }
166
-        }
143
+		/**
144
+		 *    espresso_load_required
145
+		 *    given a class name and path, this function will load that file or throw an exception
146
+		 *
147
+		 * @param    string $classname
148
+		 * @param    string $full_path_to_file
149
+		 * @throws    EE_Error
150
+		 */
151
+		function espresso_load_required($classname, $full_path_to_file)
152
+		{
153
+			if (is_readable($full_path_to_file)) {
154
+				require_once $full_path_to_file;
155
+			} else {
156
+				throw new \EE_Error (
157
+					sprintf(
158
+						esc_html__(
159
+							'The %s class file could not be located or is not readable due to file permissions.',
160
+							'event_espresso'
161
+						),
162
+						$classname
163
+					)
164
+				);
165
+			}
166
+		}
167 167
 
168
-        /**
169
-         * @since 4.9.27
170
-         * @throws \EE_Error
171
-         * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
-         * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
-         * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
-         * @throws \EventEspresso\core\exceptions\InvalidClassException
175
-         * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
-         * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
-         * @throws \OutOfBoundsException
179
-         */
180
-        function bootstrap_espresso()
181
-        {
182
-            require_once __DIR__ . '/core/espresso_definitions.php';
183
-            try {
184
-                espresso_load_error_handling();
185
-                espresso_load_required(
186
-                    'EEH_Base',
187
-                    EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
-                );
189
-                espresso_load_required(
190
-                    'EEH_File',
191
-                    EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
-                );
193
-                espresso_load_required(
194
-                    'EEH_File',
195
-                    EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
-                );
197
-                espresso_load_required(
198
-                    'EEH_Array',
199
-                    EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
-                );
201
-                // instantiate and configure PSR4 autoloader
202
-                espresso_load_required(
203
-                    'Psr4Autoloader',
204
-                    EE_CORE . 'Psr4Autoloader.php'
205
-                );
206
-                espresso_load_required(
207
-                    'EE_Psr4AutoloaderInit',
208
-                    EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
-                );
210
-                $AutoloaderInit = new EE_Psr4AutoloaderInit();
211
-                $AutoloaderInit->initializeAutoloader();
212
-                espresso_load_required(
213
-                    'EE_Request',
214
-                    EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
-                );
216
-                espresso_load_required(
217
-                    'EE_Response',
218
-                    EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
-                );
220
-                espresso_load_required(
221
-                    'EE_Bootstrap',
222
-                    EE_CORE . 'EE_Bootstrap.core.php'
223
-                );
224
-                // bootstrap EE and the request stack
225
-                new EE_Bootstrap(
226
-                    new EE_Request($_GET, $_POST, $_COOKIE),
227
-                    new EE_Response()
228
-                );
229
-            } catch (Exception $e) {
230
-                require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
231
-                new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
-            }
233
-        }
234
-        bootstrap_espresso();
235
-    }
168
+		/**
169
+		 * @since 4.9.27
170
+		 * @throws \EE_Error
171
+		 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
172
+		 * @throws \EventEspresso\core\exceptions\InvalidEntityException
173
+		 * @throws \EventEspresso\core\exceptions\InvalidIdentifierException
174
+		 * @throws \EventEspresso\core\exceptions\InvalidClassException
175
+		 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
176
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceExistsException
177
+		 * @throws \EventEspresso\core\services\container\exceptions\ServiceNotFoundException
178
+		 * @throws \OutOfBoundsException
179
+		 */
180
+		function bootstrap_espresso()
181
+		{
182
+			require_once __DIR__ . '/core/espresso_definitions.php';
183
+			try {
184
+				espresso_load_error_handling();
185
+				espresso_load_required(
186
+					'EEH_Base',
187
+					EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'
188
+				);
189
+				espresso_load_required(
190
+					'EEH_File',
191
+					EE_CORE . 'interfaces' . DS . 'EEHI_File.interface.php'
192
+				);
193
+				espresso_load_required(
194
+					'EEH_File',
195
+					EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'
196
+				);
197
+				espresso_load_required(
198
+					'EEH_Array',
199
+					EE_CORE . 'helpers' . DS . 'EEH_Array.helper.php'
200
+				);
201
+				// instantiate and configure PSR4 autoloader
202
+				espresso_load_required(
203
+					'Psr4Autoloader',
204
+					EE_CORE . 'Psr4Autoloader.php'
205
+				);
206
+				espresso_load_required(
207
+					'EE_Psr4AutoloaderInit',
208
+					EE_CORE . 'EE_Psr4AutoloaderInit.core.php'
209
+				);
210
+				$AutoloaderInit = new EE_Psr4AutoloaderInit();
211
+				$AutoloaderInit->initializeAutoloader();
212
+				espresso_load_required(
213
+					'EE_Request',
214
+					EE_CORE . 'request_stack' . DS . 'EE_Request.core.php'
215
+				);
216
+				espresso_load_required(
217
+					'EE_Response',
218
+					EE_CORE . 'request_stack' . DS . 'EE_Response.core.php'
219
+				);
220
+				espresso_load_required(
221
+					'EE_Bootstrap',
222
+					EE_CORE . 'EE_Bootstrap.core.php'
223
+				);
224
+				// bootstrap EE and the request stack
225
+				new EE_Bootstrap(
226
+					new EE_Request($_GET, $_POST, $_COOKIE),
227
+					new EE_Response()
228
+				);
229
+			} catch (Exception $e) {
230
+				require_once EE_CORE . 'exceptions' . DS . 'ExceptionStackTraceDisplay.php';
231
+				new EventEspresso\core\exceptions\ExceptionStackTraceDisplay($e);
232
+			}
233
+		}
234
+		bootstrap_espresso();
235
+	}
236 236
 }
237 237
 if (! function_exists('espresso_deactivate_plugin')) {
238
-    /**
239
-     *    deactivate_plugin
240
-     * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
-     *
242
-     * @access public
243
-     * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
-     * @return    void
245
-     */
246
-    function espresso_deactivate_plugin($plugin_basename = '')
247
-    {
248
-        if (! function_exists('deactivate_plugins')) {
249
-            require_once ABSPATH . 'wp-admin/includes/plugin.php';
250
-        }
251
-        unset($_GET['activate'], $_REQUEST['activate']);
252
-        deactivate_plugins($plugin_basename);
253
-    }
238
+	/**
239
+	 *    deactivate_plugin
240
+	 * usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
241
+	 *
242
+	 * @access public
243
+	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
244
+	 * @return    void
245
+	 */
246
+	function espresso_deactivate_plugin($plugin_basename = '')
247
+	{
248
+		if (! function_exists('deactivate_plugins')) {
249
+			require_once ABSPATH . 'wp-admin/includes/plugin.php';
250
+		}
251
+		unset($_GET['activate'], $_REQUEST['activate']);
252
+		deactivate_plugins($plugin_basename);
253
+	}
254 254
 }
Please login to merge, or discard this patch.
modules/messages/EED_Messages.module.php 1 patch
Indentation   +1235 added lines, -1235 removed lines patch added patch discarded remove patch
@@ -18,1250 +18,1250 @@
 block discarded – undo
18 18
 class EED_Messages extends EED_Module
19 19
 {
20 20
 
21
-    /**
22
-     * This holds the EE_messages controller
23
-     *
24
-     * @deprecated 4.9.0
25
-     * @var EE_messages $_EEMSG
26
-     */
27
-    protected static $_EEMSG;
28
-
29
-    /**
30
-     * @type EE_Message_Resource_Manager $_message_resource_manager
31
-     */
32
-    protected static $_message_resource_manager;
33
-
34
-    /**
35
-     * This holds the EE_Messages_Processor business class.
36
-     *
37
-     * @type EE_Messages_Processor
38
-     */
39
-    protected static $_MSG_PROCESSOR;
40
-
41
-    /**
42
-     * holds all the paths for various messages components.
43
-     * Utilized by autoloader registry
44
-     *
45
-     * @var array
46
-     */
47
-    protected static $_MSG_PATHS;
48
-
49
-
50
-    /**
51
-     * This will hold an array of messages template packs that are registered in the messages system.
52
-     * Format is:
53
-     * array(
54
-     *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
55
-     * )
56
-     *
57
-     * @var EE_Messages_Template_Pack[]
58
-     */
59
-    protected static $_TMP_PACKS = array();
60
-
61
-
62
-    /**
63
-     * @return EED_Messages
64
-     */
65
-    public static function instance()
66
-    {
67
-        return parent::get_instance(__CLASS__);
68
-    }
69
-
70
-
71
-    /**
72
-     *  set_hooks - for hooking into EE Core, other modules, etc
73
-     *
74
-     * @since 4.5.0
75
-     * @return    void
76
-     */
77
-    public static function set_hooks()
78
-    {
79
-        //actions
80
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
81
-        add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
82
-            array('EED_Messages', 'maybe_registration'), 10, 2);
83
-        //filters
84
-        add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
85
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
86
-        add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
87
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
88
-        //register routes
89
-        self::_register_routes();
90
-    }
91
-
92
-    /**
93
-     *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
94
-     *
95
-     * @access    public
96
-     * @return    void
97
-     */
98
-    public static function set_hooks_admin()
99
-    {
100
-        //actions
101
-        add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
102
-        add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
103
-            array('EED_Messages', 'payment_reminder'), 10);
104
-        add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
105
-            array('EED_Messages', 'maybe_registration'), 10, 3);
106
-        add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
107
-            array('EED_Messages', 'send_newsletter_message'), 10, 2);
108
-        add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
109
-            array('EED_Messages', 'cancelled_registration'), 10);
110
-        add_action('AHEE__EE_Admin_Page___process_admin_payment_notification',
111
-            array('EED_Messages', 'process_admin_payment'), 10, 1);
112
-        //filters
113
-        add_filter('FHEE__EE_Admin_Page___process_resend_registration__success',
114
-            array('EED_Messages', 'process_resend'), 10, 2);
115
-        add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
116
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
117
-        add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
118
-            array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
119
-    }
120
-
121
-
122
-    /**
123
-     * All the message triggers done by route go in here.
124
-     *
125
-     * @since 4.5.0
126
-     * @return void
127
-     */
128
-    protected static function _register_routes()
129
-    {
130
-        EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
131
-        EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
132
-        EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
133
-        EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
134
-        do_action('AHEE__EED_Messages___register_routes');
135
-    }
136
-
137
-
138
-    /**
139
-     * This is called when a browser display trigger is executed.
140
-     * The browser display trigger is typically used when a already generated message is displayed directly in the
141
-     * browser.
142
-     *
143
-     * @since 4.9.0
144
-     * @param WP $WP
145
-     * @throws EE_Error
146
-     * @throws InvalidArgumentException
147
-     * @throws ReflectionException
148
-     * @throws InvalidDataTypeException
149
-     * @throws InvalidInterfaceException
150
-     */
151
-    public function browser_trigger($WP)
152
-    {
153
-        //ensure controller is loaded
154
-        self::_load_controller();
155
-        $token = EE_Registry::instance()->REQ->get('token');
156
-        try {
157
-            $mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
158
-            self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
159
-        } catch (EE_Error $e) {
160
-            $error_msg = __('Please note that a system message failed to send due to a technical issue.',
161
-                'event_espresso');
162
-            // add specific message for developers if WP_DEBUG in on
163
-            $error_msg .= '||' . $e->getMessage();
164
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
165
-        }
166
-    }
167
-
168
-
169
-    /**
170
-     * This is called when a browser error trigger is executed.
171
-     * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
172
-     * message and display it.
173
-     *
174
-     * @since 4.9.0
175
-     * @param $WP
176
-     * @throws EE_Error
177
-     * @throws InvalidArgumentException
178
-     * @throws InvalidDataTypeException
179
-     * @throws InvalidInterfaceException
180
-     */
181
-    public function browser_error_trigger($WP)
182
-    {
183
-        $token = EE_Registry::instance()->REQ->get('token');
184
-        if ($token) {
185
-            $message = EEM_Message::instance()->get_one_by_token($token);
186
-            if ($message instanceof EE_Message) {
187
-                header('HTTP/1.1 200 OK');
188
-                $error_msg = nl2br($message->error_message());
189
-                ?>
21
+	/**
22
+	 * This holds the EE_messages controller
23
+	 *
24
+	 * @deprecated 4.9.0
25
+	 * @var EE_messages $_EEMSG
26
+	 */
27
+	protected static $_EEMSG;
28
+
29
+	/**
30
+	 * @type EE_Message_Resource_Manager $_message_resource_manager
31
+	 */
32
+	protected static $_message_resource_manager;
33
+
34
+	/**
35
+	 * This holds the EE_Messages_Processor business class.
36
+	 *
37
+	 * @type EE_Messages_Processor
38
+	 */
39
+	protected static $_MSG_PROCESSOR;
40
+
41
+	/**
42
+	 * holds all the paths for various messages components.
43
+	 * Utilized by autoloader registry
44
+	 *
45
+	 * @var array
46
+	 */
47
+	protected static $_MSG_PATHS;
48
+
49
+
50
+	/**
51
+	 * This will hold an array of messages template packs that are registered in the messages system.
52
+	 * Format is:
53
+	 * array(
54
+	 *    'template_pack_dbref' => EE_Messages_Template_Pack (instance)
55
+	 * )
56
+	 *
57
+	 * @var EE_Messages_Template_Pack[]
58
+	 */
59
+	protected static $_TMP_PACKS = array();
60
+
61
+
62
+	/**
63
+	 * @return EED_Messages
64
+	 */
65
+	public static function instance()
66
+	{
67
+		return parent::get_instance(__CLASS__);
68
+	}
69
+
70
+
71
+	/**
72
+	 *  set_hooks - for hooking into EE Core, other modules, etc
73
+	 *
74
+	 * @since 4.5.0
75
+	 * @return    void
76
+	 */
77
+	public static function set_hooks()
78
+	{
79
+		//actions
80
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
81
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
82
+			array('EED_Messages', 'maybe_registration'), 10, 2);
83
+		//filters
84
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
85
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
86
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
87
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
88
+		//register routes
89
+		self::_register_routes();
90
+	}
91
+
92
+	/**
93
+	 *    set_hooks_admin - for hooking into EE Admin Core, other modules, etc
94
+	 *
95
+	 * @access    public
96
+	 * @return    void
97
+	 */
98
+	public static function set_hooks_admin()
99
+	{
100
+		//actions
101
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
102
+		add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder',
103
+			array('EED_Messages', 'payment_reminder'), 10);
104
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
105
+			array('EED_Messages', 'maybe_registration'), 10, 3);
106
+		add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations',
107
+			array('EED_Messages', 'send_newsletter_message'), 10, 2);
108
+		add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction',
109
+			array('EED_Messages', 'cancelled_registration'), 10);
110
+		add_action('AHEE__EE_Admin_Page___process_admin_payment_notification',
111
+			array('EED_Messages', 'process_admin_payment'), 10, 1);
112
+		//filters
113
+		add_filter('FHEE__EE_Admin_Page___process_resend_registration__success',
114
+			array('EED_Messages', 'process_resend'), 10, 2);
115
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url',
116
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
117
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url',
118
+			array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
119
+	}
120
+
121
+
122
+	/**
123
+	 * All the message triggers done by route go in here.
124
+	 *
125
+	 * @since 4.5.0
126
+	 * @return void
127
+	 */
128
+	protected static function _register_routes()
129
+	{
130
+		EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
131
+		EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
132
+		EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
133
+		EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
134
+		do_action('AHEE__EED_Messages___register_routes');
135
+	}
136
+
137
+
138
+	/**
139
+	 * This is called when a browser display trigger is executed.
140
+	 * The browser display trigger is typically used when a already generated message is displayed directly in the
141
+	 * browser.
142
+	 *
143
+	 * @since 4.9.0
144
+	 * @param WP $WP
145
+	 * @throws EE_Error
146
+	 * @throws InvalidArgumentException
147
+	 * @throws ReflectionException
148
+	 * @throws InvalidDataTypeException
149
+	 * @throws InvalidInterfaceException
150
+	 */
151
+	public function browser_trigger($WP)
152
+	{
153
+		//ensure controller is loaded
154
+		self::_load_controller();
155
+		$token = EE_Registry::instance()->REQ->get('token');
156
+		try {
157
+			$mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
158
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
159
+		} catch (EE_Error $e) {
160
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.',
161
+				'event_espresso');
162
+			// add specific message for developers if WP_DEBUG in on
163
+			$error_msg .= '||' . $e->getMessage();
164
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
165
+		}
166
+	}
167
+
168
+
169
+	/**
170
+	 * This is called when a browser error trigger is executed.
171
+	 * When triggered this will grab the EE_Message matching the token in the request and use that to get the error
172
+	 * message and display it.
173
+	 *
174
+	 * @since 4.9.0
175
+	 * @param $WP
176
+	 * @throws EE_Error
177
+	 * @throws InvalidArgumentException
178
+	 * @throws InvalidDataTypeException
179
+	 * @throws InvalidInterfaceException
180
+	 */
181
+	public function browser_error_trigger($WP)
182
+	{
183
+		$token = EE_Registry::instance()->REQ->get('token');
184
+		if ($token) {
185
+			$message = EEM_Message::instance()->get_one_by_token($token);
186
+			if ($message instanceof EE_Message) {
187
+				header('HTTP/1.1 200 OK');
188
+				$error_msg = nl2br($message->error_message());
189
+				?>
190 190
                 <!DOCTYPE html>
191 191
                 <html>
192 192
                 <head></head>
193 193
                 <body>
194 194
                 <?php echo empty($error_msg)
195
-                    ? esc_html__('Unfortunately, we were unable to capture the error message for this message.',
196
-                        'event_espresso')
197
-                    : wp_kses(
198
-                        $error_msg,
199
-                        array(
200
-                            'a'      => array(
201
-                                'href'  => array(),
202
-                                'title' => array(),
203
-                            ),
204
-                            'span'   => array(),
205
-                            'div'    => array(),
206
-                            'p'      => array(),
207
-                            'strong' => array(),
208
-                            'em'     => array(),
209
-                            'br'     => array(),
210
-                        )
211
-                    ); ?>
195
+					? esc_html__('Unfortunately, we were unable to capture the error message for this message.',
196
+						'event_espresso')
197
+					: wp_kses(
198
+						$error_msg,
199
+						array(
200
+							'a'      => array(
201
+								'href'  => array(),
202
+								'title' => array(),
203
+							),
204
+							'span'   => array(),
205
+							'div'    => array(),
206
+							'p'      => array(),
207
+							'strong' => array(),
208
+							'em'     => array(),
209
+							'br'     => array(),
210
+						)
211
+					); ?>
212 212
                 </body>
213 213
                 </html>
214 214
                 <?php
215
-                exit;
216
-            }
217
-        }
218
-        return;
219
-    }
220
-
221
-
222
-    /**
223
-     *  This runs when the msg_url_trigger route has initiated.
224
-     *
225
-     * @since 4.5.0
226
-     * @param WP $WP
227
-     * @throws EE_Error
228
-     * @throws InvalidArgumentException
229
-     * @throws ReflectionException
230
-     * @throws InvalidDataTypeException
231
-     * @throws InvalidInterfaceException
232
-     */
233
-    public function run($WP)
234
-    {
235
-        //ensure controller is loaded
236
-        self::_load_controller();
237
-        // attempt to process message
238
-        try {
239
-            /** @type EE_Message_To_Generate_From_Request $message_to_generate */
240
-            $message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
241
-            self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
242
-        } catch (EE_Error $e) {
243
-            $error_msg = __('Please note that a system message failed to send due to a technical issue.',
244
-                'event_espresso');
245
-            // add specific message for developers if WP_DEBUG in on
246
-            $error_msg .= '||' . $e->getMessage();
247
-            EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
248
-        }
249
-    }
250
-
251
-
252
-    /**
253
-     * This is triggered by the 'msg_cron_trigger' route.
254
-     *
255
-     * @param WP $WP
256
-     */
257
-    public function execute_batch_request($WP)
258
-    {
259
-        $this->run_cron();
260
-        header('HTTP/1.1 200 OK');
261
-        exit();
262
-    }
263
-
264
-
265
-    /**
266
-     * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
267
-     * request.
268
-     */
269
-    public function run_cron()
270
-    {
271
-        self::_load_controller();
272
-        //get required vars
273
-        $cron_type     = EE_Registry::instance()->REQ->get('type');
274
-        $transient_key = EE_Registry::instance()->REQ->get('key');
275
-
276
-        //now let's verify transient, if not valid exit immediately
277
-        if (! get_transient($transient_key)) {
278
-            /**
279
-             * trigger error so this gets in the error logs.  This is important because it happens on a non-user
280
-             * request.
281
-             */
282
-            trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
283
-        }
284
-
285
-        //if made it here, lets' delete the transient to keep the db clean
286
-        delete_transient($transient_key);
287
-
288
-        if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
289
-
290
-            $method = 'batch_' . $cron_type . '_from_queue';
291
-            if (method_exists(self::$_MSG_PROCESSOR, $method)) {
292
-                self::$_MSG_PROCESSOR->$method();
293
-            } else {
294
-                //no matching task
295
-                /**
296
-                 * trigger error so this gets in the error logs.  This is important because it happens on a non user
297
-                 * request.
298
-                 */
299
-                trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'),
300
-                    $cron_type)));
301
-            }
302
-        }
303
-
304
-        do_action('FHEE__EED_Messages__run_cron__end');
305
-    }
306
-
307
-
308
-    /**
309
-     * This is used to retrieve the template pack for the given name.
310
-     * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
311
-     * the default template pack is returned.
312
-     *
313
-     * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
314
-     * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
315
-     *                                   in generating the Pack class name).
316
-     * @return EE_Messages_Template_Pack
317
-     * @throws EE_Error
318
-     * @throws InvalidArgumentException
319
-     * @throws ReflectionException
320
-     * @throws InvalidDataTypeException
321
-     * @throws InvalidInterfaceException
322
-     */
323
-    public static function get_template_pack($template_pack_name)
324
-    {
325
-        EE_Registry::instance()->load_helper('MSG_Template');
326
-        return EEH_MSG_Template::get_template_pack($template_pack_name);
327
-    }
328
-
329
-
330
-    /**
331
-     * Retrieves an array of all template packs.
332
-     * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
333
-     *
334
-     * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
335
-     * @return EE_Messages_Template_Pack[]
336
-     * @throws EE_Error
337
-     * @throws InvalidArgumentException
338
-     * @throws ReflectionException
339
-     * @throws InvalidDataTypeException
340
-     * @throws InvalidInterfaceException
341
-     */
342
-    public static function get_template_packs()
343
-    {
344
-        EE_Registry::instance()->load_helper('MSG_Template');
345
-
346
-        //for backward compat, let's make sure this returns in the same format as originally.
347
-        $template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
348
-        $template_pack_collection->rewind();
349
-        $template_packs = array();
350
-        while ($template_pack_collection->valid()) {
351
-            $template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
352
-            $template_pack_collection->next();
353
-        }
354
-        return $template_packs;
355
-    }
356
-
357
-
358
-    /**
359
-     * This simply makes sure the autoloaders are registered for the EE_messages system.
360
-     *
361
-     * @since 4.5.0
362
-     * @return void
363
-     * @throws EE_Error
364
-     */
365
-    public static function set_autoloaders()
366
-    {
367
-        if (empty(self::$_MSG_PATHS)) {
368
-            self::_set_messages_paths();
369
-            foreach (self::$_MSG_PATHS as $path) {
370
-                EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
371
-            }
372
-            // add aliases
373
-            EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
374
-            EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
375
-        }
376
-    }
377
-
378
-
379
-    /**
380
-     * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
381
-     * for use by the Messages Autoloaders
382
-     *
383
-     * @since 4.5.0
384
-     * @return void.
385
-     */
386
-    protected static function _set_messages_paths()
387
-    {
388
-        $dir_ref = array(
389
-            'messages/message_type',
390
-            'messages/messenger',
391
-            'messages/defaults',
392
-            'messages/defaults/email',
393
-            'messages/data_class',
394
-            'messages/validators',
395
-            'messages/validators/email',
396
-            'messages/validators/html',
397
-            'shortcodes',
398
-        );
399
-        $paths   = array();
400
-        foreach ($dir_ref as $index => $dir) {
401
-            $paths[$index] = EE_LIBRARIES . $dir;
402
-        }
403
-        self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
404
-    }
405
-
406
-
407
-    /**
408
-     * Takes care of loading dependencies
409
-     *
410
-     * @since 4.5.0
411
-     * @return void
412
-     * @throws EE_Error
413
-     * @throws InvalidArgumentException
414
-     * @throws ReflectionException
415
-     * @throws InvalidDataTypeException
416
-     * @throws InvalidInterfaceException
417
-     */
418
-    protected static function _load_controller()
419
-    {
420
-        if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
421
-            EE_Registry::instance()->load_core('Request_Handler');
422
-            self::set_autoloaders();
423
-            self::$_EEMSG                    = EE_Registry::instance()->load_lib('messages');
424
-            self::$_MSG_PROCESSOR            = EE_Registry::instance()->load_lib('Messages_Processor');
425
-            self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
426
-        }
427
-    }
428
-
429
-
430
-    /**
431
-     * @param EE_Transaction $transaction
432
-     * @throws EE_Error
433
-     * @throws InvalidArgumentException
434
-     * @throws InvalidDataTypeException
435
-     * @throws InvalidInterfaceException
436
-     * @throws ReflectionException
437
-     */
438
-    public static function payment_reminder(EE_Transaction $transaction)
439
-    {
440
-        self::_load_controller();
441
-        $data = array($transaction, null);
442
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
443
-    }
444
-
445
-
446
-    /**
447
-     * Any messages triggers for after successful gateway payments should go in here.
448
-     *
449
-     * @param EE_Transaction $transaction object
450
-     * @param EE_Payment     $payment     object
451
-     * @return void
452
-     * @throws EE_Error
453
-     * @throws InvalidArgumentException
454
-     * @throws ReflectionException
455
-     * @throws InvalidDataTypeException
456
-     * @throws InvalidInterfaceException
457
-     */
458
-    public static function payment(EE_Transaction $transaction, EE_Payment $payment)
459
-    {
460
-        self::_load_controller();
461
-        $data = array($transaction, $payment);
462
-        EE_Registry::instance()->load_helper('MSG_Template');
463
-        $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
464
-        //if payment amount is less than 0 then switch to payment_refund message type.
465
-        $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
466
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
467
-    }
468
-
469
-
470
-    /**
471
-     * @param EE_Transaction $transaction
472
-     * @throws EE_Error
473
-     * @throws InvalidArgumentException
474
-     * @throws InvalidDataTypeException
475
-     * @throws InvalidInterfaceException
476
-     * @throws ReflectionException
477
-     */
478
-    public static function cancelled_registration(EE_Transaction $transaction)
479
-    {
480
-        self::_load_controller();
481
-        $data = array($transaction, null);
482
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
483
-    }
484
-
485
-
486
-
487
-    /**
488
-     * Trigger for Registration messages
489
-     * Note that what registration message type is sent depends on what the reg status is for the registrations on the
490
-     * incoming transaction.
491
-     *
492
-     * @param EE_Registration $registration
493
-     * @param array           $extra_details
494
-     * @return void
495
-     * @throws EE_Error
496
-     * @throws InvalidArgumentException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     * @throws ReflectionException
500
-     * @throws EntityNotFoundException
501
-     */
502
-    public static function maybe_registration(EE_Registration $registration, $extra_details = array())
503
-    {
504
-
505
-        if (! self::_verify_registration_notification_send($registration, $extra_details)) {
506
-            //no messages please
507
-            return;
508
-        }
509
-
510
-        // get all non-trashed registrations so we make sure we send messages for the right status.
511
-        $all_registrations = $registration->transaction()->registrations(
512
-            array(
513
-                array('REG_deleted' => false),
514
-                'order_by' => array(
515
-                    'Event.EVT_name'     => 'ASC',
516
-                    'Attendee.ATT_lname' => 'ASC',
517
-                    'Attendee.ATT_fname' => 'ASC'
518
-                )
519
-            )
520
-        );
521
-        //cached array of statuses so we only trigger messages once per status.
522
-        $statuses_sent = array();
523
-        self::_load_controller();
524
-        $mtgs = array();
525
-
526
-        //loop through registrations and trigger messages once per status.
527
-        foreach ($all_registrations as $reg) {
528
-
529
-            //already triggered?
530
-            if (in_array($reg->status_ID(), $statuses_sent)) {
531
-                continue;
532
-            }
533
-
534
-            $message_type    = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
535
-            $mtgs            = array_merge(
536
-                    $mtgs,
537
-                    self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
538
-                            $message_type,
539
-                            array($registration->transaction(), null, $reg->status_ID())
540
-                    )
541
-            );
542
-            $statuses_sent[] = $reg->status_ID();
543
-        }
544
-
545
-        if (count($statuses_sent) > 1) {
546
-            $mtgs = array_merge(
547
-                $mtgs,
548
-                self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
549
-                    'registration_summary',
550
-                    array($registration->transaction(), null)
551
-                )
552
-            );
553
-        }
554
-
555
-        //batch queue and initiate request
556
-        self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
557
-        self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
558
-    }
559
-
560
-
561
-    /**
562
-     * This is a helper method used to very whether a registration notification should be sent or
563
-     * not.  Prevents duplicate notifications going out for registration context notifications.
564
-     *
565
-     * @param EE_Registration $registration  [description]
566
-     * @param array           $extra_details [description]
567
-     * @return bool          true = send away, false = nope halt the presses.
568
-     */
569
-    protected static function _verify_registration_notification_send(
570
-        EE_Registration $registration,
571
-        $extra_details = array()
572
-    ) {
573
-        //self::log(
574
-        //	__CLASS__, __FUNCTION__, __LINE__,
575
-        //	$registration->transaction(),
576
-        //	array( '$extra_details' => $extra_details )
577
-        //);
578
-        // currently only using this to send messages for the primary registrant
579
-        if (! $registration->is_primary_registrant()) {
580
-            return false;
581
-        }
582
-        // first we check if we're in admin and not doing front ajax
583
-        if (is_admin() && ! EE_FRONT_AJAX) {
584
-            //make sure appropriate admin params are set for sending messages
585
-            if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) {
586
-                //no messages sent please.
587
-                return false;
588
-            }
589
-        } else {
590
-            // frontend request (either regular or via AJAX)
591
-            // TXN is NOT finalized ?
592
-            if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
593
-                return false;
594
-            }
595
-            // return visit but nothing changed ???
596
-            if (
597
-                isset($extra_details['revisit'], $extra_details['status_updates']) &&
598
-                $extra_details['revisit'] && ! $extra_details['status_updates']
599
-            ) {
600
-                return false;
601
-            }
602
-            // NOT sending messages && reg status is something other than "Not-Approved"
603
-            if (
604
-                ! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
605
-                $registration->status_ID() !== EEM_Registration::status_id_not_approved
606
-            ) {
607
-                return false;
608
-            }
609
-        }
610
-        // release the kraken
611
-        return true;
612
-    }
613
-
614
-
615
-    /**
616
-     * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
617
-     * status id.
618
-     *
619
-     * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
620
-     *                    or EEH_MSG_Template::convert_reg_status_to_message_type
621
-     * @param string $reg_status
622
-     * @return array
623
-     * @throws EE_Error
624
-     * @throws InvalidArgumentException
625
-     * @throws ReflectionException
626
-     * @throws InvalidDataTypeException
627
-     * @throws InvalidInterfaceException
628
-     */
629
-    protected static function _get_reg_status_array($reg_status = '')
630
-    {
631
-        EE_Registry::instance()->load_helper('MSG_Template');
632
-        return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
633
-            ? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
634
-            : EEH_MSG_Template::reg_status_to_message_type_array();
635
-    }
636
-
637
-
638
-    /**
639
-     * Simply returns the payment message type for the given payment status.
640
-     *
641
-     * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
642
-     *                   or EEH_MSG_Template::convert_payment_status_to_message_type
643
-     * @param string $payment_status The payment status being matched.
644
-     * @return bool|string The payment message type slug matching the status or false if no match.
645
-     * @throws EE_Error
646
-     * @throws InvalidArgumentException
647
-     * @throws ReflectionException
648
-     * @throws InvalidDataTypeException
649
-     * @throws InvalidInterfaceException
650
-     */
651
-    protected static function _get_payment_message_type($payment_status)
652
-    {
653
-        EE_Registry::instance()->load_helper('MSG_Template');
654
-        return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
655
-            ? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
656
-            : false;
657
-    }
658
-
659
-
660
-    /**
661
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
662
-     *
663
-     * @access public
664
-     * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
665
-     * @return bool success/fail
666
-     * @throws EE_Error
667
-     * @throws InvalidArgumentException
668
-     * @throws InvalidDataTypeException
669
-     * @throws InvalidInterfaceException
670
-     * @throws ReflectionException
671
-     */
672
-    public static function process_resend($req_data)
673
-    {
674
-        self::_load_controller();
675
-
676
-        //if $msgID in this request then skip to the new resend_message
677
-        if (EE_Registry::instance()->REQ->get('MSG_ID')) {
678
-            return self::resend_message();
679
-        }
680
-
681
-        //make sure any incoming request data is set on the REQ so that it gets picked up later.
682
-        $req_data = (array)$req_data;
683
-        foreach ($req_data as $request_key => $request_value) {
684
-            EE_Registry::instance()->REQ->set($request_key, $request_value);
685
-        }
686
-
687
-        if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
688
-            return false;
689
-        }
690
-
691
-        try {
692
-            self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
693
-            self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
694
-        } catch (EE_Error $e) {
695
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
696
-            return false;
697
-        }
698
-        EE_Error::add_success(
699
-            __('Messages have been successfully queued for generation and sending.', 'event_espresso')
700
-        );
701
-        return true; //everything got queued.
702
-    }
703
-
704
-
705
-    /**
706
-     * Message triggers for a resending already sent message(s) (via EE_Message list table)
707
-     *
708
-     * @return bool
709
-     * @throws EE_Error
710
-     * @throws InvalidArgumentException
711
-     * @throws InvalidDataTypeException
712
-     * @throws InvalidInterfaceException
713
-     * @throws ReflectionException
714
-     */
715
-    public static function resend_message()
716
-    {
717
-        self::_load_controller();
718
-
719
-        $msgID = EE_Registry::instance()->REQ->get('MSG_ID');
720
-        if (! $msgID) {
721
-            EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request',
722
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
723
-            return false;
724
-        }
725
-
726
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID);
727
-
728
-        //setup success message.
729
-        $count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
730
-        EE_Error::add_success(sprintf(
731
-            _n(
732
-                'There was %d message queued for resending.',
733
-                'There were %d messages queued for resending.',
734
-                $count_ready_for_resend,
735
-                'event_espresso'
736
-            ),
737
-            $count_ready_for_resend
738
-        ));
739
-        return true;
740
-    }
741
-
742
-
743
-    /**
744
-     * Message triggers for manual payment applied by admin
745
-     *
746
-     * @param  EE_Payment $payment EE_payment object
747
-     * @return bool success/fail
748
-     * @throws EE_Error
749
-     * @throws InvalidArgumentException
750
-     * @throws ReflectionException
751
-     * @throws InvalidDataTypeException
752
-     * @throws InvalidInterfaceException
753
-     */
754
-    public static function process_admin_payment(EE_Payment $payment)
755
-    {
756
-        EE_Registry::instance()->load_helper('MSG_Template');
757
-        //we need to get the transaction object
758
-        $transaction = $payment->transaction();
759
-        if ($transaction instanceof EE_Transaction) {
760
-            $data         = array($transaction, $payment);
761
-            $message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
762
-
763
-            //if payment amount is less than 0 then switch to payment_refund message type.
764
-            $message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
765
-
766
-            //if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
767
-            $message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type;
768
-
769
-            self::_load_controller();
770
-
771
-            self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
772
-
773
-            //get count of queued for generation
774
-            $count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(
775
-                EEM_Message::status_incomplete,
776
-                EEM_Message::status_idle,
777
-            ));
778
-
779
-            if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
780
-                add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
781
-                return true;
782
-            } else {
783
-                $count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending());
784
-                /**
785
-                 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
786
-                 * IMMEDIATE generation.
787
-                 */
788
-                if ($count_failed > 0) {
789
-                    EE_Error::add_error(sprintf(
790
-                        _n(
791
-                            'The payment notification generation failed.',
792
-                            '%d payment notifications failed being sent.',
793
-                            $count_failed,
794
-                            'event_espresso'
795
-                        ),
796
-                        $count_failed
797
-                    ), __FILE__, __FUNCTION__, __LINE__);
798
-
799
-                    return false;
800
-                } else {
801
-                    add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
802
-                    return true;
803
-                }
804
-            }
805
-        } else {
806
-            EE_Error::add_error(
807
-                'Unable to generate the payment notification because the given value for the transaction is invalid.',
808
-                'event_espresso'
809
-            );
810
-            return false;
811
-        }
812
-    }
813
-
814
-
815
-    /**
816
-     * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
817
-     *
818
-     * @since   4.3.0
819
-     * @param  EE_Registration[] $registrations an array of EE_Registration objects
820
-     * @param  int               $grp_id        a specific message template group id.
821
-     * @return void
822
-     * @throws EE_Error
823
-     * @throws InvalidArgumentException
824
-     * @throws InvalidDataTypeException
825
-     * @throws InvalidInterfaceException
826
-     * @throws ReflectionException
827
-     */
828
-    public static function send_newsletter_message($registrations, $grp_id)
829
-    {
830
-        //make sure mtp is id and set it in the EE_Request Handler later messages setup.
831
-        EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id);
832
-        self::_load_controller();
833
-        self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
834
-    }
835
-
836
-
837
-    /**
838
-     * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
839
-     *
840
-     * @since   4.3.0
841
-     * @param    string          $registration_message_trigger_url
842
-     * @param    EE_Registration $registration
843
-     * @param string             $messenger
844
-     * @param string             $message_type
845
-     * @return string
846
-     * @throws EE_Error
847
-     * @throws InvalidArgumentException
848
-     * @throws InvalidDataTypeException
849
-     * @throws InvalidInterfaceException
850
-     */
851
-    public static function registration_message_trigger_url(
852
-        $registration_message_trigger_url,
853
-        EE_Registration $registration,
854
-        $messenger = 'html',
855
-        $message_type = 'invoice'
856
-    ) {
857
-        // whitelist $messenger
858
-        switch ($messenger) {
859
-            case 'pdf' :
860
-                $sending_messenger    = 'pdf';
861
-                $generating_messenger = 'html';
862
-                break;
863
-            case 'html' :
864
-            default :
865
-                $sending_messenger    = 'html';
866
-                $generating_messenger = 'html';
867
-                break;
868
-        }
869
-        // whitelist $message_type
870
-        switch ($message_type) {
871
-            case 'receipt' :
872
-                $message_type = 'receipt';
873
-                break;
874
-            case 'invoice' :
875
-            default :
876
-                $message_type = 'invoice';
877
-                break;
878
-        }
879
-        // verify that both the messenger AND the message type are active
880
-        if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
881
-            //need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
882
-            $template_query_params = array(
883
-                'MTP_is_active'    => true,
884
-                'MTP_messenger'    => $generating_messenger,
885
-                'MTP_message_type' => $message_type,
886
-                'Event.EVT_ID'     => $registration->event_ID(),
887
-            );
888
-            //get the message template group.
889
-            $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
890
-            //if we don't have an EE_Message_Template_Group then return
891
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
892
-                // remove EVT_ID from query params so that global templates get picked up
893
-                unset($template_query_params['Event.EVT_ID']);
894
-                //get global template as the fallback
895
-                $msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
896
-            }
897
-            //if we don't have an EE_Message_Template_Group then return
898
-            if (! $msg_template_group instanceof EE_Message_Template_Group) {
899
-                return '';
900
-            }
901
-            // generate the URL
902
-            $registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
903
-                $sending_messenger,
904
-                $generating_messenger,
905
-                'purchaser',
906
-                $message_type,
907
-                $registration,
908
-                $msg_template_group->ID(),
909
-                $registration->transaction_ID()
910
-            );
911
-
912
-        }
913
-        return $registration_message_trigger_url;
914
-    }
915
-
916
-
917
-    /**
918
-     * Use to generate and return a message preview!
919
-     *
920
-     * @param  string $type      This should correspond with a valid message type
921
-     * @param  string $context   This should correspond with a valid context for the message type
922
-     * @param  string $messenger This should correspond with a valid messenger.
923
-     * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
924
-     *                           preview
925
-     * @return bool|string The body of the message or if send is requested, sends.
926
-     * @throws EE_Error
927
-     * @throws InvalidArgumentException
928
-     * @throws InvalidDataTypeException
929
-     * @throws InvalidInterfaceException
930
-     * @throws ReflectionException
931
-     */
932
-    public static function preview_message($type, $context, $messenger, $send = false)
933
-    {
934
-        self::_load_controller();
935
-        $mtg                     = new EE_Message_To_Generate(
936
-            $messenger,
937
-            $type,
938
-            array(),
939
-            $context,
940
-            true
941
-        );
942
-        $generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
943
-        if ($generated_preview_queue instanceof EE_Messages_Queue) {
944
-            //loop through all content for the preview and remove any persisted records.
945
-            $content = '';
946
-            foreach ($generated_preview_queue->get_message_repository() as $message) {
947
-                $content = $message->content();
948
-                if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) {
949
-                    $message->delete();
950
-                }
951
-            }
952
-            return $content;
953
-        } else {
954
-            return $generated_preview_queue;
955
-        }
956
-    }
957
-
958
-
959
-    /**
960
-     * This is a method that allows for sending a message using a messenger matching the string given and the provided
961
-     * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
962
-     * content found in the EE_Message objects in the queue.
963
-     *
964
-     * @since 4.9.0
965
-     * @param string            $messenger            a string matching a valid active messenger in the system
966
-     * @param string            $message_type         Although it seems contrary to the name of the method, a message
967
-     *                                                type name is still required to send along the message type to the
968
-     *                                                messenger because this is used for determining what specific
969
-     *                                                variations might be loaded for the generated message.
970
-     * @param EE_Messages_Queue $queue
971
-     * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
972
-     *                                                aggregate EE_Message object.
973
-     * @return bool success or fail.
974
-     * @throws EE_Error
975
-     * @throws InvalidArgumentException
976
-     * @throws ReflectionException
977
-     * @throws InvalidDataTypeException
978
-     * @throws InvalidInterfaceException
979
-     */
980
-    public static function send_message_with_messenger_only(
981
-        $messenger,
982
-        $message_type,
983
-        EE_Messages_Queue $queue,
984
-        $custom_subject = ''
985
-    ) {
986
-        self::_load_controller();
987
-        /** @type EE_Message_To_Generate_From_Queue $message_to_generate */
988
-        $message_to_generate = EE_Registry::instance()->load_lib(
989
-            'Message_To_Generate_From_Queue',
990
-            array(
991
-                $messenger,
992
-                $message_type,
993
-                $queue,
994
-                $custom_subject,
995
-            )
996
-        );
997
-        return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
998
-    }
999
-
1000
-
1001
-    /**
1002
-     * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
1003
-     *
1004
-     * @since 4.9.0
1005
-     * @param array $message_ids An array of message ids
1006
-     * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated
1007
-     *                           messages.
1008
-     * @throws EE_Error
1009
-     * @throws InvalidArgumentException
1010
-     * @throws InvalidDataTypeException
1011
-     * @throws InvalidInterfaceException
1012
-     * @throws ReflectionException
1013
-     */
1014
-    public static function generate_now($message_ids)
1015
-    {
1016
-        self::_load_controller();
1017
-        $messages        = EEM_Message::instance()->get_all(
1018
-            array(
1019
-                0 => array(
1020
-                    'MSG_ID' => array('IN', $message_ids),
1021
-                    'STS_ID' => EEM_Message::status_incomplete,
1022
-                ),
1023
-            )
1024
-        );
1025
-        $generated_queue = false;
1026
-        if ($messages) {
1027
-            $generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1028
-        }
1029
-
1030
-        if (! $generated_queue instanceof EE_Messages_Queue) {
1031
-            EE_Error::add_error(
1032
-                __('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
1033
-                    'event_espresso'),
1034
-                __FILE__, __FUNCTION__, __LINE__
1035
-            );
1036
-        }
1037
-        return $generated_queue;
1038
-    }
1039
-
1040
-
1041
-    /**
1042
-     * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
1043
-     * EEM_Message::status_idle
1044
-     *
1045
-     * @since 4.9.0
1046
-     * @param $message_ids
1047
-     * @return bool|EE_Messages_Queue false if no messages sent.
1048
-     * @throws EE_Error
1049
-     * @throws InvalidArgumentException
1050
-     * @throws InvalidDataTypeException
1051
-     * @throws InvalidInterfaceException
1052
-     * @throws ReflectionException
1053
-     */
1054
-    public static function send_now($message_ids)
1055
-    {
1056
-        self::_load_controller();
1057
-        $messages   = EEM_Message::instance()->get_all(
1058
-            array(
1059
-                0 => array(
1060
-                    'MSG_ID' => array('IN', $message_ids),
1061
-                    'STS_ID' => array(
1062
-                        'IN',
1063
-                        array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
1064
-                    ),
1065
-                ),
1066
-            )
1067
-        );
1068
-        $sent_queue = false;
1069
-        if ($messages) {
1070
-            $sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1071
-        }
1072
-
1073
-        if (! $sent_queue instanceof EE_Messages_Queue) {
1074
-            EE_Error::add_error(
1075
-                __('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
1076
-                    'event_espresso'),
1077
-                __FILE__, __FUNCTION__, __LINE__
1078
-            );
1079
-        } else {
1080
-            //can count how many sent by using the messages in the queue
1081
-            $sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
1082
-            if ($sent_count > 0) {
1083
-                EE_Error::add_success(
1084
-                    sprintf(
1085
-                        _n(
1086
-                            'There was %d message successfully sent.',
1087
-                            'There were %d messages successfully sent.',
1088
-                            $sent_count,
1089
-                            'event_espresso'
1090
-                        ),
1091
-                        $sent_count
1092
-                    )
1093
-                );
1094
-            } else {
1095
-                EE_Error::overwrite_errors();
1096
-                EE_Error::add_error(
1097
-                    __('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
215
+				exit;
216
+			}
217
+		}
218
+		return;
219
+	}
220
+
221
+
222
+	/**
223
+	 *  This runs when the msg_url_trigger route has initiated.
224
+	 *
225
+	 * @since 4.5.0
226
+	 * @param WP $WP
227
+	 * @throws EE_Error
228
+	 * @throws InvalidArgumentException
229
+	 * @throws ReflectionException
230
+	 * @throws InvalidDataTypeException
231
+	 * @throws InvalidInterfaceException
232
+	 */
233
+	public function run($WP)
234
+	{
235
+		//ensure controller is loaded
236
+		self::_load_controller();
237
+		// attempt to process message
238
+		try {
239
+			/** @type EE_Message_To_Generate_From_Request $message_to_generate */
240
+			$message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
241
+			self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
242
+		} catch (EE_Error $e) {
243
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.',
244
+				'event_espresso');
245
+			// add specific message for developers if WP_DEBUG in on
246
+			$error_msg .= '||' . $e->getMessage();
247
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
248
+		}
249
+	}
250
+
251
+
252
+	/**
253
+	 * This is triggered by the 'msg_cron_trigger' route.
254
+	 *
255
+	 * @param WP $WP
256
+	 */
257
+	public function execute_batch_request($WP)
258
+	{
259
+		$this->run_cron();
260
+		header('HTTP/1.1 200 OK');
261
+		exit();
262
+	}
263
+
264
+
265
+	/**
266
+	 * This gets executed on wp_cron jobs or when a batch request is initiated on its own separate non regular wp
267
+	 * request.
268
+	 */
269
+	public function run_cron()
270
+	{
271
+		self::_load_controller();
272
+		//get required vars
273
+		$cron_type     = EE_Registry::instance()->REQ->get('type');
274
+		$transient_key = EE_Registry::instance()->REQ->get('key');
275
+
276
+		//now let's verify transient, if not valid exit immediately
277
+		if (! get_transient($transient_key)) {
278
+			/**
279
+			 * trigger error so this gets in the error logs.  This is important because it happens on a non-user
280
+			 * request.
281
+			 */
282
+			trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
283
+		}
284
+
285
+		//if made it here, lets' delete the transient to keep the db clean
286
+		delete_transient($transient_key);
287
+
288
+		if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
289
+
290
+			$method = 'batch_' . $cron_type . '_from_queue';
291
+			if (method_exists(self::$_MSG_PROCESSOR, $method)) {
292
+				self::$_MSG_PROCESSOR->$method();
293
+			} else {
294
+				//no matching task
295
+				/**
296
+				 * trigger error so this gets in the error logs.  This is important because it happens on a non user
297
+				 * request.
298
+				 */
299
+				trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'),
300
+					$cron_type)));
301
+			}
302
+		}
303
+
304
+		do_action('FHEE__EED_Messages__run_cron__end');
305
+	}
306
+
307
+
308
+	/**
309
+	 * This is used to retrieve the template pack for the given name.
310
+	 * Retrieved packs are cached on the static $_TMP_PACKS array.  If there is no class matching the given name then
311
+	 * the default template pack is returned.
312
+	 *
313
+	 * @deprecated 4.9.0  @see EEH_MSG_Template::get_template_pack()
314
+	 * @param string $template_pack_name This should correspond to the dbref of the template pack (which is also used
315
+	 *                                   in generating the Pack class name).
316
+	 * @return EE_Messages_Template_Pack
317
+	 * @throws EE_Error
318
+	 * @throws InvalidArgumentException
319
+	 * @throws ReflectionException
320
+	 * @throws InvalidDataTypeException
321
+	 * @throws InvalidInterfaceException
322
+	 */
323
+	public static function get_template_pack($template_pack_name)
324
+	{
325
+		EE_Registry::instance()->load_helper('MSG_Template');
326
+		return EEH_MSG_Template::get_template_pack($template_pack_name);
327
+	}
328
+
329
+
330
+	/**
331
+	 * Retrieves an array of all template packs.
332
+	 * Array is in the format array( 'dbref' => EE_Messages_Template_Pack )
333
+	 *
334
+	 * @deprecated 4.9.0  @see EEH_MSG_Template_Pack::get_template_pack_collection
335
+	 * @return EE_Messages_Template_Pack[]
336
+	 * @throws EE_Error
337
+	 * @throws InvalidArgumentException
338
+	 * @throws ReflectionException
339
+	 * @throws InvalidDataTypeException
340
+	 * @throws InvalidInterfaceException
341
+	 */
342
+	public static function get_template_packs()
343
+	{
344
+		EE_Registry::instance()->load_helper('MSG_Template');
345
+
346
+		//for backward compat, let's make sure this returns in the same format as originally.
347
+		$template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
348
+		$template_pack_collection->rewind();
349
+		$template_packs = array();
350
+		while ($template_pack_collection->valid()) {
351
+			$template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
352
+			$template_pack_collection->next();
353
+		}
354
+		return $template_packs;
355
+	}
356
+
357
+
358
+	/**
359
+	 * This simply makes sure the autoloaders are registered for the EE_messages system.
360
+	 *
361
+	 * @since 4.5.0
362
+	 * @return void
363
+	 * @throws EE_Error
364
+	 */
365
+	public static function set_autoloaders()
366
+	{
367
+		if (empty(self::$_MSG_PATHS)) {
368
+			self::_set_messages_paths();
369
+			foreach (self::$_MSG_PATHS as $path) {
370
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
371
+			}
372
+			// add aliases
373
+			EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
374
+			EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
375
+		}
376
+	}
377
+
378
+
379
+	/**
380
+	 * Take care of adding all the paths for the messages components to the $_MSG_PATHS property
381
+	 * for use by the Messages Autoloaders
382
+	 *
383
+	 * @since 4.5.0
384
+	 * @return void.
385
+	 */
386
+	protected static function _set_messages_paths()
387
+	{
388
+		$dir_ref = array(
389
+			'messages/message_type',
390
+			'messages/messenger',
391
+			'messages/defaults',
392
+			'messages/defaults/email',
393
+			'messages/data_class',
394
+			'messages/validators',
395
+			'messages/validators/email',
396
+			'messages/validators/html',
397
+			'shortcodes',
398
+		);
399
+		$paths   = array();
400
+		foreach ($dir_ref as $index => $dir) {
401
+			$paths[$index] = EE_LIBRARIES . $dir;
402
+		}
403
+		self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
404
+	}
405
+
406
+
407
+	/**
408
+	 * Takes care of loading dependencies
409
+	 *
410
+	 * @since 4.5.0
411
+	 * @return void
412
+	 * @throws EE_Error
413
+	 * @throws InvalidArgumentException
414
+	 * @throws ReflectionException
415
+	 * @throws InvalidDataTypeException
416
+	 * @throws InvalidInterfaceException
417
+	 */
418
+	protected static function _load_controller()
419
+	{
420
+		if (! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
421
+			EE_Registry::instance()->load_core('Request_Handler');
422
+			self::set_autoloaders();
423
+			self::$_EEMSG                    = EE_Registry::instance()->load_lib('messages');
424
+			self::$_MSG_PROCESSOR            = EE_Registry::instance()->load_lib('Messages_Processor');
425
+			self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
426
+		}
427
+	}
428
+
429
+
430
+	/**
431
+	 * @param EE_Transaction $transaction
432
+	 * @throws EE_Error
433
+	 * @throws InvalidArgumentException
434
+	 * @throws InvalidDataTypeException
435
+	 * @throws InvalidInterfaceException
436
+	 * @throws ReflectionException
437
+	 */
438
+	public static function payment_reminder(EE_Transaction $transaction)
439
+	{
440
+		self::_load_controller();
441
+		$data = array($transaction, null);
442
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
443
+	}
444
+
445
+
446
+	/**
447
+	 * Any messages triggers for after successful gateway payments should go in here.
448
+	 *
449
+	 * @param EE_Transaction $transaction object
450
+	 * @param EE_Payment     $payment     object
451
+	 * @return void
452
+	 * @throws EE_Error
453
+	 * @throws InvalidArgumentException
454
+	 * @throws ReflectionException
455
+	 * @throws InvalidDataTypeException
456
+	 * @throws InvalidInterfaceException
457
+	 */
458
+	public static function payment(EE_Transaction $transaction, EE_Payment $payment)
459
+	{
460
+		self::_load_controller();
461
+		$data = array($transaction, $payment);
462
+		EE_Registry::instance()->load_helper('MSG_Template');
463
+		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
464
+		//if payment amount is less than 0 then switch to payment_refund message type.
465
+		$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
466
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
467
+	}
468
+
469
+
470
+	/**
471
+	 * @param EE_Transaction $transaction
472
+	 * @throws EE_Error
473
+	 * @throws InvalidArgumentException
474
+	 * @throws InvalidDataTypeException
475
+	 * @throws InvalidInterfaceException
476
+	 * @throws ReflectionException
477
+	 */
478
+	public static function cancelled_registration(EE_Transaction $transaction)
479
+	{
480
+		self::_load_controller();
481
+		$data = array($transaction, null);
482
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
483
+	}
484
+
485
+
486
+
487
+	/**
488
+	 * Trigger for Registration messages
489
+	 * Note that what registration message type is sent depends on what the reg status is for the registrations on the
490
+	 * incoming transaction.
491
+	 *
492
+	 * @param EE_Registration $registration
493
+	 * @param array           $extra_details
494
+	 * @return void
495
+	 * @throws EE_Error
496
+	 * @throws InvalidArgumentException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 * @throws ReflectionException
500
+	 * @throws EntityNotFoundException
501
+	 */
502
+	public static function maybe_registration(EE_Registration $registration, $extra_details = array())
503
+	{
504
+
505
+		if (! self::_verify_registration_notification_send($registration, $extra_details)) {
506
+			//no messages please
507
+			return;
508
+		}
509
+
510
+		// get all non-trashed registrations so we make sure we send messages for the right status.
511
+		$all_registrations = $registration->transaction()->registrations(
512
+			array(
513
+				array('REG_deleted' => false),
514
+				'order_by' => array(
515
+					'Event.EVT_name'     => 'ASC',
516
+					'Attendee.ATT_lname' => 'ASC',
517
+					'Attendee.ATT_fname' => 'ASC'
518
+				)
519
+			)
520
+		);
521
+		//cached array of statuses so we only trigger messages once per status.
522
+		$statuses_sent = array();
523
+		self::_load_controller();
524
+		$mtgs = array();
525
+
526
+		//loop through registrations and trigger messages once per status.
527
+		foreach ($all_registrations as $reg) {
528
+
529
+			//already triggered?
530
+			if (in_array($reg->status_ID(), $statuses_sent)) {
531
+				continue;
532
+			}
533
+
534
+			$message_type    = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
535
+			$mtgs            = array_merge(
536
+					$mtgs,
537
+					self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
538
+							$message_type,
539
+							array($registration->transaction(), null, $reg->status_ID())
540
+					)
541
+			);
542
+			$statuses_sent[] = $reg->status_ID();
543
+		}
544
+
545
+		if (count($statuses_sent) > 1) {
546
+			$mtgs = array_merge(
547
+				$mtgs,
548
+				self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers(
549
+					'registration_summary',
550
+					array($registration->transaction(), null)
551
+				)
552
+			);
553
+		}
554
+
555
+		//batch queue and initiate request
556
+		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
557
+		self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
558
+	}
559
+
560
+
561
+	/**
562
+	 * This is a helper method used to very whether a registration notification should be sent or
563
+	 * not.  Prevents duplicate notifications going out for registration context notifications.
564
+	 *
565
+	 * @param EE_Registration $registration  [description]
566
+	 * @param array           $extra_details [description]
567
+	 * @return bool          true = send away, false = nope halt the presses.
568
+	 */
569
+	protected static function _verify_registration_notification_send(
570
+		EE_Registration $registration,
571
+		$extra_details = array()
572
+	) {
573
+		//self::log(
574
+		//	__CLASS__, __FUNCTION__, __LINE__,
575
+		//	$registration->transaction(),
576
+		//	array( '$extra_details' => $extra_details )
577
+		//);
578
+		// currently only using this to send messages for the primary registrant
579
+		if (! $registration->is_primary_registrant()) {
580
+			return false;
581
+		}
582
+		// first we check if we're in admin and not doing front ajax
583
+		if (is_admin() && ! EE_FRONT_AJAX) {
584
+			//make sure appropriate admin params are set for sending messages
585
+			if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) {
586
+				//no messages sent please.
587
+				return false;
588
+			}
589
+		} else {
590
+			// frontend request (either regular or via AJAX)
591
+			// TXN is NOT finalized ?
592
+			if (! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
593
+				return false;
594
+			}
595
+			// return visit but nothing changed ???
596
+			if (
597
+				isset($extra_details['revisit'], $extra_details['status_updates']) &&
598
+				$extra_details['revisit'] && ! $extra_details['status_updates']
599
+			) {
600
+				return false;
601
+			}
602
+			// NOT sending messages && reg status is something other than "Not-Approved"
603
+			if (
604
+				! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
605
+				$registration->status_ID() !== EEM_Registration::status_id_not_approved
606
+			) {
607
+				return false;
608
+			}
609
+		}
610
+		// release the kraken
611
+		return true;
612
+	}
613
+
614
+
615
+	/**
616
+	 * Simply returns an array indexed by Registration Status ID and the related message_type name associated with that
617
+	 * status id.
618
+	 *
619
+	 * @deprecated 4.9.0  Use EEH_MSG_Template::reg_status_to_message_type_array()
620
+	 *                    or EEH_MSG_Template::convert_reg_status_to_message_type
621
+	 * @param string $reg_status
622
+	 * @return array
623
+	 * @throws EE_Error
624
+	 * @throws InvalidArgumentException
625
+	 * @throws ReflectionException
626
+	 * @throws InvalidDataTypeException
627
+	 * @throws InvalidInterfaceException
628
+	 */
629
+	protected static function _get_reg_status_array($reg_status = '')
630
+	{
631
+		EE_Registry::instance()->load_helper('MSG_Template');
632
+		return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
633
+			? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
634
+			: EEH_MSG_Template::reg_status_to_message_type_array();
635
+	}
636
+
637
+
638
+	/**
639
+	 * Simply returns the payment message type for the given payment status.
640
+	 *
641
+	 * @deprecated 4.9.0 Use EEH_MSG_Template::payment_status_to_message_type_array
642
+	 *                   or EEH_MSG_Template::convert_payment_status_to_message_type
643
+	 * @param string $payment_status The payment status being matched.
644
+	 * @return bool|string The payment message type slug matching the status or false if no match.
645
+	 * @throws EE_Error
646
+	 * @throws InvalidArgumentException
647
+	 * @throws ReflectionException
648
+	 * @throws InvalidDataTypeException
649
+	 * @throws InvalidInterfaceException
650
+	 */
651
+	protected static function _get_payment_message_type($payment_status)
652
+	{
653
+		EE_Registry::instance()->load_helper('MSG_Template');
654
+		return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
655
+			? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
656
+			: false;
657
+	}
658
+
659
+
660
+	/**
661
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
662
+	 *
663
+	 * @access public
664
+	 * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
665
+	 * @return bool success/fail
666
+	 * @throws EE_Error
667
+	 * @throws InvalidArgumentException
668
+	 * @throws InvalidDataTypeException
669
+	 * @throws InvalidInterfaceException
670
+	 * @throws ReflectionException
671
+	 */
672
+	public static function process_resend($req_data)
673
+	{
674
+		self::_load_controller();
675
+
676
+		//if $msgID in this request then skip to the new resend_message
677
+		if (EE_Registry::instance()->REQ->get('MSG_ID')) {
678
+			return self::resend_message();
679
+		}
680
+
681
+		//make sure any incoming request data is set on the REQ so that it gets picked up later.
682
+		$req_data = (array)$req_data;
683
+		foreach ($req_data as $request_key => $request_value) {
684
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
685
+		}
686
+
687
+		if (! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
688
+			return false;
689
+		}
690
+
691
+		try {
692
+			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
693
+			self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
694
+		} catch (EE_Error $e) {
695
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
696
+			return false;
697
+		}
698
+		EE_Error::add_success(
699
+			__('Messages have been successfully queued for generation and sending.', 'event_espresso')
700
+		);
701
+		return true; //everything got queued.
702
+	}
703
+
704
+
705
+	/**
706
+	 * Message triggers for a resending already sent message(s) (via EE_Message list table)
707
+	 *
708
+	 * @return bool
709
+	 * @throws EE_Error
710
+	 * @throws InvalidArgumentException
711
+	 * @throws InvalidDataTypeException
712
+	 * @throws InvalidInterfaceException
713
+	 * @throws ReflectionException
714
+	 */
715
+	public static function resend_message()
716
+	{
717
+		self::_load_controller();
718
+
719
+		$msgID = EE_Registry::instance()->REQ->get('MSG_ID');
720
+		if (! $msgID) {
721
+			EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request',
722
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
723
+			return false;
724
+		}
725
+
726
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array)$msgID);
727
+
728
+		//setup success message.
729
+		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
730
+		EE_Error::add_success(sprintf(
731
+			_n(
732
+				'There was %d message queued for resending.',
733
+				'There were %d messages queued for resending.',
734
+				$count_ready_for_resend,
735
+				'event_espresso'
736
+			),
737
+			$count_ready_for_resend
738
+		));
739
+		return true;
740
+	}
741
+
742
+
743
+	/**
744
+	 * Message triggers for manual payment applied by admin
745
+	 *
746
+	 * @param  EE_Payment $payment EE_payment object
747
+	 * @return bool success/fail
748
+	 * @throws EE_Error
749
+	 * @throws InvalidArgumentException
750
+	 * @throws ReflectionException
751
+	 * @throws InvalidDataTypeException
752
+	 * @throws InvalidInterfaceException
753
+	 */
754
+	public static function process_admin_payment(EE_Payment $payment)
755
+	{
756
+		EE_Registry::instance()->load_helper('MSG_Template');
757
+		//we need to get the transaction object
758
+		$transaction = $payment->transaction();
759
+		if ($transaction instanceof EE_Transaction) {
760
+			$data         = array($transaction, $payment);
761
+			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
762
+
763
+			//if payment amount is less than 0 then switch to payment_refund message type.
764
+			$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
765
+
766
+			//if payment_refund is selected, but the status is NOT accepted.  Then change message type to false so NO message notification goes out.
767
+			$message_type = $message_type == 'payment_refund' && $payment->STS_ID() != EEM_Payment::status_id_approved ? false : $message_type;
768
+
769
+			self::_load_controller();
770
+
771
+			self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
772
+
773
+			//get count of queued for generation
774
+			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(
775
+				EEM_Message::status_incomplete,
776
+				EEM_Message::status_idle,
777
+			));
778
+
779
+			if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
780
+				add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
781
+				return true;
782
+			} else {
783
+				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending());
784
+				/**
785
+				 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
786
+				 * IMMEDIATE generation.
787
+				 */
788
+				if ($count_failed > 0) {
789
+					EE_Error::add_error(sprintf(
790
+						_n(
791
+							'The payment notification generation failed.',
792
+							'%d payment notifications failed being sent.',
793
+							$count_failed,
794
+							'event_espresso'
795
+						),
796
+						$count_failed
797
+					), __FILE__, __FUNCTION__, __LINE__);
798
+
799
+					return false;
800
+				} else {
801
+					add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
802
+					return true;
803
+				}
804
+			}
805
+		} else {
806
+			EE_Error::add_error(
807
+				'Unable to generate the payment notification because the given value for the transaction is invalid.',
808
+				'event_espresso'
809
+			);
810
+			return false;
811
+		}
812
+	}
813
+
814
+
815
+	/**
816
+	 * Callback for AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send_with_registrations trigger
817
+	 *
818
+	 * @since   4.3.0
819
+	 * @param  EE_Registration[] $registrations an array of EE_Registration objects
820
+	 * @param  int               $grp_id        a specific message template group id.
821
+	 * @return void
822
+	 * @throws EE_Error
823
+	 * @throws InvalidArgumentException
824
+	 * @throws InvalidDataTypeException
825
+	 * @throws InvalidInterfaceException
826
+	 * @throws ReflectionException
827
+	 */
828
+	public static function send_newsletter_message($registrations, $grp_id)
829
+	{
830
+		//make sure mtp is id and set it in the EE_Request Handler later messages setup.
831
+		EE_Registry::instance()->REQ->set('GRP_ID', (int)$grp_id);
832
+		self::_load_controller();
833
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
834
+	}
835
+
836
+
837
+	/**
838
+	 * Callback for FHEE__EE_Registration__invoice_url__invoice_url or FHEE__EE_Registration__receipt_url__receipt_url
839
+	 *
840
+	 * @since   4.3.0
841
+	 * @param    string          $registration_message_trigger_url
842
+	 * @param    EE_Registration $registration
843
+	 * @param string             $messenger
844
+	 * @param string             $message_type
845
+	 * @return string
846
+	 * @throws EE_Error
847
+	 * @throws InvalidArgumentException
848
+	 * @throws InvalidDataTypeException
849
+	 * @throws InvalidInterfaceException
850
+	 */
851
+	public static function registration_message_trigger_url(
852
+		$registration_message_trigger_url,
853
+		EE_Registration $registration,
854
+		$messenger = 'html',
855
+		$message_type = 'invoice'
856
+	) {
857
+		// whitelist $messenger
858
+		switch ($messenger) {
859
+			case 'pdf' :
860
+				$sending_messenger    = 'pdf';
861
+				$generating_messenger = 'html';
862
+				break;
863
+			case 'html' :
864
+			default :
865
+				$sending_messenger    = 'html';
866
+				$generating_messenger = 'html';
867
+				break;
868
+		}
869
+		// whitelist $message_type
870
+		switch ($message_type) {
871
+			case 'receipt' :
872
+				$message_type = 'receipt';
873
+				break;
874
+			case 'invoice' :
875
+			default :
876
+				$message_type = 'invoice';
877
+				break;
878
+		}
879
+		// verify that both the messenger AND the message type are active
880
+		if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
881
+			//need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
882
+			$template_query_params = array(
883
+				'MTP_is_active'    => true,
884
+				'MTP_messenger'    => $generating_messenger,
885
+				'MTP_message_type' => $message_type,
886
+				'Event.EVT_ID'     => $registration->event_ID(),
887
+			);
888
+			//get the message template group.
889
+			$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
890
+			//if we don't have an EE_Message_Template_Group then return
891
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
892
+				// remove EVT_ID from query params so that global templates get picked up
893
+				unset($template_query_params['Event.EVT_ID']);
894
+				//get global template as the fallback
895
+				$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
896
+			}
897
+			//if we don't have an EE_Message_Template_Group then return
898
+			if (! $msg_template_group instanceof EE_Message_Template_Group) {
899
+				return '';
900
+			}
901
+			// generate the URL
902
+			$registration_message_trigger_url = EEH_MSG_Template::generate_url_trigger(
903
+				$sending_messenger,
904
+				$generating_messenger,
905
+				'purchaser',
906
+				$message_type,
907
+				$registration,
908
+				$msg_template_group->ID(),
909
+				$registration->transaction_ID()
910
+			);
911
+
912
+		}
913
+		return $registration_message_trigger_url;
914
+	}
915
+
916
+
917
+	/**
918
+	 * Use to generate and return a message preview!
919
+	 *
920
+	 * @param  string $type      This should correspond with a valid message type
921
+	 * @param  string $context   This should correspond with a valid context for the message type
922
+	 * @param  string $messenger This should correspond with a valid messenger.
923
+	 * @param bool    $send      true we will do a test send using the messenger delivery, false we just do a regular
924
+	 *                           preview
925
+	 * @return bool|string The body of the message or if send is requested, sends.
926
+	 * @throws EE_Error
927
+	 * @throws InvalidArgumentException
928
+	 * @throws InvalidDataTypeException
929
+	 * @throws InvalidInterfaceException
930
+	 * @throws ReflectionException
931
+	 */
932
+	public static function preview_message($type, $context, $messenger, $send = false)
933
+	{
934
+		self::_load_controller();
935
+		$mtg                     = new EE_Message_To_Generate(
936
+			$messenger,
937
+			$type,
938
+			array(),
939
+			$context,
940
+			true
941
+		);
942
+		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
943
+		if ($generated_preview_queue instanceof EE_Messages_Queue) {
944
+			//loop through all content for the preview and remove any persisted records.
945
+			$content = '';
946
+			foreach ($generated_preview_queue->get_message_repository() as $message) {
947
+				$content = $message->content();
948
+				if ($message->ID() > 0 && $message->STS_ID() !== EEM_Message::status_failed) {
949
+					$message->delete();
950
+				}
951
+			}
952
+			return $content;
953
+		} else {
954
+			return $generated_preview_queue;
955
+		}
956
+	}
957
+
958
+
959
+	/**
960
+	 * This is a method that allows for sending a message using a messenger matching the string given and the provided
961
+	 * EE_Message_Queue object.  The EE_Message_Queue object is used to create a single aggregate EE_Message via the
962
+	 * content found in the EE_Message objects in the queue.
963
+	 *
964
+	 * @since 4.9.0
965
+	 * @param string            $messenger            a string matching a valid active messenger in the system
966
+	 * @param string            $message_type         Although it seems contrary to the name of the method, a message
967
+	 *                                                type name is still required to send along the message type to the
968
+	 *                                                messenger because this is used for determining what specific
969
+	 *                                                variations might be loaded for the generated message.
970
+	 * @param EE_Messages_Queue $queue
971
+	 * @param string            $custom_subject       Can be used to set what the custom subject string will be on the
972
+	 *                                                aggregate EE_Message object.
973
+	 * @return bool success or fail.
974
+	 * @throws EE_Error
975
+	 * @throws InvalidArgumentException
976
+	 * @throws ReflectionException
977
+	 * @throws InvalidDataTypeException
978
+	 * @throws InvalidInterfaceException
979
+	 */
980
+	public static function send_message_with_messenger_only(
981
+		$messenger,
982
+		$message_type,
983
+		EE_Messages_Queue $queue,
984
+		$custom_subject = ''
985
+	) {
986
+		self::_load_controller();
987
+		/** @type EE_Message_To_Generate_From_Queue $message_to_generate */
988
+		$message_to_generate = EE_Registry::instance()->load_lib(
989
+			'Message_To_Generate_From_Queue',
990
+			array(
991
+				$messenger,
992
+				$message_type,
993
+				$queue,
994
+				$custom_subject,
995
+			)
996
+		);
997
+		return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
998
+	}
999
+
1000
+
1001
+	/**
1002
+	 * Generates Messages immediately for EE_Message IDs (but only for the correct status for generation)
1003
+	 *
1004
+	 * @since 4.9.0
1005
+	 * @param array $message_ids An array of message ids
1006
+	 * @return bool|EE_Messages_Queue false if nothing was generated, EE_Messages_Queue containing generated
1007
+	 *                           messages.
1008
+	 * @throws EE_Error
1009
+	 * @throws InvalidArgumentException
1010
+	 * @throws InvalidDataTypeException
1011
+	 * @throws InvalidInterfaceException
1012
+	 * @throws ReflectionException
1013
+	 */
1014
+	public static function generate_now($message_ids)
1015
+	{
1016
+		self::_load_controller();
1017
+		$messages        = EEM_Message::instance()->get_all(
1018
+			array(
1019
+				0 => array(
1020
+					'MSG_ID' => array('IN', $message_ids),
1021
+					'STS_ID' => EEM_Message::status_incomplete,
1022
+				),
1023
+			)
1024
+		);
1025
+		$generated_queue = false;
1026
+		if ($messages) {
1027
+			$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
1028
+		}
1029
+
1030
+		if (! $generated_queue instanceof EE_Messages_Queue) {
1031
+			EE_Error::add_error(
1032
+				__('The messages were not generated. This could mean there is already a batch being generated on a separate request, or because the selected messages are not ready for generation. Please wait a minute or two and try again.',
1033
+					'event_espresso'),
1034
+				__FILE__, __FUNCTION__, __LINE__
1035
+			);
1036
+		}
1037
+		return $generated_queue;
1038
+	}
1039
+
1040
+
1041
+	/**
1042
+	 * Sends messages immediately for the incoming message_ids that have the status of EEM_Message::status_resend or,
1043
+	 * EEM_Message::status_idle
1044
+	 *
1045
+	 * @since 4.9.0
1046
+	 * @param $message_ids
1047
+	 * @return bool|EE_Messages_Queue false if no messages sent.
1048
+	 * @throws EE_Error
1049
+	 * @throws InvalidArgumentException
1050
+	 * @throws InvalidDataTypeException
1051
+	 * @throws InvalidInterfaceException
1052
+	 * @throws ReflectionException
1053
+	 */
1054
+	public static function send_now($message_ids)
1055
+	{
1056
+		self::_load_controller();
1057
+		$messages   = EEM_Message::instance()->get_all(
1058
+			array(
1059
+				0 => array(
1060
+					'MSG_ID' => array('IN', $message_ids),
1061
+					'STS_ID' => array(
1062
+						'IN',
1063
+						array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry),
1064
+					),
1065
+				),
1066
+			)
1067
+		);
1068
+		$sent_queue = false;
1069
+		if ($messages) {
1070
+			$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
1071
+		}
1072
+
1073
+		if (! $sent_queue instanceof EE_Messages_Queue) {
1074
+			EE_Error::add_error(
1075
+				__('The messages were not sent. This could mean there is already a batch being sent on a separate request, or because the selected messages are not sendable. Please wait a minute or two and try again.',
1076
+					'event_espresso'),
1077
+				__FILE__, __FUNCTION__, __LINE__
1078
+			);
1079
+		} else {
1080
+			//can count how many sent by using the messages in the queue
1081
+			$sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
1082
+			if ($sent_count > 0) {
1083
+				EE_Error::add_success(
1084
+					sprintf(
1085
+						_n(
1086
+							'There was %d message successfully sent.',
1087
+							'There were %d messages successfully sent.',
1088
+							$sent_count,
1089
+							'event_espresso'
1090
+						),
1091
+						$sent_count
1092
+					)
1093
+				);
1094
+			} else {
1095
+				EE_Error::overwrite_errors();
1096
+				EE_Error::add_error(
1097
+					__('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
1098 1098
 					If there was an error, you can look at the messages in the message activity list table for any error messages.',
1099
-                        'event_espresso'),
1100
-                    __FILE__, __FUNCTION__, __LINE__
1101
-                );
1102
-            }
1103
-        }
1104
-        return $sent_queue;
1105
-    }
1106
-
1107
-
1108
-    /**
1109
-     * Generate and send immediately from the given $message_ids
1110
-     *
1111
-     * @param array $message_ids EE_Message entity ids.
1112
-     * @throws EE_Error
1113
-     * @throws InvalidArgumentException
1114
-     * @throws InvalidDataTypeException
1115
-     * @throws InvalidInterfaceException
1116
-     * @throws ReflectionException
1117
-     */
1118
-    public static function generate_and_send_now(array $message_ids)
1119
-    {
1120
-        $generated_queue = self::generate_now($message_ids);
1121
-        //now let's just trigger sending immediately from this queue.
1122
-        $messages_sent = $generated_queue instanceof EE_Messages_Queue
1123
-            ? $generated_queue->execute()
1124
-            : 0;
1125
-        if ($messages_sent) {
1126
-            EE_Error::add_success(
1127
-                esc_html(
1128
-                    sprintf(
1129
-                        _n(
1130
-                            'There was %d message successfully generated and sent.',
1131
-                            'There were %d messages successfully generated and sent.',
1132
-                            $messages_sent,
1133
-                            'event_espresso'
1134
-                        ),
1135
-                        $messages_sent
1136
-                    )
1137
-                )
1138
-            );
1139
-            //errors would be added via the generate_now method.
1140
-        }
1141
-    }
1142
-
1143
-
1144
-    /**
1145
-     * This will queue the incoming message ids for resending.
1146
-     * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
1147
-     *
1148
-     * @since 4.9.0
1149
-     * @param array $message_ids An array of EE_Message IDs
1150
-     * @return bool true means messages were successfully queued for resending, false means none were queued for
1151
-     *                           resending.
1152
-     * @throws EE_Error
1153
-     * @throws InvalidArgumentException
1154
-     * @throws InvalidDataTypeException
1155
-     * @throws InvalidInterfaceException
1156
-     * @throws ReflectionException
1157
-     */
1158
-    public static function queue_for_resending($message_ids)
1159
-    {
1160
-        self::_load_controller();
1161
-        self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
1162
-
1163
-        //get queue and count
1164
-        $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
1165
-
1166
-        if (
1167
-            $queue_count > 0
1168
-        ) {
1169
-            EE_Error::add_success(
1170
-                sprintf(
1171
-                    _n(
1172
-                        '%d message successfully queued for resending.',
1173
-                        '%d messages successfully queued for resending.',
1174
-                        $queue_count,
1175
-                        'event_espresso'
1176
-                    ),
1177
-                    $queue_count
1178
-                )
1179
-            );
1180
-            /**
1181
-             * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1182
-             */
1183
-        } elseif (
1184
-            apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1185
-            || EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1186
-        ) {
1187
-            $queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1188
-            if ($queue_count > 0) {
1189
-                EE_Error::add_success(
1190
-                    sprintf(
1191
-                        _n(
1192
-                            '%d message successfully sent.',
1193
-                            '%d messages successfully sent.',
1194
-                            $queue_count,
1195
-                            'event_espresso'
1196
-                        ),
1197
-                        $queue_count
1198
-                    )
1199
-                );
1200
-            } else {
1201
-                EE_Error::add_error(
1202
-                    __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1203
-                        'event_espresso'),
1204
-                    __FILE__, __FUNCTION__, __LINE__
1205
-                );
1206
-            }
1207
-        } else {
1208
-            EE_Error::add_error(
1209
-                __('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1210
-                    'event_espresso'),
1211
-                __FILE__, __FUNCTION__, __LINE__
1212
-            );
1213
-        }
1214
-        return (bool)$queue_count;
1215
-    }
1216
-
1217
-
1218
-    /**
1219
-     * debug
1220
-     *
1221
-     * @param string          $class
1222
-     * @param string          $func
1223
-     * @param string          $line
1224
-     * @param \EE_Transaction $transaction
1225
-     * @param array           $info
1226
-     * @param bool            $display_request
1227
-     * @throws EE_Error
1228
-     * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
1229
-     */
1230
-    protected static function log(
1231
-        $class = '',
1232
-        $func = '',
1233
-        $line = '',
1234
-        EE_Transaction $transaction,
1235
-        $info = array(),
1236
-        $display_request = false
1237
-    ) {
1238
-        if (defined('EE_DEBUG') && EE_DEBUG) {
1239
-            if ($transaction instanceof EE_Transaction) {
1240
-                // don't serialize objects
1241
-                $info                  = EEH_Debug_Tools::strip_objects($info);
1242
-                $info['TXN_status']    = $transaction->status_ID();
1243
-                $info['TXN_reg_steps'] = $transaction->reg_steps();
1244
-                if ($transaction->ID()) {
1245
-                    $index = 'EE_Transaction: ' . $transaction->ID();
1246
-                    EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1247
-                }
1248
-            }
1249
-        }
1250
-
1251
-    }
1252
-
1253
-
1254
-    /**
1255
-     *  Resets all the static properties in this class when called.
1256
-     */
1257
-    public static function reset()
1258
-    {
1259
-        self::$_EEMSG                    = null;
1260
-        self::$_message_resource_manager = null;
1261
-        self::$_MSG_PROCESSOR            = null;
1262
-        self::$_MSG_PATHS                = null;
1263
-        self::$_TMP_PACKS                = array();
1264
-    }
1099
+						'event_espresso'),
1100
+					__FILE__, __FUNCTION__, __LINE__
1101
+				);
1102
+			}
1103
+		}
1104
+		return $sent_queue;
1105
+	}
1106
+
1107
+
1108
+	/**
1109
+	 * Generate and send immediately from the given $message_ids
1110
+	 *
1111
+	 * @param array $message_ids EE_Message entity ids.
1112
+	 * @throws EE_Error
1113
+	 * @throws InvalidArgumentException
1114
+	 * @throws InvalidDataTypeException
1115
+	 * @throws InvalidInterfaceException
1116
+	 * @throws ReflectionException
1117
+	 */
1118
+	public static function generate_and_send_now(array $message_ids)
1119
+	{
1120
+		$generated_queue = self::generate_now($message_ids);
1121
+		//now let's just trigger sending immediately from this queue.
1122
+		$messages_sent = $generated_queue instanceof EE_Messages_Queue
1123
+			? $generated_queue->execute()
1124
+			: 0;
1125
+		if ($messages_sent) {
1126
+			EE_Error::add_success(
1127
+				esc_html(
1128
+					sprintf(
1129
+						_n(
1130
+							'There was %d message successfully generated and sent.',
1131
+							'There were %d messages successfully generated and sent.',
1132
+							$messages_sent,
1133
+							'event_espresso'
1134
+						),
1135
+						$messages_sent
1136
+					)
1137
+				)
1138
+			);
1139
+			//errors would be added via the generate_now method.
1140
+		}
1141
+	}
1142
+
1143
+
1144
+	/**
1145
+	 * This will queue the incoming message ids for resending.
1146
+	 * Note, only message_ids corresponding to messages with the status of EEM_Message::sent will be queued.
1147
+	 *
1148
+	 * @since 4.9.0
1149
+	 * @param array $message_ids An array of EE_Message IDs
1150
+	 * @return bool true means messages were successfully queued for resending, false means none were queued for
1151
+	 *                           resending.
1152
+	 * @throws EE_Error
1153
+	 * @throws InvalidArgumentException
1154
+	 * @throws InvalidDataTypeException
1155
+	 * @throws InvalidInterfaceException
1156
+	 * @throws ReflectionException
1157
+	 */
1158
+	public static function queue_for_resending($message_ids)
1159
+	{
1160
+		self::_load_controller();
1161
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
1162
+
1163
+		//get queue and count
1164
+		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
1165
+
1166
+		if (
1167
+			$queue_count > 0
1168
+		) {
1169
+			EE_Error::add_success(
1170
+				sprintf(
1171
+					_n(
1172
+						'%d message successfully queued for resending.',
1173
+						'%d messages successfully queued for resending.',
1174
+						$queue_count,
1175
+						'event_espresso'
1176
+					),
1177
+					$queue_count
1178
+				)
1179
+			);
1180
+			/**
1181
+			 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority
1182
+			 */
1183
+		} elseif (
1184
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', true)
1185
+			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
1186
+		) {
1187
+			$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_sent);
1188
+			if ($queue_count > 0) {
1189
+				EE_Error::add_success(
1190
+					sprintf(
1191
+						_n(
1192
+							'%d message successfully sent.',
1193
+							'%d messages successfully sent.',
1194
+							$queue_count,
1195
+							'event_espresso'
1196
+						),
1197
+						$queue_count
1198
+					)
1199
+				);
1200
+			} else {
1201
+				EE_Error::add_error(
1202
+					__('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1203
+						'event_espresso'),
1204
+					__FILE__, __FUNCTION__, __LINE__
1205
+				);
1206
+			}
1207
+		} else {
1208
+			EE_Error::add_error(
1209
+				__('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.',
1210
+					'event_espresso'),
1211
+				__FILE__, __FUNCTION__, __LINE__
1212
+			);
1213
+		}
1214
+		return (bool)$queue_count;
1215
+	}
1216
+
1217
+
1218
+	/**
1219
+	 * debug
1220
+	 *
1221
+	 * @param string          $class
1222
+	 * @param string          $func
1223
+	 * @param string          $line
1224
+	 * @param \EE_Transaction $transaction
1225
+	 * @param array           $info
1226
+	 * @param bool            $display_request
1227
+	 * @throws EE_Error
1228
+	 * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
1229
+	 */
1230
+	protected static function log(
1231
+		$class = '',
1232
+		$func = '',
1233
+		$line = '',
1234
+		EE_Transaction $transaction,
1235
+		$info = array(),
1236
+		$display_request = false
1237
+	) {
1238
+		if (defined('EE_DEBUG') && EE_DEBUG) {
1239
+			if ($transaction instanceof EE_Transaction) {
1240
+				// don't serialize objects
1241
+				$info                  = EEH_Debug_Tools::strip_objects($info);
1242
+				$info['TXN_status']    = $transaction->status_ID();
1243
+				$info['TXN_reg_steps'] = $transaction->reg_steps();
1244
+				if ($transaction->ID()) {
1245
+					$index = 'EE_Transaction: ' . $transaction->ID();
1246
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1247
+				}
1248
+			}
1249
+		}
1250
+
1251
+	}
1252
+
1253
+
1254
+	/**
1255
+	 *  Resets all the static properties in this class when called.
1256
+	 */
1257
+	public static function reset()
1258
+	{
1259
+		self::$_EEMSG                    = null;
1260
+		self::$_message_resource_manager = null;
1261
+		self::$_MSG_PROCESSOR            = null;
1262
+		self::$_MSG_PATHS                = null;
1263
+		self::$_TMP_PACKS                = array();
1264
+	}
1265 1265
 
1266 1266
 }
1267 1267
 // End of file EED_Messages.module.php
Please login to merge, or discard this patch.
core/helpers/EEH_DTT_Helper.helper.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
      * Get Timezone Transitions
332 332
      *
333 333
      * @param \DateTimeZone $date_time_zone
334
-     * @param null          $time
334
+     * @param integer|null          $time
335 335
      * @param bool          $first_only
336 336
      * @return array|mixed
337 337
      */
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
      * Get Timezone Offset for given timezone object.
349 349
      *
350 350
      * @param \DateTimeZone $date_time_zone
351
-     * @param null          $time
351
+     * @param integer|null          $time
352 352
      * @return mixed
353 353
      * @throws \DomainException
354 354
      */
@@ -1082,7 +1082,7 @@  discard block
 block discarded – undo
1082 1082
      * this method will add that "1" into your date regardless of the format.
1083 1083
      *
1084 1084
      * @param string $month
1085
-     * @return string
1085
+     * @return integer
1086 1086
      */
1087 1087
     public static function first_of_month_timestamp($month = '')
1088 1088
     {
@@ -1231,7 +1231,7 @@  discard block
 block discarded – undo
1231 1231
     /**
1232 1232
      * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1233 1233
      *
1234
-     * @param int|WP_User $user_id
1234
+     * @param integer $user_id
1235 1235
      * @return string
1236 1236
      */
1237 1237
     public static function get_user_locale($user_id = 0)
Please login to merge, or discard this patch.
Indentation   +1190 added lines, -1190 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -28,366 +28,366 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    /**
32
-     * return the timezone set for the WP install
33
-     *
34
-     * @return string valid timezone string for PHP DateTimeZone() class
35
-     */
36
-    public static function get_timezone()
37
-    {
38
-        return EEH_DTT_Helper::get_valid_timezone_string();
39
-    }
40
-
41
-
42
-    /**
43
-     * get_valid_timezone_string
44
-     *    ensures that a valid timezone string is returned
45
-     *
46
-     * @access protected
47
-     * @param string $timezone_string
48
-     * @return string
49
-     * @throws \EE_Error
50
-     */
51
-    public static function get_valid_timezone_string($timezone_string = '')
52
-    {
53
-        // if passed a value, then use that, else get WP option
54
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
55
-        // value from above exists, use that, else get timezone string from gmt_offset
56
-        $timezone_string = ! empty($timezone_string) ? $timezone_string
57
-            : EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
58
-        EEH_DTT_Helper::validate_timezone($timezone_string);
59
-        return $timezone_string;
60
-    }
61
-
62
-
63
-    /**
64
-     * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
65
-     *
66
-     * @static
67
-     * @access public
68
-     * @param  string $timezone_string Timezone string to check
69
-     * @param bool    $throw_error
70
-     * @return bool
71
-     * @throws \EE_Error
72
-     */
73
-    public static function validate_timezone($timezone_string, $throw_error = true)
74
-    {
75
-        // easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
76
-        try {
77
-            new DateTimeZone($timezone_string);
78
-        } catch (Exception $e) {
79
-            // sometimes we take exception to exceptions
80
-            if (! $throw_error) {
81
-                return false;
82
-            }
83
-            throw new EE_Error(
84
-                sprintf(
85
-                    __(
86
-                        'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
87
-                        'event_espresso'
88
-                    ),
89
-                    $timezone_string,
90
-                    '<a href="http://www.php.net/manual/en/timezones.php">',
91
-                    '</a>'
92
-                )
93
-            );
94
-        }
95
-        return true;
96
-    }
97
-
98
-
99
-    /**
100
-     * _create_timezone_object_from_timezone_name
101
-     *
102
-     * @access protected
103
-     * @param string $gmt_offset
104
-     * @return string
105
-     */
106
-    public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
107
-    {
108
-        $timezone_string = 'UTC';
109
-        //if there is no incoming gmt_offset, then because WP hooks in on timezone_string, we need to see if that is
110
-        //set because it will override `gmt_offset` via `pre_get_option` filter.  If that's set, then let's just use
111
-        //that!  Otherwise we'll leave timezone_string at the default of 'UTC' before doing other logic.
112
-        if ($gmt_offset === '') {
113
-            //autoloaded so no need to set to a variable.  There will not be multiple hits to the db.
114
-            if (get_option('timezone_string')) {
115
-                return get_option('timezone_string');
116
-            }
117
-        }
118
-        $gmt_offset = $gmt_offset !== '' ? $gmt_offset : get_option('gmt_offset');
119
-        $gmt_offset = (float)$gmt_offset;
120
-        //if $gmt_offset is 0, then just return UTC
121
-        if ($gmt_offset === (float)0) {
122
-            return $timezone_string;
123
-        }
124
-        if ($gmt_offset !== '') {
125
-            // convert GMT offset to seconds
126
-            $gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
127
-            // although we don't know the TZ abbreviation, we know the UTC offset
128
-            $timezone_string = timezone_name_from_abbr(null, $gmt_offset);
129
-            //only use this timezone_string IF it's current offset matches the given offset
130
-            try {
131
-                $offset = self::get_timezone_offset(new DateTimeZone($timezone_string));
132
-                if ($offset !== $gmt_offset) {
133
-                    $timezone_string = false;
134
-                }
135
-            } catch (Exception $e) {
136
-                $timezone_string = false;
137
-            }
138
-        }
139
-        // better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
140
-        $timezone_string = $timezone_string !== false
141
-            ? $timezone_string
142
-            : EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
143
-        return $timezone_string;
144
-    }
145
-
146
-
147
-    /**
148
-     * Gets the site's GMT offset based on either the timezone string
149
-     * (in which case teh gmt offset will vary depending on the location's
150
-     * observance of daylight savings time) or the gmt_offset wp option
151
-     *
152
-     * @return int seconds offset
153
-     */
154
-    public static function get_site_timezone_gmt_offset()
155
-    {
156
-        $timezone_string = get_option('timezone_string');
157
-        if ($timezone_string) {
158
-            try {
159
-                $timezone = new DateTimeZone($timezone_string);
160
-                return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
161
-            } catch (Exception $e) {
162
-            }
163
-        }
164
-        $offset = get_option('gmt_offset');
165
-        return (int)($offset * HOUR_IN_SECONDS);
166
-    }
167
-
168
-
169
-    /**
170
-     * Depending on PHP version, there might not bevalid current timezone strings to match these gmt_offsets in its
171
-     * timezone tables.
172
-     * To get around that, for these fringe timezones we bump them to a known valid offset.
173
-     * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
174
-     *
175
-     * @access public
176
-     * @param int $gmt_offset
177
-     * @return int
178
-     */
179
-    public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
180
-    {
181
-        //make sure $gmt_offset is int
182
-        $gmt_offset = (int)$gmt_offset;
183
-        switch ($gmt_offset) {
184
-            //-12
185
-            case -43200:
186
-                $gmt_offset = -39600;
187
-                break;
188
-            //-11.5
189
-            case -41400:
190
-                $gmt_offset = -39600;
191
-                break;
192
-            //-10.5
193
-            case -37800:
194
-                $gmt_offset = -39600;
195
-                break;
196
-            //-8.5
197
-            case -30600:
198
-                $gmt_offset = -28800;
199
-                break;
200
-            //-7.5
201
-            case -27000:
202
-                $gmt_offset = -25200;
203
-                break;
204
-            //-6.5
205
-            case -23400:
206
-                $gmt_offset = -21600;
207
-                break;
208
-            //-5.5
209
-            case -19800:
210
-                $gmt_offset = -18000;
211
-                break;
212
-            //-4.5
213
-            case -16200:
214
-                $gmt_offset = -14400;
215
-                break;
216
-            //-3.5
217
-            case -12600:
218
-                $gmt_offset = -10800;
219
-                break;
220
-            //-2.5
221
-            case -9000:
222
-                $gmt_offset = -7200;
223
-                break;
224
-            //-1.5
225
-            case -5400:
226
-                $gmt_offset = -3600;
227
-                break;
228
-            //-0.5
229
-            case -1800:
230
-                $gmt_offset = 0;
231
-                break;
232
-            //.5
233
-            case 1800:
234
-                $gmt_offset = 3600;
235
-                break;
236
-            //1.5
237
-            case 5400:
238
-                $gmt_offset = 7200;
239
-                break;
240
-            //2.5
241
-            case 9000:
242
-                $gmt_offset = 10800;
243
-                break;
244
-            //3.5
245
-            case 12600:
246
-                $gmt_offset = 14400;
247
-                break;
248
-            //7.5
249
-            case 27000:
250
-                $gmt_offset = 28800;
251
-                break;
252
-            //8.5
253
-            case 30600:
254
-                $gmt_offset = 31500;
255
-                break;
256
-            //10.5
257
-            case 37800:
258
-                $gmt_offset = 39600;
259
-                break;
260
-            //11.5
261
-            case 41400:
262
-                $gmt_offset = 43200;
263
-                break;
264
-            //12.75
265
-            case 45900:
266
-                $gmt_offset = 46800;
267
-                break;
268
-            //13.75
269
-            case 49500:
270
-                $gmt_offset = 50400;
271
-                break;
272
-        }
273
-        return $gmt_offset;
274
-    }
275
-
276
-
277
-    /**
278
-     * get_timezone_string_from_abbreviations_list
279
-     *
280
-     * @access public
281
-     * @param int  $gmt_offset
282
-     * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
283
-     * @return string
284
-     * @throws \EE_Error
285
-     */
286
-    public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
287
-    {
288
-        $abbreviations = timezone_abbreviations_list();
289
-        foreach ($abbreviations as $abbreviation) {
290
-            foreach ($abbreviation as $city) {
291
-                if ($city['offset'] === $gmt_offset && $city['dst'] === false) {
292
-                    try {
293
-                        $offset = self::get_timezone_offset(new DateTimeZone($city['timezone_id']));
294
-                        if ($offset !== $gmt_offset) {
295
-                            continue;
296
-                        } else {
297
-                            return $city['timezone_id'];
298
-                        }
299
-                    } catch (Exception $e) {
300
-                        continue;
301
-                    }
302
-                }
303
-            }
304
-        }
305
-        //if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
306
-        if ($coerce == true) {
307
-            $timezone_string = self::get_timezone_string_from_abbreviations_list(
308
-                self::adjust_invalid_gmt_offsets($gmt_offset),
309
-                false
310
-            );
311
-            if ($timezone_string) {
312
-                return $timezone_string;
313
-            }
314
-        }
315
-        throw new EE_Error(
316
-            sprintf(
317
-                __(
318
-                    'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
319
-                    'event_espresso'
320
-                ),
321
-                $gmt_offset,
322
-                '<a href="http://www.php.net/manual/en/timezones.php">',
323
-                '</a>'
324
-            )
325
-        );
326
-    }
327
-
328
-
329
-
330
-    /**
331
-     * Get Timezone Transitions
332
-     *
333
-     * @param \DateTimeZone $date_time_zone
334
-     * @param null          $time
335
-     * @param bool          $first_only
336
-     * @return array|mixed
337
-     */
338
-    public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
339
-    {
340
-        $time        = is_int($time) || $time === null ? $time : strtotime($time);
341
-        $time        = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
342
-        $transitions = $date_time_zone->getTransitions($time);
343
-        return $first_only && ! isset($transitions['ts']) ? reset($transitions) : $transitions;
344
-    }
345
-
346
-
347
-    /**
348
-     * Get Timezone Offset for given timezone object.
349
-     *
350
-     * @param \DateTimeZone $date_time_zone
351
-     * @param null          $time
352
-     * @return mixed
353
-     * @throws \DomainException
354
-     */
355
-    public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
356
-    {
357
-        $transitions = self::get_timezone_transitions($date_time_zone, $time);
358
-        if (! isset($transitions['offset'])) {
359
-            throw new DomainException();
360
-        }
361
-        return $transitions['offset'];
362
-    }
363
-
364
-
365
-    /**
366
-     * @access public
367
-     * @param string $timezone_string
368
-     */
369
-    public static function timezone_select_input($timezone_string = '')
370
-    {
371
-        // get WP date time format
372
-        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
373
-        // if passed a value, then use that, else get WP option
374
-        $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
375
-        // check if the timezone is valid but don't throw any errors if it isn't
376
-        $timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
377
-        $gmt_offset      = get_option('gmt_offset');
378
-        $check_zone_info = true;
379
-        if (empty($timezone_string)) {
380
-            // Create a UTC+- zone if no timezone string exists
381
-            $check_zone_info = false;
382
-            if ($gmt_offset > 0) {
383
-                $timezone_string = 'UTC+' . $gmt_offset;
384
-            } elseif ($gmt_offset < 0) {
385
-                $timezone_string = 'UTC' . $gmt_offset;
386
-            } else {
387
-                $timezone_string = 'UTC';
388
-            }
389
-        }
390
-        ?>
31
+	/**
32
+	 * return the timezone set for the WP install
33
+	 *
34
+	 * @return string valid timezone string for PHP DateTimeZone() class
35
+	 */
36
+	public static function get_timezone()
37
+	{
38
+		return EEH_DTT_Helper::get_valid_timezone_string();
39
+	}
40
+
41
+
42
+	/**
43
+	 * get_valid_timezone_string
44
+	 *    ensures that a valid timezone string is returned
45
+	 *
46
+	 * @access protected
47
+	 * @param string $timezone_string
48
+	 * @return string
49
+	 * @throws \EE_Error
50
+	 */
51
+	public static function get_valid_timezone_string($timezone_string = '')
52
+	{
53
+		// if passed a value, then use that, else get WP option
54
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
55
+		// value from above exists, use that, else get timezone string from gmt_offset
56
+		$timezone_string = ! empty($timezone_string) ? $timezone_string
57
+			: EEH_DTT_Helper::get_timezone_string_from_gmt_offset();
58
+		EEH_DTT_Helper::validate_timezone($timezone_string);
59
+		return $timezone_string;
60
+	}
61
+
62
+
63
+	/**
64
+	 * This only purpose for this static method is to validate that the incoming timezone is a valid php timezone.
65
+	 *
66
+	 * @static
67
+	 * @access public
68
+	 * @param  string $timezone_string Timezone string to check
69
+	 * @param bool    $throw_error
70
+	 * @return bool
71
+	 * @throws \EE_Error
72
+	 */
73
+	public static function validate_timezone($timezone_string, $throw_error = true)
74
+	{
75
+		// easiest way to test a timezone string is just see if it throws an error when you try to create a DateTimeZone object with it
76
+		try {
77
+			new DateTimeZone($timezone_string);
78
+		} catch (Exception $e) {
79
+			// sometimes we take exception to exceptions
80
+			if (! $throw_error) {
81
+				return false;
82
+			}
83
+			throw new EE_Error(
84
+				sprintf(
85
+					__(
86
+						'The timezone given (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
87
+						'event_espresso'
88
+					),
89
+					$timezone_string,
90
+					'<a href="http://www.php.net/manual/en/timezones.php">',
91
+					'</a>'
92
+				)
93
+			);
94
+		}
95
+		return true;
96
+	}
97
+
98
+
99
+	/**
100
+	 * _create_timezone_object_from_timezone_name
101
+	 *
102
+	 * @access protected
103
+	 * @param string $gmt_offset
104
+	 * @return string
105
+	 */
106
+	public static function get_timezone_string_from_gmt_offset($gmt_offset = '')
107
+	{
108
+		$timezone_string = 'UTC';
109
+		//if there is no incoming gmt_offset, then because WP hooks in on timezone_string, we need to see if that is
110
+		//set because it will override `gmt_offset` via `pre_get_option` filter.  If that's set, then let's just use
111
+		//that!  Otherwise we'll leave timezone_string at the default of 'UTC' before doing other logic.
112
+		if ($gmt_offset === '') {
113
+			//autoloaded so no need to set to a variable.  There will not be multiple hits to the db.
114
+			if (get_option('timezone_string')) {
115
+				return get_option('timezone_string');
116
+			}
117
+		}
118
+		$gmt_offset = $gmt_offset !== '' ? $gmt_offset : get_option('gmt_offset');
119
+		$gmt_offset = (float)$gmt_offset;
120
+		//if $gmt_offset is 0, then just return UTC
121
+		if ($gmt_offset === (float)0) {
122
+			return $timezone_string;
123
+		}
124
+		if ($gmt_offset !== '') {
125
+			// convert GMT offset to seconds
126
+			$gmt_offset = $gmt_offset * HOUR_IN_SECONDS;
127
+			// although we don't know the TZ abbreviation, we know the UTC offset
128
+			$timezone_string = timezone_name_from_abbr(null, $gmt_offset);
129
+			//only use this timezone_string IF it's current offset matches the given offset
130
+			try {
131
+				$offset = self::get_timezone_offset(new DateTimeZone($timezone_string));
132
+				if ($offset !== $gmt_offset) {
133
+					$timezone_string = false;
134
+				}
135
+			} catch (Exception $e) {
136
+				$timezone_string = false;
137
+			}
138
+		}
139
+		// better have a valid timezone string by now, but if not, sigh... loop thru  the timezone_abbreviations_list()...
140
+		$timezone_string = $timezone_string !== false
141
+			? $timezone_string
142
+			: EEH_DTT_Helper::get_timezone_string_from_abbreviations_list($gmt_offset);
143
+		return $timezone_string;
144
+	}
145
+
146
+
147
+	/**
148
+	 * Gets the site's GMT offset based on either the timezone string
149
+	 * (in which case teh gmt offset will vary depending on the location's
150
+	 * observance of daylight savings time) or the gmt_offset wp option
151
+	 *
152
+	 * @return int seconds offset
153
+	 */
154
+	public static function get_site_timezone_gmt_offset()
155
+	{
156
+		$timezone_string = get_option('timezone_string');
157
+		if ($timezone_string) {
158
+			try {
159
+				$timezone = new DateTimeZone($timezone_string);
160
+				return $timezone->getOffset(new DateTime()); //in WordPress DateTime defaults to UTC
161
+			} catch (Exception $e) {
162
+			}
163
+		}
164
+		$offset = get_option('gmt_offset');
165
+		return (int)($offset * HOUR_IN_SECONDS);
166
+	}
167
+
168
+
169
+	/**
170
+	 * Depending on PHP version, there might not bevalid current timezone strings to match these gmt_offsets in its
171
+	 * timezone tables.
172
+	 * To get around that, for these fringe timezones we bump them to a known valid offset.
173
+	 * This method should ONLY be called after first verifying an timezone_string cannot be retrieved for the offset.
174
+	 *
175
+	 * @access public
176
+	 * @param int $gmt_offset
177
+	 * @return int
178
+	 */
179
+	public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
180
+	{
181
+		//make sure $gmt_offset is int
182
+		$gmt_offset = (int)$gmt_offset;
183
+		switch ($gmt_offset) {
184
+			//-12
185
+			case -43200:
186
+				$gmt_offset = -39600;
187
+				break;
188
+			//-11.5
189
+			case -41400:
190
+				$gmt_offset = -39600;
191
+				break;
192
+			//-10.5
193
+			case -37800:
194
+				$gmt_offset = -39600;
195
+				break;
196
+			//-8.5
197
+			case -30600:
198
+				$gmt_offset = -28800;
199
+				break;
200
+			//-7.5
201
+			case -27000:
202
+				$gmt_offset = -25200;
203
+				break;
204
+			//-6.5
205
+			case -23400:
206
+				$gmt_offset = -21600;
207
+				break;
208
+			//-5.5
209
+			case -19800:
210
+				$gmt_offset = -18000;
211
+				break;
212
+			//-4.5
213
+			case -16200:
214
+				$gmt_offset = -14400;
215
+				break;
216
+			//-3.5
217
+			case -12600:
218
+				$gmt_offset = -10800;
219
+				break;
220
+			//-2.5
221
+			case -9000:
222
+				$gmt_offset = -7200;
223
+				break;
224
+			//-1.5
225
+			case -5400:
226
+				$gmt_offset = -3600;
227
+				break;
228
+			//-0.5
229
+			case -1800:
230
+				$gmt_offset = 0;
231
+				break;
232
+			//.5
233
+			case 1800:
234
+				$gmt_offset = 3600;
235
+				break;
236
+			//1.5
237
+			case 5400:
238
+				$gmt_offset = 7200;
239
+				break;
240
+			//2.5
241
+			case 9000:
242
+				$gmt_offset = 10800;
243
+				break;
244
+			//3.5
245
+			case 12600:
246
+				$gmt_offset = 14400;
247
+				break;
248
+			//7.5
249
+			case 27000:
250
+				$gmt_offset = 28800;
251
+				break;
252
+			//8.5
253
+			case 30600:
254
+				$gmt_offset = 31500;
255
+				break;
256
+			//10.5
257
+			case 37800:
258
+				$gmt_offset = 39600;
259
+				break;
260
+			//11.5
261
+			case 41400:
262
+				$gmt_offset = 43200;
263
+				break;
264
+			//12.75
265
+			case 45900:
266
+				$gmt_offset = 46800;
267
+				break;
268
+			//13.75
269
+			case 49500:
270
+				$gmt_offset = 50400;
271
+				break;
272
+		}
273
+		return $gmt_offset;
274
+	}
275
+
276
+
277
+	/**
278
+	 * get_timezone_string_from_abbreviations_list
279
+	 *
280
+	 * @access public
281
+	 * @param int  $gmt_offset
282
+	 * @param bool $coerce If true, we attempt to coerce with our adjustment table @see self::adjust_invalid_gmt_offset.
283
+	 * @return string
284
+	 * @throws \EE_Error
285
+	 */
286
+	public static function get_timezone_string_from_abbreviations_list($gmt_offset = 0, $coerce = true)
287
+	{
288
+		$abbreviations = timezone_abbreviations_list();
289
+		foreach ($abbreviations as $abbreviation) {
290
+			foreach ($abbreviation as $city) {
291
+				if ($city['offset'] === $gmt_offset && $city['dst'] === false) {
292
+					try {
293
+						$offset = self::get_timezone_offset(new DateTimeZone($city['timezone_id']));
294
+						if ($offset !== $gmt_offset) {
295
+							continue;
296
+						} else {
297
+							return $city['timezone_id'];
298
+						}
299
+					} catch (Exception $e) {
300
+						continue;
301
+					}
302
+				}
303
+			}
304
+		}
305
+		//if $coerce is true, let's see if we can get a timezone string after the offset is adjusted
306
+		if ($coerce == true) {
307
+			$timezone_string = self::get_timezone_string_from_abbreviations_list(
308
+				self::adjust_invalid_gmt_offsets($gmt_offset),
309
+				false
310
+			);
311
+			if ($timezone_string) {
312
+				return $timezone_string;
313
+			}
314
+		}
315
+		throw new EE_Error(
316
+			sprintf(
317
+				__(
318
+					'The provided GMT offset (%1$s), is invalid, please check with %2$sthis list%3$s for what valid timezones can be used',
319
+					'event_espresso'
320
+				),
321
+				$gmt_offset,
322
+				'<a href="http://www.php.net/manual/en/timezones.php">',
323
+				'</a>'
324
+			)
325
+		);
326
+	}
327
+
328
+
329
+
330
+	/**
331
+	 * Get Timezone Transitions
332
+	 *
333
+	 * @param \DateTimeZone $date_time_zone
334
+	 * @param null          $time
335
+	 * @param bool          $first_only
336
+	 * @return array|mixed
337
+	 */
338
+	public static function get_timezone_transitions(DateTimeZone $date_time_zone, $time = null, $first_only = true)
339
+	{
340
+		$time        = is_int($time) || $time === null ? $time : strtotime($time);
341
+		$time        = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time();
342
+		$transitions = $date_time_zone->getTransitions($time);
343
+		return $first_only && ! isset($transitions['ts']) ? reset($transitions) : $transitions;
344
+	}
345
+
346
+
347
+	/**
348
+	 * Get Timezone Offset for given timezone object.
349
+	 *
350
+	 * @param \DateTimeZone $date_time_zone
351
+	 * @param null          $time
352
+	 * @return mixed
353
+	 * @throws \DomainException
354
+	 */
355
+	public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
356
+	{
357
+		$transitions = self::get_timezone_transitions($date_time_zone, $time);
358
+		if (! isset($transitions['offset'])) {
359
+			throw new DomainException();
360
+		}
361
+		return $transitions['offset'];
362
+	}
363
+
364
+
365
+	/**
366
+	 * @access public
367
+	 * @param string $timezone_string
368
+	 */
369
+	public static function timezone_select_input($timezone_string = '')
370
+	{
371
+		// get WP date time format
372
+		$datetime_format = get_option('date_format') . ' ' . get_option('time_format');
373
+		// if passed a value, then use that, else get WP option
374
+		$timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
375
+		// check if the timezone is valid but don't throw any errors if it isn't
376
+		$timezone_string = EEH_DTT_Helper::validate_timezone($timezone_string, false);
377
+		$gmt_offset      = get_option('gmt_offset');
378
+		$check_zone_info = true;
379
+		if (empty($timezone_string)) {
380
+			// Create a UTC+- zone if no timezone string exists
381
+			$check_zone_info = false;
382
+			if ($gmt_offset > 0) {
383
+				$timezone_string = 'UTC+' . $gmt_offset;
384
+			} elseif ($gmt_offset < 0) {
385
+				$timezone_string = 'UTC' . $gmt_offset;
386
+			} else {
387
+				$timezone_string = 'UTC';
388
+			}
389
+		}
390
+		?>
391 391
 
392 392
         <p>
393 393
             <label for="timezone_string"><?php _e('timezone'); ?></label>
@@ -400,13 +400,13 @@  discard block
 block discarded – undo
400 400
 
401 401
         <p>
402 402
         <span><?php
403
-            printf(
404
-                __('%1$sUTC%2$s time is %3$s'),
405
-                '<abbr title="Coordinated Universal Time">',
406
-                '</abbr>',
407
-                '<code>' . date_i18n($datetime_format, false, true) . '</code>'
408
-            );
409
-            ?></span>
403
+			printf(
404
+				__('%1$sUTC%2$s time is %3$s'),
405
+				'<abbr title="Coordinated Universal Time">',
406
+				'</abbr>',
407
+				'<code>' . date_i18n($datetime_format, false, true) . '</code>'
408
+			);
409
+			?></span>
410 410
         <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?>
411 411
         <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span>
412 412
     <?php endif; ?>
@@ -415,831 +415,831 @@  discard block
 block discarded – undo
415 415
         <br/>
416 416
         <span>
417 417
 					<?php
418
-                    // Set TZ so localtime works.
419
-                    date_default_timezone_set($timezone_string);
420
-                    $now = localtime(time(), true);
421
-                    if ($now['tm_isdst']) {
422
-                        _e('This timezone is currently in daylight saving time.');
423
-                    } else {
424
-                        _e('This timezone is currently in standard time.');
425
-                    }
426
-                    ?>
418
+					// Set TZ so localtime works.
419
+					date_default_timezone_set($timezone_string);
420
+					$now = localtime(time(), true);
421
+					if ($now['tm_isdst']) {
422
+						_e('This timezone is currently in daylight saving time.');
423
+					} else {
424
+						_e('This timezone is currently in standard time.');
425
+					}
426
+					?>
427 427
             <br/>
428 428
             <?php
429
-            if (function_exists('timezone_transitions_get')) {
430
-                $found                   = false;
431
-                $date_time_zone_selected = new DateTimeZone($timezone_string);
432
-                $tz_offset               = timezone_offset_get($date_time_zone_selected, date_create());
433
-                $right_now               = time();
434
-                $tr['isdst']             = false;
435
-                foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
436
-                    if ($tr['ts'] > $right_now) {
437
-                        $found = true;
438
-                        break;
439
-                    }
440
-                }
441
-                if ($found) {
442
-                    $message = $tr['isdst']
443
-                        ?
444
-                        __(' Daylight saving time begins on: %s.')
445
-                        :
446
-                        __(' Standard time begins  on: %s.');
447
-                    // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
448
-                    printf(
449
-                        $message,
450
-                        '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'
451
-                    );
452
-                } else {
453
-                    _e('This timezone does not observe daylight saving time.');
454
-                }
455
-            }
456
-            // Set back to UTC.
457
-            date_default_timezone_set('UTC');
458
-            ?>
429
+			if (function_exists('timezone_transitions_get')) {
430
+				$found                   = false;
431
+				$date_time_zone_selected = new DateTimeZone($timezone_string);
432
+				$tz_offset               = timezone_offset_get($date_time_zone_selected, date_create());
433
+				$right_now               = time();
434
+				$tr['isdst']             = false;
435
+				foreach (timezone_transitions_get($date_time_zone_selected) as $tr) {
436
+					if ($tr['ts'] > $right_now) {
437
+						$found = true;
438
+						break;
439
+					}
440
+				}
441
+				if ($found) {
442
+					$message = $tr['isdst']
443
+						?
444
+						__(' Daylight saving time begins on: %s.')
445
+						:
446
+						__(' Standard time begins  on: %s.');
447
+					// Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
448
+					printf(
449
+						$message,
450
+						'<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'
451
+					);
452
+				} else {
453
+					_e('This timezone does not observe daylight saving time.');
454
+				}
455
+			}
456
+			// Set back to UTC.
457
+			date_default_timezone_set('UTC');
458
+			?>
459 459
 				</span></p>
460 460
         <?php
461
-    endif;
462
-    }
463
-
464
-
465
-    /**
466
-     * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
467
-     * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
468
-     * the site is used.
469
-     * This is used typically when using a Unix timestamp any core WP functions that expect their specially
470
-     * computed timestamp (i.e. date_i18n() )
471
-     *
472
-     * @param int    $unix_timestamp                  if 0, then time() will be used.
473
-     * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
474
-     *                                                site will be used.
475
-     * @return int      $unix_timestamp with the offset applied for the given timezone.
476
-     */
477
-    public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
478
-    {
479
-        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
480
-        $timezone_string = self::get_valid_timezone_string($timezone_string);
481
-        $TimeZone        = new DateTimeZone($timezone_string);
482
-        $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
483
-        $offset   = timezone_offset_get($TimeZone, $DateTime);
484
-        return (int)$DateTime->format('U') + (int)$offset;
485
-    }
486
-
487
-
488
-    /**
489
-     *    _set_date_time_field
490
-     *    modifies EE_Base_Class EE_Datetime_Field objects
491
-     *
492
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
493
-     * @param    DateTime    $DateTime            PHP DateTime object
494
-     * @param  string        $datetime_field_name the datetime fieldname to be manipulated
495
-     * @return    EE_Base_Class
496
-     */
497
-    protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
498
-    {
499
-        // grab current datetime format
500
-        $current_format = $obj->get_format();
501
-        // set new full timestamp format
502
-        $obj->set_date_format(EE_Datetime_Field::mysql_date_format);
503
-        $obj->set_time_format(EE_Datetime_Field::mysql_time_format);
504
-        // set the new date value using a full timestamp format so that no data is lost
505
-        $obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
506
-        // reset datetime formats
507
-        $obj->set_date_format($current_format[0]);
508
-        $obj->set_time_format($current_format[1]);
509
-        return $obj;
510
-    }
511
-
512
-
513
-    /**
514
-     *    date_time_add
515
-     *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
516
-     *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
517
-     *
518
-     * @param  EE_Base_Class $obj                 EE_Base_Class object
519
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
520
-     * @param  string        $period              what you are adding. The options are (years, months, days, hours,
521
-     *                                            minutes, seconds) defaults to years
522
-     * @param  integer       $value               what you want to increment the time by
523
-     * @return EE_Base_Class           return the EE_Base_Class object so right away you can do something with it
524
-     *                                            (chaining)
525
-     */
526
-    public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
527
-    {
528
-        //get the raw UTC date.
529
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
530
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
531
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
532
-    }
533
-
534
-
535
-    /**
536
-     *    date_time_subtract
537
-     *    same as date_time_add except subtracting value instead of adding.
538
-     *
539
-     * @param \EE_Base_Class $obj
540
-     * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
541
-     * @param string         $period
542
-     * @param int            $value
543
-     * @return \EE_Base_Class
544
-     */
545
-    public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
546
-    {
547
-        //get the raw UTC date
548
-        $DateTime = $obj->get_DateTime_object($datetime_field_name);
549
-        $DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
550
-        return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
551
-    }
552
-
553
-
554
-    /**
555
-     * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
556
-     *
557
-     * @param  DateTime $DateTime DateTime object
558
-     * @param  string   $period   a value to indicate what interval is being used in the calculation. The options are
559
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
560
-     * @param  integer  $value    What you want to increment the date by
561
-     * @param  string   $operand  What operand you wish to use for the calculation
562
-     * @return \DateTime return whatever type came in.
563
-     * @throws \EE_Error
564
-     */
565
-    protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
566
-    {
567
-        if (! $DateTime instanceof DateTime) {
568
-            throw new EE_Error(
569
-                sprintf(
570
-                    __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
571
-                    print_r($DateTime, true)
572
-                )
573
-            );
574
-        }
575
-        switch ($period) {
576
-            case 'years' :
577
-                $value = 'P' . $value . 'Y';
578
-                break;
579
-            case 'months' :
580
-                $value = 'P' . $value . 'M';
581
-                break;
582
-            case 'weeks' :
583
-                $value = 'P' . $value . 'W';
584
-                break;
585
-            case 'days' :
586
-                $value = 'P' . $value . 'D';
587
-                break;
588
-            case 'hours' :
589
-                $value = 'PT' . $value . 'H';
590
-                break;
591
-            case 'minutes' :
592
-                $value = 'PT' . $value . 'M';
593
-                break;
594
-            case 'seconds' :
595
-                $value = 'PT' . $value . 'S';
596
-                break;
597
-        }
598
-        switch ($operand) {
599
-            case '+':
600
-                $DateTime->add(new DateInterval($value));
601
-                break;
602
-            case '-':
603
-                $DateTime->sub(new DateInterval($value));
604
-                break;
605
-        }
606
-        return $DateTime;
607
-    }
608
-
609
-
610
-    /**
611
-     * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
612
-     *
613
-     * @param  int     $timestamp Unix timestamp
614
-     * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
615
-     *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
616
-     * @param  integer $value     What you want to increment the date by
617
-     * @param  string  $operand   What operand you wish to use for the calculation
618
-     * @return \DateTime return whatever type came in.
619
-     * @throws \EE_Error
620
-     */
621
-    protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
622
-    {
623
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
624
-            throw new EE_Error(
625
-                sprintf(
626
-                    __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
627
-                    print_r($timestamp, true)
628
-                )
629
-            );
630
-        }
631
-        switch ($period) {
632
-            case 'years' :
633
-                $value = YEAR_IN_SECONDS * $value;
634
-                break;
635
-            case 'months' :
636
-                $value = YEAR_IN_SECONDS / 12 * $value;
637
-                break;
638
-            case 'weeks' :
639
-                $value = WEEK_IN_SECONDS * $value;
640
-                break;
641
-            case 'days' :
642
-                $value = DAY_IN_SECONDS * $value;
643
-                break;
644
-            case 'hours' :
645
-                $value = HOUR_IN_SECONDS * $value;
646
-                break;
647
-            case 'minutes' :
648
-                $value = MINUTE_IN_SECONDS * $value;
649
-                break;
650
-        }
651
-        switch ($operand) {
652
-            case '+':
653
-                $timestamp += $value;
654
-                break;
655
-            case '-':
656
-                $timestamp -= $value;
657
-                break;
658
-        }
659
-        return $timestamp;
660
-    }
661
-
662
-
663
-    /**
664
-     * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
665
-     * parameters and returns the new timestamp or DateTime.
666
-     *
667
-     * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
668
-     * @param  string         $period                a value to indicate what interval is being used in the
669
-     *                                               calculation. The options are 'years', 'months', 'days', 'hours',
670
-     *                                               'minutes', 'seconds'. Defaults to years.
671
-     * @param  integer        $value                 What you want to increment the date by
672
-     * @param  string         $operand               What operand you wish to use for the calculation
673
-     * @return mixed string|DateTime          return whatever type came in.
674
-     */
675
-    public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
676
-    {
677
-        if ($DateTime_or_timestamp instanceof DateTime) {
678
-            return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
679
-        } elseif (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
680
-            return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
681
-        } else {
682
-            //error
683
-            return $DateTime_or_timestamp;
684
-        }
685
-    }
686
-
687
-
688
-    /**
689
-     * The purpose of this helper method is to receive an incoming format string in php date/time format
690
-     * and spit out the js and moment.js equivalent formats.
691
-     * Note, if no format string is given, then it is assumed the user wants what is set for WP.
692
-     * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
693
-     * time picker.
694
-     *
695
-     * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
696
-     * @param null $date_format_string
697
-     * @param null $time_format_string
698
-     * @return array
699
-     *                array(
700
-     *                'js' => array (
701
-     *                'date' => //date format
702
-     *                'time' => //time format
703
-     *                ),
704
-     *                'moment' => //date and time format.
705
-     *                )
706
-     */
707
-    public static function convert_php_to_js_and_moment_date_formats(
708
-        $date_format_string = null,
709
-        $time_format_string = null
710
-    ) {
711
-        if ($date_format_string === null) {
712
-            $date_format_string = get_option('date_format');
713
-        }
714
-        if ($time_format_string === null) {
715
-            $time_format_string = get_option('time_format');
716
-        }
717
-        $date_format = self::_php_to_js_moment_converter($date_format_string);
718
-        $time_format = self::_php_to_js_moment_converter($time_format_string);
719
-        return array(
720
-            'js'     => array(
721
-                'date' => $date_format['js'],
722
-                'time' => $time_format['js'],
723
-            ),
724
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
725
-        );
726
-    }
727
-
728
-
729
-    /**
730
-     * This converts incoming format string into js and moment variations.
731
-     *
732
-     * @param string $format_string incoming php format string
733
-     * @return array js and moment formats.
734
-     */
735
-    protected static function _php_to_js_moment_converter($format_string)
736
-    {
737
-        /**
738
-         * This is a map of symbols for formats.
739
-         * The index is the php symbol, the equivalent values are in the array.
740
-         *
741
-         * @var array
742
-         */
743
-        $symbols_map      = array(
744
-            // Day
745
-            //01
746
-            'd' => array(
747
-                'js'     => 'dd',
748
-                'moment' => 'DD',
749
-            ),
750
-            //Mon
751
-            'D' => array(
752
-                'js'     => 'D',
753
-                'moment' => 'ddd',
754
-            ),
755
-            //1,2,...31
756
-            'j' => array(
757
-                'js'     => 'd',
758
-                'moment' => 'D',
759
-            ),
760
-            //Monday
761
-            'l' => array(
762
-                'js'     => 'DD',
763
-                'moment' => 'dddd',
764
-            ),
765
-            //ISO numeric representation of the day of the week (1-6)
766
-            'N' => array(
767
-                'js'     => '',
768
-                'moment' => 'E',
769
-            ),
770
-            //st,nd.rd
771
-            'S' => array(
772
-                'js'     => '',
773
-                'moment' => 'o',
774
-            ),
775
-            //numeric representation of day of week (0-6)
776
-            'w' => array(
777
-                'js'     => '',
778
-                'moment' => 'd',
779
-            ),
780
-            //day of year starting from 0 (0-365)
781
-            'z' => array(
782
-                'js'     => 'o',
783
-                'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1
784
-            ),
785
-            // Week
786
-            //ISO-8601 week number of year (weeks starting on monday)
787
-            'W' => array(
788
-                'js'     => '',
789
-                'moment' => 'w',
790
-            ),
791
-            // Month
792
-            // January...December
793
-            'F' => array(
794
-                'js'     => 'MM',
795
-                'moment' => 'MMMM',
796
-            ),
797
-            //01...12
798
-            'm' => array(
799
-                'js'     => 'mm',
800
-                'moment' => 'MM',
801
-            ),
802
-            //Jan...Dec
803
-            'M' => array(
804
-                'js'     => 'M',
805
-                'moment' => 'MMM',
806
-            ),
807
-            //1-12
808
-            'n' => array(
809
-                'js'     => 'm',
810
-                'moment' => 'M',
811
-            ),
812
-            //number of days in given month
813
-            't' => array(
814
-                'js'     => '',
815
-                'moment' => '',
816
-            ),
817
-            // Year
818
-            //whether leap year or not 1/0
819
-            'L' => array(
820
-                'js'     => '',
821
-                'moment' => '',
822
-            ),
823
-            //ISO-8601 year number
824
-            'o' => array(
825
-                'js'     => '',
826
-                'moment' => 'GGGG',
827
-            ),
828
-            //1999...2003
829
-            'Y' => array(
830
-                'js'     => 'yy',
831
-                'moment' => 'YYYY',
832
-            ),
833
-            //99...03
834
-            'y' => array(
835
-                'js'     => 'y',
836
-                'moment' => 'YY',
837
-            ),
838
-            // Time
839
-            // am/pm
840
-            'a' => array(
841
-                'js'     => 'tt',
842
-                'moment' => 'a',
843
-            ),
844
-            // AM/PM
845
-            'A' => array(
846
-                'js'     => 'TT',
847
-                'moment' => 'A',
848
-            ),
849
-            // Swatch Internet Time?!?
850
-            'B' => array(
851
-                'js'     => '',
852
-                'moment' => '',
853
-            ),
854
-            //1...12
855
-            'g' => array(
856
-                'js'     => 'h',
857
-                'moment' => 'h',
858
-            ),
859
-            //0...23
860
-            'G' => array(
861
-                'js'     => 'H',
862
-                'moment' => 'H',
863
-            ),
864
-            //01...12
865
-            'h' => array(
866
-                'js'     => 'hh',
867
-                'moment' => 'hh',
868
-            ),
869
-            //00...23
870
-            'H' => array(
871
-                'js'     => 'HH',
872
-                'moment' => 'HH',
873
-            ),
874
-            //00..59
875
-            'i' => array(
876
-                'js'     => 'mm',
877
-                'moment' => 'mm',
878
-            ),
879
-            //seconds... 00...59
880
-            's' => array(
881
-                'js'     => 'ss',
882
-                'moment' => 'ss',
883
-            ),
884
-            //microseconds
885
-            'u' => array(
886
-                'js'     => '',
887
-                'moment' => '',
888
-            ),
889
-        );
890
-        $jquery_ui_format = "";
891
-        $moment_format    = "";
892
-        $escaping         = false;
893
-        for ($i = 0; $i < strlen($format_string); $i++) {
894
-            $char = $format_string[$i];
895
-            if ($char === '\\') { // PHP date format escaping character
896
-                $i++;
897
-                if ($escaping) {
898
-                    $jquery_ui_format .= $format_string[$i];
899
-                    $moment_format    .= $format_string[$i];
900
-                } else {
901
-                    $jquery_ui_format .= '\'' . $format_string[$i];
902
-                    $moment_format    .= $format_string[$i];
903
-                }
904
-                $escaping = true;
905
-            } else {
906
-                if ($escaping) {
907
-                    $jquery_ui_format .= "'";
908
-                    $moment_format    .= "'";
909
-                    $escaping         = false;
910
-                }
911
-                if (isset($symbols_map[$char])) {
912
-                    $jquery_ui_format .= $symbols_map[$char]['js'];
913
-                    $moment_format    .= $symbols_map[$char]['moment'];
914
-                } else {
915
-                    $jquery_ui_format .= $char;
916
-                    $moment_format    .= $char;
917
-                }
918
-            }
919
-        }
920
-        return array('js' => $jquery_ui_format, 'moment' => $moment_format);
921
-    }
922
-
923
-
924
-    /**
925
-     * This takes an incoming format string and validates it to ensure it will work fine with PHP.
926
-     *
927
-     * @param string $format_string   Incoming format string for php date().
928
-     * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
929
-     *                                errors is returned.  So for client code calling, check for is_array() to
930
-     *                                indicate failed validations.
931
-     */
932
-    public static function validate_format_string($format_string)
933
-    {
934
-        $error_msg = array();
935
-        //time format checks
936
-        switch (true) {
937
-            case   strpos($format_string, 'h') !== false  :
938
-            case   strpos($format_string, 'g') !== false :
939
-                /**
940
-                 * if the time string has a lowercase 'h' which == 12 hour time format and there
941
-                 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
942
-                 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
943
-                 */
944
-                if (strpos(strtoupper($format_string), 'A') === false) {
945
-                    $error_msg[] = __(
946
-                        'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
947
-                        'event_espresso'
948
-                    );
949
-                }
950
-                break;
951
-        }
952
-        return empty($error_msg) ? true : $error_msg;
953
-    }
954
-
955
-
956
-    /**
957
-     *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
958
-     *     very next day then this method will return true.
959
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
960
-     *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
961
-     *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
962
-     *
963
-     * @param mixed $date_1
964
-     * @param mixed $date_2
965
-     * @return bool
966
-     */
967
-    public static function dates_represent_one_24_hour_date($date_1, $date_2)
968
-    {
969
-
970
-        if (
971
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
972
-            || ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00'
973
-                || $date_2->format(
974
-                    EE_Datetime_Field::mysql_time_format
975
-                ) != '00:00:00')
976
-        ) {
977
-            return false;
978
-        }
979
-        return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false;
980
-    }
981
-
982
-
983
-    /**
984
-     * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
985
-     * Functions.
986
-     *
987
-     * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
988
-     * @param string $field_for_interval The Database field that is the interval is applied to in the query.
989
-     * @return string
990
-     */
991
-    public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
992
-    {
993
-        try {
994
-            /** need to account for timezone offset on the selects */
995
-            $DateTimeZone = new DateTimeZone($timezone_string);
996
-        } catch (Exception $e) {
997
-            $DateTimeZone = null;
998
-        }
999
-        /**
1000
-         * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
1001
-         * Hence we do the calc for DateTimeZone::getOffset.
1002
-         */
1003
-        $offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now')))
1004
-                                                                  / HOUR_IN_SECONDS : get_option('gmt_offset');
1005
-        $query_interval = $offset < 0
1006
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
1007
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
1008
-        return $query_interval;
1009
-    }
1010
-
1011
-
1012
-    /**
1013
-     * Retrieves the site's default timezone and returns it formatted so it's ready for display
1014
-     * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
1015
-     * and 'gmt_offset' WordPress options directly; or use the filter
1016
-     * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
1017
-     * (although note that we remove any HTML that may be added)
1018
-     *
1019
-     * @return string
1020
-     */
1021
-    public static function get_timezone_string_for_display()
1022
-    {
1023
-        $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
1024
-        if (! empty($pretty_timezone)) {
1025
-            return esc_html($pretty_timezone);
1026
-        }
1027
-        $timezone_string = get_option('timezone_string');
1028
-        if ($timezone_string) {
1029
-            static $mo_loaded = false;
1030
-            // Load translations for continents and cities just like wp_timezone_choice does
1031
-            if (! $mo_loaded) {
1032
-                $locale = get_locale();
1033
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
1034
-                load_textdomain('continents-cities', $mofile);
1035
-                $mo_loaded = true;
1036
-            }
1037
-            //well that was easy.
1038
-            $parts = explode('/', $timezone_string);
1039
-            //remove the continent
1040
-            unset($parts[0]);
1041
-            $t_parts = array();
1042
-            foreach ($parts as $part) {
1043
-                $t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
1044
-            }
1045
-            return implode(' - ', $t_parts);
1046
-        }
1047
-        //they haven't set the timezone string, so let's return a string like "UTC+1"
1048
-        $gmt_offset = get_option('gmt_offset');
1049
-        if (intval($gmt_offset) >= 0) {
1050
-            $prefix = '+';
1051
-        } else {
1052
-            $prefix = '';
1053
-        }
1054
-        $parts = explode('.', (string)$gmt_offset);
1055
-        if (count($parts) === 1) {
1056
-            $parts[1] = '00';
1057
-        } else {
1058
-            //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
1059
-            //to minutes, eg 30 or 15, respectively
1060
-            $hour_fraction = (float)('0.' . $parts[1]);
1061
-            $parts[1]      = (string)$hour_fraction * 60;
1062
-        }
1063
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
1064
-    }
1065
-
1066
-
1067
-
1068
-    /**
1069
-     * So PHP does this awesome thing where if you are trying to get a timestamp
1070
-     * for a month using a string like "February" or "February 2017",
1071
-     * and you don't specify a day as part of your string,
1072
-     * then PHP will use whatever the current day of the month is.
1073
-     * IF the current day of the month happens to be the 30th or 31st,
1074
-     * then PHP gets really confused by a date like February 30,
1075
-     * so instead of saying
1076
-     *      "Hey February only has 28 days (this year)...
1077
-     *      ...you must have meant the last day of the month!"
1078
-     * PHP does the next most logical thing, and bumps the date up to March 2nd,
1079
-     * because someone requesting February 30th obviously meant March 1st!
1080
-     * The way around this is to always set the day to the first,
1081
-     * so that the month will stay on the month you wanted.
1082
-     * this method will add that "1" into your date regardless of the format.
1083
-     *
1084
-     * @param string $month
1085
-     * @return string
1086
-     */
1087
-    public static function first_of_month_timestamp($month = '')
1088
-    {
1089
-        $month = (string)$month;
1090
-        $year  = '';
1091
-        // check if the incoming string has a year in it or not
1092
-        if (preg_match('/\b\d{4}\b/', $month, $matches)) {
1093
-            $year = $matches[0];
1094
-            // ten remove that from the month string as well as any spaces
1095
-            $month = trim(str_replace($year, '', $month));
1096
-            // add a space before the year
1097
-            $year = " {$year}";
1098
-        }
1099
-        // return timestamp for something like "February 1 2017"
1100
-        return strtotime("{$month} 1{$year}");
1101
-    }
1102
-
1103
-
1104
-    /**
1105
-     * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
1106
-     * for this sites timezone, but the timestamp could be some other time GMT.
1107
-     */
1108
-    public static function tomorrow()
1109
-    {
1110
-        //The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
1111
-        //before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
1112
-        //not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
1113
-        //final timestamp is equivalent to midnight in this timezone as represented in GMT.
1114
-        return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
1115
-    }
1116
-
1117
-
1118
-    /**
1119
-     * **
1120
-     * Gives a nicely-formatted list of timezone strings.
1121
-     * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
1122
-     *
1123
-     * @since     4.9.40.rc.008
1124
-     * @staticvar bool $mo_loaded
1125
-     * @staticvar string $locale_loaded
1126
-     * @param string $selected_zone Selected timezone.
1127
-     * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
1128
-     * @return string
1129
-     */
1130
-    public static function wp_timezone_choice($selected_zone, $locale = null)
1131
-    {
1132
-        static $mo_loaded = false, $locale_loaded = null;
1133
-        $continents = array(
1134
-            'Africa',
1135
-            'America',
1136
-            'Antarctica',
1137
-            'Arctic',
1138
-            'Asia',
1139
-            'Atlantic',
1140
-            'Australia',
1141
-            'Europe',
1142
-            'Indian',
1143
-            'Pacific',
1144
-        );
1145
-        // Load translations for continents and cities.
1146
-        if (! $mo_loaded || $locale !== $locale_loaded) {
1147
-            $locale_loaded = $locale ? $locale : get_locale();
1148
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
1149
-            unload_textdomain('continents-cities');
1150
-            load_textdomain('continents-cities', $mofile);
1151
-            $mo_loaded = true;
1152
-        }
1153
-        $zonen = array();
1154
-        foreach (timezone_identifiers_list() as $zone) {
1155
-            $zone = explode('/', $zone);
1156
-            if (! in_array($zone[0], $continents)) {
1157
-                continue;
1158
-            }
1159
-            // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
1160
-            $exists    = array(
1161
-                0 => (isset($zone[0]) && $zone[0]),
1162
-                1 => (isset($zone[1]) && $zone[1]),
1163
-                2 => (isset($zone[2]) && $zone[2]),
1164
-            );
1165
-            $exists[3] = ($exists[0] && 'Etc' !== $zone[0]);
1166
-            $exists[4] = ($exists[1] && $exists[3]);
1167
-            $exists[5] = ($exists[2] && $exists[3]);
1168
-            $zonen[] = array(
1169
-                'continent'   => ($exists[0] ? $zone[0] : ''),
1170
-                'city'        => ($exists[1] ? $zone[1] : ''),
1171
-                'subcity'     => ($exists[2] ? $zone[2] : ''),
1172
-                't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''),
1173
-                't_city'      => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''),
1174
-                't_subcity'   => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : ''),
1175
-            );
1176
-        }
1177
-        usort($zonen, '_wp_timezone_choice_usort_callback');
1178
-        $structure = array();
1179
-        if (empty($selected_zone)) {
1180
-            $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>';
1181
-        }
1182
-        foreach ($zonen as $key => $zone) {
1183
-            // Build value in an array to join later
1184
-            $value = array($zone['continent']);
1185
-            if (empty($zone['city'])) {
1186
-                // It's at the continent level (generally won't happen)
1187
-                $display = $zone['t_continent'];
1188
-            } else {
1189
-                // It's inside a continent group
1190
-                // Continent optgroup
1191
-                if (! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
1192
-                    $label       = $zone['t_continent'];
1193
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
1194
-                }
1195
-                // Add the city to the value
1196
-                $value[] = $zone['city'];
1197
-                $display = $zone['t_city'];
1198
-                if (! empty($zone['subcity'])) {
1199
-                    // Add the subcity to the value
1200
-                    $value[] = $zone['subcity'];
1201
-                    $display .= ' - ' . $zone['t_subcity'];
1202
-                }
1203
-            }
1204
-            // Build the value
1205
-            $value    = join('/', $value);
1206
-            $selected = '';
1207
-            if ($value === $selected_zone) {
1208
-                $selected = 'selected="selected" ';
1209
-            }
1210
-            $structure[] = '<option '
1211
-                           . $selected
1212
-                           . 'value="'
1213
-                           . esc_attr($value)
1214
-                           . '">'
1215
-                           . esc_html($display)
1216
-                           . "</option>";
1217
-            // Close continent optgroup
1218
-            if (! empty($zone['city'])
1219
-                && (! isset($zonen[$key + 1])
1220
-                    || (isset($zonen[$key + 1])
1221
-                        && $zonen[$key
1222
-                                  + 1]['continent']
1223
-                           !== $zone['continent']))) {
1224
-                $structure[] = '</optgroup>';
1225
-            }
1226
-        }
1227
-        return join("\n", $structure);
1228
-    }
1229
-
1230
-
1231
-    /**
1232
-     * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1233
-     *
1234
-     * @param int|WP_User $user_id
1235
-     * @return string
1236
-     */
1237
-    public static function get_user_locale($user_id = 0)
1238
-    {
1239
-        if (function_exists('get_user_locale')) {
1240
-            return get_user_locale($user_id);
1241
-        }
1242
-        return get_locale();
1243
-    }
461
+	endif;
462
+	}
463
+
464
+
465
+	/**
466
+	 * This method will take an incoming unix timestamp and add the offset to it for the given timezone_string.
467
+	 * If no unix timestamp is given then time() is used.  If no timezone is given then the set timezone string for
468
+	 * the site is used.
469
+	 * This is used typically when using a Unix timestamp any core WP functions that expect their specially
470
+	 * computed timestamp (i.e. date_i18n() )
471
+	 *
472
+	 * @param int    $unix_timestamp                  if 0, then time() will be used.
473
+	 * @param string $timezone_string                 timezone_string. If empty, then the current set timezone for the
474
+	 *                                                site will be used.
475
+	 * @return int      $unix_timestamp with the offset applied for the given timezone.
476
+	 */
477
+	public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
478
+	{
479
+		$unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
480
+		$timezone_string = self::get_valid_timezone_string($timezone_string);
481
+		$TimeZone        = new DateTimeZone($timezone_string);
482
+		$DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
483
+		$offset   = timezone_offset_get($TimeZone, $DateTime);
484
+		return (int)$DateTime->format('U') + (int)$offset;
485
+	}
486
+
487
+
488
+	/**
489
+	 *    _set_date_time_field
490
+	 *    modifies EE_Base_Class EE_Datetime_Field objects
491
+	 *
492
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
493
+	 * @param    DateTime    $DateTime            PHP DateTime object
494
+	 * @param  string        $datetime_field_name the datetime fieldname to be manipulated
495
+	 * @return    EE_Base_Class
496
+	 */
497
+	protected static function _set_date_time_field(EE_Base_Class $obj, DateTime $DateTime, $datetime_field_name)
498
+	{
499
+		// grab current datetime format
500
+		$current_format = $obj->get_format();
501
+		// set new full timestamp format
502
+		$obj->set_date_format(EE_Datetime_Field::mysql_date_format);
503
+		$obj->set_time_format(EE_Datetime_Field::mysql_time_format);
504
+		// set the new date value using a full timestamp format so that no data is lost
505
+		$obj->set($datetime_field_name, $DateTime->format(EE_Datetime_Field::mysql_timestamp_format));
506
+		// reset datetime formats
507
+		$obj->set_date_format($current_format[0]);
508
+		$obj->set_time_format($current_format[1]);
509
+		return $obj;
510
+	}
511
+
512
+
513
+	/**
514
+	 *    date_time_add
515
+	 *    helper for doing simple datetime calculations on a given datetime from EE_Base_Class
516
+	 *    and modifying it IN the EE_Base_Class so you don't have to do anything else.
517
+	 *
518
+	 * @param  EE_Base_Class $obj                 EE_Base_Class object
519
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
520
+	 * @param  string        $period              what you are adding. The options are (years, months, days, hours,
521
+	 *                                            minutes, seconds) defaults to years
522
+	 * @param  integer       $value               what you want to increment the time by
523
+	 * @return EE_Base_Class           return the EE_Base_Class object so right away you can do something with it
524
+	 *                                            (chaining)
525
+	 */
526
+	public static function date_time_add(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
527
+	{
528
+		//get the raw UTC date.
529
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
530
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value);
531
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
532
+	}
533
+
534
+
535
+	/**
536
+	 *    date_time_subtract
537
+	 *    same as date_time_add except subtracting value instead of adding.
538
+	 *
539
+	 * @param \EE_Base_Class $obj
540
+	 * @param  string        $datetime_field_name name of the EE_Datetime_Filed datatype db column to be manipulated
541
+	 * @param string         $period
542
+	 * @param int            $value
543
+	 * @return \EE_Base_Class
544
+	 */
545
+	public static function date_time_subtract(EE_Base_Class $obj, $datetime_field_name, $period = 'years', $value = 1)
546
+	{
547
+		//get the raw UTC date
548
+		$DateTime = $obj->get_DateTime_object($datetime_field_name);
549
+		$DateTime = EEH_DTT_Helper::calc_date($DateTime, $period, $value, '-');
550
+		return EEH_DTT_Helper::_set_date_time_field($obj, $DateTime, $datetime_field_name);
551
+	}
552
+
553
+
554
+	/**
555
+	 * Simply takes an incoming DateTime object and does calculations on it based on the incoming parameters
556
+	 *
557
+	 * @param  DateTime $DateTime DateTime object
558
+	 * @param  string   $period   a value to indicate what interval is being used in the calculation. The options are
559
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
560
+	 * @param  integer  $value    What you want to increment the date by
561
+	 * @param  string   $operand  What operand you wish to use for the calculation
562
+	 * @return \DateTime return whatever type came in.
563
+	 * @throws \EE_Error
564
+	 */
565
+	protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
566
+	{
567
+		if (! $DateTime instanceof DateTime) {
568
+			throw new EE_Error(
569
+				sprintf(
570
+					__('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
571
+					print_r($DateTime, true)
572
+				)
573
+			);
574
+		}
575
+		switch ($period) {
576
+			case 'years' :
577
+				$value = 'P' . $value . 'Y';
578
+				break;
579
+			case 'months' :
580
+				$value = 'P' . $value . 'M';
581
+				break;
582
+			case 'weeks' :
583
+				$value = 'P' . $value . 'W';
584
+				break;
585
+			case 'days' :
586
+				$value = 'P' . $value . 'D';
587
+				break;
588
+			case 'hours' :
589
+				$value = 'PT' . $value . 'H';
590
+				break;
591
+			case 'minutes' :
592
+				$value = 'PT' . $value . 'M';
593
+				break;
594
+			case 'seconds' :
595
+				$value = 'PT' . $value . 'S';
596
+				break;
597
+		}
598
+		switch ($operand) {
599
+			case '+':
600
+				$DateTime->add(new DateInterval($value));
601
+				break;
602
+			case '-':
603
+				$DateTime->sub(new DateInterval($value));
604
+				break;
605
+		}
606
+		return $DateTime;
607
+	}
608
+
609
+
610
+	/**
611
+	 * Simply takes an incoming Unix timestamp and does calculations on it based on the incoming parameters
612
+	 *
613
+	 * @param  int     $timestamp Unix timestamp
614
+	 * @param  string  $period    a value to indicate what interval is being used in the calculation. The options are
615
+	 *                            'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years.
616
+	 * @param  integer $value     What you want to increment the date by
617
+	 * @param  string  $operand   What operand you wish to use for the calculation
618
+	 * @return \DateTime return whatever type came in.
619
+	 * @throws \EE_Error
620
+	 */
621
+	protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
622
+	{
623
+		if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
624
+			throw new EE_Error(
625
+				sprintf(
626
+					__('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
627
+					print_r($timestamp, true)
628
+				)
629
+			);
630
+		}
631
+		switch ($period) {
632
+			case 'years' :
633
+				$value = YEAR_IN_SECONDS * $value;
634
+				break;
635
+			case 'months' :
636
+				$value = YEAR_IN_SECONDS / 12 * $value;
637
+				break;
638
+			case 'weeks' :
639
+				$value = WEEK_IN_SECONDS * $value;
640
+				break;
641
+			case 'days' :
642
+				$value = DAY_IN_SECONDS * $value;
643
+				break;
644
+			case 'hours' :
645
+				$value = HOUR_IN_SECONDS * $value;
646
+				break;
647
+			case 'minutes' :
648
+				$value = MINUTE_IN_SECONDS * $value;
649
+				break;
650
+		}
651
+		switch ($operand) {
652
+			case '+':
653
+				$timestamp += $value;
654
+				break;
655
+			case '-':
656
+				$timestamp -= $value;
657
+				break;
658
+		}
659
+		return $timestamp;
660
+	}
661
+
662
+
663
+	/**
664
+	 * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming
665
+	 * parameters and returns the new timestamp or DateTime.
666
+	 *
667
+	 * @param  int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp
668
+	 * @param  string         $period                a value to indicate what interval is being used in the
669
+	 *                                               calculation. The options are 'years', 'months', 'days', 'hours',
670
+	 *                                               'minutes', 'seconds'. Defaults to years.
671
+	 * @param  integer        $value                 What you want to increment the date by
672
+	 * @param  string         $operand               What operand you wish to use for the calculation
673
+	 * @return mixed string|DateTime          return whatever type came in.
674
+	 */
675
+	public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+')
676
+	{
677
+		if ($DateTime_or_timestamp instanceof DateTime) {
678
+			return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand);
679
+		} elseif (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) {
680
+			return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand);
681
+		} else {
682
+			//error
683
+			return $DateTime_or_timestamp;
684
+		}
685
+	}
686
+
687
+
688
+	/**
689
+	 * The purpose of this helper method is to receive an incoming format string in php date/time format
690
+	 * and spit out the js and moment.js equivalent formats.
691
+	 * Note, if no format string is given, then it is assumed the user wants what is set for WP.
692
+	 * Note, js date and time formats are those used by the jquery-ui datepicker and the jquery-ui date-
693
+	 * time picker.
694
+	 *
695
+	 * @see http://stackoverflow.com/posts/16725290/ for the code inspiration.
696
+	 * @param null $date_format_string
697
+	 * @param null $time_format_string
698
+	 * @return array
699
+	 *                array(
700
+	 *                'js' => array (
701
+	 *                'date' => //date format
702
+	 *                'time' => //time format
703
+	 *                ),
704
+	 *                'moment' => //date and time format.
705
+	 *                )
706
+	 */
707
+	public static function convert_php_to_js_and_moment_date_formats(
708
+		$date_format_string = null,
709
+		$time_format_string = null
710
+	) {
711
+		if ($date_format_string === null) {
712
+			$date_format_string = get_option('date_format');
713
+		}
714
+		if ($time_format_string === null) {
715
+			$time_format_string = get_option('time_format');
716
+		}
717
+		$date_format = self::_php_to_js_moment_converter($date_format_string);
718
+		$time_format = self::_php_to_js_moment_converter($time_format_string);
719
+		return array(
720
+			'js'     => array(
721
+				'date' => $date_format['js'],
722
+				'time' => $time_format['js'],
723
+			),
724
+			'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
725
+		);
726
+	}
727
+
728
+
729
+	/**
730
+	 * This converts incoming format string into js and moment variations.
731
+	 *
732
+	 * @param string $format_string incoming php format string
733
+	 * @return array js and moment formats.
734
+	 */
735
+	protected static function _php_to_js_moment_converter($format_string)
736
+	{
737
+		/**
738
+		 * This is a map of symbols for formats.
739
+		 * The index is the php symbol, the equivalent values are in the array.
740
+		 *
741
+		 * @var array
742
+		 */
743
+		$symbols_map      = array(
744
+			// Day
745
+			//01
746
+			'd' => array(
747
+				'js'     => 'dd',
748
+				'moment' => 'DD',
749
+			),
750
+			//Mon
751
+			'D' => array(
752
+				'js'     => 'D',
753
+				'moment' => 'ddd',
754
+			),
755
+			//1,2,...31
756
+			'j' => array(
757
+				'js'     => 'd',
758
+				'moment' => 'D',
759
+			),
760
+			//Monday
761
+			'l' => array(
762
+				'js'     => 'DD',
763
+				'moment' => 'dddd',
764
+			),
765
+			//ISO numeric representation of the day of the week (1-6)
766
+			'N' => array(
767
+				'js'     => '',
768
+				'moment' => 'E',
769
+			),
770
+			//st,nd.rd
771
+			'S' => array(
772
+				'js'     => '',
773
+				'moment' => 'o',
774
+			),
775
+			//numeric representation of day of week (0-6)
776
+			'w' => array(
777
+				'js'     => '',
778
+				'moment' => 'd',
779
+			),
780
+			//day of year starting from 0 (0-365)
781
+			'z' => array(
782
+				'js'     => 'o',
783
+				'moment' => 'DDD' //note moment does not start with 0 so will need to modify by subtracting 1
784
+			),
785
+			// Week
786
+			//ISO-8601 week number of year (weeks starting on monday)
787
+			'W' => array(
788
+				'js'     => '',
789
+				'moment' => 'w',
790
+			),
791
+			// Month
792
+			// January...December
793
+			'F' => array(
794
+				'js'     => 'MM',
795
+				'moment' => 'MMMM',
796
+			),
797
+			//01...12
798
+			'm' => array(
799
+				'js'     => 'mm',
800
+				'moment' => 'MM',
801
+			),
802
+			//Jan...Dec
803
+			'M' => array(
804
+				'js'     => 'M',
805
+				'moment' => 'MMM',
806
+			),
807
+			//1-12
808
+			'n' => array(
809
+				'js'     => 'm',
810
+				'moment' => 'M',
811
+			),
812
+			//number of days in given month
813
+			't' => array(
814
+				'js'     => '',
815
+				'moment' => '',
816
+			),
817
+			// Year
818
+			//whether leap year or not 1/0
819
+			'L' => array(
820
+				'js'     => '',
821
+				'moment' => '',
822
+			),
823
+			//ISO-8601 year number
824
+			'o' => array(
825
+				'js'     => '',
826
+				'moment' => 'GGGG',
827
+			),
828
+			//1999...2003
829
+			'Y' => array(
830
+				'js'     => 'yy',
831
+				'moment' => 'YYYY',
832
+			),
833
+			//99...03
834
+			'y' => array(
835
+				'js'     => 'y',
836
+				'moment' => 'YY',
837
+			),
838
+			// Time
839
+			// am/pm
840
+			'a' => array(
841
+				'js'     => 'tt',
842
+				'moment' => 'a',
843
+			),
844
+			// AM/PM
845
+			'A' => array(
846
+				'js'     => 'TT',
847
+				'moment' => 'A',
848
+			),
849
+			// Swatch Internet Time?!?
850
+			'B' => array(
851
+				'js'     => '',
852
+				'moment' => '',
853
+			),
854
+			//1...12
855
+			'g' => array(
856
+				'js'     => 'h',
857
+				'moment' => 'h',
858
+			),
859
+			//0...23
860
+			'G' => array(
861
+				'js'     => 'H',
862
+				'moment' => 'H',
863
+			),
864
+			//01...12
865
+			'h' => array(
866
+				'js'     => 'hh',
867
+				'moment' => 'hh',
868
+			),
869
+			//00...23
870
+			'H' => array(
871
+				'js'     => 'HH',
872
+				'moment' => 'HH',
873
+			),
874
+			//00..59
875
+			'i' => array(
876
+				'js'     => 'mm',
877
+				'moment' => 'mm',
878
+			),
879
+			//seconds... 00...59
880
+			's' => array(
881
+				'js'     => 'ss',
882
+				'moment' => 'ss',
883
+			),
884
+			//microseconds
885
+			'u' => array(
886
+				'js'     => '',
887
+				'moment' => '',
888
+			),
889
+		);
890
+		$jquery_ui_format = "";
891
+		$moment_format    = "";
892
+		$escaping         = false;
893
+		for ($i = 0; $i < strlen($format_string); $i++) {
894
+			$char = $format_string[$i];
895
+			if ($char === '\\') { // PHP date format escaping character
896
+				$i++;
897
+				if ($escaping) {
898
+					$jquery_ui_format .= $format_string[$i];
899
+					$moment_format    .= $format_string[$i];
900
+				} else {
901
+					$jquery_ui_format .= '\'' . $format_string[$i];
902
+					$moment_format    .= $format_string[$i];
903
+				}
904
+				$escaping = true;
905
+			} else {
906
+				if ($escaping) {
907
+					$jquery_ui_format .= "'";
908
+					$moment_format    .= "'";
909
+					$escaping         = false;
910
+				}
911
+				if (isset($symbols_map[$char])) {
912
+					$jquery_ui_format .= $symbols_map[$char]['js'];
913
+					$moment_format    .= $symbols_map[$char]['moment'];
914
+				} else {
915
+					$jquery_ui_format .= $char;
916
+					$moment_format    .= $char;
917
+				}
918
+			}
919
+		}
920
+		return array('js' => $jquery_ui_format, 'moment' => $moment_format);
921
+	}
922
+
923
+
924
+	/**
925
+	 * This takes an incoming format string and validates it to ensure it will work fine with PHP.
926
+	 *
927
+	 * @param string $format_string   Incoming format string for php date().
928
+	 * @return mixed bool|array  If all is okay then TRUE is returned.  Otherwise an array of validation
929
+	 *                                errors is returned.  So for client code calling, check for is_array() to
930
+	 *                                indicate failed validations.
931
+	 */
932
+	public static function validate_format_string($format_string)
933
+	{
934
+		$error_msg = array();
935
+		//time format checks
936
+		switch (true) {
937
+			case   strpos($format_string, 'h') !== false  :
938
+			case   strpos($format_string, 'g') !== false :
939
+				/**
940
+				 * if the time string has a lowercase 'h' which == 12 hour time format and there
941
+				 * is not any ante meridiem format ('a' or 'A').  Then throw an error because its
942
+				 * too ambiguous and PHP won't be able to figure out whether 1 = 1pm or 1am.
943
+				 */
944
+				if (strpos(strtoupper($format_string), 'A') === false) {
945
+					$error_msg[] = __(
946
+						'There is a  time format for 12 hour time but no  "a" or "A" to indicate am/pm.  Without this distinction, PHP is unable to determine if a "1" for the hour value equals "1pm" or "1am".',
947
+						'event_espresso'
948
+					);
949
+				}
950
+				break;
951
+		}
952
+		return empty($error_msg) ? true : $error_msg;
953
+	}
954
+
955
+
956
+	/**
957
+	 *     If the the first date starts at midnight on one day, and the next date ends at midnight on the
958
+	 *     very next day then this method will return true.
959
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-16 00:00:00 then this function will return true.
960
+	 *    If $date_1 = 2015-12-15 03:00:00 and $date_2 = 2015-12_16 03:00:00 then this function will return false.
961
+	 *    If $date_1 = 2015-12-15 00:00:00 and $date_2 = 2015-12-15 00:00:00 then this function will return true.
962
+	 *
963
+	 * @param mixed $date_1
964
+	 * @param mixed $date_2
965
+	 * @return bool
966
+	 */
967
+	public static function dates_represent_one_24_hour_date($date_1, $date_2)
968
+	{
969
+
970
+		if (
971
+			(! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
972
+			|| ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00'
973
+				|| $date_2->format(
974
+					EE_Datetime_Field::mysql_time_format
975
+				) != '00:00:00')
976
+		) {
977
+			return false;
978
+		}
979
+		return $date_2->format('U') - $date_1->format('U') == 86400 ? true : false;
980
+	}
981
+
982
+
983
+	/**
984
+	 * This returns the appropriate query interval string that can be used in sql queries involving mysql Date
985
+	 * Functions.
986
+	 *
987
+	 * @param string $timezone_string    A timezone string in a valid format to instantiate a DateTimeZone object.
988
+	 * @param string $field_for_interval The Database field that is the interval is applied to in the query.
989
+	 * @return string
990
+	 */
991
+	public static function get_sql_query_interval_for_offset($timezone_string, $field_for_interval)
992
+	{
993
+		try {
994
+			/** need to account for timezone offset on the selects */
995
+			$DateTimeZone = new DateTimeZone($timezone_string);
996
+		} catch (Exception $e) {
997
+			$DateTimeZone = null;
998
+		}
999
+		/**
1000
+		 * Note get_option( 'gmt_offset') returns a value in hours, whereas DateTimeZone::getOffset returns values in seconds.
1001
+		 * Hence we do the calc for DateTimeZone::getOffset.
1002
+		 */
1003
+		$offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now')))
1004
+																  / HOUR_IN_SECONDS : get_option('gmt_offset');
1005
+		$query_interval = $offset < 0
1006
+			? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
1007
+			: 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
1008
+		return $query_interval;
1009
+	}
1010
+
1011
+
1012
+	/**
1013
+	 * Retrieves the site's default timezone and returns it formatted so it's ready for display
1014
+	 * to users. If you want to customize how its displayed feel free to fetch the 'timezone_string'
1015
+	 * and 'gmt_offset' WordPress options directly; or use the filter
1016
+	 * FHEE__EEH_DTT_Helper__get_timezone_string_for_display
1017
+	 * (although note that we remove any HTML that may be added)
1018
+	 *
1019
+	 * @return string
1020
+	 */
1021
+	public static function get_timezone_string_for_display()
1022
+	{
1023
+		$pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
1024
+		if (! empty($pretty_timezone)) {
1025
+			return esc_html($pretty_timezone);
1026
+		}
1027
+		$timezone_string = get_option('timezone_string');
1028
+		if ($timezone_string) {
1029
+			static $mo_loaded = false;
1030
+			// Load translations for continents and cities just like wp_timezone_choice does
1031
+			if (! $mo_loaded) {
1032
+				$locale = get_locale();
1033
+				$mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
1034
+				load_textdomain('continents-cities', $mofile);
1035
+				$mo_loaded = true;
1036
+			}
1037
+			//well that was easy.
1038
+			$parts = explode('/', $timezone_string);
1039
+			//remove the continent
1040
+			unset($parts[0]);
1041
+			$t_parts = array();
1042
+			foreach ($parts as $part) {
1043
+				$t_parts[] = translate(str_replace('_', ' ', $part), 'continents-cities');
1044
+			}
1045
+			return implode(' - ', $t_parts);
1046
+		}
1047
+		//they haven't set the timezone string, so let's return a string like "UTC+1"
1048
+		$gmt_offset = get_option('gmt_offset');
1049
+		if (intval($gmt_offset) >= 0) {
1050
+			$prefix = '+';
1051
+		} else {
1052
+			$prefix = '';
1053
+		}
1054
+		$parts = explode('.', (string)$gmt_offset);
1055
+		if (count($parts) === 1) {
1056
+			$parts[1] = '00';
1057
+		} else {
1058
+			//convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
1059
+			//to minutes, eg 30 or 15, respectively
1060
+			$hour_fraction = (float)('0.' . $parts[1]);
1061
+			$parts[1]      = (string)$hour_fraction * 60;
1062
+		}
1063
+		return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
1064
+	}
1065
+
1066
+
1067
+
1068
+	/**
1069
+	 * So PHP does this awesome thing where if you are trying to get a timestamp
1070
+	 * for a month using a string like "February" or "February 2017",
1071
+	 * and you don't specify a day as part of your string,
1072
+	 * then PHP will use whatever the current day of the month is.
1073
+	 * IF the current day of the month happens to be the 30th or 31st,
1074
+	 * then PHP gets really confused by a date like February 30,
1075
+	 * so instead of saying
1076
+	 *      "Hey February only has 28 days (this year)...
1077
+	 *      ...you must have meant the last day of the month!"
1078
+	 * PHP does the next most logical thing, and bumps the date up to March 2nd,
1079
+	 * because someone requesting February 30th obviously meant March 1st!
1080
+	 * The way around this is to always set the day to the first,
1081
+	 * so that the month will stay on the month you wanted.
1082
+	 * this method will add that "1" into your date regardless of the format.
1083
+	 *
1084
+	 * @param string $month
1085
+	 * @return string
1086
+	 */
1087
+	public static function first_of_month_timestamp($month = '')
1088
+	{
1089
+		$month = (string)$month;
1090
+		$year  = '';
1091
+		// check if the incoming string has a year in it or not
1092
+		if (preg_match('/\b\d{4}\b/', $month, $matches)) {
1093
+			$year = $matches[0];
1094
+			// ten remove that from the month string as well as any spaces
1095
+			$month = trim(str_replace($year, '', $month));
1096
+			// add a space before the year
1097
+			$year = " {$year}";
1098
+		}
1099
+		// return timestamp for something like "February 1 2017"
1100
+		return strtotime("{$month} 1{$year}");
1101
+	}
1102
+
1103
+
1104
+	/**
1105
+	 * This simply returns the timestamp for tomorrow (midnight next day) in this sites timezone.  So it may be midnight
1106
+	 * for this sites timezone, but the timestamp could be some other time GMT.
1107
+	 */
1108
+	public static function tomorrow()
1109
+	{
1110
+		//The multiplication of -1 ensures that we switch positive offsets to negative and negative offsets to positive
1111
+		//before adding to the timestamp.  Why? Because we want tomorrow to be for midnight the next day in THIS timezone
1112
+		//not an offset from midnight in UTC.  So if we're starting with UTC 00:00:00, then we want to make sure the
1113
+		//final timestamp is equivalent to midnight in this timezone as represented in GMT.
1114
+		return strtotime('tomorrow') + (self::get_site_timezone_gmt_offset() * -1);
1115
+	}
1116
+
1117
+
1118
+	/**
1119
+	 * **
1120
+	 * Gives a nicely-formatted list of timezone strings.
1121
+	 * Copied from the core wp function by the same name so we could customize to remove UTC offsets.
1122
+	 *
1123
+	 * @since     4.9.40.rc.008
1124
+	 * @staticvar bool $mo_loaded
1125
+	 * @staticvar string $locale_loaded
1126
+	 * @param string $selected_zone Selected timezone.
1127
+	 * @param string $locale        Optional. Locale to load the timezones in. Default current site locale.
1128
+	 * @return string
1129
+	 */
1130
+	public static function wp_timezone_choice($selected_zone, $locale = null)
1131
+	{
1132
+		static $mo_loaded = false, $locale_loaded = null;
1133
+		$continents = array(
1134
+			'Africa',
1135
+			'America',
1136
+			'Antarctica',
1137
+			'Arctic',
1138
+			'Asia',
1139
+			'Atlantic',
1140
+			'Australia',
1141
+			'Europe',
1142
+			'Indian',
1143
+			'Pacific',
1144
+		);
1145
+		// Load translations for continents and cities.
1146
+		if (! $mo_loaded || $locale !== $locale_loaded) {
1147
+			$locale_loaded = $locale ? $locale : get_locale();
1148
+			$mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
1149
+			unload_textdomain('continents-cities');
1150
+			load_textdomain('continents-cities', $mofile);
1151
+			$mo_loaded = true;
1152
+		}
1153
+		$zonen = array();
1154
+		foreach (timezone_identifiers_list() as $zone) {
1155
+			$zone = explode('/', $zone);
1156
+			if (! in_array($zone[0], $continents)) {
1157
+				continue;
1158
+			}
1159
+			// This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
1160
+			$exists    = array(
1161
+				0 => (isset($zone[0]) && $zone[0]),
1162
+				1 => (isset($zone[1]) && $zone[1]),
1163
+				2 => (isset($zone[2]) && $zone[2]),
1164
+			);
1165
+			$exists[3] = ($exists[0] && 'Etc' !== $zone[0]);
1166
+			$exists[4] = ($exists[1] && $exists[3]);
1167
+			$exists[5] = ($exists[2] && $exists[3]);
1168
+			$zonen[] = array(
1169
+				'continent'   => ($exists[0] ? $zone[0] : ''),
1170
+				'city'        => ($exists[1] ? $zone[1] : ''),
1171
+				'subcity'     => ($exists[2] ? $zone[2] : ''),
1172
+				't_continent' => ($exists[3] ? translate(str_replace('_', ' ', $zone[0]), 'continents-cities') : ''),
1173
+				't_city'      => ($exists[4] ? translate(str_replace('_', ' ', $zone[1]), 'continents-cities') : ''),
1174
+				't_subcity'   => ($exists[5] ? translate(str_replace('_', ' ', $zone[2]), 'continents-cities') : ''),
1175
+			);
1176
+		}
1177
+		usort($zonen, '_wp_timezone_choice_usort_callback');
1178
+		$structure = array();
1179
+		if (empty($selected_zone)) {
1180
+			$structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>';
1181
+		}
1182
+		foreach ($zonen as $key => $zone) {
1183
+			// Build value in an array to join later
1184
+			$value = array($zone['continent']);
1185
+			if (empty($zone['city'])) {
1186
+				// It's at the continent level (generally won't happen)
1187
+				$display = $zone['t_continent'];
1188
+			} else {
1189
+				// It's inside a continent group
1190
+				// Continent optgroup
1191
+				if (! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
1192
+					$label       = $zone['t_continent'];
1193
+					$structure[] = '<optgroup label="' . esc_attr($label) . '">';
1194
+				}
1195
+				// Add the city to the value
1196
+				$value[] = $zone['city'];
1197
+				$display = $zone['t_city'];
1198
+				if (! empty($zone['subcity'])) {
1199
+					// Add the subcity to the value
1200
+					$value[] = $zone['subcity'];
1201
+					$display .= ' - ' . $zone['t_subcity'];
1202
+				}
1203
+			}
1204
+			// Build the value
1205
+			$value    = join('/', $value);
1206
+			$selected = '';
1207
+			if ($value === $selected_zone) {
1208
+				$selected = 'selected="selected" ';
1209
+			}
1210
+			$structure[] = '<option '
1211
+						   . $selected
1212
+						   . 'value="'
1213
+						   . esc_attr($value)
1214
+						   . '">'
1215
+						   . esc_html($display)
1216
+						   . "</option>";
1217
+			// Close continent optgroup
1218
+			if (! empty($zone['city'])
1219
+				&& (! isset($zonen[$key + 1])
1220
+					|| (isset($zonen[$key + 1])
1221
+						&& $zonen[$key
1222
+								  + 1]['continent']
1223
+						   !== $zone['continent']))) {
1224
+				$structure[] = '</optgroup>';
1225
+			}
1226
+		}
1227
+		return join("\n", $structure);
1228
+	}
1229
+
1230
+
1231
+	/**
1232
+	 * Shim for the WP function `get_user_locale` that was added in WordPress 4.7.0
1233
+	 *
1234
+	 * @param int|WP_User $user_id
1235
+	 * @return string
1236
+	 */
1237
+	public static function get_user_locale($user_id = 0)
1238
+	{
1239
+		if (function_exists('get_user_locale')) {
1240
+			return get_user_locale($user_id);
1241
+		}
1242
+		return get_locale();
1243
+	}
1244 1244
 
1245 1245
 }// end class EEH_DTT_Helper
Please login to merge, or discard this patch.
Spacing   +52 added lines, -52 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
             new DateTimeZone($timezone_string);
78 78
         } catch (Exception $e) {
79 79
             // sometimes we take exception to exceptions
80
-            if (! $throw_error) {
80
+            if ( ! $throw_error) {
81 81
                 return false;
82 82
             }
83 83
             throw new EE_Error(
@@ -116,9 +116,9 @@  discard block
 block discarded – undo
116 116
             }
117 117
         }
118 118
         $gmt_offset = $gmt_offset !== '' ? $gmt_offset : get_option('gmt_offset');
119
-        $gmt_offset = (float)$gmt_offset;
119
+        $gmt_offset = (float) $gmt_offset;
120 120
         //if $gmt_offset is 0, then just return UTC
121
-        if ($gmt_offset === (float)0) {
121
+        if ($gmt_offset === (float) 0) {
122 122
             return $timezone_string;
123 123
         }
124 124
         if ($gmt_offset !== '') {
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
             }
163 163
         }
164 164
         $offset = get_option('gmt_offset');
165
-        return (int)($offset * HOUR_IN_SECONDS);
165
+        return (int) ($offset * HOUR_IN_SECONDS);
166 166
     }
167 167
 
168 168
 
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
     public static function adjust_invalid_gmt_offsets($gmt_offset = 0)
180 180
     {
181 181
         //make sure $gmt_offset is int
182
-        $gmt_offset = (int)$gmt_offset;
182
+        $gmt_offset = (int) $gmt_offset;
183 183
         switch ($gmt_offset) {
184 184
             //-12
185 185
             case -43200:
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
     public static function get_timezone_offset(DateTimeZone $date_time_zone, $time = null)
356 356
     {
357 357
         $transitions = self::get_timezone_transitions($date_time_zone, $time);
358
-        if (! isset($transitions['offset'])) {
358
+        if ( ! isset($transitions['offset'])) {
359 359
             throw new DomainException();
360 360
         }
361 361
         return $transitions['offset'];
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
     public static function timezone_select_input($timezone_string = '')
370 370
     {
371 371
         // get WP date time format
372
-        $datetime_format = get_option('date_format') . ' ' . get_option('time_format');
372
+        $datetime_format = get_option('date_format').' '.get_option('time_format');
373 373
         // if passed a value, then use that, else get WP option
374 374
         $timezone_string = ! empty($timezone_string) ? $timezone_string : get_option('timezone_string');
375 375
         // check if the timezone is valid but don't throw any errors if it isn't
@@ -380,9 +380,9 @@  discard block
 block discarded – undo
380 380
             // Create a UTC+- zone if no timezone string exists
381 381
             $check_zone_info = false;
382 382
             if ($gmt_offset > 0) {
383
-                $timezone_string = 'UTC+' . $gmt_offset;
383
+                $timezone_string = 'UTC+'.$gmt_offset;
384 384
             } elseif ($gmt_offset < 0) {
385
-                $timezone_string = 'UTC' . $gmt_offset;
385
+                $timezone_string = 'UTC'.$gmt_offset;
386 386
             } else {
387 387
                 $timezone_string = 'UTC';
388 388
             }
@@ -404,11 +404,11 @@  discard block
 block discarded – undo
404 404
                 __('%1$sUTC%2$s time is %3$s'),
405 405
                 '<abbr title="Coordinated Universal Time">',
406 406
                 '</abbr>',
407
-                '<code>' . date_i18n($datetime_format, false, true) . '</code>'
407
+                '<code>'.date_i18n($datetime_format, false, true).'</code>'
408 408
             );
409 409
             ?></span>
410
-        <?php if (! empty($timezone_string) || ! empty($gmt_offset)) : ?>
411
-        <br/><span><?php printf(__('Local time is %1$s'), '<code>' . date_i18n($datetime_format) . '</code>'); ?></span>
410
+        <?php if ( ! empty($timezone_string) || ! empty($gmt_offset)) : ?>
411
+        <br/><span><?php printf(__('Local time is %1$s'), '<code>'.date_i18n($datetime_format).'</code>'); ?></span>
412 412
     <?php endif; ?>
413 413
 
414 414
         <?php if ($check_zone_info && $timezone_string) : ?>
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
                     // Add the difference between the current offset and the new offset to ts to get the correct transition time from date_i18n().
448 448
                     printf(
449 449
                         $message,
450
-                        '<code >' . date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])) . '</code >'
450
+                        '<code >'.date_i18n($datetime_format, $tr['ts'] + ($tz_offset - $tr['offset'])).'</code >'
451 451
                     );
452 452
                 } else {
453 453
                     _e('This timezone does not observe daylight saving time.');
@@ -476,12 +476,12 @@  discard block
 block discarded – undo
476 476
      */
477 477
     public static function get_timestamp_with_offset($unix_timestamp = 0, $timezone_string = '')
478 478
     {
479
-        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int)$unix_timestamp;
479
+        $unix_timestamp  = $unix_timestamp === 0 ? time() : (int) $unix_timestamp;
480 480
         $timezone_string = self::get_valid_timezone_string($timezone_string);
481 481
         $TimeZone        = new DateTimeZone($timezone_string);
482
-        $DateTime = new DateTime('@' . $unix_timestamp, $TimeZone);
482
+        $DateTime = new DateTime('@'.$unix_timestamp, $TimeZone);
483 483
         $offset   = timezone_offset_get($TimeZone, $DateTime);
484
-        return (int)$DateTime->format('U') + (int)$offset;
484
+        return (int) $DateTime->format('U') + (int) $offset;
485 485
     }
486 486
 
487 487
 
@@ -564,7 +564,7 @@  discard block
 block discarded – undo
564 564
      */
565 565
     protected static function _modify_datetime_object(DateTime $DateTime, $period = 'years', $value = 1, $operand = '+')
566 566
     {
567
-        if (! $DateTime instanceof DateTime) {
567
+        if ( ! $DateTime instanceof DateTime) {
568 568
             throw new EE_Error(
569 569
                 sprintf(
570 570
                     __('Expected a PHP DateTime object, but instead received %1$s', 'event_espresso'),
@@ -574,25 +574,25 @@  discard block
 block discarded – undo
574 574
         }
575 575
         switch ($period) {
576 576
             case 'years' :
577
-                $value = 'P' . $value . 'Y';
577
+                $value = 'P'.$value.'Y';
578 578
                 break;
579 579
             case 'months' :
580
-                $value = 'P' . $value . 'M';
580
+                $value = 'P'.$value.'M';
581 581
                 break;
582 582
             case 'weeks' :
583
-                $value = 'P' . $value . 'W';
583
+                $value = 'P'.$value.'W';
584 584
                 break;
585 585
             case 'days' :
586
-                $value = 'P' . $value . 'D';
586
+                $value = 'P'.$value.'D';
587 587
                 break;
588 588
             case 'hours' :
589
-                $value = 'PT' . $value . 'H';
589
+                $value = 'PT'.$value.'H';
590 590
                 break;
591 591
             case 'minutes' :
592
-                $value = 'PT' . $value . 'M';
592
+                $value = 'PT'.$value.'M';
593 593
                 break;
594 594
             case 'seconds' :
595
-                $value = 'PT' . $value . 'S';
595
+                $value = 'PT'.$value.'S';
596 596
                 break;
597 597
         }
598 598
         switch ($operand) {
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
      */
621 621
     protected static function _modify_timestamp($timestamp, $period = 'years', $value = 1, $operand = '+')
622 622
     {
623
-        if (! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
623
+        if ( ! preg_match(EE_Datetime_Field::unix_timestamp_regex, $timestamp)) {
624 624
             throw new EE_Error(
625 625
                 sprintf(
626 626
                     __('Expected a Unix timestamp, but instead received %1$s', 'event_espresso'),
@@ -721,7 +721,7 @@  discard block
 block discarded – undo
721 721
                 'date' => $date_format['js'],
722 722
                 'time' => $time_format['js'],
723 723
             ),
724
-            'moment' => $date_format['moment'] . ' ' . $time_format['moment'],
724
+            'moment' => $date_format['moment'].' '.$time_format['moment'],
725 725
         );
726 726
     }
727 727
 
@@ -740,7 +740,7 @@  discard block
 block discarded – undo
740 740
          *
741 741
          * @var array
742 742
          */
743
-        $symbols_map      = array(
743
+        $symbols_map = array(
744 744
             // Day
745 745
             //01
746 746
             'd' => array(
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
                     $jquery_ui_format .= $format_string[$i];
899 899
                     $moment_format    .= $format_string[$i];
900 900
                 } else {
901
-                    $jquery_ui_format .= '\'' . $format_string[$i];
901
+                    $jquery_ui_format .= '\''.$format_string[$i];
902 902
                     $moment_format    .= $format_string[$i];
903 903
                 }
904 904
                 $escaping = true;
@@ -906,7 +906,7 @@  discard block
 block discarded – undo
906 906
                 if ($escaping) {
907 907
                     $jquery_ui_format .= "'";
908 908
                     $moment_format    .= "'";
909
-                    $escaping         = false;
909
+                    $escaping = false;
910 910
                 }
911 911
                 if (isset($symbols_map[$char])) {
912 912
                     $jquery_ui_format .= $symbols_map[$char]['js'];
@@ -968,7 +968,7 @@  discard block
 block discarded – undo
968 968
     {
969 969
 
970 970
         if (
971
-            (! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
971
+            ( ! $date_1 instanceof DateTime || ! $date_2 instanceof DateTime)
972 972
             || ($date_1->format(EE_Datetime_Field::mysql_time_format) != '00:00:00'
973 973
                 || $date_2->format(
974 974
                     EE_Datetime_Field::mysql_time_format
@@ -1003,8 +1003,8 @@  discard block
 block discarded – undo
1003 1003
         $offset         = $DateTimeZone instanceof DateTimeZone ? ($DateTimeZone->getOffset(new DateTime('now')))
1004 1004
                                                                   / HOUR_IN_SECONDS : get_option('gmt_offset');
1005 1005
         $query_interval = $offset < 0
1006
-            ? 'DATE_SUB(' . $field_for_interval . ', INTERVAL ' . $offset * -1 . ' HOUR)'
1007
-            : 'DATE_ADD(' . $field_for_interval . ', INTERVAL ' . $offset . ' HOUR)';
1006
+            ? 'DATE_SUB('.$field_for_interval.', INTERVAL '.$offset * -1.' HOUR)'
1007
+            : 'DATE_ADD('.$field_for_interval.', INTERVAL '.$offset.' HOUR)';
1008 1008
         return $query_interval;
1009 1009
     }
1010 1010
 
@@ -1021,16 +1021,16 @@  discard block
 block discarded – undo
1021 1021
     public static function get_timezone_string_for_display()
1022 1022
     {
1023 1023
         $pretty_timezone = apply_filters('FHEE__EEH_DTT_Helper__get_timezone_string_for_display', '');
1024
-        if (! empty($pretty_timezone)) {
1024
+        if ( ! empty($pretty_timezone)) {
1025 1025
             return esc_html($pretty_timezone);
1026 1026
         }
1027 1027
         $timezone_string = get_option('timezone_string');
1028 1028
         if ($timezone_string) {
1029 1029
             static $mo_loaded = false;
1030 1030
             // Load translations for continents and cities just like wp_timezone_choice does
1031
-            if (! $mo_loaded) {
1031
+            if ( ! $mo_loaded) {
1032 1032
                 $locale = get_locale();
1033
-                $mofile = WP_LANG_DIR . '/continents-cities-' . $locale . '.mo';
1033
+                $mofile = WP_LANG_DIR.'/continents-cities-'.$locale.'.mo';
1034 1034
                 load_textdomain('continents-cities', $mofile);
1035 1035
                 $mo_loaded = true;
1036 1036
             }
@@ -1051,16 +1051,16 @@  discard block
 block discarded – undo
1051 1051
         } else {
1052 1052
             $prefix = '';
1053 1053
         }
1054
-        $parts = explode('.', (string)$gmt_offset);
1054
+        $parts = explode('.', (string) $gmt_offset);
1055 1055
         if (count($parts) === 1) {
1056 1056
             $parts[1] = '00';
1057 1057
         } else {
1058 1058
             //convert the part after the decimal, eg "5" (from x.5) or "25" (from x.25)
1059 1059
             //to minutes, eg 30 or 15, respectively
1060
-            $hour_fraction = (float)('0.' . $parts[1]);
1061
-            $parts[1]      = (string)$hour_fraction * 60;
1060
+            $hour_fraction = (float) ('0.'.$parts[1]);
1061
+            $parts[1]      = (string) $hour_fraction * 60;
1062 1062
         }
1063
-        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix . implode(':', $parts));
1063
+        return sprintf(__('UTC%1$s', 'event_espresso'), $prefix.implode(':', $parts));
1064 1064
     }
1065 1065
 
1066 1066
 
@@ -1086,7 +1086,7 @@  discard block
 block discarded – undo
1086 1086
      */
1087 1087
     public static function first_of_month_timestamp($month = '')
1088 1088
     {
1089
-        $month = (string)$month;
1089
+        $month = (string) $month;
1090 1090
         $year  = '';
1091 1091
         // check if the incoming string has a year in it or not
1092 1092
         if (preg_match('/\b\d{4}\b/', $month, $matches)) {
@@ -1143,9 +1143,9 @@  discard block
 block discarded – undo
1143 1143
             'Pacific',
1144 1144
         );
1145 1145
         // Load translations for continents and cities.
1146
-        if (! $mo_loaded || $locale !== $locale_loaded) {
1146
+        if ( ! $mo_loaded || $locale !== $locale_loaded) {
1147 1147
             $locale_loaded = $locale ? $locale : get_locale();
1148
-            $mofile        = WP_LANG_DIR . '/continents-cities-' . $locale_loaded . '.mo';
1148
+            $mofile        = WP_LANG_DIR.'/continents-cities-'.$locale_loaded.'.mo';
1149 1149
             unload_textdomain('continents-cities');
1150 1150
             load_textdomain('continents-cities', $mofile);
1151 1151
             $mo_loaded = true;
@@ -1153,11 +1153,11 @@  discard block
 block discarded – undo
1153 1153
         $zonen = array();
1154 1154
         foreach (timezone_identifiers_list() as $zone) {
1155 1155
             $zone = explode('/', $zone);
1156
-            if (! in_array($zone[0], $continents)) {
1156
+            if ( ! in_array($zone[0], $continents)) {
1157 1157
                 continue;
1158 1158
             }
1159 1159
             // This determines what gets set and translated - we don't translate Etc/* strings here, they are done later
1160
-            $exists    = array(
1160
+            $exists = array(
1161 1161
                 0 => (isset($zone[0]) && $zone[0]),
1162 1162
                 1 => (isset($zone[1]) && $zone[1]),
1163 1163
                 2 => (isset($zone[2]) && $zone[2]),
@@ -1177,7 +1177,7 @@  discard block
 block discarded – undo
1177 1177
         usort($zonen, '_wp_timezone_choice_usort_callback');
1178 1178
         $structure = array();
1179 1179
         if (empty($selected_zone)) {
1180
-            $structure[] = '<option selected="selected" value="">' . __('Select a city') . '</option>';
1180
+            $structure[] = '<option selected="selected" value="">'.__('Select a city').'</option>';
1181 1181
         }
1182 1182
         foreach ($zonen as $key => $zone) {
1183 1183
             // Build value in an array to join later
@@ -1188,17 +1188,17 @@  discard block
 block discarded – undo
1188 1188
             } else {
1189 1189
                 // It's inside a continent group
1190 1190
                 // Continent optgroup
1191
-                if (! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
1191
+                if ( ! isset($zonen[$key - 1]) || $zonen[$key - 1]['continent'] !== $zone['continent']) {
1192 1192
                     $label       = $zone['t_continent'];
1193
-                    $structure[] = '<optgroup label="' . esc_attr($label) . '">';
1193
+                    $structure[] = '<optgroup label="'.esc_attr($label).'">';
1194 1194
                 }
1195 1195
                 // Add the city to the value
1196 1196
                 $value[] = $zone['city'];
1197 1197
                 $display = $zone['t_city'];
1198
-                if (! empty($zone['subcity'])) {
1198
+                if ( ! empty($zone['subcity'])) {
1199 1199
                     // Add the subcity to the value
1200 1200
                     $value[] = $zone['subcity'];
1201
-                    $display .= ' - ' . $zone['t_subcity'];
1201
+                    $display .= ' - '.$zone['t_subcity'];
1202 1202
                 }
1203 1203
             }
1204 1204
             // Build the value
@@ -1215,8 +1215,8 @@  discard block
 block discarded – undo
1215 1215
                            . esc_html($display)
1216 1216
                            . "</option>";
1217 1217
             // Close continent optgroup
1218
-            if (! empty($zone['city'])
1219
-                && (! isset($zonen[$key + 1])
1218
+            if ( ! empty($zone['city'])
1219
+                && ( ! isset($zonen[$key + 1])
1220 1220
                     || (isset($zonen[$key + 1])
1221 1221
                         && $zonen[$key
1222 1222
                                   + 1]['continent']
Please login to merge, or discard this patch.