Completed
Branch BUG-10246-use-wp-json-encode (aacd81)
by
unknown
23:44 queued 12:52
created
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 1 patch
Indentation   +407 added lines, -407 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -17,407 +17,407 @@  discard block
 block discarded – undo
17 17
 class EE_Payment_Method_Manager
18 18
 {
19 19
 
20
-    /**
21
-     *    instance of the EE_Payment_Method_Manager object
22
-     *
23
-     * @var    $_instance
24
-     * @access    private
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var array keys are classnames without 'EE_PMT_', values are their filepaths
30
-     */
31
-    protected $_payment_method_types = array();
32
-
33
-
34
-
35
-    /**
36
-     * @singleton method used to instantiate class object
37
-     * @access    public
38
-     * @return EE_Payment_Method_Manager instance
39
-     */
40
-    public static function instance()
41
-    {
42
-        // check if class object is instantiated, and instantiated properly
43
-        if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
44
-            self::$_instance = new self();
45
-        }
46
-        EE_Registry::instance()->load_lib('PMT_Base');
47
-        return self::$_instance;
48
-    }
49
-
50
-
51
-
52
-    /**
53
-     * Resets the instance and returns a new one
54
-     *
55
-     * @return EE_Payment_Method_Manager
56
-     */
57
-    public static function reset()
58
-    {
59
-        self::$_instance = null;
60
-        return self::instance();
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * If necessary, re-register payment methods
67
-     *
68
-     * @param boolean $force_recheck whether to recheck for payment method types,
69
-     *                               or just re-use the PMTs we found last time we checked during this request (if
70
-     *                               we have not yet checked during this request, then we need to check anyways)
71
-     */
72
-    public function maybe_register_payment_methods($force_recheck = false)
73
-    {
74
-        if ( ! $this->_payment_method_types || $force_recheck) {
75
-            $this->_register_payment_methods();
76
-            //if in admin lets ensure caps are set.
77
-            if (is_admin()) {
78
-                add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
79
-                EE_Registry::instance()->CAP->init_caps();
80
-            }
81
-        }
82
-    }
83
-
84
-
85
-
86
-    /**
87
-     *        register_payment_methods
88
-     *
89
-     * @return array
90
-     */
91
-    protected function _register_payment_methods()
92
-    {
93
-        // grab list of installed modules
94
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
95
-        // filter list of modules to register
96
-        $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
97
-            $pm_to_register);
98
-        // loop through folders
99
-        foreach ($pm_to_register as $pm_path) {
100
-            $this->register_payment_method($pm_path);
101
-        }
102
-        do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
103
-        // filter list of installed modules
104
-        //keep them organized alphabetically by the payment method type's name
105
-        ksort($this->_payment_method_types);
106
-        return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
107
-            $this->_payment_method_types);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     *    register_payment_method- makes core aware of this payment method
114
-     *
115
-     * @access public
116
-     * @param string $payment_method_path - full path up to and including payment method folder
117
-     * @return boolean
118
-     */
119
-    public function register_payment_method($payment_method_path = '')
120
-    {
121
-        do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
122
-        $module_ext = '.pm.php';
123
-        // make all separators match
124
-        $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
125
-        // grab and sanitize module name
126
-        $module_dir = basename($payment_method_path);
127
-        // create classname from module directory name
128
-        $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
129
-        // add class prefix
130
-        $module_class = 'EE_PMT_' . $module;
131
-        // does the module exist ?
132
-        if ( ! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
133
-            $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.',
134
-                'event_espresso'), $module);
135
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
136
-            return false;
137
-        }
138
-        if (WP_DEBUG === true) {
139
-            EEH_Debug_Tools::instance()->start_timer();
140
-        }
141
-        // load the module class file
142
-        require_once($payment_method_path . DS . $module_class . $module_ext);
143
-        if (WP_DEBUG === true) {
144
-            EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class");
145
-        }
146
-        // verify that class exists
147
-        if ( ! class_exists($module_class)) {
148
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
149
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
150
-            return false;
151
-        }
152
-        // add to array of registered modules
153
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
154
-        return true;
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     * Checks if a payment method has been registered, and if so includes it
161
-     *
162
-     * @param string  $payment_method_name like 'Paypal_Pro', (ie classname without the prefix 'EEPM_')
163
-     * @param boolean $force_recheck       whether to force re-checking for new payment method types
164
-     * @return boolean
165
-     */
166
-    public function payment_method_type_exists($payment_method_name, $force_recheck = false)
167
-    {
168
-        if (
169
-            $force_recheck
170
-            || ! is_array($this->_payment_method_types)
171
-            || ! isset($this->_payment_method_types[$payment_method_name])
172
-        ) {
173
-            $this->maybe_register_payment_methods($force_recheck);
174
-        }
175
-        if (isset($this->_payment_method_types[$payment_method_name])) {
176
-            require_once($this->_payment_method_types[$payment_method_name]);
177
-            return true;
178
-        } else {
179
-            return false;
180
-        }
181
-    }
182
-
183
-
184
-
185
-    /**
186
-     * Returns all the classnames of the various payment method types
187
-     *
188
-     * @param boolean $with_prefixes TRUE: get payment method type classnames; false just their 'names'
189
-     *                               (what you'd find in wp_esp_payment_method.PMD_type)
190
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
191
-     * @return array
192
-     */
193
-    public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
194
-    {
195
-        $this->maybe_register_payment_methods($force_recheck);
196
-        if ($with_prefixes) {
197
-            $classnames = array_keys($this->_payment_method_types);
198
-            $payment_methods = array();
199
-            foreach ($classnames as $classname) {
200
-                $payment_methods[] = $this->payment_method_class_from_type($classname);
201
-            }
202
-            return $payment_methods;
203
-        } else {
204
-            return array_keys($this->_payment_method_types);
205
-        }
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * Gets an object of each payment method type, none of which are bound to a
212
-     * payment method instance
213
-     *
214
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
215
-     * @return EE_PMT_Base[]
216
-     */
217
-    public function payment_method_types($force_recheck = false)
218
-    {
219
-        $this->maybe_register_payment_methods($force_recheck);
220
-        $pmt_objs = array();
221
-        foreach ($this->payment_method_type_names(true) as $classname) {
222
-            $pmt_objs[] = new $classname;
223
-        }
224
-        return $pmt_objs;
225
-    }
226
-
227
-
228
-
229
-    /**
230
-     * Changes the payment method's classname into the payment method type's name
231
-     * (as used on the payment method's table's PMD_type field)
232
-     *
233
-     * @param string $classname
234
-     * @return string
235
-     */
236
-    public function payment_method_type_sans_class_prefix($classname)
237
-    {
238
-        return str_replace("EE_PMT_", "", $classname);
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * Does the opposite of payment-method_type_sans_prefix
245
-     *
246
-     * @param string $type
247
-     * @return string
248
-     */
249
-    public function payment_method_class_from_type($type)
250
-    {
251
-        $this->maybe_register_payment_methods();
252
-        return "EE_PMT_" . $type;
253
-    }
254
-
255
-
256
-
257
-    /**
258
-     * Activates a payment method of the given type.
259
-     *
260
-     * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
261
-     * @return \EE_Payment_Method
262
-     * @throws \EE_Error
263
-     */
264
-    public function activate_a_payment_method_of_type($payment_method_type)
265
-    {
266
-        $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
267
-        if ( ! $payment_method instanceof EE_Payment_Method) {
268
-            $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
269
-            if (class_exists($pm_type_class)) {
270
-                /** @var $pm_type_obj EE_PMT_Base */
271
-                $pm_type_obj = new $pm_type_class;
272
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
273
-                if ( ! $payment_method) {
274
-                    $payment_method = $this->create_payment_method_of_type($pm_type_obj);
275
-                }
276
-                $payment_method->set_type($payment_method_type);
277
-                $this->initialize_payment_method($payment_method);
278
-            } else {
279
-                throw new EE_Error(
280
-                    sprintf(
281
-                        __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'),
282
-                        $pm_type_class)
283
-                );
284
-            }
285
-        }
286
-        $payment_method->set_active();
287
-        $payment_method->save();
288
-        $this->set_usable_currencies_on_payment_method($payment_method);
289
-        if ($payment_method->type() === 'Invoice') {
290
-            /** @type EE_Message_Resource_Manager $message_resource_manager */
291
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
292
-            $message_resource_manager->ensure_message_type_is_active('invoice', 'html');
293
-            $message_resource_manager->ensure_messenger_is_active('pdf');
294
-            EE_Error::add_persistent_admin_notice(
295
-                'invoice_pm_requirements_notice',
296
-                sprintf(
297
-                    __('The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
298
-                        'event_espresso'),
299
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
300
-                    '</a>'
301
-                ),
302
-                true
303
-            );
304
-        }
305
-        return $payment_method;
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * Creates a payment method of the specified type. Does not save it.
312
-     *
313
-     * @global WP_User    $current_user
314
-     * @param EE_PMT_Base $pm_type_obj
315
-     * @return EE_Payment_Method
316
-     * @throws \EE_Error
317
-     */
318
-    public function create_payment_method_of_type($pm_type_obj)
319
-    {
320
-        global $current_user;
321
-        $payment_method = EE_Payment_Method::new_instance(
322
-            array(
323
-                'PMD_type'       => $pm_type_obj->system_name(),
324
-                'PMD_name'       => $pm_type_obj->pretty_name(),
325
-                'PMD_admin_name' => $pm_type_obj->pretty_name(),
326
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
327
-                'PMD_wp_user'    => $current_user->ID,
328
-                'PMD_order'      => EEM_Payment_Method::instance()->count(
329
-                        array(array('PMD_type' => array('!=', 'Admin_Only')))
330
-                    ) * 10,
331
-            )
332
-        );
333
-        return $payment_method;
334
-    }
335
-
336
-
337
-
338
-    /**
339
-     * Sets the initial payment method properties (including extra meta)
340
-     *
341
-     * @param EE_Payment_Method $payment_method
342
-     * @return EE_Payment_Method
343
-     * @throws \EE_Error
344
-     */
345
-    public function initialize_payment_method($payment_method)
346
-    {
347
-        $pm_type_obj = $payment_method->type_obj();
348
-        $payment_method->set_description($pm_type_obj->default_description());
349
-        if ( ! $payment_method->button_url()) {
350
-            $payment_method->set_button_url($pm_type_obj->default_button_url());
351
-        }
352
-        //now add setup its default extra meta properties
353
-        $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
354
-        if ( ! empty($extra_metas)) {
355
-            //verify the payment method has an ID before adding extra meta
356
-            if ( ! $payment_method->ID()) {
357
-                $payment_method->save();
358
-            }
359
-            foreach ($extra_metas as $meta_name => $input) {
360
-                $payment_method->update_extra_meta($meta_name, $input->raw_value());
361
-            }
362
-        }
363
-        return $payment_method;
364
-    }
365
-
366
-
367
-
368
-    /**
369
-     * Makes sure the payment method is related to the specified payment method
370
-     *
371
-     * @param EE_Payment_Method $payment_method
372
-     * @return EE_Payment_Method
373
-     * @throws \EE_Error
374
-     */
375
-    public function set_usable_currencies_on_payment_method($payment_method)
376
-    {
377
-        foreach ($payment_method->get_all_usable_currencies() as $currency_obj) {
378
-            $payment_method->_add_relation_to($currency_obj, 'Currency');
379
-        }
380
-        return $payment_method;
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * Deactivates a payment method of the given payment method slug.
387
-     *
388
-     * @param string $payment_method_slug The slug for the payment method to deactivate.
389
-     * @return int count of rows updated.
390
-     */
391
-    public function deactivate_payment_method($payment_method_slug)
392
-    {
393
-        EE_Log::instance()->log(
394
-            __FILE__,
395
-            __FUNCTION__,
396
-            sprintf(
397
-                __('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'),
398
-                $payment_method_slug
399
-            ),
400
-            'payment_method_change'
401
-        );
402
-        $count_updated = EEM_Payment_Method::instance()->update(
403
-            array('PMD_scope' => array()),
404
-            array(array('PMD_slug' => $payment_method_slug))
405
-        );
406
-        return $count_updated;
407
-    }
408
-
409
-
410
-
411
-    /**
412
-     * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method
413
-     * access caps.
414
-     *
415
-     * @param array $caps capabilities being filtered
416
-     * @return array
417
-     */
418
-    public function add_payment_method_caps($caps)
419
-    {
420
-        /* add dynamic caps from payment methods
20
+	/**
21
+	 *    instance of the EE_Payment_Method_Manager object
22
+	 *
23
+	 * @var    $_instance
24
+	 * @access    private
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var array keys are classnames without 'EE_PMT_', values are their filepaths
30
+	 */
31
+	protected $_payment_method_types = array();
32
+
33
+
34
+
35
+	/**
36
+	 * @singleton method used to instantiate class object
37
+	 * @access    public
38
+	 * @return EE_Payment_Method_Manager instance
39
+	 */
40
+	public static function instance()
41
+	{
42
+		// check if class object is instantiated, and instantiated properly
43
+		if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
44
+			self::$_instance = new self();
45
+		}
46
+		EE_Registry::instance()->load_lib('PMT_Base');
47
+		return self::$_instance;
48
+	}
49
+
50
+
51
+
52
+	/**
53
+	 * Resets the instance and returns a new one
54
+	 *
55
+	 * @return EE_Payment_Method_Manager
56
+	 */
57
+	public static function reset()
58
+	{
59
+		self::$_instance = null;
60
+		return self::instance();
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * If necessary, re-register payment methods
67
+	 *
68
+	 * @param boolean $force_recheck whether to recheck for payment method types,
69
+	 *                               or just re-use the PMTs we found last time we checked during this request (if
70
+	 *                               we have not yet checked during this request, then we need to check anyways)
71
+	 */
72
+	public function maybe_register_payment_methods($force_recheck = false)
73
+	{
74
+		if ( ! $this->_payment_method_types || $force_recheck) {
75
+			$this->_register_payment_methods();
76
+			//if in admin lets ensure caps are set.
77
+			if (is_admin()) {
78
+				add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
79
+				EE_Registry::instance()->CAP->init_caps();
80
+			}
81
+		}
82
+	}
83
+
84
+
85
+
86
+	/**
87
+	 *        register_payment_methods
88
+	 *
89
+	 * @return array
90
+	 */
91
+	protected function _register_payment_methods()
92
+	{
93
+		// grab list of installed modules
94
+		$pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
95
+		// filter list of modules to register
96
+		$pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
97
+			$pm_to_register);
98
+		// loop through folders
99
+		foreach ($pm_to_register as $pm_path) {
100
+			$this->register_payment_method($pm_path);
101
+		}
102
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
103
+		// filter list of installed modules
104
+		//keep them organized alphabetically by the payment method type's name
105
+		ksort($this->_payment_method_types);
106
+		return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
107
+			$this->_payment_method_types);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 *    register_payment_method- makes core aware of this payment method
114
+	 *
115
+	 * @access public
116
+	 * @param string $payment_method_path - full path up to and including payment method folder
117
+	 * @return boolean
118
+	 */
119
+	public function register_payment_method($payment_method_path = '')
120
+	{
121
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
122
+		$module_ext = '.pm.php';
123
+		// make all separators match
124
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
125
+		// grab and sanitize module name
126
+		$module_dir = basename($payment_method_path);
127
+		// create classname from module directory name
128
+		$module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
129
+		// add class prefix
130
+		$module_class = 'EE_PMT_' . $module;
131
+		// does the module exist ?
132
+		if ( ! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
133
+			$msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.',
134
+				'event_espresso'), $module);
135
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
136
+			return false;
137
+		}
138
+		if (WP_DEBUG === true) {
139
+			EEH_Debug_Tools::instance()->start_timer();
140
+		}
141
+		// load the module class file
142
+		require_once($payment_method_path . DS . $module_class . $module_ext);
143
+		if (WP_DEBUG === true) {
144
+			EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class");
145
+		}
146
+		// verify that class exists
147
+		if ( ! class_exists($module_class)) {
148
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
149
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
150
+			return false;
151
+		}
152
+		// add to array of registered modules
153
+		$this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
154
+		return true;
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 * Checks if a payment method has been registered, and if so includes it
161
+	 *
162
+	 * @param string  $payment_method_name like 'Paypal_Pro', (ie classname without the prefix 'EEPM_')
163
+	 * @param boolean $force_recheck       whether to force re-checking for new payment method types
164
+	 * @return boolean
165
+	 */
166
+	public function payment_method_type_exists($payment_method_name, $force_recheck = false)
167
+	{
168
+		if (
169
+			$force_recheck
170
+			|| ! is_array($this->_payment_method_types)
171
+			|| ! isset($this->_payment_method_types[$payment_method_name])
172
+		) {
173
+			$this->maybe_register_payment_methods($force_recheck);
174
+		}
175
+		if (isset($this->_payment_method_types[$payment_method_name])) {
176
+			require_once($this->_payment_method_types[$payment_method_name]);
177
+			return true;
178
+		} else {
179
+			return false;
180
+		}
181
+	}
182
+
183
+
184
+
185
+	/**
186
+	 * Returns all the classnames of the various payment method types
187
+	 *
188
+	 * @param boolean $with_prefixes TRUE: get payment method type classnames; false just their 'names'
189
+	 *                               (what you'd find in wp_esp_payment_method.PMD_type)
190
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
191
+	 * @return array
192
+	 */
193
+	public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
194
+	{
195
+		$this->maybe_register_payment_methods($force_recheck);
196
+		if ($with_prefixes) {
197
+			$classnames = array_keys($this->_payment_method_types);
198
+			$payment_methods = array();
199
+			foreach ($classnames as $classname) {
200
+				$payment_methods[] = $this->payment_method_class_from_type($classname);
201
+			}
202
+			return $payment_methods;
203
+		} else {
204
+			return array_keys($this->_payment_method_types);
205
+		}
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * Gets an object of each payment method type, none of which are bound to a
212
+	 * payment method instance
213
+	 *
214
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
215
+	 * @return EE_PMT_Base[]
216
+	 */
217
+	public function payment_method_types($force_recheck = false)
218
+	{
219
+		$this->maybe_register_payment_methods($force_recheck);
220
+		$pmt_objs = array();
221
+		foreach ($this->payment_method_type_names(true) as $classname) {
222
+			$pmt_objs[] = new $classname;
223
+		}
224
+		return $pmt_objs;
225
+	}
226
+
227
+
228
+
229
+	/**
230
+	 * Changes the payment method's classname into the payment method type's name
231
+	 * (as used on the payment method's table's PMD_type field)
232
+	 *
233
+	 * @param string $classname
234
+	 * @return string
235
+	 */
236
+	public function payment_method_type_sans_class_prefix($classname)
237
+	{
238
+		return str_replace("EE_PMT_", "", $classname);
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * Does the opposite of payment-method_type_sans_prefix
245
+	 *
246
+	 * @param string $type
247
+	 * @return string
248
+	 */
249
+	public function payment_method_class_from_type($type)
250
+	{
251
+		$this->maybe_register_payment_methods();
252
+		return "EE_PMT_" . $type;
253
+	}
254
+
255
+
256
+
257
+	/**
258
+	 * Activates a payment method of the given type.
259
+	 *
260
+	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
261
+	 * @return \EE_Payment_Method
262
+	 * @throws \EE_Error
263
+	 */
264
+	public function activate_a_payment_method_of_type($payment_method_type)
265
+	{
266
+		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
267
+		if ( ! $payment_method instanceof EE_Payment_Method) {
268
+			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
269
+			if (class_exists($pm_type_class)) {
270
+				/** @var $pm_type_obj EE_PMT_Base */
271
+				$pm_type_obj = new $pm_type_class;
272
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
273
+				if ( ! $payment_method) {
274
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
275
+				}
276
+				$payment_method->set_type($payment_method_type);
277
+				$this->initialize_payment_method($payment_method);
278
+			} else {
279
+				throw new EE_Error(
280
+					sprintf(
281
+						__('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'),
282
+						$pm_type_class)
283
+				);
284
+			}
285
+		}
286
+		$payment_method->set_active();
287
+		$payment_method->save();
288
+		$this->set_usable_currencies_on_payment_method($payment_method);
289
+		if ($payment_method->type() === 'Invoice') {
290
+			/** @type EE_Message_Resource_Manager $message_resource_manager */
291
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
292
+			$message_resource_manager->ensure_message_type_is_active('invoice', 'html');
293
+			$message_resource_manager->ensure_messenger_is_active('pdf');
294
+			EE_Error::add_persistent_admin_notice(
295
+				'invoice_pm_requirements_notice',
296
+				sprintf(
297
+					__('The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
298
+						'event_espresso'),
299
+					'<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
300
+					'</a>'
301
+				),
302
+				true
303
+			);
304
+		}
305
+		return $payment_method;
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * Creates a payment method of the specified type. Does not save it.
312
+	 *
313
+	 * @global WP_User    $current_user
314
+	 * @param EE_PMT_Base $pm_type_obj
315
+	 * @return EE_Payment_Method
316
+	 * @throws \EE_Error
317
+	 */
318
+	public function create_payment_method_of_type($pm_type_obj)
319
+	{
320
+		global $current_user;
321
+		$payment_method = EE_Payment_Method::new_instance(
322
+			array(
323
+				'PMD_type'       => $pm_type_obj->system_name(),
324
+				'PMD_name'       => $pm_type_obj->pretty_name(),
325
+				'PMD_admin_name' => $pm_type_obj->pretty_name(),
326
+				'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
327
+				'PMD_wp_user'    => $current_user->ID,
328
+				'PMD_order'      => EEM_Payment_Method::instance()->count(
329
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
330
+					) * 10,
331
+			)
332
+		);
333
+		return $payment_method;
334
+	}
335
+
336
+
337
+
338
+	/**
339
+	 * Sets the initial payment method properties (including extra meta)
340
+	 *
341
+	 * @param EE_Payment_Method $payment_method
342
+	 * @return EE_Payment_Method
343
+	 * @throws \EE_Error
344
+	 */
345
+	public function initialize_payment_method($payment_method)
346
+	{
347
+		$pm_type_obj = $payment_method->type_obj();
348
+		$payment_method->set_description($pm_type_obj->default_description());
349
+		if ( ! $payment_method->button_url()) {
350
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
351
+		}
352
+		//now add setup its default extra meta properties
353
+		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
354
+		if ( ! empty($extra_metas)) {
355
+			//verify the payment method has an ID before adding extra meta
356
+			if ( ! $payment_method->ID()) {
357
+				$payment_method->save();
358
+			}
359
+			foreach ($extra_metas as $meta_name => $input) {
360
+				$payment_method->update_extra_meta($meta_name, $input->raw_value());
361
+			}
362
+		}
363
+		return $payment_method;
364
+	}
365
+
366
+
367
+
368
+	/**
369
+	 * Makes sure the payment method is related to the specified payment method
370
+	 *
371
+	 * @param EE_Payment_Method $payment_method
372
+	 * @return EE_Payment_Method
373
+	 * @throws \EE_Error
374
+	 */
375
+	public function set_usable_currencies_on_payment_method($payment_method)
376
+	{
377
+		foreach ($payment_method->get_all_usable_currencies() as $currency_obj) {
378
+			$payment_method->_add_relation_to($currency_obj, 'Currency');
379
+		}
380
+		return $payment_method;
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * Deactivates a payment method of the given payment method slug.
387
+	 *
388
+	 * @param string $payment_method_slug The slug for the payment method to deactivate.
389
+	 * @return int count of rows updated.
390
+	 */
391
+	public function deactivate_payment_method($payment_method_slug)
392
+	{
393
+		EE_Log::instance()->log(
394
+			__FILE__,
395
+			__FUNCTION__,
396
+			sprintf(
397
+				__('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'),
398
+				$payment_method_slug
399
+			),
400
+			'payment_method_change'
401
+		);
402
+		$count_updated = EEM_Payment_Method::instance()->update(
403
+			array('PMD_scope' => array()),
404
+			array(array('PMD_slug' => $payment_method_slug))
405
+		);
406
+		return $count_updated;
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method
413
+	 * access caps.
414
+	 *
415
+	 * @param array $caps capabilities being filtered
416
+	 * @return array
417
+	 */
418
+	public function add_payment_method_caps($caps)
419
+	{
420
+		/* add dynamic caps from payment methods
421 421
          * at the time of writing, october 20 2014, these are the caps added:
422 422
          * ee_payment_method_admin_only
423 423
          * ee_payment_method_aim
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
          * their related capability automatically added too, so long as they are
432 432
          * registered properly using EE_Register_Payment_Method::register()
433 433
          */
434
-        foreach ($this->payment_method_types() as $payment_method_type_obj) {
435
-            $caps['administrator'][] = $payment_method_type_obj->cap_name();
436
-        }
437
-        return $caps;
438
-    }
434
+		foreach ($this->payment_method_types() as $payment_method_type_obj) {
435
+			$caps['administrator'][] = $payment_method_type_obj->cap_name();
436
+		}
437
+		return $caps;
438
+	}
439 439
 
440 440
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/db/EEME_Base.lib.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function __construct(){
73 73
 		if( ! $this->_model_name_extended){
74
-            throw new EE_Error(
75
-                __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
-                "event_espresso" )
77
-            );
74
+			throw new EE_Error(
75
+				__( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
+				"event_espresso" )
77
+			);
78 78
 		}
79 79
 		$construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end';
80 80
 		if ( did_action( $construct_end_action )) {
@@ -95,30 +95,30 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
 
98
-    /**
99
-     * @param array $existing_tables
100
-     * @return array
101
-     */
102
-    public function add_extra_tables_on_filter( $existing_tables ){
103
-        return array_merge( (array)$existing_tables, $this->_extra_tables );
98
+	/**
99
+	 * @param array $existing_tables
100
+	 * @return array
101
+	 */
102
+	public function add_extra_tables_on_filter( $existing_tables ){
103
+		return array_merge( (array)$existing_tables, $this->_extra_tables );
104 104
 	}
105 105
 
106 106
 
107 107
 
108
-    /**
109
-     * @param array $existing_fields
110
-     * @return array
111
-     */
112
-    public function add_extra_fields_on_filter( $existing_fields ){
108
+	/**
109
+	 * @param array $existing_fields
110
+	 * @return array
111
+	 */
112
+	public function add_extra_fields_on_filter( $existing_fields ){
113 113
 		if( $this->_extra_fields){
114 114
 			foreach($this->_extra_fields as $table_alias => $fields){
115 115
 				if( ! isset( $existing_fields[ $table_alias ] ) ){
116 116
 					$existing_fields[ $table_alias ] = array();
117 117
 				}
118 118
 				$existing_fields[$table_alias] = array_merge(
119
-                    (array)$existing_fields[$table_alias],
120
-                    $this->_extra_fields[$table_alias]
121
-                );
119
+					(array)$existing_fields[$table_alias],
120
+					$this->_extra_fields[$table_alias]
121
+				);
122 122
 
123 123
 			}
124 124
 		}
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 
128 128
 
129 129
 
130
-    /**
131
-     * @param array $existing_relations
132
-     * @return array
133
-     */
134
-    public function add_extra_relations_on_filter( $existing_relations ){
135
-        return  array_merge((array)$existing_relations,$this->_extra_relations);
130
+	/**
131
+	 * @param array $existing_relations
132
+	 * @return array
133
+	 */
134
+	public function add_extra_relations_on_filter( $existing_relations ){
135
+		return  array_merge((array)$existing_relations,$this->_extra_relations);
136 136
 	}
137 137
 
138 138
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 				remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10);
169 169
 			}
170 170
 		}
171
-        /** @var EEM_Base $model_to_reset */
172
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
171
+		/** @var EEM_Base $model_to_reset */
172
+		$model_to_reset = 'EEM_' . $this->_model_name_extended;
173 173
 		if ( class_exists( $model_to_reset ) ) {
174 174
 			$model_to_reset::reset();
175 175
 		}
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
 
180
-    /**
181
-     * @param string $callback_method_name
182
-     * @param array  $args
183
-     * @return mixed
184
-     * @throws EE_Error
185
-     */
186
-    public function __call( $callback_method_name, $args){
180
+	/**
181
+	 * @param string $callback_method_name
182
+	 * @param array  $args
183
+	 * @return mixed
184
+	 * @throws EE_Error
185
+	 */
186
+	public function __call( $callback_method_name, $args){
187 187
 		if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){
188 188
 			//it's a dynamic callback for a method name
189 189
 			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
 				return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model);
195 195
 			}else{
196 196
 				throw new EE_Error(
197
-				    sprintf(
198
-				        __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),
199
-                        $this->_model_name_extended,
200
-                        get_class($this),
201
-                        $extending_method,$extending_method
202
-                    )
203
-                );
197
+					sprintf(
198
+						__("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),
199
+						$this->_model_name_extended,
200
+						get_class($this),
201
+						$extending_method,$extending_method
202
+					)
203
+				);
204 204
 			}
205 205
 
206 206
 		}else{
207 207
 			throw new EE_Error(
208
-			    sprintf(
209
-			        __("There is no method named '%s' on '%s'", "event_espresso"),
210
-                    $callback_method_name,
211
-                    get_class($this)
212
-                )
213
-            );
208
+				sprintf(
209
+					__("There is no method named '%s' on '%s'", "event_espresso"),
210
+					$callback_method_name,
211
+					get_class($this)
212
+				)
213
+			);
214 214
 		}
215 215
 	}
216 216
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
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
 /**
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
 	/**
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	public function __construct(){
73
-		if( ! $this->_model_name_extended){
72
+	public function __construct() {
73
+		if ( ! $this->_model_name_extended) {
74 74
             throw new EE_Error(
75
-                __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
-                "event_espresso" )
75
+                __("When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
+                "event_espresso")
77 77
             );
78 78
 		}
79 79
 		$construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end';
80
-		if ( did_action( $construct_end_action )) {
80
+		if (did_action($construct_end_action)) {
81 81
 			throw new EE_Error(
82 82
 				sprintf(
83
-					__( "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"),
83
+					__("Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"),
84 84
 					get_class($this),
85 85
 					$this->_model_name_extended,
86 86
 					$construct_end_action
87 87
 				)
88 88
 			);
89 89
 		}
90
-		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter'));
91
-		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter'));
92
-		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter'));
90
+		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter'));
91
+		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter'));
92
+		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter'));
93 93
 		$this->_register_extending_methods();
94 94
 	}
95 95
 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
      * @param array $existing_tables
100 100
      * @return array
101 101
      */
102
-    public function add_extra_tables_on_filter( $existing_tables ){
103
-        return array_merge( (array)$existing_tables, $this->_extra_tables );
102
+    public function add_extra_tables_on_filter($existing_tables) {
103
+        return array_merge((array) $existing_tables, $this->_extra_tables);
104 104
 	}
105 105
 
106 106
 
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
      * @param array $existing_fields
110 110
      * @return array
111 111
      */
112
-    public function add_extra_fields_on_filter( $existing_fields ){
113
-		if( $this->_extra_fields){
114
-			foreach($this->_extra_fields as $table_alias => $fields){
115
-				if( ! isset( $existing_fields[ $table_alias ] ) ){
116
-					$existing_fields[ $table_alias ] = array();
112
+    public function add_extra_fields_on_filter($existing_fields) {
113
+		if ($this->_extra_fields) {
114
+			foreach ($this->_extra_fields as $table_alias => $fields) {
115
+				if ( ! isset($existing_fields[$table_alias])) {
116
+					$existing_fields[$table_alias] = array();
117 117
 				}
118 118
 				$existing_fields[$table_alias] = array_merge(
119
-                    (array)$existing_fields[$table_alias],
119
+                    (array) $existing_fields[$table_alias],
120 120
                     $this->_extra_fields[$table_alias]
121 121
                 );
122 122
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      * @param array $existing_relations
132 132
      * @return array
133 133
      */
134
-    public function add_extra_relations_on_filter( $existing_relations ){
135
-        return  array_merge((array)$existing_relations,$this->_extra_relations);
134
+    public function add_extra_relations_on_filter($existing_relations) {
135
+        return  array_merge((array) $existing_relations, $this->_extra_relations);
136 136
 	}
137 137
 
138 138
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	 * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
142 142
 	 * model extended. (Internally uses filters, and the __call magic method)
143 143
 	 */
144
-	protected function _register_extending_methods(){
144
+	protected function _register_extending_methods() {
145 145
 		$all_methods = get_class_methods(get_class($this));
146
-		foreach($all_methods as $method_name){
147
-			if(strpos($method_name, self::extending_method_prefix) === 0){
146
+		foreach ($all_methods as $method_name) {
147
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
148 148
 				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
149 149
 				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
150
-				add_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10,10);
150
+				add_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10, 10);
151 151
 			}
152 152
 		}
153 153
 	}
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
 	 * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
157 157
 	 * model extended. (Internally uses filters, and the __call magic method)
158 158
 	 */
159
-	public function deregister(){
160
-		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter'));
161
-		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter'));
162
-		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter'));
159
+	public function deregister() {
160
+		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter'));
161
+		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter'));
162
+		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter'));
163 163
 		$all_methods = get_class_methods(get_class($this));
164
-		foreach($all_methods as $method_name){
165
-			if(strpos($method_name, self::extending_method_prefix) === 0){
164
+		foreach ($all_methods as $method_name) {
165
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
166 166
 				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
167 167
 				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
168
-				remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10);
168
+				remove_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10);
169 169
 			}
170 170
 		}
171 171
         /** @var EEM_Base $model_to_reset */
172
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
173
-		if ( class_exists( $model_to_reset ) ) {
172
+        $model_to_reset = 'EEM_'.$this->_model_name_extended;
173
+		if (class_exists($model_to_reset)) {
174 174
 			$model_to_reset::reset();
175 175
 		}
176 176
 	}
@@ -183,27 +183,27 @@  discard block
 block discarded – undo
183 183
      * @return mixed
184 184
      * @throws EE_Error
185 185
      */
186
-    public function __call( $callback_method_name, $args){
187
-		if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){
186
+    public function __call($callback_method_name, $args) {
187
+		if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
188 188
 			//it's a dynamic callback for a method name
189 189
 			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
190
-			list( $original_return_val, $model_called, $args_provided_to_method_on_model ) = (array) $args;
190
+			list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args;
191 191
 			$this->_ = $model_called;
192 192
 			$extending_method = self::extending_method_prefix.$method_called_on_model;
193
-			if(method_exists($this, $extending_method)){
194
-				return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model);
195
-			}else{
193
+			if (method_exists($this, $extending_method)) {
194
+				return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
195
+			} else {
196 196
 				throw new EE_Error(
197 197
 				    sprintf(
198 198
 				        __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),
199 199
                         $this->_model_name_extended,
200 200
                         get_class($this),
201
-                        $extending_method,$extending_method
201
+                        $extending_method, $extending_method
202 202
                     )
203 203
                 );
204 204
 			}
205 205
 
206
-		}else{
206
+		} else {
207 207
 			throw new EE_Error(
208 208
 			    sprintf(
209 209
 			        __("There is no method named '%s' on '%s'", "event_espresso"),
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474 474
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475 475
         global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
476
+        $ee_menu_slugs = (array) $ee_menu_slugs;
477 477
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478 478
             return false;
479 479
         }
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489 489
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490 490
         $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
491
+        $this->_req_nonce = $this->_req_action.'_nonce';
492 492
         $this->_define_page_props();
493 493
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494 494
         //default things
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
             $this->_extend_page_config_for_cpt();
510 510
         }
511 511
         //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
512
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
513
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
514 514
         //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
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
515
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
516
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
517 517
         }
518 518
         //next route only if routing enabled
519 519
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
             if ($this->_is_UI_request) {
524 524
                 //admin_init stuff - global, all views for this page class, specific view
525 525
                 add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
526
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
527
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
528 528
                 }
529 529
             } else {
530 530
                 //hijack regular WP loading and route admin request immediately
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
      */
545 545
     private function _do_other_page_hooks()
546 546
     {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
547
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
548 548
         foreach ($registered_pages as $page) {
549 549
             //now let's setup the file name and class that should be present
550 550
             $classname = str_replace('.class.php', '', $page);
@@ -590,13 +590,13 @@  discard block
 block discarded – undo
590 590
         //load admin_notices - global, page class, and view specific
591 591
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592 592
         add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
593
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
594
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
595 595
         }
596 596
         //load network admin_notices - global, page class, and view specific
597 597
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
598
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
599
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
600 600
         }
601 601
         //this will save any per_page screen options if they are present
602 602
         $this->_set_per_page_screen_options();
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
         //add screen options - global, page child class, and view specific
609 609
         $this->_add_global_screen_options();
610 610
         $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
611
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
612
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
613 613
         }
614 614
         //add help tab(s) and tours- set via page_config and qtips.
615 615
         $this->_add_help_tour();
@@ -618,31 +618,31 @@  discard block
 block discarded – undo
618 618
         //add feature_pointers - global, page child class, and view specific
619 619
         $this->_add_feature_pointers();
620 620
         $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
621
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
622
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
623 623
         }
624 624
         //enqueue scripts/styles - global, page class, and view specific
625 625
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626 626
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
627
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
628
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
629 629
         }
630 630
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631 631
         //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
632 632
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633 633
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
634
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
635
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
636 636
         }
637 637
         //admin footer scripts
638 638
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639 639
         add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
640
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
641
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
642 642
         }
643 643
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644 644
         //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
645
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
646 646
     }
647 647
 
648 648
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
             // user error msg
719 719
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720 720
             // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
721
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722 722
             throw new EE_Error($error_msg);
723 723
         }
724 724
         // and that the requested page route exists
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
             // user error msg
730 730
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731 731
             // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
732
+            $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733 733
             throw new EE_Error($error_msg);
734 734
         }
735 735
         // and that a default route exists
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
             // user error msg
738 738
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739 739
             // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
740
+            $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741 741
             throw new EE_Error($error_msg);
742 742
         }
743 743
         //first lets' catch if the UI request has EVER been set.
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             // user error msg
767 767
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768 768
             // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
769
+            $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770 770
             throw new EE_Error($error_msg);
771 771
         }
772 772
     }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
             // these are not the droids you are looking for !!!
789 789
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790 790
             if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
791
+                $msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792 792
             }
793 793
             if ( ! defined('DOING_AJAX')) {
794 794
                 wp_die($msg);
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                 if (strpos($key, 'nonce') !== false) {
964 964
                     continue;
965 965
                 }
966
-                $args['wp_referer[' . $key . ']'] = $value;
966
+                $args['wp_referer['.$key.']'] = $value;
967 967
             }
968 968
         }
969 969
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1010 1010
                         continue;
1011 1011
                     }
1012
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1012
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1013 1013
                 }
1014 1014
                 $tour_buttons .= implode('<br />', $tb);
1015 1015
                 $tour_buttons .= '</div></div>';
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
                     throw new EE_Error(sprintf(__('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',
1022 1022
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1023 1023
                 }
1024
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1024
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025 1025
                 $content .= $tour_buttons; //add help tour buttons.
1026 1026
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1027 1027
                 $this->_current_screen->set_help_sidebar($content);
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035 1035
                 $_ht['id'] = $this->page_slug;
1036 1036
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1037
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1037
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1038 1038
                 $this->_current_screen->add_help_tab($_ht);
1039 1039
             }/**/
1040 1040
             if ( ! isset($config['help_tabs'])) {
1041 1041
                 return;
1042 1042
             } //no help tabs for this route
1043
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1043
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1044 1044
                 //we're here so there ARE help tabs!
1045 1045
                 //make sure we've got what we need
1046 1046
                 if ( ! isset($cfg['title'])) {
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056 1056
                     //second priority goes to filename
1057 1057
                 } else if ( ! empty($cfg['filename'])) {
1058
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1058
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1059 1059
                     //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)
1060
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1060
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1061 1061
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062 1062
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063 1063
                         EE_Error::add_error(sprintf(__('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',
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                     return;
1077 1077
                 }
1078 1078
                 //setup config array for help tab method
1079
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1079
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1080 1080
                 $_ht = array(
1081 1081
                         'id'       => $id,
1082 1082
                         'title'    => $cfg['title'],
@@ -1114,9 +1114,9 @@  discard block
 block discarded – undo
1114 1114
             }
1115 1115
             if (isset($config['help_tour'])) {
1116 1116
                 foreach ($config['help_tour'] as $tour) {
1117
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1117
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1118 1118
                     //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
1119
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1119
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1120 1120
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121 1121
                     if ( ! is_readable($file_path)) {
1122 1122
                         EE_Error::add_error(sprintf(__('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', 'event_espresso'),
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
                     require_once $file_path;
1127 1127
                     if ( ! class_exists($tour)) {
1128 1128
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('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.',
1129
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(__('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.',
1130 1130
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131 1131
                         throw new EE_Error(implode('||', $error_msg));
1132 1132
                     }
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
     protected function _add_qtips()
1159 1159
     {
1160 1160
         if (isset($this->_route_config['qtips'])) {
1161
-            $qtips = (array)$this->_route_config['qtips'];
1161
+            $qtips = (array) $this->_route_config['qtips'];
1162 1162
             //load qtip loader
1163 1163
             $path = array(
1164
-                    $this->_get_dir() . '/qtips/',
1165
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1164
+                    $this->_get_dir().'/qtips/',
1165
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1166 1166
             );
1167 1167
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1168 1168
         }
@@ -1192,11 +1192,11 @@  discard block
 block discarded – undo
1192 1192
             if ( ! $this->check_user_access($slug, true)) {
1193 1193
                 continue;
1194 1194
             } //no nav tab becasue current user does not have access.
1195
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1195
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1196 1196
             $this->_nav_tabs[$slug] = array(
1197 1197
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198 1198
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1199
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1200 1200
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201 1201
             );
1202 1202
             $i++;
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
             $capability = empty($capability) ? 'manage_options' : $capability;
1260 1260
         }
1261 1261
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1262
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263 1263
             if ($verify_only) {
1264 1264
                 return false;
1265 1265
             } else {
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
     public function admin_footer_global()
1352 1352
     {
1353 1353
         //dialog container for dialog helper
1354
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1354
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1355 1355
         $d_cont .= '<div class="ee-notices"></div>';
1356 1356
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1357 1357
         $d_cont .= '</div>';
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1362 1362
         }
1363 1363
         //current set timezone for timezone js
1364
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1364
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1365 1365
     }
1366 1366
 
1367 1367
 
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
     {
1387 1387
         $content = '';
1388 1388
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1389
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1389
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1390 1390
         //loop through the array and setup content
1391 1391
         foreach ($help_array as $trigger => $help) {
1392 1392
             //make sure the array is setup properly
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
     private function _get_help_content()
1421 1421
     {
1422 1422
         //what is the method we're looking for?
1423
-        $method_name = '_help_popup_content_' . $this->_req_action;
1423
+        $method_name = '_help_popup_content_'.$this->_req_action;
1424 1424
         //if method doesn't exist let's get out.
1425 1425
         if ( ! method_exists($this, $method_name)) {
1426 1426
             return array();
@@ -1464,8 +1464,8 @@  discard block
 block discarded – undo
1464 1464
             $help_content = $this->_set_help_popup_content($help_array, false);
1465 1465
         }
1466 1466
         //let's setup the trigger
1467
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
-        $content = $content . $help_content;
1467
+        $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
+        $content = $content.$help_content;
1469 1469
         if ($display) {
1470 1470
             echo $content;
1471 1471
         } else {
@@ -1525,32 +1525,32 @@  discard block
 block discarded – undo
1525 1525
             add_action('admin_head', array($this, 'add_xdebug_style'));
1526 1526
         }
1527 1527
         //register all styles
1528
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1528
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1530 1530
         //helpers styles
1531
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1531
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1532 1532
         //enqueue global styles
1533 1533
         wp_enqueue_style('ee-admin-css');
1534 1534
         /** SCRIPTS **/
1535 1535
         //register all scripts
1536
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1536
+        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
+        wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
+        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540 1540
         // register jQuery Validate - see /includes/functions/wp_hooks.php
1541 1541
         add_filter('FHEE_load_jquery_validate', '__return_true');
1542 1542
         add_filter('FHEE_load_joyride', '__return_true');
1543 1543
         //script for sorting tables
1544
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1544
+        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1545 1545
         //script for parsing uri's
1546
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1546
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1547 1547
         //and parsing associative serialized form elements
1548
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1548
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1549 1549
         //helpers scripts
1550
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1550
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554 1554
         //google charts
1555 1555
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1556 1556
         //enqueue global scripts
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
          */
1572 1572
         if ( ! empty($this->_help_tour)) {
1573 1573
             //register the js for kicking things off
1574
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1574
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1575 1575
             //setup tours for the js tour object
1576 1576
             foreach ($this->_help_tour['tours'] as $tour) {
1577 1577
                 $tours[] = array(
@@ -1670,17 +1670,17 @@  discard block
 block discarded – undo
1670 1670
             return;
1671 1671
         } //not a list_table view so get out.
1672 1672
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1673
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1673
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1674 1674
             //user error msg
1675 1675
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1676 1676
             //developer error msg
1677
-            $error_msg .= '||' . sprintf(__('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.', 'event_espresso'),
1678
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1677
+            $error_msg .= '||'.sprintf(__('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.', 'event_espresso'),
1678
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1679 1679
             throw new EE_Error($error_msg);
1680 1680
         }
1681 1681
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1682
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1683
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1682
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1683
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1684 1684
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1685 1685
         $this->_set_list_table_view();
1686 1686
         $this->_set_list_table_object();
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
             // check for current view
1756 1756
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1757 1757
             $query_args['action'] = $this->_req_action;
1758
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1758
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1759 1759
             $query_args['status'] = $view['slug'];
1760 1760
             //merge any other arguments sent in.
1761 1761
             if (isset($extra_query_args[$view['slug']])) {
@@ -1793,14 +1793,14 @@  discard block
 block discarded – undo
1793 1793
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1794 1794
         foreach ($values as $value) {
1795 1795
             if ($value < $max_entries) {
1796
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1796
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1797 1797
                 $entries_per_page_dropdown .= '
1798
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1798
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1799 1799
             }
1800 1800
         }
1801
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1801
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1802 1802
         $entries_per_page_dropdown .= '
1803
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1803
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1804 1804
         $entries_per_page_dropdown .= '
1805 1805
 					</select>
1806 1806
 					entries
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
     public function _set_search_attributes()
1823 1823
     {
1824 1824
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1825
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1825
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1826 1826
     }
1827 1827
 
1828 1828
     /*** END LIST TABLE METHODS **/
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
                     // user error msg
1861 1861
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1862 1862
                     // developer error msg
1863
-                    $error_msg .= '||' . sprintf(
1863
+                    $error_msg .= '||'.sprintf(
1864 1864
                                     __(
1865 1865
                                             '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.',
1866 1866
                                             'event_espresso'
@@ -1890,15 +1890,15 @@  discard block
 block discarded – undo
1890 1890
                 && is_array($this->_route_config['columns'])
1891 1891
                 && count($this->_route_config['columns']) === 2
1892 1892
         ) {
1893
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1893
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1894 1894
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1895 1895
             $screen_id = $this->_current_screen->id;
1896
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1896
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1897 1897
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1898
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1898
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1899 1899
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1900 1900
             $this->_template_args['screen'] = $this->_current_screen;
1901
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1901
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1902 1902
             //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.
1903 1903
             $this->_route_config['has_metaboxes'] = true;
1904 1904
         }
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
      */
1946 1946
     public function espresso_ratings_request()
1947 1947
     {
1948
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1948
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1949 1949
         EEH_Template::display_template($template_path, array());
1950 1950
     }
1951 1951
 
@@ -1953,18 +1953,18 @@  discard block
 block discarded – undo
1953 1953
 
1954 1954
     public static function cached_rss_display($rss_id, $url)
1955 1955
     {
1956
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1956
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1957 1957
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1958
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1959
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1960
-        $post = '</div>' . "\n";
1961
-        $cache_key = 'ee_rss_' . md5($rss_id);
1958
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1959
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1960
+        $post = '</div>'."\n";
1961
+        $cache_key = 'ee_rss_'.md5($rss_id);
1962 1962
         if (false != ($output = get_transient($cache_key))) {
1963
-            echo $pre . $output . $post;
1963
+            echo $pre.$output.$post;
1964 1964
             return true;
1965 1965
         }
1966 1966
         if ( ! $doing_ajax) {
1967
-            echo $pre . $loading . $post;
1967
+            echo $pre.$loading.$post;
1968 1968
             return false;
1969 1969
         }
1970 1970
         ob_start();
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 
2024 2024
     public function espresso_sponsors_post_box()
2025 2025
     {
2026
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2026
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2027 2027
         EEH_Template::display_template($templatepath);
2028 2028
     }
2029 2029
 
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
 
2032 2032
     private function _publish_post_box()
2033 2033
     {
2034
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2034
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2035 2035
         //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)
2036 2036
         if ( ! empty($this->_labels['publishbox'])) {
2037 2037
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
     {
2049 2049
         //if we have extra content set let's add it in if not make sure its empty
2050 2050
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2051
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2051
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2052 2052
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2053 2053
     }
2054 2054
 
@@ -2217,7 +2217,7 @@  discard block
 block discarded – undo
2217 2217
         //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)
2218 2218
         $call_back_func = $create_func ? create_function('$post, $metabox',
2219 2219
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2220
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2220
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2221 2221
     }
2222 2222
 
2223 2223
 
@@ -2297,10 +2297,10 @@  discard block
 block discarded – undo
2297 2297
                 ? 'poststuff'
2298 2298
                 : 'espresso-default-admin';
2299 2299
         $template_path = $sidebar
2300
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2301
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2300
+                ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php'
2301
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2302 2302
         if (defined('DOING_AJAX') && DOING_AJAX) {
2303
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2303
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2304 2304
         }
2305 2305
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2306 2306
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
                         true
2347 2347
                 )
2348 2348
                 : $this->_template_args['preview_action_button'];
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2349
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2350 2350
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2351 2351
                 $template_path,
2352 2352
                 $this->_template_args,
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
         //setup search attributes
2398 2398
         $this->_set_search_attributes();
2399 2399
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2400
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2400
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2401 2401
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2402 2402
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2403 2403
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2407,31 +2407,31 @@  discard block
 block discarded – undo
2407 2407
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2408 2408
         if ( ! empty($ajax_sorting_callback)) {
2409 2409
             $sortable_list_table_form_fields = wp_nonce_field(
2410
-                    $ajax_sorting_callback . '_nonce',
2411
-                    $ajax_sorting_callback . '_nonce',
2410
+                    $ajax_sorting_callback.'_nonce',
2411
+                    $ajax_sorting_callback.'_nonce',
2412 2412
                     false,
2413 2413
                     false
2414 2414
             );
2415 2415
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2416 2416
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2417
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2418
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2417
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2418
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2419 2419
         } else {
2420 2420
             $sortable_list_table_form_fields = '';
2421 2421
         }
2422 2422
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2423 2423
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2424
-        $nonce_ref = $this->_req_action . '_nonce';
2425
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2424
+        $nonce_ref = $this->_req_action.'_nonce';
2425
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2426 2426
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2427 2427
         //display message about search results?
2428 2428
         $this->_template_args['before_list_table'] .= apply_filters(
2429 2429
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2430 2430
                 ! empty($this->_req_data['s'])
2431
-                        ? '<p class="ee-search-results">' . sprintf(
2431
+                        ? '<p class="ee-search-results">'.sprintf(
2432 2432
                                 __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'),
2433 2433
                                 trim($this->_req_data['s'], '%')
2434
-                        ) . '</p>'
2434
+                        ).'</p>'
2435 2435
                         : '',
2436 2436
                 $this->page_slug,
2437 2437
                 $this->_req_data,
@@ -2467,8 +2467,8 @@  discard block
 block discarded – undo
2467 2467
      */
2468 2468
     protected function _display_legend($items)
2469 2469
     {
2470
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2471
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2470
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2471
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2472 2472
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2473 2473
     }
2474 2474
 
@@ -2563,15 +2563,15 @@  discard block
 block discarded – undo
2563 2563
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2564 2564
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2565 2565
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2566
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2566
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2567 2567
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2568
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2568
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2569 2569
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2570 2570
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2571 2571
         // load settings page wrapper template
2572
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2572
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2573 2573
         //about page?
2574
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2574
+        $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path;
2575 2575
         if (defined('DOING_AJAX')) {
2576 2576
             $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2577 2577
             $this->_return_json();
@@ -2643,20 +2643,20 @@  discard block
 block discarded – undo
2643 2643
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2644 2644
     {
2645 2645
         //make sure $text and $actions are in an array
2646
-        $text = (array)$text;
2647
-        $actions = (array)$actions;
2646
+        $text = (array) $text;
2647
+        $actions = (array) $actions;
2648 2648
         $referrer_url = empty($referrer) ? '' : $referrer;
2649
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2650
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2649
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2650
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2651 2651
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2652 2652
         $default_names = array('save', 'save_and_close');
2653 2653
         //add in a hidden index for the current page (so save and close redirects properly)
2654 2654
         $this->_template_args['save_buttons'] = $referrer_url;
2655 2655
         foreach ($button_text as $key => $button) {
2656 2656
             $ref = $default_names[$key];
2657
-            $id = $this->_current_view . '_' . $ref;
2657
+            $id = $this->_current_view.'_'.$ref;
2658 2658
             $name = ! empty($actions) ? $actions[$key] : $ref;
2659
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2659
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2660 2660
             if ( ! $both) {
2661 2661
                 break;
2662 2662
             }
@@ -2692,15 +2692,15 @@  discard block
 block discarded – undo
2692 2692
     {
2693 2693
         if (empty($route)) {
2694 2694
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2695
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2696
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2695
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2696
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2697 2697
         }
2698 2698
         // open form
2699
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2699
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2700 2700
         // add nonce
2701
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2701
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2702 2702
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2703
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2703
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2704 2704
         // add REQUIRED form action
2705 2705
         $hidden_fields = array(
2706 2706
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2710,8 +2710,8 @@  discard block
 block discarded – undo
2710 2710
         // generate form fields
2711 2711
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2712 2712
         // add fields to form
2713
-        foreach ((array)$form_fields as $field_name => $form_field) {
2714
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2713
+        foreach ((array) $form_fields as $field_name => $form_field) {
2714
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2715 2715
         }
2716 2716
         // close form
2717 2717
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2792,7 +2792,7 @@  discard block
 block discarded – undo
2792 2792
          * @param array $query_args       The original query_args array coming into the
2793 2793
          *                                method.
2794 2794
          */
2795
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2795
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2796 2796
         //calculate where we're going (if we have a "save and close" button pushed)
2797 2797
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2798 2798
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2808,7 +2808,7 @@  discard block
 block discarded – undo
2808 2808
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2809 2809
                 //is there a wp_referer array in our _default_route_query_args property?
2810 2810
                 if ($query_param == 'wp_referer') {
2811
-                    $query_value = (array)$query_value;
2811
+                    $query_value = (array) $query_value;
2812 2812
                     foreach ($query_value as $reference => $value) {
2813 2813
                         if (strpos($reference, 'nonce') !== false) {
2814 2814
                             continue;
@@ -2834,11 +2834,11 @@  discard block
 block discarded – undo
2834 2834
         // if redirecting to anything other than the main page, add a nonce
2835 2835
         if (isset($query_args['action'])) {
2836 2836
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2837
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2837
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2838 2838
         }
2839 2839
         //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).
2840
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2841
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2840
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2841
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2842 2842
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2843 2843
         if (defined('DOING_AJAX')) {
2844 2844
             $default_data = array(
@@ -2968,7 +2968,7 @@  discard block
 block discarded – undo
2968 2968
         $args = array(
2969 2969
                 'label'   => $this->_admin_page_title,
2970 2970
                 'default' => 10,
2971
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2971
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
2972 2972
         );
2973 2973
         //ONLY add the screen option if the user has access to it.
2974 2974
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3001,8 +3001,8 @@  discard block
 block discarded – undo
3001 3001
             $map_option = $option;
3002 3002
             $option = str_replace('-', '_', $option);
3003 3003
             switch ($map_option) {
3004
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3005
-                    $value = (int)$value;
3004
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3005
+                    $value = (int) $value;
3006 3006
                     if ($value < 1 || $value > 999) {
3007 3007
                         return;
3008 3008
                     }
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
      */
3030 3030
     public function set_template_args($data)
3031 3031
     {
3032
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3032
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3033 3033
     }
3034 3034
 
3035 3035
 
@@ -3051,12 +3051,12 @@  discard block
 block discarded – undo
3051 3051
             $this->_verify_route($route);
3052 3052
         }
3053 3053
         //now let's set the string for what kind of transient we're setting
3054
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3054
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3055 3055
         $data = $notices ? array('notices' => $data) : $data;
3056 3056
         //is there already a transient for this route?  If there is then let's ADD to that transient
3057 3057
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3058 3058
         if ($existing) {
3059
-            $data = array_merge((array)$data, (array)$existing);
3059
+            $data = array_merge((array) $data, (array) $existing);
3060 3060
         }
3061 3061
         if (is_multisite() && is_network_admin()) {
3062 3062
             set_site_transient($transient, $data, 8);
@@ -3077,7 +3077,7 @@  discard block
 block discarded – undo
3077 3077
     {
3078 3078
         $user_id = get_current_user_id();
3079 3079
         $route = ! $route ? $this->_req_action : $route;
3080
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3080
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3081 3081
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3082 3082
         //delete transient after retrieval (just in case it hasn't expired);
3083 3083
         if (is_multisite() && is_network_admin()) {
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
      */
3319 3319
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3320 3320
     {
3321
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3321
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3322 3322
     }
3323 3323
 
3324 3324
 
@@ -3332,7 +3332,7 @@  discard block
 block discarded – undo
3332 3332
      */
3333 3333
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3334 3334
     {
3335
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3335
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3336 3336
     }
3337 3337
 
3338 3338
 
Please login to merge, or discard this patch.
Indentation   +3261 added lines, -3261 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -28,2112 +28,2112 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    //set in _init_page_props()
32
-    public $page_slug;
31
+	//set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    //set in define_page_props()
39
-    protected $_admin_base_url;
38
+	//set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    //set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	//set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    //navtabs
52
-    protected $_nav_tabs;
51
+	//navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    //helptourstops
57
-    protected $_help_tour = array();
56
+	//helptourstops
57
+	protected $_help_tour = array();
58 58
 
59 59
 
60
-    //template variables (used by templates)
61
-    protected $_template_path;
60
+	//template variables (used by templates)
61
+	protected $_template_path;
62 62
 
63
-    protected $_column_template_path;
63
+	protected $_column_template_path;
64 64
 
65
-    /**
66
-     * @var array $_template_args
67
-     */
68
-    protected $_template_args = array();
65
+	/**
66
+	 * @var array $_template_args
67
+	 */
68
+	protected $_template_args = array();
69 69
 
70
-    /**
71
-     * this will hold the list table object for a given view.
72
-     *
73
-     * @var EE_Admin_List_Table $_list_table_object
74
-     */
75
-    protected $_list_table_object;
70
+	/**
71
+	 * this will hold the list table object for a given view.
72
+	 *
73
+	 * @var EE_Admin_List_Table $_list_table_object
74
+	 */
75
+	protected $_list_table_object;
76 76
 
77
-    //bools
78
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
77
+	//bools
78
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79 79
 
80
-    protected $_routing;
80
+	protected $_routing;
81 81
 
82
-    //list table args
83
-    protected $_view;
82
+	//list table args
83
+	protected $_view;
84 84
 
85
-    protected $_views;
85
+	protected $_views;
86 86
 
87 87
 
88
-    //action => method pairs used for routing incoming requests
89
-    protected $_page_routes;
88
+	//action => method pairs used for routing incoming requests
89
+	protected $_page_routes;
90 90
 
91
-    protected $_page_config;
91
+	protected $_page_config;
92 92
 
93
-    //the current page route and route config
94
-    protected $_route;
93
+	//the current page route and route config
94
+	protected $_route;
95 95
 
96
-    protected $_route_config;
96
+	protected $_route_config;
97 97
 
98
-    /**
99
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
-     * actions.
101
-     *
102
-     * @since 4.6.x
103
-     * @var array.
104
-     */
105
-    protected $_default_route_query_args;
98
+	/**
99
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
+	 * actions.
101
+	 *
102
+	 * @since 4.6.x
103
+	 * @var array.
104
+	 */
105
+	protected $_default_route_query_args;
106 106
 
107
-    //set via request page and action args.
108
-    protected $_current_page;
107
+	//set via request page and action args.
108
+	protected $_current_page;
109 109
 
110
-    protected $_current_view;
110
+	protected $_current_view;
111 111
 
112
-    protected $_current_page_view_url;
112
+	protected $_current_page_view_url;
113 113
 
114
-    //sanitized request action (and nonce)
115
-    /**
116
-     * @var string $_req_action
117
-     */
118
-    protected $_req_action;
114
+	//sanitized request action (and nonce)
115
+	/**
116
+	 * @var string $_req_action
117
+	 */
118
+	protected $_req_action;
119 119
 
120
-    /**
121
-     * @var string $_req_nonce
122
-     */
123
-    protected $_req_nonce;
120
+	/**
121
+	 * @var string $_req_nonce
122
+	 */
123
+	protected $_req_nonce;
124 124
 
125
-    //search related
126
-    protected $_search_btn_label;
125
+	//search related
126
+	protected $_search_btn_label;
127 127
 
128
-    protected $_search_box_callback;
128
+	protected $_search_box_callback;
129 129
 
130
-    /**
131
-     * WP Current Screen object
132
-     *
133
-     * @var WP_Screen
134
-     */
135
-    protected $_current_screen;
130
+	/**
131
+	 * WP Current Screen object
132
+	 *
133
+	 * @var WP_Screen
134
+	 */
135
+	protected $_current_screen;
136 136
 
137
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
-    protected $_hook_obj;
137
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
+	protected $_hook_obj;
139 139
 
140
-    //for holding incoming request data
141
-    protected $_req_data;
140
+	//for holding incoming request data
141
+	protected $_req_data;
142 142
 
143
-    // yes / no array for admin form fields
144
-    protected $_yes_no_values = array();
145
-
146
-    //some default things shared by all child classes
147
-    protected $_default_espresso_metaboxes;
148
-
149
-    /**
150
-     *    EE_Registry Object
151
-     *
152
-     * @var    EE_Registry
153
-     * @access    protected
154
-     */
155
-    protected $EE = null;
156
-
157
-
158
-
159
-    /**
160
-     * This is just a property that flags whether the given route is a caffeinated route or not.
161
-     *
162
-     * @var boolean
163
-     */
164
-    protected $_is_caf = false;
165
-
166
-
167
-
168
-    /**
169
-     * @Constructor
170
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
-     * @access public
172
-     */
173
-    public function __construct($routing = true)
174
-    {
175
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
-            $this->_is_caf = true;
177
-        }
178
-        $this->_yes_no_values = array(
179
-                array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
-                array('id' => false, 'text' => __('No', 'event_espresso')),
181
-        );
182
-        //set the _req_data property.
183
-        $this->_req_data = array_merge($_GET, $_POST);
184
-        //routing enabled?
185
-        $this->_routing = $routing;
186
-        //set initial page props (child method)
187
-        $this->_init_page_props();
188
-        //set global defaults
189
-        $this->_set_defaults();
190
-        //set early because incoming requests could be ajax related and we need to register those hooks.
191
-        $this->_global_ajax_hooks();
192
-        $this->_ajax_hooks();
193
-        //other_page_hooks have to be early too.
194
-        $this->_do_other_page_hooks();
195
-        //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
-        if (method_exists($this, '_before_page_setup')) {
197
-            $this->_before_page_setup();
198
-        }
199
-        //set up page dependencies
200
-        $this->_page_setup();
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * _init_page_props
207
-     * Child classes use to set at least the following properties:
208
-     * $page_slug.
209
-     * $page_label.
210
-     *
211
-     * @abstract
212
-     * @access protected
213
-     * @return void
214
-     */
215
-    abstract protected function _init_page_props();
216
-
217
-
218
-
219
-    /**
220
-     * _ajax_hooks
221
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
-     * Note: within the ajax callback methods.
223
-     *
224
-     * @abstract
225
-     * @access protected
226
-     * @return void
227
-     */
228
-    abstract protected function _ajax_hooks();
229
-
230
-
231
-
232
-    /**
233
-     * _define_page_props
234
-     * child classes define page properties in here.  Must include at least:
235
-     * $_admin_base_url = base_url for all admin pages
236
-     * $_admin_page_title = default admin_page_title for admin pages
237
-     * $_labels = array of default labels for various automatically generated elements:
238
-     *    array(
239
-     *        'buttons' => array(
240
-     *            'add' => __('label for add new button'),
241
-     *            'edit' => __('label for edit button'),
242
-     *            'delete' => __('label for delete button')
243
-     *            )
244
-     *        )
245
-     *
246
-     * @abstract
247
-     * @access protected
248
-     * @return void
249
-     */
250
-    abstract protected function _define_page_props();
251
-
252
-
253
-
254
-    /**
255
-     * _set_page_routes
256
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
-     * route. Here's the format
258
-     * $this->_page_routes = array(
259
-     *        'default' => array(
260
-     *            'func' => '_default_method_handling_route',
261
-     *            'args' => array('array','of','args'),
262
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
-     *        ),
267
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
-     *        )
269
-     * )
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _set_page_routes();
276
-
277
-
278
-
279
-    /**
280
-     * _set_page_config
281
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
-     * Format:
283
-     * $this->_page_config = array(
284
-     *        'default' => array(
285
-     *            'labels' => array(
286
-     *                'buttons' => array(
287
-     *                    'add' => __('label for adding item'),
288
-     *                    'edit' => __('label for editing item'),
289
-     *                    'delete' => __('label for deleting item')
290
-     *                ),
291
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
-     *            'nav' => array(
294
-     *                'label' => __('Label for Tab', 'event_espresso').
295
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
-     *                'order' => 10, //required to indicate tab position.
298
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
-     *            this flag to make sure the necessary js gets enqueued on page load.
303
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
-     *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
307
-     *                'tab_id' => array(
308
-     *                    'title' => 'tab_title',
309
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
-     *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
-     *                    ),
313
-     *                'tab2_id' => array(
314
-     *                    'title' => 'tab2 title',
315
-     *                    'filename' => 'file_name_2'
316
-     *                    'callback' => 'callback_method_for_content',
317
-     *                 ),
318
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
-     *            'help_tour' => array(
320
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
-     *            ),
323
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
-     *            'require_nonce' to FALSE
325
-     *            )
326
-     * )
327
-     *
328
-     * @abstract
329
-     * @access protected
330
-     * @return void
331
-     */
332
-    abstract protected function _set_page_config();
333
-
334
-
335
-
336
-
337
-
338
-    /** end sample help_tour methods **/
339
-    /**
340
-     * _add_screen_options
341
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
-     * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
-     *
344
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
-     *         see also WP_Screen object documents...
346
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
-     * @abstract
348
-     * @access protected
349
-     * @return void
350
-     */
351
-    abstract protected function _add_screen_options();
352
-
353
-
354
-
355
-    /**
356
-     * _add_feature_pointers
357
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
-     * Note: this is just a placeholder for now.  Implementation will come down the road
360
-     * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
-     *
362
-     * @link   http://eamann.com/tech/wordpress-portland/
363
-     * @abstract
364
-     * @access protected
365
-     * @return void
366
-     */
367
-    abstract protected function _add_feature_pointers();
368
-
369
-
370
-
371
-    /**
372
-     * load_scripts_styles
373
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
-     * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
-     *
376
-     * @abstract
377
-     * @access public
378
-     * @return void
379
-     */
380
-    abstract public function load_scripts_styles();
381
-
382
-
383
-
384
-    /**
385
-     * admin_init
386
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
-     *
388
-     * @abstract
389
-     * @access public
390
-     * @return void
391
-     */
392
-    abstract public function admin_init();
393
-
394
-
395
-
396
-    /**
397
-     * admin_notices
398
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
-     *
400
-     * @abstract
401
-     * @access public
402
-     * @return void
403
-     */
404
-    abstract public function admin_notices();
405
-
406
-
407
-
408
-    /**
409
-     * admin_footer_scripts
410
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
-     *
412
-     * @access public
413
-     * @return void
414
-     */
415
-    abstract public function admin_footer_scripts();
416
-
417
-
418
-
419
-    /**
420
-     * admin_footer
421
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
-     *
423
-     * @access  public
424
-     * @return void
425
-     */
426
-    public function admin_footer()
427
-    {
428
-    }
429
-
430
-
431
-
432
-    /**
433
-     * _global_ajax_hooks
434
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
-     * Note: within the ajax callback methods.
436
-     *
437
-     * @abstract
438
-     * @access protected
439
-     * @return void
440
-     */
441
-    protected function _global_ajax_hooks()
442
-    {
443
-        //for lazy loading of metabox content
444
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
-    }
446
-
447
-
448
-
449
-    public function ajax_metabox_content()
450
-    {
451
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
-        self::cached_rss_display($contentid, $url);
454
-        wp_die();
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * _page_setup
461
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
-     *
463
-     * @final
464
-     * @access protected
465
-     * @return void
466
-     */
467
-    final protected function _page_setup()
468
-    {
469
-        //requires?
470
-        //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.
471
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
472
-        //next verify if we need to load anything...
473
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
-        $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
-        global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
477
-        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
-            return false;
479
-        }
480
-        // 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
481
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
-        }
484
-        // then set blank or -1 action values to 'default'
485
-        $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
-        //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.
487
-        $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
-        $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
492
-        $this->_define_page_props();
493
-        $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
-        //default things
495
-        $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
-        //set page configs
497
-        $this->_set_page_routes();
498
-        $this->_set_page_config();
499
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
500
-        if (isset($this->_req_data['wp_referer'])) {
501
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
-        }
503
-        //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
504
-        if (method_exists($this, '_extend_page_config')) {
505
-            $this->_extend_page_config();
506
-        }
507
-        //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.
508
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
509
-            $this->_extend_page_config_for_cpt();
510
-        }
511
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
-        //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
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
-        }
518
-        //next route only if routing enabled
519
-        if ($this->_routing && ! defined('DOING_AJAX')) {
520
-            $this->_verify_routes();
521
-            //next let's just check user_access and kill if no access
522
-            $this->check_user_access();
523
-            if ($this->_is_UI_request) {
524
-                //admin_init stuff - global, all views for this page class, specific view
525
-                add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
-                }
529
-            } else {
530
-                //hijack regular WP loading and route admin request immediately
531
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
-                $this->route_admin_request();
533
-            }
534
-        }
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
-     *
542
-     * @access private
543
-     * @return void
544
-     */
545
-    private function _do_other_page_hooks()
546
-    {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
-        foreach ($registered_pages as $page) {
549
-            //now let's setup the file name and class that should be present
550
-            $classname = str_replace('.class.php', '', $page);
551
-            //autoloaders should take care of loading file
552
-            if ( ! class_exists($classname)) {
553
-                $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
-                $error_msg[] = $error_msg[0]
555
-                               . "\r\n"
556
-                               . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
-                                'event_espresso'), $page, '<br />', $classname);
558
-                throw new EE_Error(implode('||', $error_msg));
559
-            }
560
-            $a = new ReflectionClass($classname);
561
-            //notice we are passing the instance of this class to the hook object.
562
-            $hookobj[] = $a->newInstance($this);
563
-        }
564
-    }
565
-
566
-
567
-
568
-    public function load_page_dependencies()
569
-    {
570
-        try {
571
-            $this->_load_page_dependencies();
572
-        } catch (EE_Error $e) {
573
-            $e->get_error();
574
-        }
575
-    }
576
-
577
-
578
-
579
-    /**
580
-     * load_page_dependencies
581
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
-     *
583
-     * @access public
584
-     * @return void
585
-     */
586
-    protected function _load_page_dependencies()
587
-    {
588
-        //let's set the current_screen and screen options to override what WP set
589
-        $this->_current_screen = get_current_screen();
590
-        //load admin_notices - global, page class, and view specific
591
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
-        }
596
-        //load network admin_notices - global, page class, and view specific
597
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
-        }
601
-        //this will save any per_page screen options if they are present
602
-        $this->_set_per_page_screen_options();
603
-        //setup list table properties
604
-        $this->_set_list_table();
605
-        // 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.
606
-        $this->_add_registered_meta_boxes();
607
-        $this->_add_screen_columns();
608
-        //add screen options - global, page child class, and view specific
609
-        $this->_add_global_screen_options();
610
-        $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
-        }
614
-        //add help tab(s) and tours- set via page_config and qtips.
615
-        $this->_add_help_tour();
616
-        $this->_add_help_tabs();
617
-        $this->_add_qtips();
618
-        //add feature_pointers - global, page child class, and view specific
619
-        $this->_add_feature_pointers();
620
-        $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
-        }
624
-        //enqueue scripts/styles - global, page class, and view specific
625
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
-        }
630
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
-        //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
632
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
-        }
637
-        //admin footer scripts
638
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
-        }
643
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
-        //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * _set_defaults
652
-     * This sets some global defaults for class properties.
653
-     */
654
-    private function _set_defaults()
655
-    {
656
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
-        $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
-        $this->default_nav_tab_name = 'overview';
659
-        //init template args
660
-        $this->_template_args = array(
661
-                'admin_page_header'  => '',
662
-                'admin_page_content' => '',
663
-                'post_body_content'  => '',
664
-                'before_list_table'  => '',
665
-                'after_list_table'   => '',
666
-        );
667
-    }
668
-
669
-
670
-
671
-    /**
672
-     * route_admin_request
673
-     *
674
-     * @see    _route_admin_request()
675
-     * @access public
676
-     * @return void|exception error
677
-     */
678
-    public function route_admin_request()
679
-    {
680
-        try {
681
-            $this->_route_admin_request();
682
-        } catch (EE_Error $e) {
683
-            $e->get_error();
684
-        }
685
-    }
686
-
687
-
688
-
689
-    public function set_wp_page_slug($wp_page_slug)
690
-    {
691
-        $this->_wp_page_slug = $wp_page_slug;
692
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
-        if (is_network_admin()) {
694
-            $this->_wp_page_slug .= '-network';
695
-        }
696
-    }
697
-
698
-
699
-
700
-    /**
701
-     * _verify_routes
702
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
-     *
704
-     * @access protected
705
-     * @return void
706
-     */
707
-    protected function _verify_routes()
708
-    {
709
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
-        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
-            return false;
712
-        }
713
-        $this->_route = false;
714
-        $func = false;
715
-        $args = array();
716
-        // check that the page_routes array is not empty
717
-        if (empty($this->_page_routes)) {
718
-            // user error msg
719
-            $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
-            // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
-            throw new EE_Error($error_msg);
723
-        }
724
-        // and that the requested page route exists
725
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
-            $this->_route = $this->_page_routes[$this->_req_action];
727
-            $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
-        } else {
729
-            // user error msg
730
-            $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
-            // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
-            throw new EE_Error($error_msg);
734
-        }
735
-        // and that a default route exists
736
-        if ( ! array_key_exists('default', $this->_page_routes)) {
737
-            // user error msg
738
-            $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
-            // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
-            throw new EE_Error($error_msg);
742
-        }
743
-        //first lets' catch if the UI request has EVER been set.
744
-        if ($this->_is_UI_request === null) {
745
-            //lets set if this is a UI request or not.
746
-            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
-            //wait a minute... we might have a noheader in the route array
748
-            $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
-        }
750
-        $this->_set_current_labels();
751
-    }
752
-
753
-
754
-
755
-    /**
756
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
-     *
758
-     * @param  string $route the route name we're verifying
759
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
-     */
761
-    protected function _verify_route($route)
762
-    {
763
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
-            return true;
765
-        } else {
766
-            // user error msg
767
-            $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
-            // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
-            throw new EE_Error($error_msg);
771
-        }
772
-    }
773
-
774
-
775
-
776
-    /**
777
-     * perform nonce verification
778
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
-     *
780
-     * @param  string $nonce     The nonce sent
781
-     * @param  string $nonce_ref The nonce reference string (name0)
782
-     * @return mixed (bool|die)
783
-     */
784
-    protected function _verify_nonce($nonce, $nonce_ref)
785
-    {
786
-        // verify nonce against expected value
787
-        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
-            // these are not the droids you are looking for !!!
789
-            $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
-            if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
-            }
793
-            if ( ! defined('DOING_AJAX')) {
794
-                wp_die($msg);
795
-            } else {
796
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
-                $this->_return_json();
798
-            }
799
-        }
800
-    }
801
-
802
-
803
-
804
-    /**
805
-     * _route_admin_request()
806
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
-     * in the page routes and then will try to load the corresponding method.
809
-     *
810
-     * @access protected
811
-     * @return void
812
-     * @throws \EE_Error
813
-     */
814
-    protected function _route_admin_request()
815
-    {
816
-        if ( ! $this->_is_UI_request) {
817
-            $this->_verify_routes();
818
-        }
819
-        $nonce_check = isset($this->_route_config['require_nonce'])
820
-            ? $this->_route_config['require_nonce']
821
-            : true;
822
-        if ($this->_req_action !== 'default' && $nonce_check) {
823
-            // set nonce from post data
824
-            $nonce = isset($this->_req_data[$this->_req_nonce])
825
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
-                : '';
827
-            $this->_verify_nonce($nonce, $this->_req_nonce);
828
-        }
829
-        //set the nav_tabs array but ONLY if this is  UI_request
830
-        if ($this->_is_UI_request) {
831
-            $this->_set_nav_tabs();
832
-        }
833
-        // grab callback function
834
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
-        // check if callback has args
836
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
-        $error_msg = '';
838
-        // action right before calling route
839
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
-        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
-        }
843
-        // right before calling the route, let's remove _wp_http_referer from the
844
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
-        if ( ! empty($func)) {
847
-            if (is_array($func)) {
848
-                list($class, $method) = $func;
849
-            } else if (strpos($func, '::') !== false) {
850
-                list($class, $method) = explode('::', $func);
851
-            } else {
852
-                $class = $this;
853
-                $method = $func;
854
-            }
855
-            if ( ! (is_object($class) && $class === $this)) {
856
-                // send along this admin page object for access by addons.
857
-                $args['admin_page_object'] = $this;
858
-            }
859
-            if (
860
-                //is it a method on a class that doesn't work?
861
-                (
862
-                    method_exists($class, $method)
863
-                    && call_user_func_array(array($class, $method), $args) === false
864
-                )
865
-                || (
866
-                    //is it a standalone function that doesn't work?
867
-                    function_exists($method)
868
-                    && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
869
-                )
870
-                || (
871
-                    //is it neither a class method NOR a standalone function?
872
-                    ! method_exists($class, $method)
873
-                    && ! function_exists($method)
874
-                )
875
-            ) {
876
-                // user error msg
877
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
878
-                // developer error msg
879
-                $error_msg .= '||';
880
-                $error_msg .= sprintf(
881
-                    __(
882
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
883
-                        'event_espresso'
884
-                    ),
885
-                    $method
886
-                );
887
-            }
888
-            if ( ! empty($error_msg)) {
889
-                throw new EE_Error($error_msg);
890
-            }
891
-        }
892
-        //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.
893
-        //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.
894
-        if ($this->_is_UI_request === false
895
-            && is_array($this->_route)
896
-            && ! empty($this->_route['headers_sent_route'])
897
-        ) {
898
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
899
-        }
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * This method just allows the resetting of page properties in the case where a no headers
906
-     * route redirects to a headers route in its route config.
907
-     *
908
-     * @since   4.3.0
909
-     * @param  string $new_route New (non header) route to redirect to.
910
-     * @return   void
911
-     */
912
-    protected function _reset_routing_properties($new_route)
913
-    {
914
-        $this->_is_UI_request = true;
915
-        //now we set the current route to whatever the headers_sent_route is set at
916
-        $this->_req_data['action'] = $new_route;
917
-        //rerun page setup
918
-        $this->_page_setup();
919
-    }
920
-
921
-
922
-
923
-    /**
924
-     * _add_query_arg
925
-     * adds nonce to array of arguments then calls WP add_query_arg function
926
-     *(internally just uses EEH_URL's function with the same name)
927
-     *
928
-     * @access public
929
-     * @param array  $args
930
-     * @param string $url
931
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
932
-     *                                        url in an associative array indexed by the key 'wp_referer';
933
-     *                                        Example usage:
934
-     *                                        If the current page is:
935
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
936
-     *                                        &action=default&event_id=20&month_range=March%202015
937
-     *                                        &_wpnonce=5467821
938
-     *                                        and you call:
939
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
940
-     *                                        array(
941
-     *                                        'action' => 'resend_something',
942
-     *                                        'page=>espresso_registrations'
943
-     *                                        ),
944
-     *                                        $some_url,
945
-     *                                        true
946
-     *                                        );
947
-     *                                        It will produce a url in this structure:
948
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
949
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
950
-     *                                        month_range]=March%202015
951
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
952
-     * @return string
953
-     */
954
-    public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
955
-    {
956
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
957
-        if ($sticky) {
958
-            $request = $_REQUEST;
959
-            unset($request['_wp_http_referer']);
960
-            unset($request['wp_referer']);
961
-            foreach ($request as $key => $value) {
962
-                //do not add nonces
963
-                if (strpos($key, 'nonce') !== false) {
964
-                    continue;
965
-                }
966
-                $args['wp_referer[' . $key . ']'] = $value;
967
-            }
968
-        }
969
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     * This returns a generated link that will load the related help tab.
976
-     *
977
-     * @param  string $help_tab_id the id for the connected help tab
978
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
979
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
980
-     * @uses EEH_Template::get_help_tab_link()
981
-     * @return string              generated link
982
-     */
983
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
984
-    {
985
-        return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
986
-    }
987
-
988
-
989
-
990
-    /**
991
-     * _add_help_tabs
992
-     * Note child classes define their help tabs within the page_config array.
993
-     *
994
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
995
-     * @access protected
996
-     * @return void
997
-     */
998
-    protected function _add_help_tabs()
999
-    {
1000
-        $tour_buttons = '';
1001
-        if (isset($this->_page_config[$this->_req_action])) {
1002
-            $config = $this->_page_config[$this->_req_action];
1003
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1004
-            if (isset($this->_help_tour[$this->_req_action])) {
1005
-                $tb = array();
1006
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1007
-                foreach ($this->_help_tour['tours'] as $tour) {
1008
-                    //if this is the end tour then we don't need to setup a button
1009
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1010
-                        continue;
1011
-                    }
1012
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1013
-                }
1014
-                $tour_buttons .= implode('<br />', $tb);
1015
-                $tour_buttons .= '</div></div>';
1016
-            }
1017
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1018
-            if (is_array($config) && isset($config['help_sidebar'])) {
1019
-                //check that the callback given is valid
1020
-                if ( ! method_exists($this, $config['help_sidebar'])) {
1021
-                    throw new EE_Error(sprintf(__('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',
1022
-                            'event_espresso'), $config['help_sidebar'], get_class($this)));
1023
-                }
1024
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025
-                $content .= $tour_buttons; //add help tour buttons.
1026
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1027
-                $this->_current_screen->set_help_sidebar($content);
1028
-            }
1029
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1030
-            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1031
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1032
-            }
1033
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1034
-            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035
-                $_ht['id'] = $this->page_slug;
1036
-                $_ht['title'] = __('Help Tours', 'event_espresso');
1037
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1038
-                $this->_current_screen->add_help_tab($_ht);
1039
-            }/**/
1040
-            if ( ! isset($config['help_tabs'])) {
1041
-                return;
1042
-            } //no help tabs for this route
1043
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1044
-                //we're here so there ARE help tabs!
1045
-                //make sure we've got what we need
1046
-                if ( ! isset($cfg['title'])) {
1047
-                    throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1048
-                }
1049
-                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1050
-                    throw new EE_Error(__('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',
1051
-                            'event_espresso'));
1052
-                }
1053
-                //first priority goes to content.
1054
-                if ( ! empty($cfg['content'])) {
1055
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056
-                    //second priority goes to filename
1057
-                } else if ( ! empty($cfg['filename'])) {
1058
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1059
-                    //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)
1060
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1061
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062
-                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063
-                        EE_Error::add_error(sprintf(__('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',
1064
-                                'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1065
-                        return;
1066
-                    }
1067
-                    $template_args['admin_page_obj'] = $this;
1068
-                    $content = EEH_Template::display_template($file_path, $template_args, true);
1069
-                } else {
1070
-                    $content = '';
1071
-                }
1072
-                //check if callback is valid
1073
-                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1074
-                    EE_Error::add_error(sprintf(__('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.',
1075
-                            'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1076
-                    return;
1077
-                }
1078
-                //setup config array for help tab method
1079
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1080
-                $_ht = array(
1081
-                        'id'       => $id,
1082
-                        'title'    => $cfg['title'],
1083
-                        'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1084
-                        'content'  => $content,
1085
-                );
1086
-                $this->_current_screen->add_help_tab($_ht);
1087
-            }
1088
-        }
1089
-    }
1090
-
1091
-
1092
-
1093
-    /**
1094
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1095
-     *
1096
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1097
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1098
-     * @access protected
1099
-     * @return void
1100
-     */
1101
-    protected function _add_help_tour()
1102
-    {
1103
-        $tours = array();
1104
-        $this->_help_tour = array();
1105
-        //exit early if help tours are turned off globally
1106
-        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1107
-            return;
1108
-        }
1109
-        //loop through _page_config to find any help_tour defined
1110
-        foreach ($this->_page_config as $route => $config) {
1111
-            //we're only going to set things up for this route
1112
-            if ($route !== $this->_req_action) {
1113
-                continue;
1114
-            }
1115
-            if (isset($config['help_tour'])) {
1116
-                foreach ($config['help_tour'] as $tour) {
1117
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1118
-                    //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
1119
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1120
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121
-                    if ( ! is_readable($file_path)) {
1122
-                        EE_Error::add_error(sprintf(__('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', 'event_espresso'),
1123
-                                $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1124
-                        return;
1125
-                    }
1126
-                    require_once $file_path;
1127
-                    if ( ! class_exists($tour)) {
1128
-                        $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('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.',
1130
-                                        'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131
-                        throw new EE_Error(implode('||', $error_msg));
1132
-                    }
1133
-                    $a = new ReflectionClass($tour);
1134
-                    $tour_obj = $a->newInstance($this->_is_caf);
1135
-                    $tours[] = $tour_obj;
1136
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1137
-                }
1138
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1139
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1140
-                $tours[] = $end_stop_tour;
1141
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1142
-            }
1143
-        }
1144
-        if ( ! empty($tours)) {
1145
-            $this->_help_tour['tours'] = $tours;
1146
-        }
1147
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1148
-    }
1149
-
1150
-
1151
-
1152
-    /**
1153
-     * This simply sets up any qtips that have been defined in the page config
1154
-     *
1155
-     * @access protected
1156
-     * @return void
1157
-     */
1158
-    protected function _add_qtips()
1159
-    {
1160
-        if (isset($this->_route_config['qtips'])) {
1161
-            $qtips = (array)$this->_route_config['qtips'];
1162
-            //load qtip loader
1163
-            $path = array(
1164
-                    $this->_get_dir() . '/qtips/',
1165
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1166
-            );
1167
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1168
-        }
1169
-    }
1170
-
1171
-
1172
-
1173
-    /**
1174
-     * _set_nav_tabs
1175
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1176
-     *
1177
-     * @access protected
1178
-     * @return void
1179
-     */
1180
-    protected function _set_nav_tabs()
1181
-    {
1182
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1183
-        $i = 0;
1184
-        foreach ($this->_page_config as $slug => $config) {
1185
-            if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1186
-                continue;
1187
-            } //no nav tab for this config
1188
-            //check for persistent flag
1189
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1190
-                continue;
1191
-            } //nav tab is only to appear when route requested.
1192
-            if ( ! $this->check_user_access($slug, true)) {
1193
-                continue;
1194
-            } //no nav tab becasue current user does not have access.
1195
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1196
-            $this->_nav_tabs[$slug] = array(
1197
-                    'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198
-                    'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1200
-                    'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201
-            );
1202
-            $i++;
1203
-        }
1204
-        //if $this->_nav_tabs is empty then lets set the default
1205
-        if (empty($this->_nav_tabs)) {
1206
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1207
-                    'url'       => $this->admin_base_url,
1208
-                    'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1209
-                    'css_class' => 'nav-tab-active',
1210
-                    'order'     => 10,
1211
-            );
1212
-        }
1213
-        //now let's sort the tabs according to order
1214
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1215
-    }
1216
-
1217
-
1218
-
1219
-    /**
1220
-     * _set_current_labels
1221
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1222
-     *
1223
-     * @access private
1224
-     * @return void
1225
-     */
1226
-    private function _set_current_labels()
1227
-    {
1228
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1229
-            foreach ($this->_route_config['labels'] as $label => $text) {
1230
-                if (is_array($text)) {
1231
-                    foreach ($text as $sublabel => $subtext) {
1232
-                        $this->_labels[$label][$sublabel] = $subtext;
1233
-                    }
1234
-                } else {
1235
-                    $this->_labels[$label] = $text;
1236
-                }
1237
-            }
1238
-        }
1239
-    }
1240
-
1241
-
1242
-
1243
-    /**
1244
-     *        verifies user access for this admin page
1245
-     *
1246
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1247
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1248
-     * @return        BOOL|wp_die()
1249
-     */
1250
-    public function check_user_access($route_to_check = '', $verify_only = false)
1251
-    {
1252
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1253
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1254
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1255
-                ? $this->_page_routes[$route_to_check]['capability'] : null;
1256
-        if (empty($capability) && empty($route_to_check)) {
1257
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1258
-        } else {
1259
-            $capability = empty($capability) ? 'manage_options' : $capability;
1260
-        }
1261
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263
-            if ($verify_only) {
1264
-                return false;
1265
-            } else {
1266
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1267
-            }
1268
-        }
1269
-        return true;
1270
-    }
1271
-
1272
-
1273
-
1274
-    /**
1275
-     * admin_init_global
1276
-     * This runs all the code that we want executed within the WP admin_init hook.
1277
-     * This method executes for ALL EE Admin pages.
1278
-     *
1279
-     * @access public
1280
-     * @return void
1281
-     */
1282
-    public function admin_init_global()
1283
-    {
1284
-    }
1285
-
1286
-
1287
-
1288
-    /**
1289
-     * wp_loaded_global
1290
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1291
-     *
1292
-     * @access public
1293
-     * @return void
1294
-     */
1295
-    public function wp_loaded()
1296
-    {
1297
-    }
1298
-
1299
-
1300
-
1301
-    /**
1302
-     * admin_notices
1303
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1304
-     *
1305
-     * @access public
1306
-     * @return void
1307
-     */
1308
-    public function admin_notices_global()
1309
-    {
1310
-        $this->_display_no_javascript_warning();
1311
-        $this->_display_espresso_notices();
1312
-    }
1313
-
1314
-
1315
-
1316
-    public function network_admin_notices_global()
1317
-    {
1318
-        $this->_display_no_javascript_warning();
1319
-        $this->_display_espresso_notices();
1320
-    }
1321
-
1322
-
1323
-
1324
-    /**
1325
-     * admin_footer_scripts_global
1326
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1327
-     *
1328
-     * @access public
1329
-     * @return void
1330
-     */
1331
-    public function admin_footer_scripts_global()
1332
-    {
1333
-        $this->_add_admin_page_ajax_loading_img();
1334
-        $this->_add_admin_page_overlay();
1335
-        //if metaboxes are present we need to add the nonce field
1336
-        if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1337
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1338
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1339
-        }
1340
-    }
1341
-
1342
-
1343
-
1344
-    /**
1345
-     * admin_footer_global
1346
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1347
-     *
1348
-     * @access  public
1349
-     * @return  void
1350
-     */
1351
-    public function admin_footer_global()
1352
-    {
1353
-        //dialog container for dialog helper
1354
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1355
-        $d_cont .= '<div class="ee-notices"></div>';
1356
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1357
-        $d_cont .= '</div>';
1358
-        echo $d_cont;
1359
-        //help tour stuff?
1360
-        if (isset($this->_help_tour[$this->_req_action])) {
1361
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1362
-        }
1363
-        //current set timezone for timezone js
1364
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1365
-    }
1366
-
1367
-
1368
-
1369
-    /**
1370
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1371
-     * For child classes:
1372
-     * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1373
-     * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1374
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1375
-     *    'help_trigger_id' => array(
1376
-     *        'title' => __('localized title for popup', 'event_espresso'),
1377
-     *        'content' => __('localized content for popup', 'event_espresso')
1378
-     *    )
1379
-     * );
1380
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1381
-     *
1382
-     * @access protected
1383
-     * @return string content
1384
-     */
1385
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1386
-    {
1387
-        $content = '';
1388
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1389
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1390
-        //loop through the array and setup content
1391
-        foreach ($help_array as $trigger => $help) {
1392
-            //make sure the array is setup properly
1393
-            if ( ! isset($help['title']) || ! isset($help['content'])) {
1394
-                throw new EE_Error(__('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',
1395
-                        'event_espresso'));
1396
-            }
1397
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1398
-            $template_args = array(
1399
-                    'help_popup_id'      => $trigger,
1400
-                    'help_popup_title'   => $help['title'],
1401
-                    'help_popup_content' => $help['content'],
1402
-            );
1403
-            $content .= EEH_Template::display_template($template_path, $template_args, true);
1404
-        }
1405
-        if ($display) {
1406
-            echo $content;
1407
-        } else {
1408
-            return $content;
1409
-        }
1410
-    }
1411
-
1412
-
1413
-
1414
-    /**
1415
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1416
-     *
1417
-     * @access private
1418
-     * @return array properly formatted array for help popup content
1419
-     */
1420
-    private function _get_help_content()
1421
-    {
1422
-        //what is the method we're looking for?
1423
-        $method_name = '_help_popup_content_' . $this->_req_action;
1424
-        //if method doesn't exist let's get out.
1425
-        if ( ! method_exists($this, $method_name)) {
1426
-            return array();
1427
-        }
1428
-        //k we're good to go let's retrieve the help array
1429
-        $help_array = call_user_func(array($this, $method_name));
1430
-        //make sure we've got an array!
1431
-        if ( ! is_array($help_array)) {
1432
-            throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1433
-        }
1434
-        return $help_array;
1435
-    }
1436
-
1437
-
1438
-
1439
-    /**
1440
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1441
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1442
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1443
-     *
1444
-     * @access protected
1445
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1446
-     * @param boolean $display    if false then we return the trigger string
1447
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1448
-     * @return string
1449
-     */
1450
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1451
-    {
1452
-        if (defined('DOING_AJAX')) {
1453
-            return;
1454
-        }
1455
-        //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
1456
-        $help_array = $this->_get_help_content();
1457
-        $help_content = '';
1458
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1459
-            $help_array[$trigger_id] = array(
1460
-                    'title'   => __('Missing Content', 'event_espresso'),
1461
-                    'content' => __('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.)',
1462
-                            'event_espresso'),
1463
-            );
1464
-            $help_content = $this->_set_help_popup_content($help_array, false);
1465
-        }
1466
-        //let's setup the trigger
1467
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
-        $content = $content . $help_content;
1469
-        if ($display) {
1470
-            echo $content;
1471
-        } else {
1472
-            return $content;
1473
-        }
1474
-    }
1475
-
1476
-
1477
-
1478
-    /**
1479
-     * _add_global_screen_options
1480
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1481
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1482
-     *
1483
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1484
-     *         see also WP_Screen object documents...
1485
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1486
-     * @abstract
1487
-     * @access private
1488
-     * @return void
1489
-     */
1490
-    private function _add_global_screen_options()
1491
-    {
1492
-    }
1493
-
1494
-
1495
-
1496
-    /**
1497
-     * _add_global_feature_pointers
1498
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1499
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1500
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1501
-     *
1502
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1503
-     * @link   http://eamann.com/tech/wordpress-portland/
1504
-     * @abstract
1505
-     * @access protected
1506
-     * @return void
1507
-     */
1508
-    private function _add_global_feature_pointers()
1509
-    {
1510
-    }
1511
-
1512
-
1513
-
1514
-    /**
1515
-     * load_global_scripts_styles
1516
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1517
-     *
1518
-     * @return void
1519
-     */
1520
-    public function load_global_scripts_styles()
1521
-    {
1522
-        /** STYLES **/
1523
-        // add debugging styles
1524
-        if (WP_DEBUG) {
1525
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1526
-        }
1527
-        //register all styles
1528
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1530
-        //helpers styles
1531
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1532
-        //enqueue global styles
1533
-        wp_enqueue_style('ee-admin-css');
1534
-        /** SCRIPTS **/
1535
-        //register all scripts
1536
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540
-        // register jQuery Validate - see /includes/functions/wp_hooks.php
1541
-        add_filter('FHEE_load_jquery_validate', '__return_true');
1542
-        add_filter('FHEE_load_joyride', '__return_true');
1543
-        //script for sorting tables
1544
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1545
-        //script for parsing uri's
1546
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1547
-        //and parsing associative serialized form elements
1548
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1549
-        //helpers scripts
1550
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554
-        //google charts
1555
-        wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1556
-        //enqueue global scripts
1557
-        //taking care of metaboxes
1558
-        if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1559
-            wp_enqueue_script('dashboard');
1560
-        }
1561
-        //enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1562
-        if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1563
-            wp_enqueue_script('ee_admin_js');
1564
-            wp_enqueue_style('ee-admin-css');
1565
-        }
1566
-        //localize script for ajax lazy loading
1567
-        $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1568
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1569
-        /**
1570
-         * help tour stuff
1571
-         */
1572
-        if ( ! empty($this->_help_tour)) {
1573
-            //register the js for kicking things off
1574
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1575
-            //setup tours for the js tour object
1576
-            foreach ($this->_help_tour['tours'] as $tour) {
1577
-                $tours[] = array(
1578
-                        'id'      => $tour->get_slug(),
1579
-                        'options' => $tour->get_options(),
1580
-                );
1581
-            }
1582
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1583
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1584
-        }
1585
-    }
1586
-
1587
-
1588
-
1589
-    /**
1590
-     *        admin_footer_scripts_eei18n_js_strings
1591
-     *
1592
-     * @access        public
1593
-     * @return        void
1594
-     */
1595
-    public function admin_footer_scripts_eei18n_js_strings()
1596
-    {
1597
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1598
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __('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!!!', 'event_espresso');
1599
-        EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1600
-        EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1601
-        EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1602
-        EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1603
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1604
-        EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1605
-        EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1606
-        EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1607
-        EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1608
-        EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1609
-        EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1610
-        EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1611
-        EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1612
-        EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1613
-        EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1614
-        EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1615
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1616
-        EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1617
-        EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1618
-        EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1619
-        EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1620
-        EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1621
-        EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1622
-        EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1623
-        EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1624
-        EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1625
-        EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1626
-        EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1627
-        EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1628
-        EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1629
-        EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1630
-        EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1631
-        EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1632
-        EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1633
-        EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1634
-        EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1635
-        EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1636
-        EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1637
-        //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1638
-        //admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1639
-        //espresso_core is listed as a dependency of ee_admin_js.
1640
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1641
-    }
1642
-
1643
-
1644
-
1645
-    /**
1646
-     *        load enhanced xdebug styles for ppl with failing eyesight
1647
-     *
1648
-     * @access        public
1649
-     * @return        void
1650
-     */
1651
-    public function add_xdebug_style()
1652
-    {
1653
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1654
-    }
1655
-
1656
-
1657
-    /************************/
1658
-    /** LIST TABLE METHODS **/
1659
-    /************************/
1660
-    /**
1661
-     * this sets up the list table if the current view requires it.
1662
-     *
1663
-     * @access protected
1664
-     * @return void
1665
-     */
1666
-    protected function _set_list_table()
1667
-    {
1668
-        //first is this a list_table view?
1669
-        if ( ! isset($this->_route_config['list_table'])) {
1670
-            return;
1671
-        } //not a list_table view so get out.
1672
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
1673
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1674
-            //user error msg
1675
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1676
-            //developer error msg
1677
-            $error_msg .= '||' . sprintf(__('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.', 'event_espresso'),
1678
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1679
-            throw new EE_Error($error_msg);
1680
-        }
1681
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1682
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1683
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1684
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1685
-        $this->_set_list_table_view();
1686
-        $this->_set_list_table_object();
1687
-    }
1688
-
1689
-
1690
-
1691
-    /**
1692
-     *        set current view for List Table
1693
-     *
1694
-     * @access public
1695
-     * @return array
1696
-     */
1697
-    protected function _set_list_table_view()
1698
-    {
1699
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1700
-        // looking at active items or dumpster diving ?
1701
-        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1702
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1703
-        } else {
1704
-            $this->_view = sanitize_key($this->_req_data['status']);
1705
-        }
1706
-    }
1707
-
1708
-
1709
-
1710
-    /**
1711
-     * _set_list_table_object
1712
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1713
-     *
1714
-     * @throws \EE_Error
1715
-     */
1716
-    protected function _set_list_table_object()
1717
-    {
1718
-        if (isset($this->_route_config['list_table'])) {
1719
-            if ( ! class_exists($this->_route_config['list_table'])) {
1720
-                throw new EE_Error(
1721
-                        sprintf(
1722
-                                __(
1723
-                                        '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.',
1724
-                                        'event_espresso'
1725
-                                ),
1726
-                                $this->_route_config['list_table'],
1727
-                                get_class($this)
1728
-                        )
1729
-                );
1730
-            }
1731
-            $list_table = $this->_route_config['list_table'];
1732
-            $this->_list_table_object = new $list_table($this);
1733
-        }
1734
-    }
1735
-
1736
-
1737
-
1738
-    /**
1739
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1740
-     *
1741
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1742
-     *                                                    urls.  The array should be indexed by the view it is being
1743
-     *                                                    added to.
1744
-     * @return array
1745
-     */
1746
-    public function get_list_table_view_RLs($extra_query_args = array())
1747
-    {
1748
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1749
-        if (empty($this->_views)) {
1750
-            $this->_views = array();
1751
-        }
1752
-        // cycle thru views
1753
-        foreach ($this->_views as $key => $view) {
1754
-            $query_args = array();
1755
-            // check for current view
1756
-            $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1757
-            $query_args['action'] = $this->_req_action;
1758
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1759
-            $query_args['status'] = $view['slug'];
1760
-            //merge any other arguments sent in.
1761
-            if (isset($extra_query_args[$view['slug']])) {
1762
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1763
-            }
1764
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1765
-        }
1766
-        return $this->_views;
1767
-    }
1768
-
1769
-
1770
-
1771
-    /**
1772
-     * _entries_per_page_dropdown
1773
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
1774
-     *
1775
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1776
-     * @access protected
1777
-     * @param int $max_entries total number of rows in the table
1778
-     * @return string
1779
-     */
1780
-    protected function _entries_per_page_dropdown($max_entries = false)
1781
-    {
1782
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1783
-        $values = array(10, 25, 50, 100);
1784
-        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1785
-        if ($max_entries) {
1786
-            $values[] = $max_entries;
1787
-            sort($values);
1788
-        }
1789
-        $entries_per_page_dropdown = '
143
+	// yes / no array for admin form fields
144
+	protected $_yes_no_values = array();
145
+
146
+	//some default things shared by all child classes
147
+	protected $_default_espresso_metaboxes;
148
+
149
+	/**
150
+	 *    EE_Registry Object
151
+	 *
152
+	 * @var    EE_Registry
153
+	 * @access    protected
154
+	 */
155
+	protected $EE = null;
156
+
157
+
158
+
159
+	/**
160
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
161
+	 *
162
+	 * @var boolean
163
+	 */
164
+	protected $_is_caf = false;
165
+
166
+
167
+
168
+	/**
169
+	 * @Constructor
170
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
+	 * @access public
172
+	 */
173
+	public function __construct($routing = true)
174
+	{
175
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
+			$this->_is_caf = true;
177
+		}
178
+		$this->_yes_no_values = array(
179
+				array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
+				array('id' => false, 'text' => __('No', 'event_espresso')),
181
+		);
182
+		//set the _req_data property.
183
+		$this->_req_data = array_merge($_GET, $_POST);
184
+		//routing enabled?
185
+		$this->_routing = $routing;
186
+		//set initial page props (child method)
187
+		$this->_init_page_props();
188
+		//set global defaults
189
+		$this->_set_defaults();
190
+		//set early because incoming requests could be ajax related and we need to register those hooks.
191
+		$this->_global_ajax_hooks();
192
+		$this->_ajax_hooks();
193
+		//other_page_hooks have to be early too.
194
+		$this->_do_other_page_hooks();
195
+		//This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
+		if (method_exists($this, '_before_page_setup')) {
197
+			$this->_before_page_setup();
198
+		}
199
+		//set up page dependencies
200
+		$this->_page_setup();
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * _init_page_props
207
+	 * Child classes use to set at least the following properties:
208
+	 * $page_slug.
209
+	 * $page_label.
210
+	 *
211
+	 * @abstract
212
+	 * @access protected
213
+	 * @return void
214
+	 */
215
+	abstract protected function _init_page_props();
216
+
217
+
218
+
219
+	/**
220
+	 * _ajax_hooks
221
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
+	 * Note: within the ajax callback methods.
223
+	 *
224
+	 * @abstract
225
+	 * @access protected
226
+	 * @return void
227
+	 */
228
+	abstract protected function _ajax_hooks();
229
+
230
+
231
+
232
+	/**
233
+	 * _define_page_props
234
+	 * child classes define page properties in here.  Must include at least:
235
+	 * $_admin_base_url = base_url for all admin pages
236
+	 * $_admin_page_title = default admin_page_title for admin pages
237
+	 * $_labels = array of default labels for various automatically generated elements:
238
+	 *    array(
239
+	 *        'buttons' => array(
240
+	 *            'add' => __('label for add new button'),
241
+	 *            'edit' => __('label for edit button'),
242
+	 *            'delete' => __('label for delete button')
243
+	 *            )
244
+	 *        )
245
+	 *
246
+	 * @abstract
247
+	 * @access protected
248
+	 * @return void
249
+	 */
250
+	abstract protected function _define_page_props();
251
+
252
+
253
+
254
+	/**
255
+	 * _set_page_routes
256
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
+	 * route. Here's the format
258
+	 * $this->_page_routes = array(
259
+	 *        'default' => array(
260
+	 *            'func' => '_default_method_handling_route',
261
+	 *            'args' => array('array','of','args'),
262
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
+	 *        ),
267
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
+	 *        )
269
+	 * )
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _set_page_routes();
276
+
277
+
278
+
279
+	/**
280
+	 * _set_page_config
281
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
+	 * Format:
283
+	 * $this->_page_config = array(
284
+	 *        'default' => array(
285
+	 *            'labels' => array(
286
+	 *                'buttons' => array(
287
+	 *                    'add' => __('label for adding item'),
288
+	 *                    'edit' => __('label for editing item'),
289
+	 *                    'delete' => __('label for deleting item')
290
+	 *                ),
291
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
+	 *            'nav' => array(
294
+	 *                'label' => __('Label for Tab', 'event_espresso').
295
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
+	 *                'order' => 10, //required to indicate tab position.
298
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
+	 *            this flag to make sure the necessary js gets enqueued on page load.
303
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
+	 *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
307
+	 *                'tab_id' => array(
308
+	 *                    'title' => 'tab_title',
309
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
+	 *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
+	 *                    ),
313
+	 *                'tab2_id' => array(
314
+	 *                    'title' => 'tab2 title',
315
+	 *                    'filename' => 'file_name_2'
316
+	 *                    'callback' => 'callback_method_for_content',
317
+	 *                 ),
318
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
+	 *            'help_tour' => array(
320
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
+	 *            ),
323
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
+	 *            'require_nonce' to FALSE
325
+	 *            )
326
+	 * )
327
+	 *
328
+	 * @abstract
329
+	 * @access protected
330
+	 * @return void
331
+	 */
332
+	abstract protected function _set_page_config();
333
+
334
+
335
+
336
+
337
+
338
+	/** end sample help_tour methods **/
339
+	/**
340
+	 * _add_screen_options
341
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
+	 * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
+	 *
344
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
+	 *         see also WP_Screen object documents...
346
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
+	 * @abstract
348
+	 * @access protected
349
+	 * @return void
350
+	 */
351
+	abstract protected function _add_screen_options();
352
+
353
+
354
+
355
+	/**
356
+	 * _add_feature_pointers
357
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
360
+	 * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
+	 *
362
+	 * @link   http://eamann.com/tech/wordpress-portland/
363
+	 * @abstract
364
+	 * @access protected
365
+	 * @return void
366
+	 */
367
+	abstract protected function _add_feature_pointers();
368
+
369
+
370
+
371
+	/**
372
+	 * load_scripts_styles
373
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
+	 * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
+	 *
376
+	 * @abstract
377
+	 * @access public
378
+	 * @return void
379
+	 */
380
+	abstract public function load_scripts_styles();
381
+
382
+
383
+
384
+	/**
385
+	 * admin_init
386
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
+	 *
388
+	 * @abstract
389
+	 * @access public
390
+	 * @return void
391
+	 */
392
+	abstract public function admin_init();
393
+
394
+
395
+
396
+	/**
397
+	 * admin_notices
398
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
+	 *
400
+	 * @abstract
401
+	 * @access public
402
+	 * @return void
403
+	 */
404
+	abstract public function admin_notices();
405
+
406
+
407
+
408
+	/**
409
+	 * admin_footer_scripts
410
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
+	 *
412
+	 * @access public
413
+	 * @return void
414
+	 */
415
+	abstract public function admin_footer_scripts();
416
+
417
+
418
+
419
+	/**
420
+	 * admin_footer
421
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
+	 *
423
+	 * @access  public
424
+	 * @return void
425
+	 */
426
+	public function admin_footer()
427
+	{
428
+	}
429
+
430
+
431
+
432
+	/**
433
+	 * _global_ajax_hooks
434
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
+	 * Note: within the ajax callback methods.
436
+	 *
437
+	 * @abstract
438
+	 * @access protected
439
+	 * @return void
440
+	 */
441
+	protected function _global_ajax_hooks()
442
+	{
443
+		//for lazy loading of metabox content
444
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
+	}
446
+
447
+
448
+
449
+	public function ajax_metabox_content()
450
+	{
451
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
+		self::cached_rss_display($contentid, $url);
454
+		wp_die();
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * _page_setup
461
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
+	 *
463
+	 * @final
464
+	 * @access protected
465
+	 * @return void
466
+	 */
467
+	final protected function _page_setup()
468
+	{
469
+		//requires?
470
+		//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.
471
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
472
+		//next verify if we need to load anything...
473
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
+		global $ee_menu_slugs;
476
+		$ee_menu_slugs = (array)$ee_menu_slugs;
477
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
+			return false;
479
+		}
480
+		// 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
481
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
+		}
484
+		// then set blank or -1 action values to 'default'
485
+		$this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
+		//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.
487
+		$this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
+		$this->_current_view = $this->_req_action;
491
+		$this->_req_nonce = $this->_req_action . '_nonce';
492
+		$this->_define_page_props();
493
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
+		//default things
495
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
+		//set page configs
497
+		$this->_set_page_routes();
498
+		$this->_set_page_config();
499
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
500
+		if (isset($this->_req_data['wp_referer'])) {
501
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
+		}
503
+		//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
504
+		if (method_exists($this, '_extend_page_config')) {
505
+			$this->_extend_page_config();
506
+		}
507
+		//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.
508
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
509
+			$this->_extend_page_config_for_cpt();
510
+		}
511
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
512
+		$this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
+		$this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
+		//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
515
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
+		}
518
+		//next route only if routing enabled
519
+		if ($this->_routing && ! defined('DOING_AJAX')) {
520
+			$this->_verify_routes();
521
+			//next let's just check user_access and kill if no access
522
+			$this->check_user_access();
523
+			if ($this->_is_UI_request) {
524
+				//admin_init stuff - global, all views for this page class, specific view
525
+				add_action('admin_init', array($this, 'admin_init'), 10);
526
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
+				}
529
+			} else {
530
+				//hijack regular WP loading and route admin request immediately
531
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
+				$this->route_admin_request();
533
+			}
534
+		}
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
+	 *
542
+	 * @access private
543
+	 * @return void
544
+	 */
545
+	private function _do_other_page_hooks()
546
+	{
547
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
+		foreach ($registered_pages as $page) {
549
+			//now let's setup the file name and class that should be present
550
+			$classname = str_replace('.class.php', '', $page);
551
+			//autoloaders should take care of loading file
552
+			if ( ! class_exists($classname)) {
553
+				$error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
+				$error_msg[] = $error_msg[0]
555
+							   . "\r\n"
556
+							   . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
+								'event_espresso'), $page, '<br />', $classname);
558
+				throw new EE_Error(implode('||', $error_msg));
559
+			}
560
+			$a = new ReflectionClass($classname);
561
+			//notice we are passing the instance of this class to the hook object.
562
+			$hookobj[] = $a->newInstance($this);
563
+		}
564
+	}
565
+
566
+
567
+
568
+	public function load_page_dependencies()
569
+	{
570
+		try {
571
+			$this->_load_page_dependencies();
572
+		} catch (EE_Error $e) {
573
+			$e->get_error();
574
+		}
575
+	}
576
+
577
+
578
+
579
+	/**
580
+	 * load_page_dependencies
581
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
+	 *
583
+	 * @access public
584
+	 * @return void
585
+	 */
586
+	protected function _load_page_dependencies()
587
+	{
588
+		//let's set the current_screen and screen options to override what WP set
589
+		$this->_current_screen = get_current_screen();
590
+		//load admin_notices - global, page class, and view specific
591
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
593
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
+		}
596
+		//load network admin_notices - global, page class, and view specific
597
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
+		}
601
+		//this will save any per_page screen options if they are present
602
+		$this->_set_per_page_screen_options();
603
+		//setup list table properties
604
+		$this->_set_list_table();
605
+		// 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.
606
+		$this->_add_registered_meta_boxes();
607
+		$this->_add_screen_columns();
608
+		//add screen options - global, page child class, and view specific
609
+		$this->_add_global_screen_options();
610
+		$this->_add_screen_options();
611
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
+		}
614
+		//add help tab(s) and tours- set via page_config and qtips.
615
+		$this->_add_help_tour();
616
+		$this->_add_help_tabs();
617
+		$this->_add_qtips();
618
+		//add feature_pointers - global, page child class, and view specific
619
+		$this->_add_feature_pointers();
620
+		$this->_add_global_feature_pointers();
621
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
+		}
624
+		//enqueue scripts/styles - global, page class, and view specific
625
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
+		}
630
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
+		//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
632
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
+		}
637
+		//admin footer scripts
638
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
640
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
+		}
643
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
+		//targeted hook
645
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * _set_defaults
652
+	 * This sets some global defaults for class properties.
653
+	 */
654
+	private function _set_defaults()
655
+	{
656
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
+		$this->default_nav_tab_name = 'overview';
659
+		//init template args
660
+		$this->_template_args = array(
661
+				'admin_page_header'  => '',
662
+				'admin_page_content' => '',
663
+				'post_body_content'  => '',
664
+				'before_list_table'  => '',
665
+				'after_list_table'   => '',
666
+		);
667
+	}
668
+
669
+
670
+
671
+	/**
672
+	 * route_admin_request
673
+	 *
674
+	 * @see    _route_admin_request()
675
+	 * @access public
676
+	 * @return void|exception error
677
+	 */
678
+	public function route_admin_request()
679
+	{
680
+		try {
681
+			$this->_route_admin_request();
682
+		} catch (EE_Error $e) {
683
+			$e->get_error();
684
+		}
685
+	}
686
+
687
+
688
+
689
+	public function set_wp_page_slug($wp_page_slug)
690
+	{
691
+		$this->_wp_page_slug = $wp_page_slug;
692
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
+		if (is_network_admin()) {
694
+			$this->_wp_page_slug .= '-network';
695
+		}
696
+	}
697
+
698
+
699
+
700
+	/**
701
+	 * _verify_routes
702
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
+	 *
704
+	 * @access protected
705
+	 * @return void
706
+	 */
707
+	protected function _verify_routes()
708
+	{
709
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
+			return false;
712
+		}
713
+		$this->_route = false;
714
+		$func = false;
715
+		$args = array();
716
+		// check that the page_routes array is not empty
717
+		if (empty($this->_page_routes)) {
718
+			// user error msg
719
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
+			// developer error msg
721
+			$error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
+			throw new EE_Error($error_msg);
723
+		}
724
+		// and that the requested page route exists
725
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
+			$this->_route = $this->_page_routes[$this->_req_action];
727
+			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
+		} else {
729
+			// user error msg
730
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
+			// developer error msg
732
+			$error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
+			throw new EE_Error($error_msg);
734
+		}
735
+		// and that a default route exists
736
+		if ( ! array_key_exists('default', $this->_page_routes)) {
737
+			// user error msg
738
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
+			// developer error msg
740
+			$error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
+			throw new EE_Error($error_msg);
742
+		}
743
+		//first lets' catch if the UI request has EVER been set.
744
+		if ($this->_is_UI_request === null) {
745
+			//lets set if this is a UI request or not.
746
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
+			//wait a minute... we might have a noheader in the route array
748
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
+		}
750
+		$this->_set_current_labels();
751
+	}
752
+
753
+
754
+
755
+	/**
756
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
+	 *
758
+	 * @param  string $route the route name we're verifying
759
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
+	 */
761
+	protected function _verify_route($route)
762
+	{
763
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
+			return true;
765
+		} else {
766
+			// user error msg
767
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
+			// developer error msg
769
+			$error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
+			throw new EE_Error($error_msg);
771
+		}
772
+	}
773
+
774
+
775
+
776
+	/**
777
+	 * perform nonce verification
778
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
+	 *
780
+	 * @param  string $nonce     The nonce sent
781
+	 * @param  string $nonce_ref The nonce reference string (name0)
782
+	 * @return mixed (bool|die)
783
+	 */
784
+	protected function _verify_nonce($nonce, $nonce_ref)
785
+	{
786
+		// verify nonce against expected value
787
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
+			// these are not the droids you are looking for !!!
789
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
+			if (WP_DEBUG) {
791
+				$msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
+			}
793
+			if ( ! defined('DOING_AJAX')) {
794
+				wp_die($msg);
795
+			} else {
796
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
+				$this->_return_json();
798
+			}
799
+		}
800
+	}
801
+
802
+
803
+
804
+	/**
805
+	 * _route_admin_request()
806
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
+	 * in the page routes and then will try to load the corresponding method.
809
+	 *
810
+	 * @access protected
811
+	 * @return void
812
+	 * @throws \EE_Error
813
+	 */
814
+	protected function _route_admin_request()
815
+	{
816
+		if ( ! $this->_is_UI_request) {
817
+			$this->_verify_routes();
818
+		}
819
+		$nonce_check = isset($this->_route_config['require_nonce'])
820
+			? $this->_route_config['require_nonce']
821
+			: true;
822
+		if ($this->_req_action !== 'default' && $nonce_check) {
823
+			// set nonce from post data
824
+			$nonce = isset($this->_req_data[$this->_req_nonce])
825
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
+				: '';
827
+			$this->_verify_nonce($nonce, $this->_req_nonce);
828
+		}
829
+		//set the nav_tabs array but ONLY if this is  UI_request
830
+		if ($this->_is_UI_request) {
831
+			$this->_set_nav_tabs();
832
+		}
833
+		// grab callback function
834
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
+		// check if callback has args
836
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
+		$error_msg = '';
838
+		// action right before calling route
839
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
+		}
843
+		// right before calling the route, let's remove _wp_http_referer from the
844
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
+		if ( ! empty($func)) {
847
+			if (is_array($func)) {
848
+				list($class, $method) = $func;
849
+			} else if (strpos($func, '::') !== false) {
850
+				list($class, $method) = explode('::', $func);
851
+			} else {
852
+				$class = $this;
853
+				$method = $func;
854
+			}
855
+			if ( ! (is_object($class) && $class === $this)) {
856
+				// send along this admin page object for access by addons.
857
+				$args['admin_page_object'] = $this;
858
+			}
859
+			if (
860
+				//is it a method on a class that doesn't work?
861
+				(
862
+					method_exists($class, $method)
863
+					&& call_user_func_array(array($class, $method), $args) === false
864
+				)
865
+				|| (
866
+					//is it a standalone function that doesn't work?
867
+					function_exists($method)
868
+					&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
869
+				)
870
+				|| (
871
+					//is it neither a class method NOR a standalone function?
872
+					! method_exists($class, $method)
873
+					&& ! function_exists($method)
874
+				)
875
+			) {
876
+				// user error msg
877
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
878
+				// developer error msg
879
+				$error_msg .= '||';
880
+				$error_msg .= sprintf(
881
+					__(
882
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
883
+						'event_espresso'
884
+					),
885
+					$method
886
+				);
887
+			}
888
+			if ( ! empty($error_msg)) {
889
+				throw new EE_Error($error_msg);
890
+			}
891
+		}
892
+		//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.
893
+		//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.
894
+		if ($this->_is_UI_request === false
895
+			&& is_array($this->_route)
896
+			&& ! empty($this->_route['headers_sent_route'])
897
+		) {
898
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
899
+		}
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * This method just allows the resetting of page properties in the case where a no headers
906
+	 * route redirects to a headers route in its route config.
907
+	 *
908
+	 * @since   4.3.0
909
+	 * @param  string $new_route New (non header) route to redirect to.
910
+	 * @return   void
911
+	 */
912
+	protected function _reset_routing_properties($new_route)
913
+	{
914
+		$this->_is_UI_request = true;
915
+		//now we set the current route to whatever the headers_sent_route is set at
916
+		$this->_req_data['action'] = $new_route;
917
+		//rerun page setup
918
+		$this->_page_setup();
919
+	}
920
+
921
+
922
+
923
+	/**
924
+	 * _add_query_arg
925
+	 * adds nonce to array of arguments then calls WP add_query_arg function
926
+	 *(internally just uses EEH_URL's function with the same name)
927
+	 *
928
+	 * @access public
929
+	 * @param array  $args
930
+	 * @param string $url
931
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
932
+	 *                                        url in an associative array indexed by the key 'wp_referer';
933
+	 *                                        Example usage:
934
+	 *                                        If the current page is:
935
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
936
+	 *                                        &action=default&event_id=20&month_range=March%202015
937
+	 *                                        &_wpnonce=5467821
938
+	 *                                        and you call:
939
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
940
+	 *                                        array(
941
+	 *                                        'action' => 'resend_something',
942
+	 *                                        'page=>espresso_registrations'
943
+	 *                                        ),
944
+	 *                                        $some_url,
945
+	 *                                        true
946
+	 *                                        );
947
+	 *                                        It will produce a url in this structure:
948
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
949
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
950
+	 *                                        month_range]=March%202015
951
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
952
+	 * @return string
953
+	 */
954
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
955
+	{
956
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
957
+		if ($sticky) {
958
+			$request = $_REQUEST;
959
+			unset($request['_wp_http_referer']);
960
+			unset($request['wp_referer']);
961
+			foreach ($request as $key => $value) {
962
+				//do not add nonces
963
+				if (strpos($key, 'nonce') !== false) {
964
+					continue;
965
+				}
966
+				$args['wp_referer[' . $key . ']'] = $value;
967
+			}
968
+		}
969
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 * This returns a generated link that will load the related help tab.
976
+	 *
977
+	 * @param  string $help_tab_id the id for the connected help tab
978
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
979
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
980
+	 * @uses EEH_Template::get_help_tab_link()
981
+	 * @return string              generated link
982
+	 */
983
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
984
+	{
985
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
986
+	}
987
+
988
+
989
+
990
+	/**
991
+	 * _add_help_tabs
992
+	 * Note child classes define their help tabs within the page_config array.
993
+	 *
994
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
995
+	 * @access protected
996
+	 * @return void
997
+	 */
998
+	protected function _add_help_tabs()
999
+	{
1000
+		$tour_buttons = '';
1001
+		if (isset($this->_page_config[$this->_req_action])) {
1002
+			$config = $this->_page_config[$this->_req_action];
1003
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1004
+			if (isset($this->_help_tour[$this->_req_action])) {
1005
+				$tb = array();
1006
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1007
+				foreach ($this->_help_tour['tours'] as $tour) {
1008
+					//if this is the end tour then we don't need to setup a button
1009
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1010
+						continue;
1011
+					}
1012
+					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1013
+				}
1014
+				$tour_buttons .= implode('<br />', $tb);
1015
+				$tour_buttons .= '</div></div>';
1016
+			}
1017
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1018
+			if (is_array($config) && isset($config['help_sidebar'])) {
1019
+				//check that the callback given is valid
1020
+				if ( ! method_exists($this, $config['help_sidebar'])) {
1021
+					throw new EE_Error(sprintf(__('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',
1022
+							'event_espresso'), $config['help_sidebar'], get_class($this)));
1023
+				}
1024
+				$content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025
+				$content .= $tour_buttons; //add help tour buttons.
1026
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1027
+				$this->_current_screen->set_help_sidebar($content);
1028
+			}
1029
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1030
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1031
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1032
+			}
1033
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1034
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035
+				$_ht['id'] = $this->page_slug;
1036
+				$_ht['title'] = __('Help Tours', 'event_espresso');
1037
+				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1038
+				$this->_current_screen->add_help_tab($_ht);
1039
+			}/**/
1040
+			if ( ! isset($config['help_tabs'])) {
1041
+				return;
1042
+			} //no help tabs for this route
1043
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1044
+				//we're here so there ARE help tabs!
1045
+				//make sure we've got what we need
1046
+				if ( ! isset($cfg['title'])) {
1047
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1048
+				}
1049
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1050
+					throw new EE_Error(__('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',
1051
+							'event_espresso'));
1052
+				}
1053
+				//first priority goes to content.
1054
+				if ( ! empty($cfg['content'])) {
1055
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056
+					//second priority goes to filename
1057
+				} else if ( ! empty($cfg['filename'])) {
1058
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1059
+					//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)
1060
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1061
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063
+						EE_Error::add_error(sprintf(__('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',
1064
+								'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1065
+						return;
1066
+					}
1067
+					$template_args['admin_page_obj'] = $this;
1068
+					$content = EEH_Template::display_template($file_path, $template_args, true);
1069
+				} else {
1070
+					$content = '';
1071
+				}
1072
+				//check if callback is valid
1073
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1074
+					EE_Error::add_error(sprintf(__('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.',
1075
+							'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1076
+					return;
1077
+				}
1078
+				//setup config array for help tab method
1079
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1080
+				$_ht = array(
1081
+						'id'       => $id,
1082
+						'title'    => $cfg['title'],
1083
+						'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1084
+						'content'  => $content,
1085
+				);
1086
+				$this->_current_screen->add_help_tab($_ht);
1087
+			}
1088
+		}
1089
+	}
1090
+
1091
+
1092
+
1093
+	/**
1094
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1095
+	 *
1096
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1097
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1098
+	 * @access protected
1099
+	 * @return void
1100
+	 */
1101
+	protected function _add_help_tour()
1102
+	{
1103
+		$tours = array();
1104
+		$this->_help_tour = array();
1105
+		//exit early if help tours are turned off globally
1106
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1107
+			return;
1108
+		}
1109
+		//loop through _page_config to find any help_tour defined
1110
+		foreach ($this->_page_config as $route => $config) {
1111
+			//we're only going to set things up for this route
1112
+			if ($route !== $this->_req_action) {
1113
+				continue;
1114
+			}
1115
+			if (isset($config['help_tour'])) {
1116
+				foreach ($config['help_tour'] as $tour) {
1117
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1118
+					//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
1119
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1120
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121
+					if ( ! is_readable($file_path)) {
1122
+						EE_Error::add_error(sprintf(__('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', 'event_espresso'),
1123
+								$file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1124
+						return;
1125
+					}
1126
+					require_once $file_path;
1127
+					if ( ! class_exists($tour)) {
1128
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('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.',
1130
+										'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131
+						throw new EE_Error(implode('||', $error_msg));
1132
+					}
1133
+					$a = new ReflectionClass($tour);
1134
+					$tour_obj = $a->newInstance($this->_is_caf);
1135
+					$tours[] = $tour_obj;
1136
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1137
+				}
1138
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1139
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1140
+				$tours[] = $end_stop_tour;
1141
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1142
+			}
1143
+		}
1144
+		if ( ! empty($tours)) {
1145
+			$this->_help_tour['tours'] = $tours;
1146
+		}
1147
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1148
+	}
1149
+
1150
+
1151
+
1152
+	/**
1153
+	 * This simply sets up any qtips that have been defined in the page config
1154
+	 *
1155
+	 * @access protected
1156
+	 * @return void
1157
+	 */
1158
+	protected function _add_qtips()
1159
+	{
1160
+		if (isset($this->_route_config['qtips'])) {
1161
+			$qtips = (array)$this->_route_config['qtips'];
1162
+			//load qtip loader
1163
+			$path = array(
1164
+					$this->_get_dir() . '/qtips/',
1165
+					EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1166
+			);
1167
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1168
+		}
1169
+	}
1170
+
1171
+
1172
+
1173
+	/**
1174
+	 * _set_nav_tabs
1175
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1176
+	 *
1177
+	 * @access protected
1178
+	 * @return void
1179
+	 */
1180
+	protected function _set_nav_tabs()
1181
+	{
1182
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1183
+		$i = 0;
1184
+		foreach ($this->_page_config as $slug => $config) {
1185
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1186
+				continue;
1187
+			} //no nav tab for this config
1188
+			//check for persistent flag
1189
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1190
+				continue;
1191
+			} //nav tab is only to appear when route requested.
1192
+			if ( ! $this->check_user_access($slug, true)) {
1193
+				continue;
1194
+			} //no nav tab becasue current user does not have access.
1195
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1196
+			$this->_nav_tabs[$slug] = array(
1197
+					'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198
+					'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
+					'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1200
+					'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201
+			);
1202
+			$i++;
1203
+		}
1204
+		//if $this->_nav_tabs is empty then lets set the default
1205
+		if (empty($this->_nav_tabs)) {
1206
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1207
+					'url'       => $this->admin_base_url,
1208
+					'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1209
+					'css_class' => 'nav-tab-active',
1210
+					'order'     => 10,
1211
+			);
1212
+		}
1213
+		//now let's sort the tabs according to order
1214
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1215
+	}
1216
+
1217
+
1218
+
1219
+	/**
1220
+	 * _set_current_labels
1221
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1222
+	 *
1223
+	 * @access private
1224
+	 * @return void
1225
+	 */
1226
+	private function _set_current_labels()
1227
+	{
1228
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1229
+			foreach ($this->_route_config['labels'] as $label => $text) {
1230
+				if (is_array($text)) {
1231
+					foreach ($text as $sublabel => $subtext) {
1232
+						$this->_labels[$label][$sublabel] = $subtext;
1233
+					}
1234
+				} else {
1235
+					$this->_labels[$label] = $text;
1236
+				}
1237
+			}
1238
+		}
1239
+	}
1240
+
1241
+
1242
+
1243
+	/**
1244
+	 *        verifies user access for this admin page
1245
+	 *
1246
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1247
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1248
+	 * @return        BOOL|wp_die()
1249
+	 */
1250
+	public function check_user_access($route_to_check = '', $verify_only = false)
1251
+	{
1252
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1253
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1254
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1255
+				? $this->_page_routes[$route_to_check]['capability'] : null;
1256
+		if (empty($capability) && empty($route_to_check)) {
1257
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1258
+		} else {
1259
+			$capability = empty($capability) ? 'manage_options' : $capability;
1260
+		}
1261
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263
+			if ($verify_only) {
1264
+				return false;
1265
+			} else {
1266
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1267
+			}
1268
+		}
1269
+		return true;
1270
+	}
1271
+
1272
+
1273
+
1274
+	/**
1275
+	 * admin_init_global
1276
+	 * This runs all the code that we want executed within the WP admin_init hook.
1277
+	 * This method executes for ALL EE Admin pages.
1278
+	 *
1279
+	 * @access public
1280
+	 * @return void
1281
+	 */
1282
+	public function admin_init_global()
1283
+	{
1284
+	}
1285
+
1286
+
1287
+
1288
+	/**
1289
+	 * wp_loaded_global
1290
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1291
+	 *
1292
+	 * @access public
1293
+	 * @return void
1294
+	 */
1295
+	public function wp_loaded()
1296
+	{
1297
+	}
1298
+
1299
+
1300
+
1301
+	/**
1302
+	 * admin_notices
1303
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1304
+	 *
1305
+	 * @access public
1306
+	 * @return void
1307
+	 */
1308
+	public function admin_notices_global()
1309
+	{
1310
+		$this->_display_no_javascript_warning();
1311
+		$this->_display_espresso_notices();
1312
+	}
1313
+
1314
+
1315
+
1316
+	public function network_admin_notices_global()
1317
+	{
1318
+		$this->_display_no_javascript_warning();
1319
+		$this->_display_espresso_notices();
1320
+	}
1321
+
1322
+
1323
+
1324
+	/**
1325
+	 * admin_footer_scripts_global
1326
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1327
+	 *
1328
+	 * @access public
1329
+	 * @return void
1330
+	 */
1331
+	public function admin_footer_scripts_global()
1332
+	{
1333
+		$this->_add_admin_page_ajax_loading_img();
1334
+		$this->_add_admin_page_overlay();
1335
+		//if metaboxes are present we need to add the nonce field
1336
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1337
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1338
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1339
+		}
1340
+	}
1341
+
1342
+
1343
+
1344
+	/**
1345
+	 * admin_footer_global
1346
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1347
+	 *
1348
+	 * @access  public
1349
+	 * @return  void
1350
+	 */
1351
+	public function admin_footer_global()
1352
+	{
1353
+		//dialog container for dialog helper
1354
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1355
+		$d_cont .= '<div class="ee-notices"></div>';
1356
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1357
+		$d_cont .= '</div>';
1358
+		echo $d_cont;
1359
+		//help tour stuff?
1360
+		if (isset($this->_help_tour[$this->_req_action])) {
1361
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1362
+		}
1363
+		//current set timezone for timezone js
1364
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1365
+	}
1366
+
1367
+
1368
+
1369
+	/**
1370
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1371
+	 * For child classes:
1372
+	 * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1373
+	 * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1374
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1375
+	 *    'help_trigger_id' => array(
1376
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1377
+	 *        'content' => __('localized content for popup', 'event_espresso')
1378
+	 *    )
1379
+	 * );
1380
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1381
+	 *
1382
+	 * @access protected
1383
+	 * @return string content
1384
+	 */
1385
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1386
+	{
1387
+		$content = '';
1388
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1389
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1390
+		//loop through the array and setup content
1391
+		foreach ($help_array as $trigger => $help) {
1392
+			//make sure the array is setup properly
1393
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1394
+				throw new EE_Error(__('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',
1395
+						'event_espresso'));
1396
+			}
1397
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1398
+			$template_args = array(
1399
+					'help_popup_id'      => $trigger,
1400
+					'help_popup_title'   => $help['title'],
1401
+					'help_popup_content' => $help['content'],
1402
+			);
1403
+			$content .= EEH_Template::display_template($template_path, $template_args, true);
1404
+		}
1405
+		if ($display) {
1406
+			echo $content;
1407
+		} else {
1408
+			return $content;
1409
+		}
1410
+	}
1411
+
1412
+
1413
+
1414
+	/**
1415
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1416
+	 *
1417
+	 * @access private
1418
+	 * @return array properly formatted array for help popup content
1419
+	 */
1420
+	private function _get_help_content()
1421
+	{
1422
+		//what is the method we're looking for?
1423
+		$method_name = '_help_popup_content_' . $this->_req_action;
1424
+		//if method doesn't exist let's get out.
1425
+		if ( ! method_exists($this, $method_name)) {
1426
+			return array();
1427
+		}
1428
+		//k we're good to go let's retrieve the help array
1429
+		$help_array = call_user_func(array($this, $method_name));
1430
+		//make sure we've got an array!
1431
+		if ( ! is_array($help_array)) {
1432
+			throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1433
+		}
1434
+		return $help_array;
1435
+	}
1436
+
1437
+
1438
+
1439
+	/**
1440
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1441
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1442
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1443
+	 *
1444
+	 * @access protected
1445
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1446
+	 * @param boolean $display    if false then we return the trigger string
1447
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1448
+	 * @return string
1449
+	 */
1450
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1451
+	{
1452
+		if (defined('DOING_AJAX')) {
1453
+			return;
1454
+		}
1455
+		//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
1456
+		$help_array = $this->_get_help_content();
1457
+		$help_content = '';
1458
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1459
+			$help_array[$trigger_id] = array(
1460
+					'title'   => __('Missing Content', 'event_espresso'),
1461
+					'content' => __('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.)',
1462
+							'event_espresso'),
1463
+			);
1464
+			$help_content = $this->_set_help_popup_content($help_array, false);
1465
+		}
1466
+		//let's setup the trigger
1467
+		$content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
+		$content = $content . $help_content;
1469
+		if ($display) {
1470
+			echo $content;
1471
+		} else {
1472
+			return $content;
1473
+		}
1474
+	}
1475
+
1476
+
1477
+
1478
+	/**
1479
+	 * _add_global_screen_options
1480
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1481
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1482
+	 *
1483
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1484
+	 *         see also WP_Screen object documents...
1485
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1486
+	 * @abstract
1487
+	 * @access private
1488
+	 * @return void
1489
+	 */
1490
+	private function _add_global_screen_options()
1491
+	{
1492
+	}
1493
+
1494
+
1495
+
1496
+	/**
1497
+	 * _add_global_feature_pointers
1498
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1499
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1500
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1501
+	 *
1502
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1503
+	 * @link   http://eamann.com/tech/wordpress-portland/
1504
+	 * @abstract
1505
+	 * @access protected
1506
+	 * @return void
1507
+	 */
1508
+	private function _add_global_feature_pointers()
1509
+	{
1510
+	}
1511
+
1512
+
1513
+
1514
+	/**
1515
+	 * load_global_scripts_styles
1516
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1517
+	 *
1518
+	 * @return void
1519
+	 */
1520
+	public function load_global_scripts_styles()
1521
+	{
1522
+		/** STYLES **/
1523
+		// add debugging styles
1524
+		if (WP_DEBUG) {
1525
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1526
+		}
1527
+		//register all styles
1528
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1530
+		//helpers styles
1531
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1532
+		//enqueue global styles
1533
+		wp_enqueue_style('ee-admin-css');
1534
+		/** SCRIPTS **/
1535
+		//register all scripts
1536
+		wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
+		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
+		wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
+		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540
+		// register jQuery Validate - see /includes/functions/wp_hooks.php
1541
+		add_filter('FHEE_load_jquery_validate', '__return_true');
1542
+		add_filter('FHEE_load_joyride', '__return_true');
1543
+		//script for sorting tables
1544
+		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1545
+		//script for parsing uri's
1546
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1547
+		//and parsing associative serialized form elements
1548
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1549
+		//helpers scripts
1550
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
+		wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554
+		//google charts
1555
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1556
+		//enqueue global scripts
1557
+		//taking care of metaboxes
1558
+		if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1559
+			wp_enqueue_script('dashboard');
1560
+		}
1561
+		//enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1562
+		if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1563
+			wp_enqueue_script('ee_admin_js');
1564
+			wp_enqueue_style('ee-admin-css');
1565
+		}
1566
+		//localize script for ajax lazy loading
1567
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1568
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1569
+		/**
1570
+		 * help tour stuff
1571
+		 */
1572
+		if ( ! empty($this->_help_tour)) {
1573
+			//register the js for kicking things off
1574
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1575
+			//setup tours for the js tour object
1576
+			foreach ($this->_help_tour['tours'] as $tour) {
1577
+				$tours[] = array(
1578
+						'id'      => $tour->get_slug(),
1579
+						'options' => $tour->get_options(),
1580
+				);
1581
+			}
1582
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1583
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1584
+		}
1585
+	}
1586
+
1587
+
1588
+
1589
+	/**
1590
+	 *        admin_footer_scripts_eei18n_js_strings
1591
+	 *
1592
+	 * @access        public
1593
+	 * @return        void
1594
+	 */
1595
+	public function admin_footer_scripts_eei18n_js_strings()
1596
+	{
1597
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1598
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __('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!!!', 'event_espresso');
1599
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1600
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1601
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1602
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1603
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1604
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1605
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1606
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1607
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1608
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1609
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1610
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1611
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1612
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1613
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1614
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1615
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1616
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1617
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1618
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1619
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1620
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1621
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1622
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1623
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1624
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1625
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1626
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1627
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1628
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1629
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1630
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1631
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1632
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1633
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1634
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1635
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1636
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1637
+		//setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1638
+		//admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1639
+		//espresso_core is listed as a dependency of ee_admin_js.
1640
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1641
+	}
1642
+
1643
+
1644
+
1645
+	/**
1646
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1647
+	 *
1648
+	 * @access        public
1649
+	 * @return        void
1650
+	 */
1651
+	public function add_xdebug_style()
1652
+	{
1653
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1654
+	}
1655
+
1656
+
1657
+	/************************/
1658
+	/** LIST TABLE METHODS **/
1659
+	/************************/
1660
+	/**
1661
+	 * this sets up the list table if the current view requires it.
1662
+	 *
1663
+	 * @access protected
1664
+	 * @return void
1665
+	 */
1666
+	protected function _set_list_table()
1667
+	{
1668
+		//first is this a list_table view?
1669
+		if ( ! isset($this->_route_config['list_table'])) {
1670
+			return;
1671
+		} //not a list_table view so get out.
1672
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1673
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1674
+			//user error msg
1675
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1676
+			//developer error msg
1677
+			$error_msg .= '||' . sprintf(__('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.', 'event_espresso'),
1678
+							$this->_req_action, '_set_list_table_views_' . $this->_req_action);
1679
+			throw new EE_Error($error_msg);
1680
+		}
1681
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1682
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1683
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1684
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1685
+		$this->_set_list_table_view();
1686
+		$this->_set_list_table_object();
1687
+	}
1688
+
1689
+
1690
+
1691
+	/**
1692
+	 *        set current view for List Table
1693
+	 *
1694
+	 * @access public
1695
+	 * @return array
1696
+	 */
1697
+	protected function _set_list_table_view()
1698
+	{
1699
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1700
+		// looking at active items or dumpster diving ?
1701
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1702
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1703
+		} else {
1704
+			$this->_view = sanitize_key($this->_req_data['status']);
1705
+		}
1706
+	}
1707
+
1708
+
1709
+
1710
+	/**
1711
+	 * _set_list_table_object
1712
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1713
+	 *
1714
+	 * @throws \EE_Error
1715
+	 */
1716
+	protected function _set_list_table_object()
1717
+	{
1718
+		if (isset($this->_route_config['list_table'])) {
1719
+			if ( ! class_exists($this->_route_config['list_table'])) {
1720
+				throw new EE_Error(
1721
+						sprintf(
1722
+								__(
1723
+										'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.',
1724
+										'event_espresso'
1725
+								),
1726
+								$this->_route_config['list_table'],
1727
+								get_class($this)
1728
+						)
1729
+				);
1730
+			}
1731
+			$list_table = $this->_route_config['list_table'];
1732
+			$this->_list_table_object = new $list_table($this);
1733
+		}
1734
+	}
1735
+
1736
+
1737
+
1738
+	/**
1739
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1740
+	 *
1741
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1742
+	 *                                                    urls.  The array should be indexed by the view it is being
1743
+	 *                                                    added to.
1744
+	 * @return array
1745
+	 */
1746
+	public function get_list_table_view_RLs($extra_query_args = array())
1747
+	{
1748
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1749
+		if (empty($this->_views)) {
1750
+			$this->_views = array();
1751
+		}
1752
+		// cycle thru views
1753
+		foreach ($this->_views as $key => $view) {
1754
+			$query_args = array();
1755
+			// check for current view
1756
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1757
+			$query_args['action'] = $this->_req_action;
1758
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1759
+			$query_args['status'] = $view['slug'];
1760
+			//merge any other arguments sent in.
1761
+			if (isset($extra_query_args[$view['slug']])) {
1762
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1763
+			}
1764
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1765
+		}
1766
+		return $this->_views;
1767
+	}
1768
+
1769
+
1770
+
1771
+	/**
1772
+	 * _entries_per_page_dropdown
1773
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
1774
+	 *
1775
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1776
+	 * @access protected
1777
+	 * @param int $max_entries total number of rows in the table
1778
+	 * @return string
1779
+	 */
1780
+	protected function _entries_per_page_dropdown($max_entries = false)
1781
+	{
1782
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1783
+		$values = array(10, 25, 50, 100);
1784
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1785
+		if ($max_entries) {
1786
+			$values[] = $max_entries;
1787
+			sort($values);
1788
+		}
1789
+		$entries_per_page_dropdown = '
1790 1790
 			<div id="entries-per-page-dv" class="alignleft actions">
1791 1791
 				<label class="hide-if-no-js">
1792 1792
 					Show
1793 1793
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1794
-        foreach ($values as $value) {
1795
-            if ($value < $max_entries) {
1796
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1797
-                $entries_per_page_dropdown .= '
1794
+		foreach ($values as $value) {
1795
+			if ($value < $max_entries) {
1796
+				$selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1797
+				$entries_per_page_dropdown .= '
1798 1798
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1799
-            }
1800
-        }
1801
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1802
-        $entries_per_page_dropdown .= '
1799
+			}
1800
+		}
1801
+		$selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1802
+		$entries_per_page_dropdown .= '
1803 1803
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1804
-        $entries_per_page_dropdown .= '
1804
+		$entries_per_page_dropdown .= '
1805 1805
 					</select>
1806 1806
 					entries
1807 1807
 				</label>
1808 1808
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
1809 1809
 			</div>
1810 1810
 		';
1811
-        return $entries_per_page_dropdown;
1812
-    }
1813
-
1814
-
1815
-
1816
-    /**
1817
-     *        _set_search_attributes
1818
-     *
1819
-     * @access        protected
1820
-     * @return        void
1821
-     */
1822
-    public function _set_search_attributes()
1823
-    {
1824
-        $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1825
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1826
-    }
1827
-
1828
-    /*** END LIST TABLE METHODS **/
1829
-    /*****************************/
1830
-    /**
1831
-     *        _add_registered_metaboxes
1832
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1833
-     *
1834
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1835
-     * @access private
1836
-     * @return void
1837
-     */
1838
-    private function _add_registered_meta_boxes()
1839
-    {
1840
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1841
-        //we only add meta boxes if the page_route calls for it
1842
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1843
-            && is_array(
1844
-                    $this->_route_config['metaboxes']
1845
-            )
1846
-        ) {
1847
-            // this simply loops through the callbacks provided
1848
-            // and checks if there is a corresponding callback registered by the child
1849
-            // if there is then we go ahead and process the metabox loader.
1850
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1851
-                // first check for Closures
1852
-                if ($metabox_callback instanceof Closure) {
1853
-                    $result = $metabox_callback();
1854
-                } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1855
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1856
-                } else {
1857
-                    $result = call_user_func(array($this, &$metabox_callback));
1858
-                }
1859
-                if ($result === false) {
1860
-                    // user error msg
1861
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1862
-                    // developer error msg
1863
-                    $error_msg .= '||' . sprintf(
1864
-                                    __(
1865
-                                            '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.',
1866
-                                            'event_espresso'
1867
-                                    ),
1868
-                                    $metabox_callback
1869
-                            );
1870
-                    throw new EE_Error($error_msg);
1871
-                }
1872
-            }
1873
-        }
1874
-    }
1875
-
1876
-
1877
-
1878
-    /**
1879
-     * _add_screen_columns
1880
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1881
-     *
1882
-     * @access private
1883
-     * @return void
1884
-     */
1885
-    private function _add_screen_columns()
1886
-    {
1887
-        if (
1888
-                is_array($this->_route_config)
1889
-                && isset($this->_route_config['columns'])
1890
-                && is_array($this->_route_config['columns'])
1891
-                && count($this->_route_config['columns']) === 2
1892
-        ) {
1893
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1894
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1895
-            $screen_id = $this->_current_screen->id;
1896
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1897
-            $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1898
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1899
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
1900
-            $this->_template_args['screen'] = $this->_current_screen;
1901
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1902
-            //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.
1903
-            $this->_route_config['has_metaboxes'] = true;
1904
-        }
1905
-    }
1906
-
1907
-
1908
-
1909
-    /**********************************/
1910
-    /** GLOBALLY AVAILABLE METABOXES **/
1911
-    /**
1912
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1913
-     * loaded on.
1914
-     */
1915
-    private function _espresso_news_post_box()
1916
-    {
1917
-        $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1918
-        add_meta_box('espresso_news_post_box', $news_box_title, array(
1919
-                $this,
1920
-                'espresso_news_post_box',
1921
-        ), $this->_wp_page_slug, 'side');
1922
-    }
1923
-
1924
-
1925
-
1926
-    /**
1927
-     * Code for setting up espresso ratings request metabox.
1928
-     */
1929
-    protected function _espresso_ratings_request()
1930
-    {
1931
-        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1932
-            return '';
1933
-        }
1934
-        $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1935
-        add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1936
-                $this,
1937
-                'espresso_ratings_request',
1938
-        ), $this->_wp_page_slug, 'side');
1939
-    }
1940
-
1941
-
1942
-
1943
-    /**
1944
-     * Code for setting up espresso ratings request metabox content.
1945
-     */
1946
-    public function espresso_ratings_request()
1947
-    {
1948
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1949
-        EEH_Template::display_template($template_path, array());
1950
-    }
1951
-
1952
-
1953
-
1954
-    public static function cached_rss_display($rss_id, $url)
1955
-    {
1956
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1957
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1958
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1959
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1960
-        $post = '</div>' . "\n";
1961
-        $cache_key = 'ee_rss_' . md5($rss_id);
1962
-        if (false != ($output = get_transient($cache_key))) {
1963
-            echo $pre . $output . $post;
1964
-            return true;
1965
-        }
1966
-        if ( ! $doing_ajax) {
1967
-            echo $pre . $loading . $post;
1968
-            return false;
1969
-        }
1970
-        ob_start();
1971
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1972
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1973
-        return true;
1974
-    }
1975
-
1976
-
1977
-
1978
-    public function espresso_news_post_box()
1979
-    {
1980
-        ?>
1811
+		return $entries_per_page_dropdown;
1812
+	}
1813
+
1814
+
1815
+
1816
+	/**
1817
+	 *        _set_search_attributes
1818
+	 *
1819
+	 * @access        protected
1820
+	 * @return        void
1821
+	 */
1822
+	public function _set_search_attributes()
1823
+	{
1824
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1825
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1826
+	}
1827
+
1828
+	/*** END LIST TABLE METHODS **/
1829
+	/*****************************/
1830
+	/**
1831
+	 *        _add_registered_metaboxes
1832
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1833
+	 *
1834
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1835
+	 * @access private
1836
+	 * @return void
1837
+	 */
1838
+	private function _add_registered_meta_boxes()
1839
+	{
1840
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1841
+		//we only add meta boxes if the page_route calls for it
1842
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1843
+			&& is_array(
1844
+					$this->_route_config['metaboxes']
1845
+			)
1846
+		) {
1847
+			// this simply loops through the callbacks provided
1848
+			// and checks if there is a corresponding callback registered by the child
1849
+			// if there is then we go ahead and process the metabox loader.
1850
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1851
+				// first check for Closures
1852
+				if ($metabox_callback instanceof Closure) {
1853
+					$result = $metabox_callback();
1854
+				} else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1855
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1856
+				} else {
1857
+					$result = call_user_func(array($this, &$metabox_callback));
1858
+				}
1859
+				if ($result === false) {
1860
+					// user error msg
1861
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1862
+					// developer error msg
1863
+					$error_msg .= '||' . sprintf(
1864
+									__(
1865
+											'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.',
1866
+											'event_espresso'
1867
+									),
1868
+									$metabox_callback
1869
+							);
1870
+					throw new EE_Error($error_msg);
1871
+				}
1872
+			}
1873
+		}
1874
+	}
1875
+
1876
+
1877
+
1878
+	/**
1879
+	 * _add_screen_columns
1880
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1881
+	 *
1882
+	 * @access private
1883
+	 * @return void
1884
+	 */
1885
+	private function _add_screen_columns()
1886
+	{
1887
+		if (
1888
+				is_array($this->_route_config)
1889
+				&& isset($this->_route_config['columns'])
1890
+				&& is_array($this->_route_config['columns'])
1891
+				&& count($this->_route_config['columns']) === 2
1892
+		) {
1893
+			add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1894
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1895
+			$screen_id = $this->_current_screen->id;
1896
+			$screen_columns = (int)get_user_option("screen_layout_$screen_id");
1897
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1898
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1899
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
1900
+			$this->_template_args['screen'] = $this->_current_screen;
1901
+			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1902
+			//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.
1903
+			$this->_route_config['has_metaboxes'] = true;
1904
+		}
1905
+	}
1906
+
1907
+
1908
+
1909
+	/**********************************/
1910
+	/** GLOBALLY AVAILABLE METABOXES **/
1911
+	/**
1912
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1913
+	 * loaded on.
1914
+	 */
1915
+	private function _espresso_news_post_box()
1916
+	{
1917
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1918
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
1919
+				$this,
1920
+				'espresso_news_post_box',
1921
+		), $this->_wp_page_slug, 'side');
1922
+	}
1923
+
1924
+
1925
+
1926
+	/**
1927
+	 * Code for setting up espresso ratings request metabox.
1928
+	 */
1929
+	protected function _espresso_ratings_request()
1930
+	{
1931
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1932
+			return '';
1933
+		}
1934
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1935
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1936
+				$this,
1937
+				'espresso_ratings_request',
1938
+		), $this->_wp_page_slug, 'side');
1939
+	}
1940
+
1941
+
1942
+
1943
+	/**
1944
+	 * Code for setting up espresso ratings request metabox content.
1945
+	 */
1946
+	public function espresso_ratings_request()
1947
+	{
1948
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1949
+		EEH_Template::display_template($template_path, array());
1950
+	}
1951
+
1952
+
1953
+
1954
+	public static function cached_rss_display($rss_id, $url)
1955
+	{
1956
+		$loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1957
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1958
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
1959
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1960
+		$post = '</div>' . "\n";
1961
+		$cache_key = 'ee_rss_' . md5($rss_id);
1962
+		if (false != ($output = get_transient($cache_key))) {
1963
+			echo $pre . $output . $post;
1964
+			return true;
1965
+		}
1966
+		if ( ! $doing_ajax) {
1967
+			echo $pre . $loading . $post;
1968
+			return false;
1969
+		}
1970
+		ob_start();
1971
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1972
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1973
+		return true;
1974
+	}
1975
+
1976
+
1977
+
1978
+	public function espresso_news_post_box()
1979
+	{
1980
+		?>
1981 1981
         <div class="padding">
1982 1982
             <div id="espresso_news_post_box_content" class="infolinks">
1983 1983
                 <?php
1984
-                // Get RSS Feed(s)
1985
-                $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1986
-                $url = urlencode($feed_url);
1987
-                self::cached_rss_display('espresso_news_post_box_content', $url);
1988
-                ?>
1984
+				// Get RSS Feed(s)
1985
+				$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1986
+				$url = urlencode($feed_url);
1987
+				self::cached_rss_display('espresso_news_post_box_content', $url);
1988
+				?>
1989 1989
             </div>
1990 1990
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
1991 1991
         </div>
1992 1992
         <?php
1993
-    }
1994
-
1995
-
1996
-
1997
-    private function _espresso_links_post_box()
1998
-    {
1999
-        //Hiding until we actually have content to put in here...
2000
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2001
-    }
2002
-
2003
-
2004
-
2005
-    public function espresso_links_post_box()
2006
-    {
2007
-        //Hiding until we actually have content to put in here...
2008
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2009
-        //EEH_Template::display_template( $templatepath );
2010
-    }
2011
-
2012
-
2013
-
2014
-    protected function _espresso_sponsors_post_box()
2015
-    {
2016
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2017
-        if ($show_sponsors) {
2018
-            add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2019
-        }
2020
-    }
2021
-
2022
-
2023
-
2024
-    public function espresso_sponsors_post_box()
2025
-    {
2026
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2027
-        EEH_Template::display_template($templatepath);
2028
-    }
2029
-
2030
-
2031
-
2032
-    private function _publish_post_box()
2033
-    {
2034
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2035
-        //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)
2036
-        if ( ! empty($this->_labels['publishbox'])) {
2037
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2038
-        } else {
2039
-            $box_label = __('Publish', 'event_espresso');
2040
-        }
2041
-        $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2042
-        add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2043
-    }
2044
-
2045
-
2046
-
2047
-    public function editor_overview()
2048
-    {
2049
-        //if we have extra content set let's add it in if not make sure its empty
2050
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2051
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2052
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2053
-    }
2054
-
2055
-
2056
-    /** end of globally available metaboxes section **/
2057
-    /*************************************************/
2058
-    /**
2059
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2060
-     * protected method.
2061
-     *
2062
-     * @see   $this->_set_publish_post_box_vars for param details
2063
-     * @since 4.6.0
2064
-     */
2065
-    public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2066
-    {
2067
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2068
-    }
2069
-
2070
-
2071
-
2072
-    /**
2073
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2074
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2075
-     * save, and save and close buttons to work properly, then you will want to include a
2076
-     * values for the name and id arguments.
2077
-     *
2078
-     * @todo  Add in validation for name/id arguments.
2079
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2080
-     * @param    int     $id                      id attached to the item published
2081
-     * @param    string  $delete                  page route callback for the delete action
2082
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2083
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2084
-     * @throws \EE_Error
2085
-     */
2086
-    protected function _set_publish_post_box_vars(
2087
-            $name = '',
2088
-            $id = 0,
2089
-            $delete = '',
2090
-            $save_close_redirect_URL = '',
2091
-            $both_btns = true
2092
-    ) {
2093
-        // if Save & Close, use a custom redirect URL or default to the main page?
2094
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2095
-        // create the Save & Close and Save buttons
2096
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2097
-        //if we have extra content set let's add it in if not make sure its empty
2098
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2099
-        if ($delete && ! empty($id)) {
2100
-            //make sure we have a default if just true is sent.
2101
-            $delete = ! empty($delete) ? $delete : 'delete';
2102
-            $delete_link_args = array($name => $id);
2103
-            $delete = $this->get_action_link_or_button(
2104
-                    $delete,
2105
-                    $delete,
2106
-                    $delete_link_args,
2107
-                    'submitdelete deletion',
2108
-                    '',
2109
-                    false
2110
-            );
2111
-        }
2112
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2113
-        if ( ! empty($name) && ! empty($id)) {
2114
-            $hidden_field_arr[$name] = array(
2115
-                    'type'  => 'hidden',
2116
-                    'value' => $id,
2117
-            );
2118
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2119
-        } else {
2120
-            $hf = '';
2121
-        }
2122
-        // add hidden field
2123
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2124
-    }
2125
-
2126
-
2127
-
2128
-    /**
2129
-     *        displays an error message to ppl who have javascript disabled
2130
-     *
2131
-     * @access        private
2132
-     * @return        string
2133
-     */
2134
-    private function _display_no_javascript_warning()
2135
-    {
2136
-        ?>
1993
+	}
1994
+
1995
+
1996
+
1997
+	private function _espresso_links_post_box()
1998
+	{
1999
+		//Hiding until we actually have content to put in here...
2000
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2001
+	}
2002
+
2003
+
2004
+
2005
+	public function espresso_links_post_box()
2006
+	{
2007
+		//Hiding until we actually have content to put in here...
2008
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2009
+		//EEH_Template::display_template( $templatepath );
2010
+	}
2011
+
2012
+
2013
+
2014
+	protected function _espresso_sponsors_post_box()
2015
+	{
2016
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2017
+		if ($show_sponsors) {
2018
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2019
+		}
2020
+	}
2021
+
2022
+
2023
+
2024
+	public function espresso_sponsors_post_box()
2025
+	{
2026
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2027
+		EEH_Template::display_template($templatepath);
2028
+	}
2029
+
2030
+
2031
+
2032
+	private function _publish_post_box()
2033
+	{
2034
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2035
+		//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)
2036
+		if ( ! empty($this->_labels['publishbox'])) {
2037
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2038
+		} else {
2039
+			$box_label = __('Publish', 'event_espresso');
2040
+		}
2041
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2042
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2043
+	}
2044
+
2045
+
2046
+
2047
+	public function editor_overview()
2048
+	{
2049
+		//if we have extra content set let's add it in if not make sure its empty
2050
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2051
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2052
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2053
+	}
2054
+
2055
+
2056
+	/** end of globally available metaboxes section **/
2057
+	/*************************************************/
2058
+	/**
2059
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2060
+	 * protected method.
2061
+	 *
2062
+	 * @see   $this->_set_publish_post_box_vars for param details
2063
+	 * @since 4.6.0
2064
+	 */
2065
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2066
+	{
2067
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2068
+	}
2069
+
2070
+
2071
+
2072
+	/**
2073
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2074
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2075
+	 * save, and save and close buttons to work properly, then you will want to include a
2076
+	 * values for the name and id arguments.
2077
+	 *
2078
+	 * @todo  Add in validation for name/id arguments.
2079
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2080
+	 * @param    int     $id                      id attached to the item published
2081
+	 * @param    string  $delete                  page route callback for the delete action
2082
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2083
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2084
+	 * @throws \EE_Error
2085
+	 */
2086
+	protected function _set_publish_post_box_vars(
2087
+			$name = '',
2088
+			$id = 0,
2089
+			$delete = '',
2090
+			$save_close_redirect_URL = '',
2091
+			$both_btns = true
2092
+	) {
2093
+		// if Save & Close, use a custom redirect URL or default to the main page?
2094
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2095
+		// create the Save & Close and Save buttons
2096
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2097
+		//if we have extra content set let's add it in if not make sure its empty
2098
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2099
+		if ($delete && ! empty($id)) {
2100
+			//make sure we have a default if just true is sent.
2101
+			$delete = ! empty($delete) ? $delete : 'delete';
2102
+			$delete_link_args = array($name => $id);
2103
+			$delete = $this->get_action_link_or_button(
2104
+					$delete,
2105
+					$delete,
2106
+					$delete_link_args,
2107
+					'submitdelete deletion',
2108
+					'',
2109
+					false
2110
+			);
2111
+		}
2112
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2113
+		if ( ! empty($name) && ! empty($id)) {
2114
+			$hidden_field_arr[$name] = array(
2115
+					'type'  => 'hidden',
2116
+					'value' => $id,
2117
+			);
2118
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2119
+		} else {
2120
+			$hf = '';
2121
+		}
2122
+		// add hidden field
2123
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2124
+	}
2125
+
2126
+
2127
+
2128
+	/**
2129
+	 *        displays an error message to ppl who have javascript disabled
2130
+	 *
2131
+	 * @access        private
2132
+	 * @return        string
2133
+	 */
2134
+	private function _display_no_javascript_warning()
2135
+	{
2136
+		?>
2137 2137
         <noscript>
2138 2138
             <div id="no-js-message" class="error">
2139 2139
                 <p style="font-size:1.3em;">
@@ -2143,1231 +2143,1231 @@  discard block
 block discarded – undo
2143 2143
             </div>
2144 2144
         </noscript>
2145 2145
         <?php
2146
-    }
2146
+	}
2147 2147
 
2148 2148
 
2149 2149
 
2150
-    /**
2151
-     *        displays espresso success and/or error notices
2152
-     *
2153
-     * @access        private
2154
-     * @return        string
2155
-     */
2156
-    private function _display_espresso_notices()
2157
-    {
2158
-        $notices = $this->_get_transient(true);
2159
-        echo stripslashes($notices);
2160
-    }
2150
+	/**
2151
+	 *        displays espresso success and/or error notices
2152
+	 *
2153
+	 * @access        private
2154
+	 * @return        string
2155
+	 */
2156
+	private function _display_espresso_notices()
2157
+	{
2158
+		$notices = $this->_get_transient(true);
2159
+		echo stripslashes($notices);
2160
+	}
2161 2161
 
2162 2162
 
2163 2163
 
2164
-    /**
2165
-     *        spinny things pacify the masses
2166
-     *
2167
-     * @access private
2168
-     * @return string
2169
-     */
2170
-    protected function _add_admin_page_ajax_loading_img()
2171
-    {
2172
-        ?>
2164
+	/**
2165
+	 *        spinny things pacify the masses
2166
+	 *
2167
+	 * @access private
2168
+	 * @return string
2169
+	 */
2170
+	protected function _add_admin_page_ajax_loading_img()
2171
+	{
2172
+		?>
2173 2173
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2174 2174
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php _e('loading...', 'event_espresso'); ?></span>
2175 2175
         </div>
2176 2176
         <?php
2177
-    }
2177
+	}
2178 2178
 
2179 2179
 
2180 2180
 
2181
-    /**
2182
-     *        add admin page overlay for modal boxes
2183
-     *
2184
-     * @access private
2185
-     * @return string
2186
-     */
2187
-    protected function _add_admin_page_overlay()
2188
-    {
2189
-        ?>
2181
+	/**
2182
+	 *        add admin page overlay for modal boxes
2183
+	 *
2184
+	 * @access private
2185
+	 * @return string
2186
+	 */
2187
+	protected function _add_admin_page_overlay()
2188
+	{
2189
+		?>
2190 2190
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2191 2191
         <?php
2192
-    }
2193
-
2194
-
2195
-
2196
-    /**
2197
-     * facade for add_meta_box
2198
-     *
2199
-     * @param string  $action        where the metabox get's displayed
2200
-     * @param string  $title         Title of Metabox (output in metabox header)
2201
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2202
-     * @param array   $callback_args an array of args supplied for the metabox
2203
-     * @param string  $column        what metabox column
2204
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2205
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2206
-     */
2207
-    public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2208
-    {
2209
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2210
-        //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.
2211
-        if (empty($callback_args) && $create_func) {
2212
-            $callback_args = array(
2213
-                    'template_path' => $this->_template_path,
2214
-                    'template_args' => $this->_template_args,
2215
-            );
2216
-        }
2217
-        //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)
2218
-        $call_back_func = $create_func ? create_function('$post, $metabox',
2219
-                'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2220
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2221
-    }
2222
-
2223
-
2224
-
2225
-    /**
2226
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2227
-     *
2228
-     * @return [type] [description]
2229
-     */
2230
-    public function display_admin_page_with_metabox_columns()
2231
-    {
2232
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2233
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2234
-        //the final wrapper
2235
-        $this->admin_page_wrapper();
2236
-    }
2237
-
2238
-
2239
-
2240
-    /**
2241
-     *        generates  HTML wrapper for an admin details page
2242
-     *
2243
-     * @access public
2244
-     * @return void
2245
-     */
2246
-    public function display_admin_page_with_sidebar()
2247
-    {
2248
-        $this->_display_admin_page(true);
2249
-    }
2250
-
2251
-
2252
-
2253
-    /**
2254
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2255
-     *
2256
-     * @access public
2257
-     * @return void
2258
-     */
2259
-    public function display_admin_page_with_no_sidebar()
2260
-    {
2261
-        $this->_display_admin_page();
2262
-    }
2263
-
2264
-
2265
-
2266
-    /**
2267
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2268
-     *
2269
-     * @access public
2270
-     * @return void
2271
-     */
2272
-    public function display_about_admin_page()
2273
-    {
2274
-        $this->_display_admin_page(false, true);
2275
-    }
2276
-
2277
-
2278
-
2279
-    /**
2280
-     * display_admin_page
2281
-     * contains the code for actually displaying an admin page
2282
-     *
2283
-     * @access private
2284
-     * @param  boolean $sidebar true with sidebar, false without
2285
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2286
-     * @return void
2287
-     */
2288
-    private function _display_admin_page($sidebar = false, $about = false)
2289
-    {
2290
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2291
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2292
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2293
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2294
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2295
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2296
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2297
-                ? 'poststuff'
2298
-                : 'espresso-default-admin';
2299
-        $template_path = $sidebar
2300
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2301
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2302
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2303
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2304
-        }
2305
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2306
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2307
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2308
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2309
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2310
-        // the final template wrapper
2311
-        $this->admin_page_wrapper($about);
2312
-    }
2313
-
2314
-
2315
-
2316
-    /**
2317
-     * This is used to display caf preview pages.
2318
-     *
2319
-     * @since 4.3.2
2320
-     * @param string $utm_campaign_source what is the key used for google analytics link
2321
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2322
-     * @return void
2323
-     * @throws \EE_Error
2324
-     */
2325
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2326
-    {
2327
-        //let's generate a default preview action button if there isn't one already present.
2328
-        $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2329
-        $buy_now_url = add_query_arg(
2330
-                array(
2331
-                        'ee_ver'       => 'ee4',
2332
-                        'utm_source'   => 'ee4_plugin_admin',
2333
-                        'utm_medium'   => 'link',
2334
-                        'utm_campaign' => $utm_campaign_source,
2335
-                        'utm_content'  => 'buy_now_button',
2336
-                ),
2337
-                'http://eventespresso.com/pricing/'
2338
-        );
2339
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2340
-                ? $this->get_action_link_or_button(
2341
-                        '',
2342
-                        'buy_now',
2343
-                        array(),
2344
-                        'button-primary button-large',
2345
-                        $buy_now_url,
2346
-                        true
2347
-                )
2348
-                : $this->_template_args['preview_action_button'];
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2350
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2351
-                $template_path,
2352
-                $this->_template_args,
2353
-                true
2354
-        );
2355
-        $this->_display_admin_page($display_sidebar);
2356
-    }
2357
-
2358
-
2359
-
2360
-    /**
2361
-     * display_admin_list_table_page_with_sidebar
2362
-     * generates HTML wrapper for an admin_page with list_table
2363
-     *
2364
-     * @access public
2365
-     * @return void
2366
-     */
2367
-    public function display_admin_list_table_page_with_sidebar()
2368
-    {
2369
-        $this->_display_admin_list_table_page(true);
2370
-    }
2371
-
2372
-
2373
-
2374
-    /**
2375
-     * display_admin_list_table_page_with_no_sidebar
2376
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2377
-     *
2378
-     * @access public
2379
-     * @return void
2380
-     */
2381
-    public function display_admin_list_table_page_with_no_sidebar()
2382
-    {
2383
-        $this->_display_admin_list_table_page();
2384
-    }
2385
-
2386
-
2387
-
2388
-    /**
2389
-     * generates html wrapper for an admin_list_table page
2390
-     *
2391
-     * @access private
2392
-     * @param boolean $sidebar whether to display with sidebar or not.
2393
-     * @return void
2394
-     */
2395
-    private function _display_admin_list_table_page($sidebar = false)
2396
-    {
2397
-        //setup search attributes
2398
-        $this->_set_search_attributes();
2399
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2400
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2401
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2402
-                ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2403
-                : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2404
-        $this->_template_args['list_table'] = $this->_list_table_object;
2405
-        $this->_template_args['current_route'] = $this->_req_action;
2406
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2407
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2408
-        if ( ! empty($ajax_sorting_callback)) {
2409
-            $sortable_list_table_form_fields = wp_nonce_field(
2410
-                    $ajax_sorting_callback . '_nonce',
2411
-                    $ajax_sorting_callback . '_nonce',
2412
-                    false,
2413
-                    false
2414
-            );
2415
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2416
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2417
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2418
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2419
-        } else {
2420
-            $sortable_list_table_form_fields = '';
2421
-        }
2422
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2423
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2424
-        $nonce_ref = $this->_req_action . '_nonce';
2425
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2426
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2427
-        //display message about search results?
2428
-        $this->_template_args['before_list_table'] .= apply_filters(
2429
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2430
-                ! empty($this->_req_data['s'])
2431
-                        ? '<p class="ee-search-results">' . sprintf(
2432
-                                __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'),
2433
-                                trim($this->_req_data['s'], '%')
2434
-                        ) . '</p>'
2435
-                        : '',
2436
-                $this->page_slug,
2437
-                $this->_req_data,
2438
-                $this->_req_action
2439
-        );
2440
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2441
-                $template_path,
2442
-                $this->_template_args,
2443
-                true
2444
-        );
2445
-        // the final template wrapper
2446
-        if ($sidebar) {
2447
-            $this->display_admin_page_with_sidebar();
2448
-        } else {
2449
-            $this->display_admin_page_with_no_sidebar();
2450
-        }
2451
-    }
2452
-
2453
-
2454
-
2455
-    /**
2456
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2457
-     * $items are expected in an array in the following format:
2458
-     * $legend_items = array(
2459
-     *        'item_id' => array(
2460
-     *            'icon' => 'http://url_to_icon_being_described.png',
2461
-     *            'desc' => __('localized description of item');
2462
-     *        )
2463
-     * );
2464
-     *
2465
-     * @param  array $items see above for format of array
2466
-     * @return string        html string of legend
2467
-     */
2468
-    protected function _display_legend($items)
2469
-    {
2470
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2471
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2472
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2473
-    }
2474
-
2475
-
2476
-
2477
-    /**
2478
-     * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2479
-     *
2480
-     * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2481
-     *                             The returned json object is created from an array in the following format:
2482
-     *                             array(
2483
-     *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2484
-     *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2485
-     *                             'notices' => '', // - contains any EE_Error formatted notices
2486
-     *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2487
-     *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2488
-     *                             specific template args that might be included in here)
2489
-     *                             )
2490
-     *                             The json object is populated by whatever is set in the $_template_args property.
2491
-     * @return void
2492
-     */
2493
-    protected function _return_json($sticky_notices = false)
2494
-    {
2495
-        //make sure any EE_Error notices have been handled.
2496
-        $this->_process_notices(array(), true, $sticky_notices);
2497
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2498
-        unset($this->_template_args['data']);
2499
-        $json = array(
2500
-                'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2501
-                'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2502
-                'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2503
-                'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2504
-                'notices'   => EE_Error::get_notices(),
2505
-                'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2506
-                'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2507
-                'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2508
-        );
2509
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2510
-        if (null === error_get_last() || ! headers_sent()) {
2511
-            header('Content-Type: application/json; charset=UTF-8');
2512
-        }
2513
-        echo wp_json_encode($json);
2514
-
2515
-        exit();
2516
-    }
2517
-
2518
-
2519
-
2520
-    /**
2521
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2522
-     *
2523
-     * @return void
2524
-     * @throws EE_Error
2525
-     */
2526
-    public function return_json()
2527
-    {
2528
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2529
-            $this->_return_json();
2530
-        } else {
2531
-            throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2532
-        }
2533
-    }
2534
-
2535
-
2536
-
2537
-    /**
2538
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2539
-     *
2540
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2541
-     * @access   public
2542
-     */
2543
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
2544
-    {
2545
-        $this->_hook_obj = $hook_obj;
2546
-    }
2547
-
2548
-
2549
-
2550
-    /**
2551
-     *        generates  HTML wrapper with Tabbed nav for an admin page
2552
-     *
2553
-     * @access public
2554
-     * @param  boolean $about whether to use the special about page wrapper or default.
2555
-     * @return void
2556
-     */
2557
-    public function admin_page_wrapper($about = false)
2558
-    {
2559
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2560
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
2561
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2562
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2563
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2564
-                isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2565
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2566
-                isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2567
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2568
-        // load settings page wrapper template
2569
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2570
-        //about page?
2571
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2572
-        if (defined('DOING_AJAX')) {
2573
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2574
-            $this->_return_json();
2575
-        } else {
2576
-            EEH_Template::display_template($template_path, $this->_template_args);
2577
-        }
2578
-    }
2579
-
2580
-
2581
-
2582
-    /**
2583
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2584
-     *
2585
-     * @return string html
2586
-     */
2587
-    protected function _get_main_nav_tabs()
2588
-    {
2589
-        //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)
2590
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2591
-    }
2592
-
2593
-
2594
-
2595
-    /**
2596
-     *        sort nav tabs
2597
-     *
2598
-     * @access public
2599
-     * @param $a
2600
-     * @param $b
2601
-     * @return int
2602
-     */
2603
-    private function _sort_nav_tabs($a, $b)
2604
-    {
2605
-        if ($a['order'] == $b['order']) {
2606
-            return 0;
2607
-        }
2608
-        return ($a['order'] < $b['order']) ? -1 : 1;
2609
-    }
2610
-
2611
-
2612
-
2613
-    /**
2614
-     *    generates HTML for the forms used on admin pages
2615
-     *
2616
-     * @access protected
2617
-     * @param    array $input_vars - array of input field details
2618
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2619
-     * @return string
2620
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2621
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2622
-     */
2623
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2624
-    {
2625
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2626
-        return $content;
2627
-    }
2628
-
2629
-
2630
-
2631
-    /**
2632
-     * generates the "Save" and "Save & Close" buttons for edit forms
2633
-     *
2634
-     * @access protected
2635
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2636
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2637
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2638
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2639
-     */
2640
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2641
-    {
2642
-        //make sure $text and $actions are in an array
2643
-        $text = (array)$text;
2644
-        $actions = (array)$actions;
2645
-        $referrer_url = empty($referrer) ? '' : $referrer;
2646
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2647
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2648
-        $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2649
-        $default_names = array('save', 'save_and_close');
2650
-        //add in a hidden index for the current page (so save and close redirects properly)
2651
-        $this->_template_args['save_buttons'] = $referrer_url;
2652
-        foreach ($button_text as $key => $button) {
2653
-            $ref = $default_names[$key];
2654
-            $id = $this->_current_view . '_' . $ref;
2655
-            $name = ! empty($actions) ? $actions[$key] : $ref;
2656
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2657
-            if ( ! $both) {
2658
-                break;
2659
-            }
2660
-        }
2661
-    }
2662
-
2663
-
2664
-
2665
-    /**
2666
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2667
-     *
2668
-     * @see   $this->_set_add_edit_form_tags() for details on params
2669
-     * @since 4.6.0
2670
-     * @param string $route
2671
-     * @param array  $additional_hidden_fields
2672
-     */
2673
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2674
-    {
2675
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2676
-    }
2677
-
2678
-
2679
-
2680
-    /**
2681
-     * set form open and close tags on add/edit pages.
2682
-     *
2683
-     * @access protected
2684
-     * @param string $route                    the route you want the form to direct to
2685
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2686
-     * @return void
2687
-     */
2688
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2689
-    {
2690
-        if (empty($route)) {
2691
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2692
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2693
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2694
-        }
2695
-        // open form
2696
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2697
-        // add nonce
2698
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2699
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2700
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2701
-        // add REQUIRED form action
2702
-        $hidden_fields = array(
2703
-                'action' => array('type' => 'hidden', 'value' => $route),
2704
-        );
2705
-        // merge arrays
2706
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2707
-        // generate form fields
2708
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2709
-        // add fields to form
2710
-        foreach ((array)$form_fields as $field_name => $form_field) {
2711
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2712
-        }
2713
-        // close form
2714
-        $this->_template_args['after_admin_page_content'] = '</form>';
2715
-    }
2716
-
2717
-
2718
-
2719
-    /**
2720
-     * Public Wrapper for _redirect_after_action() method since its
2721
-     * discovered it would be useful for external code to have access.
2722
-     *
2723
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
2724
-     * @since 4.5.0
2725
-     */
2726
-    public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2727
-    {
2728
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2729
-    }
2730
-
2731
-
2732
-
2733
-    /**
2734
-     *    _redirect_after_action
2735
-     *
2736
-     * @param int    $success            - whether success was for two or more records, or just one, or none
2737
-     * @param string $what               - what the action was performed on
2738
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
2739
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2740
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2741
-     * @access protected
2742
-     * @return void
2743
-     */
2744
-    protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2745
-    {
2746
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2747
-        //class name for actions/filters.
2748
-        $classname = get_class($this);
2749
-        //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
2750
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2751
-        $notices = EE_Error::get_notices(false);
2752
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
2753
-        if ( ! $override_overwrite || ! empty($notices['errors'])) {
2754
-            EE_Error::overwrite_success();
2755
-        }
2756
-        if ( ! empty($what) && ! empty($action_desc)) {
2757
-            // how many records affected ? more than one record ? or just one ?
2758
-            if ($success > 1 && empty($notices['errors'])) {
2759
-                // set plural msg
2760
-                EE_Error::add_success(
2761
-                        sprintf(
2762
-                                __('The "%s" have been successfully %s.', 'event_espresso'),
2763
-                                $what,
2764
-                                $action_desc
2765
-                        ),
2766
-                        __FILE__, __FUNCTION__, __LINE__
2767
-                );
2768
-            } else if ($success == 1 && empty($notices['errors'])) {
2769
-                // set singular msg
2770
-                EE_Error::add_success(
2771
-                        sprintf(
2772
-                                __('The "%s" has been successfully %s.', 'event_espresso'),
2773
-                                $what,
2774
-                                $action_desc
2775
-                        ),
2776
-                        __FILE__, __FUNCTION__, __LINE__
2777
-                );
2778
-            }
2779
-        }
2780
-        // check that $query_args isn't something crazy
2781
-        if ( ! is_array($query_args)) {
2782
-            $query_args = array();
2783
-        }
2784
-        /**
2785
-         * Allow injecting actions before the query_args are modified for possible different
2786
-         * redirections on save and close actions
2787
-         *
2788
-         * @since 4.2.0
2789
-         * @param array $query_args       The original query_args array coming into the
2790
-         *                                method.
2791
-         */
2792
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2793
-        //calculate where we're going (if we have a "save and close" button pushed)
2794
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2795
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2796
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2797
-            // regenerate query args array from referrer URL
2798
-            parse_str($parsed_url['query'], $query_args);
2799
-            // correct page and action will be in the query args now
2800
-            $redirect_url = admin_url('admin.php');
2801
-        }
2802
-        //merge any default query_args set in _default_route_query_args property
2803
-        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2804
-            $args_to_merge = array();
2805
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
2806
-                //is there a wp_referer array in our _default_route_query_args property?
2807
-                if ($query_param == 'wp_referer') {
2808
-                    $query_value = (array)$query_value;
2809
-                    foreach ($query_value as $reference => $value) {
2810
-                        if (strpos($reference, 'nonce') !== false) {
2811
-                            continue;
2812
-                        }
2813
-                        //finally we will override any arguments in the referer with
2814
-                        //what might be set on the _default_route_query_args array.
2815
-                        if (isset($this->_default_route_query_args[$reference])) {
2816
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2817
-                        } else {
2818
-                            $args_to_merge[$reference] = urlencode($value);
2819
-                        }
2820
-                    }
2821
-                    continue;
2822
-                }
2823
-                $args_to_merge[$query_param] = $query_value;
2824
-            }
2825
-            //now let's merge these arguments but override with what was specifically sent in to the
2826
-            //redirect.
2827
-            $query_args = array_merge($args_to_merge, $query_args);
2828
-        }
2829
-        $this->_process_notices($query_args);
2830
-        // generate redirect url
2831
-        // if redirecting to anything other than the main page, add a nonce
2832
-        if (isset($query_args['action'])) {
2833
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2834
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2835
-        }
2836
-        //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).
2837
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2838
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2839
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2840
-        if (defined('DOING_AJAX')) {
2841
-            $default_data = array(
2842
-                    'close'        => true,
2843
-                    'redirect_url' => $redirect_url,
2844
-                    'where'        => 'main',
2845
-                    'what'         => 'append',
2846
-            );
2847
-            $this->_template_args['success'] = $success;
2848
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2849
-            $this->_return_json();
2850
-        }
2851
-        wp_safe_redirect($redirect_url);
2852
-        exit();
2853
-    }
2854
-
2855
-
2856
-
2857
-    /**
2858
-     * process any notices before redirecting (or returning ajax request)
2859
-     * This method sets the $this->_template_args['notices'] attribute;
2860
-     *
2861
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
2862
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2863
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2864
-     * @return void
2865
-     */
2866
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2867
-    {
2868
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
2869
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2870
-            $notices = EE_Error::get_notices(false);
2871
-            if (empty($this->_template_args['success'])) {
2872
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2873
-            }
2874
-            if (empty($this->_template_args['errors'])) {
2875
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2876
-            }
2877
-            if (empty($this->_template_args['attention'])) {
2878
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2879
-            }
2880
-        }
2881
-        $this->_template_args['notices'] = EE_Error::get_notices();
2882
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2883
-        if ( ! defined('DOING_AJAX') || $sticky_notices) {
2884
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
2885
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2886
-        }
2887
-    }
2888
-
2889
-
2890
-
2891
-    /**
2892
-     * get_action_link_or_button
2893
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
2894
-     *
2895
-     * @param string $action        use this to indicate which action the url is generated with.
2896
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2897
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2898
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2899
-     * @param string $base_url      If this is not provided
2900
-     *                              the _admin_base_url will be used as the default for the button base_url.
2901
-     *                              Otherwise this value will be used.
2902
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2903
-     * @return string
2904
-     * @throws \EE_Error
2905
-     */
2906
-    public function get_action_link_or_button(
2907
-            $action,
2908
-            $type = 'add',
2909
-            $extra_request = array(),
2910
-            $class = 'button-primary',
2911
-            $base_url = '',
2912
-            $exclude_nonce = false
2913
-    ) {
2914
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2915
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2916
-            throw new EE_Error(
2917
-                    sprintf(
2918
-                            __(
2919
-                                    'There is no page route for given action for the button.  This action was given: %s',
2920
-                                    'event_espresso'
2921
-                            ),
2922
-                            $action
2923
-                    )
2924
-            );
2925
-        }
2926
-        if ( ! isset($this->_labels['buttons'][$type])) {
2927
-            throw new EE_Error(
2928
-                    sprintf(
2929
-                            __(
2930
-                                    'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2931
-                                    'event_espresso'
2932
-                            ),
2933
-                            $type
2934
-                    )
2935
-            );
2936
-        }
2937
-        //finally check user access for this button.
2938
-        $has_access = $this->check_user_access($action, true);
2939
-        if ( ! $has_access) {
2940
-            return '';
2941
-        }
2942
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2943
-        $query_args = array(
2944
-                'action' => $action,
2945
-        );
2946
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2947
-        if ( ! empty($extra_request)) {
2948
-            $query_args = array_merge($extra_request, $query_args);
2949
-        }
2950
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2951
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2952
-    }
2953
-
2954
-
2955
-
2956
-    /**
2957
-     * _per_page_screen_option
2958
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
2959
-     *
2960
-     * @return void
2961
-     */
2962
-    protected function _per_page_screen_option()
2963
-    {
2964
-        $option = 'per_page';
2965
-        $args = array(
2966
-                'label'   => $this->_admin_page_title,
2967
-                'default' => 10,
2968
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2969
-        );
2970
-        //ONLY add the screen option if the user has access to it.
2971
-        if ($this->check_user_access($this->_current_view, true)) {
2972
-            add_screen_option($option, $args);
2973
-        }
2974
-    }
2975
-
2976
-
2977
-
2978
-    /**
2979
-     * set_per_page_screen_option
2980
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
2981
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
2982
-     *
2983
-     * @access private
2984
-     * @return void
2985
-     */
2986
-    private function _set_per_page_screen_options()
2987
-    {
2988
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
2989
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
2990
-            if ( ! $user = wp_get_current_user()) {
2991
-                return;
2992
-            }
2993
-            $option = $_POST['wp_screen_options']['option'];
2994
-            $value = $_POST['wp_screen_options']['value'];
2995
-            if ($option != sanitize_key($option)) {
2996
-                return;
2997
-            }
2998
-            $map_option = $option;
2999
-            $option = str_replace('-', '_', $option);
3000
-            switch ($map_option) {
3001
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3002
-                    $value = (int)$value;
3003
-                    if ($value < 1 || $value > 999) {
3004
-                        return;
3005
-                    }
3006
-                    break;
3007
-                default:
3008
-                    $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3009
-                    if (false === $value) {
3010
-                        return;
3011
-                    }
3012
-                    break;
3013
-            }
3014
-            update_user_meta($user->ID, $option, $value);
3015
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3016
-            exit;
3017
-        }
3018
-    }
3019
-
3020
-
3021
-
3022
-    /**
3023
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3024
-     *
3025
-     * @param array $data array that will be assigned to template args.
3026
-     */
3027
-    public function set_template_args($data)
3028
-    {
3029
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3030
-    }
3031
-
3032
-
3033
-
3034
-    /**
3035
-     * This makes available the WP transient system for temporarily moving data between routes
3036
-     *
3037
-     * @access protected
3038
-     * @param string $route             the route that should receive the transient
3039
-     * @param array  $data              the data that gets sent
3040
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3041
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3042
-     * @return void
3043
-     */
3044
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3045
-    {
3046
-        $user_id = get_current_user_id();
3047
-        if ( ! $skip_route_verify) {
3048
-            $this->_verify_route($route);
3049
-        }
3050
-        //now let's set the string for what kind of transient we're setting
3051
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3052
-        $data = $notices ? array('notices' => $data) : $data;
3053
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3054
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3055
-        if ($existing) {
3056
-            $data = array_merge((array)$data, (array)$existing);
3057
-        }
3058
-        if (is_multisite() && is_network_admin()) {
3059
-            set_site_transient($transient, $data, 8);
3060
-        } else {
3061
-            set_transient($transient, $data, 8);
3062
-        }
3063
-    }
3064
-
3065
-
3066
-
3067
-    /**
3068
-     * this retrieves the temporary transient that has been set for moving data between routes.
3069
-     *
3070
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3071
-     * @return mixed data
3072
-     */
3073
-    protected function _get_transient($notices = false, $route = false)
3074
-    {
3075
-        $user_id = get_current_user_id();
3076
-        $route = ! $route ? $this->_req_action : $route;
3077
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3078
-        $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3079
-        //delete transient after retrieval (just in case it hasn't expired);
3080
-        if (is_multisite() && is_network_admin()) {
3081
-            delete_site_transient($transient);
3082
-        } else {
3083
-            delete_transient($transient);
3084
-        }
3085
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3086
-    }
3087
-
3088
-
3089
-
3090
-    /**
3091
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3092
-     * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3093
-     *
3094
-     * @return void
3095
-     */
3096
-    protected function _transient_garbage_collection()
3097
-    {
3098
-        global $wpdb;
3099
-        //retrieve all existing transients
3100
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3101
-        if ($results = $wpdb->get_results($query)) {
3102
-            foreach ($results as $result) {
3103
-                $transient = str_replace('_transient_', '', $result->option_name);
3104
-                get_transient($transient);
3105
-                if (is_multisite() && is_network_admin()) {
3106
-                    get_site_transient($transient);
3107
-                }
3108
-            }
3109
-        }
3110
-    }
3111
-
3112
-
3113
-
3114
-    /**
3115
-     * get_view
3116
-     *
3117
-     * @access public
3118
-     * @return string content of _view property
3119
-     */
3120
-    public function get_view()
3121
-    {
3122
-        return $this->_view;
3123
-    }
3124
-
3125
-
3126
-
3127
-    /**
3128
-     * getter for the protected $_views property
3129
-     *
3130
-     * @return array
3131
-     */
3132
-    public function get_views()
3133
-    {
3134
-        return $this->_views;
3135
-    }
3136
-
3137
-
3138
-
3139
-    /**
3140
-     * get_current_page
3141
-     *
3142
-     * @access public
3143
-     * @return string _current_page property value
3144
-     */
3145
-    public function get_current_page()
3146
-    {
3147
-        return $this->_current_page;
3148
-    }
3149
-
3150
-
3151
-
3152
-    /**
3153
-     * get_current_view
3154
-     *
3155
-     * @access public
3156
-     * @return string _current_view property value
3157
-     */
3158
-    public function get_current_view()
3159
-    {
3160
-        return $this->_current_view;
3161
-    }
3162
-
3163
-
3164
-
3165
-    /**
3166
-     * get_current_screen
3167
-     *
3168
-     * @access public
3169
-     * @return object The current WP_Screen object
3170
-     */
3171
-    public function get_current_screen()
3172
-    {
3173
-        return $this->_current_screen;
3174
-    }
3175
-
3176
-
3177
-
3178
-    /**
3179
-     * get_current_page_view_url
3180
-     *
3181
-     * @access public
3182
-     * @return string This returns the url for the current_page_view.
3183
-     */
3184
-    public function get_current_page_view_url()
3185
-    {
3186
-        return $this->_current_page_view_url;
3187
-    }
3188
-
3189
-
3190
-
3191
-    /**
3192
-     * just returns the _req_data property
3193
-     *
3194
-     * @return array
3195
-     */
3196
-    public function get_request_data()
3197
-    {
3198
-        return $this->_req_data;
3199
-    }
3200
-
3201
-
3202
-
3203
-    /**
3204
-     * returns the _req_data protected property
3205
-     *
3206
-     * @return string
3207
-     */
3208
-    public function get_req_action()
3209
-    {
3210
-        return $this->_req_action;
3211
-    }
3212
-
3213
-
3214
-
3215
-    /**
3216
-     * @return bool  value of $_is_caf property
3217
-     */
3218
-    public function is_caf()
3219
-    {
3220
-        return $this->_is_caf;
3221
-    }
3222
-
3223
-
3224
-
3225
-    /**
3226
-     * @return mixed
3227
-     */
3228
-    public function default_espresso_metaboxes()
3229
-    {
3230
-        return $this->_default_espresso_metaboxes;
3231
-    }
3232
-
3233
-
3234
-
3235
-    /**
3236
-     * @return mixed
3237
-     */
3238
-    public function admin_base_url()
3239
-    {
3240
-        return $this->_admin_base_url;
3241
-    }
3242
-
3243
-
3244
-
3245
-    /**
3246
-     * @return mixed
3247
-     */
3248
-    public function wp_page_slug()
3249
-    {
3250
-        return $this->_wp_page_slug;
3251
-    }
3252
-
3253
-
3254
-
3255
-    /**
3256
-     * updates  espresso configuration settings
3257
-     *
3258
-     * @access    protected
3259
-     * @param string                   $tab
3260
-     * @param EE_Config_Base|EE_Config $config
3261
-     * @param string                   $file file where error occurred
3262
-     * @param string                   $func function  where error occurred
3263
-     * @param string                   $line line no where error occurred
3264
-     * @return boolean
3265
-     */
3266
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3267
-    {
3268
-        //remove any options that are NOT going to be saved with the config settings.
3269
-        if (isset($config->core->ee_ueip_optin)) {
3270
-            $config->core->ee_ueip_has_notified = true;
3271
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3272
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3273
-            update_option('ee_ueip_has_notified', true);
3274
-        }
3275
-        // and save it (note we're also doing the network save here)
3276
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3277
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3278
-        if ($config_saved && $net_saved) {
3279
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3280
-            return true;
3281
-        } else {
3282
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3283
-            return false;
3284
-        }
3285
-    }
3286
-
3287
-
3288
-
3289
-    /**
3290
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3291
-     *
3292
-     * @return array
3293
-     */
3294
-    public function get_yes_no_values()
3295
-    {
3296
-        return $this->_yes_no_values;
3297
-    }
3298
-
3299
-
3300
-
3301
-    protected function _get_dir()
3302
-    {
3303
-        $reflector = new ReflectionClass(get_class($this));
3304
-        return dirname($reflector->getFileName());
3305
-    }
3306
-
3307
-
3308
-
3309
-    /**
3310
-     * A helper for getting a "next link".
3311
-     *
3312
-     * @param string $url   The url to link to
3313
-     * @param string $class The class to use.
3314
-     * @return string
3315
-     */
3316
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3317
-    {
3318
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3319
-    }
3320
-
3321
-
3322
-
3323
-    /**
3324
-     * A helper for getting a "previous link".
3325
-     *
3326
-     * @param string $url   The url to link to
3327
-     * @param string $class The class to use.
3328
-     * @return string
3329
-     */
3330
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3331
-    {
3332
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3333
-    }
3334
-
3335
-
3336
-
3337
-
3338
-
3339
-
3340
-
3341
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3342
-    /**
3343
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller 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 _req_data
3344
-     * array.
3345
-     *
3346
-     * @return bool success/fail
3347
-     */
3348
-    protected function _process_resend_registration()
3349
-    {
3350
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3351
-        do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3352
-        return $this->_template_args['success'];
3353
-    }
3354
-
3355
-
3356
-
3357
-    /**
3358
-     * This automatically processes any payment message notifications when manual payment has been applied.
3359
-     *
3360
-     * @access protected
3361
-     * @param \EE_Payment $payment
3362
-     * @return bool success/fail
3363
-     */
3364
-    protected function _process_payment_notification(EE_Payment $payment)
3365
-    {
3366
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3367
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3368
-        $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3369
-        return $this->_template_args['success'];
3370
-    }
2192
+	}
2193
+
2194
+
2195
+
2196
+	/**
2197
+	 * facade for add_meta_box
2198
+	 *
2199
+	 * @param string  $action        where the metabox get's displayed
2200
+	 * @param string  $title         Title of Metabox (output in metabox header)
2201
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2202
+	 * @param array   $callback_args an array of args supplied for the metabox
2203
+	 * @param string  $column        what metabox column
2204
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2205
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2206
+	 */
2207
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2208
+	{
2209
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2210
+		//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.
2211
+		if (empty($callback_args) && $create_func) {
2212
+			$callback_args = array(
2213
+					'template_path' => $this->_template_path,
2214
+					'template_args' => $this->_template_args,
2215
+			);
2216
+		}
2217
+		//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)
2218
+		$call_back_func = $create_func ? create_function('$post, $metabox',
2219
+				'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2220
+		add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2221
+	}
2222
+
2223
+
2224
+
2225
+	/**
2226
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2227
+	 *
2228
+	 * @return [type] [description]
2229
+	 */
2230
+	public function display_admin_page_with_metabox_columns()
2231
+	{
2232
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2233
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2234
+		//the final wrapper
2235
+		$this->admin_page_wrapper();
2236
+	}
2237
+
2238
+
2239
+
2240
+	/**
2241
+	 *        generates  HTML wrapper for an admin details page
2242
+	 *
2243
+	 * @access public
2244
+	 * @return void
2245
+	 */
2246
+	public function display_admin_page_with_sidebar()
2247
+	{
2248
+		$this->_display_admin_page(true);
2249
+	}
2250
+
2251
+
2252
+
2253
+	/**
2254
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2255
+	 *
2256
+	 * @access public
2257
+	 * @return void
2258
+	 */
2259
+	public function display_admin_page_with_no_sidebar()
2260
+	{
2261
+		$this->_display_admin_page();
2262
+	}
2263
+
2264
+
2265
+
2266
+	/**
2267
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2268
+	 *
2269
+	 * @access public
2270
+	 * @return void
2271
+	 */
2272
+	public function display_about_admin_page()
2273
+	{
2274
+		$this->_display_admin_page(false, true);
2275
+	}
2276
+
2277
+
2278
+
2279
+	/**
2280
+	 * display_admin_page
2281
+	 * contains the code for actually displaying an admin page
2282
+	 *
2283
+	 * @access private
2284
+	 * @param  boolean $sidebar true with sidebar, false without
2285
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2286
+	 * @return void
2287
+	 */
2288
+	private function _display_admin_page($sidebar = false, $about = false)
2289
+	{
2290
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2291
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2292
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2293
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2294
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2295
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2296
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2297
+				? 'poststuff'
2298
+				: 'espresso-default-admin';
2299
+		$template_path = $sidebar
2300
+				? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2301
+				: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2302
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2303
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2304
+		}
2305
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2306
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2307
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2308
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2309
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2310
+		// the final template wrapper
2311
+		$this->admin_page_wrapper($about);
2312
+	}
2313
+
2314
+
2315
+
2316
+	/**
2317
+	 * This is used to display caf preview pages.
2318
+	 *
2319
+	 * @since 4.3.2
2320
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2321
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2322
+	 * @return void
2323
+	 * @throws \EE_Error
2324
+	 */
2325
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2326
+	{
2327
+		//let's generate a default preview action button if there isn't one already present.
2328
+		$this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2329
+		$buy_now_url = add_query_arg(
2330
+				array(
2331
+						'ee_ver'       => 'ee4',
2332
+						'utm_source'   => 'ee4_plugin_admin',
2333
+						'utm_medium'   => 'link',
2334
+						'utm_campaign' => $utm_campaign_source,
2335
+						'utm_content'  => 'buy_now_button',
2336
+				),
2337
+				'http://eventespresso.com/pricing/'
2338
+		);
2339
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2340
+				? $this->get_action_link_or_button(
2341
+						'',
2342
+						'buy_now',
2343
+						array(),
2344
+						'button-primary button-large',
2345
+						$buy_now_url,
2346
+						true
2347
+				)
2348
+				: $this->_template_args['preview_action_button'];
2349
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2350
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2351
+				$template_path,
2352
+				$this->_template_args,
2353
+				true
2354
+		);
2355
+		$this->_display_admin_page($display_sidebar);
2356
+	}
2357
+
2358
+
2359
+
2360
+	/**
2361
+	 * display_admin_list_table_page_with_sidebar
2362
+	 * generates HTML wrapper for an admin_page with list_table
2363
+	 *
2364
+	 * @access public
2365
+	 * @return void
2366
+	 */
2367
+	public function display_admin_list_table_page_with_sidebar()
2368
+	{
2369
+		$this->_display_admin_list_table_page(true);
2370
+	}
2371
+
2372
+
2373
+
2374
+	/**
2375
+	 * display_admin_list_table_page_with_no_sidebar
2376
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2377
+	 *
2378
+	 * @access public
2379
+	 * @return void
2380
+	 */
2381
+	public function display_admin_list_table_page_with_no_sidebar()
2382
+	{
2383
+		$this->_display_admin_list_table_page();
2384
+	}
2385
+
2386
+
2387
+
2388
+	/**
2389
+	 * generates html wrapper for an admin_list_table page
2390
+	 *
2391
+	 * @access private
2392
+	 * @param boolean $sidebar whether to display with sidebar or not.
2393
+	 * @return void
2394
+	 */
2395
+	private function _display_admin_list_table_page($sidebar = false)
2396
+	{
2397
+		//setup search attributes
2398
+		$this->_set_search_attributes();
2399
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2400
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2401
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2402
+				? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2403
+				: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2404
+		$this->_template_args['list_table'] = $this->_list_table_object;
2405
+		$this->_template_args['current_route'] = $this->_req_action;
2406
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2407
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2408
+		if ( ! empty($ajax_sorting_callback)) {
2409
+			$sortable_list_table_form_fields = wp_nonce_field(
2410
+					$ajax_sorting_callback . '_nonce',
2411
+					$ajax_sorting_callback . '_nonce',
2412
+					false,
2413
+					false
2414
+			);
2415
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2416
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2417
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2418
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2419
+		} else {
2420
+			$sortable_list_table_form_fields = '';
2421
+		}
2422
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2423
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2424
+		$nonce_ref = $this->_req_action . '_nonce';
2425
+		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2426
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2427
+		//display message about search results?
2428
+		$this->_template_args['before_list_table'] .= apply_filters(
2429
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2430
+				! empty($this->_req_data['s'])
2431
+						? '<p class="ee-search-results">' . sprintf(
2432
+								__('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'),
2433
+								trim($this->_req_data['s'], '%')
2434
+						) . '</p>'
2435
+						: '',
2436
+				$this->page_slug,
2437
+				$this->_req_data,
2438
+				$this->_req_action
2439
+		);
2440
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2441
+				$template_path,
2442
+				$this->_template_args,
2443
+				true
2444
+		);
2445
+		// the final template wrapper
2446
+		if ($sidebar) {
2447
+			$this->display_admin_page_with_sidebar();
2448
+		} else {
2449
+			$this->display_admin_page_with_no_sidebar();
2450
+		}
2451
+	}
2452
+
2453
+
2454
+
2455
+	/**
2456
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2457
+	 * $items are expected in an array in the following format:
2458
+	 * $legend_items = array(
2459
+	 *        'item_id' => array(
2460
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2461
+	 *            'desc' => __('localized description of item');
2462
+	 *        )
2463
+	 * );
2464
+	 *
2465
+	 * @param  array $items see above for format of array
2466
+	 * @return string        html string of legend
2467
+	 */
2468
+	protected function _display_legend($items)
2469
+	{
2470
+		$this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2471
+		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2472
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2473
+	}
2474
+
2475
+
2476
+
2477
+	/**
2478
+	 * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2479
+	 *
2480
+	 * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2481
+	 *                             The returned json object is created from an array in the following format:
2482
+	 *                             array(
2483
+	 *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2484
+	 *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2485
+	 *                             'notices' => '', // - contains any EE_Error formatted notices
2486
+	 *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2487
+	 *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2488
+	 *                             specific template args that might be included in here)
2489
+	 *                             )
2490
+	 *                             The json object is populated by whatever is set in the $_template_args property.
2491
+	 * @return void
2492
+	 */
2493
+	protected function _return_json($sticky_notices = false)
2494
+	{
2495
+		//make sure any EE_Error notices have been handled.
2496
+		$this->_process_notices(array(), true, $sticky_notices);
2497
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2498
+		unset($this->_template_args['data']);
2499
+		$json = array(
2500
+				'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2501
+				'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2502
+				'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2503
+				'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2504
+				'notices'   => EE_Error::get_notices(),
2505
+				'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2506
+				'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2507
+				'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2508
+		);
2509
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2510
+		if (null === error_get_last() || ! headers_sent()) {
2511
+			header('Content-Type: application/json; charset=UTF-8');
2512
+		}
2513
+		echo wp_json_encode($json);
2514
+
2515
+		exit();
2516
+	}
2517
+
2518
+
2519
+
2520
+	/**
2521
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2522
+	 *
2523
+	 * @return void
2524
+	 * @throws EE_Error
2525
+	 */
2526
+	public function return_json()
2527
+	{
2528
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2529
+			$this->_return_json();
2530
+		} else {
2531
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2532
+		}
2533
+	}
2534
+
2535
+
2536
+
2537
+	/**
2538
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2539
+	 *
2540
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2541
+	 * @access   public
2542
+	 */
2543
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
2544
+	{
2545
+		$this->_hook_obj = $hook_obj;
2546
+	}
2547
+
2548
+
2549
+
2550
+	/**
2551
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
2552
+	 *
2553
+	 * @access public
2554
+	 * @param  boolean $about whether to use the special about page wrapper or default.
2555
+	 * @return void
2556
+	 */
2557
+	public function admin_page_wrapper($about = false)
2558
+	{
2559
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2560
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
2561
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2562
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2563
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2564
+				isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2565
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2566
+				isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2567
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2568
+		// load settings page wrapper template
2569
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2570
+		//about page?
2571
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2572
+		if (defined('DOING_AJAX')) {
2573
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2574
+			$this->_return_json();
2575
+		} else {
2576
+			EEH_Template::display_template($template_path, $this->_template_args);
2577
+		}
2578
+	}
2579
+
2580
+
2581
+
2582
+	/**
2583
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2584
+	 *
2585
+	 * @return string html
2586
+	 */
2587
+	protected function _get_main_nav_tabs()
2588
+	{
2589
+		//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)
2590
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2591
+	}
2592
+
2593
+
2594
+
2595
+	/**
2596
+	 *        sort nav tabs
2597
+	 *
2598
+	 * @access public
2599
+	 * @param $a
2600
+	 * @param $b
2601
+	 * @return int
2602
+	 */
2603
+	private function _sort_nav_tabs($a, $b)
2604
+	{
2605
+		if ($a['order'] == $b['order']) {
2606
+			return 0;
2607
+		}
2608
+		return ($a['order'] < $b['order']) ? -1 : 1;
2609
+	}
2610
+
2611
+
2612
+
2613
+	/**
2614
+	 *    generates HTML for the forms used on admin pages
2615
+	 *
2616
+	 * @access protected
2617
+	 * @param    array $input_vars - array of input field details
2618
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2619
+	 * @return string
2620
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2621
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2622
+	 */
2623
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2624
+	{
2625
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2626
+		return $content;
2627
+	}
2628
+
2629
+
2630
+
2631
+	/**
2632
+	 * generates the "Save" and "Save & Close" buttons for edit forms
2633
+	 *
2634
+	 * @access protected
2635
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2636
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2637
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2638
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2639
+	 */
2640
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2641
+	{
2642
+		//make sure $text and $actions are in an array
2643
+		$text = (array)$text;
2644
+		$actions = (array)$actions;
2645
+		$referrer_url = empty($referrer) ? '' : $referrer;
2646
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2647
+				: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2648
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2649
+		$default_names = array('save', 'save_and_close');
2650
+		//add in a hidden index for the current page (so save and close redirects properly)
2651
+		$this->_template_args['save_buttons'] = $referrer_url;
2652
+		foreach ($button_text as $key => $button) {
2653
+			$ref = $default_names[$key];
2654
+			$id = $this->_current_view . '_' . $ref;
2655
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2656
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2657
+			if ( ! $both) {
2658
+				break;
2659
+			}
2660
+		}
2661
+	}
2662
+
2663
+
2664
+
2665
+	/**
2666
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2667
+	 *
2668
+	 * @see   $this->_set_add_edit_form_tags() for details on params
2669
+	 * @since 4.6.0
2670
+	 * @param string $route
2671
+	 * @param array  $additional_hidden_fields
2672
+	 */
2673
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2674
+	{
2675
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2676
+	}
2677
+
2678
+
2679
+
2680
+	/**
2681
+	 * set form open and close tags on add/edit pages.
2682
+	 *
2683
+	 * @access protected
2684
+	 * @param string $route                    the route you want the form to direct to
2685
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2686
+	 * @return void
2687
+	 */
2688
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2689
+	{
2690
+		if (empty($route)) {
2691
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2692
+			$dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2693
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2694
+		}
2695
+		// open form
2696
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2697
+		// add nonce
2698
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2699
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2700
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2701
+		// add REQUIRED form action
2702
+		$hidden_fields = array(
2703
+				'action' => array('type' => 'hidden', 'value' => $route),
2704
+		);
2705
+		// merge arrays
2706
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2707
+		// generate form fields
2708
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2709
+		// add fields to form
2710
+		foreach ((array)$form_fields as $field_name => $form_field) {
2711
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2712
+		}
2713
+		// close form
2714
+		$this->_template_args['after_admin_page_content'] = '</form>';
2715
+	}
2716
+
2717
+
2718
+
2719
+	/**
2720
+	 * Public Wrapper for _redirect_after_action() method since its
2721
+	 * discovered it would be useful for external code to have access.
2722
+	 *
2723
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
2724
+	 * @since 4.5.0
2725
+	 */
2726
+	public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2727
+	{
2728
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2729
+	}
2730
+
2731
+
2732
+
2733
+	/**
2734
+	 *    _redirect_after_action
2735
+	 *
2736
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
2737
+	 * @param string $what               - what the action was performed on
2738
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
2739
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2740
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2741
+	 * @access protected
2742
+	 * @return void
2743
+	 */
2744
+	protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2745
+	{
2746
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2747
+		//class name for actions/filters.
2748
+		$classname = get_class($this);
2749
+		//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
2750
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2751
+		$notices = EE_Error::get_notices(false);
2752
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
2753
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2754
+			EE_Error::overwrite_success();
2755
+		}
2756
+		if ( ! empty($what) && ! empty($action_desc)) {
2757
+			// how many records affected ? more than one record ? or just one ?
2758
+			if ($success > 1 && empty($notices['errors'])) {
2759
+				// set plural msg
2760
+				EE_Error::add_success(
2761
+						sprintf(
2762
+								__('The "%s" have been successfully %s.', 'event_espresso'),
2763
+								$what,
2764
+								$action_desc
2765
+						),
2766
+						__FILE__, __FUNCTION__, __LINE__
2767
+				);
2768
+			} else if ($success == 1 && empty($notices['errors'])) {
2769
+				// set singular msg
2770
+				EE_Error::add_success(
2771
+						sprintf(
2772
+								__('The "%s" has been successfully %s.', 'event_espresso'),
2773
+								$what,
2774
+								$action_desc
2775
+						),
2776
+						__FILE__, __FUNCTION__, __LINE__
2777
+				);
2778
+			}
2779
+		}
2780
+		// check that $query_args isn't something crazy
2781
+		if ( ! is_array($query_args)) {
2782
+			$query_args = array();
2783
+		}
2784
+		/**
2785
+		 * Allow injecting actions before the query_args are modified for possible different
2786
+		 * redirections on save and close actions
2787
+		 *
2788
+		 * @since 4.2.0
2789
+		 * @param array $query_args       The original query_args array coming into the
2790
+		 *                                method.
2791
+		 */
2792
+		do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2793
+		//calculate where we're going (if we have a "save and close" button pushed)
2794
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2795
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2796
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2797
+			// regenerate query args array from referrer URL
2798
+			parse_str($parsed_url['query'], $query_args);
2799
+			// correct page and action will be in the query args now
2800
+			$redirect_url = admin_url('admin.php');
2801
+		}
2802
+		//merge any default query_args set in _default_route_query_args property
2803
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2804
+			$args_to_merge = array();
2805
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2806
+				//is there a wp_referer array in our _default_route_query_args property?
2807
+				if ($query_param == 'wp_referer') {
2808
+					$query_value = (array)$query_value;
2809
+					foreach ($query_value as $reference => $value) {
2810
+						if (strpos($reference, 'nonce') !== false) {
2811
+							continue;
2812
+						}
2813
+						//finally we will override any arguments in the referer with
2814
+						//what might be set on the _default_route_query_args array.
2815
+						if (isset($this->_default_route_query_args[$reference])) {
2816
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2817
+						} else {
2818
+							$args_to_merge[$reference] = urlencode($value);
2819
+						}
2820
+					}
2821
+					continue;
2822
+				}
2823
+				$args_to_merge[$query_param] = $query_value;
2824
+			}
2825
+			//now let's merge these arguments but override with what was specifically sent in to the
2826
+			//redirect.
2827
+			$query_args = array_merge($args_to_merge, $query_args);
2828
+		}
2829
+		$this->_process_notices($query_args);
2830
+		// generate redirect url
2831
+		// if redirecting to anything other than the main page, add a nonce
2832
+		if (isset($query_args['action'])) {
2833
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2834
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2835
+		}
2836
+		//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).
2837
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2838
+		$redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2839
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2840
+		if (defined('DOING_AJAX')) {
2841
+			$default_data = array(
2842
+					'close'        => true,
2843
+					'redirect_url' => $redirect_url,
2844
+					'where'        => 'main',
2845
+					'what'         => 'append',
2846
+			);
2847
+			$this->_template_args['success'] = $success;
2848
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2849
+			$this->_return_json();
2850
+		}
2851
+		wp_safe_redirect($redirect_url);
2852
+		exit();
2853
+	}
2854
+
2855
+
2856
+
2857
+	/**
2858
+	 * process any notices before redirecting (or returning ajax request)
2859
+	 * This method sets the $this->_template_args['notices'] attribute;
2860
+	 *
2861
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
2862
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2863
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2864
+	 * @return void
2865
+	 */
2866
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2867
+	{
2868
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
2869
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2870
+			$notices = EE_Error::get_notices(false);
2871
+			if (empty($this->_template_args['success'])) {
2872
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2873
+			}
2874
+			if (empty($this->_template_args['errors'])) {
2875
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2876
+			}
2877
+			if (empty($this->_template_args['attention'])) {
2878
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2879
+			}
2880
+		}
2881
+		$this->_template_args['notices'] = EE_Error::get_notices();
2882
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2883
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2884
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2885
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2886
+		}
2887
+	}
2888
+
2889
+
2890
+
2891
+	/**
2892
+	 * get_action_link_or_button
2893
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
2894
+	 *
2895
+	 * @param string $action        use this to indicate which action the url is generated with.
2896
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2897
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2898
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2899
+	 * @param string $base_url      If this is not provided
2900
+	 *                              the _admin_base_url will be used as the default for the button base_url.
2901
+	 *                              Otherwise this value will be used.
2902
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2903
+	 * @return string
2904
+	 * @throws \EE_Error
2905
+	 */
2906
+	public function get_action_link_or_button(
2907
+			$action,
2908
+			$type = 'add',
2909
+			$extra_request = array(),
2910
+			$class = 'button-primary',
2911
+			$base_url = '',
2912
+			$exclude_nonce = false
2913
+	) {
2914
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2915
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2916
+			throw new EE_Error(
2917
+					sprintf(
2918
+							__(
2919
+									'There is no page route for given action for the button.  This action was given: %s',
2920
+									'event_espresso'
2921
+							),
2922
+							$action
2923
+					)
2924
+			);
2925
+		}
2926
+		if ( ! isset($this->_labels['buttons'][$type])) {
2927
+			throw new EE_Error(
2928
+					sprintf(
2929
+							__(
2930
+									'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2931
+									'event_espresso'
2932
+							),
2933
+							$type
2934
+					)
2935
+			);
2936
+		}
2937
+		//finally check user access for this button.
2938
+		$has_access = $this->check_user_access($action, true);
2939
+		if ( ! $has_access) {
2940
+			return '';
2941
+		}
2942
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2943
+		$query_args = array(
2944
+				'action' => $action,
2945
+		);
2946
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2947
+		if ( ! empty($extra_request)) {
2948
+			$query_args = array_merge($extra_request, $query_args);
2949
+		}
2950
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2951
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2952
+	}
2953
+
2954
+
2955
+
2956
+	/**
2957
+	 * _per_page_screen_option
2958
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
2959
+	 *
2960
+	 * @return void
2961
+	 */
2962
+	protected function _per_page_screen_option()
2963
+	{
2964
+		$option = 'per_page';
2965
+		$args = array(
2966
+				'label'   => $this->_admin_page_title,
2967
+				'default' => 10,
2968
+				'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2969
+		);
2970
+		//ONLY add the screen option if the user has access to it.
2971
+		if ($this->check_user_access($this->_current_view, true)) {
2972
+			add_screen_option($option, $args);
2973
+		}
2974
+	}
2975
+
2976
+
2977
+
2978
+	/**
2979
+	 * set_per_page_screen_option
2980
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
2981
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
2982
+	 *
2983
+	 * @access private
2984
+	 * @return void
2985
+	 */
2986
+	private function _set_per_page_screen_options()
2987
+	{
2988
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
2989
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
2990
+			if ( ! $user = wp_get_current_user()) {
2991
+				return;
2992
+			}
2993
+			$option = $_POST['wp_screen_options']['option'];
2994
+			$value = $_POST['wp_screen_options']['value'];
2995
+			if ($option != sanitize_key($option)) {
2996
+				return;
2997
+			}
2998
+			$map_option = $option;
2999
+			$option = str_replace('-', '_', $option);
3000
+			switch ($map_option) {
3001
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3002
+					$value = (int)$value;
3003
+					if ($value < 1 || $value > 999) {
3004
+						return;
3005
+					}
3006
+					break;
3007
+				default:
3008
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3009
+					if (false === $value) {
3010
+						return;
3011
+					}
3012
+					break;
3013
+			}
3014
+			update_user_meta($user->ID, $option, $value);
3015
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3016
+			exit;
3017
+		}
3018
+	}
3019
+
3020
+
3021
+
3022
+	/**
3023
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3024
+	 *
3025
+	 * @param array $data array that will be assigned to template args.
3026
+	 */
3027
+	public function set_template_args($data)
3028
+	{
3029
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3030
+	}
3031
+
3032
+
3033
+
3034
+	/**
3035
+	 * This makes available the WP transient system for temporarily moving data between routes
3036
+	 *
3037
+	 * @access protected
3038
+	 * @param string $route             the route that should receive the transient
3039
+	 * @param array  $data              the data that gets sent
3040
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3041
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3042
+	 * @return void
3043
+	 */
3044
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3045
+	{
3046
+		$user_id = get_current_user_id();
3047
+		if ( ! $skip_route_verify) {
3048
+			$this->_verify_route($route);
3049
+		}
3050
+		//now let's set the string for what kind of transient we're setting
3051
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3052
+		$data = $notices ? array('notices' => $data) : $data;
3053
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3054
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3055
+		if ($existing) {
3056
+			$data = array_merge((array)$data, (array)$existing);
3057
+		}
3058
+		if (is_multisite() && is_network_admin()) {
3059
+			set_site_transient($transient, $data, 8);
3060
+		} else {
3061
+			set_transient($transient, $data, 8);
3062
+		}
3063
+	}
3064
+
3065
+
3066
+
3067
+	/**
3068
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3069
+	 *
3070
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3071
+	 * @return mixed data
3072
+	 */
3073
+	protected function _get_transient($notices = false, $route = false)
3074
+	{
3075
+		$user_id = get_current_user_id();
3076
+		$route = ! $route ? $this->_req_action : $route;
3077
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3078
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3079
+		//delete transient after retrieval (just in case it hasn't expired);
3080
+		if (is_multisite() && is_network_admin()) {
3081
+			delete_site_transient($transient);
3082
+		} else {
3083
+			delete_transient($transient);
3084
+		}
3085
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3086
+	}
3087
+
3088
+
3089
+
3090
+	/**
3091
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3092
+	 * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3093
+	 *
3094
+	 * @return void
3095
+	 */
3096
+	protected function _transient_garbage_collection()
3097
+	{
3098
+		global $wpdb;
3099
+		//retrieve all existing transients
3100
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3101
+		if ($results = $wpdb->get_results($query)) {
3102
+			foreach ($results as $result) {
3103
+				$transient = str_replace('_transient_', '', $result->option_name);
3104
+				get_transient($transient);
3105
+				if (is_multisite() && is_network_admin()) {
3106
+					get_site_transient($transient);
3107
+				}
3108
+			}
3109
+		}
3110
+	}
3111
+
3112
+
3113
+
3114
+	/**
3115
+	 * get_view
3116
+	 *
3117
+	 * @access public
3118
+	 * @return string content of _view property
3119
+	 */
3120
+	public function get_view()
3121
+	{
3122
+		return $this->_view;
3123
+	}
3124
+
3125
+
3126
+
3127
+	/**
3128
+	 * getter for the protected $_views property
3129
+	 *
3130
+	 * @return array
3131
+	 */
3132
+	public function get_views()
3133
+	{
3134
+		return $this->_views;
3135
+	}
3136
+
3137
+
3138
+
3139
+	/**
3140
+	 * get_current_page
3141
+	 *
3142
+	 * @access public
3143
+	 * @return string _current_page property value
3144
+	 */
3145
+	public function get_current_page()
3146
+	{
3147
+		return $this->_current_page;
3148
+	}
3149
+
3150
+
3151
+
3152
+	/**
3153
+	 * get_current_view
3154
+	 *
3155
+	 * @access public
3156
+	 * @return string _current_view property value
3157
+	 */
3158
+	public function get_current_view()
3159
+	{
3160
+		return $this->_current_view;
3161
+	}
3162
+
3163
+
3164
+
3165
+	/**
3166
+	 * get_current_screen
3167
+	 *
3168
+	 * @access public
3169
+	 * @return object The current WP_Screen object
3170
+	 */
3171
+	public function get_current_screen()
3172
+	{
3173
+		return $this->_current_screen;
3174
+	}
3175
+
3176
+
3177
+
3178
+	/**
3179
+	 * get_current_page_view_url
3180
+	 *
3181
+	 * @access public
3182
+	 * @return string This returns the url for the current_page_view.
3183
+	 */
3184
+	public function get_current_page_view_url()
3185
+	{
3186
+		return $this->_current_page_view_url;
3187
+	}
3188
+
3189
+
3190
+
3191
+	/**
3192
+	 * just returns the _req_data property
3193
+	 *
3194
+	 * @return array
3195
+	 */
3196
+	public function get_request_data()
3197
+	{
3198
+		return $this->_req_data;
3199
+	}
3200
+
3201
+
3202
+
3203
+	/**
3204
+	 * returns the _req_data protected property
3205
+	 *
3206
+	 * @return string
3207
+	 */
3208
+	public function get_req_action()
3209
+	{
3210
+		return $this->_req_action;
3211
+	}
3212
+
3213
+
3214
+
3215
+	/**
3216
+	 * @return bool  value of $_is_caf property
3217
+	 */
3218
+	public function is_caf()
3219
+	{
3220
+		return $this->_is_caf;
3221
+	}
3222
+
3223
+
3224
+
3225
+	/**
3226
+	 * @return mixed
3227
+	 */
3228
+	public function default_espresso_metaboxes()
3229
+	{
3230
+		return $this->_default_espresso_metaboxes;
3231
+	}
3232
+
3233
+
3234
+
3235
+	/**
3236
+	 * @return mixed
3237
+	 */
3238
+	public function admin_base_url()
3239
+	{
3240
+		return $this->_admin_base_url;
3241
+	}
3242
+
3243
+
3244
+
3245
+	/**
3246
+	 * @return mixed
3247
+	 */
3248
+	public function wp_page_slug()
3249
+	{
3250
+		return $this->_wp_page_slug;
3251
+	}
3252
+
3253
+
3254
+
3255
+	/**
3256
+	 * updates  espresso configuration settings
3257
+	 *
3258
+	 * @access    protected
3259
+	 * @param string                   $tab
3260
+	 * @param EE_Config_Base|EE_Config $config
3261
+	 * @param string                   $file file where error occurred
3262
+	 * @param string                   $func function  where error occurred
3263
+	 * @param string                   $line line no where error occurred
3264
+	 * @return boolean
3265
+	 */
3266
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3267
+	{
3268
+		//remove any options that are NOT going to be saved with the config settings.
3269
+		if (isset($config->core->ee_ueip_optin)) {
3270
+			$config->core->ee_ueip_has_notified = true;
3271
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3272
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3273
+			update_option('ee_ueip_has_notified', true);
3274
+		}
3275
+		// and save it (note we're also doing the network save here)
3276
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3277
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3278
+		if ($config_saved && $net_saved) {
3279
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3280
+			return true;
3281
+		} else {
3282
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3283
+			return false;
3284
+		}
3285
+	}
3286
+
3287
+
3288
+
3289
+	/**
3290
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3291
+	 *
3292
+	 * @return array
3293
+	 */
3294
+	public function get_yes_no_values()
3295
+	{
3296
+		return $this->_yes_no_values;
3297
+	}
3298
+
3299
+
3300
+
3301
+	protected function _get_dir()
3302
+	{
3303
+		$reflector = new ReflectionClass(get_class($this));
3304
+		return dirname($reflector->getFileName());
3305
+	}
3306
+
3307
+
3308
+
3309
+	/**
3310
+	 * A helper for getting a "next link".
3311
+	 *
3312
+	 * @param string $url   The url to link to
3313
+	 * @param string $class The class to use.
3314
+	 * @return string
3315
+	 */
3316
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3317
+	{
3318
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3319
+	}
3320
+
3321
+
3322
+
3323
+	/**
3324
+	 * A helper for getting a "previous link".
3325
+	 *
3326
+	 * @param string $url   The url to link to
3327
+	 * @param string $class The class to use.
3328
+	 * @return string
3329
+	 */
3330
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3331
+	{
3332
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3333
+	}
3334
+
3335
+
3336
+
3337
+
3338
+
3339
+
3340
+
3341
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3342
+	/**
3343
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller 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 _req_data
3344
+	 * array.
3345
+	 *
3346
+	 * @return bool success/fail
3347
+	 */
3348
+	protected function _process_resend_registration()
3349
+	{
3350
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3351
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3352
+		return $this->_template_args['success'];
3353
+	}
3354
+
3355
+
3356
+
3357
+	/**
3358
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3359
+	 *
3360
+	 * @access protected
3361
+	 * @param \EE_Payment $payment
3362
+	 * @return bool success/fail
3363
+	 */
3364
+	protected function _process_payment_notification(EE_Payment $payment)
3365
+	{
3366
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3367
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3368
+		$this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3369
+		return $this->_template_args['success'];
3370
+	}
3371 3371
 
3372 3372
 
3373 3373
 }
Please login to merge, or discard this patch.
modules/add_new_state/EED_Add_New_State.module.php 1 patch
Spacing   +165 added lines, -165 removed lines patch added patch discarded remove patch
@@ -16,7 +16,7 @@  discard block
 block discarded – undo
16 16
 	 * @return EED_Add_New_State
17 17
 	 */
18 18
 	public static function instance() {
19
-		return parent::get_instance( __CLASS__ );
19
+		return parent::get_instance(__CLASS__);
20 20
 	}
21 21
 
22 22
 
@@ -27,16 +27,16 @@  discard block
 block discarded – undo
27 27
 	 *  	@return 		void
28 28
 	 */
29 29
 	public static function set_hooks() {
30
-		add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 );
31
-		add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'translate_js_strings' ), 0 );
32
-		add_action( 'wp_enqueue_scripts', array( 'EED_Add_New_State', 'wp_enqueue_scripts' ), 10 );
33
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 );
34
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 );
35
-		add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 );
36
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 );
37
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 );
38
-		add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 );
39
-		add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 );
30
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
31
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'translate_js_strings'), 0);
32
+		add_action('wp_enqueue_scripts', array('EED_Add_New_State', 'wp_enqueue_scripts'), 10);
33
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
34
+		add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
35
+		add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
36
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
37
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
38
+		add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1);
39
+		add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1);
40 40
 	}
41 41
 
42 42
 	/**
@@ -46,20 +46,20 @@  discard block
 block discarded – undo
46 46
 	 *  	@return 		void
47 47
 	 */
48 48
 	public static function set_hooks_admin() {
49
-		add_action( 'wp_loaded', array( 'EED_Add_New_State', 'set_definitions' ), 2 );
50
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 );
51
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array( 'EED_Add_New_State', 'display_add_new_state_micro_form' ), 1, 1 );
52
-		add_action( 'wp_ajax_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' ));
53
-		add_action( 'wp_ajax_nopriv_espresso_add_new_state', array( 'EED_Add_New_State', 'add_new_state' ));
54
-		add_filter( 'FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array( 'EED_Add_New_State', 'unset_new_state_request_params' ), 10, 1 );
55
-		add_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 );
56
-		add_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array( 'EED_Add_New_State', 'update_country_settings' ), 10, 3 );
57
-		add_filter( 'FHEE__EE_State_Select_Input____construct__state_options', array( 'EED_Add_New_State', 'state_options' ), 10, 1 );
58
-		add_filter( 'FHEE__EE_Country_Select_Input____construct__country_options', array( 'EED_Add_New_State', 'country_options' ), 10, 1 );
49
+		add_action('wp_loaded', array('EED_Add_New_State', 'set_definitions'), 2);
50
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___question_group_reg_form__question_group_reg_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
51
+		add_filter('FHEE__EE_SPCO_Reg_Step_Payment_Options___get_billing_form_for_payment_method__billing_form', array('EED_Add_New_State', 'display_add_new_state_micro_form'), 1, 1);
52
+		add_action('wp_ajax_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
53
+		add_action('wp_ajax_nopriv_espresso_add_new_state', array('EED_Add_New_State', 'add_new_state'));
54
+		add_filter('FHEE__EE_Single_Page_Checkout__process_attendee_information__valid_data_line_item', array('EED_Add_New_State', 'unset_new_state_request_params'), 10, 1);
55
+		add_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', array('EED_Add_New_State', 'update_country_settings'), 10, 3);
56
+		add_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', array('EED_Add_New_State', 'update_country_settings'), 10, 3);
57
+		add_filter('FHEE__EE_State_Select_Input____construct__state_options', array('EED_Add_New_State', 'state_options'), 10, 1);
58
+		add_filter('FHEE__EE_Country_Select_Input____construct__country_options', array('EED_Add_New_State', 'country_options'), 10, 1);
59 59
 		//add_filter( 'FHEE__Single_Page_Checkout___check_form_submission__request_params', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 );
60
-		add_filter( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', array( 'EED_Add_New_State', 'filter_checkout_request_params' ), 10, 1 );
61
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array( 'EED_Add_New_State', 'inject_new_reg_state_into_options' ), 10, 5 );
62
-		add_filter( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array( 'EED_Add_New_State', 'inject_new_reg_country_into_options' ), 10, 5 );
60
+		add_filter('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', array('EED_Add_New_State', 'filter_checkout_request_params'), 10, 1);
61
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__state_options', array('EED_Add_New_State', 'inject_new_reg_state_into_options'), 10, 5);
62
+		add_filter('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__country_options', array('EED_Add_New_State', 'inject_new_reg_country_into_options'), 10, 5);
63 63
 	}
64 64
 
65 65
 
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *  	@return 		void
72 72
 	 */
73 73
 	public static function set_definitions() {
74
-		define( 'ANS_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
75
-		define( 'ANS_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS );
74
+		define('ANS_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
75
+		define('ANS_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
76 76
 	}
77 77
 
78 78
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 	 * @param \WP $WP
85 85
 	 * @return        void
86 86
 	 */
87
-	public function run( $WP ) {
87
+	public function run($WP) {
88 88
 	}
89 89
 
90 90
 
@@ -112,9 +112,9 @@  discard block
 block discarded – undo
112 112
 	 * 	@return 		void
113 113
 	 */
114 114
 	public static function wp_enqueue_scripts() {
115
-		if ( apply_filters( 'EED_Single_Page_Checkout__SPCO_active', false ) ) {
116
-			wp_register_script( 'add_new_state', ANS_ASSETS_URL . 'add_new_state.js', array( 'espresso_core', 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, true );
117
-			wp_enqueue_script( 'add_new_state' );
115
+		if (apply_filters('EED_Single_Page_Checkout__SPCO_active', false)) {
116
+			wp_register_script('add_new_state', ANS_ASSETS_URL.'add_new_state.js', array('espresso_core', 'single_page_checkout'), EVENT_ESPRESSO_VERSION, true);
117
+			wp_enqueue_script('add_new_state');
118 118
 		}
119 119
 	}
120 120
 
@@ -128,34 +128,34 @@  discard block
 block discarded – undo
128 128
 	 * @return 	string
129 129
 	 */
130 130
 //	public static function display_add_new_state_micro_form( $html, EE_Form_Input_With_Options_Base $input ){
131
-	public static function display_add_new_state_micro_form( EE_Form_Section_Proper $question_group_reg_form ){
131
+	public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form) {
132 132
 		// only add the 'new_state_micro_form' when displaying reg forms,
133 133
 		// not during processing since we process the 'new_state_micro_form' in it's own AJAX request
134
-		$action = EE_Registry::instance()->REQ->get( 'action', '' );
134
+		$action = EE_Registry::instance()->REQ->get('action', '');
135 135
 		// is the "state" question in this form section?
136
-		$input = $question_group_reg_form->get_subsection( 'state' );
137
-		if ( $action === 'process_reg_step' || $action === 'update_reg_step' ) {
136
+		$input = $question_group_reg_form->get_subsection('state');
137
+		if ($action === 'process_reg_step' || $action === 'update_reg_step') {
138 138
 			//ok then all we need to do is make sure the input's HTML name is consistent
139 139
 			//by forcing it to set it now, like it did while getting the form for display
140
-			if( $input instanceof EE_State_Select_Input ) {
140
+			if ($input instanceof EE_State_Select_Input) {
141 141
 				$input->html_name();
142 142
 			}
143 143
 			return $question_group_reg_form;
144 144
 		}
145 145
 		
146 146
 		// we're only doing this for state select inputs
147
-		if ( $input instanceof EE_State_Select_Input ) {
147
+		if ($input instanceof EE_State_Select_Input) {
148 148
 			// grab any set values from the request
149
-			$country_name = str_replace( 'state', 'nsmf_new_state_country', $input->html_name() );
150
-			$state_name = str_replace( 'state', 'nsmf_new_state_name', $input->html_name() );
151
-			$abbrv_name = str_replace( 'state', 'nsmf_new_state_abbrv', $input->html_name() );
152
-			$new_state_submit_id = str_replace( 'state', 'new_state', $input->html_id() );
149
+			$country_name = str_replace('state', 'nsmf_new_state_country', $input->html_name());
150
+			$state_name = str_replace('state', 'nsmf_new_state_name', $input->html_name());
151
+			$abbrv_name = str_replace('state', 'nsmf_new_state_abbrv', $input->html_name());
152
+			$new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
153 153
 			$country_options = array();
154 154
 			$countries = EEM_Country::instance()->get_all_countries();
155
-			if ( ! empty( $countries )) {
156
-				foreach( $countries as $country ){
157
-					if ( $country instanceof EE_Country ) {
158
-						$country_options[ $country->ID() ] = $country->name();
155
+			if ( ! empty($countries)) {
156
+				foreach ($countries as $country) {
157
+					if ($country instanceof EE_Country) {
158
+						$country_options[$country->ID()] = $country->name();
159 159
 					}
160 160
 				}
161 161
 			}
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 						// add hidden input to indicate that a new state is being added
169 169
 						'add_new_state' 	=> new EE_Hidden_Input(
170 170
 							array(
171
-								'html_name' 	=> str_replace( 'state', 'nsmf_add_new_state', $input->html_name() ),
172
-								'html_id' 			=> str_replace( 'state', 'nsmf_add_new_state', $input->html_id() ),
171
+								'html_name' 	=> str_replace('state', 'nsmf_add_new_state', $input->html_name()),
172
+								'html_id' 			=> str_replace('state', 'nsmf_add_new_state', $input->html_id()),
173 173
 								'default'			=> 0
174 174
 							)
175 175
 						),
@@ -181,10 +181,10 @@  discard block
 block discarded – undo
181 181
 									'',
182 182
 									__('click here to add a new state/province', 'event_espresso'),
183 183
 									'',
184
-									'display-' . $input->html_id(),
184
+									'display-'.$input->html_id(),
185 185
 									'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js',
186 186
 									'',
187
-									'data-target="' . $input->html_id() . '"'
187
+									'data-target="'.$input->html_id().'"'
188 188
 								)
189 189
 							)
190 190
 						),
@@ -192,13 +192,13 @@  discard block
 block discarded – undo
192 192
 						'add_new_state_micro_form' =>new EE_Form_Section_HTML(
193 193
 							apply_filters(
194 194
 								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form',
195
-								EEH_HTML::div( '', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', 'display: none;' ) .
196
-								EEH_HTML::h6( __('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')) .
197
-								EEH_HTML::ul() .
198
-								EEH_HTML::li( __('first select the Country that your State/Province belongs to', 'event_espresso') ) .
199
-								EEH_HTML::li( __('enter the name of your State/Province', 'event_espresso') ) .
200
-								EEH_HTML::li( __('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso') ) .
201
-								EEH_HTML::li( __('click the ADD button', 'event_espresso') ) .
195
+								EEH_HTML::div('', $input->html_id().'-dv', 'ee-form-add-new-state-dv', 'display: none;').
196
+								EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')).
197
+								EEH_HTML::ul().
198
+								EEH_HTML::li(__('first select the Country that your State/Province belongs to', 'event_espresso')).
199
+								EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')).
200
+								EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso')).
201
+								EEH_HTML::li(__('click the ADD button', 'event_espresso')).
202 202
 								EEH_HTML::ulx()
203 203
 							)
204 204
 						),
@@ -207,10 +207,10 @@  discard block
 block discarded – undo
207 207
 							$country_options,
208 208
 							array(
209 209
 								'html_name' 			=> $country_name,
210
-								'html_id' 					=> str_replace( 'state', 'nsmf_new_state_country', $input->html_id() ),
211
-								'html_class' 			=> $input->html_class() . ' new-state-country',
210
+								'html_id' 					=> str_replace('state', 'nsmf_new_state_country', $input->html_id()),
211
+								'html_class' 			=> $input->html_class().' new-state-country',
212 212
 								'html_label_text'		=> __('New State/Province Country', 'event_espresso'),
213
-								'default'					=> EE_Registry::instance()->REQ->get( $country_name, '' ),
213
+								'default'					=> EE_Registry::instance()->REQ->get($country_name, ''),
214 214
 								'required' 				=> false
215 215
 							)
216 216
 						),
@@ -218,23 +218,23 @@  discard block
 block discarded – undo
218 218
 						'new_state_name' => new EE_Text_Input(
219 219
 							array(
220 220
 								'html_name' 			=> $state_name,
221
-								'html_id' 					=> str_replace( 'state', 'nsmf_new_state_name', $input->html_id() ),
222
-								'html_class' 			=> $input->html_class() . ' new-state-state',
221
+								'html_id' 					=> str_replace('state', 'nsmf_new_state_name', $input->html_id()),
222
+								'html_class' 			=> $input->html_class().' new-state-state',
223 223
 								'html_label_text'		=> __('New State/Province Name', 'event_espresso'),
224
-								'default'					=> EE_Registry::instance()->REQ->get( $state_name, '' ),
224
+								'default'					=> EE_Registry::instance()->REQ->get($state_name, ''),
225 225
 								'required' 				=> false
226 226
 							)
227 227
 						),
228
-						'spacer' => new EE_Form_Section_HTML( EEH_HTML::br() ),
228
+						'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()),
229 229
 						// NEW STATE NAME
230 230
 						'new_state_abbrv' => new EE_Text_Input(
231 231
 							array(
232 232
 								'html_name' 					=> $abbrv_name,
233
-								'html_id' 							=> str_replace( 'state', 'nsmf_new_state_abbrv', $input->html_id() ),
234
-								'html_class' 					=> $input->html_class() . ' new-state-abbrv',
233
+								'html_id' 							=> str_replace('state', 'nsmf_new_state_abbrv', $input->html_id()),
234
+								'html_class' 					=> $input->html_class().' new-state-abbrv',
235 235
 								'html_label_text'				=> __('New State/Province Abbreviation', 'event_espresso'),
236 236
 								'html_other_attributes'	=> 'size="24"',
237
-								'default'							=> EE_Registry::instance()->REQ->get( $abbrv_name, '' ),
237
+								'default'							=> EE_Registry::instance()->REQ->get($abbrv_name, ''),
238 238
 								'required' 						=> false
239 239
 							)
240 240
 						),
@@ -242,15 +242,15 @@  discard block
 block discarded – undo
242 242
 						'add_new_state_submit_button' => new EE_Form_Section_HTML(
243 243
 							apply_filters(
244 244
 								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button',
245
-								EEH_HTML::nbsp(3) .
245
+								EEH_HTML::nbsp(3).
246 246
 								EEH_HTML::link(
247 247
 									'',
248 248
 									__('ADD', 'event_espresso'),
249 249
 									'',
250
-									'submit-' . $new_state_submit_id,
250
+									'submit-'.$new_state_submit_id,
251 251
 									'ee-form-add-new-state-submit button button-secondary',
252 252
 									'',
253
-									'data-target="' . $new_state_submit_id . '"'
253
+									'data-target="'.$new_state_submit_id.'"'
254 254
 								)
255 255
 							)
256 256
 						),
@@ -258,18 +258,18 @@  discard block
 block discarded – undo
258 258
 						'add_new_state_extra' => new EE_Form_Section_HTML(
259 259
 							apply_filters(
260 260
 								'FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra',
261
-								EEH_HTML::br(2) .
262
-								EEH_HTML::div( '', '', 'small-text' ) .
263
-								EEH_HTML::strong( __('Don\'t know your State/Province Abbreviation?', 'event_espresso') ) .
264
-								EEH_HTML::br() .
261
+								EEH_HTML::br(2).
262
+								EEH_HTML::div('', '', 'small-text').
263
+								EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso')).
264
+								EEH_HTML::br().
265 265
 								sprintf(
266 266
 									__('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', 'event_espresso'),
267
-									EEH_HTML::link( 'http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk' )
268
-								) .
269
-								EEH_HTML::divx() .
270
-								EEH_HTML::br() .
271
-								EEH_HTML::link( '', __('cancel new state/province', 'event_espresso'), '', 'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'data-target="' . $input->html_id() . '"' ) .
272
-								EEH_HTML::divx() .
267
+									EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk')
268
+								).
269
+								EEH_HTML::divx().
270
+								EEH_HTML::br().
271
+								EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '', 'hide-'.$input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'data-target="'.$input->html_id().'"').
272
+								EEH_HTML::divx().
273 273
 								EEH_HTML::br()
274 274
 							)
275 275
 						)
@@ -277,7 +277,7 @@  discard block
 block discarded – undo
277 277
 					)
278 278
 				)
279 279
 			);
280
-			$question_group_reg_form->add_subsections( array( 'new_state_micro_form' => $new_state_micro_form ), 'state', false );
280
+			$question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state', false);
281 281
 		}
282 282
 		return $question_group_reg_form;
283 283
 	}
@@ -295,50 +295,50 @@  discard block
 block discarded – undo
295 295
 	public static function add_new_state() {
296 296
 		$REQ = EE_Registry::instance()->load_core('Request_Handler');
297 297
 		if (
298
-			$REQ->is_set( 'nsmf_add_new_state' )
299
-			&& $REQ->get( 'nsmf_add_new_state' ) == 1
298
+			$REQ->is_set('nsmf_add_new_state')
299
+			&& $REQ->get('nsmf_add_new_state') == 1
300 300
 		) {
301 301
 			EE_Registry::instance()->load_model('State');
302 302
 			// grab country ISO code, new state name, and new state abbreviation
303
-			$state_country = $REQ->is_set( 'nsmf_new_state_country' )
304
-				? sanitize_text_field( $REQ->get( 'nsmf_new_state_country' ) )
303
+			$state_country = $REQ->is_set('nsmf_new_state_country')
304
+				? sanitize_text_field($REQ->get('nsmf_new_state_country'))
305 305
 				: false;
306
-			$state_name = $REQ->is_set( 'nsmf_new_state_name' )
307
-				? sanitize_text_field( $REQ->get( 'nsmf_new_state_name' ) )
306
+			$state_name = $REQ->is_set('nsmf_new_state_name')
307
+				? sanitize_text_field($REQ->get('nsmf_new_state_name'))
308 308
 				: false;
309
-			$state_abbr = $REQ->is_set( 'nsmf_new_state_abbrv' )
310
-				? sanitize_text_field( $REQ->get( 'nsmf_new_state_abbrv' ) )
309
+			$state_abbr = $REQ->is_set('nsmf_new_state_abbrv')
310
+				? sanitize_text_field($REQ->get('nsmf_new_state_abbrv'))
311 311
 				: false;
312 312
 //echo '<h4>$state_country : ' . $state_country . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
313 313
 //echo '<h4>$state_name : ' . $state_name . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
314 314
 //echo '<h4>$state_abbr : ' . $state_abbr . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
315 315
 
316
-			if ( $state_country && $state_name && $state_abbr ) {
317
-				$new_state = EED_Add_New_State::save_new_state_to_db( array(
318
-					'CNT_ISO'=> strtoupper( $state_country ),
319
-					'STA_abbrev' => strtoupper( $state_abbr ),
320
-					'STA_name' => ucwords( $state_name ),
316
+			if ($state_country && $state_name && $state_abbr) {
317
+				$new_state = EED_Add_New_State::save_new_state_to_db(array(
318
+					'CNT_ISO'=> strtoupper($state_country),
319
+					'STA_abbrev' => strtoupper($state_abbr),
320
+					'STA_name' => ucwords($state_name),
321 321
 					'STA_active' => FALSE
322 322
 				));
323 323
 
324
-				if ( $new_state instanceof EE_State ) {
324
+				if ($new_state instanceof EE_State) {
325 325
 					// clean house
326
-					EE_Registry::instance()->REQ->un_set( 'nsmf_add_new_state' );
327
-					EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_country' );
328
-					EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_name' );
329
-					EE_Registry::instance()->REQ->un_set( 'nsmf_new_state_abbrv' );
326
+					EE_Registry::instance()->REQ->un_set('nsmf_add_new_state');
327
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_country');
328
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_name');
329
+					EE_Registry::instance()->REQ->un_set('nsmf_new_state_abbrv');
330 330
 
331 331
 					// get any existing new states
332 332
 					$new_states = EE_Registry::instance()->SSN->get_session_data(
333 333
 						'nsmf_new_states'
334 334
 					);
335
-					$new_states[ $new_state->ID() ] = $new_state;
335
+					$new_states[$new_state->ID()] = $new_state;
336 336
 					EE_Registry::instance()->SSN->set_session_data(
337
-						array( 'nsmf_new_states' => $new_states )
337
+						array('nsmf_new_states' => $new_states)
338 338
 					);
339 339
 
340
-					if ( EE_Registry::instance()->REQ->ajax ) {
341
-						echo wp_json_encode( array(
340
+					if (EE_Registry::instance()->REQ->ajax) {
341
+						echo wp_json_encode(array(
342 342
 							'success' => TRUE,
343 343
 							'id' => $new_state->ID(),
344 344
 							'name' => $new_state->name(),
@@ -353,12 +353,12 @@  discard block
 block discarded – undo
353 353
 				}
354 354
 
355 355
 			} else {
356
-				$error = __( 'A new State/Province could not be added because invalid or missing data was received.', 'event_espresso' );
357
-				if ( EE_Registry::instance()->REQ->ajax ) {
358
-					echo wp_json_encode( array( 'error' => $error ));
356
+				$error = __('A new State/Province could not be added because invalid or missing data was received.', 'event_espresso');
357
+				if (EE_Registry::instance()->REQ->ajax) {
358
+					echo wp_json_encode(array('error' => $error));
359 359
 					exit();
360 360
 				} else {
361
-					EE_Error::add_error( $error, __FILE__, __FUNCTION__, __LINE__ );
361
+					EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
362 362
 				}
363 363
 			}
364 364
 		}
@@ -376,11 +376,11 @@  discard block
 block discarded – undo
376 376
 	 * @param array $request_params
377 377
 	 * @return array
378 378
 	 */
379
-	public static function filter_checkout_request_params ( $request_params ) {
380
-		foreach ( $request_params as $form_section ) {
381
-			if ( is_array( $form_section )) {
382
-				EED_Add_New_State::unset_new_state_request_params( $form_section );
383
-				EED_Add_New_State::filter_checkout_request_params( $form_section );
379
+	public static function filter_checkout_request_params($request_params) {
380
+		foreach ($request_params as $form_section) {
381
+			if (is_array($form_section)) {
382
+				EED_Add_New_State::unset_new_state_request_params($form_section);
383
+				EED_Add_New_State::filter_checkout_request_params($form_section);
384 384
 			}
385 385
 		}
386 386
 		return $request_params;
@@ -395,12 +395,12 @@  discard block
 block discarded – undo
395 395
 	 * @param array $request_params
396 396
 	 * @return        boolean
397 397
 	 */
398
-	public static function unset_new_state_request_params ( $request_params ) {
399
-		unset( $request_params[ 'new_state_micro_form' ] );
400
-		unset( $request_params[ 'new_state_micro_add_new_state' ] );
401
-		unset( $request_params[ 'new_state_micro_new_state_country' ] );
402
-		unset( $request_params[ 'new_state_micro_new_state_name' ] );
403
-		unset( $request_params[ 'new_state_micro_new_state_abbrv' ] );
398
+	public static function unset_new_state_request_params($request_params) {
399
+		unset($request_params['new_state_micro_form']);
400
+		unset($request_params['new_state_micro_add_new_state']);
401
+		unset($request_params['new_state_micro_new_state_country']);
402
+		unset($request_params['new_state_micro_new_state_name']);
403
+		unset($request_params['new_state_micro_new_state_abbrv']);
404 404
 		return $request_params;
405 405
 	}
406 406
 
@@ -413,25 +413,25 @@  discard block
 block discarded – undo
413 413
 	 * @param array $props_n_values
414 414
 	 * @return        boolean
415 415
 	 */
416
-	public static function save_new_state_to_db ( $props_n_values = array() ) {
416
+	public static function save_new_state_to_db($props_n_values = array()) {
417 417
 //		EEH_Debug_Tools::printr( $props_n_values, '$props_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
418
-		$existing_state = EEM_State::instance()->get_all( array( $props_n_values, 'limit' => 1 ));
419
-		if ( ! empty( $existing_state )) {
420
-			return array_pop( $existing_state );
418
+		$existing_state = EEM_State::instance()->get_all(array($props_n_values, 'limit' => 1));
419
+		if ( ! empty($existing_state)) {
420
+			return array_pop($existing_state);
421 421
 		}
422
-		$new_state = EE_State::new_instance( $props_n_values );
423
-		if ( $new_state instanceof EE_State ) {
422
+		$new_state = EE_State::new_instance($props_n_values);
423
+		if ($new_state instanceof EE_State) {
424 424
 			// if not non-ajax admin
425
-			$new_state_key = 'new-state-added-' . $new_state->country_iso() . '-' . $new_state->abbrev();
425
+			$new_state_key = 'new-state-added-'.$new_state->country_iso().'-'.$new_state->abbrev();
426 426
 			$new_state_notice = sprintf(
427
-					__( 'A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso' ),
428
-					'<b>' . $new_state->name() . '</b>',
429
-					'<b>' . $new_state->abbrev() . '</b>',
430
-					'<b>' . $new_state->country()->name() . '</b>',
431
-					'<a href="' . add_query_arg( array( 'page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso() ), admin_url( 'admin.php' )) . '">' . __( 'Event Espresso - General Settings > Countries Tab', 'event_espresso' ) . '</a>',
427
+					__('A new State named "%1$s (%2$s)" was dynamically added from an Event Espresso form for the Country of "%3$s".%5$sTo verify, edit, and/or delete this new State, please go to the %4$s and update the States / Provinces section.%5$sCheck "Yes" to have this new State added to dropdown select lists in forms.', 'event_espresso'),
428
+					'<b>'.$new_state->name().'</b>',
429
+					'<b>'.$new_state->abbrev().'</b>',
430
+					'<b>'.$new_state->country()->name().'</b>',
431
+					'<a href="'.add_query_arg(array('page' => 'espresso_general_settings', 'action' => 'country_settings', 'country' => $new_state->country_iso()), admin_url('admin.php')).'">'.__('Event Espresso - General Settings > Countries Tab', 'event_espresso').'</a>',
432 432
 					'<br />'
433 433
 			);
434
-			EE_Error::add_persistent_admin_notice( $new_state_key, $new_state_notice );
434
+			EE_Error::add_persistent_admin_notice($new_state_key, $new_state_notice);
435 435
 			$new_state->save();
436 436
 			EEM_State::instance()->reset_cached_states();
437 437
 			return $new_state;
@@ -450,22 +450,22 @@  discard block
 block discarded – undo
450 450
 	 * @param array  $cols_n_values
451 451
 	 * @return        boolean
452 452
 	 */
453
-	public static function update_country_settings( $CNT_ISO = '', $STA_ID = '', $cols_n_values = array() ) {
454
-		$CNT_ISO = ! empty( $CNT_ISO ) ? $CNT_ISO : FALSE;
455
-		if ( ! $CNT_ISO ) {
456
-			EE_Error::add_error( __( 'An invalid or missing Country ISO Code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
453
+	public static function update_country_settings($CNT_ISO = '', $STA_ID = '', $cols_n_values = array()) {
454
+		$CNT_ISO = ! empty($CNT_ISO) ? $CNT_ISO : FALSE;
455
+		if ( ! $CNT_ISO) {
456
+			EE_Error::add_error(__('An invalid or missing Country ISO Code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
457 457
 		}
458
-		$STA_abbrev = is_array( $cols_n_values ) && isset( $cols_n_values['STA_abbrev'] ) ? $cols_n_values['STA_abbrev'] : FALSE;
459
-		if (  ! $STA_abbrev && ! empty( $STA_ID )) {
460
-			$state = EEM_State::instance()->get_one_by_ID( $STA_ID );
461
-			if ( $state instanceof EE_State ) {
458
+		$STA_abbrev = is_array($cols_n_values) && isset($cols_n_values['STA_abbrev']) ? $cols_n_values['STA_abbrev'] : FALSE;
459
+		if ( ! $STA_abbrev && ! empty($STA_ID)) {
460
+			$state = EEM_State::instance()->get_one_by_ID($STA_ID);
461
+			if ($state instanceof EE_State) {
462 462
 				$STA_abbrev = $state->abbrev();
463 463
 			}
464 464
 		}
465
-		if ( ! $STA_abbrev ) {
466
-			EE_Error::add_error( __( 'An invalid or missing State Abbreviation was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
465
+		if ( ! $STA_abbrev) {
466
+			EE_Error::add_error(__('An invalid or missing State Abbreviation was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
467 467
 		}
468
-		EE_Error::dismiss_persistent_admin_notice( $CNT_ISO . '-' . $STA_abbrev, TRUE, TRUE );
468
+		EE_Error::dismiss_persistent_admin_notice($CNT_ISO.'-'.$STA_abbrev, TRUE, TRUE);
469 469
 	}
470 470
 
471 471
 
@@ -481,19 +481,19 @@  discard block
 block discarded – undo
481 481
 	 * @param $answer
482 482
 	 * @return bool
483 483
 	 */
484
-	public static function inject_new_reg_state_into_options( $state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) {
485
-		if ( $answer instanceof EE_Answer  && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state ) {
484
+	public static function inject_new_reg_state_into_options($state_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) {
485
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_state) {
486 486
 			$STA_ID = $answer->value();
487
-			if ( ! empty( $STA_ID ) ) {
488
-				$state = EEM_State::instance()->get_one_by_ID( $STA_ID );
489
-				if ( $state instanceof EE_State ) {
487
+			if ( ! empty($STA_ID)) {
488
+				$state = EEM_State::instance()->get_one_by_ID($STA_ID);
489
+				if ($state instanceof EE_State) {
490 490
 					$country = $state->country();
491
-					if ( $country instanceof EE_Country ) {
492
-						if ( ! isset( $state_options[ $country->name() ] )) {
493
-							$state_options[ $country->name() ] = array();
491
+					if ($country instanceof EE_Country) {
492
+						if ( ! isset($state_options[$country->name()])) {
493
+							$state_options[$country->name()] = array();
494 494
 						}
495
-						if ( ! isset( $state_options[ $country->name() ][ $STA_ID ] )) {
496
-							$state_options[ $country->name() ][ $STA_ID ] = $state->name();
495
+						if ( ! isset($state_options[$country->name()][$STA_ID])) {
496
+							$state_options[$country->name()][$STA_ID] = $state->name();
497 497
 						}
498 498
 					}
499 499
 				}
@@ -515,14 +515,14 @@  discard block
 block discarded – undo
515 515
 	 * @param $answer
516 516
 	 * @return bool
517 517
 	 */
518
-	public static function inject_new_reg_country_into_options( $country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer ) {
519
-		if ( $answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country ) {
518
+	public static function inject_new_reg_country_into_options($country_options = array(), EE_SPCO_Reg_Step_Attendee_Information $reg_step, EE_Registration $registration, EE_Question $question, $answer) {
519
+		if ($answer instanceof EE_Answer && $question instanceof EE_Question && $question->type() === EEM_Question::QST_type_country) {
520 520
 			$CNT_ISO = $answer->value();
521
-			if ( ! empty( $CNT_ISO ) ) {
522
-				$country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO );
523
-				if ( $country instanceof EE_Country ) {
524
-					if ( ! isset( $country_options[ $CNT_ISO ] ) ) {
525
-						$country_options[ $CNT_ISO ] = $country->name();
521
+			if ( ! empty($CNT_ISO)) {
522
+				$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
523
+				if ($country instanceof EE_Country) {
524
+					if ( ! isset($country_options[$CNT_ISO])) {
525
+						$country_options[$CNT_ISO] = $country->name();
526 526
 					}
527 527
 				}
528 528
 			}
@@ -539,14 +539,14 @@  discard block
 block discarded – undo
539 539
 	 * @param EE_State[]  $state_options
540 540
 	 * @return        boolean
541 541
 	 */
542
-	public static function state_options( $state_options = array() ) {
542
+	public static function state_options($state_options = array()) {
543 543
 		$new_states = EED_Add_New_State::_get_new_states();
544
-		foreach ( $new_states as $new_state ) {
544
+		foreach ($new_states as $new_state) {
545 545
 			if (
546 546
 				$new_state instanceof EE_State
547 547
 				&& $new_state->country() instanceof EE_Country
548 548
 			) {
549
-				$state_options[ $new_state->country()->name() ][ $new_state->ID() ] = $new_state->name();
549
+				$state_options[$new_state->country()->name()][$new_state->ID()] = $new_state->name();
550 550
 			}
551 551
 		}
552 552
 		return $state_options;
@@ -562,12 +562,12 @@  discard block
 block discarded – undo
562 562
 	 */
563 563
 	protected static function _get_new_states() {
564 564
 		$new_states = array();
565
-		if ( EE_Registry::instance()->SSN instanceof EE_Session ) {
565
+		if (EE_Registry::instance()->SSN instanceof EE_Session) {
566 566
 			$new_states = EE_Registry::instance()->SSN->get_session_data(
567 567
 				'nsmf_new_states'
568 568
 			);
569 569
 		}
570
-		return is_array( $new_states ) ? $new_states : array();
570
+		return is_array($new_states) ? $new_states : array();
571 571
 	}
572 572
 
573 573
 
@@ -579,14 +579,14 @@  discard block
 block discarded – undo
579 579
 	 * @param EE_Country[]  $country_options
580 580
 	 * @return        boolean
581 581
 	 */
582
-	public static function country_options( $country_options = array() ) {
582
+	public static function country_options($country_options = array()) {
583 583
 		$new_states = EED_Add_New_State::_get_new_states();
584
-		foreach ( $new_states as $new_state ) {
584
+		foreach ($new_states as $new_state) {
585 585
 			if (
586 586
 				$new_state instanceof EE_State
587 587
 				&& $new_state->country() instanceof EE_Country
588 588
 			) {
589
-				$country_options[ $new_state->country()->ID() ] = $new_state->country()->name();
589
+				$country_options[$new_state->country()->ID()] = $new_state->country()->name();
590 590
 			}
591 591
 		}
592 592
 		return $country_options;
Please login to merge, or discard this patch.
modules/bot_trap/EED_Bot_Trap.module.php 1 patch
Indentation   +57 added lines, -57 removed lines patch added patch discarded remove patch
@@ -30,11 +30,11 @@  discard block
 block discarded – undo
30 30
 	 *  @return 	void
31 31
 	 */
32 32
 	public static function set_hooks() {
33
-        if (
33
+		if (
34 34
 			apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) &&
35 35
 			\EE_Registry::instance()->CFG->registration->use_bot_trap
36 36
 		) {
37
-            \EED_Bot_Trap::set_trap();
37
+			\EED_Bot_Trap::set_trap();
38 38
 			// redirect bots to bogus success page
39 39
 			\EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' );
40 40
 		}
@@ -49,18 +49,18 @@  discard block
 block discarded – undo
49 49
 	 *  @return 	void
50 50
 	 */
51 51
 	public static function set_trap() {
52
-        define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
53
-        add_action(
54
-            'AHEE__ticket_selector_chart__template__after_ticket_selector',
55
-            array('EED_Bot_Trap', 'generate_bot_trap'),
56
-            10, 2
57
-        );
58
-        add_action(
59
-            'EED_Ticket_Selector__process_ticket_selections__before',
60
-            array('EED_Bot_Trap', 'process_bot_trap'),
61
-            1, 2
62
-        );
63
-    }
52
+		define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__) . DS);
53
+		add_action(
54
+			'AHEE__ticket_selector_chart__template__after_ticket_selector',
55
+			array('EED_Bot_Trap', 'generate_bot_trap'),
56
+			10, 2
57
+		);
58
+		add_action(
59
+			'EED_Ticket_Selector__process_ticket_selections__before',
60
+			array('EED_Bot_Trap', 'process_bot_trap'),
61
+			1, 2
62
+		);
63
+	}
64 64
 
65 65
 
66 66
 
@@ -71,15 +71,15 @@  discard block
 block discarded – undo
71 71
 	 *  @return 	void
72 72
 	 */
73 73
 	public static function set_hooks_admin() {
74
-        if (
75
-            defined('DOING_AJAX')
76
-            && DOING_AJAX
77
-            && apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
78
-            && \EE_Registry::instance()->CFG->registration->use_bot_trap
79
-        ) {
80
-            \EED_Bot_Trap::set_trap();
81
-        }
82
-        add_action(
74
+		if (
75
+			defined('DOING_AJAX')
76
+			&& DOING_AJAX
77
+			&& apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true)
78
+			&& \EE_Registry::instance()->CFG->registration->use_bot_trap
79
+		) {
80
+			\EED_Bot_Trap::set_trap();
81
+		}
82
+		add_action(
83 83
 			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
84 84
 			array( 'EED_Bot_Trap', 'bot_trap_settings_form' ),
85 85
 			5
@@ -130,23 +130,23 @@  discard block
 block discarded – undo
130 130
 
131 131
 
132 132
 	/**
133
-     * process_bot_trap
134
-     *
135
-     * @param array|string $triggered_trap_callback Callback that will be executed for handling the
136
-     *                                              response if the bot trap is triggered.
137
-     *                                              It should receive one argument: a boolean indicating
138
-     *                                              whether the trap was triggered by suspicious timing or not.
133
+	 * process_bot_trap
134
+	 *
135
+	 * @param array|string $triggered_trap_callback Callback that will be executed for handling the
136
+	 *                                              response if the bot trap is triggered.
137
+	 *                                              It should receive one argument: a boolean indicating
138
+	 *                                              whether the trap was triggered by suspicious timing or not.
139 139
 	 */
140 140
 	public static function process_bot_trap( $triggered_trap_callback = array() ) {
141
-        // what's your email address Mr. Bot ?
141
+		// what's your email address Mr. Bot ?
142 142
 		$empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] )
143
-                      && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === ''
144
-            ? true
145
-            : false;
143
+					  && $_REQUEST[ 'tkt-slctr-request-processor-email' ] === ''
144
+			? true
145
+			: false;
146 146
 		// get encrypted timestamp for when the form was originally displayed
147 147
 		$bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] )
148
-            ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] )
149
-            : '';
148
+			? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] )
149
+			: '';
150 150
 		// decrypt and convert to absolute  integer
151 151
 		if ( EE_Registry::instance()->CFG->registration->use_encryption ) {
152 152
 			EE_Registry::instance()->load_core( 'EE_Encryption' );
@@ -156,17 +156,17 @@  discard block
 block discarded – undo
156 156
 		}
157 157
 		// ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
158 158
 		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS )
159
-            ? true
160
-            : false;
159
+			? true
160
+			: false;
161 161
 		// are we human ?
162 162
 		if ( $empty_trap && ! $suspicious_timing ) {
163
-		    do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
163
+			do_action('AHEE__EED_Bot_Trap__process_bot_trap__trap_not_triggered');
164 164
 			return;
165 165
 		}
166 166
 		// check the given callback is valid first before executing
167 167
 		if ( ! is_callable($triggered_trap_callback ) ) {
168 168
 			// invalid callback so lets just sub in our default.
169
-            $triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' );
169
+			$triggered_trap_callback = array( 'EED_Bot_Trap', 'triggered_trap_response' );
170 170
 		}
171 171
 		call_user_func_array($triggered_trap_callback, array( $suspicious_timing ) );
172 172
 	}
@@ -192,21 +192,21 @@  discard block
 block discarded – undo
192 192
 			);
193 193
 		}
194 194
 		$redirect_url = apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url);
195
-        // if AJAX, return the redirect URL
196
-        if (defined('DOING_AJAX') && DOING_AJAX) {
197
-            echo wp_json_encode(
198
-                array_merge(
199
-                    \EE_Error::get_notices(false),
200
-                    array(
201
-                       'redirect_url' => $redirect_url
202
-                    )
203
-                )
204
-            );
205
-            exit();
206
-        }
207
-        wp_safe_redirect($redirect_url);
208
-        exit();
209
-    }
195
+		// if AJAX, return the redirect URL
196
+		if (defined('DOING_AJAX') && DOING_AJAX) {
197
+			echo wp_json_encode(
198
+				array_merge(
199
+					\EE_Error::get_notices(false),
200
+					array(
201
+					   'redirect_url' => $redirect_url
202
+					)
203
+				)
204
+			);
205
+			exit();
206
+		}
207
+		wp_safe_redirect($redirect_url);
208
+		exit();
209
+	}
210 210
 
211 211
 
212 212
 
@@ -237,9 +237,9 @@  discard block
 block discarded – undo
237 237
 	 * @return    void
238 238
 	 */
239 239
 	public static function bot_trap_settings_form() {
240
-        EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
241
-        echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
242
-    }
240
+		EED_Bot_Trap::_bot_trap_settings_form()->enqueue_js();
241
+		echo EED_Bot_Trap::_bot_trap_settings_form()->get_html();
242
+	}
243 243
 
244 244
 
245 245
 
Please login to merge, or discard this patch.
modules/batch/EED_Batch.module.php 2 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -250,7 +250,7 @@
 block discarded – undo
250 250
 		if ( NULL === error_get_last() || ! headers_sent() ) {
251 251
 			header('Content-Type: application/json; charset=UTF-8');
252 252
 		}
253
-        echo wp_json_encode( $json );
253
+		echo wp_json_encode( $json );
254 254
 		exit();
255 255
 	}
256 256
 	
Please login to merge, or discard this patch.
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -17,13 +17,13 @@  discard block
 block discarded – undo
17 17
  * @since		 	   4.8.30.rc.007
18 18
  *
19 19
  */
20
-if( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
21
-	exit( 'No direct script access allowed' );
20
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
21
+	exit('No direct script access allowed');
22 22
 }
23 23
 
24
-define( 'BATCH_URL', plugin_dir_url( __FILE__ ) );
24
+define('BATCH_URL', plugin_dir_url(__FILE__));
25 25
 
26
-class EED_Batch extends EED_Module{
26
+class EED_Batch extends EED_Module {
27 27
 	
28 28
 	/**
29 29
 	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
@@ -70,9 +70,9 @@  discard block
 block discarded – undo
70 70
 	public static function set_hooks() {
71 71
 		//because this is a possibel attack vector, let's have this disabled until 
72 72
 		//we at least have a real use for it on the frontend
73
-		if( apply_filters( 'FHEE__EED_Batch__set_hooks__enable_frontend_batch', false ) ) {
74
-			add_action( 'wp_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) );
75
-			add_filter( 'template_include', array( self::instance(), 'override_template' ), 99 );
73
+		if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
74
+			add_action('wp_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
75
+			add_filter('template_include', array(self::instance(), 'override_template'), 99);
76 76
 		}
77 77
 	}
78 78
 	
@@ -80,28 +80,28 @@  discard block
 block discarded – undo
80 80
 	 * Initializes some hooks for the admin in order to run batch jobs
81 81
 	 */
82 82
 	public static function set_hooks_admin() {
83
-		add_action( 'admin_menu', array( self::instance(), 'register_admin_pages' ) );
84
-		add_action( 'admin_enqueue_scripts', array( self::instance(), 'enqueue_scripts' ) );
83
+		add_action('admin_menu', array(self::instance(), 'register_admin_pages'));
84
+		add_action('admin_enqueue_scripts', array(self::instance(), 'enqueue_scripts'));
85 85
 		
86 86
 		//ajax
87
-		add_action('wp_ajax_espresso_batch_continue',array(self::instance(),'batch_continue'));
88
-		add_action('wp_ajax_espresso_batch_cleanup',array(self::instance(),'batch_cleanup'));
89
-		add_action('wp_ajax_nopriv_espresso_batch_continue',array(self::instance(),'batch_continue'));
90
-		add_action('wp_ajax_nopriv_espresso_batch_cleanup',array(self::instance(),'batch_cleanup'));
87
+		add_action('wp_ajax_espresso_batch_continue', array(self::instance(), 'batch_continue'));
88
+		add_action('wp_ajax_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
89
+		add_action('wp_ajax_nopriv_espresso_batch_continue', array(self::instance(), 'batch_continue'));
90
+		add_action('wp_ajax_nopriv_espresso_batch_cleanup', array(self::instance(), 'batch_cleanup'));
91 91
 	}
92 92
 	
93 93
 	/**
94 94
 	 * Enqueues batch scripts on the frontend or admin, and creates a job
95 95
 	 */
96 96
 	public function enqueue_scripts() { 
97
-		if( isset( $_REQUEST[ 'espresso_batch' ] ) 
97
+		if (isset($_REQUEST['espresso_batch']) 
98 98
 			|| 
99 99
 			( 
100
-				isset( $_REQUEST[ 'page' ] )
101
-				&& $_REQUEST[ 'page' ] == 'espresso_batch'
100
+				isset($_REQUEST['page'])
101
+				&& $_REQUEST['page'] == 'espresso_batch'
102 102
 			) 
103 103
 		) { 
104
-			switch( $this->batch_request_type() ) {
104
+			switch ($this->batch_request_type()) {
105 105
 				case self::batch_job:
106 106
 					$this->enqueue_scripts_styles_batch_create();
107 107
 					break;
@@ -117,11 +117,11 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public function enqueue_scripts_styles_batch_create() {	
119 119
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
120
-		wp_enqueue_script( 'batch_runner_init', BATCH_URL . '/assets/batch_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true );
121
-		wp_localize_script( 'batch_runner_init', 'ee_job_response', $job_response->to_array() );
122
-		wp_localize_script( 'batch_runner_init', 'ee_job_i18n', 
120
+		wp_enqueue_script('batch_runner_init', BATCH_URL.'/assets/batch_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true);
121
+		wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
122
+		wp_localize_script('batch_runner_init', 'ee_job_i18n', 
123 123
 			array(
124
-				'return_url' => $_REQUEST['return_url' ],
124
+				'return_url' => $_REQUEST['return_url'],
125 125
 			));
126 126
 	}
127 127
 	
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 	public function enqueue_scripts_styles_batch_file_create() {
132 132
 		//creates a job based on the request variable
133 133
 		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
134
-		wp_enqueue_script( 'batch_file_runner_init', BATCH_URL . '/assets/batch_file_runner_init.js', array( 'batch_runner' ), EVENT_ESPRESSO_VERSION, true );
135
-		wp_localize_script( 'batch_file_runner_init', 'ee_job_response', $job_response->to_array() );
136
-		wp_localize_script( 'batch_file_runner_init', 'ee_job_i18n', 
134
+		wp_enqueue_script('batch_file_runner_init', BATCH_URL.'/assets/batch_file_runner_init.js', array('batch_runner'), EVENT_ESPRESSO_VERSION, true);
135
+		wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
136
+		wp_localize_script('batch_file_runner_init', 'ee_job_i18n', 
137 137
 				array(
138 138
 					'download_and_redirecting' => sprintf( 
139 139
 							__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso'),
140
-							'<a href="' . $_REQUEST['return_url' ] .'">',
140
+							'<a href="'.$_REQUEST['return_url'].'">',
141 141
 							'</a>' ),
142
-					'return_url' => $_REQUEST['return_url' ],
142
+					'return_url' => $_REQUEST['return_url'],
143 143
 				));
144 144
 	}
145 145
 	
@@ -150,18 +150,18 @@  discard block
 block discarded – undo
150 150
 	 * @return \EventEspressoBatchRequest\Helpers\JobStepResponse
151 151
 	 */
152 152
 	protected function _enqueue_batch_job_scripts_and_styles_and_start_job() {
153
-		wp_register_script( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js', array( 'jquery' ) );
154
-		wp_enqueue_style( 'progress_bar', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION );
155
-		wp_enqueue_script( 'batch_runner', EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js', array( 'progress_bar' ));
153
+		wp_register_script('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js', array('jquery'));
154
+		wp_enqueue_style('progress_bar', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css', array(), EVENT_ESPRESSO_VERSION);
155
+		wp_enqueue_script('batch_runner', EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js', array('progress_bar'));
156 156
 		//just copy the bits of EE admin's eei18n that we need in the JS
157
-		wp_localize_script( 'batch_runner', 'eei18n', array( 'ajax_url' => WP_AJAX_URL, 'is_admin' => (bool)is_admin() ) );
158
-		$job_handler_classname = stripslashes( $_GET[ 'job_handler' ] );
157
+		wp_localize_script('batch_runner', 'eei18n', array('ajax_url' => WP_AJAX_URL, 'is_admin' => (bool) is_admin()));
158
+		$job_handler_classname = stripslashes($_GET['job_handler']);
159 159
 		$request_data = array_diff_key( 
160 160
 				$_REQUEST, 
161
-				array_flip( array( 'action',  'page', 'ee', 'batch' ) ) );
161
+				array_flip(array('action', 'page', 'ee', 'batch')) );
162 162
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
163 163
 		//eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
164
-		$job_response = $batch_runner->create_job( $job_handler_classname, $request_data );
164
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
165 165
 		//remember the response for later. We need it to display the page body
166 166
 		$this->_job_step_response = $job_response;
167 167
 		return $job_response;
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
 	 * @param string $template
173 173
 	 * @return string
174 174
 	 */
175
-	public function override_template( $template ) {
176
-		if( isset( $_REQUEST[ 'espresso_batch' ] ) && isset( $_REQUEST[ 'batch' ] ) ) {
177
-			return EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_frontend_wrapper.template.html';
175
+	public function override_template($template) {
176
+		if (isset($_REQUEST['espresso_batch']) && isset($_REQUEST['batch'])) {
177
+			return EE_MODULES.'batch'.DS.'templates'.DS.'batch_frontend_wrapper.template.html';
178 178
 		}
179 179
 		return $template;
180 180
 	}
@@ -185,11 +185,11 @@  discard block
 block discarded – undo
185 185
 	public function register_admin_pages() {
186 186
 		add_submenu_page( 
187 187
 			'', //parent slug. we don't want this to actually appear in the menu
188
-			__( 'Batch Job', 'event_espresso' ), //page title
188
+			__('Batch Job', 'event_espresso'), //page title
189 189
 			'n/a', //menu title
190 190
 			'read', //we want this page to actually be accessible to anyone,  
191 191
 			'espresso_batch', //menu slug
192
-			array( self::instance(), 'show_admin_page' )
192
+			array(self::instance(), 'show_admin_page')
193 193
 		);
194 194
 	}
195 195
 	
@@ -199,8 +199,8 @@  discard block
 block discarded – undo
199 199
 	 */
200 200
 	public function show_admin_page() { 
201 201
 		echo EEH_Template::locate_template( 
202
-			EE_MODULES . 'batch' . DS . 'templates' . DS . 'batch_wrapper.template.html', 
203
-			array( 'batch_request_type' => $this->batch_request_type() )
202
+			EE_MODULES.'batch'.DS.'templates'.DS.'batch_wrapper.template.html', 
203
+			array('batch_request_type' => $this->batch_request_type())
204 204
 		);
205 205
 	}
206 206
 	
@@ -208,10 +208,10 @@  discard block
 block discarded – undo
208 208
 	 * Receives ajax calls for continuing a job
209 209
 	 */
210 210
 	public function batch_continue() {
211
-		$job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] );
211
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
212 212
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
213
-		$response_obj = $batch_runner->continue_job( $job_id);
214
-		$this->_return_json( $response_obj->to_array() );
213
+		$response_obj = $batch_runner->continue_job($job_id);
214
+		$this->_return_json($response_obj->to_array());
215 215
 	}
216 216
 	
217 217
 	/**
@@ -219,10 +219,10 @@  discard block
 block discarded – undo
219 219
 	 * @return type
220 220
 	 */
221 221
 	public function batch_cleanup() {
222
-		$job_id = sanitize_text_field( $_REQUEST[ 'job_id' ] );
222
+		$job_id = sanitize_text_field($_REQUEST['job_id']);
223 223
 		$batch_runner = new EventEspressoBatchRequest\BatchRequestProcessor();
224
-		$response_obj = $batch_runner->cleanup_job( $job_id );
225
-		$this->_return_json( $response_obj->to_array() );
224
+		$response_obj = $batch_runner->cleanup_job($job_id);
225
+		$this->_return_json($response_obj->to_array());
226 226
 	}
227 227
 	
228 228
 	
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
 	 *	'isEEajax' => true,//indicates this is a response from EE
239 239
 	 * )
240 240
 	 */
241
-	protected function _return_json( $data ) {
241
+	protected function _return_json($data) {
242 242
 		$json = array(
243 243
 			'notices' => EE_Error::get_notices(),
244 244
 			'data' => $data,
@@ -247,10 +247,10 @@  discard block
 block discarded – undo
247 247
 
248 248
 
249 249
 		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
250
-		if ( NULL === error_get_last() || ! headers_sent() ) {
250
+		if (NULL === error_get_last() || ! headers_sent()) {
251 251
 			header('Content-Type: application/json; charset=UTF-8');
252 252
 		}
253
-        echo wp_json_encode( $json );
253
+        echo wp_json_encode($json);
254 254
 		exit();
255 255
 	}
256 256
 	
@@ -266,16 +266,16 @@  discard block
 block discarded – undo
266 266
 	 * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
267 267
 	 */
268 268
 	public function batch_request_type() {
269
-		if( $this->_batch_request_type === null ) {
270
-			if( isset( $_GET[ 'batch' ] ) ) {
271
-				if( $_GET[ 'batch' ] == self::batch_job ) {
269
+		if ($this->_batch_request_type === null) {
270
+			if (isset($_GET['batch'])) {
271
+				if ($_GET['batch'] == self::batch_job) {
272 272
 					$this->_batch_request_type = self::batch_job;
273
-				} elseif( $_GET[ 'batch' ] == self::batch_file_job ) {
273
+				} elseif ($_GET['batch'] == self::batch_file_job) {
274 274
 					$this->_batch_request_type = self::batch_file_job;
275 275
 				}
276 276
 			}
277 277
 			//if we didn't find that it was a batch request, indicate it wasn't
278
-			if( $this->_batch_request_type === null ) {
278
+			if ($this->_batch_request_type === null) {
279 279
 				$this->_batch_request_type = self::batch_not_job;
280 280
 			}
281 281
 		}
@@ -286,7 +286,7 @@  discard block
 block discarded – undo
286 286
 	 * Unnecessary
287 287
 	 * @param type $WP
288 288
 	 */
289
-	public function run( $WP ) {
289
+	public function run($WP) {
290 290
 		
291 291
 	}
292 292
 
Please login to merge, or discard this patch.
reg_steps/payment_options/EE_SPCO_Reg_Step_Payment_Options.class.php 1 patch
Spacing   +348 added lines, -348 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -38,32 +38,32 @@  discard block
 block discarded – undo
38 38
 	public static function set_hooks() {
39 39
 		add_filter(
40 40
 			'FHEE__SPCO__EE_Line_Item_Filter_Collection',
41
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters' )
41
+			array('EE_SPCO_Reg_Step_Payment_Options', 'add_spco_line_item_filters')
42 42
 		);
43 43
 		add_action(
44 44
 			'wp_ajax_switch_spco_billing_form',
45
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )
45
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
46 46
 		);
47 47
 		add_action(
48 48
 			'wp_ajax_nopriv_switch_spco_billing_form',
49
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form' )
49
+			array('EE_SPCO_Reg_Step_Payment_Options', 'switch_spco_billing_form')
50 50
 		);
51
-		add_action( 'wp_ajax_save_payer_details', array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' ) );
51
+		add_action('wp_ajax_save_payer_details', array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details'));
52 52
 		add_action(
53 53
 			'wp_ajax_nopriv_save_payer_details',
54
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details' )
54
+			array('EE_SPCO_Reg_Step_Payment_Options', 'save_payer_details')
55 55
 		);
56 56
 		add_action(
57 57
 			'wp_ajax_get_transaction_details_for_gateways',
58
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
58
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
59 59
 		);
60 60
 		add_action(
61 61
 			'wp_ajax_nopriv_get_transaction_details_for_gateways',
62
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details' )
62
+			array('EE_SPCO_Reg_Step_Payment_Options', 'get_transaction_details')
63 63
 		);
64 64
 		add_filter(
65 65
 			'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
66
-			array( 'EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method' ),
66
+			array('EE_SPCO_Reg_Step_Payment_Options', 'bypass_recaptcha_for_load_payment_method'),
67 67
 			10,
68 68
 			1
69 69
 		);
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	 * @throws \EE_Error
78 78
 	 */
79 79
 	public static function switch_spco_billing_form() {
80
-		EED_Single_Page_Checkout::process_ajax_request( 'switch_payment_method' );
80
+		EED_Single_Page_Checkout::process_ajax_request('switch_payment_method');
81 81
 	}
82 82
 
83 83
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
 	 * @throws \EE_Error
89 89
 	 */
90 90
 	public static function save_payer_details() {
91
-		EED_Single_Page_Checkout::process_ajax_request( 'save_payer_details_via_ajax' );
91
+		EED_Single_Page_Checkout::process_ajax_request('save_payer_details_via_ajax');
92 92
 	}
93 93
 
94 94
 
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
 	 * @throws \EE_Error
100 100
 	 */
101 101
 	public static function get_transaction_details() {
102
-		EED_Single_Page_Checkout::process_ajax_request( 'get_transaction_details_for_gateways' );
102
+		EED_Single_Page_Checkout::process_ajax_request('get_transaction_details_for_gateways');
103 103
 	}
104 104
 
105 105
 
@@ -126,10 +126,10 @@  discard block
 block discarded – undo
126 126
 	 * @access    public
127 127
 	 * @param    EE_Checkout $checkout
128 128
 	 */
129
-	public function __construct( EE_Checkout $checkout ) {
129
+	public function __construct(EE_Checkout $checkout) {
130 130
 		$this->_slug = 'payment_options';
131
-		$this->_name = __( 'Payment Options', 'event_espresso' );
132
-		$this->_template = SPCO_REG_STEPS_PATH . $this->_slug . DS . 'payment_options_main.template.php';
131
+		$this->_name = __('Payment Options', 'event_espresso');
132
+		$this->_template = SPCO_REG_STEPS_PATH.$this->_slug.DS.'payment_options_main.template.php';
133 133
 		$this->checkout = $checkout;
134 134
 		$this->_reset_success_message();
135 135
 		$this->set_instructions(
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	/**
155 155
 	 * @param null $line_item_display
156 156
 	 */
157
-	public function set_line_item_display( $line_item_display ) {
157
+	public function set_line_item_display($line_item_display) {
158 158
 		$this->line_item_display = $line_item_display;
159 159
 	}
160 160
 
@@ -172,8 +172,8 @@  discard block
 block discarded – undo
172 172
 	/**
173 173
 	 * @param boolean $handle_IPN_in_this_request
174 174
 	 */
175
-	public function set_handle_IPN_in_this_request( $handle_IPN_in_this_request ) {
176
-		$this->handle_IPN_in_this_request = filter_var( $handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN );
175
+	public function set_handle_IPN_in_this_request($handle_IPN_in_this_request) {
176
+		$this->handle_IPN_in_this_request = filter_var($handle_IPN_in_this_request, FILTER_VALIDATE_BOOLEAN);
177 177
 	}
178 178
 
179 179
 
@@ -208,14 +208,14 @@  discard block
 block discarded – undo
208 208
 	public function enqueue_styles_and_scripts() {
209 209
 		$transaction = $this->checkout->transaction;
210 210
 		//if the transaction isn't set or nothing is owed on it, don't enqueue any JS
211
-		if( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats( $transaction->remaining(), 0 ) ) {
211
+		if ( ! $transaction instanceof EE_Transaction || EEH_Money::compare_floats($transaction->remaining(), 0)) {
212 212
 			return;
213 213
 		}
214
-		foreach( EEM_Payment_Method::instance()->get_all_for_transaction( $transaction, EEM_Payment_Method::scope_cart ) as $payment_method ) {
214
+		foreach (EEM_Payment_Method::instance()->get_all_for_transaction($transaction, EEM_Payment_Method::scope_cart) as $payment_method) {
215 215
 			$type_obj = $payment_method->type_obj();
216
-			if( $type_obj instanceof EE_PMT_Base ) {
217
-				$billing_form = $type_obj->generate_new_billing_form( $transaction );
218
-				if( $billing_form instanceof EE_Form_Section_Proper ) {
216
+			if ($type_obj instanceof EE_PMT_Base) {
217
+				$billing_form = $type_obj->generate_new_billing_form($transaction);
218
+				if ($billing_form instanceof EE_Form_Section_Proper) {
219 219
 					$billing_form->enqueue_js();
220 220
 				}
221 221
 			}
@@ -240,20 +240,20 @@  discard block
 block discarded – undo
240 240
 			// 	$ 0.00 transactions (no payment required)
241 241
 			! $this->checkout->payment_required()
242 242
 			// but do NOT remove if current action being called belongs to this reg step
243
-			&& ! is_callable( array( $this, $this->checkout->action ) )
243
+			&& ! is_callable(array($this, $this->checkout->action))
244 244
 			&& ! $this->completed()
245 245
 		) {
246 246
 			// and if so, then we no longer need the Payment Options step
247
-			if ( $this->is_current_step() ) {
247
+			if ($this->is_current_step()) {
248 248
 				$this->checkout->generate_reg_form = false;
249 249
 			}
250
-			$this->checkout->remove_reg_step( $this->_slug );
250
+			$this->checkout->remove_reg_step($this->_slug);
251 251
 			// DEBUG LOG
252 252
 			//$this->checkout->log( __CLASS__, __FUNCTION__, __LINE__ );
253 253
 			return false;
254 254
 		}
255 255
 		// load EEM_Payment_Method
256
-		EE_Registry::instance()->load_model( 'Payment_Method' );
256
+		EE_Registry::instance()->load_model('Payment_Method');
257 257
 		// get all active payment methods
258 258
 		$this->checkout->available_payment_methods = EEM_Payment_Method::instance()->get_all_for_transaction(
259 259
 			$this->checkout->transaction,
@@ -280,15 +280,15 @@  discard block
 block discarded – undo
280 280
 		$insufficient_spaces_available = array();
281 281
 		$reg_count = 0;
282 282
 		// loop thru registrations to gather info
283
-		$registrations = $this->checkout->transaction->registrations( $this->checkout->reg_cache_where_params );
283
+		$registrations = $this->checkout->transaction->registrations($this->checkout->reg_cache_where_params);
284 284
 		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
285 285
 			$registrations,
286 286
 			$this->checkout->revisit
287 287
 		);
288
-		foreach ( $registrations as $REG_ID => $registration ) {
288
+		foreach ($registrations as $REG_ID => $registration) {
289 289
 			// has this registration lost it's space ?
290
-			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
291
-				$insufficient_spaces_available[ $registration->event()->ID() ] = $registration->event();
290
+			if (isset($ejected_registrations[$REG_ID])) {
291
+				$insufficient_spaces_available[$registration->event()->ID()] = $registration->event();
292 292
 				continue;
293 293
 			}
294 294
 			/** @var $registration EE_Registration */
@@ -300,9 +300,9 @@  discard block
 block discarded – undo
300 300
 				&& $registration->status_ID() === EEM_Registration::status_id_approved
301 301
 			)
302 302
 			) {
303
-				if ( $registration->event()->is_sold_out() || $registration->event()->is_sold_out( true ) ) {
303
+				if ($registration->event()->is_sold_out() || $registration->event()->is_sold_out(true)) {
304 304
 					// add event to list of events that are sold out
305
-					$sold_out_events[ $registration->event()->ID() ] = $registration->event();
305
+					$sold_out_events[$registration->event()->ID()] = $registration->event();
306 306
 					do_action(
307 307
 						'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__sold_out_event',
308 308
 						$registration->event(),
@@ -311,9 +311,9 @@  discard block
 block discarded – undo
311 311
 					continue;
312 312
 				}
313 313
 				// event requires admin approval
314
-				if ( $registration->status_ID() === EEM_Registration::status_id_not_approved ) {
314
+				if ($registration->status_ID() === EEM_Registration::status_id_not_approved) {
315 315
 					// add event to list of events with pre-approval reg status
316
-					$registrations_requiring_pre_approval[ $REG_ID ] = $registration;
316
+					$registrations_requiring_pre_approval[$REG_ID] = $registration;
317 317
 					do_action(
318 318
 						'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_pre_approval',
319 319
 						$registration->event(),
@@ -322,8 +322,8 @@  discard block
 block discarded – undo
322 322
 				}
323 323
 			}
324 324
 			// are they allowed to pay now and is there monies owing?
325
-			if ( $registration->owes_monies_and_can_pay() ) {
326
-				$registrations_requiring_payment[ $REG_ID ] = $registration;
325
+			if ($registration->owes_monies_and_can_pay()) {
326
+				$registrations_requiring_payment[$REG_ID] = $registration;
327 327
 				do_action(
328 328
 					'AHEE__EE_SPCO_Reg_Step_Payment_Options__generate_reg_form__event_requires_payment',
329 329
 					$registration->event(),
@@ -334,29 +334,29 @@  discard block
 block discarded – undo
334 334
 				&& $registration->status_ID() !== EEM_Registration::status_id_not_approved
335 335
 				&& $registration->ticket()->is_free()
336 336
 			) {
337
-				$registrations_for_free_events[ $registration->event()->ID() ] = $registration;
337
+				$registrations_for_free_events[$registration->event()->ID()] = $registration;
338 338
 			}
339 339
 		}
340 340
 		$subsections = array();
341 341
 		// now decide which template to load
342
-		if ( ! empty( $sold_out_events ) ) {
343
-			$subsections['sold_out_events'] = $this->_sold_out_events( $sold_out_events );
342
+		if ( ! empty($sold_out_events)) {
343
+			$subsections['sold_out_events'] = $this->_sold_out_events($sold_out_events);
344 344
 		}
345
-		if ( ! empty( $insufficient_spaces_available ) ) {
345
+		if ( ! empty($insufficient_spaces_available)) {
346 346
 			$subsections['insufficient_space'] = $this->_insufficient_spaces_available(
347 347
 				$insufficient_spaces_available
348 348
 			);
349 349
 		}
350
-		if ( ! empty( $registrations_requiring_pre_approval ) ) {
350
+		if ( ! empty($registrations_requiring_pre_approval)) {
351 351
 			$subsections['registrations_requiring_pre_approval'] = $this->_registrations_requiring_pre_approval(
352 352
 				$registrations_requiring_pre_approval
353 353
 			);
354 354
 		}
355
-		if ( ! empty( $registrations_for_free_events ) ) {
356
-			$subsections['no_payment_required'] = $this->_no_payment_required( $registrations_for_free_events );
355
+		if ( ! empty($registrations_for_free_events)) {
356
+			$subsections['no_payment_required'] = $this->_no_payment_required($registrations_for_free_events);
357 357
 		}
358
-		if ( ! empty( $registrations_requiring_payment ) ) {
359
-			if ( $this->checkout->amount_owing > 0 ) {
358
+		if ( ! empty($registrations_requiring_payment)) {
359
+			if ($this->checkout->amount_owing > 0) {
360 360
 				// autoload Line_Item_Display classes
361 361
 				EEH_Autoloader::register_line_item_filter_autoloaders();
362 362
 				$line_item_filter_processor = new EE_Line_Item_Filter_Processor(
@@ -369,15 +369,15 @@  discard block
 block discarded – undo
369 369
 				/** @var EE_Line_Item $filtered_line_item_tree */
370 370
 				$filtered_line_item_tree = $line_item_filter_processor->process();
371 371
 				EEH_Autoloader::register_line_item_display_autoloaders();
372
-				$this->set_line_item_display( new EE_Line_Item_Display( 'spco' ) );
372
+				$this->set_line_item_display(new EE_Line_Item_Display('spco'));
373 373
 				$subsections['payment_options'] = $this->_display_payment_options(
374 374
 					$this->line_item_display->display_line_item(
375 375
 						$filtered_line_item_tree,
376
-						array( 'registrations' => $registrations )
376
+						array('registrations' => $registrations)
377 377
 					)
378 378
 				);
379 379
 				$this->checkout->amount_owing = $filtered_line_item_tree->total();
380
-				$this->_apply_registration_payments_to_amount_owing( $registrations );
380
+				$this->_apply_registration_payments_to_amount_owing($registrations);
381 381
 			}
382 382
 		} else {
383 383
 			$this->_hide_reg_step_submit_button_if_revisit();
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 	 * @return \EE_Line_Item_Filter_Collection
409 409
 	 * @throws \EE_Error
410 410
 	 */
411
-	public static function add_spco_line_item_filters( EE_Line_Item_Filter_Collection $line_item_filter_collection ) {
411
+	public static function add_spco_line_item_filters(EE_Line_Item_Filter_Collection $line_item_filter_collection) {
412 412
 		$line_item_filter_collection->add(
413 413
 			new EE_Billable_Line_Item_Filter(
414 414
 				EE_SPCO_Reg_Step_Payment_Options::remove_ejected_registrations(
@@ -418,7 +418,7 @@  discard block
 block discarded – undo
418 418
 				)
419 419
 			)
420 420
 		);
421
-		$line_item_filter_collection->add( new EE_Non_Zero_Line_Item_Filter() );
421
+		$line_item_filter_collection->add(new EE_Non_Zero_Line_Item_Filter());
422 422
 		return $line_item_filter_collection;
423 423
 	}
424 424
 
@@ -434,15 +434,15 @@  discard block
 block discarded – undo
434 434
 	 * @return \EE_Registration[]
435 435
 	 * @throws \EE_Error
436 436
 	 */
437
-	public static function remove_ejected_registrations( array $registrations ) {
437
+	public static function remove_ejected_registrations(array $registrations) {
438 438
 		$ejected_registrations = EE_SPCO_Reg_Step_Payment_Options::find_registrations_that_lost_their_space(
439 439
 			$registrations,
440 440
 			EE_Registry::instance()->SSN->checkout()->revisit
441 441
 		);
442
-		foreach ( $registrations as $REG_ID => $registration ) {
442
+		foreach ($registrations as $REG_ID => $registration) {
443 443
 			// has this registration lost it's space ?
444
-			if ( isset( $ejected_registrations[ $REG_ID ] ) ) {
445
-				unset( $registrations[ $REG_ID ] );
444
+			if (isset($ejected_registrations[$REG_ID])) {
445
+				unset($registrations[$REG_ID]);
446 446
 				continue;
447 447
 			}
448 448
 		}
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 	 * @return array
466 466
 	 * @throws \EE_Error
467 467
 	 */
468
-	public static function find_registrations_that_lost_their_space( array $registrations, $revisit = false ) {
468
+	public static function find_registrations_that_lost_their_space(array $registrations, $revisit = false) {
469 469
         // registrations per event
470 470
 		$event_reg_count = array();
471 471
 		// spaces left per event
@@ -474,8 +474,8 @@  discard block
 block discarded – undo
474 474
         $tickets_remaining = array();
475 475
         // registrations that have lost their space
476 476
 		$ejected_registrations = array();
477
-		foreach ( $registrations as $REG_ID => $registration ) {
478
-			if ( $registration->status_ID() === EEM_Registration::status_id_approved ) {
477
+		foreach ($registrations as $REG_ID => $registration) {
478
+			if ($registration->status_ID() === EEM_Registration::status_id_approved) {
479 479
 				continue;
480 480
 			}
481 481
 			$EVT_ID = $registration->event_ID();
@@ -496,13 +496,13 @@  discard block
 block discarded – undo
496 496
 				$revisit
497 497
 				&& (
498 498
                     $tickets_remaining[$ticket->ID()] === 0
499
-				    || $event_reg_count[ $EVT_ID ] > $event_spaces_remaining[ $EVT_ID ]
499
+				    || $event_reg_count[$EVT_ID] > $event_spaces_remaining[$EVT_ID]
500 500
                 )
501 501
 			) {
502
-				$ejected_registrations[ $REG_ID ] = $registration->event();
503
-				if ( $registration->status_ID() !== EEM_Registration::status_id_wait_list ) {
502
+				$ejected_registrations[$REG_ID] = $registration->event();
503
+				if ($registration->status_ID() !== EEM_Registration::status_id_wait_list) {
504 504
 					/** @type EE_Registration_Processor $registration_processor */
505
-					$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
505
+					$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
506 506
 					// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
507 507
 					$registration_processor->manually_update_registration_status(
508 508
 						$registration,
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	 * @return void
538 538
 	 */
539 539
 	protected function _hide_reg_step_submit_button_if_revisit() {
540
-		if ( $this->checkout->revisit ) {
541
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string' );
540
+		if ($this->checkout->revisit) {
541
+			add_filter('FHEE__EE_SPCO_Reg_Step__reg_step_submit_button__sbmt_btn_html', '__return_empty_string');
542 542
 		}
543 543
 	}
544 544
 
@@ -552,13 +552,13 @@  discard block
 block discarded – undo
552 552
 	 * @return \EE_Form_Section_Proper
553 553
 	 * @throws \EE_Error
554 554
 	 */
555
-	private function _sold_out_events( $sold_out_events_array = array() ) {
555
+	private function _sold_out_events($sold_out_events_array = array()) {
556 556
 		// set some defaults
557 557
 		$this->checkout->selected_method_of_payment = 'events_sold_out';
558 558
 		$sold_out_events = '';
559
-		foreach ( $sold_out_events_array as $sold_out_event ) {
559
+		foreach ($sold_out_events_array as $sold_out_event) {
560 560
 			$sold_out_events .= EEH_HTML::li(
561
-				EEH_HTML::span( '  ' .$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )
561
+				EEH_HTML::span('  '.$sold_out_event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
562 562
 			);
563 563
 		}
564 564
 		return new EE_Form_Section_Proper(
@@ -605,14 +605,14 @@  discard block
 block discarded – undo
605 605
 	 * @return \EE_Form_Section_Proper
606 606
 	 * @throws \EE_Error
607 607
 	 */
608
-	private function _insufficient_spaces_available( $insufficient_spaces_events_array = array() ) {
608
+	private function _insufficient_spaces_available($insufficient_spaces_events_array = array()) {
609 609
 		// set some defaults
610 610
 		$this->checkout->selected_method_of_payment = 'invoice';
611 611
 		$insufficient_space_events = '';
612
-		foreach ( $insufficient_spaces_events_array as $event ) {
613
-			if ( $event instanceof EE_Event ) {
612
+		foreach ($insufficient_spaces_events_array as $event) {
613
+			if ($event instanceof EE_Event) {
614 614
 				$insufficient_space_events .= EEH_HTML::li(
615
-					EEH_HTML::span( ' ' . $event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text' )
615
+					EEH_HTML::span(' '.$event->name(), '', 'dashicons dashicons-marker ee-icon-size-16 pink-text')
616 616
 				);
617 617
 			}
618 618
 		}
@@ -656,17 +656,17 @@  discard block
 block discarded – undo
656 656
 	 * @return \EE_Form_Section_Proper
657 657
 	 * @throws \EE_Error
658 658
 	 */
659
-	private function _registrations_requiring_pre_approval( $registrations_requiring_pre_approval = array() ) {
659
+	private function _registrations_requiring_pre_approval($registrations_requiring_pre_approval = array()) {
660 660
 		$events_requiring_pre_approval = '';
661
-		foreach ( $registrations_requiring_pre_approval as $registration ) {
662
-			if ( $registration instanceof EE_Registration && $registration->event() instanceof EE_Event ) {
663
-				$events_requiring_pre_approval[ $registration->event()->ID() ] = EEH_HTML::li(
661
+		foreach ($registrations_requiring_pre_approval as $registration) {
662
+			if ($registration instanceof EE_Registration && $registration->event() instanceof EE_Event) {
663
+				$events_requiring_pre_approval[$registration->event()->ID()] = EEH_HTML::li(
664 664
 					EEH_HTML::span(
665 665
 						'',
666 666
 						'',
667 667
 						'dashicons dashicons-marker ee-icon-size-16 orange-text'
668 668
 					)
669
-					. EEH_HTML::span( $registration->event()->name(), '', 'orange-text' )
669
+					. EEH_HTML::span($registration->event()->name(), '', 'orange-text')
670 670
 				);
671 671
 			}
672 672
 		}
@@ -685,7 +685,7 @@  discard block
 block discarded – undo
685 685
 						'template_args'        => apply_filters(
686 686
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___sold_out_events__template_args',
687 687
 							array(
688
-								'events_requiring_pre_approval'     => implode( '', $events_requiring_pre_approval ),
688
+								'events_requiring_pre_approval'     => implode('', $events_requiring_pre_approval),
689 689
 								'events_requiring_pre_approval_msg' => apply_filters(
690 690
 									'FHEE__EE_SPCO_Reg_Step_Payment_Options___events_requiring_pre_approval__events_requiring_pre_approval_msg',
691 691
 									__(
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
 	 * @return \EE_Form_Section_Proper
711 711
 	 * @throws \EE_Error
712 712
 	 */
713
-	private function _no_payment_required( $registrations_for_free_events = array() ) {
713
+	private function _no_payment_required($registrations_for_free_events = array()) {
714 714
 		// set some defaults
715 715
 		$this->checkout->selected_method_of_payment = 'no_payment_required';
716 716
 		// generate no_payment_required form
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 								'ticket_count'                  => array(),
735 735
 								'registrations_for_free_events' => $registrations_for_free_events,
736 736
 								'no_payment_required_msg'       => EEH_HTML::p(
737
-									__( 'This is a free event, so no billing will occur.', 'event_espresso' )
737
+									__('This is a free event, so no billing will occur.', 'event_espresso')
738 738
 								)
739 739
 							)
740 740
 						),
@@ -753,7 +753,7 @@  discard block
 block discarded – undo
753 753
 	 * @return \EE_Form_Section_Proper
754 754
 	 * @throws \EE_Error
755 755
 	 */
756
-	private function _display_payment_options( $transaction_details = '' ) {
756
+	private function _display_payment_options($transaction_details = '') {
757 757
 		// has method_of_payment been set by no-js user?
758 758
 		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment();
759 759
 		// build payment options form
@@ -765,18 +765,18 @@  discard block
 block discarded – undo
765 765
 						'before_payment_options' => apply_filters(
766 766
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__before_payment_options',
767 767
 							new EE_Form_Section_Proper(
768
-								array( 'layout_strategy' => new EE_Div_Per_Section_Layout() )
768
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
769 769
 							)
770 770
 						),
771 771
 						'payment_options'        => $this->_setup_payment_options(),
772 772
 						'after_payment_options'  => apply_filters(
773 773
 							'FHEE__EE_SPCO_Reg_Step_Payment_Options___display_payment_options__after_payment_options',
774 774
 							new EE_Form_Section_Proper(
775
-								array( 'layout_strategy' => new EE_Div_Per_Section_Layout() )
775
+								array('layout_strategy' => new EE_Div_Per_Section_Layout())
776 776
 							)
777 777
 						),
778 778
 						'default_hidden_inputs'  => $this->reg_step_hidden_inputs(),
779
-						'extra_hidden_inputs'    => $this->_extra_hidden_inputs( false )
779
+						'extra_hidden_inputs'    => $this->_extra_hidden_inputs(false)
780 780
 					),
781 781
 					'layout_strategy' => new EE_Template_Layout(
782 782
 						array(
@@ -805,10 +805,10 @@  discard block
 block discarded – undo
805 805
 	 * @return \EE_Form_Section_Proper
806 806
 	 * @throws \EE_Error
807 807
 	 */
808
-	private function _extra_hidden_inputs( $no_payment_required = true ) {
808
+	private function _extra_hidden_inputs($no_payment_required = true) {
809 809
 		return new EE_Form_Section_Proper(
810 810
 			array(
811
-				'html_id'         => 'ee-' . $this->slug() . '-extra-hidden-inputs',
811
+				'html_id'         => 'ee-'.$this->slug().'-extra-hidden-inputs',
812 812
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
813 813
 				'subsections'     => array(
814 814
 					'spco_no_payment_required' => new EE_Hidden_Input(
@@ -840,16 +840,16 @@  discard block
 block discarded – undo
840 840
 	 * @access protected
841 841
 	 * @param array $registrations
842 842
 	 */
843
-	protected function _apply_registration_payments_to_amount_owing( array $registrations ) {
843
+	protected function _apply_registration_payments_to_amount_owing(array $registrations) {
844 844
 		$payments = array();
845
-		foreach ( $registrations as $registration ) {
846
-			if ( $registration instanceof EE_Registration && $registration->owes_monies_and_can_pay() ) {
845
+		foreach ($registrations as $registration) {
846
+			if ($registration instanceof EE_Registration && $registration->owes_monies_and_can_pay()) {
847 847
 				$payments += $registration->registration_payments();
848 848
 			}
849 849
 		}
850
-		if ( ! empty( $payments ) ) {
851
-			foreach ( $payments as $payment ) {
852
-				if ( $payment instanceof EE_Registration_Payment ) {
850
+		if ( ! empty($payments)) {
851
+			foreach ($payments as $payment) {
852
+				if ($payment instanceof EE_Registration_Payment) {
853 853
 					$this->checkout->amount_owing -= $payment->amount();
854 854
 				}
855 855
 			}
@@ -865,11 +865,11 @@  discard block
 block discarded – undo
865 865
 	 * @param    bool $force_reset
866 866
 	 * @return    void
867 867
 	 */
868
-	private function _reset_selected_method_of_payment( $force_reset = false ) {
868
+	private function _reset_selected_method_of_payment($force_reset = false) {
869 869
 		$reset_payment_method = $force_reset
870 870
 			? true
871
-			: sanitize_text_field( EE_Registry::instance()->REQ->get( 'reset_payment_method', false ) );
872
-		if ( $reset_payment_method ) {
871
+			: sanitize_text_field(EE_Registry::instance()->REQ->get('reset_payment_method', false));
872
+		if ($reset_payment_method) {
873 873
 			$this->checkout->selected_method_of_payment = null;
874 874
 			$this->checkout->payment_method = null;
875 875
 			$this->checkout->billing_form = null;
@@ -888,12 +888,12 @@  discard block
 block discarded – undo
888 888
 	 * @param string $selected_method_of_payment
889 889
 	 * @return  void
890 890
 	 */
891
-	private function _save_selected_method_of_payment( $selected_method_of_payment = '' ) {
892
-		$selected_method_of_payment = ! empty( $selected_method_of_payment )
891
+	private function _save_selected_method_of_payment($selected_method_of_payment = '') {
892
+		$selected_method_of_payment = ! empty($selected_method_of_payment)
893 893
 			? $selected_method_of_payment
894 894
 			: $this->checkout->selected_method_of_payment;
895 895
 		EE_Registry::instance()->SSN->set_session_data(
896
-			array( 'selected_method_of_payment' => $selected_method_of_payment )
896
+			array('selected_method_of_payment' => $selected_method_of_payment)
897 897
 		);
898 898
 	}
899 899
 
@@ -909,19 +909,19 @@  discard block
 block discarded – undo
909 909
 		// load payment method classes
910 910
 		$this->checkout->available_payment_methods = $this->_get_available_payment_methods();
911 911
 		// switch up header depending on number of available payment methods
912
-		$payment_method_header = count( $this->checkout->available_payment_methods ) > 1
912
+		$payment_method_header = count($this->checkout->available_payment_methods) > 1
913 913
 			? apply_filters(
914 914
 				'FHEE__registration_page_payment_options__method_of_payment_hdr',
915
-				__( 'Please Select Your Method of Payment', 'event_espresso' )
915
+				__('Please Select Your Method of Payment', 'event_espresso')
916 916
 			)
917 917
 			: apply_filters(
918 918
 				'FHEE__registration_page_payment_options__method_of_payment_hdr',
919
-				__( 'Method of Payment', 'event_espresso' )
919
+				__('Method of Payment', 'event_espresso')
920 920
 			);
921 921
 		$available_payment_methods = array(
922 922
 			// display the "Payment Method" header
923 923
 			'payment_method_header' => new EE_Form_Section_HTML(
924
-				EEH_HTML::h4( $payment_method_header, 'method-of-payment-hdr' )
924
+				EEH_HTML::h4($payment_method_header, 'method-of-payment-hdr')
925 925
 			)
926 926
 		);
927 927
 		// the list of actual payment methods ( invoice, paypal, etc ) in a  ( slug => HTML )  format
@@ -930,32 +930,32 @@  discard block
 block discarded – undo
930 930
 		// additional instructions to be displayed and hidden below payment methods (adding a clearing div to start)
931 931
 		$payment_methods_billing_info = array(
932 932
 			new EE_Form_Section_HTML(
933
-				EEH_HTML::div( '<br />', '', '', 'clear:both;' )
933
+				EEH_HTML::div('<br />', '', '', 'clear:both;')
934 934
 			)
935 935
 		);
936 936
 		// loop through payment methods
937
-		foreach ( $this->checkout->available_payment_methods as $payment_method ) {
938
-			if ( $payment_method instanceof EE_Payment_Method ) {
937
+		foreach ($this->checkout->available_payment_methods as $payment_method) {
938
+			if ($payment_method instanceof EE_Payment_Method) {
939 939
 				$payment_method_button = EEH_HTML::img(
940 940
 					$payment_method->button_url(),
941 941
 					$payment_method->name(),
942
-					'spco-payment-method-' . $payment_method->slug() . '-btn-img',
942
+					'spco-payment-method-'.$payment_method->slug().'-btn-img',
943 943
 					'spco-payment-method-btn-img'
944 944
 				);
945 945
 				// check if any payment methods are set as default
946 946
 				// if payment method is already selected OR nothing is selected and this payment method should be open_by_default
947 947
 				if (
948
-					( $this->checkout->selected_method_of_payment === $payment_method->slug() )
949
-					|| ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default() )
948
+					($this->checkout->selected_method_of_payment === $payment_method->slug())
949
+					|| ( ! $this->checkout->selected_method_of_payment && $payment_method->open_by_default())
950 950
 				) {
951 951
 					$this->checkout->selected_method_of_payment = $payment_method->slug();
952 952
 					$this->_save_selected_method_of_payment();
953
-					$default_payment_method_option[ $payment_method->slug() ] = $payment_method_button;
953
+					$default_payment_method_option[$payment_method->slug()] = $payment_method_button;
954 954
 				} else {
955
-					$available_payment_method_options[ $payment_method->slug() ] = $payment_method_button;
955
+					$available_payment_method_options[$payment_method->slug()] = $payment_method_button;
956 956
 				}
957
-				$payment_methods_billing_info[ $payment_method->slug()
958
-				                               . '-info' ] = $this->_payment_method_billing_info(
957
+				$payment_methods_billing_info[$payment_method->slug()
958
+				                               . '-info'] = $this->_payment_method_billing_info(
959 959
 					$payment_method
960 960
 				);
961 961
 			}
@@ -985,12 +985,12 @@  discard block
 block discarded – undo
985 985
 	 * @return EE_Payment_Method[]
986 986
 	 */
987 987
 	protected function _get_available_payment_methods() {
988
-		if ( ! empty( $this->checkout->available_payment_methods ) ) {
988
+		if ( ! empty($this->checkout->available_payment_methods)) {
989 989
 			return $this->checkout->available_payment_methods;
990 990
 		}
991 991
 		$available_payment_methods = array();
992 992
 		// load EEM_Payment_Method
993
-		EE_Registry::instance()->load_model( 'Payment_Method' );
993
+		EE_Registry::instance()->load_model('Payment_Method');
994 994
 		/** @type EEM_Payment_Method $EEM_Payment_Method */
995 995
 		$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
996 996
 		// get all active payment methods
@@ -998,9 +998,9 @@  discard block
 block discarded – undo
998 998
 			$this->checkout->transaction,
999 999
 			EEM_Payment_Method::scope_cart
1000 1000
 		);
1001
-		foreach ( $payment_methods as $payment_method ) {
1002
-			if ( $payment_method instanceof EE_Payment_Method ) {
1003
-				$available_payment_methods[ $payment_method->slug() ] = $payment_method;
1001
+		foreach ($payment_methods as $payment_method) {
1002
+			if ($payment_method instanceof EE_Payment_Method) {
1003
+				$available_payment_methods[$payment_method->slug()] = $payment_method;
1004 1004
 			}
1005 1005
 		}
1006 1006
 		return $available_payment_methods;
@@ -1015,14 +1015,14 @@  discard block
 block discarded – undo
1015 1015
 	 * @param    array $available_payment_method_options
1016 1016
 	 * @return    \EE_Form_Section_Proper
1017 1017
 	 */
1018
-	private function _available_payment_method_inputs( $available_payment_method_options = array() ) {
1018
+	private function _available_payment_method_inputs($available_payment_method_options = array()) {
1019 1019
 		// generate inputs
1020 1020
 		return new EE_Form_Section_Proper(
1021 1021
 			array(
1022 1022
 				'html_id'         => 'ee-available-payment-method-inputs',
1023 1023
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1024 1024
 				'subsections'     => array(
1025
-					'' => new EE_Radio_Button_Input (
1025
+					'' => new EE_Radio_Button_Input(
1026 1026
 						$available_payment_method_options,
1027 1027
 						array(
1028 1028
 							'html_name'          => 'selected_method_of_payment',
@@ -1047,28 +1047,28 @@  discard block
 block discarded – undo
1047 1047
 	 * @return    \EE_Form_Section_Proper
1048 1048
 	 * @throws \EE_Error
1049 1049
 	 */
1050
-	private function _payment_method_billing_info( EE_Payment_Method $payment_method ) {
1050
+	private function _payment_method_billing_info(EE_Payment_Method $payment_method) {
1051 1051
 		$currently_selected = $this->checkout->selected_method_of_payment === $payment_method->slug()
1052 1052
 			? true
1053 1053
 			: false;
1054 1054
 		// generate the billing form for payment method
1055 1055
 		$billing_form = $currently_selected
1056
-			? $this->_get_billing_form_for_payment_method( $payment_method )
1056
+			? $this->_get_billing_form_for_payment_method($payment_method)
1057 1057
 			: new EE_Form_Section_HTML();
1058 1058
 		$this->checkout->billing_form = $currently_selected
1059 1059
 			? $billing_form
1060 1060
 			: $this->checkout->billing_form;
1061 1061
 		// it's all in the details
1062 1062
 		$info_html = EEH_HTML::h3(
1063
-			__( 'Important information regarding your payment', 'event_espresso' ),
1063
+			__('Important information regarding your payment', 'event_espresso'),
1064 1064
 			'',
1065 1065
 			'spco-payment-method-hdr'
1066 1066
 		);
1067 1067
 		// add some info regarding the step, either from what's saved in the admin,
1068 1068
 		// or a default string depending on whether the PM has a billing form or not
1069
-		if ( $payment_method->description() ) {
1069
+		if ($payment_method->description()) {
1070 1070
 			$payment_method_info = $payment_method->description();
1071
-		} elseif ( $billing_form instanceof EE_Billing_Info_Form ) {
1071
+		} elseif ($billing_form instanceof EE_Billing_Info_Form) {
1072 1072
 			$payment_method_info = sprintf(
1073 1073
 				__(
1074 1074
 					'Please provide the following billing information, then click the "%1$s" button below in order to proceed.',
@@ -1078,7 +1078,7 @@  discard block
 block discarded – undo
1078 1078
 			);
1079 1079
 		} else {
1080 1080
 			$payment_method_info = sprintf(
1081
-				__( 'Please click the "%1$s" button below in order to proceed.', 'event_espresso' ),
1081
+				__('Please click the "%1$s" button below in order to proceed.', 'event_espresso'),
1082 1082
 				$this->submit_button_text()
1083 1083
 			);
1084 1084
 		}
@@ -1092,13 +1092,13 @@  discard block
 block discarded – undo
1092 1092
 		);
1093 1093
 		return new EE_Form_Section_Proper(
1094 1094
 			array(
1095
-				'html_id'         => 'spco-payment-method-info-' . $payment_method->slug(),
1095
+				'html_id'         => 'spco-payment-method-info-'.$payment_method->slug(),
1096 1096
 				'html_class'      => 'spco-payment-method-info-dv',
1097 1097
 				// only display the selected or default PM
1098 1098
 				'html_style'      => $currently_selected ? '' : 'display:none;',
1099 1099
 				'layout_strategy' => new EE_Div_Per_Section_Layout(),
1100 1100
 				'subsections'     => array(
1101
-					'info'         => new EE_Form_Section_HTML( $info_html ),
1101
+					'info'         => new EE_Form_Section_HTML($info_html),
1102 1102
 					'billing_form' => $currently_selected ? $billing_form : new EE_Form_Section_HTML()
1103 1103
 				)
1104 1104
 			)
@@ -1116,15 +1116,15 @@  discard block
 block discarded – undo
1116 1116
 	 */
1117 1117
 	public function get_billing_form_html_for_payment_method() {
1118 1118
 		// how have they chosen to pay?
1119
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1119
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1120 1120
 		$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1121
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
1121
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1122 1122
 			return false;
1123 1123
 		}
1124
-		if ( apply_filters(
1124
+		if (apply_filters(
1125 1125
 			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1126 1126
 			false
1127
-		) ) {
1127
+		)) {
1128 1128
 			EE_Error::add_success(
1129 1129
 				apply_filters(
1130 1130
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 			);
1140 1140
 		}
1141 1141
 		// now generate billing form for selected method of payment
1142
-		$payment_method_billing_form = $this->_get_billing_form_for_payment_method( $this->checkout->payment_method );
1142
+		$payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
1143 1143
 		// fill form with attendee info if applicable
1144 1144
 		if (
1145 1145
 			$payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form
@@ -1161,10 +1161,10 @@  discard block
 block discarded – undo
1161 1161
 		$billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper
1162 1162
 			? $payment_method_billing_form->get_html()
1163 1163
 			: '';
1164
-		$this->checkout->json_response->set_return_data( array( 'payment_method_info' => $billing_info ) );
1164
+		$this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
1165 1165
 		// localize validation rules for main form
1166 1166
 		$this->checkout->current_step->reg_form->localize_validation_rules();
1167
-		$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
1167
+		$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1168 1168
 		return true;
1169 1169
 	}
1170 1170
 
@@ -1178,18 +1178,18 @@  discard block
 block discarded – undo
1178 1178
 	 * @return \EE_Billing_Info_Form|\EE_Form_Section_HTML
1179 1179
 	 * @throws \EE_Error
1180 1180
 	 */
1181
-	private function _get_billing_form_for_payment_method( EE_Payment_Method $payment_method ) {
1181
+	private function _get_billing_form_for_payment_method(EE_Payment_Method $payment_method) {
1182 1182
 		$billing_form = $payment_method->type_obj()->billing_form(
1183 1183
 			$this->checkout->transaction,
1184
-			array( 'amount_owing' => $this->checkout->amount_owing )
1184
+			array('amount_owing' => $this->checkout->amount_owing)
1185 1185
 		);
1186
-		if ( $billing_form instanceof EE_Billing_Info_Form ) {
1186
+		if ($billing_form instanceof EE_Billing_Info_Form) {
1187 1187
 			if (
1188 1188
 				apply_filters(
1189 1189
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1190 1190
 					false
1191 1191
 				)
1192
-				&& EE_Registry::instance()->REQ->is_set( 'payment_method' )
1192
+				&& EE_Registry::instance()->REQ->is_set('payment_method')
1193 1193
 			) {
1194 1194
 				EE_Error::add_success(
1195 1195
 					apply_filters(
@@ -1231,15 +1231,15 @@  discard block
 block discarded – undo
1231 1231
 		$request_param = 'selected_method_of_payment'
1232 1232
 	) {
1233 1233
 		// is selected_method_of_payment set in the request ?
1234
-		$selected_method_of_payment = EE_Registry::instance()->REQ->get( $request_param, false );
1235
-		if ( $selected_method_of_payment ) {
1234
+		$selected_method_of_payment = EE_Registry::instance()->REQ->get($request_param, false);
1235
+		if ($selected_method_of_payment) {
1236 1236
 			// sanitize it
1237
-			$selected_method_of_payment = is_array( $selected_method_of_payment )
1238
-				? array_shift( $selected_method_of_payment )
1237
+			$selected_method_of_payment = is_array($selected_method_of_payment)
1238
+				? array_shift($selected_method_of_payment)
1239 1239
 				: $selected_method_of_payment;
1240
-			$selected_method_of_payment = sanitize_text_field( $selected_method_of_payment );
1240
+			$selected_method_of_payment = sanitize_text_field($selected_method_of_payment);
1241 1241
 			// store it in the session so that it's available for all subsequent requests including AJAX
1242
-			$this->_save_selected_method_of_payment( $selected_method_of_payment );
1242
+			$this->_save_selected_method_of_payment($selected_method_of_payment);
1243 1243
 		} else {
1244 1244
 			// or is is set in the session ?
1245 1245
 			$selected_method_of_payment = EE_Registry::instance()->SSN->get_session_data(
@@ -1247,7 +1247,7 @@  discard block
 block discarded – undo
1247 1247
 			);
1248 1248
 		}
1249 1249
 		// do ya really really gotta have it?
1250
-		if ( empty( $selected_method_of_payment ) && $required ) {
1250
+		if (empty($selected_method_of_payment) && $required) {
1251 1251
 			EE_Error::add_error(
1252 1252
 				sprintf(
1253 1253
 					__(
@@ -1256,7 +1256,7 @@  discard block
 block discarded – undo
1256 1256
 					),
1257 1257
 					'<br/>',
1258 1258
 					'<br/>',
1259
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1259
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1260 1260
 				),
1261 1261
 				__FILE__,
1262 1262
 				__FUNCTION__,
@@ -1283,13 +1283,13 @@  discard block
 block discarded – undo
1283 1283
 	 * @throws \EE_Error
1284 1284
 	 */
1285 1285
 	public function switch_payment_method() {
1286
-		if ( ! $this->_verify_payment_method_is_set() ) {
1286
+		if ( ! $this->_verify_payment_method_is_set()) {
1287 1287
 			return false;
1288 1288
 		}
1289
-		if ( apply_filters(
1289
+		if (apply_filters(
1290 1290
 			'FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success',
1291 1291
 			false
1292
-		) ) {
1292
+		)) {
1293 1293
 			EE_Error::add_success(
1294 1294
 				apply_filters(
1295 1295
 					'FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method',
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 			);
1305 1305
 		}
1306 1306
 		// generate billing form for selected method of payment if it hasn't been done already
1307
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1307
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1308 1308
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1309 1309
 				$this->checkout->payment_method
1310 1310
 			);
@@ -1326,7 +1326,7 @@  discard block
 block discarded – undo
1326 1326
 			);
1327 1327
 		}
1328 1328
 		// and debug content
1329
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form
1329
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form
1330 1330
 		     && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base
1331 1331
 		) {
1332 1332
 			$this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings(
@@ -1334,15 +1334,15 @@  discard block
 block discarded – undo
1334 1334
 			);
1335 1335
 		}
1336 1336
 		// get html and validation rules for form
1337
-		if ( $this->checkout->billing_form instanceof EE_Form_Section_Proper ) {
1337
+		if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
1338 1338
 			$this->checkout->json_response->set_return_data(
1339
-				array( 'payment_method_info' => $this->checkout->billing_form->get_html() )
1339
+				array('payment_method_info' => $this->checkout->billing_form->get_html())
1340 1340
 			);
1341 1341
 			// localize validation rules for main form
1342
-			$this->checkout->billing_form->localize_validation_rules( true );
1343
-			$this->checkout->json_response->add_validation_rules( EE_Form_Section_Proper::js_localization() );
1342
+			$this->checkout->billing_form->localize_validation_rules(true);
1343
+			$this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
1344 1344
 		} else {
1345
-			$this->checkout->json_response->set_return_data( array( 'payment_method_info' => '' ) );
1345
+			$this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
1346 1346
 		}
1347 1347
 		//prevents advancement to next step
1348 1348
 		$this->checkout->continue_reg = false;
@@ -1359,12 +1359,12 @@  discard block
 block discarded – undo
1359 1359
 	 */
1360 1360
 	protected function _verify_payment_method_is_set() {
1361 1361
 		// generate billing form for selected method of payment if it hasn't been done already
1362
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1362
+		if (empty($this->checkout->selected_method_of_payment)) {
1363 1363
 			// how have they chosen to pay?
1364
-			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
1364
+			$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
1365 1365
 		}
1366 1366
 		// verify payment method
1367
-		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method ) {
1367
+		if ( ! $this->checkout->payment_method instanceof EE_Payment_Method) {
1368 1368
 			// get payment method for selected method of payment
1369 1369
 			$this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
1370 1370
 		}
@@ -1383,25 +1383,25 @@  discard block
 block discarded – undo
1383 1383
 	 * @throws \EE_Error
1384 1384
 	 */
1385 1385
 	public function save_payer_details_via_ajax() {
1386
-		if ( ! $this->_verify_payment_method_is_set() ) {
1386
+		if ( ! $this->_verify_payment_method_is_set()) {
1387 1387
 			return;
1388 1388
 		}
1389 1389
 		// generate billing form for selected method of payment if it hasn't been done already
1390
-		if ( $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1390
+		if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
1391 1391
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1392 1392
 				$this->checkout->payment_method
1393 1393
 			);
1394 1394
 		}
1395 1395
 		// generate primary attendee from payer info if applicable
1396
-		if ( ! $this->checkout->transaction_has_primary_registrant() ) {
1396
+		if ( ! $this->checkout->transaction_has_primary_registrant()) {
1397 1397
 			$attendee = $this->_create_attendee_from_request_data();
1398
-			if ( $attendee instanceof EE_Attendee ) {
1399
-				foreach ( $this->checkout->transaction->registrations() as $registration ) {
1400
-					if ( $registration->is_primary_registrant() ) {
1398
+			if ($attendee instanceof EE_Attendee) {
1399
+				foreach ($this->checkout->transaction->registrations() as $registration) {
1400
+					if ($registration->is_primary_registrant()) {
1401 1401
 						$this->checkout->primary_attendee_obj = $attendee;
1402
-						$registration->_add_relation_to( $attendee, 'Attendee' );
1403
-						$registration->set_attendee_id( $attendee->ID() );
1404
-						$registration->update_cache_after_object_save( 'Attendee', $attendee );
1402
+						$registration->_add_relation_to($attendee, 'Attendee');
1403
+						$registration->set_attendee_id($attendee->ID());
1404
+						$registration->update_cache_after_object_save('Attendee', $attendee);
1405 1405
 					}
1406 1406
 				}
1407 1407
 			}
@@ -1419,50 +1419,50 @@  discard block
 block discarded – undo
1419 1419
 	 */
1420 1420
 	protected function _create_attendee_from_request_data() {
1421 1421
 		// get State ID
1422
-		$STA_ID = ! empty( $_REQUEST['state'] ) ? sanitize_text_field( $_REQUEST['state'] ) : '';
1423
-		if ( ! empty( $STA_ID ) ) {
1422
+		$STA_ID = ! empty($_REQUEST['state']) ? sanitize_text_field($_REQUEST['state']) : '';
1423
+		if ( ! empty($STA_ID)) {
1424 1424
 			// can we get state object from name ?
1425
-			EE_Registry::instance()->load_model( 'State' );
1426
-			$state = EEM_State::instance()->get_col( array( array( 'STA_name' => $STA_ID ), 'limit' => 1 ), 'STA_ID' );
1427
-			$STA_ID = is_array( $state ) && ! empty( $state ) ? reset( $state ) : $STA_ID;
1425
+			EE_Registry::instance()->load_model('State');
1426
+			$state = EEM_State::instance()->get_col(array(array('STA_name' => $STA_ID), 'limit' => 1), 'STA_ID');
1427
+			$STA_ID = is_array($state) && ! empty($state) ? reset($state) : $STA_ID;
1428 1428
 		}
1429 1429
 		// get Country ISO
1430
-		$CNT_ISO = ! empty( $_REQUEST['country'] ) ? sanitize_text_field( $_REQUEST['country'] ) : '';
1431
-		if ( ! empty( $CNT_ISO ) ) {
1430
+		$CNT_ISO = ! empty($_REQUEST['country']) ? sanitize_text_field($_REQUEST['country']) : '';
1431
+		if ( ! empty($CNT_ISO)) {
1432 1432
 			// can we get country object from name ?
1433
-			EE_Registry::instance()->load_model( 'Country' );
1433
+			EE_Registry::instance()->load_model('Country');
1434 1434
 			$country = EEM_Country::instance()->get_col(
1435
-				array( array( 'CNT_name' => $CNT_ISO ), 'limit' => 1 ),
1435
+				array(array('CNT_name' => $CNT_ISO), 'limit' => 1),
1436 1436
 				'CNT_ISO'
1437 1437
 			);
1438
-			$CNT_ISO = is_array( $country ) && ! empty( $country ) ? reset( $country ) : $CNT_ISO;
1438
+			$CNT_ISO = is_array($country) && ! empty($country) ? reset($country) : $CNT_ISO;
1439 1439
 		}
1440 1440
 		// grab attendee data
1441 1441
 		$attendee_data = array(
1442
-			'ATT_fname'    => ! empty( $_REQUEST['first_name'] ) ? sanitize_text_field( $_REQUEST['first_name'] ) : '',
1443
-			'ATT_lname'    => ! empty( $_REQUEST['last_name'] ) ? sanitize_text_field( $_REQUEST['last_name'] ) : '',
1444
-			'ATT_email'    => ! empty( $_REQUEST['email'] ) ? sanitize_email( $_REQUEST['email'] ) : '',
1445
-			'ATT_address'  => ! empty( $_REQUEST['address'] ) ? sanitize_text_field( $_REQUEST['address'] ) : '',
1446
-			'ATT_address2' => ! empty( $_REQUEST['address2'] ) ? sanitize_text_field( $_REQUEST['address2'] ) : '',
1447
-			'ATT_city'     => ! empty( $_REQUEST['city'] ) ? sanitize_text_field( $_REQUEST['city'] ) : '',
1442
+			'ATT_fname'    => ! empty($_REQUEST['first_name']) ? sanitize_text_field($_REQUEST['first_name']) : '',
1443
+			'ATT_lname'    => ! empty($_REQUEST['last_name']) ? sanitize_text_field($_REQUEST['last_name']) : '',
1444
+			'ATT_email'    => ! empty($_REQUEST['email']) ? sanitize_email($_REQUEST['email']) : '',
1445
+			'ATT_address'  => ! empty($_REQUEST['address']) ? sanitize_text_field($_REQUEST['address']) : '',
1446
+			'ATT_address2' => ! empty($_REQUEST['address2']) ? sanitize_text_field($_REQUEST['address2']) : '',
1447
+			'ATT_city'     => ! empty($_REQUEST['city']) ? sanitize_text_field($_REQUEST['city']) : '',
1448 1448
 			'STA_ID'       => $STA_ID,
1449 1449
 			'CNT_ISO'      => $CNT_ISO,
1450
-			'ATT_zip'      => ! empty( $_REQUEST['zip'] ) ? sanitize_text_field( $_REQUEST['zip'] ) : '',
1451
-			'ATT_phone'    => ! empty( $_REQUEST['phone'] ) ? sanitize_text_field( $_REQUEST['phone'] ) : '',
1450
+			'ATT_zip'      => ! empty($_REQUEST['zip']) ? sanitize_text_field($_REQUEST['zip']) : '',
1451
+			'ATT_phone'    => ! empty($_REQUEST['phone']) ? sanitize_text_field($_REQUEST['phone']) : '',
1452 1452
 		);
1453 1453
 		// validate the email address since it is the most important piece of info
1454
-		if ( empty( $attendee_data['ATT_email'] ) || $attendee_data['ATT_email'] !== $_REQUEST['email'] ) {
1454
+		if (empty($attendee_data['ATT_email']) || $attendee_data['ATT_email'] !== $_REQUEST['email']) {
1455 1455
 			EE_Error::add_error(
1456
-				__( 'An invalid email address was submitted.', 'event_espresso' ),
1456
+				__('An invalid email address was submitted.', 'event_espresso'),
1457 1457
 				__FILE__,
1458 1458
 				__FUNCTION__,
1459 1459
 				__LINE__
1460 1460
 			);
1461 1461
 		}
1462 1462
 		// does this attendee already exist in the db ? we're searching using a combination of first name, last name, AND email address
1463
-		if ( ! empty( $attendee_data['ATT_fname'] )
1464
-		     && ! empty( $attendee_data['ATT_lname'] )
1465
-		     && ! empty( $attendee_data['ATT_email'] )
1463
+		if ( ! empty($attendee_data['ATT_fname'])
1464
+		     && ! empty($attendee_data['ATT_lname'])
1465
+		     && ! empty($attendee_data['ATT_email'])
1466 1466
 		) {
1467 1467
 			$existing_attendee = EE_Registry::instance()->LIB->EEM_Attendee->find_existing_attendee(
1468 1468
 				array(
@@ -1471,19 +1471,19 @@  discard block
 block discarded – undo
1471 1471
 					'ATT_email' => $attendee_data['ATT_email']
1472 1472
 				)
1473 1473
 			);
1474
-			if ( $existing_attendee instanceof EE_Attendee ) {
1474
+			if ($existing_attendee instanceof EE_Attendee) {
1475 1475
 				return $existing_attendee;
1476 1476
 			}
1477 1477
 		}
1478 1478
 		// no existing attendee? kk let's create a new one
1479 1479
 		// kinda lame, but we need a first and last name to create an attendee, so use the email address if those don't exist
1480
-		$attendee_data['ATT_fname'] = ! empty( $attendee_data['ATT_fname'] )
1480
+		$attendee_data['ATT_fname'] = ! empty($attendee_data['ATT_fname'])
1481 1481
 			? $attendee_data['ATT_fname']
1482 1482
 			: $attendee_data['ATT_email'];
1483
-		$attendee_data['ATT_lname'] = ! empty( $attendee_data['ATT_lname'] )
1483
+		$attendee_data['ATT_lname'] = ! empty($attendee_data['ATT_lname'])
1484 1484
 			? $attendee_data['ATT_lname']
1485 1485
 			: $attendee_data['ATT_email'];
1486
-		return EE_Attendee::new_instance( $attendee_data );
1486
+		return EE_Attendee::new_instance($attendee_data);
1487 1487
 	}
1488 1488
 
1489 1489
 
@@ -1501,26 +1501,26 @@  discard block
 block discarded – undo
1501 1501
 		// how have they chosen to pay?
1502 1502
 		$this->checkout->selected_method_of_payment = $this->checkout->transaction->is_free()
1503 1503
 			? 'no_payment_required'
1504
-			: $this->_get_selected_method_of_payment( true );
1504
+			: $this->_get_selected_method_of_payment(true);
1505 1505
 		// choose your own adventure based on method_of_payment
1506
-		switch ( $this->checkout->selected_method_of_payment ) {
1506
+		switch ($this->checkout->selected_method_of_payment) {
1507 1507
 
1508 1508
 			case 'events_sold_out' :
1509 1509
 				$this->checkout->redirect = true;
1510 1510
 				$this->checkout->redirect_url = $this->checkout->cancel_page_url;
1511
-				$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1511
+				$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1512 1512
 				// mark this reg step as completed
1513 1513
 				$this->set_completed();
1514 1514
 				return false;
1515 1515
 				break;
1516 1516
 
1517 1517
 			case 'payments_closed' :
1518
-				if ( apply_filters(
1518
+				if (apply_filters(
1519 1519
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__payments_closed__display_success',
1520 1520
 					false
1521
-				) ) {
1521
+				)) {
1522 1522
 					EE_Error::add_success(
1523
-						__( 'no payment required at this time.', 'event_espresso' ),
1523
+						__('no payment required at this time.', 'event_espresso'),
1524 1524
 						__FILE__,
1525 1525
 						__FUNCTION__,
1526 1526
 						__LINE__
@@ -1532,12 +1532,12 @@  discard block
 block discarded – undo
1532 1532
 				break;
1533 1533
 
1534 1534
 			case 'no_payment_required' :
1535
-				if ( apply_filters(
1535
+				if (apply_filters(
1536 1536
 					'FHEE__EE_SPCO_Reg_Step_Payment_Options__process_reg_step__no_payment_required__display_success',
1537 1537
 					false
1538
-				) ) {
1538
+				)) {
1539 1539
 					EE_Error::add_success(
1540
-						__( 'no payment required.', 'event_espresso' ),
1540
+						__('no payment required.', 'event_espresso'),
1541 1541
 						__FILE__,
1542 1542
 						__FUNCTION__,
1543 1543
 						__LINE__
@@ -1557,15 +1557,15 @@  discard block
 block discarded – undo
1557 1557
 					EE_Registry::instance()->SSN->checkout()->revisit
1558 1558
 				);
1559 1559
 				// calculate difference between the two arrays
1560
-				$registrations = array_diff( $registrations, $ejected_registrations );
1561
-				if ( empty( $registrations ) ) {
1560
+				$registrations = array_diff($registrations, $ejected_registrations);
1561
+				if (empty($registrations)) {
1562 1562
 					$this->_redirect_because_event_sold_out();
1563 1563
 					return false;
1564 1564
 				}
1565 1565
 				$payment_successful = $this->_process_payment();
1566
-				if ( $payment_successful ) {
1566
+				if ($payment_successful) {
1567 1567
 					$this->checkout->continue_reg = true;
1568
-					$this->_maybe_set_completed( $this->checkout->payment_method );
1568
+					$this->_maybe_set_completed($this->checkout->payment_method);
1569 1569
 				} else {
1570 1570
 					$this->checkout->continue_reg = false;
1571 1571
 				}
@@ -1586,10 +1586,10 @@  discard block
 block discarded – undo
1586 1586
 		$this->checkout->continue_reg = false;
1587 1587
 		// set redirect URL
1588 1588
 		$this->checkout->redirect_url = add_query_arg(
1589
-			array( 'e_reg_url_link' => $this->checkout->reg_url_link ),
1589
+			array('e_reg_url_link' => $this->checkout->reg_url_link),
1590 1590
 			$this->checkout->current_step->reg_step_url()
1591 1591
 		);
1592
-		$this->checkout->json_response->set_redirect_url( $this->checkout->redirect_url );
1592
+		$this->checkout->json_response->set_redirect_url($this->checkout->redirect_url);
1593 1593
 	}
1594 1594
 
1595 1595
 
@@ -1602,8 +1602,8 @@  discard block
 block discarded – undo
1602 1602
 	 * @return void
1603 1603
 	 * @throws \EE_Error
1604 1604
 	 */
1605
-	protected function _maybe_set_completed( EE_Payment_Method $payment_method ) {
1606
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
1605
+	protected function _maybe_set_completed(EE_Payment_Method $payment_method) {
1606
+		switch ($payment_method->type_obj()->payment_occurs()) {
1607 1607
 			case EE_PMT_Base::offsite :
1608 1608
 				break;
1609 1609
 			case EE_PMT_Base::onsite :
@@ -1626,7 +1626,7 @@  discard block
 block discarded – undo
1626 1626
 	public function update_reg_step() {
1627 1627
 		$success = true;
1628 1628
 		// if payment required
1629
-		if ( $this->checkout->transaction->total() > 0 ) {
1629
+		if ($this->checkout->transaction->total() > 0) {
1630 1630
 			do_action(
1631 1631
 				'AHEE__EE_Single_Page_Checkout__process_finalize_registration__before_gateway',
1632 1632
 				$this->checkout->transaction
@@ -1634,13 +1634,13 @@  discard block
 block discarded – undo
1634 1634
 			// attempt payment via payment method
1635 1635
 			$success = $this->process_reg_step();
1636 1636
 		}
1637
-		if ( $success && ! $this->checkout->redirect ) {
1637
+		if ($success && ! $this->checkout->redirect) {
1638 1638
 			$this->checkout->cart->get_grand_total()->save_this_and_descendants_to_txn(
1639 1639
 				$this->checkout->transaction->ID()
1640 1640
 			);
1641 1641
 			// set return URL
1642 1642
 			$this->checkout->redirect_url = add_query_arg(
1643
-				array( 'e_reg_url_link' => $this->checkout->reg_url_link ),
1643
+				array('e_reg_url_link' => $this->checkout->reg_url_link),
1644 1644
 				$this->checkout->thank_you_page_url
1645 1645
 			);
1646 1646
 		}
@@ -1660,28 +1660,28 @@  discard block
 block discarded – undo
1660 1660
 		// clear any previous errors related to not selecting a payment method
1661 1661
 //		EE_Error::overwrite_errors();
1662 1662
 		// ya gotta make a choice man
1663
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
1663
+		if (empty($this->checkout->selected_method_of_payment)) {
1664 1664
 			$this->checkout->json_response->set_plz_select_method_of_payment(
1665
-				__( 'Please select a method of payment before proceeding.', 'event_espresso' )
1665
+				__('Please select a method of payment before proceeding.', 'event_espresso')
1666 1666
 			);
1667 1667
 			return false;
1668 1668
 		}
1669 1669
 		// get EE_Payment_Method object
1670
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
1670
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
1671 1671
 			return false;
1672 1672
 		}
1673 1673
 		// setup billing form
1674
-		if ( $this->checkout->payment_method->is_on_site() ) {
1674
+		if ($this->checkout->payment_method->is_on_site()) {
1675 1675
 			$this->checkout->billing_form = $this->_get_billing_form_for_payment_method(
1676 1676
 				$this->checkout->payment_method
1677 1677
 			);
1678 1678
 			// bad billing form ?
1679
-			if ( ! $this->_billing_form_is_valid() ) {
1679
+			if ( ! $this->_billing_form_is_valid()) {
1680 1680
 				return false;
1681 1681
 			}
1682 1682
 		}
1683 1683
 		// ensure primary registrant has been fully processed
1684
-		if ( ! $this->_setup_primary_registrant_prior_to_payment() ) {
1684
+		if ( ! $this->_setup_primary_registrant_prior_to_payment()) {
1685 1685
 			return false;
1686 1686
 		}
1687 1687
 		/** @type EE_Transaction_Processor $transaction_processor */
@@ -1689,12 +1689,12 @@  discard block
 block discarded – undo
1689 1689
 		// in case a registrant leaves to an Off-Site Gateway and never returns, we want to approve any registrations for events with a default reg status of Approved
1690 1690
 		//$transaction_processor->toggle_registration_statuses_for_default_approved_events( $this->checkout->transaction, $this->checkout->reg_cache_where_params );
1691 1691
 		// attempt payment
1692
-		$payment = $this->_attempt_payment( $this->checkout->payment_method );
1692
+		$payment = $this->_attempt_payment($this->checkout->payment_method);
1693 1693
 		// process results
1694
-		$payment = $this->_validate_payment( $payment );
1695
-		$payment = $this->_post_payment_processing( $payment );
1694
+		$payment = $this->_validate_payment($payment);
1695
+		$payment = $this->_post_payment_processing($payment);
1696 1696
 		// verify payment
1697
-		if ( $payment instanceof EE_Payment ) {
1697
+		if ($payment instanceof EE_Payment) {
1698 1698
 			// store that for later
1699 1699
 			$this->checkout->payment = $payment;
1700 1700
 			// we can also consider the TXN to not have been failed, so temporarily upgrade it's status to abandoned
@@ -1708,7 +1708,7 @@  discard block
 block discarded – undo
1708 1708
 			} else {
1709 1709
 				return false;
1710 1710
 			}
1711
-		} else if ( $payment === true ) {
1711
+		} else if ($payment === true) {
1712 1712
 			// please note that offline payment methods will NOT make a payment,
1713 1713
 			// but instead just mark themselves as the PMD_ID on the transaction, and return true
1714 1714
 			$this->checkout->payment = $payment;
@@ -1733,7 +1733,7 @@  discard block
 block discarded – undo
1733 1733
 		);
1734 1734
 		$html = $payment_method_billing_info->get_html();
1735 1735
 		$html .= $this->checkout->redirect_form;
1736
-		EE_Registry::instance()->REQ->add_output( $html );
1736
+		EE_Registry::instance()->REQ->add_output($html);
1737 1737
 		return true;
1738 1738
 	}
1739 1739
 
@@ -1747,28 +1747,28 @@  discard block
 block discarded – undo
1747 1747
 	 * @throws \EE_Error
1748 1748
 	 */
1749 1749
 	private function _billing_form_is_valid() {
1750
-		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form() ) {
1750
+		if ( ! $this->checkout->payment_method->type_obj()->has_billing_form()) {
1751 1751
 			return true;
1752 1752
 		}
1753
-		if ( $this->checkout->billing_form instanceof EE_Billing_Info_Form ) {
1754
-			if ( $this->checkout->billing_form->was_submitted() ) {
1753
+		if ($this->checkout->billing_form instanceof EE_Billing_Info_Form) {
1754
+			if ($this->checkout->billing_form->was_submitted()) {
1755 1755
 				$this->checkout->billing_form->receive_form_submission();
1756
-				if ( $this->checkout->billing_form->is_valid() ) {
1756
+				if ($this->checkout->billing_form->is_valid()) {
1757 1757
 					return true;
1758 1758
 				}
1759 1759
 				$validation_errors = $this->checkout->billing_form->get_validation_errors_accumulated();
1760 1760
 				$error_strings = array();
1761
-				foreach ( $validation_errors as $validation_error ) {
1762
-					if ( $validation_error instanceof EE_Validation_Error ) {
1761
+				foreach ($validation_errors as $validation_error) {
1762
+					if ($validation_error instanceof EE_Validation_Error) {
1763 1763
 						$form_section = $validation_error->get_form_section();
1764
-						if ( $form_section instanceof EE_Form_Input_Base ) {
1764
+						if ($form_section instanceof EE_Form_Input_Base) {
1765 1765
 							$label = $form_section->html_label_text();
1766
-						} elseif ( $form_section instanceof EE_Form_Section_Base ) {
1766
+						} elseif ($form_section instanceof EE_Form_Section_Base) {
1767 1767
 							$label = $form_section->name();
1768 1768
 						} else {
1769
-							$label = __( 'Validation Error', 'event_espresso' );
1769
+							$label = __('Validation Error', 'event_espresso');
1770 1770
 						}
1771
-						$error_strings[] = sprintf( '%1$s: %2$s', $label, $validation_error->getMessage() );
1771
+						$error_strings[] = sprintf('%1$s: %2$s', $label, $validation_error->getMessage());
1772 1772
 					}
1773 1773
 				}
1774 1774
 				EE_Error::add_error(
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
 							'event_espresso'
1779 1779
 						),
1780 1780
 						'<br/>',
1781
-						implode( '<br/>', $error_strings )
1781
+						implode('<br/>', $error_strings)
1782 1782
 					),
1783 1783
 					__FILE__,
1784 1784
 					__FUNCTION__,
@@ -1797,7 +1797,7 @@  discard block
 block discarded – undo
1797 1797
 			}
1798 1798
 		} else {
1799 1799
 			EE_Error::add_error(
1800
-				__( 'The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso' ),
1800
+				__('The submitted billing form is invalid possibly due to a technical reason.', 'event_espresso'),
1801 1801
 				__FILE__,
1802 1802
 				__FUNCTION__,
1803 1803
 				__LINE__
@@ -1836,7 +1836,7 @@  discard block
 block discarded – undo
1836 1836
 		// save the TXN ( which clears cached copy of primary_registration)
1837 1837
 		$this->checkout->transaction->save();
1838 1838
 		// grab TXN ID and save it to the primary_registration
1839
-		$primary_registration->set_transaction_id( $this->checkout->transaction->ID() );
1839
+		$primary_registration->set_transaction_id($this->checkout->transaction->ID());
1840 1840
 		// save what we have so far
1841 1841
 		$primary_registration->save();
1842 1842
 		return true;
@@ -1854,7 +1854,7 @@  discard block
 block discarded – undo
1854 1854
 	private function _capture_primary_registration_data_from_billing_form() {
1855 1855
 		// convert billing form data into an attendee
1856 1856
 		$this->checkout->primary_attendee_obj = $this->checkout->billing_form->create_attendee_from_billing_form_data();
1857
-		if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee ) {
1857
+		if ( ! $this->checkout->primary_attendee_obj instanceof EE_Attendee) {
1858 1858
 			EE_Error::add_error(
1859 1859
 				sprintf(
1860 1860
 					__(
@@ -1862,7 +1862,7 @@  discard block
 block discarded – undo
1862 1862
 						'event_espresso'
1863 1863
 					),
1864 1864
 					'<br/>',
1865
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1865
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1866 1866
 				),
1867 1867
 				__FILE__,
1868 1868
 				__FUNCTION__,
@@ -1871,7 +1871,7 @@  discard block
 block discarded – undo
1871 1871
 			return false;
1872 1872
 		}
1873 1873
 		$primary_registration = $this->checkout->transaction->primary_registration();
1874
-		if ( ! $primary_registration instanceof EE_Registration ) {
1874
+		if ( ! $primary_registration instanceof EE_Registration) {
1875 1875
 			EE_Error::add_error(
1876 1876
 				sprintf(
1877 1877
 					__(
@@ -1879,7 +1879,7 @@  discard block
 block discarded – undo
1879 1879
 						'event_espresso'
1880 1880
 					),
1881 1881
 					'<br/>',
1882
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1882
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1883 1883
 				),
1884 1884
 				__FILE__,
1885 1885
 				__FUNCTION__,
@@ -1887,7 +1887,7 @@  discard block
 block discarded – undo
1887 1887
 			);
1888 1888
 			return false;
1889 1889
 		}
1890
-		if ( ! $primary_registration->_add_relation_to( $this->checkout->primary_attendee_obj, 'Attendee' )
1890
+		if ( ! $primary_registration->_add_relation_to($this->checkout->primary_attendee_obj, 'Attendee')
1891 1891
 		       instanceof
1892 1892
 		       EE_Attendee
1893 1893
 		) {
@@ -1898,7 +1898,7 @@  discard block
 block discarded – undo
1898 1898
 						'event_espresso'
1899 1899
 					),
1900 1900
 					'<br/>',
1901
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1901
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1902 1902
 				),
1903 1903
 				__FILE__,
1904 1904
 				__FUNCTION__,
@@ -1907,9 +1907,9 @@  discard block
 block discarded – undo
1907 1907
 			return false;
1908 1908
 		}
1909 1909
 		/** @type EE_Registration_Processor $registration_processor */
1910
-		$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
1910
+		$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
1911 1911
 		// at this point, we should have enough details about the registrant to consider the registration NOT incomplete
1912
-		$registration_processor->toggle_incomplete_registration_status_to_default( $primary_registration );
1912
+		$registration_processor->toggle_incomplete_registration_status_to_default($primary_registration);
1913 1913
 		return true;
1914 1914
 	}
1915 1915
 
@@ -1924,22 +1924,22 @@  discard block
 block discarded – undo
1924 1924
 	 * @throws \EE_Error
1925 1925
 	 */
1926 1926
 	private function _get_payment_method_for_selected_method_of_payment() {
1927
-		if ( $this->checkout->selected_method_of_payment === 'events_sold_out' ) {
1927
+		if ($this->checkout->selected_method_of_payment === 'events_sold_out') {
1928 1928
 			$this->_redirect_because_event_sold_out();
1929 1929
 			return null;
1930 1930
 		}
1931 1931
 		// get EE_Payment_Method object
1932
-		if ( isset( $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ] ) ) {
1933
-			$payment_method = $this->checkout->available_payment_methods[ $this->checkout->selected_method_of_payment ];
1932
+		if (isset($this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment])) {
1933
+			$payment_method = $this->checkout->available_payment_methods[$this->checkout->selected_method_of_payment];
1934 1934
 		} else {
1935 1935
 			// load EEM_Payment_Method
1936
-			EE_Registry::instance()->load_model( 'Payment_Method' );
1936
+			EE_Registry::instance()->load_model('Payment_Method');
1937 1937
 			/** @type EEM_Payment_Method $EEM_Payment_Method */
1938 1938
 			$EEM_Payment_Method = EE_Registry::instance()->LIB->EEM_Payment_Method;
1939
-			$payment_method = $EEM_Payment_Method->get_one_by_slug( $this->checkout->selected_method_of_payment );
1939
+			$payment_method = $EEM_Payment_Method->get_one_by_slug($this->checkout->selected_method_of_payment);
1940 1940
 		}
1941 1941
 		// verify $payment_method
1942
-		if ( ! $payment_method instanceof EE_Payment_Method ) {
1942
+		if ( ! $payment_method instanceof EE_Payment_Method) {
1943 1943
 			// not a payment
1944 1944
 			EE_Error::add_error(
1945 1945
 				sprintf(
@@ -1948,7 +1948,7 @@  discard block
 block discarded – undo
1948 1948
 						'event_espresso'
1949 1949
 					),
1950 1950
 					'<br/>',
1951
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1951
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1952 1952
 				),
1953 1953
 				__FILE__,
1954 1954
 				__FUNCTION__,
@@ -1957,7 +1957,7 @@  discard block
 block discarded – undo
1957 1957
 			return null;
1958 1958
 		}
1959 1959
 		// and verify it has a valid Payment_Method Type object
1960
-		if ( ! $payment_method->type_obj() instanceof EE_PMT_Base ) {
1960
+		if ( ! $payment_method->type_obj() instanceof EE_PMT_Base) {
1961 1961
 			// not a payment
1962 1962
 			EE_Error::add_error(
1963 1963
 				sprintf(
@@ -1966,7 +1966,7 @@  discard block
 block discarded – undo
1966 1966
 						'event_espresso'
1967 1967
 					),
1968 1968
 					'<br/>',
1969
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
1969
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
1970 1970
 				),
1971 1971
 				__FILE__,
1972 1972
 				__FUNCTION__,
@@ -1987,29 +1987,29 @@  discard block
 block discarded – undo
1987 1987
 	 * @return    mixed    EE_Payment | boolean
1988 1988
 	 * @throws \EE_Error
1989 1989
 	 */
1990
-	private function _attempt_payment( EE_Payment_Method $payment_method ) {
1990
+	private function _attempt_payment(EE_Payment_Method $payment_method) {
1991 1991
 		$payment = null;
1992 1992
 		$this->checkout->transaction->save();
1993
-		$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
1994
-		if ( ! $payment_processor instanceof EE_Payment_Processor ) {
1993
+		$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
1994
+		if ( ! $payment_processor instanceof EE_Payment_Processor) {
1995 1995
 			return false;
1996 1996
 		}
1997 1997
 		try {
1998
-			$payment_processor->set_revisit( $this->checkout->revisit );
1998
+			$payment_processor->set_revisit($this->checkout->revisit);
1999 1999
 			// generate payment object
2000 2000
 			$payment = $payment_processor->process_payment(
2001 2001
 				$payment_method,
2002 2002
 				$this->checkout->transaction,
2003 2003
 				$this->checkout->amount_owing,
2004 2004
 				$this->checkout->billing_form,
2005
-				$this->_get_return_url( $payment_method ),
2005
+				$this->_get_return_url($payment_method),
2006 2006
 				'CART',
2007 2007
 				$this->checkout->admin_request,
2008 2008
 				true,
2009 2009
 				$this->reg_step_url()
2010 2010
 			);
2011
-		} catch ( Exception $e ) {
2012
-			$this->_handle_payment_processor_exception( $e );
2011
+		} catch (Exception $e) {
2012
+			$this->_handle_payment_processor_exception($e);
2013 2013
 		}
2014 2014
 		return $payment;
2015 2015
 	}
@@ -2024,7 +2024,7 @@  discard block
 block discarded – undo
2024 2024
 	 * @return void
2025 2025
 	 * @throws \EE_Error
2026 2026
 	 */
2027
-	protected function _handle_payment_processor_exception( Exception $e ) {
2027
+	protected function _handle_payment_processor_exception(Exception $e) {
2028 2028
 		EE_Error::add_error(
2029 2029
 			sprintf(
2030 2030
 				__(
@@ -2032,7 +2032,7 @@  discard block
 block discarded – undo
2032 2032
 					'event_espresso'
2033 2033
 				),
2034 2034
 				'<br/>',
2035
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' ),
2035
+				EE_Registry::instance()->CFG->organization->get_pretty('email'),
2036 2036
 				$e->getMessage(),
2037 2037
 				$e->getFile(),
2038 2038
 				$e->getLine()
@@ -2053,9 +2053,9 @@  discard block
 block discarded – undo
2053 2053
 	 * @return string
2054 2054
 	 * @throws \EE_Error
2055 2055
 	 */
2056
-	protected function _get_return_url( EE_Payment_Method $payment_method ) {
2056
+	protected function _get_return_url(EE_Payment_Method $payment_method) {
2057 2057
 		$return_url = '';
2058
-		switch ( $payment_method->type_obj()->payment_occurs() ) {
2058
+		switch ($payment_method->type_obj()->payment_occurs()) {
2059 2059
 			case EE_PMT_Base::offsite :
2060 2060
 				$return_url = add_query_arg(
2061 2061
 					array(
@@ -2084,12 +2084,12 @@  discard block
 block discarded – undo
2084 2084
 	 * @return EE_Payment | FALSE
2085 2085
 	 * @throws \EE_Error
2086 2086
 	 */
2087
-	private function _validate_payment( $payment = null ) {
2088
-		if ( $this->checkout->payment_method->is_off_line() ) {
2087
+	private function _validate_payment($payment = null) {
2088
+		if ($this->checkout->payment_method->is_off_line()) {
2089 2089
 			return true;
2090 2090
 		}
2091 2091
 		// verify payment object
2092
-		if ( ! $payment instanceof EE_Payment ) {
2092
+		if ( ! $payment instanceof EE_Payment) {
2093 2093
 			// not a payment
2094 2094
 			EE_Error::add_error(
2095 2095
 				sprintf(
@@ -2098,7 +2098,7 @@  discard block
 block discarded – undo
2098 2098
 						'event_espresso'
2099 2099
 					),
2100 2100
 					'<br/>',
2101
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2101
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2102 2102
 				),
2103 2103
 				__FILE__,
2104 2104
 				__FUNCTION__,
@@ -2119,27 +2119,27 @@  discard block
 block discarded – undo
2119 2119
 	 * @return bool
2120 2120
 	 * @throws \EE_Error
2121 2121
 	 */
2122
-	private function _post_payment_processing( $payment = null ) {
2122
+	private function _post_payment_processing($payment = null) {
2123 2123
 		// Off-Line payment?
2124
-		if ( $payment === true ) {
2124
+		if ($payment === true) {
2125 2125
 			//$this->_setup_redirect_for_next_step();
2126 2126
 			return true;
2127 2127
 		// On-Site payment?
2128
-		} else if ( $this->checkout->payment_method->is_on_site() ) {
2129
-			if ( ! $this->_process_payment_status( $payment, EE_PMT_Base::onsite ) ) {
2128
+		} else if ($this->checkout->payment_method->is_on_site()) {
2129
+			if ( ! $this->_process_payment_status($payment, EE_PMT_Base::onsite)) {
2130 2130
 				//$this->_setup_redirect_for_next_step();
2131 2131
 				$this->checkout->continue_reg = false;
2132 2132
 			}
2133 2133
 		// Off-Site payment?
2134
-		} else if ( $this->checkout->payment_method->is_off_site() ) {
2134
+		} else if ($this->checkout->payment_method->is_off_site()) {
2135 2135
 			// if a payment object was made and it specifies a redirect url, then we'll setup that redirect info
2136
-			if ( $payment instanceof EE_Payment && $payment->redirect_url() ) {
2137
-				do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()' );
2136
+			if ($payment instanceof EE_Payment && $payment->redirect_url()) {
2137
+				do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->redirect_url(), '$payment->redirect_url()');
2138 2138
 				$this->checkout->redirect = true;
2139 2139
 				$this->checkout->redirect_form = $payment->redirect_form();
2140
-				$this->checkout->redirect_url = $this->reg_step_url( 'redirect_form' );
2140
+				$this->checkout->redirect_url = $this->reg_step_url('redirect_form');
2141 2141
 				// set JSON response
2142
-				$this->checkout->json_response->set_redirect_form( $this->checkout->redirect_form );
2142
+				$this->checkout->json_response->set_redirect_form($this->checkout->redirect_form);
2143 2143
 				// set cron job for finalizing the TXN
2144 2144
 				// in case the user does not return from the off-site gateway
2145 2145
 				EE_Cron_Tasks::schedule_finalize_abandoned_transactions_check(
@@ -2147,7 +2147,7 @@  discard block
 block discarded – undo
2147 2147
 					$this->checkout->transaction->ID()
2148 2148
 				);
2149 2149
 				// and lastly, let's bump the payment status to pending
2150
-				$payment->set_status( EEM_Payment::status_id_pending );
2150
+				$payment->set_status(EEM_Payment::status_id_pending);
2151 2151
 				$payment->save();
2152 2152
 			} else {
2153 2153
 				// not a payment
@@ -2159,7 +2159,7 @@  discard block
 block discarded – undo
2159 2159
 							'event_espresso'
2160 2160
 						),
2161 2161
 						'<br/>',
2162
-						EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2162
+						EE_Registry::instance()->CFG->organization->get_pretty('email')
2163 2163
 					),
2164 2164
 					__FILE__,
2165 2165
 					__FUNCTION__,
@@ -2197,21 +2197,21 @@  discard block
 block discarded – undo
2197 2197
 	 * @return bool
2198 2198
 	 * @throws \EE_Error
2199 2199
 	 */
2200
-	private function _process_payment_status( $payment, $payment_occurs = EE_PMT_Base::offline ) {
2200
+	private function _process_payment_status($payment, $payment_occurs = EE_PMT_Base::offline) {
2201 2201
 		// off-line payment? carry on
2202
-		if ( $payment_occurs === EE_PMT_Base::offline ) {
2202
+		if ($payment_occurs === EE_PMT_Base::offline) {
2203 2203
 			return true;
2204 2204
 		}
2205 2205
 		// verify payment validity
2206
-		if ( $payment instanceof EE_Payment ) {
2207
-			do_action( 'AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()' );
2206
+		if ($payment instanceof EE_Payment) {
2207
+			do_action('AHEE_log', __CLASS__, __FUNCTION__, $payment->status(), '$payment->status()');
2208 2208
 			$msg = $payment->gateway_response();
2209 2209
 			// check results
2210
-			switch ( $payment->status() ) {
2210
+			switch ($payment->status()) {
2211 2211
 				// good payment
2212 2212
 				case EEM_Payment::status_id_approved :
2213 2213
 					EE_Error::add_success(
2214
-						__( 'Your payment was processed successfully.', 'event_espresso' ),
2214
+						__('Your payment was processed successfully.', 'event_espresso'),
2215 2215
 						__FILE__,
2216 2216
 						__FUNCTION__,
2217 2217
 						__LINE__
@@ -2220,45 +2220,45 @@  discard block
 block discarded – undo
2220 2220
 					break;
2221 2221
 				// slow payment
2222 2222
 				case EEM_Payment::status_id_pending :
2223
-					if ( empty( $msg ) ) {
2223
+					if (empty($msg)) {
2224 2224
 						$msg = __(
2225 2225
 							'Your payment appears to have been processed successfully, but the Instant Payment Notification has not yet been received. It should arrive shortly.',
2226 2226
 							'event_espresso'
2227 2227
 						);
2228 2228
 					}
2229
-					EE_Error::add_success( $msg, __FILE__, __FUNCTION__, __LINE__ );
2229
+					EE_Error::add_success($msg, __FILE__, __FUNCTION__, __LINE__);
2230 2230
 					return true;
2231 2231
 					break;
2232 2232
 				// don't wanna payment
2233 2233
 				case EEM_Payment::status_id_cancelled :
2234
-					if ( empty( $msg ) ) {
2234
+					if (empty($msg)) {
2235 2235
 						$msg = _n(
2236 2236
 							'Payment cancelled. Please try again.',
2237 2237
 							'Payment cancelled. Please try again or select another method of payment.',
2238
-							count( $this->checkout->available_payment_methods ),
2238
+							count($this->checkout->available_payment_methods),
2239 2239
 							'event_espresso'
2240 2240
 						);
2241 2241
 					}
2242
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
2242
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2243 2243
 					return false;
2244 2244
 					break;
2245 2245
 				// not enough payment
2246 2246
 				case EEM_Payment::status_id_declined :
2247
-					if ( empty( $msg ) ) {
2247
+					if (empty($msg)) {
2248 2248
 						$msg = _n(
2249 2249
 							'We\'re sorry but your payment was declined. Please try again.',
2250 2250
 							'We\'re sorry but your payment was declined. Please try again or select another method of payment.',
2251
-							count( $this->checkout->available_payment_methods ),
2251
+							count($this->checkout->available_payment_methods),
2252 2252
 							'event_espresso'
2253 2253
 						);
2254 2254
 					}
2255
-					EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
2255
+					EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
2256 2256
 					return false;
2257 2257
 					break;
2258 2258
 				// bad payment
2259 2259
 				case EEM_Payment::status_id_failed :
2260
-					if ( ! empty( $msg ) ) {
2261
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2260
+					if ( ! empty($msg)) {
2261
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2262 2262
 						return false;
2263 2263
 					}
2264 2264
 					// default to error below
@@ -2267,7 +2267,7 @@  discard block
 block discarded – undo
2267 2267
 		}
2268 2268
 		// off-site payment gateway responses are too unreliable, so let's just assume that
2269 2269
 		// the payment processing is just running slower than the registrant's request
2270
-		if ( $payment_occurs === EE_PMT_Base::offsite ) {
2270
+		if ($payment_occurs === EE_PMT_Base::offsite) {
2271 2271
 			return true;
2272 2272
 		}
2273 2273
 		EE_Error::add_error(
@@ -2277,7 +2277,7 @@  discard block
 block discarded – undo
2277 2277
 					'event_espresso'
2278 2278
 				),
2279 2279
 				'<br/>',
2280
-				EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2280
+				EE_Registry::instance()->CFG->organization->get_pretty('email')
2281 2281
 			),
2282 2282
 			__FILE__,
2283 2283
 			__FUNCTION__,
@@ -2310,13 +2310,13 @@  discard block
 block discarded – undo
2310 2310
 	public function process_gateway_response() {
2311 2311
 		$payment = null;
2312 2312
 		// how have they chosen to pay?
2313
-		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment( true );
2313
+		$this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(true);
2314 2314
 		// get EE_Payment_Method object
2315
-		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment() ) {
2315
+		if ( ! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()) {
2316 2316
 			$this->checkout->continue_reg = false;
2317 2317
 			return false;
2318 2318
 		}
2319
-		if ( ! $this->checkout->payment_method->is_off_site() ) {
2319
+		if ( ! $this->checkout->payment_method->is_off_site()) {
2320 2320
 			return false;
2321 2321
 		}
2322 2322
 		$this->_validate_offsite_return();
@@ -2330,23 +2330,23 @@  discard block
 block discarded – undo
2330 2330
 		//	true
2331 2331
 		//);
2332 2332
 		// verify TXN
2333
-		if ( $this->checkout->transaction instanceof EE_Transaction ) {
2333
+		if ($this->checkout->transaction instanceof EE_Transaction) {
2334 2334
 			$gateway = $this->checkout->payment_method->type_obj()->get_gateway();
2335
-			if ( ! $gateway instanceof EE_Offsite_Gateway ) {
2335
+			if ( ! $gateway instanceof EE_Offsite_Gateway) {
2336 2336
 				$this->checkout->continue_reg = false;
2337 2337
 				return false;
2338 2338
 			}
2339
-			$payment = $this->_process_off_site_payment( $gateway );
2340
-			$payment = $this->_process_cancelled_payments( $payment );
2341
-			$payment = $this->_validate_payment( $payment );
2339
+			$payment = $this->_process_off_site_payment($gateway);
2340
+			$payment = $this->_process_cancelled_payments($payment);
2341
+			$payment = $this->_validate_payment($payment);
2342 2342
 			// if payment was not declined by the payment gateway or cancelled by the registrant
2343
-			if ( $this->_process_payment_status( $payment, EE_PMT_Base::offsite ) ) {
2343
+			if ($this->_process_payment_status($payment, EE_PMT_Base::offsite)) {
2344 2344
 				//$this->_setup_redirect_for_next_step();
2345 2345
 				// store that for later
2346 2346
 				$this->checkout->payment = $payment;
2347 2347
 				// mark this reg step as completed, as long as gateway doesn't use a separate IPN request,
2348 2348
 				// because we will complete this step during the IPN processing then
2349
-				if ( $gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request() ) {
2349
+				if ($gateway instanceof EE_Offsite_Gateway && ! $this->handle_IPN_in_this_request()) {
2350 2350
 					$this->set_completed();
2351 2351
 				}
2352 2352
 				return true;
@@ -2370,21 +2370,21 @@  discard block
 block discarded – undo
2370 2370
 	 * @throws \EE_Error
2371 2371
 	 */
2372 2372
 	private function _validate_offsite_return() {
2373
-		$TXN_ID = (int)EE_Registry::instance()->REQ->get( 'spco_txn', 0 );
2374
-		if ( $TXN_ID !== $this->checkout->transaction->ID() ) {
2373
+		$TXN_ID = (int) EE_Registry::instance()->REQ->get('spco_txn', 0);
2374
+		if ($TXN_ID !== $this->checkout->transaction->ID()) {
2375 2375
 			// Houston... we might have a problem
2376 2376
 			$invalid_TXN = false;
2377 2377
 			// first gather some info
2378
-			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID( $TXN_ID );
2378
+			$valid_TXN = EEM_Transaction::instance()->get_one_by_ID($TXN_ID);
2379 2379
 			$primary_registrant = $valid_TXN instanceof EE_Transaction
2380 2380
 				? $valid_TXN->primary_registration()
2381 2381
 				: null;
2382 2382
 			// let's start by retrieving the cart for this TXN
2383
-			$cart = $this->checkout->get_cart_for_transaction( $this->checkout->transaction );
2384
-			if ( $cart instanceof EE_Cart ) {
2383
+			$cart = $this->checkout->get_cart_for_transaction($this->checkout->transaction);
2384
+			if ($cart instanceof EE_Cart) {
2385 2385
 				// verify that the current cart has tickets
2386 2386
 				$tickets = $cart->get_tickets();
2387
-				if ( empty( $tickets ) ) {
2387
+				if (empty($tickets)) {
2388 2388
 					$invalid_TXN = true;
2389 2389
 				}
2390 2390
 			} else {
@@ -2394,35 +2394,35 @@  discard block
 block discarded – undo
2394 2394
 				? $primary_registrant->session_ID()
2395 2395
 				: null;
2396 2396
 			// validate current Session ID and compare against valid TXN session ID
2397
-			if ( EE_Session::instance()->id() === null ) {
2397
+			if (EE_Session::instance()->id() === null) {
2398 2398
 				$invalid_TXN = true;
2399
-			} else if ( EE_Session::instance()->id() === $valid_TXN_SID ) {
2399
+			} else if (EE_Session::instance()->id() === $valid_TXN_SID) {
2400 2400
 				// WARNING !!!
2401 2401
 				// this could be PayPal sending back duplicate requests (ya they do that)
2402 2402
 				// or it **could** mean someone is simply registering AGAIN after having just done so
2403 2403
 				// so now we need to determine if this current TXN looks valid or not
2404 2404
 				// has this step even been started ?
2405
-				if ( $this->checkout->transaction->reg_step_completed( $this->slug() === false )
2405
+				if ($this->checkout->transaction->reg_step_completed($this->slug() === false)
2406 2406
 				) {
2407 2407
 					// really? you're half way through this reg step, but you never started it ?
2408 2408
 					$invalid_TXN = true;
2409 2409
 				}
2410 2410
 			}
2411
-			if ( $invalid_TXN ) {
2411
+			if ($invalid_TXN) {
2412 2412
 				// is the valid TXN completed ?
2413
-				if ( $valid_TXN instanceof EE_Transaction ) {
2413
+				if ($valid_TXN instanceof EE_Transaction) {
2414 2414
 					// has this step even been started ?
2415
-					$reg_step_completed = $valid_TXN->reg_step_completed( $this->slug() );
2416
-					if ( $reg_step_completed !== false && $reg_step_completed !== true ) {
2415
+					$reg_step_completed = $valid_TXN->reg_step_completed($this->slug());
2416
+					if ($reg_step_completed !== false && $reg_step_completed !== true) {
2417 2417
 						// so it **looks** like this is a double request from PayPal
2418 2418
 						// so let's try to pick up where we left off
2419 2419
 						$this->checkout->transaction = $valid_TXN;
2420
-						$this->checkout->refresh_all_entities( true );
2420
+						$this->checkout->refresh_all_entities(true);
2421 2421
 						return;
2422 2422
 					}
2423 2423
 				}
2424 2424
 				// you appear to be lost?
2425
-				$this->_redirect_wayward_request( $primary_registrant );
2425
+				$this->_redirect_wayward_request($primary_registrant);
2426 2426
 			}
2427 2427
 		}
2428 2428
 	}
@@ -2437,14 +2437,14 @@  discard block
 block discarded – undo
2437 2437
 	 * @return bool
2438 2438
 	 * @throws \EE_Error
2439 2439
 	 */
2440
-	private function _redirect_wayward_request( EE_Registration $primary_registrant ) {
2441
-		if ( ! $primary_registrant instanceof EE_Registration ) {
2440
+	private function _redirect_wayward_request(EE_Registration $primary_registrant) {
2441
+		if ( ! $primary_registrant instanceof EE_Registration) {
2442 2442
 			// try redirecting based on the current TXN
2443 2443
 			$primary_registrant = $this->checkout->transaction instanceof EE_Transaction
2444 2444
 				? $this->checkout->transaction->primary_registration()
2445 2445
 				: null;
2446 2446
 		}
2447
-		if ( ! $primary_registrant instanceof EE_Registration ) {
2447
+		if ( ! $primary_registrant instanceof EE_Registration) {
2448 2448
 			EE_Error::add_error(
2449 2449
 				sprintf(
2450 2450
 					__(
@@ -2452,7 +2452,7 @@  discard block
 block discarded – undo
2452 2452
 						'event_espresso'
2453 2453
 					),
2454 2454
 					'<br/>',
2455
-					EE_Registry::instance()->CFG->organization->get_pretty( 'email' )
2455
+					EE_Registry::instance()->CFG->organization->get_pretty('email')
2456 2456
 				),
2457 2457
 				__FILE__,
2458 2458
 				__FUNCTION__,
@@ -2483,17 +2483,17 @@  discard block
 block discarded – undo
2483 2483
 	 * @return \EE_Payment
2484 2484
 	 * @throws \EE_Error
2485 2485
 	 */
2486
-	private function _process_off_site_payment( EE_Offsite_Gateway $gateway ) {
2486
+	private function _process_off_site_payment(EE_Offsite_Gateway $gateway) {
2487 2487
 		try {
2488 2488
 			$request_data = \EE_Registry::instance()->REQ->params();
2489 2489
 			// if gateway uses_separate_IPN_request, then we don't have to process the IPN manually
2490 2490
 			$this->set_handle_IPN_in_this_request(
2491
-				$gateway->handle_IPN_in_this_request( $request_data, false )
2491
+				$gateway->handle_IPN_in_this_request($request_data, false)
2492 2492
 			);
2493
-			if ( $this->handle_IPN_in_this_request() ) {
2493
+			if ($this->handle_IPN_in_this_request()) {
2494 2494
 				// get payment details and process results
2495 2495
 				/** @type EE_Payment_Processor $payment_processor */
2496
-				$payment_processor = EE_Registry::instance()->load_core( 'Payment_Processor' );
2496
+				$payment_processor = EE_Registry::instance()->load_core('Payment_Processor');
2497 2497
 				$payment = $payment_processor->process_ipn(
2498 2498
 					$request_data,
2499 2499
 					$this->checkout->transaction,
@@ -2506,14 +2506,14 @@  discard block
 block discarded – undo
2506 2506
 				$payment = $this->checkout->transaction->last_payment();
2507 2507
 				//$payment_source = 'last_payment';
2508 2508
 			}
2509
-		} catch ( Exception $e ) {
2509
+		} catch (Exception $e) {
2510 2510
 			// let's just eat the exception and try to move on using any previously set payment info
2511 2511
 			$payment = $this->checkout->transaction->last_payment();
2512 2512
 			//$payment_source = 'last_payment after Exception';
2513 2513
 			// but if we STILL don't have a payment object
2514
-			if ( ! $payment instanceof EE_Payment ) {
2514
+			if ( ! $payment instanceof EE_Payment) {
2515 2515
 				// then we'll object ! ( not object like a thing... but object like what a lawyer says ! )
2516
-				$this->_handle_payment_processor_exception( $e );
2516
+				$this->_handle_payment_processor_exception($e);
2517 2517
 			}
2518 2518
 		}
2519 2519
 		// DEBUG LOG
@@ -2538,13 +2538,13 @@  discard block
 block discarded – undo
2538 2538
 	 * @return EE_Payment | FALSE
2539 2539
 	 * @throws \EE_Error
2540 2540
 	 */
2541
-	private function _process_cancelled_payments( $payment = null ) {
2541
+	private function _process_cancelled_payments($payment = null) {
2542 2542
 		if (
2543 2543
 			$payment instanceof EE_Payment
2544
-			&& isset( $_REQUEST['ee_cancel_payment'] )
2544
+			&& isset($_REQUEST['ee_cancel_payment'])
2545 2545
 			&& $payment->status() === EEM_Payment::status_id_failed
2546 2546
 		) {
2547
-			$payment->set_status( EEM_Payment::status_id_cancelled );
2547
+			$payment->set_status(EEM_Payment::status_id_cancelled);
2548 2548
 		}
2549 2549
 		return $payment;
2550 2550
 	}
@@ -2561,14 +2561,14 @@  discard block
 block discarded – undo
2561 2561
 	public function get_transaction_details_for_gateways() {
2562 2562
 		$txn_details = array();
2563 2563
 		// ya gotta make a choice man
2564
-		if ( empty( $this->checkout->selected_method_of_payment ) ) {
2564
+		if (empty($this->checkout->selected_method_of_payment)) {
2565 2565
 			$txn_details = array(
2566
-				'error' => __( 'Please select a method of payment before proceeding.', 'event_espresso' )
2566
+				'error' => __('Please select a method of payment before proceeding.', 'event_espresso')
2567 2567
 			);
2568 2568
 		}
2569 2569
 		// get EE_Payment_Method object
2570 2570
 		if (
2571
-			empty( $txn_details )
2571
+			empty($txn_details)
2572 2572
 			&&
2573 2573
 			! $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment()
2574 2574
 		) {
@@ -2580,8 +2580,8 @@  discard block
 block discarded – undo
2580 2580
 				)
2581 2581
 			);
2582 2582
 		}
2583
-		if ( empty( $txn_details ) && $this->checkout->transaction instanceof EE_Transaction ) {
2584
-			$return_url = $this->_get_return_url( $this->checkout->payment_method );
2583
+		if (empty($txn_details) && $this->checkout->transaction instanceof EE_Transaction) {
2584
+			$return_url = $this->_get_return_url($this->checkout->payment_method);
2585 2585
 			$txn_details = array(
2586 2586
 				'TXN_ID'         => $this->checkout->transaction->ID(),
2587 2587
 				'TXN_timestamp'  => $this->checkout->transaction->datetime(),
@@ -2592,7 +2592,7 @@  discard block
 block discarded – undo
2592 2592
 				'PMD_ID'         => $this->checkout->transaction->payment_method_ID(),
2593 2593
 				'payment_amount' => $this->checkout->amount_owing,
2594 2594
 				'return_url'     => $return_url,
2595
-				'cancel_url'     => add_query_arg( array( 'ee_cancel_payment' => true ), $return_url ),
2595
+				'cancel_url'     => add_query_arg(array('ee_cancel_payment' => true), $return_url),
2596 2596
 				'notify_url'     => EE_Config::instance()->core->txn_page_url(
2597 2597
 					array(
2598 2598
 						'e_reg_url_link'    => $this->checkout->transaction->primary_registration()->reg_url_link(),
@@ -2601,7 +2601,7 @@  discard block
 block discarded – undo
2601 2601
 				)
2602 2602
 			);
2603 2603
 		}
2604
-		echo wp_json_encode( $txn_details );
2604
+		echo wp_json_encode($txn_details);
2605 2605
 		exit();
2606 2606
 	}
2607 2607
 
@@ -2618,7 +2618,7 @@  discard block
 block discarded – undo
2618 2618
     public function __sleep()
2619 2619
     {
2620 2620
         // remove the reg form and the checkout
2621
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'reg_form', 'checkout', 'line_item_display' ) );
2621
+        return array_diff(array_keys(get_object_vars($this)), array('reg_form', 'checkout', 'line_item_display'));
2622 2622
     }
2623 2623
 
2624 2624
 
Please login to merge, or discard this patch.
shortcodes/espresso_thank_you/EES_Espresso_Thank_You.shortcode.php 1 patch
Spacing   +135 added lines, -135 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @return    void
92 92
 	 */
93 93
 	public static function set_hooks() {
94
-		add_action( 'wp_loaded', array( 'EES_Espresso_Thank_You', 'set_definitions' ), 2 );
94
+		add_action('wp_loaded', array('EES_Espresso_Thank_You', 'set_definitions'), 2);
95 95
 	}
96 96
 
97 97
 
@@ -104,22 +104,22 @@  discard block
 block discarded – undo
104 104
 	 */
105 105
 	public static function set_hooks_admin() {
106 106
 		// AJAX for IPN monitoring
107
-		add_filter( 'heartbeat_received', array( 'EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor' ), 10, 3 );
107
+		add_filter('heartbeat_received', array('EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor'), 10, 3);
108 108
 		add_filter(
109 109
 			'heartbeat_nopriv_received',
110
-			array( 'EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor' ),
110
+			array('EES_Espresso_Thank_You', 'thank_you_page_IPN_monitor'),
111 111
 			10,
112 112
 			3
113 113
 		);
114 114
 		add_action(
115 115
 			'wp_ajax_espresso_resend_reg_confirmation_email',
116
-			array( 'EES_Espresso_Thank_You', 'resend_reg_confirmation_email' ),
116
+			array('EES_Espresso_Thank_You', 'resend_reg_confirmation_email'),
117 117
 			10,
118 118
 			2
119 119
 		);
120 120
 		add_action(
121 121
 			'wp_ajax_nopriv_espresso_resend_reg_confirmation_email',
122
-			array( 'EES_Espresso_Thank_You', 'resend_reg_confirmation_email' ),
122
+			array('EES_Espresso_Thank_You', 'resend_reg_confirmation_email'),
123 123
 			10,
124 124
 			2
125 125
 		);
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @return    void
135 135
 	 */
136 136
 	public static function set_definitions() {
137
-		define( 'THANK_YOU_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS );
138
-		define( 'THANK_YOU_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ ) ) . 'templates' . DS );
137
+		define('THANK_YOU_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS);
138
+		define('THANK_YOU_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS);
139 139
 	}
140 140
 
141 141
 
@@ -147,13 +147,13 @@  discard block
 block discarded – undo
147 147
 	 * @return    EE_Transaction
148 148
 	 */
149 149
 	public function get_txn() {
150
-		if ( $this->_current_txn instanceof EE_Transaction ) {
150
+		if ($this->_current_txn instanceof EE_Transaction) {
151 151
 			return $this->_current_txn;
152 152
 		}
153
-		$TXN_model = EE_Registry::instance()->load_model( 'Transaction' );
154
-		if ( ! $TXN_model instanceof EEM_Transaction ) {
153
+		$TXN_model = EE_Registry::instance()->load_model('Transaction');
154
+		if ( ! $TXN_model instanceof EEM_Transaction) {
155 155
 			EE_Error::add_error(
156
-				__( 'The transaction model could not be established.', 'event_espresso' ),
156
+				__('The transaction model could not be established.', 'event_espresso'),
157 157
 				__FILE__,
158 158
 				__FUNCTION__,
159 159
 				__LINE__
@@ -161,9 +161,9 @@  discard block
 block discarded – undo
161 161
 			return null;
162 162
 		}
163 163
 		//get the transaction. yes, we may have just loaded it, but it may have been updated, or this may be via an ajax request
164
-		$this->_current_txn = $TXN_model->get_transaction_from_reg_url_link( $this->_reg_url_link );
164
+		$this->_current_txn = $TXN_model->get_transaction_from_reg_url_link($this->_reg_url_link);
165 165
 		// verify TXN
166
-		if ( WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction ) {
166
+		if (WP_DEBUG && ! $this->_current_txn instanceof EE_Transaction) {
167 167
 			EE_Error::add_error(
168 168
 				__(
169 169
 					'No transaction information could be retrieved or the transaction data is not of the correct type.',
@@ -187,16 +187,16 @@  discard block
 block discarded – undo
187 187
 	 * @param int $since
188 188
 	 * @return    mixed array of EE_Payment || FALSE
189 189
 	 */
190
-	public function get_txn_payments( $since = 0 ) {
191
-		if ( ! $this->get_txn() ) {
190
+	public function get_txn_payments($since = 0) {
191
+		if ( ! $this->get_txn()) {
192 192
 			return false;
193 193
 		}
194
-		$args = array( 'order_by' => array( 'PAY_timestamp' => 'ASC' ) );
195
-		if ( $since > 0 ) {
196
-			$args[0] = array( 'PAY_timestamp' => array( '>', $since ) );
194
+		$args = array('order_by' => array('PAY_timestamp' => 'ASC'));
195
+		if ($since > 0) {
196
+			$args[0] = array('PAY_timestamp' => array('>', $since));
197 197
 		}
198 198
 		// get array of payments with most recent first
199
-		return $this->_current_txn->payments( $args );
199
+		return $this->_current_txn->payments($args);
200 200
 	}
201 201
 
202 202
 
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 	 * @return    void
209 209
 	 */
210 210
 	private function _get_reg_url_link() {
211
-		if ( ! empty( $this->_reg_url_link ) ) {
211
+		if ( ! empty($this->_reg_url_link)) {
212 212
 			return;
213 213
 		}
214 214
 		// only do thank you page stuff if we have a REG_url_link in the url
215
-		if ( WP_DEBUG && ! EE_Registry::instance()->REQ->is_set( 'e_reg_url_link' ) ) {
215
+		if (WP_DEBUG && ! EE_Registry::instance()->REQ->is_set('e_reg_url_link')) {
216 216
 			EE_Error::add_error(
217 217
 				__(
218 218
 					'No transaction information could be retrieved because the registration URL link is missing or invalid.',
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			return;
226 226
 		}
227 227
 		// check for reg_url_link
228
-		$this->_reg_url_link = EE_Registry::instance()->REQ->get( 'e_reg_url_link' );
228
+		$this->_reg_url_link = EE_Registry::instance()->REQ->get('e_reg_url_link');
229 229
 	}
230 230
 
231 231
 
@@ -237,8 +237,8 @@  discard block
 block discarded – undo
237 237
 	 * @param    string $reg_url_link
238 238
 	 * @return    string
239 239
 	 */
240
-	public function set_reg_url_link( $reg_url_link = null ) {
241
-		$this->_reg_url_link = ! empty( $reg_url_link ) ? $reg_url_link : $this->_reg_url_link;
240
+	public function set_reg_url_link($reg_url_link = null) {
241
+		$this->_reg_url_link = ! empty($reg_url_link) ? $reg_url_link : $this->_reg_url_link;
242 242
 	}
243 243
 
244 244
 
@@ -251,28 +251,28 @@  discard block
 block discarded – undo
251 251
 	 * @param    WP $WP
252 252
 	 * @return    void
253 253
 	 */
254
-	public function run( WP $WP ) {
254
+	public function run(WP $WP) {
255 255
 		// remove site_url() from thank you page URL
256
-		$thank_you_page_URL = substr( EE_Registry::instance()->CFG->core->thank_you_page_url(), strlen( home_url() ) );
256
+		$thank_you_page_URL = substr(EE_Registry::instance()->CFG->core->thank_you_page_url(), strlen(home_url()));
257 257
 		// remove other non-essential details from URL
258
-		$thank_you_page_URL = trim( parse_url( $thank_you_page_URL, PHP_URL_PATH ), '/' );
258
+		$thank_you_page_URL = trim(parse_url($thank_you_page_URL, PHP_URL_PATH), '/');
259 259
 		// ensure this shortcode doesn't trigger on anything BUT the thank you page
260
-		if ( isset( $WP->request ) && trim( $WP->request, '/' ) !== $thank_you_page_URL ) {
260
+		if (isset($WP->request) && trim($WP->request, '/') !== $thank_you_page_URL) {
261 261
 			return;
262 262
 		} else if (
263
-			isset( $WP->query_vars['page_id'] )
264
-			&& (int)$WP->query_vars['page_id'] !== (int)EE_Registry::instance()->CFG->core->thank_you_page_id
263
+			isset($WP->query_vars['page_id'])
264
+			&& (int) $WP->query_vars['page_id'] !== (int) EE_Registry::instance()->CFG->core->thank_you_page_id
265 265
 		) {
266 266
 			return;
267 267
 		}
268 268
 		$this->_get_reg_url_link();
269 269
 		// resend_reg_confirmation_email ?
270
-		if ( EE_Registry::instance()->REQ->is_set( 'resend' ) ) {
270
+		if (EE_Registry::instance()->REQ->is_set('resend')) {
271 271
 			EES_Espresso_Thank_You::resend_reg_confirmation_email();
272 272
 		}
273 273
 		// load assets
274
-		add_action( 'wp_enqueue_scripts', array( $this, 'load_js' ), 10 );
275
-		EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
274
+		add_action('wp_enqueue_scripts', array($this, 'load_js'), 10);
275
+		EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
276 276
 		$this->_translate_strings();
277 277
 	}
278 278
 
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
 	public function load_js() {
327 327
 		wp_register_script(
328 328
 			'thank_you_page',
329
-			THANK_YOU_ASSETS_URL . 'thank_you_page.js',
330
-			array( 'espresso_core', 'heartbeat' ),
329
+			THANK_YOU_ASSETS_URL.'thank_you_page.js',
330
+			array('espresso_core', 'heartbeat'),
331 331
 			EVENT_ESPRESSO_VERSION,
332 332
 			true
333 333
 		);
334
-		wp_enqueue_script( 'thank_you_page' );
334
+		wp_enqueue_script('thank_you_page');
335 335
 	}
336 336
 
337 337
 
@@ -345,9 +345,9 @@  discard block
 block discarded – undo
345 345
 	 */
346 346
 	public function init() {
347 347
 		$this->_get_reg_url_link();
348
-		if ( ! $this->get_txn() ) {
348
+		if ( ! $this->get_txn()) {
349 349
 			echo EEH_HTML::div(
350
-				EEH_HTML::h4( __( 'We\'re sorry...', 'event_espresso' ), '', '' ) .
350
+				EEH_HTML::h4(__('We\'re sorry...', 'event_espresso'), '', '').
351 351
 				sprintf(
352 352
 					__(
353 353
 						'This is a system page for displaying transaction information after a purchase.%1$sYou are most likely seeing this notice because you have navigated to this page%1$sthrough some means other than completing a transaction.%1$sSorry for the disappointment, but you will most likely find nothing of interest here.%1$s%1$s',
@@ -361,8 +361,8 @@  discard block
 block discarded – undo
361 361
 			return null;
362 362
 		}
363 363
 		// if we've made it to the Thank You page, then let's toggle any "Failed" transactions to "Incomplete"
364
-		if ( $this->_current_txn->status_ID() === EEM_Transaction::failed_status_code ) {
365
-			$this->_current_txn->set_status( EEM_Transaction::incomplete_status_code );
364
+		if ($this->_current_txn->status_ID() === EEM_Transaction::failed_status_code) {
365
+			$this->_current_txn->set_status(EEM_Transaction::incomplete_status_code);
366 366
 			$this->_current_txn->save();
367 367
 		}
368 368
 		$this->_primary_registrant = $this->_current_txn->primary_registration() instanceof EE_Registration
@@ -375,15 +375,15 @@  discard block
 block discarded – undo
375 375
 		);
376 376
 		$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
377 377
 		// txn status ?
378
-		if ( $this->_current_txn->is_completed() ) {
378
+		if ($this->_current_txn->is_completed()) {
379 379
 			$this->_show_try_pay_again_link = $show_try_pay_again_link_default;
380 380
 		} else if (
381 381
 			$this->_current_txn->is_incomplete()
382
-			&& ( $this->_primary_registrant->is_approved()
383
-			|| $this->_primary_registrant->is_pending_payment() )
382
+			&& ($this->_primary_registrant->is_approved()
383
+			|| $this->_primary_registrant->is_pending_payment())
384 384
 		) {
385 385
 			$this->_show_try_pay_again_link = true;
386
-		} else if ( $this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment() ) {
386
+		} else if ($this->_primary_registrant->is_approved() || $this->_primary_registrant->is_pending_payment()) {
387 387
 			// its pending
388 388
 			$this->_show_try_pay_again_link = isset(
389 389
 				EE_Registry::instance()->CFG->registration->show_pending_payment_options
@@ -409,21 +409,21 @@  discard block
 block discarded – undo
409 409
 		}
410 410
 		// link to SPCO
411 411
 		$revisit_spco_url = add_query_arg(
412
-			array( 'ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link ),
412
+			array('ee' => '_register', 'revisit' => true, 'e_reg_url_link' => $this->_reg_url_link),
413 413
 			EE_Registry::instance()->CFG->core->reg_page_url()
414 414
 		);
415 415
 		// link to SPCO payment_options
416 416
 		$this->_SPCO_payment_options_url = $this->_primary_registrant instanceof EE_Registration
417 417
 			? $this->_primary_registrant->payment_overview_url()
418 418
 			: add_query_arg(
419
-				array( 'step' => 'payment_options' ),
419
+				array('step' => 'payment_options'),
420 420
 				$revisit_spco_url
421 421
 			);
422 422
 		// link to SPCO attendee_information
423 423
 		$this->_SPCO_attendee_information_url = $this->_primary_registrant instanceof EE_Registration
424 424
 			? $this->_primary_registrant->edit_attendee_information_url()
425 425
 			: false;
426
-		do_action( 'AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn );
426
+		do_action('AHEE__EES_Espresso_Thank_You__init_end', $this->_current_txn);
427 427
 		// set no cache headers and constants
428 428
 		EE_System::do_not_cache();
429 429
 	}
@@ -438,15 +438,15 @@  discard block
 block discarded – undo
438 438
 	 * @return    string
439 439
 	 * @throws \EE_Error
440 440
 	 */
441
-	public function process_shortcode( $attributes = array() ) {
441
+	public function process_shortcode($attributes = array()) {
442 442
 		$this->init();
443
-		if ( ! $this->_current_txn instanceof EE_Transaction ) {
443
+		if ( ! $this->_current_txn instanceof EE_Transaction) {
444 444
 			return EE_Error::get_notices();
445 445
 		}
446 446
 		//EEH_Debug_Tools::log( __CLASS__, __FUNCTION__, __LINE__, array( $this->_current_txn ), true, 	'EE_Transaction: ' . $this->_current_txn->ID() );
447 447
 		// link to receipt
448
-		$template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url( 'html' );
449
-		if ( ! empty( $template_args['TXN_receipt_url'] ) ) {
448
+		$template_args['TXN_receipt_url'] = $this->_current_txn->receipt_url('html');
449
+		if ( ! empty($template_args['TXN_receipt_url'])) {
450 450
 			$template_args['order_conf_desc'] = __(
451 451
 				'%1$sCongratulations%2$sYour registration has been successfully processed.%3$sCheck your email for your registration confirmation or click the button below to view / download / print a full description of your purchases and registration information.',
452 452
 				'event_espresso'
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 			);
459 459
 		}
460 460
 		$template_args['transaction'] = $this->_current_txn;
461
-		$template_args['revisit'] = EE_Registry::instance()->REQ->get( 'revisit', false );
462
-		add_action( 'AHEE__thank_you_page_overview_template__content', array( $this, 'get_registration_details' ) );
463
-		if ( $this->_is_primary && ! $this->_current_txn->is_free() ) {
464
-			add_action( 'AHEE__thank_you_page_overview_template__content', array( $this, 'get_ajax_content' ) );
461
+		$template_args['revisit'] = EE_Registry::instance()->REQ->get('revisit', false);
462
+		add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_registration_details'));
463
+		if ($this->_is_primary && ! $this->_current_txn->is_free()) {
464
+			add_action('AHEE__thank_you_page_overview_template__content', array($this, 'get_ajax_content'));
465 465
 		}
466 466
 		return EEH_Template::locate_template(
467
-			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-overview.template.php',
467
+			THANK_YOU_TEMPLATES_PATH.'thank-you-page-overview.template.php',
468 468
 			$template_args,
469 469
 			true,
470 470
 			true
@@ -485,15 +485,15 @@  discard block
 block discarded – undo
485 485
 	 * @return    array
486 486
 	 * @throws \EE_Error
487 487
 	 */
488
-	public static function thank_you_page_IPN_monitor( $response = array(), $data = array() ) {
488
+	public static function thank_you_page_IPN_monitor($response = array(), $data = array()) {
489 489
 		// does this heartbeat contain our data ?
490
-		if ( ! isset( $data['espresso_thank_you_page'] ) ) {
490
+		if ( ! isset($data['espresso_thank_you_page'])) {
491 491
 			return $response;
492 492
 		}
493 493
 		// check for reg_url_link in the incoming heartbeat data
494
-		if ( ! isset( $data['espresso_thank_you_page']['e_reg_url_link'] ) ) {
494
+		if ( ! isset($data['espresso_thank_you_page']['e_reg_url_link'])) {
495 495
 			$response['espresso_thank_you_page'] = array(
496
-			'errors' => ! empty( $notices['errors'] )
496
+			'errors' => ! empty($notices['errors'])
497 497
 				? $notices['errors']
498 498
 				: __(
499 499
 					'No transaction information could be retrieved because the registration URL link is missing or invalid.',
@@ -508,15 +508,15 @@  discard block
 block discarded – undo
508 508
 		EES_Espresso_Thank_You::set_definitions();
509 509
 		/** @var $espresso_thank_you_page EES_Espresso_Thank_You */
510 510
 		$espresso_thank_you_page = EES_Espresso_Thank_You::instance();
511
-		$espresso_thank_you_page->set_reg_url_link( $data['espresso_thank_you_page']['e_reg_url_link'] );
511
+		$espresso_thank_you_page->set_reg_url_link($data['espresso_thank_you_page']['e_reg_url_link']);
512 512
 		$espresso_thank_you_page->init();
513 513
 		//get TXN
514 514
 		$TXN = $espresso_thank_you_page->get_txn();
515 515
 		// no TXN? then get out
516
-		if ( ! $TXN instanceof EE_Transaction ) {
516
+		if ( ! $TXN instanceof EE_Transaction) {
517 517
 			$notices = EE_Error::get_notices();
518 518
 			$response['espresso_thank_you_page'] = array(
519
-			'errors' => ! empty( $notices['errors'] )
519
+			'errors' => ! empty($notices['errors'])
520 520
 				? $notices['errors']
521 521
 				: sprintf(
522 522
 					__(
@@ -529,13 +529,13 @@  discard block
 block discarded – undo
529 529
 			return $response;
530 530
 		}
531 531
 		// grab transient of TXN's status
532
-		$txn_status = isset( $data['espresso_thank_you_page']['txn_status'] )
532
+		$txn_status = isset($data['espresso_thank_you_page']['txn_status'])
533 533
 			? $data['espresso_thank_you_page']['txn_status']
534 534
 			: null;
535 535
 		// has the TXN status changed since we last checked (or empty because this is the first time running through this code)?
536
-		if ( $txn_status !== $TXN->status_ID() ) {
536
+		if ($txn_status !== $TXN->status_ID()) {
537 537
 			// switch between two possible basic outcomes
538
-			switch ( $TXN->status_ID() ) {
538
+			switch ($TXN->status_ID()) {
539 539
 				// TXN has been updated in some way
540 540
 				case EEM_Transaction::overpaid_status_code:
541 541
 				case EEM_Transaction::complete_status_code:
@@ -550,25 +550,25 @@  discard block
 block discarded – undo
550 550
 				case EEM_Transaction::failed_status_code:
551 551
 				default:
552 552
 					// keep on waiting...
553
-					return $espresso_thank_you_page->_update_server_wait_time( $data['espresso_thank_you_page'] );
553
+					return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
554 554
 			}
555 555
 			// or is the TXN still failed (never been updated) ???
556
-		} else if ( $TXN->failed() ) {
556
+		} else if ($TXN->failed()) {
557 557
 			// keep on waiting...
558
-			return $espresso_thank_you_page->_update_server_wait_time( $data['espresso_thank_you_page'] );
558
+			return $espresso_thank_you_page->_update_server_wait_time($data['espresso_thank_you_page']);
559 559
 		}
560 560
 		// TXN is happening so let's get the payments now
561 561
 		// if we've already gotten payments then the heartbeat data will contain the timestamp of the last time we checked
562
-		$since = isset( $data['espresso_thank_you_page']['get_payments_since'] )
562
+		$since = isset($data['espresso_thank_you_page']['get_payments_since'])
563 563
 			? $data['espresso_thank_you_page']['get_payments_since']
564 564
 			: 0;
565 565
 		// then check for payments
566
-		$payments = $espresso_thank_you_page->get_txn_payments( $since );
566
+		$payments = $espresso_thank_you_page->get_txn_payments($since);
567 567
 		// has a payment been processed ?
568
-		if ( ! empty( $payments ) || $espresso_thank_you_page->_is_offline_payment_method ) {
569
-			if ( $since ) {
568
+		if ( ! empty($payments) || $espresso_thank_you_page->_is_offline_payment_method) {
569
+			if ($since) {
570 570
 				$response['espresso_thank_you_page'] = array(
571
-					'new_payments'        => $espresso_thank_you_page->get_new_payments( $payments ),
571
+					'new_payments'        => $espresso_thank_you_page->get_new_payments($payments),
572 572
 					'transaction_details' => $espresso_thank_you_page->get_transaction_details(),
573 573
 					'txn_status'          => $TXN->status_ID()
574 574
 				);
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
 	 * @param    array $thank_you_page_data thank you page portion of the incoming JSON array from the WP heartbeat data
595 595
 	 * @return    array
596 596
 	 */
597
-	private function _update_server_wait_time( $thank_you_page_data = array() ) {
597
+	private function _update_server_wait_time($thank_you_page_data = array()) {
598 598
 		$response['espresso_thank_you_page'] = array(
599
-			'still_waiting' => isset( $thank_you_page_data['initial_access'] )
599
+			'still_waiting' => isset($thank_you_page_data['initial_access'])
600 600
 				? time() - $thank_you_page_data['initial_access']
601 601
 				: 0,
602 602
 			'txn_status'    => $this->_current_txn->status_ID()
@@ -621,17 +621,17 @@  discard block
 block discarded – undo
621 621
 		$template_args['is_primary'] = $this->_is_primary;
622 622
 		$template_args['SPCO_attendee_information_url'] = $this->_SPCO_attendee_information_url;
623 623
 		$template_args['resend_reg_confirmation_url'] = add_query_arg(
624
-			array( 'token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true' ),
624
+			array('token' => $this->_reg_url_link, 'resend_reg_confirmation' => 'true'),
625 625
 			EE_Registry::instance()->CFG->core->thank_you_page_url()
626 626
 		);
627 627
 		// verify template arguments
628
-		EEH_Template_Validator::verify_instanceof( $template_args['transaction'], '$transaction', 'EE_Transaction' );
628
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
629 629
 		EEH_Template_Validator::verify_isnt_null(
630 630
 			$template_args['SPCO_attendee_information_url'],
631 631
 			'$SPCO_attendee_information_url'
632 632
 		);
633 633
 		echo EEH_Template::locate_template(
634
-			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-registration-details.template.php',
634
+			THANK_YOU_TEMPLATES_PATH.'thank-you-page-registration-details.template.php',
635 635
 			$template_args,
636 636
 			true,
637 637
 			true
@@ -644,16 +644,16 @@  discard block
 block discarded – undo
644 644
 	 *    resend_reg_confirmation_email
645 645
 	 */
646 646
 	public static function resend_reg_confirmation_email() {
647
-		EE_Registry::instance()->load_core( 'Request_Handler' );
648
-		$reg_url_link = EE_Registry::instance()->REQ->get( 'token' );
647
+		EE_Registry::instance()->load_core('Request_Handler');
648
+		$reg_url_link = EE_Registry::instance()->REQ->get('token');
649 649
 		// was a REG_ID passed ?
650
-		if ( $reg_url_link ) {
651
-			$registration = EE_Registry::instance()->load_model( 'Registration' )->get_one(
652
-				array( array( 'REG_url_link' => $reg_url_link ) )
650
+		if ($reg_url_link) {
651
+			$registration = EE_Registry::instance()->load_model('Registration')->get_one(
652
+				array(array('REG_url_link' => $reg_url_link))
653 653
 			);
654
-			if ( $registration instanceof EE_Registration ) {
654
+			if ($registration instanceof EE_Registration) {
655 655
 				// resend email
656
-				EED_Messages::process_resend( array( '_REG_ID' => $registration->ID() ) );
656
+				EED_Messages::process_resend(array('_REG_ID' => $registration->ID()));
657 657
 			} else {
658 658
 				EE_Error::add_error(
659 659
 					__(
@@ -677,16 +677,16 @@  discard block
 block discarded – undo
677 677
 			);
678 678
 		}
679 679
 		// request sent via AJAX ?
680
-		if ( EE_FRONT_AJAX ) {
681
-			echo wp_json_encode( EE_Error::get_notices( false ) );
680
+		if (EE_FRONT_AJAX) {
681
+			echo wp_json_encode(EE_Error::get_notices(false));
682 682
 			die();
683 683
 			// or was JS disabled ?
684 684
 		} else {
685 685
 			// save errors so that they get picked up on the next request
686
-			EE_Error::get_notices( true, true );
686
+			EE_Error::get_notices(true, true);
687 687
 			wp_safe_redirect(
688 688
 				add_query_arg(
689
-					array( 'e_reg_url_link' => $reg_url_link ),
689
+					array('e_reg_url_link' => $reg_url_link),
690 690
 					EE_Registry::instance()->CFG->core->thank_you_page_url()
691 691
 				)
692 692
 			);
@@ -702,26 +702,26 @@  discard block
 block discarded – undo
702 702
 	 * @return    void
703 703
 	 */
704 704
 	public function get_ajax_content() {
705
-		if ( ! $this->get_txn() ) {
705
+		if ( ! $this->get_txn()) {
706 706
 			return;
707 707
 		}
708 708
 		// first determine which event(s) require pre-approval or not
709 709
 		$events = array();
710 710
 		$events_requiring_pre_approval = array();
711
-		foreach ( $this->_current_txn->registrations() as $registration ) {
712
-			if ( $registration instanceof EE_Registration ) {
711
+		foreach ($this->_current_txn->registrations() as $registration) {
712
+			if ($registration instanceof EE_Registration) {
713 713
 				$event = $registration->event();
714
-				if ( $event instanceof EE_Event ) {
715
-					if ( $registration->is_not_approved() && $registration->event() instanceof EE_Event ) {
716
-						$events_requiring_pre_approval[ $event->ID() ] = $event;
714
+				if ($event instanceof EE_Event) {
715
+					if ($registration->is_not_approved() && $registration->event() instanceof EE_Event) {
716
+						$events_requiring_pre_approval[$event->ID()] = $event;
717 717
 					} else {
718
-						$events[ $event->ID() ] = $event;
718
+						$events[$event->ID()] = $event;
719 719
 					}
720 720
 				}
721 721
 			}
722 722
 		}
723
-		$this->display_details_for_events_requiring_pre_approval( $events_requiring_pre_approval );
724
-		$this->display_details_for_events( $events );
723
+		$this->display_details_for_events_requiring_pre_approval($events_requiring_pre_approval);
724
+		$this->display_details_for_events($events);
725 725
 	}
726 726
 
727 727
 
@@ -733,8 +733,8 @@  discard block
 block discarded – undo
733 733
 	 * @param EE_Event[] $events
734 734
 	 * @return string
735 735
 	 */
736
-	public function display_details_for_events( $events = array() ) {
737
-		if ( ! empty( $events ) ) {
736
+	public function display_details_for_events($events = array()) {
737
+		if ( ! empty($events)) {
738 738
 			?>
739 739
 			<div id="espresso-thank-you-page-ajax-content-dv">
740 740
 				<div id="espresso-thank-you-page-ajax-transaction-dv"></div>
@@ -746,7 +746,7 @@  discard block
 block discarded – undo
746 746
 							'event_espresso'
747 747
 							); ?></span>
748 748
 					</div>
749
-					<?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed ) : ?>
749
+					<?php if ( ! $this->_is_offline_payment_method && ! $this->_payments_closed) : ?>
750 750
 						<p id="ee-ajax-loading-pg" class="highlight-bg small-text clear">
751 751
 							<?php echo apply_filters(
752 752
 								'EES_Espresso_Thank_You__get_ajax_content__waiting_for_IPN_msg',
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
 							); ?>
758 758
 							<br/>
759 759
 							<span class="jst-rght ee-block small-text lt-grey-text">
760
-								<?php _e( 'current wait time ', 'event_espresso' ); ?>
760
+								<?php _e('current wait time ', 'event_espresso'); ?>
761 761
 							<span id="espresso-thank-you-page-ajax-time-dv">00:00:00</span></span>
762 762
 						</p>
763 763
 					<?php endif; ?>
@@ -777,11 +777,11 @@  discard block
 block discarded – undo
777 777
 	 * @param EE_Event[] $events
778 778
 	 * @return string
779 779
 	 */
780
-	public function display_details_for_events_requiring_pre_approval( $events = array() ) {
781
-		if ( ! empty( $events ) ) {
780
+	public function display_details_for_events_requiring_pre_approval($events = array()) {
781
+		if ( ! empty($events)) {
782 782
 			?>
783 783
 			<div id="espresso-thank-you-page-not-approved-message-dv">
784
-				<h4 class="orange-text"><?php _e( 'Important Notice:', 'event_espresso' ); ?></h4>
784
+				<h4 class="orange-text"><?php _e('Important Notice:', 'event_espresso'); ?></h4>
785 785
 				<p id="events-requiring-pre-approval-pg" class="small-text">
786 786
 					<?php echo apply_filters(
787 787
 						'AHEE__EES_Espresso_Thank_You__get_ajax_content__not_approved_message',
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 					); ?>
793 793
 				</p>
794 794
 				<ul class="events-requiring-pre-approval-ul">
795
-					<?php foreach ( $events as $event ) {
796
-						if ( $event instanceof EE_Event ) {
795
+					<?php foreach ($events as $event) {
796
+						if ($event instanceof EE_Event) {
797 797
 							echo '<li><span class="dashicons dashicons-marker ee-icon-size-16 orange-text"></span>',
798 798
 								$event->name(),
799 799
 								'</li>';
@@ -820,12 +820,12 @@  discard block
 block discarded – undo
820 820
 		$template_args = array();
821 821
 		$template_args['transaction'] = $this->_current_txn;
822 822
 		$template_args['reg_url_link'] = $this->_reg_url_link;
823
-		$template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name( true );
823
+		$template_args['primary_registrant_name'] = $this->_primary_registrant->attendee()->full_name(true);
824 824
 		// link to SPCO payment_options
825 825
 		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
826 826
 		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
827 827
 		// verify template arguments
828
-		EEH_Template_Validator::verify_instanceof( $template_args['transaction'], '$transaction', 'EE_Transaction' );
828
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
829 829
 		EEH_Template_Validator::verify_isnt_null(
830 830
 			$template_args['show_try_pay_again_link'],
831 831
 			'$show_try_pay_again_link'
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 			'$SPCO_payment_options_url'
836 836
 		);
837 837
 		return EEH_Template::locate_template(
838
-			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-transaction-details.template.php',
838
+			THANK_YOU_TEMPLATES_PATH.'thank-you-page-transaction-details.template.php',
839 839
 			$template_args,
840 840
 			true,
841 841
 			true
@@ -852,9 +852,9 @@  discard block
 block discarded – undo
852 852
 	 * @return    string
853 853
 	 * @throws \EE_Error
854 854
 	 */
855
-	public function get_payment_row_html( $payment = null ) {
855
+	public function get_payment_row_html($payment = null) {
856 856
 		$html = '';
857
-		if ( $payment instanceof EE_Payment ) {
857
+		if ($payment instanceof EE_Payment) {
858 858
 			if (
859 859
 				$payment->payment_method() instanceof EE_Payment_Method
860 860
 				&& $payment->status() === EEM_Payment::status_id_failed
@@ -863,31 +863,31 @@  discard block
 block discarded – undo
863 863
 				// considering the registrant has made it to the Thank You page,
864 864
 				// any failed payments may actually be pending and the IPN is just slow
865 865
 				// so let's
866
-				$payment->set_status( EEM_Payment::status_id_pending );
866
+				$payment->set_status(EEM_Payment::status_id_pending);
867 867
 			}
868 868
 			$payment_declined_msg = $payment->STS_ID() === EEM_Payment::status_id_declined
869
-				? '<br /><span class="small-text">' . $payment->gateway_response() . '</span>'
869
+				? '<br /><span class="small-text">'.$payment->gateway_response().'</span>'
870 870
 				: '';
871 871
 			$html .= '
872 872
 				<tr>
873 873
 					<td>
874
-						' . $payment->timestamp() . '
874
+						' . $payment->timestamp().'
875 875
 					</td>
876 876
 					<td>
877 877
 						' . (
878 878
 								$payment->payment_method() instanceof EE_Payment_Method
879 879
 									? $payment->payment_method()->name()
880
-									: __( 'Unknown', 'event_espresso' )
881
-							) . '
880
+									: __('Unknown', 'event_espresso')
881
+							).'
882 882
 					</td>
883 883
 					<td class="jst-rght">
884
-						' . EEH_Template::format_currency( $payment->amount() ) . '
884
+						' . EEH_Template::format_currency($payment->amount()).'
885 885
 					</td>
886 886
 					<td class="jst-rght" style="line-height:1;">
887
-						' . $payment->pretty_status( true ) . $payment_declined_msg . '
887
+						' . $payment->pretty_status(true).$payment_declined_msg.'
888 888
 					</td>
889 889
 				</tr>';
890
-			do_action( 'AHEE__thank_you_page_payment_details_template__after_each_payment', $payment );
890
+			do_action('AHEE__thank_you_page_payment_details_template__after_each_payment', $payment);
891 891
 		}
892 892
 		return $html;
893 893
 	}
@@ -902,14 +902,14 @@  discard block
 block discarded – undo
902 902
 	 * @return    string
903 903
 	 * @throws \EE_Error
904 904
 	 */
905
-	public function get_payment_details( $payments = array() ) {
905
+	public function get_payment_details($payments = array()) {
906 906
 		//prepare variables for displaying
907 907
 		$template_args = array();
908 908
 		$template_args['transaction'] = $this->_current_txn;
909 909
 		$template_args['reg_url_link'] = $this->_reg_url_link;
910 910
 		$template_args['payments'] = array();
911
-		foreach ( $payments as $payment ) {
912
-			$template_args['payments'][] = $this->get_payment_row_html( $payment );
911
+		foreach ($payments as $payment) {
912
+			$template_args['payments'][] = $this->get_payment_row_html($payment);
913 913
 		}
914 914
 		//create a hacky payment object, but dont save it
915 915
 		$payment = EE_Payment::new_instance(
@@ -922,8 +922,8 @@  discard block
 block discarded – undo
922 922
 			)
923 923
 		);
924 924
 		$payment_method = $this->_current_txn->payment_method();
925
-		if ( $payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base ) {
926
-			$template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content( $payment );
925
+		if ($payment_method instanceof EE_Payment_Method && $payment_method->type_obj() instanceof EE_PMT_Base) {
926
+			$template_args['gateway_content'] = $payment_method->type_obj()->payment_overview_content($payment);
927 927
 		} else {
928 928
 			$template_args['gateway_content'] = '';
929 929
 		}
@@ -931,19 +931,19 @@  discard block
 block discarded – undo
931 931
 		$template_args['show_try_pay_again_link'] = $this->_show_try_pay_again_link;
932 932
 		$template_args['SPCO_payment_options_url'] = $this->_SPCO_payment_options_url;
933 933
 		// verify template arguments
934
-		EEH_Template_Validator::verify_instanceof( $template_args['transaction'], '$transaction', 'EE_Transaction' );
935
-		EEH_Template_Validator::verify_isnt_null( $template_args['payments'], '$payments' );
934
+		EEH_Template_Validator::verify_instanceof($template_args['transaction'], '$transaction', 'EE_Transaction');
935
+		EEH_Template_Validator::verify_isnt_null($template_args['payments'], '$payments');
936 936
 		EEH_Template_Validator::verify_isnt_null(
937 937
 			$template_args['show_try_pay_again_link'],
938 938
 			'$show_try_pay_again_link'
939 939
 		);
940
-		EEH_Template_Validator::verify_isnt_null( $template_args['gateway_content'], '$gateway_content' );
940
+		EEH_Template_Validator::verify_isnt_null($template_args['gateway_content'], '$gateway_content');
941 941
 		EEH_Template_Validator::verify_isnt_null(
942 942
 			$template_args['SPCO_payment_options_url'],
943 943
 			'$SPCO_payment_options_url'
944 944
 		);
945 945
 		return EEH_Template::locate_template(
946
-			THANK_YOU_TEMPLATES_PATH . 'thank-you-page-payment-details.template.php',
946
+			THANK_YOU_TEMPLATES_PATH.'thank-you-page-payment-details.template.php',
947 947
 			$template_args,
948 948
 			true,
949 949
 			true
@@ -960,11 +960,11 @@  discard block
 block discarded – undo
960 960
 	 * @return    string
961 961
 	 * @throws \EE_Error
962 962
 	 */
963
-	public function get_new_payments( $payments = array() ) {
963
+	public function get_new_payments($payments = array()) {
964 964
 		$payments_html = '';
965 965
 		//prepare variables for displaying
966
-		foreach ( $payments as $payment ) {
967
-			$payments_html .= $this->get_payment_row_html( $payment );
966
+		foreach ($payments as $payment) {
967
+			$payments_html .= $this->get_payment_row_html($payment);
968 968
 		}
969 969
 		return $payments_html;
970 970
 	}
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Indentation   +1025 added lines, -1025 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\admin_pages\general_settings\AdminOptionsSettings;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('NO direct script access allowed');
5
+	exit('NO direct script access allowed');
6 6
 }
7 7
 
8 8
 /**
@@ -22,1138 +22,1138 @@  discard block
 block discarded – undo
22 22
 {
23 23
     
24 24
     
25
-    /**
26
-     * _question_group
27
-     * holds the specific question group object for the question group details screen
28
-     * @var object
29
-     */
30
-    protected $_question_group;
25
+	/**
26
+	 * _question_group
27
+	 * holds the specific question group object for the question group details screen
28
+	 * @var object
29
+	 */
30
+	protected $_question_group;
31 31
     
32 32
     
33
-    public function __construct($routing = true)
34
-    {
35
-        parent::__construct($routing);
36
-    }
33
+	public function __construct($routing = true)
34
+	{
35
+		parent::__construct($routing);
36
+	}
37 37
     
38 38
     
39
-    protected function _init_page_props()
40
-    {
41
-        $this->page_slug        = GEN_SET_PG_SLUG;
42
-        $this->page_label       = GEN_SET_LABEL;
43
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
44
-        $this->_admin_base_path = GEN_SET_ADMIN;
45
-    }
39
+	protected function _init_page_props()
40
+	{
41
+		$this->page_slug        = GEN_SET_PG_SLUG;
42
+		$this->page_label       = GEN_SET_LABEL;
43
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
44
+		$this->_admin_base_path = GEN_SET_ADMIN;
45
+	}
46 46
     
47 47
     
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
-    }
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
51
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
52
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
53
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
54
+	}
55 55
     
56 56
     
57
-    protected function _define_page_props()
58
-    {
59
-        $this->_admin_page_title = GEN_SET_LABEL;
60
-        $this->_labels           = array(
61
-            'publishbox' => __('Update Settings', 'event_espresso')
62
-        );
63
-    }
57
+	protected function _define_page_props()
58
+	{
59
+		$this->_admin_page_title = GEN_SET_LABEL;
60
+		$this->_labels           = array(
61
+			'publishbox' => __('Update Settings', 'event_espresso')
62
+		);
63
+	}
64 64
     
65 65
     
66
-    protected function _set_page_routes()
67
-    {
68
-        $this->_page_routes = array(
66
+	protected function _set_page_routes()
67
+	{
68
+		$this->_page_routes = array(
69 69
             
70
-            'critical_pages'                => array(
71
-                'func'       => '_espresso_page_settings',
72
-                'capability' => 'manage_options'
73
-            ),
74
-            'update_espresso_page_settings' => array(
75
-                'func'       => '_update_espresso_page_settings',
76
-                'capability' => 'manage_options',
77
-                'noheader'   => true,
78
-            ),
79
-            'default'                       => array(
80
-                'func'       => '_your_organization_settings',
81
-                'capability' => 'manage_options',
82
-            ),
70
+			'critical_pages'                => array(
71
+				'func'       => '_espresso_page_settings',
72
+				'capability' => 'manage_options'
73
+			),
74
+			'update_espresso_page_settings' => array(
75
+				'func'       => '_update_espresso_page_settings',
76
+				'capability' => 'manage_options',
77
+				'noheader'   => true,
78
+			),
79
+			'default'                       => array(
80
+				'func'       => '_your_organization_settings',
81
+				'capability' => 'manage_options',
82
+			),
83 83
             
84
-            'update_your_organization_settings' => array(
85
-                'func'       => '_update_your_organization_settings',
86
-                'capability' => 'manage_options',
87
-                'noheader'   => true,
88
-            ),
84
+			'update_your_organization_settings' => array(
85
+				'func'       => '_update_your_organization_settings',
86
+				'capability' => 'manage_options',
87
+				'noheader'   => true,
88
+			),
89 89
             
90
-            'admin_option_settings' => array(
91
-                'func'       => '_admin_option_settings',
92
-                'capability' => 'manage_options',
93
-            ),
90
+			'admin_option_settings' => array(
91
+				'func'       => '_admin_option_settings',
92
+				'capability' => 'manage_options',
93
+			),
94 94
             
95
-            'update_admin_option_settings' => array(
96
-                'func'       => '_update_admin_option_settings',
97
-                'capability' => 'manage_options',
98
-                'noheader'   => true,
99
-            ),
95
+			'update_admin_option_settings' => array(
96
+				'func'       => '_update_admin_option_settings',
97
+				'capability' => 'manage_options',
98
+				'noheader'   => true,
99
+			),
100 100
             
101
-            'country_settings' => array(
102
-                'func'       => '_country_settings',
103
-                'capability' => 'manage_options'
104
-            ),
101
+			'country_settings' => array(
102
+				'func'       => '_country_settings',
103
+				'capability' => 'manage_options'
104
+			),
105 105
             
106
-            'update_country_settings' => array(
107
-                'func'       => '_update_country_settings',
108
-                'capability' => 'manage_options',
109
-                'noheader'   => true,
110
-            ),
106
+			'update_country_settings' => array(
107
+				'func'       => '_update_country_settings',
108
+				'capability' => 'manage_options',
109
+				'noheader'   => true,
110
+			),
111 111
             
112
-            'display_country_settings' => array(
113
-                'func'       => 'display_country_settings',
114
-                'capability' => 'manage_options',
115
-                'noheader'   => true,
116
-            ),
112
+			'display_country_settings' => array(
113
+				'func'       => 'display_country_settings',
114
+				'capability' => 'manage_options',
115
+				'noheader'   => true,
116
+			),
117 117
             
118
-            'add_new_state' => array(
119
-                'func'       => 'add_new_state',
120
-                'capability' => 'manage_options',
121
-                'noheader'   => true,
122
-            ),
118
+			'add_new_state' => array(
119
+				'func'       => 'add_new_state',
120
+				'capability' => 'manage_options',
121
+				'noheader'   => true,
122
+			),
123 123
             
124
-            'delete_state' => array(
125
-                'func'       => 'delete_state',
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            )
129
-        );
130
-    }
131
-    
132
-    
133
-    protected function _set_page_config()
134
-    {
135
-        $this->_page_config = array(
136
-            'critical_pages'        => array(
137
-                'nav'           => array(
138
-                    'label' => __('Critical Pages', 'event_espresso'),
139
-                    'order' => 50
140
-                ),
141
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
142
-                'help_tabs'     => array(
143
-                    'general_settings_critical_pages_help_tab' => array(
144
-                        'title'    => __('Critical Pages', 'event_espresso'),
145
-                        'filename' => 'general_settings_critical_pages'
146
-                    )
147
-                ),
148
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
149
-                'require_nonce' => false
150
-            ),
151
-            'default'               => array(
152
-                'nav'           => array(
153
-                    'label' => __('Your Organization', 'event_espresso'),
154
-                    'order' => 20
155
-                ),
156
-                'help_tabs'     => array(
157
-                    'general_settings_your_organization_help_tab' => array(
158
-                        'title'    => __('Your Organization', 'event_espresso'),
159
-                        'filename' => 'general_settings_your_organization'
160
-                    )
161
-                ),
162
-                'help_tour'     => array('Your_Organization_Help_Tour'),
163
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164
-                'require_nonce' => false
165
-            ),
166
-            'admin_option_settings' => array(
167
-                'nav'           => array(
168
-                    'label' => __('Admin Options', 'event_espresso'),
169
-                    'order' => 60
170
-                ),
171
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
172
-                'help_tabs'     => array(
173
-                    'general_settings_admin_options_help_tab' => array(
174
-                        'title'    => __('Admin Options', 'event_espresso'),
175
-                        'filename' => 'general_settings_admin_options'
176
-                    )
177
-                ),
178
-                'help_tour'     => array('Admin_Options_Help_Tour'),
179
-                'require_nonce' => false
180
-            ),
181
-            'country_settings'      => array(
182
-                'nav'           => array(
183
-                    'label' => __('Countries', 'event_espresso'),
184
-                    'order' => 70
185
-                ),
186
-                'help_tabs'     => array(
187
-                    'general_settings_countries_help_tab' => array(
188
-                        'title'    => __('Countries', 'event_espresso'),
189
-                        'filename' => 'general_settings_countries'
190
-                    )
191
-                ),
192
-                'help_tour'     => array('Countries_Help_Tour'),
193
-                'require_nonce' => false
194
-            )
195
-        );
196
-    }
197
-    
198
-    
199
-    protected function _add_screen_options()
200
-    {
201
-    }
202
-    
203
-    protected function _add_feature_pointers()
204
-    {
205
-    }
206
-    
207
-    public function load_scripts_styles()
208
-    {
209
-        //styles
210
-        wp_enqueue_style('espresso-ui-theme');
211
-        //scripts
212
-        wp_enqueue_script('ee_admin_js');
213
-    }
214
-    
215
-    public function admin_init()
216
-    {
217
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
218
-            'event_espresso');
219
-        EE_Registry::$i18n_js_strings['error_occurred']          = __('An error occurred! Please refresh the page and try again.',
220
-            'event_espresso');
221
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = __('Are you sure you want to delete this State / Province?',
222
-            'event_espresso');
223
-        $protocol                                                = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
224
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url('admin-ajax.php?page=espresso_general_settings',
225
-            $protocol);
226
-    }
227
-    
228
-    public function admin_notices()
229
-    {
230
-    }
231
-    
232
-    public function admin_footer_scripts()
233
-    {
234
-    }
235
-    
236
-    
237
-    public function load_scripts_styles_default()
238
-    {
239
-        //styles
240
-        wp_enqueue_style('thickbox');
241
-        //scripts
242
-        wp_enqueue_script('media-upload');
243
-        wp_enqueue_script('thickbox');
244
-        wp_register_script('organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js',
245
-            array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, true);
246
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
247
-        wp_enqueue_script('organization_settings');
248
-        wp_enqueue_style('organization-css');
249
-        $confirm_image_delete = array(
250
-            'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.',
251
-                'event_espresso')
252
-        );
253
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
124
+			'delete_state' => array(
125
+				'func'       => 'delete_state',
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			)
129
+		);
130
+	}
131
+    
132
+    
133
+	protected function _set_page_config()
134
+	{
135
+		$this->_page_config = array(
136
+			'critical_pages'        => array(
137
+				'nav'           => array(
138
+					'label' => __('Critical Pages', 'event_espresso'),
139
+					'order' => 50
140
+				),
141
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
142
+				'help_tabs'     => array(
143
+					'general_settings_critical_pages_help_tab' => array(
144
+						'title'    => __('Critical Pages', 'event_espresso'),
145
+						'filename' => 'general_settings_critical_pages'
146
+					)
147
+				),
148
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
149
+				'require_nonce' => false
150
+			),
151
+			'default'               => array(
152
+				'nav'           => array(
153
+					'label' => __('Your Organization', 'event_espresso'),
154
+					'order' => 20
155
+				),
156
+				'help_tabs'     => array(
157
+					'general_settings_your_organization_help_tab' => array(
158
+						'title'    => __('Your Organization', 'event_espresso'),
159
+						'filename' => 'general_settings_your_organization'
160
+					)
161
+				),
162
+				'help_tour'     => array('Your_Organization_Help_Tour'),
163
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164
+				'require_nonce' => false
165
+			),
166
+			'admin_option_settings' => array(
167
+				'nav'           => array(
168
+					'label' => __('Admin Options', 'event_espresso'),
169
+					'order' => 60
170
+				),
171
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
172
+				'help_tabs'     => array(
173
+					'general_settings_admin_options_help_tab' => array(
174
+						'title'    => __('Admin Options', 'event_espresso'),
175
+						'filename' => 'general_settings_admin_options'
176
+					)
177
+				),
178
+				'help_tour'     => array('Admin_Options_Help_Tour'),
179
+				'require_nonce' => false
180
+			),
181
+			'country_settings'      => array(
182
+				'nav'           => array(
183
+					'label' => __('Countries', 'event_espresso'),
184
+					'order' => 70
185
+				),
186
+				'help_tabs'     => array(
187
+					'general_settings_countries_help_tab' => array(
188
+						'title'    => __('Countries', 'event_espresso'),
189
+						'filename' => 'general_settings_countries'
190
+					)
191
+				),
192
+				'help_tour'     => array('Countries_Help_Tour'),
193
+				'require_nonce' => false
194
+			)
195
+		);
196
+	}
197
+    
198
+    
199
+	protected function _add_screen_options()
200
+	{
201
+	}
202
+    
203
+	protected function _add_feature_pointers()
204
+	{
205
+	}
206
+    
207
+	public function load_scripts_styles()
208
+	{
209
+		//styles
210
+		wp_enqueue_style('espresso-ui-theme');
211
+		//scripts
212
+		wp_enqueue_script('ee_admin_js');
213
+	}
214
+    
215
+	public function admin_init()
216
+	{
217
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.',
218
+			'event_espresso');
219
+		EE_Registry::$i18n_js_strings['error_occurred']          = __('An error occurred! Please refresh the page and try again.',
220
+			'event_espresso');
221
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = __('Are you sure you want to delete this State / Province?',
222
+			'event_espresso');
223
+		$protocol                                                = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
224
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url('admin-ajax.php?page=espresso_general_settings',
225
+			$protocol);
226
+	}
227
+    
228
+	public function admin_notices()
229
+	{
230
+	}
231
+    
232
+	public function admin_footer_scripts()
233
+	{
234
+	}
235
+    
236
+    
237
+	public function load_scripts_styles_default()
238
+	{
239
+		//styles
240
+		wp_enqueue_style('thickbox');
241
+		//scripts
242
+		wp_enqueue_script('media-upload');
243
+		wp_enqueue_script('thickbox');
244
+		wp_register_script('organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js',
245
+			array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, true);
246
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
247
+		wp_enqueue_script('organization_settings');
248
+		wp_enqueue_style('organization-css');
249
+		$confirm_image_delete = array(
250
+			'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.',
251
+				'event_espresso')
252
+		);
253
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
254 254
         
255
-    }
256
-    
257
-    public function load_scripts_styles_country_settings()
258
-    {
259
-        //scripts
260
-        wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
261
-            array('ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
262
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
263
-        wp_enqueue_script('gen_settings_countries');
264
-        wp_enqueue_style('organization-css');
255
+	}
256
+    
257
+	public function load_scripts_styles_country_settings()
258
+	{
259
+		//scripts
260
+		wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
261
+			array('ee_admin_js'), EVENT_ESPRESSO_VERSION, true);
262
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
263
+		wp_enqueue_script('gen_settings_countries');
264
+		wp_enqueue_style('organization-css');
265 265
         
266
-    }
267
-    
268
-    
269
-    /*************        Espresso Pages        *************/
270
-    /**
271
-     * _espresso_page_settings
272
-     *
273
-     * @throws \EE_Error
274
-     */
275
-    protected function _espresso_page_settings()
276
-    {
277
-        // Check to make sure all of the main pages are setup properly,
278
-        // if not create the default pages and display an admin notice
279
-        EEH_Activation::verify_default_pages_exist();
280
-        $this->_transient_garbage_collection();
281
-        $this->_template_args['values']             = $this->_yes_no_values;
282
-        $this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
283
-            ? EE_Registry::instance()->CFG->core->reg_page_id
284
-            : null;
285
-        $this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
286
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
287
-            : false;
288
-        $this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
289
-            ? EE_Registry::instance()->CFG->core->txn_page_id
290
-            : null;
291
-        $this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
292
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
293
-            : false;
294
-        $this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
295
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
296
-            : null;
297
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
298
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
299
-            : false;
300
-        $this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
301
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
302
-            : null;
303
-        $this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
304
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
305
-            : false;
306
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
307
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
308
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
309
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
310
-            $this->_template_args,
311
-            true
312
-        );
313
-        $this->display_admin_page_with_sidebar();
266
+	}
267
+    
268
+    
269
+	/*************        Espresso Pages        *************/
270
+	/**
271
+	 * _espresso_page_settings
272
+	 *
273
+	 * @throws \EE_Error
274
+	 */
275
+	protected function _espresso_page_settings()
276
+	{
277
+		// Check to make sure all of the main pages are setup properly,
278
+		// if not create the default pages and display an admin notice
279
+		EEH_Activation::verify_default_pages_exist();
280
+		$this->_transient_garbage_collection();
281
+		$this->_template_args['values']             = $this->_yes_no_values;
282
+		$this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
283
+			? EE_Registry::instance()->CFG->core->reg_page_id
284
+			: null;
285
+		$this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
286
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
287
+			: false;
288
+		$this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
289
+			? EE_Registry::instance()->CFG->core->txn_page_id
290
+			: null;
291
+		$this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
292
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
293
+			: false;
294
+		$this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
295
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
296
+			: null;
297
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
298
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
299
+			: false;
300
+		$this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
301
+			? EE_Registry::instance()->CFG->core->cancel_page_id
302
+			: null;
303
+		$this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
304
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
305
+			: false;
306
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
307
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
308
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
309
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
310
+			$this->_template_args,
311
+			true
312
+		);
313
+		$this->display_admin_page_with_sidebar();
314 314
         
315
-    }
316
-    
317
-    protected function _update_espresso_page_settings()
318
-    {
319
-        // capture incoming request data
320
-        $reg_page_id       = isset($this->_req_data['reg_page_id']) ? absint($this->_req_data['reg_page_id']) : EE_Registry::instance()->CFG->core->reg_page_id;
321
-        $txn_page_id       = isset($this->_req_data['txn_page_id']) ? absint($this->_req_data['txn_page_id']) : EE_Registry::instance()->CFG->core->txn_page_id;
322
-        $thank_you_page_id = isset($this->_req_data['thank_you_page_id']) ? absint($this->_req_data['thank_you_page_id']) : EE_Registry::instance()->CFG->core->thank_you_page_id;
323
-        $cancel_page_id    = isset($this->_req_data['cancel_page_id']) ? absint($this->_req_data['cancel_page_id']) : EE_Registry::instance()->CFG->core->cancel_page_id;
324
-        // pack critical_pages into an array
325
-        $critical_pages = array(
326
-            'reg_page_id'       => $reg_page_id,
327
-            'txn_page_id'       => $txn_page_id,
328
-            'thank_you_page_id' => $thank_you_page_id,
329
-            'cancel_page_id'    => $cancel_page_id
330
-        );
331
-        foreach ($critical_pages as $critical_page_name => $critical_page_id) {
332
-            // has the page changed ?
333
-            if (EE_Registry::instance()->CFG->core->{$critical_page_name} !== $critical_page_id) {
334
-                // grab post object for old page
335
-                $post = get_post(EE_Registry::instance()->CFG->core->{$critical_page_name});
336
-                // update post shortcodes for old page
337
-                EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($critical_page_id, $post);
338
-                // grab post object for new page
339
-                $post = get_post($critical_page_id);
340
-                // update post shortcodes for new page
341
-                EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($critical_page_id, $post);
342
-            }
343
-        }
344
-        // set page IDs
345
-        EE_Registry::instance()->CFG->core->reg_page_id       = $reg_page_id;
346
-        EE_Registry::instance()->CFG->core->txn_page_id       = $txn_page_id;
347
-        EE_Registry::instance()->CFG->core->thank_you_page_id = $thank_you_page_id;
348
-        EE_Registry::instance()->CFG->core->cancel_page_id    = $cancel_page_id;
315
+	}
316
+    
317
+	protected function _update_espresso_page_settings()
318
+	{
319
+		// capture incoming request data
320
+		$reg_page_id       = isset($this->_req_data['reg_page_id']) ? absint($this->_req_data['reg_page_id']) : EE_Registry::instance()->CFG->core->reg_page_id;
321
+		$txn_page_id       = isset($this->_req_data['txn_page_id']) ? absint($this->_req_data['txn_page_id']) : EE_Registry::instance()->CFG->core->txn_page_id;
322
+		$thank_you_page_id = isset($this->_req_data['thank_you_page_id']) ? absint($this->_req_data['thank_you_page_id']) : EE_Registry::instance()->CFG->core->thank_you_page_id;
323
+		$cancel_page_id    = isset($this->_req_data['cancel_page_id']) ? absint($this->_req_data['cancel_page_id']) : EE_Registry::instance()->CFG->core->cancel_page_id;
324
+		// pack critical_pages into an array
325
+		$critical_pages = array(
326
+			'reg_page_id'       => $reg_page_id,
327
+			'txn_page_id'       => $txn_page_id,
328
+			'thank_you_page_id' => $thank_you_page_id,
329
+			'cancel_page_id'    => $cancel_page_id
330
+		);
331
+		foreach ($critical_pages as $critical_page_name => $critical_page_id) {
332
+			// has the page changed ?
333
+			if (EE_Registry::instance()->CFG->core->{$critical_page_name} !== $critical_page_id) {
334
+				// grab post object for old page
335
+				$post = get_post(EE_Registry::instance()->CFG->core->{$critical_page_name});
336
+				// update post shortcodes for old page
337
+				EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($critical_page_id, $post);
338
+				// grab post object for new page
339
+				$post = get_post($critical_page_id);
340
+				// update post shortcodes for new page
341
+				EventEspresso\core\admin\PostShortcodeTracking::parse_post_content_on_save($critical_page_id, $post);
342
+			}
343
+		}
344
+		// set page IDs
345
+		EE_Registry::instance()->CFG->core->reg_page_id       = $reg_page_id;
346
+		EE_Registry::instance()->CFG->core->txn_page_id       = $txn_page_id;
347
+		EE_Registry::instance()->CFG->core->thank_you_page_id = $thank_you_page_id;
348
+		EE_Registry::instance()->CFG->core->cancel_page_id    = $cancel_page_id;
349 349
         
350
-        EE_Registry::instance()->CFG->core = apply_filters('FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
351
-            EE_Registry::instance()->CFG->core, $this->_req_data);
350
+		EE_Registry::instance()->CFG->core = apply_filters('FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
351
+			EE_Registry::instance()->CFG->core, $this->_req_data);
352 352
         
353
-        $what       = __('Critical Pages & Shortcodes', 'event_espresso');
354
-        $success    = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->core, __FILE__,
355
-            __FUNCTION__, __LINE__);
356
-        $query_args = array(
357
-            'action' => 'critical_pages'
358
-        );
359
-        $this->_redirect_after_action(false, '', '', $query_args, true);
353
+		$what       = __('Critical Pages & Shortcodes', 'event_espresso');
354
+		$success    = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->core, __FILE__,
355
+			__FUNCTION__, __LINE__);
356
+		$query_args = array(
357
+			'action' => 'critical_pages'
358
+		);
359
+		$this->_redirect_after_action(false, '', '', $query_args, true);
360 360
         
361
-    }
361
+	}
362 362
     
363 363
     
364
-    /*************        Your Organization        *************/
364
+	/*************        Your Organization        *************/
365 365
     
366 366
     
367
-    protected function _your_organization_settings()
368
-    {
367
+	protected function _your_organization_settings()
368
+	{
369 369
         
370
-        $this->_template_args['site_license_key']       = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : '';
371
-        $this->_template_args['organization_name']      = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : '';
372
-        $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : '';
373
-        $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : '';
374
-        $this->_template_args['organization_city']      = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : '';
375
-        $this->_template_args['organization_zip']       = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : '';
376
-        $this->_template_args['organization_email']     = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : '';
377
-        $this->_template_args['organization_phone']     = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : '';
378
-        $this->_template_args['organization_vat']       = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : '';
379
-        $this->_template_args['currency_sign']          = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$';
380
-        $this->_template_args['organization_logo_url']  = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : false;
381
-        $this->_template_args['organization_facebook']  = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : '';
382
-        $this->_template_args['organization_twitter']   = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : '';
383
-        $this->_template_args['organization_linkedin']  = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : '';
384
-        $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : '';
385
-        $this->_template_args['organization_google']    = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : '';
386
-        $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : '';
387
-        //UXIP settings
388
-        $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : true;
370
+		$this->_template_args['site_license_key']       = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : '';
371
+		$this->_template_args['organization_name']      = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : '';
372
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : '';
373
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : '';
374
+		$this->_template_args['organization_city']      = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : '';
375
+		$this->_template_args['organization_zip']       = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : '';
376
+		$this->_template_args['organization_email']     = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : '';
377
+		$this->_template_args['organization_phone']     = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : '';
378
+		$this->_template_args['organization_vat']       = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : '';
379
+		$this->_template_args['currency_sign']          = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$';
380
+		$this->_template_args['organization_logo_url']  = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : false;
381
+		$this->_template_args['organization_facebook']  = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : '';
382
+		$this->_template_args['organization_twitter']   = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : '';
383
+		$this->_template_args['organization_linkedin']  = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : '';
384
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : '';
385
+		$this->_template_args['organization_google']    = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : '';
386
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : '';
387
+		//UXIP settings
388
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : true;
389 389
         
390
-        $STA_ID                         = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
391
-        $this->_template_args['states'] = new EE_Question_Form_Input(
392
-            EE_Question::new_instance(array(
393
-                'QST_ID'           => 0,
394
-                'QST_display_text' => __('State/Province', 'event_espresso'),
395
-                'QST_system'       => 'admin-state'
396
-            )),
397
-            EE_Answer::new_instance(array(
398
-                'ANS_ID'    => 0,
399
-                'ANS_value' => $STA_ID
400
-            )),
401
-            array(
402
-                'input_id'       => 'organization_state',
403
-                'input_name'     => 'organization_state',
404
-                'input_prefix'   => '',
405
-                'append_qstn_id' => false
406
-            )
407
-        );
390
+		$STA_ID                         = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
391
+		$this->_template_args['states'] = new EE_Question_Form_Input(
392
+			EE_Question::new_instance(array(
393
+				'QST_ID'           => 0,
394
+				'QST_display_text' => __('State/Province', 'event_espresso'),
395
+				'QST_system'       => 'admin-state'
396
+			)),
397
+			EE_Answer::new_instance(array(
398
+				'ANS_ID'    => 0,
399
+				'ANS_value' => $STA_ID
400
+			)),
401
+			array(
402
+				'input_id'       => 'organization_state',
403
+				'input_name'     => 'organization_state',
404
+				'input_prefix'   => '',
405
+				'append_qstn_id' => false
406
+			)
407
+		);
408 408
         
409
-        $CNT_ISO                           = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
410
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
411
-            EE_Question::new_instance(array(
412
-                'QST_ID'           => 0,
413
-                'QST_display_text' => __('Country', 'event_espresso'),
414
-                'QST_system'       => 'admin-country'
415
-            )),
416
-            EE_Answer::new_instance(array(
417
-                'ANS_ID'    => 0,
418
-                'ANS_value' => $CNT_ISO
419
-            )),
420
-            array(
421
-                'input_id'       => 'organization_country',
422
-                'input_name'     => 'organization_country',
423
-                'input_prefix'   => '',
424
-                'append_qstn_id' => false
425
-            )
426
-        );
409
+		$CNT_ISO                           = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
410
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
411
+			EE_Question::new_instance(array(
412
+				'QST_ID'           => 0,
413
+				'QST_display_text' => __('Country', 'event_espresso'),
414
+				'QST_system'       => 'admin-country'
415
+			)),
416
+			EE_Answer::new_instance(array(
417
+				'ANS_ID'    => 0,
418
+				'ANS_value' => $CNT_ISO
419
+			)),
420
+			array(
421
+				'input_id'       => 'organization_country',
422
+				'input_name'     => 'organization_country',
423
+				'input_prefix'   => '',
424
+				'append_qstn_id' => false
425
+			)
426
+		);
427 427
         
428
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
429
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
428
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
429
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
430 430
         
431
-        //PUE verification stuff
432
-        $ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
433
-        $verify_fail                                       = get_option($ver_option_key);
434
-        $this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
431
+		//PUE verification stuff
432
+		$ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
433
+		$verify_fail                                       = get_option($ver_option_key);
434
+		$this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
435 435
         
436
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
437
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
438
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
439
-            $this->_template_args, true);
436
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
437
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
438
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
439
+			$this->_template_args, true);
440 440
         
441
-        $this->display_admin_page_with_sidebar();
442
-    }
443
-    
444
-    protected function _update_your_organization_settings()
445
-    {
446
-        if (is_main_site()) {
447
-            EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key;
448
-        }
449
-        EE_Registry::instance()->CFG->organization->name      = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name;
450
-        EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1;
451
-        EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2;
452
-        EE_Registry::instance()->CFG->organization->city      = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city;
453
-        EE_Registry::instance()->CFG->organization->STA_ID    = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID;
454
-        EE_Registry::instance()->CFG->organization->CNT_ISO   = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO;
455
-        EE_Registry::instance()->CFG->organization->zip       = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip;
456
-        EE_Registry::instance()->CFG->organization->email     = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email;
457
-        EE_Registry::instance()->CFG->organization->vat       = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat;
458
-        EE_Registry::instance()->CFG->organization->phone     = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone;
459
-        EE_Registry::instance()->CFG->organization->logo_url  = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url;
460
-        EE_Registry::instance()->CFG->organization->facebook  = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook;
461
-        EE_Registry::instance()->CFG->organization->twitter   = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter;
462
-        EE_Registry::instance()->CFG->organization->linkedin  = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin;
463
-        EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest;
464
-        EE_Registry::instance()->CFG->organization->google    = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google;
465
-        EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram;
466
-        EE_Registry::instance()->CFG->core->ee_ueip_optin     = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
441
+		$this->display_admin_page_with_sidebar();
442
+	}
443
+    
444
+	protected function _update_your_organization_settings()
445
+	{
446
+		if (is_main_site()) {
447
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key;
448
+		}
449
+		EE_Registry::instance()->CFG->organization->name      = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name;
450
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1;
451
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2;
452
+		EE_Registry::instance()->CFG->organization->city      = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city;
453
+		EE_Registry::instance()->CFG->organization->STA_ID    = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID;
454
+		EE_Registry::instance()->CFG->organization->CNT_ISO   = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO;
455
+		EE_Registry::instance()->CFG->organization->zip       = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip;
456
+		EE_Registry::instance()->CFG->organization->email     = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email;
457
+		EE_Registry::instance()->CFG->organization->vat       = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat;
458
+		EE_Registry::instance()->CFG->organization->phone     = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone;
459
+		EE_Registry::instance()->CFG->organization->logo_url  = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url;
460
+		EE_Registry::instance()->CFG->organization->facebook  = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook;
461
+		EE_Registry::instance()->CFG->organization->twitter   = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter;
462
+		EE_Registry::instance()->CFG->organization->linkedin  = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin;
463
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest;
464
+		EE_Registry::instance()->CFG->organization->google    = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google;
465
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram;
466
+		EE_Registry::instance()->CFG->core->ee_ueip_optin     = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
467 467
         
468
-        EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO);
468
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO);
469 469
         
470
-        EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
471
-            EE_Registry::instance()->CFG);
470
+		EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
471
+			EE_Registry::instance()->CFG);
472 472
         
473
-        $what    = 'Your Organization Settings';
474
-        $success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__,
475
-            __LINE__);
473
+		$what    = 'Your Organization Settings';
474
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__,
475
+			__LINE__);
476 476
         
477
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
477
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
478 478
         
479
-    }
480
-    
481
-    
482
-    
483
-    /*************        Admin Options        *************/
484
-    
485
-    
486
-    /**
487
-     * _admin_option_settings
488
-     *
489
-     * @throws \EE_Error
490
-     * @throws \LogicException
491
-     */
492
-    protected function _admin_option_settings()
493
-    {
494
-        $this->_template_args['admin_page_content'] = '';
495
-        try {
496
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
497
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
498
-            $this->_template_args['values'] = $this->_yes_no_values;
499
-            // also need to account for the do_action that was in the old template
500
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
501
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
502
-        } catch (Exception $e) {
503
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
504
-        }
505
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
506
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
507
-        $this->display_admin_page_with_sidebar();
508
-    }
509
-    
510
-    
511
-    /**
512
-     * _update_admin_option_settings
513
-     *
514
-     * @throws \EE_Error
515
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
516
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
517
-     * @throws \InvalidArgumentException
518
-     * @throws \LogicException
519
-     */
520
-    protected function _update_admin_option_settings()
521
-    {
522
-        try {
523
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
524
-            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
525
-            EE_Registry::instance()->CFG->admin = apply_filters(
526
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
527
-                EE_Registry::instance()->CFG->admin
528
-            );
529
-        } catch (Exception $e) {
530
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
531
-        }
532
-        $this->_redirect_after_action(
533
-            apply_filters(
534
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
535
-                $this->_update_espresso_configuration(
536
-                    'Admin Options',
537
-                    EE_Registry::instance()->CFG->admin,
538
-                    __FILE__, __FUNCTION__, __LINE__
539
-                )
540
-            ),
541
-            'Admin Options',
542
-            'updated',
543
-            array('action' => 'admin_option_settings')
544
-        );
479
+	}
480
+    
481
+    
482
+    
483
+	/*************        Admin Options        *************/
484
+    
485
+    
486
+	/**
487
+	 * _admin_option_settings
488
+	 *
489
+	 * @throws \EE_Error
490
+	 * @throws \LogicException
491
+	 */
492
+	protected function _admin_option_settings()
493
+	{
494
+		$this->_template_args['admin_page_content'] = '';
495
+		try {
496
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
497
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
498
+			$this->_template_args['values'] = $this->_yes_no_values;
499
+			// also need to account for the do_action that was in the old template
500
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
501
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
502
+		} catch (Exception $e) {
503
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
504
+		}
505
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
506
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
507
+		$this->display_admin_page_with_sidebar();
508
+	}
509
+    
510
+    
511
+	/**
512
+	 * _update_admin_option_settings
513
+	 *
514
+	 * @throws \EE_Error
515
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
516
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
517
+	 * @throws \InvalidArgumentException
518
+	 * @throws \LogicException
519
+	 */
520
+	protected function _update_admin_option_settings()
521
+	{
522
+		try {
523
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
524
+			$admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
525
+			EE_Registry::instance()->CFG->admin = apply_filters(
526
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
527
+				EE_Registry::instance()->CFG->admin
528
+			);
529
+		} catch (Exception $e) {
530
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
531
+		}
532
+		$this->_redirect_after_action(
533
+			apply_filters(
534
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
535
+				$this->_update_espresso_configuration(
536
+					'Admin Options',
537
+					EE_Registry::instance()->CFG->admin,
538
+					__FILE__, __FUNCTION__, __LINE__
539
+				)
540
+			),
541
+			'Admin Options',
542
+			'updated',
543
+			array('action' => 'admin_option_settings')
544
+		);
545 545
         
546
-    }
546
+	}
547 547
     
548 548
     
549
-    /*************        Countries        *************/
549
+	/*************        Countries        *************/
550 550
     
551 551
     
552
-    protected function _country_settings()
553
-    {
552
+	protected function _country_settings()
553
+	{
554 554
         
555
-        $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
556
-        $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
555
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
556
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
557 557
         
558
-        //load field generator helper
558
+		//load field generator helper
559 559
         
560
-        $this->_template_args['values'] = $this->_yes_no_values;
560
+		$this->_template_args['values'] = $this->_yes_no_values;
561 561
         
562
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
563
-            EE_Question::new_instance(array(
564
-                'QST_ID'           => 0,
565
-                'QST_display_text' => __('Select Country', 'event_espresso'),
566
-                'QST_system'       => 'admin-country'
567
-            )),
568
-            EE_Answer::new_instance(array(
569
-                'ANS_ID'    => 0,
570
-                'ANS_value' => $CNT_ISO
571
-            )),
572
-            array(
573
-                'input_id'       => 'country',
574
-                'input_name'     => 'country',
575
-                'input_prefix'   => '',
576
-                'append_qstn_id' => false
577
-            )
578
-        );
562
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
563
+			EE_Question::new_instance(array(
564
+				'QST_ID'           => 0,
565
+				'QST_display_text' => __('Select Country', 'event_espresso'),
566
+				'QST_system'       => 'admin-country'
567
+			)),
568
+			EE_Answer::new_instance(array(
569
+				'ANS_ID'    => 0,
570
+				'ANS_value' => $CNT_ISO
571
+			)),
572
+			array(
573
+				'input_id'       => 'country',
574
+				'input_name'     => 'country',
575
+				'input_prefix'   => '',
576
+				'append_qstn_id' => false
577
+			)
578
+		);
579 579
 //		EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
580 580
         
581
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
582
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
583
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
584
-        $this->_template_args['country_states_settings']  = $this->display_country_states();
581
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
582
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
583
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
584
+		$this->_template_args['country_states_settings']  = $this->display_country_states();
585 585
         
586
-        $this->_set_add_edit_form_tags('update_country_settings');
587
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
588
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
589
-            $this->_template_args, true);
590
-        $this->display_admin_page_with_no_sidebar();
591
-    }
592
-    
593
-    
594
-    /**
595
-     *        display_country_settings
596
-     *
597
-     * @access    public
598
-     *
599
-     * @param    string $CNT_ISO
600
-     *
601
-     * @return        mixed        string | array
602
-     */
603
-    public function display_country_settings($CNT_ISO = '')
604
-    {
586
+		$this->_set_add_edit_form_tags('update_country_settings');
587
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
588
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
589
+			$this->_template_args, true);
590
+		$this->display_admin_page_with_no_sidebar();
591
+	}
592
+    
593
+    
594
+	/**
595
+	 *        display_country_settings
596
+	 *
597
+	 * @access    public
598
+	 *
599
+	 * @param    string $CNT_ISO
600
+	 *
601
+	 * @return        mixed        string | array
602
+	 */
603
+	public function display_country_settings($CNT_ISO = '')
604
+	{
605 605
         
606
-        $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
607
-        if ( ! $CNT_ISO) {
608
-            return '';
609
-        }
606
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
607
+		if ( ! $CNT_ISO) {
608
+			return '';
609
+		}
610 610
         
611
-        // for ajax
612
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
613
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
614
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
615
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
616
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
617
-        //EEH_Debug_Tools::printr( $country, '$country  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
618
-        $country_input_types            = array(
619
-            'CNT_active'      => array(
620
-                'type'             => 'RADIO_BTN',
621
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
622
-                'class'            => '',
623
-                'options'          => $this->_yes_no_values,
624
-                'use_desc_4_label' => true
625
-            ),
626
-            'CNT_ISO'         => array(
627
-                'type'       => 'TEXT',
628
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
629
-                'class'      => 'small-text'
630
-            ),
631
-            'CNT_ISO3'        => array(
632
-                'type'       => 'TEXT',
633
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
634
-                'class'      => 'small-text'
635
-            ),
636
-            'RGN_ID'          => array(
637
-                'type'       => 'TEXT',
638
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
639
-                'class'      => 'small-text'
640
-            ),
641
-            'CNT_name'        => array(
642
-                'type'       => 'TEXT',
643
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
644
-                'class'      => 'regular-text'
645
-            ),
646
-            'CNT_cur_code'    => array(
647
-                'type'       => 'TEXT',
648
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
649
-                'class'      => 'small-text'
650
-            ),
651
-            'CNT_cur_single'  => array(
652
-                'type'       => 'TEXT',
653
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
654
-                'class'      => 'medium-text'
655
-            ),
656
-            'CNT_cur_plural'  => array(
657
-                'type'       => 'TEXT',
658
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
659
-                'class'      => 'medium-text'
660
-            ),
661
-            'CNT_cur_sign'    => array(
662
-                'type'         => 'TEXT',
663
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
664
-                'class'        => 'small-text',
665
-                'htmlentities' => false
666
-            ),
667
-            'CNT_cur_sign_b4' => array(
668
-                'type'             => 'RADIO_BTN',
669
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
670
-                'class'            => '',
671
-                'options'          => $this->_yes_no_values,
672
-                'use_desc_4_label' => true
673
-            ),
674
-            'CNT_cur_dec_plc' => array(
675
-                'type'       => 'RADIO_BTN',
676
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
677
-                'class'      => '',
678
-                'options'    => array(
679
-                    array('id' => 0, 'text' => ''),
680
-                    array('id' => 1, 'text' => ''),
681
-                    array('id' => 2, 'text' => ''),
682
-                    array('id' => 3, 'text' => '')
683
-                )
684
-            ),
685
-            'CNT_cur_dec_mrk' => array(
686
-                'type'             => 'RADIO_BTN',
687
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
688
-                'class'            => '',
689
-                'options'          => array(
690
-                    array(
691
-                        'id'   => ',',
692
-                        'text' => __(', (comma)', 'event_espresso')
693
-                    ),
694
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))
695
-                ),
696
-                'use_desc_4_label' => true
697
-            ),
698
-            'CNT_cur_thsnds'  => array(
699
-                'type'             => 'RADIO_BTN',
700
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
701
-                'class'            => '',
702
-                'options'          => array(
703
-                    array(
704
-                        'id'   => ',',
705
-                        'text' => __(', (comma)', 'event_espresso')
706
-                    ),
707
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))
708
-                ),
709
-                'use_desc_4_label' => true
710
-            ),
711
-            'CNT_tel_code'    => array(
712
-                'type'       => 'TEXT',
713
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
714
-                'class'      => 'small-text'
715
-            ),
716
-            'CNT_is_EU'       => array(
717
-                'type'             => 'RADIO_BTN',
718
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
719
-                'class'            => '',
720
-                'options'          => $this->_yes_no_values,
721
-                'use_desc_4_label' => true
722
-            )
723
-        );
724
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country,
725
-            $country_input_types);
726
-        $country_details_settings       = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
727
-            $this->_template_args, true);
611
+		// for ajax
612
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
613
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
614
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
615
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
616
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
617
+		//EEH_Debug_Tools::printr( $country, '$country  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
618
+		$country_input_types            = array(
619
+			'CNT_active'      => array(
620
+				'type'             => 'RADIO_BTN',
621
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
622
+				'class'            => '',
623
+				'options'          => $this->_yes_no_values,
624
+				'use_desc_4_label' => true
625
+			),
626
+			'CNT_ISO'         => array(
627
+				'type'       => 'TEXT',
628
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
629
+				'class'      => 'small-text'
630
+			),
631
+			'CNT_ISO3'        => array(
632
+				'type'       => 'TEXT',
633
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
634
+				'class'      => 'small-text'
635
+			),
636
+			'RGN_ID'          => array(
637
+				'type'       => 'TEXT',
638
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
639
+				'class'      => 'small-text'
640
+			),
641
+			'CNT_name'        => array(
642
+				'type'       => 'TEXT',
643
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
644
+				'class'      => 'regular-text'
645
+			),
646
+			'CNT_cur_code'    => array(
647
+				'type'       => 'TEXT',
648
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
649
+				'class'      => 'small-text'
650
+			),
651
+			'CNT_cur_single'  => array(
652
+				'type'       => 'TEXT',
653
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
654
+				'class'      => 'medium-text'
655
+			),
656
+			'CNT_cur_plural'  => array(
657
+				'type'       => 'TEXT',
658
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
659
+				'class'      => 'medium-text'
660
+			),
661
+			'CNT_cur_sign'    => array(
662
+				'type'         => 'TEXT',
663
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
664
+				'class'        => 'small-text',
665
+				'htmlentities' => false
666
+			),
667
+			'CNT_cur_sign_b4' => array(
668
+				'type'             => 'RADIO_BTN',
669
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
670
+				'class'            => '',
671
+				'options'          => $this->_yes_no_values,
672
+				'use_desc_4_label' => true
673
+			),
674
+			'CNT_cur_dec_plc' => array(
675
+				'type'       => 'RADIO_BTN',
676
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
677
+				'class'      => '',
678
+				'options'    => array(
679
+					array('id' => 0, 'text' => ''),
680
+					array('id' => 1, 'text' => ''),
681
+					array('id' => 2, 'text' => ''),
682
+					array('id' => 3, 'text' => '')
683
+				)
684
+			),
685
+			'CNT_cur_dec_mrk' => array(
686
+				'type'             => 'RADIO_BTN',
687
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
688
+				'class'            => '',
689
+				'options'          => array(
690
+					array(
691
+						'id'   => ',',
692
+						'text' => __(', (comma)', 'event_espresso')
693
+					),
694
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))
695
+				),
696
+				'use_desc_4_label' => true
697
+			),
698
+			'CNT_cur_thsnds'  => array(
699
+				'type'             => 'RADIO_BTN',
700
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
701
+				'class'            => '',
702
+				'options'          => array(
703
+					array(
704
+						'id'   => ',',
705
+						'text' => __(', (comma)', 'event_espresso')
706
+					),
707
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))
708
+				),
709
+				'use_desc_4_label' => true
710
+			),
711
+			'CNT_tel_code'    => array(
712
+				'type'       => 'TEXT',
713
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
714
+				'class'      => 'small-text'
715
+			),
716
+			'CNT_is_EU'       => array(
717
+				'type'             => 'RADIO_BTN',
718
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
719
+				'class'            => '',
720
+				'options'          => $this->_yes_no_values,
721
+				'use_desc_4_label' => true
722
+			)
723
+		);
724
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country,
725
+			$country_input_types);
726
+		$country_details_settings       = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
727
+			$this->_template_args, true);
728 728
         
729
-        if (defined('DOING_AJAX')) {
730
-            $notices = EE_Error::get_notices(false, false, false);
731
-            echo wp_json_encode(array(
732
-                'return_data' => $country_details_settings,
733
-                'success'     => $notices['success'],
734
-                'errors'      => $notices['errors']
735
-            ));
736
-            die();
737
-        } else {
738
-            return $country_details_settings;
739
-        }
729
+		if (defined('DOING_AJAX')) {
730
+			$notices = EE_Error::get_notices(false, false, false);
731
+			echo wp_json_encode(array(
732
+				'return_data' => $country_details_settings,
733
+				'success'     => $notices['success'],
734
+				'errors'      => $notices['errors']
735
+			));
736
+			die();
737
+		} else {
738
+			return $country_details_settings;
739
+		}
740 740
         
741
-    }
742
-    
743
-    
744
-    /**
745
-     *        display_country_states
746
-     *
747
-     * @access    public
748
-     *
749
-     * @param    string $CNT_ISO
750
-     *
751
-     * @return        string
752
-     */
753
-    public function display_country_states($CNT_ISO = '')
754
-    {
741
+	}
742
+    
743
+    
744
+	/**
745
+	 *        display_country_states
746
+	 *
747
+	 * @access    public
748
+	 *
749
+	 * @param    string $CNT_ISO
750
+	 *
751
+	 * @return        string
752
+	 */
753
+	public function display_country_states($CNT_ISO = '')
754
+	{
755 755
         
756
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
756
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
757 757
         
758
-        if ( ! $CNT_ISO) {
759
-            return '';
760
-        }
761
-        // for ajax
762
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
763
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
764
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
765
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
766
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
758
+		if ( ! $CNT_ISO) {
759
+			return '';
760
+		}
761
+		// for ajax
762
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
763
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
764
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
765
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
766
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
767 767
 
768 768
 //			echo '<h4>$CNT_ISO : ' . $CNT_ISO . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
769 769
 //			global $wpdb;
770 770
 //			echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
771 771
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
772
-        if ($states) {
773
-            foreach ($states as $STA_ID => $state) {
774
-                if ($state instanceof EE_State) {
775
-                    //STA_abbrev 	STA_name 	STA_active
776
-                    $state_input_types                                           = array(
777
-                        'STA_abbrev' => array(
778
-                            'type'       => 'TEXT',
779
-                            'input_name' => 'states[' . $STA_ID . ']',
780
-                            'class'      => 'mid-text'
781
-                        ),
782
-                        'STA_name'   => array(
783
-                            'type'       => 'TEXT',
784
-                            'input_name' => 'states[' . $STA_ID . ']',
785
-                            'class'      => 'regular-text'
786
-                        ),
787
-                        'STA_active' => array(
788
-                            'type'             => 'RADIO_BTN',
789
-                            'input_name'       => 'states[' . $STA_ID . ']',
790
-                            'options'          => $this->_yes_no_values,
791
-                            'use_desc_4_label' => true
792
-                        )
793
-                    );
794
-                    $this->_template_args['states'][$STA_ID]['inputs']           = EE_Question_Form_Input::generate_question_form_inputs_for_object($state,
795
-                        $state_input_types);
796
-                    $query_args                                                  = array(
797
-                        'action'     => 'delete_state',
798
-                        'STA_ID'     => $STA_ID,
799
-                        'CNT_ISO'    => $CNT_ISO,
800
-                        'STA_abbrev' => $state->abbrev()
801
-                    );
802
-                    $this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args,
803
-                        GEN_SET_ADMIN_URL);
804
-                }
805
-            }
806
-        } else {
807
-            $this->_template_args['states'] = false;
808
-        }
772
+		if ($states) {
773
+			foreach ($states as $STA_ID => $state) {
774
+				if ($state instanceof EE_State) {
775
+					//STA_abbrev 	STA_name 	STA_active
776
+					$state_input_types                                           = array(
777
+						'STA_abbrev' => array(
778
+							'type'       => 'TEXT',
779
+							'input_name' => 'states[' . $STA_ID . ']',
780
+							'class'      => 'mid-text'
781
+						),
782
+						'STA_name'   => array(
783
+							'type'       => 'TEXT',
784
+							'input_name' => 'states[' . $STA_ID . ']',
785
+							'class'      => 'regular-text'
786
+						),
787
+						'STA_active' => array(
788
+							'type'             => 'RADIO_BTN',
789
+							'input_name'       => 'states[' . $STA_ID . ']',
790
+							'options'          => $this->_yes_no_values,
791
+							'use_desc_4_label' => true
792
+						)
793
+					);
794
+					$this->_template_args['states'][$STA_ID]['inputs']           = EE_Question_Form_Input::generate_question_form_inputs_for_object($state,
795
+						$state_input_types);
796
+					$query_args                                                  = array(
797
+						'action'     => 'delete_state',
798
+						'STA_ID'     => $STA_ID,
799
+						'CNT_ISO'    => $CNT_ISO,
800
+						'STA_abbrev' => $state->abbrev()
801
+					);
802
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args,
803
+						GEN_SET_ADMIN_URL);
804
+				}
805
+			}
806
+		} else {
807
+			$this->_template_args['states'] = false;
808
+		}
809 809
 //		EEH_Debug_Tools::printr( $this->_template_args['states'], 'states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
810
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'),
811
-            GEN_SET_ADMIN_URL);
810
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'),
811
+			GEN_SET_ADMIN_URL);
812 812
         
813
-        $state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
814
-            $this->_template_args, true);
813
+		$state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
814
+			$this->_template_args, true);
815 815
         
816
-        if (defined('DOING_AJAX')) {
817
-            $notices = EE_Error::get_notices(false, false, false);
818
-            echo wp_json_encode(array(
819
-                'return_data' => $state_details_settings,
820
-                'success'     => $notices['success'],
821
-                'errors'      => $notices['errors']
822
-            ));
823
-            die();
824
-        } else {
825
-            return $state_details_settings;
826
-        }
816
+		if (defined('DOING_AJAX')) {
817
+			$notices = EE_Error::get_notices(false, false, false);
818
+			echo wp_json_encode(array(
819
+				'return_data' => $state_details_settings,
820
+				'success'     => $notices['success'],
821
+				'errors'      => $notices['errors']
822
+			));
823
+			die();
824
+		} else {
825
+			return $state_details_settings;
826
+		}
827 827
         
828
-    }
828
+	}
829 829
     
830 830
     
831
-    /**
832
-     *        add_new_state
833
-     *
834
-     * @access    public
835
-     * @return        void
836
-     */
837
-    public function add_new_state()
838
-    {
831
+	/**
832
+	 *        add_new_state
833
+	 *
834
+	 * @access    public
835
+	 * @return        void
836
+	 */
837
+	public function add_new_state()
838
+	{
839 839
         
840
-        $success = true;
840
+		$success = true;
841 841
         
842
-        $CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false;
843
-        if ( ! $CNT_ISO) {
844
-            EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.',
845
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
846
-            $success = false;
847
-        }
848
-        $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false;
849
-        if ( ! $STA_abbrev) {
850
-            EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
851
-                __FILE__, __FUNCTION__, __LINE__);
852
-            $success = false;
853
-        }
854
-        $STA_name = isset($this->_req_data['STA_name']) ? sanitize_text_field($this->_req_data['STA_name']) :
855
-            false;
856
-        if ( ! $STA_name) {
857
-            EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__,
858
-                __FUNCTION__, __LINE__);
859
-            $success = false;
860
-        }
842
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false;
843
+		if ( ! $CNT_ISO) {
844
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.',
845
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
846
+			$success = false;
847
+		}
848
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false;
849
+		if ( ! $STA_abbrev) {
850
+			EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
851
+				__FILE__, __FUNCTION__, __LINE__);
852
+			$success = false;
853
+		}
854
+		$STA_name = isset($this->_req_data['STA_name']) ? sanitize_text_field($this->_req_data['STA_name']) :
855
+			false;
856
+		if ( ! $STA_name) {
857
+			EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__,
858
+				__FUNCTION__, __LINE__);
859
+			$success = false;
860
+		}
861 861
         
862
-        if ($success) {
863
-            $cols_n_values = array(
864
-                'CNT_ISO'    => $CNT_ISO,
865
-                'STA_abbrev' => $STA_abbrev,
866
-                'STA_name'   => $STA_name,
867
-                'STA_active' => true
868
-            );
869
-            $success       = EEM_State::instance()->insert($cols_n_values);
870
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
871
-        }
862
+		if ($success) {
863
+			$cols_n_values = array(
864
+				'CNT_ISO'    => $CNT_ISO,
865
+				'STA_abbrev' => $STA_abbrev,
866
+				'STA_name'   => $STA_name,
867
+				'STA_active' => true
868
+			);
869
+			$success       = EEM_State::instance()->insert($cols_n_values);
870
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
871
+		}
872 872
         
873
-        if (defined('DOING_AJAX')) {
874
-            $notices = EE_Error::get_notices(false, false, false);
875
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
876
-            die();
877
-        } else {
878
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
879
-        }
880
-    }
881
-    
882
-    
883
-    /**
884
-     *        delete_state
885
-     *
886
-     * @access    public
887
-     * @return        boolean | void
888
-     */
889
-    public function delete_state()
890
-    {
891
-        $CNT_ISO    = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false;
892
-        $STA_ID     = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : false;
893
-        $STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false;
894
-        if ( ! $STA_ID) {
895
-            EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__,
896
-                __FUNCTION__, __LINE__);
873
+		if (defined('DOING_AJAX')) {
874
+			$notices = EE_Error::get_notices(false, false, false);
875
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
876
+			die();
877
+		} else {
878
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
879
+		}
880
+	}
881
+    
882
+    
883
+	/**
884
+	 *        delete_state
885
+	 *
886
+	 * @access    public
887
+	 * @return        boolean | void
888
+	 */
889
+	public function delete_state()
890
+	{
891
+		$CNT_ISO    = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : false;
892
+		$STA_ID     = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : false;
893
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : false;
894
+		if ( ! $STA_ID) {
895
+			EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__,
896
+				__FUNCTION__, __LINE__);
897 897
             
898
-            return false;
899
-        }
900
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
901
-        if ($success !== false) {
902
-            do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID,
903
-                array('STA_abbrev' => $STA_abbrev));
904
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
905
-        }
906
-        if (defined('DOING_AJAX')) {
907
-            $notices                = EE_Error::get_notices(false, false);
908
-            $notices['return_data'] = true;
909
-            echo wp_json_encode($notices);
910
-            die();
911
-        } else {
912
-            $this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings'));
913
-        }
914
-    }
915
-    
916
-    
917
-    /**
918
-     *        _update_country_settings
919
-     *
920
-     * @access    protected
921
-     * @return        void
922
-     */
923
-    protected function _update_country_settings()
924
-    {
898
+			return false;
899
+		}
900
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
901
+		if ($success !== false) {
902
+			do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID,
903
+				array('STA_abbrev' => $STA_abbrev));
904
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
905
+		}
906
+		if (defined('DOING_AJAX')) {
907
+			$notices                = EE_Error::get_notices(false, false);
908
+			$notices['return_data'] = true;
909
+			echo wp_json_encode($notices);
910
+			die();
911
+		} else {
912
+			$this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings'));
913
+		}
914
+	}
915
+    
916
+    
917
+	/**
918
+	 *        _update_country_settings
919
+	 *
920
+	 * @access    protected
921
+	 * @return        void
922
+	 */
923
+	protected function _update_country_settings()
924
+	{
925 925
 //		EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
926
-        // grab the country ISO code
927
-        $CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : false;
928
-        if ( ! $CNT_ISO) {
929
-            EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.',
930
-                'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
926
+		// grab the country ISO code
927
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : false;
928
+		if ( ! $CNT_ISO) {
929
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.',
930
+				'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
931 931
             
932
-            return;
933
-        }
934
-        $cols_n_values                    = array();
935
-        $cols_n_values['CNT_ISO3']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : false;
936
-        $cols_n_values['RGN_ID']          = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : null;
937
-        $cols_n_values['CNT_name']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : null;
938
-        $cols_n_values['CNT_cur_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD';
939
-        $cols_n_values['CNT_cur_single']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar';
940
-        $cols_n_values['CNT_cur_plural']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars';
941
-        $cols_n_values['CNT_cur_sign']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$';
942
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : true;
943
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2;
944
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.';
945
-        $cols_n_values['CNT_cur_thsnds']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ',';
946
-        $cols_n_values['CNT_tel_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : null;
947
-        $cols_n_values['CNT_is_EU']       = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : false;
948
-        $cols_n_values['CNT_active']      = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : false;
949
-        // allow filtering of country data
950
-        $cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
951
-            $cols_n_values);
952
-        //EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
953
-        // where values
954
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
955
-        // run the update
956
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
932
+			return;
933
+		}
934
+		$cols_n_values                    = array();
935
+		$cols_n_values['CNT_ISO3']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : false;
936
+		$cols_n_values['RGN_ID']          = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : null;
937
+		$cols_n_values['CNT_name']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : null;
938
+		$cols_n_values['CNT_cur_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD';
939
+		$cols_n_values['CNT_cur_single']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar';
940
+		$cols_n_values['CNT_cur_plural']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars';
941
+		$cols_n_values['CNT_cur_sign']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$';
942
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : true;
943
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2;
944
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.';
945
+		$cols_n_values['CNT_cur_thsnds']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ',';
946
+		$cols_n_values['CNT_tel_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : null;
947
+		$cols_n_values['CNT_is_EU']       = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : false;
948
+		$cols_n_values['CNT_active']      = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : false;
949
+		// allow filtering of country data
950
+		$cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
951
+			$cols_n_values);
952
+		//EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
953
+		// where values
954
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
955
+		// run the update
956
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
957 957
 //		global $wpdb;
958 958
 //		echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
959 959
 //		echo '<h4>$success : ' . $success . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
960
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
961
-            // allow filtering of states data
962
-            $states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states',
963
-                $this->_req_data['states']);
960
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
961
+			// allow filtering of states data
962
+			$states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states',
963
+				$this->_req_data['states']);
964 964
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
965
-            // loop thru state data ( looks like : states[75][STA_name] )
966
-            foreach ($states as $STA_ID => $state) {
967
-                $cols_n_values = array(
968
-                    'CNT_ISO'    => $CNT_ISO,
969
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
970
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
971
-                    'STA_active' => (bool)absint($state['STA_active'])
972
-                );
973
-                // where values
974
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
975
-                // run the update
976
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
977
-                if ($success !== false) {
978
-                    do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO,
979
-                        $STA_ID, $cols_n_values);
980
-                }
981
-            }
982
-        }
983
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
984
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) {
985
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
986
-            EE_Registry::instance()->CFG->update_espresso_config();
987
-        }
988
-        $this->_redirect_after_action($success, 'Countries', 'updated',
989
-            array('action' => 'country_settings', 'country' => $CNT_ISO));
990
-    }
991
-    
992
-    
993
-    /**
994
-     *        form_form_field_label_wrap
995
-     *
996
-     * @access        public
997
-     *
998
-     * @param        string $label
999
-     *
1000
-     * @return        string
1001
-     */
1002
-    public function country_form_field_label_wrap($label, $required_text)
1003
-    {
1004
-        return '
965
+			// loop thru state data ( looks like : states[75][STA_name] )
966
+			foreach ($states as $STA_ID => $state) {
967
+				$cols_n_values = array(
968
+					'CNT_ISO'    => $CNT_ISO,
969
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
970
+					'STA_name'   => sanitize_text_field($state['STA_name']),
971
+					'STA_active' => (bool)absint($state['STA_active'])
972
+				);
973
+				// where values
974
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
975
+				// run the update
976
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
977
+				if ($success !== false) {
978
+					do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO,
979
+						$STA_ID, $cols_n_values);
980
+				}
981
+			}
982
+		}
983
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
984
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) {
985
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
986
+			EE_Registry::instance()->CFG->update_espresso_config();
987
+		}
988
+		$this->_redirect_after_action($success, 'Countries', 'updated',
989
+			array('action' => 'country_settings', 'country' => $CNT_ISO));
990
+	}
991
+    
992
+    
993
+	/**
994
+	 *        form_form_field_label_wrap
995
+	 *
996
+	 * @access        public
997
+	 *
998
+	 * @param        string $label
999
+	 *
1000
+	 * @return        string
1001
+	 */
1002
+	public function country_form_field_label_wrap($label, $required_text)
1003
+	{
1004
+		return '
1005 1005
 			<tr>
1006 1006
 				<th>
1007 1007
 					' . $label . '
1008 1008
 				</th>';
1009
-    }
1010
-    
1011
-    
1012
-    /**
1013
-     *        form_form_field_input__wrap
1014
-     *
1015
-     * @access        public
1016
-     *
1017
-     * @param        string $label
1018
-     *
1019
-     * @return        string
1020
-     */
1021
-    public function country_form_field_input__wrap($input, $label)
1022
-    {
1023
-        return '
1009
+	}
1010
+    
1011
+    
1012
+	/**
1013
+	 *        form_form_field_input__wrap
1014
+	 *
1015
+	 * @access        public
1016
+	 *
1017
+	 * @param        string $label
1018
+	 *
1019
+	 * @return        string
1020
+	 */
1021
+	public function country_form_field_input__wrap($input, $label)
1022
+	{
1023
+		return '
1024 1024
 				<td class="general-settings-country-input-td">
1025 1025
 					' . $input . '
1026 1026
 				</td>
1027 1027
 			</tr>';
1028
-    }
1029
-    
1030
-    
1031
-    /**
1032
-     *        form_form_field_label_wrap
1033
-     *
1034
-     * @access        public
1035
-     *
1036
-     * @param        string $label
1037
-     * @param        string $required_text
1038
-     *
1039
-     * @return        string
1040
-     */
1041
-    public function state_form_field_label_wrap($label, $required_text)
1042
-    {
1043
-        return $required_text;
1044
-    }
1045
-    
1046
-    
1047
-    /**
1048
-     *        form_form_field_input__wrap
1049
-     *
1050
-     * @access        public
1051
-     *
1052
-     * @param        string $label
1053
-     *
1054
-     * @return        string
1055
-     */
1056
-    public function state_form_field_input__wrap($input, $label)
1057
-    {
1058
-        return '
1028
+	}
1029
+    
1030
+    
1031
+	/**
1032
+	 *        form_form_field_label_wrap
1033
+	 *
1034
+	 * @access        public
1035
+	 *
1036
+	 * @param        string $label
1037
+	 * @param        string $required_text
1038
+	 *
1039
+	 * @return        string
1040
+	 */
1041
+	public function state_form_field_label_wrap($label, $required_text)
1042
+	{
1043
+		return $required_text;
1044
+	}
1045
+    
1046
+    
1047
+	/**
1048
+	 *        form_form_field_input__wrap
1049
+	 *
1050
+	 * @access        public
1051
+	 *
1052
+	 * @param        string $label
1053
+	 *
1054
+	 * @return        string
1055
+	 */
1056
+	public function state_form_field_input__wrap($input, $label)
1057
+	{
1058
+		return '
1059 1059
 				<td class="general-settings-country-state-input-td">
1060 1060
 					' . $input . '
1061 1061
 				</td>';
1062 1062
         
1063
-    }
1063
+	}
1064 1064
     
1065 1065
     
1066 1066
     
1067 1067
     
1068 1068
     
1069 1069
     
1070
-    /***********/
1070
+	/***********/
1071 1071
     
1072 1072
     
1073
-    /**
1074
-     * displays edit and view links for critical EE pages
1075
-     *
1076
-     * @access public
1077
-     *
1078
-     * @param int $ee_page_id
1079
-     *
1080
-     * @return string
1081
-     */
1082
-    public static function edit_view_links($ee_page_id)
1083
-    {
1084
-        $links = '<a href="' . add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'),
1085
-                admin_url('post.php')) . '" >' . __('Edit', 'event_espresso') . '</a>';
1086
-        $links .= ' &nbsp;|&nbsp; ';
1087
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1073
+	/**
1074
+	 * displays edit and view links for critical EE pages
1075
+	 *
1076
+	 * @access public
1077
+	 *
1078
+	 * @param int $ee_page_id
1079
+	 *
1080
+	 * @return string
1081
+	 */
1082
+	public static function edit_view_links($ee_page_id)
1083
+	{
1084
+		$links = '<a href="' . add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'),
1085
+				admin_url('post.php')) . '" >' . __('Edit', 'event_espresso') . '</a>';
1086
+		$links .= ' &nbsp;|&nbsp; ';
1087
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1088 1088
         
1089
-        return $links;
1090
-    }
1091
-    
1092
-    
1093
-    /**
1094
-     * displays page and shortcode status for critical EE pages
1095
-     *
1096
-     * @param WP page object $ee_page
1097
-     *
1098
-     * @return string
1099
-     */
1100
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1101
-    {
1089
+		return $links;
1090
+	}
1091
+    
1092
+    
1093
+	/**
1094
+	 * displays page and shortcode status for critical EE pages
1095
+	 *
1096
+	 * @param WP page object $ee_page
1097
+	 *
1098
+	 * @return string
1099
+	 */
1100
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1101
+	{
1102 1102
         
1103
-        // page status
1104
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1105
-            $pg_colour = 'green';
1106
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1107
-        } else {
1108
-            $pg_colour = 'red';
1109
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1110
-        }
1103
+		// page status
1104
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1105
+			$pg_colour = 'green';
1106
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1107
+		} else {
1108
+			$pg_colour = 'red';
1109
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1110
+		}
1111 1111
         
1112
-        // shortcode status
1113
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1114
-            $sc_colour = 'green';
1115
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1116
-        } else {
1117
-            $sc_colour = 'red';
1118
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1119
-        }
1112
+		// shortcode status
1113
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1114
+			$sc_colour = 'green';
1115
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1116
+		} else {
1117
+			$sc_colour = 'red';
1118
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1119
+		}
1120 1120
         
1121
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1121
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1122 1122
         
1123
-    }
1124
-    
1125
-    
1126
-    /**
1127
-     * generates a dropdown of all parent pages - copied from WP core
1128
-     *
1129
-     * @param unknown_type $default
1130
-     * @param unknown_type $parent
1131
-     * @param unknown_type $level
1132
-     *
1133
-     * @return unknown
1134
-     */
1135
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1136
-    {
1137
-        global $wpdb;
1138
-        $items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1139
-            $parent));
1123
+	}
1124
+    
1125
+    
1126
+	/**
1127
+	 * generates a dropdown of all parent pages - copied from WP core
1128
+	 *
1129
+	 * @param unknown_type $default
1130
+	 * @param unknown_type $parent
1131
+	 * @param unknown_type $level
1132
+	 *
1133
+	 * @return unknown
1134
+	 */
1135
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1136
+	{
1137
+		global $wpdb;
1138
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order",
1139
+			$parent));
1140 1140
         
1141
-        if ($items) {
1142
-            foreach ($items as $item) {
1143
-                $pad = str_repeat('&nbsp;', $level * 3);
1144
-                if ($item->ID == $default) {
1145
-                    $current = ' selected="selected"';
1146
-                } else {
1147
-                    $current = '';
1148
-                }
1141
+		if ($items) {
1142
+			foreach ($items as $item) {
1143
+				$pad = str_repeat('&nbsp;', $level * 3);
1144
+				if ($item->ID == $default) {
1145
+					$current = ' selected="selected"';
1146
+				} else {
1147
+					$current = '';
1148
+				}
1149 1149
                 
1150
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
1151
-                parent_dropdown($default, $item->ID, $level + 1);
1152
-            }
1153
-        } else {
1154
-            return false;
1155
-        }
1156
-    }
1150
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
1151
+				parent_dropdown($default, $item->ID, $level + 1);
1152
+			}
1153
+		} else {
1154
+			return false;
1155
+		}
1156
+	}
1157 1157
     
1158 1158
     
1159 1159
 } //ends Forms_Admin_Page class
Please login to merge, or discard this patch.