Completed
Branch FET-10766-extract-activation-d... (a86901)
by
unknown
187:06 queued 176:14
created
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 2 patches
Indentation   +419 added lines, -419 removed lines patch added patch discarded remove patch
@@ -17,420 +17,420 @@  discard block
 block discarded – undo
17 17
 class EE_Payment_Method_Manager
18 18
 {
19 19
 
20
-    /**
21
-     * @var EE_Payment_Method_Manager $_instance
22
-     */
23
-    private static $_instance;
24
-
25
-    /**
26
-     * @var array keys are class names without 'EE_PMT_', values are their filepaths
27
-     */
28
-    protected $_payment_method_types = array();
29
-
30
-
31
-
32
-    /**
33
-     * @singleton method used to instantiate class object
34
-     * @return EE_Payment_Method_Manager instance
35
-     */
36
-    public static function instance()
37
-    {
38
-        // check if class object is instantiated, and instantiated properly
39
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
40
-            self::$_instance = new self();
41
-        }
42
-        EE_Registry::instance()->load_lib('PMT_Base');
43
-        return self::$_instance;
44
-    }
45
-
46
-
47
-
48
-    /**
49
-     * Resets the instance and returns a new one
50
-     *
51
-     * @return EE_Payment_Method_Manager
52
-     */
53
-    public static function reset()
54
-    {
55
-        self::$_instance = null;
56
-        return self::instance();
57
-    }
58
-
59
-
60
-
61
-    /**
62
-     * If necessary, re-register payment methods
63
-     *
64
-     * @param boolean $force_recheck whether to recheck for payment method types,
65
-     *                               or just re-use the PMTs we found last time we checked during this request (if
66
-     *                               we have not yet checked during this request, then we need to check anyways)
67
-     */
68
-    public function maybe_register_payment_methods($force_recheck = false)
69
-    {
70
-        if (! $this->_payment_method_types || $force_recheck) {
71
-            $this->_register_payment_methods();
72
-            //if in admin lets ensure caps are set.
73
-            if (is_admin()) {
74
-                add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
75
-                EE_Registry::instance()->CAP->init_caps();
76
-            }
77
-        }
78
-    }
79
-
80
-
81
-
82
-    /**
83
-     * register_payment_methods
84
-     *
85
-     * @return array
86
-     */
87
-    protected function _register_payment_methods()
88
-    {
89
-        // grab list of installed modules
90
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
91
-        // filter list of modules to register
92
-        $pm_to_register = apply_filters(
93
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
94
-            $pm_to_register
95
-        );
96
-        // loop through folders
97
-        foreach ($pm_to_register as $pm_path) {
98
-            $this->register_payment_method($pm_path);
99
-        }
100
-        do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
101
-        // filter list of installed modules
102
-        //keep them organized alphabetically by the payment method type's name
103
-        ksort($this->_payment_method_types);
104
-        return apply_filters(
105
-            'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
106
-            $this->_payment_method_types
107
-        );
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     * register_payment_method- makes core aware of this payment method
114
-     *
115
-     * @param string $payment_method_path - full path up to and including payment method folder
116
-     * @return boolean
117
-     */
118
-    public function register_payment_method($payment_method_path = '')
119
-    {
120
-        do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
121
-        $module_ext = '.pm.php';
122
-        // make all separators match
123
-        $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
124
-        // grab and sanitize module name
125
-        $module_dir = basename($payment_method_path);
126
-        // create classname from module directory name
127
-        $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
128
-        // add class prefix
129
-        $module_class = 'EE_PMT_' . $module;
130
-        // does the module exist ?
131
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
132
-            $msg = sprintf(
133
-                esc_html__(
134
-                    'The requested %s payment method file could not be found or is not readable due to file permissions.',
135
-                    'event_espresso'
136
-                ), $module
137
-            );
138
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
139
-            return false;
140
-        }
141
-        // load the module class file
142
-        require_once($payment_method_path . DS . $module_class . $module_ext);
143
-        // verify that class exists
144
-        if (! class_exists($module_class)) {
145
-            $msg = sprintf(
146
-                esc_html__('The requested %s module class does not exist.', 'event_espresso'),
147
-                $module_class
148
-            );
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
-        }
179
-        return false;
180
-    }
181
-
182
-
183
-
184
-    /**
185
-     * Returns all the class names of the various payment method types
186
-     *
187
-     * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
188
-     *                               (what you'd find in wp_esp_payment_method.PMD_type)
189
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
190
-     * @return array
191
-     */
192
-    public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
193
-    {
194
-        $this->maybe_register_payment_methods($force_recheck);
195
-        if ($with_prefixes) {
196
-            $classnames = array_keys($this->_payment_method_types);
197
-            $payment_methods = array();
198
-            foreach ($classnames as $classname) {
199
-                $payment_methods[] = $this->payment_method_class_from_type($classname);
200
-            }
201
-            return $payment_methods;
202
-        }
203
-        return array_keys($this->_payment_method_types);
204
-    }
205
-
206
-
207
-
208
-    /**
209
-     * Gets an object of each payment method type, none of which are bound to a
210
-     * payment method instance
211
-     *
212
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
213
-     * @return EE_PMT_Base[]
214
-     */
215
-    public function payment_method_types($force_recheck = false)
216
-    {
217
-        $this->maybe_register_payment_methods($force_recheck);
218
-        $payment_method_objects = array();
219
-        foreach ($this->payment_method_type_names(true) as $classname) {
220
-            $payment_method_objects[] = new $classname;
221
-        }
222
-        return $payment_method_objects;
223
-    }
224
-
225
-
226
-
227
-    /**
228
-     * Changes the payment method's classname into the payment method type's name
229
-     * (as used on the payment method's table's PMD_type field)
230
-     *
231
-     * @param string $classname
232
-     * @return string
233
-     */
234
-    public function payment_method_type_sans_class_prefix($classname)
235
-    {
236
-        return str_replace('EE_PMT_', '', $classname);
237
-    }
238
-
239
-
240
-
241
-    /**
242
-     * Does the opposite of payment-method_type_sans_prefix
243
-     *
244
-     * @param string $type
245
-     * @return string
246
-     */
247
-    public function payment_method_class_from_type($type)
248
-    {
249
-        $this->maybe_register_payment_methods();
250
-        return 'EE_PMT_' . $type;
251
-    }
252
-
253
-
254
-
255
-    /**
256
-     * Activates a payment method of the given type.
257
-     *
258
-     * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
259
-     * @return EE_Payment_Method
260
-     * @throws EE_Error
261
-     */
262
-    public function activate_a_payment_method_of_type($payment_method_type)
263
-    {
264
-        $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
265
-        if (! $payment_method instanceof EE_Payment_Method) {
266
-            $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
267
-            if (class_exists($pm_type_class)) {
268
-                /** @var $pm_type_obj EE_PMT_Base */
269
-                $pm_type_obj = new $pm_type_class;
270
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
271
-                if (! $payment_method) {
272
-                    $payment_method = $this->create_payment_method_of_type($pm_type_obj);
273
-                }
274
-                $payment_method->set_type($payment_method_type);
275
-                $this->initialize_payment_method($payment_method);
276
-            } else {
277
-                throw new EE_Error(
278
-                    sprintf(
279
-                        esc_html__(
280
-                            'There is no payment method of type %1$s, so it could not be activated',
281
-                            'event_espresso'
282
-                        ),
283
-                        $pm_type_class
284
-                    )
285
-                );
286
-            }
287
-        }
288
-        $payment_method->set_active();
289
-        $payment_method->save();
290
-        if ($payment_method->type() === 'Invoice') {
291
-            /** @type EE_Message_Resource_Manager $message_resource_manager */
292
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
293
-            $message_resource_manager->ensure_message_type_is_active('invoice', 'html');
294
-            $message_resource_manager->ensure_messenger_is_active('pdf');
295
-            EE_Error::add_persistent_admin_notice(
296
-                'invoice_pm_requirements_notice',
297
-                sprintf(
298
-                    esc_html__(
299
-                        '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.',
300
-                        'event_espresso'
301
-                    ),
302
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
303
-                    '</a>'
304
-                ),
305
-                true
306
-            );
307
-        }
308
-        return $payment_method;
309
-    }
310
-
311
-
312
-
313
-    /**
314
-     * Creates a payment method of the specified type. Does not save it.
315
-     *
316
-     * @global WP_User    $current_user
317
-     * @param EE_PMT_Base $pm_type_obj
318
-     * @return EE_Payment_Method
319
-     * @throws EE_Error
320
-     */
321
-    public function create_payment_method_of_type($pm_type_obj)
322
-    {
323
-        global $current_user;
324
-        $payment_method = EE_Payment_Method::new_instance(
325
-            array(
326
-                'PMD_type'       => $pm_type_obj->system_name(),
327
-                'PMD_name'       => $pm_type_obj->pretty_name(),
328
-                'PMD_admin_name' => $pm_type_obj->pretty_name(),
329
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
330
-                'PMD_wp_user'    => $current_user->ID,
331
-                'PMD_order'      => EEM_Payment_Method::instance()->count(
332
-                        array(array('PMD_type' => array('!=', 'Admin_Only')))
333
-                    ) * 10,
334
-            )
335
-        );
336
-        return $payment_method;
337
-    }
338
-
339
-
340
-
341
-    /**
342
-     * Sets the initial payment method properties (including extra meta)
343
-     *
344
-     * @param EE_Payment_Method $payment_method
345
-     * @return EE_Payment_Method
346
-     * @throws EE_Error
347
-     */
348
-    public function initialize_payment_method($payment_method)
349
-    {
350
-        $pm_type_obj = $payment_method->type_obj();
351
-        $payment_method->set_description($pm_type_obj->default_description());
352
-        if (! $payment_method->button_url()) {
353
-            $payment_method->set_button_url($pm_type_obj->default_button_url());
354
-        }
355
-        //now add setup its default extra meta properties
356
-        $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
357
-        if (! empty($extra_metas)) {
358
-            //verify the payment method has an ID before adding extra meta
359
-            if (! $payment_method->ID()) {
360
-                $payment_method->save();
361
-            }
362
-            foreach ($extra_metas as $meta_name => $input) {
363
-                $payment_method->update_extra_meta($meta_name, $input->raw_value());
364
-            }
365
-        }
366
-        return $payment_method;
367
-    }
368
-
369
-
370
-
371
-    /**
372
-     * Makes sure the payment method is related to the specified payment method
373
-     *
374
-     * @deprecated in 4.9.40 because the currency payment method table is being deprecated
375
-     * @param EE_Payment_Method $payment_method
376
-     * @return EE_Payment_Method
377
-     * @throws EE_Error
378
-     */
379
-    public function set_usable_currencies_on_payment_method($payment_method)
380
-    {
381
-        EE_Error::doing_it_wrong(
382
-            'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
383
-            esc_html__(
384
-                'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
385
-                'event_espresso'
386
-            ),
387
-            '4.9.40'
388
-        );
389
-        return $payment_method;
390
-    }
391
-
392
-
393
-
394
-    /**
395
-     * Deactivates a payment method of the given payment method slug.
396
-     *
397
-     * @param string $payment_method_slug The slug for the payment method to deactivate.
398
-     * @return int count of rows updated.
399
-     * @throws EE_Error
400
-     */
401
-    public function deactivate_payment_method($payment_method_slug)
402
-    {
403
-        EE_Log::instance()->log(
404
-            __FILE__,
405
-            __FUNCTION__,
406
-            sprintf(
407
-                esc_html__(
408
-                    'Payment method with slug %1$s is being deactivated by site admin',
409
-                    'event_espresso'
410
-                ),
411
-                $payment_method_slug
412
-            ),
413
-            'payment_method_change'
414
-        );
415
-        $count_updated = EEM_Payment_Method::instance()->update(
416
-            array('PMD_scope' => array()),
417
-            array(array('PMD_slug' => $payment_method_slug))
418
-        );
419
-        return $count_updated;
420
-    }
421
-
422
-
423
-
424
-    /**
425
-     * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method
426
-     * access caps.
427
-     *
428
-     * @param array $caps capabilities being filtered
429
-     * @return array
430
-     */
431
-    public function add_payment_method_caps($caps)
432
-    {
433
-        /* add dynamic caps from payment methods
20
+	/**
21
+	 * @var EE_Payment_Method_Manager $_instance
22
+	 */
23
+	private static $_instance;
24
+
25
+	/**
26
+	 * @var array keys are class names without 'EE_PMT_', values are their filepaths
27
+	 */
28
+	protected $_payment_method_types = array();
29
+
30
+
31
+
32
+	/**
33
+	 * @singleton method used to instantiate class object
34
+	 * @return EE_Payment_Method_Manager instance
35
+	 */
36
+	public static function instance()
37
+	{
38
+		// check if class object is instantiated, and instantiated properly
39
+		if (! self::$_instance instanceof EE_Payment_Method_Manager) {
40
+			self::$_instance = new self();
41
+		}
42
+		EE_Registry::instance()->load_lib('PMT_Base');
43
+		return self::$_instance;
44
+	}
45
+
46
+
47
+
48
+	/**
49
+	 * Resets the instance and returns a new one
50
+	 *
51
+	 * @return EE_Payment_Method_Manager
52
+	 */
53
+	public static function reset()
54
+	{
55
+		self::$_instance = null;
56
+		return self::instance();
57
+	}
58
+
59
+
60
+
61
+	/**
62
+	 * If necessary, re-register payment methods
63
+	 *
64
+	 * @param boolean $force_recheck whether to recheck for payment method types,
65
+	 *                               or just re-use the PMTs we found last time we checked during this request (if
66
+	 *                               we have not yet checked during this request, then we need to check anyways)
67
+	 */
68
+	public function maybe_register_payment_methods($force_recheck = false)
69
+	{
70
+		if (! $this->_payment_method_types || $force_recheck) {
71
+			$this->_register_payment_methods();
72
+			//if in admin lets ensure caps are set.
73
+			if (is_admin()) {
74
+				add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
75
+				EE_Registry::instance()->CAP->init_caps();
76
+			}
77
+		}
78
+	}
79
+
80
+
81
+
82
+	/**
83
+	 * register_payment_methods
84
+	 *
85
+	 * @return array
86
+	 */
87
+	protected function _register_payment_methods()
88
+	{
89
+		// grab list of installed modules
90
+		$pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
91
+		// filter list of modules to register
92
+		$pm_to_register = apply_filters(
93
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
94
+			$pm_to_register
95
+		);
96
+		// loop through folders
97
+		foreach ($pm_to_register as $pm_path) {
98
+			$this->register_payment_method($pm_path);
99
+		}
100
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
101
+		// filter list of installed modules
102
+		//keep them organized alphabetically by the payment method type's name
103
+		ksort($this->_payment_method_types);
104
+		return apply_filters(
105
+			'FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
106
+			$this->_payment_method_types
107
+		);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 * register_payment_method- makes core aware of this payment method
114
+	 *
115
+	 * @param string $payment_method_path - full path up to and including payment method folder
116
+	 * @return boolean
117
+	 */
118
+	public function register_payment_method($payment_method_path = '')
119
+	{
120
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
121
+		$module_ext = '.pm.php';
122
+		// make all separators match
123
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
124
+		// grab and sanitize module name
125
+		$module_dir = basename($payment_method_path);
126
+		// create classname from module directory name
127
+		$module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
128
+		// add class prefix
129
+		$module_class = 'EE_PMT_' . $module;
130
+		// does the module exist ?
131
+		if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
132
+			$msg = sprintf(
133
+				esc_html__(
134
+					'The requested %s payment method file could not be found or is not readable due to file permissions.',
135
+					'event_espresso'
136
+				), $module
137
+			);
138
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
139
+			return false;
140
+		}
141
+		// load the module class file
142
+		require_once($payment_method_path . DS . $module_class . $module_ext);
143
+		// verify that class exists
144
+		if (! class_exists($module_class)) {
145
+			$msg = sprintf(
146
+				esc_html__('The requested %s module class does not exist.', 'event_espresso'),
147
+				$module_class
148
+			);
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
+		}
179
+		return false;
180
+	}
181
+
182
+
183
+
184
+	/**
185
+	 * Returns all the class names of the various payment method types
186
+	 *
187
+	 * @param boolean $with_prefixes TRUE: get payment method type class names; false just their 'names'
188
+	 *                               (what you'd find in wp_esp_payment_method.PMD_type)
189
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
190
+	 * @return array
191
+	 */
192
+	public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
193
+	{
194
+		$this->maybe_register_payment_methods($force_recheck);
195
+		if ($with_prefixes) {
196
+			$classnames = array_keys($this->_payment_method_types);
197
+			$payment_methods = array();
198
+			foreach ($classnames as $classname) {
199
+				$payment_methods[] = $this->payment_method_class_from_type($classname);
200
+			}
201
+			return $payment_methods;
202
+		}
203
+		return array_keys($this->_payment_method_types);
204
+	}
205
+
206
+
207
+
208
+	/**
209
+	 * Gets an object of each payment method type, none of which are bound to a
210
+	 * payment method instance
211
+	 *
212
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
213
+	 * @return EE_PMT_Base[]
214
+	 */
215
+	public function payment_method_types($force_recheck = false)
216
+	{
217
+		$this->maybe_register_payment_methods($force_recheck);
218
+		$payment_method_objects = array();
219
+		foreach ($this->payment_method_type_names(true) as $classname) {
220
+			$payment_method_objects[] = new $classname;
221
+		}
222
+		return $payment_method_objects;
223
+	}
224
+
225
+
226
+
227
+	/**
228
+	 * Changes the payment method's classname into the payment method type's name
229
+	 * (as used on the payment method's table's PMD_type field)
230
+	 *
231
+	 * @param string $classname
232
+	 * @return string
233
+	 */
234
+	public function payment_method_type_sans_class_prefix($classname)
235
+	{
236
+		return str_replace('EE_PMT_', '', $classname);
237
+	}
238
+
239
+
240
+
241
+	/**
242
+	 * Does the opposite of payment-method_type_sans_prefix
243
+	 *
244
+	 * @param string $type
245
+	 * @return string
246
+	 */
247
+	public function payment_method_class_from_type($type)
248
+	{
249
+		$this->maybe_register_payment_methods();
250
+		return 'EE_PMT_' . $type;
251
+	}
252
+
253
+
254
+
255
+	/**
256
+	 * Activates a payment method of the given type.
257
+	 *
258
+	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
259
+	 * @return EE_Payment_Method
260
+	 * @throws EE_Error
261
+	 */
262
+	public function activate_a_payment_method_of_type($payment_method_type)
263
+	{
264
+		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
265
+		if (! $payment_method instanceof EE_Payment_Method) {
266
+			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
267
+			if (class_exists($pm_type_class)) {
268
+				/** @var $pm_type_obj EE_PMT_Base */
269
+				$pm_type_obj = new $pm_type_class;
270
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
271
+				if (! $payment_method) {
272
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
273
+				}
274
+				$payment_method->set_type($payment_method_type);
275
+				$this->initialize_payment_method($payment_method);
276
+			} else {
277
+				throw new EE_Error(
278
+					sprintf(
279
+						esc_html__(
280
+							'There is no payment method of type %1$s, so it could not be activated',
281
+							'event_espresso'
282
+						),
283
+						$pm_type_class
284
+					)
285
+				);
286
+			}
287
+		}
288
+		$payment_method->set_active();
289
+		$payment_method->save();
290
+		if ($payment_method->type() === 'Invoice') {
291
+			/** @type EE_Message_Resource_Manager $message_resource_manager */
292
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
293
+			$message_resource_manager->ensure_message_type_is_active('invoice', 'html');
294
+			$message_resource_manager->ensure_messenger_is_active('pdf');
295
+			EE_Error::add_persistent_admin_notice(
296
+				'invoice_pm_requirements_notice',
297
+				sprintf(
298
+					esc_html__(
299
+						'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.',
300
+						'event_espresso'
301
+					),
302
+					'<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
303
+					'</a>'
304
+				),
305
+				true
306
+			);
307
+		}
308
+		return $payment_method;
309
+	}
310
+
311
+
312
+
313
+	/**
314
+	 * Creates a payment method of the specified type. Does not save it.
315
+	 *
316
+	 * @global WP_User    $current_user
317
+	 * @param EE_PMT_Base $pm_type_obj
318
+	 * @return EE_Payment_Method
319
+	 * @throws EE_Error
320
+	 */
321
+	public function create_payment_method_of_type($pm_type_obj)
322
+	{
323
+		global $current_user;
324
+		$payment_method = EE_Payment_Method::new_instance(
325
+			array(
326
+				'PMD_type'       => $pm_type_obj->system_name(),
327
+				'PMD_name'       => $pm_type_obj->pretty_name(),
328
+				'PMD_admin_name' => $pm_type_obj->pretty_name(),
329
+				'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
330
+				'PMD_wp_user'    => $current_user->ID,
331
+				'PMD_order'      => EEM_Payment_Method::instance()->count(
332
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
333
+					) * 10,
334
+			)
335
+		);
336
+		return $payment_method;
337
+	}
338
+
339
+
340
+
341
+	/**
342
+	 * Sets the initial payment method properties (including extra meta)
343
+	 *
344
+	 * @param EE_Payment_Method $payment_method
345
+	 * @return EE_Payment_Method
346
+	 * @throws EE_Error
347
+	 */
348
+	public function initialize_payment_method($payment_method)
349
+	{
350
+		$pm_type_obj = $payment_method->type_obj();
351
+		$payment_method->set_description($pm_type_obj->default_description());
352
+		if (! $payment_method->button_url()) {
353
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
354
+		}
355
+		//now add setup its default extra meta properties
356
+		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
357
+		if (! empty($extra_metas)) {
358
+			//verify the payment method has an ID before adding extra meta
359
+			if (! $payment_method->ID()) {
360
+				$payment_method->save();
361
+			}
362
+			foreach ($extra_metas as $meta_name => $input) {
363
+				$payment_method->update_extra_meta($meta_name, $input->raw_value());
364
+			}
365
+		}
366
+		return $payment_method;
367
+	}
368
+
369
+
370
+
371
+	/**
372
+	 * Makes sure the payment method is related to the specified payment method
373
+	 *
374
+	 * @deprecated in 4.9.40 because the currency payment method table is being deprecated
375
+	 * @param EE_Payment_Method $payment_method
376
+	 * @return EE_Payment_Method
377
+	 * @throws EE_Error
378
+	 */
379
+	public function set_usable_currencies_on_payment_method($payment_method)
380
+	{
381
+		EE_Error::doing_it_wrong(
382
+			'EE_Payment_Method_Manager::set_usable_currencies_on_payment_method',
383
+			esc_html__(
384
+				'We no longer define what currencies are usable by payment methods. Its not used nor efficient.',
385
+				'event_espresso'
386
+			),
387
+			'4.9.40'
388
+		);
389
+		return $payment_method;
390
+	}
391
+
392
+
393
+
394
+	/**
395
+	 * Deactivates a payment method of the given payment method slug.
396
+	 *
397
+	 * @param string $payment_method_slug The slug for the payment method to deactivate.
398
+	 * @return int count of rows updated.
399
+	 * @throws EE_Error
400
+	 */
401
+	public function deactivate_payment_method($payment_method_slug)
402
+	{
403
+		EE_Log::instance()->log(
404
+			__FILE__,
405
+			__FUNCTION__,
406
+			sprintf(
407
+				esc_html__(
408
+					'Payment method with slug %1$s is being deactivated by site admin',
409
+					'event_espresso'
410
+				),
411
+				$payment_method_slug
412
+			),
413
+			'payment_method_change'
414
+		);
415
+		$count_updated = EEM_Payment_Method::instance()->update(
416
+			array('PMD_scope' => array()),
417
+			array(array('PMD_slug' => $payment_method_slug))
418
+		);
419
+		return $count_updated;
420
+	}
421
+
422
+
423
+
424
+	/**
425
+	 * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method
426
+	 * access caps.
427
+	 *
428
+	 * @param array $caps capabilities being filtered
429
+	 * @return array
430
+	 */
431
+	public function add_payment_method_caps($caps)
432
+	{
433
+		/* add dynamic caps from payment methods
434 434
          * at the time of writing, october 20 2014, these are the caps added:
435 435
          * ee_payment_method_admin_only
436 436
          * ee_payment_method_aim
@@ -444,10 +444,10 @@  discard block
 block discarded – undo
444 444
          * their related capability automatically added too, so long as they are
445 445
          * registered properly using EE_Register_Payment_Method::register()
446 446
          */
447
-        foreach ($this->payment_method_types() as $payment_method_type_obj) {
448
-            $caps['administrator'][] = $payment_method_type_obj->cap_name();
449
-        }
450
-        return $caps;
451
-    }
447
+		foreach ($this->payment_method_types() as $payment_method_type_obj) {
448
+			$caps['administrator'][] = $payment_method_type_obj->cap_name();
449
+		}
450
+		return $caps;
451
+	}
452 452
 
453 453
 }
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     public static function instance()
37 37
     {
38 38
         // check if class object is instantiated, and instantiated properly
39
-        if (! self::$_instance instanceof EE_Payment_Method_Manager) {
39
+        if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
40 40
             self::$_instance = new self();
41 41
         }
42 42
         EE_Registry::instance()->load_lib('PMT_Base');
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
      */
68 68
     public function maybe_register_payment_methods($force_recheck = false)
69 69
     {
70
-        if (! $this->_payment_method_types || $force_recheck) {
70
+        if ( ! $this->_payment_method_types || $force_recheck) {
71 71
             $this->_register_payment_methods();
72 72
             //if in admin lets ensure caps are set.
73 73
             if (is_admin()) {
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
     protected function _register_payment_methods()
88 88
     {
89 89
         // grab list of installed modules
90
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
90
+        $pm_to_register = glob(EE_PAYMENT_METHODS.'*', GLOB_ONLYDIR);
91 91
         // filter list of modules to register
92 92
         $pm_to_register = apply_filters(
93 93
             'FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
@@ -126,31 +126,31 @@  discard block
 block discarded – undo
126 126
         // create classname from module directory name
127 127
         $module = str_replace(array('_', ' '), array(' ', '_'), $module_dir);
128 128
         // add class prefix
129
-        $module_class = 'EE_PMT_' . $module;
129
+        $module_class = 'EE_PMT_'.$module;
130 130
         // does the module exist ?
131
-        if (! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
131
+        if ( ! is_readable($payment_method_path.DS.$module_class.$module_ext)) {
132 132
             $msg = sprintf(
133 133
                 esc_html__(
134 134
                     'The requested %s payment method file could not be found or is not readable due to file permissions.',
135 135
                     'event_espresso'
136 136
                 ), $module
137 137
             );
138
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
138
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
139 139
             return false;
140 140
         }
141 141
         // load the module class file
142
-        require_once($payment_method_path . DS . $module_class . $module_ext);
142
+        require_once($payment_method_path.DS.$module_class.$module_ext);
143 143
         // verify that class exists
144
-        if (! class_exists($module_class)) {
144
+        if ( ! class_exists($module_class)) {
145 145
             $msg = sprintf(
146 146
                 esc_html__('The requested %s module class does not exist.', 'event_espresso'),
147 147
                 $module_class
148 148
             );
149
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
149
+            EE_Error::add_error($msg.'||'.$msg, __FILE__, __FUNCTION__, __LINE__);
150 150
             return false;
151 151
         }
152 152
         // add to array of registered modules
153
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
153
+        $this->_payment_method_types[$module] = $payment_method_path.DS.$module_class.$module_ext;
154 154
         return true;
155 155
     }
156 156
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
     public function payment_method_class_from_type($type)
248 248
     {
249 249
         $this->maybe_register_payment_methods();
250
-        return 'EE_PMT_' . $type;
250
+        return 'EE_PMT_'.$type;
251 251
     }
252 252
 
253 253
 
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
     public function activate_a_payment_method_of_type($payment_method_type)
263 263
     {
264 264
         $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
265
-        if (! $payment_method instanceof EE_Payment_Method) {
265
+        if ( ! $payment_method instanceof EE_Payment_Method) {
266 266
             $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
267 267
             if (class_exists($pm_type_class)) {
268 268
                 /** @var $pm_type_obj EE_PMT_Base */
269 269
                 $pm_type_obj = new $pm_type_class;
270 270
                 $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
271
-                if (! $payment_method) {
271
+                if ( ! $payment_method) {
272 272
                     $payment_method = $this->create_payment_method_of_type($pm_type_obj);
273 273
                 }
274 274
                 $payment_method->set_type($payment_method_type);
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
                         '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.',
300 300
                         'event_espresso'
301 301
                     ),
302
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
302
+                    '<a href="'.admin_url('admin.php?page=espresso_messages').'">',
303 303
                     '</a>'
304 304
                 ),
305 305
                 true
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
                 'PMD_type'       => $pm_type_obj->system_name(),
327 327
                 'PMD_name'       => $pm_type_obj->pretty_name(),
328 328
                 'PMD_admin_name' => $pm_type_obj->pretty_name(),
329
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
329
+                'PMD_slug'       => $pm_type_obj->system_name(), //automatically converted to slug
330 330
                 'PMD_wp_user'    => $current_user->ID,
331 331
                 'PMD_order'      => EEM_Payment_Method::instance()->count(
332 332
                         array(array('PMD_type' => array('!=', 'Admin_Only')))
@@ -349,14 +349,14 @@  discard block
 block discarded – undo
349 349
     {
350 350
         $pm_type_obj = $payment_method->type_obj();
351 351
         $payment_method->set_description($pm_type_obj->default_description());
352
-        if (! $payment_method->button_url()) {
352
+        if ( ! $payment_method->button_url()) {
353 353
             $payment_method->set_button_url($pm_type_obj->default_button_url());
354 354
         }
355 355
         //now add setup its default extra meta properties
356 356
         $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
357
-        if (! empty($extra_metas)) {
357
+        if ( ! empty($extra_metas)) {
358 358
             //verify the payment method has an ID before adding extra meta
359
-            if (! $payment_method->ID()) {
359
+            if ( ! $payment_method->ID()) {
360 360
                 $payment_method->save();
361 361
             }
362 362
             foreach ($extra_metas as $meta_name => $input) {
Please login to merge, or discard this patch.
core/libraries/form_sections/form_handlers/FormHandler.php 2 patches
Indentation   +637 added lines, -637 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
 use EventEspresso\core\exceptions\InvalidFormSubmissionException;
13 13
 
14 14
 if (! defined('EVENT_ESPRESSO_VERSION')) {
15
-    exit('No direct script access allowed');
15
+	exit('No direct script access allowed');
16 16
 }
17 17
 
18 18
 
@@ -31,642 +31,642 @@  discard block
 block discarded – undo
31 31
 abstract class FormHandler implements FormHandlerInterface
32 32
 {
33 33
 
34
-    /**
35
-     * will add opening and closing HTML form tags as well as a submit button
36
-     */
37
-    const ADD_FORM_TAGS_AND_SUBMIT = 'add_form_tags_and_submit';
38
-
39
-    /**
40
-     * will add opening and closing HTML form tags but NOT a submit button
41
-     */
42
-    const ADD_FORM_TAGS_ONLY = 'add_form_tags_only';
43
-
44
-    /**
45
-     * will NOT add opening and closing HTML form tags but will add a submit button
46
-     */
47
-    const ADD_FORM_SUBMIT_ONLY = 'add_form_submit_only';
48
-
49
-    /**
50
-     * will NOT add opening and closing HTML form tags NOR a submit button
51
-     */
52
-    const DO_NOT_SETUP_FORM = 'do_not_setup_form';
53
-
54
-    /**
55
-     * if set to false, then this form has no displayable content,
56
-     * and will only be used for processing data sent passed via GET or POST
57
-     * defaults to true ( ie: form has displayable content )
58
-     *
59
-     * @var boolean $displayable
60
-     */
61
-    private $displayable = true;
62
-
63
-    /**
64
-     * @var string $form_name
65
-     */
66
-    private $form_name;
67
-
68
-    /**
69
-     * @var string $admin_name
70
-     */
71
-    private $admin_name;
72
-
73
-    /**
74
-     * @var string $slug
75
-     */
76
-    private $slug;
77
-
78
-    /**
79
-     * @var string $submit_btn_text
80
-     */
81
-    private $submit_btn_text;
82
-
83
-    /**
84
-     * @var string $form_action
85
-     */
86
-    private $form_action;
87
-
88
-    /**
89
-     * form params in key value pairs
90
-     * can be added to form action URL or as hidden inputs
91
-     *
92
-     * @var array $form_args
93
-     */
94
-    private $form_args = array();
95
-
96
-    /**
97
-     * value of one of the string constant above
98
-     *
99
-     * @var string $form_config
100
-     */
101
-    private $form_config;
102
-
103
-    /**
104
-     * whether or not the form was determined to be invalid
105
-     *
106
-     * @var boolean $form_has_errors
107
-     */
108
-    private $form_has_errors;
109
-
110
-    /**
111
-     * the absolute top level form section being used on the page
112
-     *
113
-     * @var \EE_Form_Section_Proper $form
114
-     */
115
-    private $form;
116
-
117
-    /**
118
-     * @var \EE_Registry $registry
119
-     */
120
-    protected $registry;
121
-
122
-
123
-
124
-    /**
125
-     * Form constructor.
126
-     *
127
-     * @param string       $form_name
128
-     * @param string       $admin_name
129
-     * @param string       $slug
130
-     * @param string       $form_action
131
-     * @param string       $form_config
132
-     * @param \EE_Registry $registry
133
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
134
-     * @throws \DomainException
135
-     * @throws \InvalidArgumentException
136
-     */
137
-    public function __construct(
138
-        $form_name,
139
-        $admin_name,
140
-        $slug,
141
-        $form_action = '',
142
-        $form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
143
-        \EE_Registry $registry
144
-    ) {
145
-        $this->setFormName($form_name);
146
-        $this->setAdminName($admin_name);
147
-        $this->setSlug($slug);
148
-        $this->setFormAction($form_action);
149
-        $this->setFormConfig($form_config);
150
-        $this->setSubmitBtnText(esc_html__('Submit', 'event_espresso'));
151
-        $this->registry = $registry;
152
-    }
153
-
154
-
155
-
156
-    /**
157
-     * @return array
158
-     */
159
-    public static function getFormConfigConstants()
160
-    {
161
-        return array(
162
-            FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
163
-            FormHandler::ADD_FORM_TAGS_ONLY,
164
-            FormHandler::ADD_FORM_SUBMIT_ONLY,
165
-            FormHandler::DO_NOT_SETUP_FORM,
166
-        );
167
-    }
168
-
169
-
170
-
171
-    /**
172
-     * @param bool $for_display
173
-     * @return \EE_Form_Section_Proper
174
-     * @throws \EE_Error
175
-     * @throws \LogicException
176
-     */
177
-    public function form($for_display = false)
178
-    {
179
-        if (! $this->formIsValid()) {
180
-            return null;
181
-        }
182
-        if ($for_display) {
183
-            $form_config = $this->formConfig();
184
-            if (
185
-                $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
186
-                || $form_config === FormHandler::ADD_FORM_SUBMIT_ONLY
187
-            ) {
188
-                $this->appendSubmitButton();
189
-                $this->clearFormButtonFloats();
190
-            }
191
-        }
192
-        return $this->form;
193
-    }
194
-
195
-
196
-
197
-    /**
198
-     * @return boolean
199
-     * @throws LogicException
200
-     */
201
-    public function formIsValid()
202
-    {
203
-        if (! $this->form instanceof \EE_Form_Section_Proper) {
204
-            static $generated = false;
205
-            if (! $generated) {
206
-                $generated = true;
207
-                $form = apply_filters(
208
-                    'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object',
209
-                    $this->generate(),
210
-                    $this
211
-                );
212
-                if ($form instanceof \EE_Form_Section_Proper) {
213
-                    $this->setForm($form);
214
-                }
215
-            }
216
-            return $this->verifyForm();
217
-        }
218
-        return true;
219
-    }
220
-
221
-
222
-
223
-    /**
224
-     * @return boolean
225
-     * @throws LogicException
226
-     */
227
-    public function verifyForm()
228
-    {
229
-        if ($this->form instanceof \EE_Form_Section_Proper) {
230
-            return true;
231
-        }
232
-        throw new LogicException(
233
-            sprintf(
234
-                esc_html__('The "%1$s" form is invalid or missing', 'event_espresso'),
235
-                $this->form_name
236
-            )
237
-        );
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     * @param \EE_Form_Section_Proper $form
244
-     */
245
-    public function setForm(\EE_Form_Section_Proper $form)
246
-    {
247
-        $this->form = $form;
248
-    }
249
-
250
-
251
-
252
-    /**
253
-     * @return boolean
254
-     */
255
-    public function displayable()
256
-    {
257
-        return $this->displayable;
258
-    }
259
-
260
-
261
-
262
-    /**
263
-     * @param boolean $displayable
264
-     */
265
-    public function setDisplayable($displayable = false)
266
-    {
267
-        $this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN);
268
-    }
269
-
270
-
271
-
272
-    /**
273
-     * a public name for the form that can be displayed on the frontend of a site
274
-     *
275
-     * @return string
276
-     */
277
-    public function formName()
278
-    {
279
-        return $this->form_name;
280
-    }
281
-
282
-
283
-
284
-    /**
285
-     * @param string $form_name
286
-     * @throws InvalidDataTypeException
287
-     */
288
-    public function setFormName($form_name)
289
-    {
290
-        if (! is_string($form_name)) {
291
-            throw new InvalidDataTypeException('$form_name', $form_name, 'string');
292
-        }
293
-        $this->form_name = $form_name;
294
-    }
295
-
296
-
297
-
298
-    /**
299
-     * a public name for the form that can be displayed, but only in the admin
300
-     *
301
-     * @return string
302
-     */
303
-    public function adminName()
304
-    {
305
-        return $this->admin_name;
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * @param string $admin_name
312
-     * @throws InvalidDataTypeException
313
-     */
314
-    public function setAdminName($admin_name)
315
-    {
316
-        if (! is_string($admin_name)) {
317
-            throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
318
-        }
319
-        $this->admin_name = $admin_name;
320
-    }
321
-
322
-
323
-
324
-    /**
325
-     * a URL friendly string that can be used for identifying the form
326
-     *
327
-     * @return string
328
-     */
329
-    public function slug()
330
-    {
331
-        return $this->slug;
332
-    }
333
-
334
-
335
-
336
-    /**
337
-     * @param string $slug
338
-     * @throws InvalidDataTypeException
339
-     */
340
-    public function setSlug($slug)
341
-    {
342
-        if (! is_string($slug)) {
343
-            throw new InvalidDataTypeException('$slug', $slug, 'string');
344
-        }
345
-        $this->slug = $slug;
346
-    }
347
-
348
-
349
-
350
-    /**
351
-     * @return string
352
-     */
353
-    public function submitBtnText()
354
-    {
355
-        return $this->submit_btn_text;
356
-    }
357
-
358
-
359
-
360
-    /**
361
-     * @param string $submit_btn_text
362
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
363
-     * @throws \InvalidArgumentException
364
-     */
365
-    public function setSubmitBtnText($submit_btn_text)
366
-    {
367
-        if (! is_string($submit_btn_text)) {
368
-            throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
369
-        }
370
-        if (empty($submit_btn_text)) {
371
-            throw new InvalidArgumentException(
372
-                esc_html__('Can not set Submit button text because an empty string was provided.', 'event_espresso')
373
-            );
374
-        }
375
-        $this->submit_btn_text = $submit_btn_text;
376
-    }
377
-
378
-
379
-
380
-    /**
381
-     * @return string
382
-     */
383
-    public function formAction()
384
-    {
385
-        return ! empty($this->form_args)
386
-            ? add_query_arg($this->form_args, $this->form_action)
387
-            : $this->form_action;
388
-    }
389
-
390
-
391
-
392
-    /**
393
-     * @param string $form_action
394
-     * @throws InvalidDataTypeException
395
-     */
396
-    public function setFormAction($form_action)
397
-    {
398
-        if (! is_string($form_action)) {
399
-            throw new InvalidDataTypeException('$form_action', $form_action, 'string');
400
-        }
401
-        $this->form_action = $form_action;
402
-    }
403
-
404
-
405
-
406
-    /**
407
-     * @param array $form_args
408
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
409
-     * @throws \InvalidArgumentException
410
-     */
411
-    public function addFormActionArgs($form_args = array())
412
-    {
413
-        if (is_object($form_args)) {
414
-            throw new InvalidDataTypeException(
415
-                '$form_args',
416
-                $form_args,
417
-                'anything other than an object was expected.'
418
-            );
419
-        }
420
-        if (empty($form_args)) {
421
-            throw new InvalidArgumentException(
422
-                esc_html__('The redirect arguments can not be an empty array.', 'event_espresso')
423
-            );
424
-        }
425
-        $this->form_args = array_merge($this->form_args, $form_args);
426
-    }
427
-
428
-
429
-
430
-    /**
431
-     * @return string
432
-     */
433
-    public function formConfig()
434
-    {
435
-        return $this->form_config;
436
-    }
437
-
438
-
439
-
440
-    /**
441
-     * @param string $form_config
442
-     * @throws DomainException
443
-     */
444
-    public function setFormConfig($form_config)
445
-    {
446
-        if (
447
-        ! in_array(
448
-            $form_config,
449
-            array(
450
-                FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
451
-                FormHandler::ADD_FORM_TAGS_ONLY,
452
-                FormHandler::ADD_FORM_SUBMIT_ONLY,
453
-                FormHandler::DO_NOT_SETUP_FORM,
454
-            ),
455
-            true
456
-        )
457
-        ) {
458
-            throw new DomainException(
459
-                sprintf(
460
-                    esc_html__('"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form',
461
-                        'event_espresso'),
462
-                    $form_config
463
-                )
464
-            );
465
-        }
466
-        $this->form_config = $form_config;
467
-    }
468
-
469
-
470
-
471
-    /**
472
-     * called after the form is instantiated
473
-     * and used for performing any logic that needs to occur early
474
-     * before any of the other methods are called.
475
-     * returns true if everything is ok to proceed,
476
-     * and false if no further form logic should be implemented
477
-     *
478
-     * @return boolean
479
-     */
480
-    public function initialize()
481
-    {
482
-        $this->form_has_errors = \EE_Error::has_error(true);
483
-        return true;
484
-    }
485
-
486
-
487
-
488
-    /**
489
-     * used for setting up css and js
490
-     *
491
-     * @return void
492
-     * @throws LogicException
493
-     * @throws \EE_Error
494
-     */
495
-    public function enqueueStylesAndScripts()
496
-    {
497
-        $this->form(false)->enqueue_js();
498
-    }
499
-
500
-
501
-
502
-    /**
503
-     * creates and returns the actual form
504
-     *
505
-     * @return EE_Form_Section_Proper
506
-     */
507
-    abstract public function generate();
508
-
509
-
510
-
511
-    /**
512
-     * creates and returns an EE_Submit_Input labeled "Submit"
513
-     *
514
-     * @param string $text
515
-     * @return \EE_Submit_Input
516
-     */
517
-    public function generateSubmitButton($text = '')
518
-    {
519
-        $text = ! empty($text) ? $text : $this->submitBtnText();
520
-        return new EE_Submit_Input(
521
-            array(
522
-                'html_name'             => 'ee-form-submit-' . $this->slug(),
523
-                'html_id'               => 'ee-form-submit-' . $this->slug(),
524
-                'html_class'            => 'ee-form-submit',
525
-                'html_label'            => '&nbsp;',
526
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
527
-                'default'               => $text,
528
-            )
529
-        );
530
-    }
531
-
532
-
533
-
534
-    /**
535
-     * calls generateSubmitButton() and appends it onto the form along with a float clearing div
536
-     *
537
-     * @param string $text
538
-     * @return void
539
-     * @throws \LogicException
540
-     * @throws \EE_Error
541
-     */
542
-    public function appendSubmitButton($text = '')
543
-    {
544
-        if ($this->form->subsection_exists($this->slug() . '-submit-btn')) {
545
-            return;
546
-        }
547
-        $this->form->add_subsections(
548
-            array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)),
549
-            null,
550
-            false
551
-        );
552
-    }
553
-
554
-
555
-
556
-    /**
557
-     * creates and returns an EE_Submit_Input labeled "Cancel"
558
-     *
559
-     * @param string $text
560
-     * @return \EE_Submit_Input
561
-     */
562
-    public function generateCancelButton($text = '')
563
-    {
564
-        $cancel_button = new EE_Submit_Input(
565
-            array(
566
-                'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
567
-                'html_id'               => 'ee-cancel-form-' . $this->slug(),
568
-                'html_class'            => 'ee-cancel-form',
569
-                'html_label'            => '&nbsp;',
570
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
571
-                'default'               => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'),
572
-            )
573
-        );
574
-        $cancel_button->set_button_css_attributes(false);
575
-        return $cancel_button;
576
-    }
577
-
578
-
579
-
580
-    /**
581
-     * appends a float clearing div onto end of form
582
-     *
583
-     * @return void
584
-     * @throws \EE_Error
585
-     */
586
-    public function clearFormButtonFloats()
587
-    {
588
-        $this->form->add_subsections(
589
-            array(
590
-                'clear-submit-btn-float' => new \EE_Form_Section_HTML(
591
-                    EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx()
592
-                ),
593
-            ),
594
-            null,
595
-            false
596
-        );
597
-    }
598
-
599
-
600
-
601
-    /**
602
-     * takes the generated form and displays it along with ony other non-form HTML that may be required
603
-     * returns a string of HTML that can be directly echoed in a template
604
-     *
605
-     * @return string
606
-     * @throws LogicException
607
-     * @throws \EE_Error
608
-     */
609
-    public function display()
610
-    {
611
-        $form_html = apply_filters(
612
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
613
-            ''
614
-        );
615
-        $form_config = $this->formConfig();
616
-        if (
617
-            $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
618
-            || $form_config === FormHandler::ADD_FORM_TAGS_ONLY
619
-        ) {
620
-            $form_html .= $this->form()->form_open($this->formAction());
621
-        }
622
-        $form_html .= $this->form(true)->get_html($this->form_has_errors);
623
-        if (
624
-            $form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
625
-            || $form_config === FormHandler::ADD_FORM_TAGS_ONLY
626
-        ) {
627
-            $form_html .= $this->form()->form_close();
628
-        }
629
-        $form_html .= apply_filters(
630
-            'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__after_form',
631
-            ''
632
-        );
633
-        return $form_html;
634
-    }
635
-
636
-
637
-
638
-    /**
639
-     * handles processing the form submission
640
-     * returns true or false depending on whether the form was processed successfully or not
641
-     *
642
-     * @param array $submitted_form_data
643
-     * @return array
644
-     * @throws \EE_Error
645
-     * @throws \LogicException
646
-     * @throws InvalidFormSubmissionException
647
-     */
648
-    public function process($submitted_form_data = array())
649
-    {
650
-        if (! $this->form()->was_submitted($submitted_form_data)) {
651
-            throw new InvalidFormSubmissionException($this->form_name);
652
-        }
653
-        $this->form(true)->receive_form_submission($submitted_form_data);
654
-        if (! $this->form()->is_valid()) {
655
-            throw new InvalidFormSubmissionException(
656
-                $this->form_name,
657
-                sprintf(
658
-                    esc_html__(
659
-                        'The "%1$s" form is invalid. Please correct the following errors and resubmit: %2$s %3$s',
660
-                        'event_espresso'
661
-                    ),
662
-                    $this->form_name,
663
-                    '<br />',
664
-                    $this->form()->submission_error_message()
665
-                )
666
-            );
667
-        }
668
-        return $this->form()->valid_data();
669
-    }
34
+	/**
35
+	 * will add opening and closing HTML form tags as well as a submit button
36
+	 */
37
+	const ADD_FORM_TAGS_AND_SUBMIT = 'add_form_tags_and_submit';
38
+
39
+	/**
40
+	 * will add opening and closing HTML form tags but NOT a submit button
41
+	 */
42
+	const ADD_FORM_TAGS_ONLY = 'add_form_tags_only';
43
+
44
+	/**
45
+	 * will NOT add opening and closing HTML form tags but will add a submit button
46
+	 */
47
+	const ADD_FORM_SUBMIT_ONLY = 'add_form_submit_only';
48
+
49
+	/**
50
+	 * will NOT add opening and closing HTML form tags NOR a submit button
51
+	 */
52
+	const DO_NOT_SETUP_FORM = 'do_not_setup_form';
53
+
54
+	/**
55
+	 * if set to false, then this form has no displayable content,
56
+	 * and will only be used for processing data sent passed via GET or POST
57
+	 * defaults to true ( ie: form has displayable content )
58
+	 *
59
+	 * @var boolean $displayable
60
+	 */
61
+	private $displayable = true;
62
+
63
+	/**
64
+	 * @var string $form_name
65
+	 */
66
+	private $form_name;
67
+
68
+	/**
69
+	 * @var string $admin_name
70
+	 */
71
+	private $admin_name;
72
+
73
+	/**
74
+	 * @var string $slug
75
+	 */
76
+	private $slug;
77
+
78
+	/**
79
+	 * @var string $submit_btn_text
80
+	 */
81
+	private $submit_btn_text;
82
+
83
+	/**
84
+	 * @var string $form_action
85
+	 */
86
+	private $form_action;
87
+
88
+	/**
89
+	 * form params in key value pairs
90
+	 * can be added to form action URL or as hidden inputs
91
+	 *
92
+	 * @var array $form_args
93
+	 */
94
+	private $form_args = array();
95
+
96
+	/**
97
+	 * value of one of the string constant above
98
+	 *
99
+	 * @var string $form_config
100
+	 */
101
+	private $form_config;
102
+
103
+	/**
104
+	 * whether or not the form was determined to be invalid
105
+	 *
106
+	 * @var boolean $form_has_errors
107
+	 */
108
+	private $form_has_errors;
109
+
110
+	/**
111
+	 * the absolute top level form section being used on the page
112
+	 *
113
+	 * @var \EE_Form_Section_Proper $form
114
+	 */
115
+	private $form;
116
+
117
+	/**
118
+	 * @var \EE_Registry $registry
119
+	 */
120
+	protected $registry;
121
+
122
+
123
+
124
+	/**
125
+	 * Form constructor.
126
+	 *
127
+	 * @param string       $form_name
128
+	 * @param string       $admin_name
129
+	 * @param string       $slug
130
+	 * @param string       $form_action
131
+	 * @param string       $form_config
132
+	 * @param \EE_Registry $registry
133
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
134
+	 * @throws \DomainException
135
+	 * @throws \InvalidArgumentException
136
+	 */
137
+	public function __construct(
138
+		$form_name,
139
+		$admin_name,
140
+		$slug,
141
+		$form_action = '',
142
+		$form_config = FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
143
+		\EE_Registry $registry
144
+	) {
145
+		$this->setFormName($form_name);
146
+		$this->setAdminName($admin_name);
147
+		$this->setSlug($slug);
148
+		$this->setFormAction($form_action);
149
+		$this->setFormConfig($form_config);
150
+		$this->setSubmitBtnText(esc_html__('Submit', 'event_espresso'));
151
+		$this->registry = $registry;
152
+	}
153
+
154
+
155
+
156
+	/**
157
+	 * @return array
158
+	 */
159
+	public static function getFormConfigConstants()
160
+	{
161
+		return array(
162
+			FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
163
+			FormHandler::ADD_FORM_TAGS_ONLY,
164
+			FormHandler::ADD_FORM_SUBMIT_ONLY,
165
+			FormHandler::DO_NOT_SETUP_FORM,
166
+		);
167
+	}
168
+
169
+
170
+
171
+	/**
172
+	 * @param bool $for_display
173
+	 * @return \EE_Form_Section_Proper
174
+	 * @throws \EE_Error
175
+	 * @throws \LogicException
176
+	 */
177
+	public function form($for_display = false)
178
+	{
179
+		if (! $this->formIsValid()) {
180
+			return null;
181
+		}
182
+		if ($for_display) {
183
+			$form_config = $this->formConfig();
184
+			if (
185
+				$form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
186
+				|| $form_config === FormHandler::ADD_FORM_SUBMIT_ONLY
187
+			) {
188
+				$this->appendSubmitButton();
189
+				$this->clearFormButtonFloats();
190
+			}
191
+		}
192
+		return $this->form;
193
+	}
194
+
195
+
196
+
197
+	/**
198
+	 * @return boolean
199
+	 * @throws LogicException
200
+	 */
201
+	public function formIsValid()
202
+	{
203
+		if (! $this->form instanceof \EE_Form_Section_Proper) {
204
+			static $generated = false;
205
+			if (! $generated) {
206
+				$generated = true;
207
+				$form = apply_filters(
208
+					'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object',
209
+					$this->generate(),
210
+					$this
211
+				);
212
+				if ($form instanceof \EE_Form_Section_Proper) {
213
+					$this->setForm($form);
214
+				}
215
+			}
216
+			return $this->verifyForm();
217
+		}
218
+		return true;
219
+	}
220
+
221
+
222
+
223
+	/**
224
+	 * @return boolean
225
+	 * @throws LogicException
226
+	 */
227
+	public function verifyForm()
228
+	{
229
+		if ($this->form instanceof \EE_Form_Section_Proper) {
230
+			return true;
231
+		}
232
+		throw new LogicException(
233
+			sprintf(
234
+				esc_html__('The "%1$s" form is invalid or missing', 'event_espresso'),
235
+				$this->form_name
236
+			)
237
+		);
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 * @param \EE_Form_Section_Proper $form
244
+	 */
245
+	public function setForm(\EE_Form_Section_Proper $form)
246
+	{
247
+		$this->form = $form;
248
+	}
249
+
250
+
251
+
252
+	/**
253
+	 * @return boolean
254
+	 */
255
+	public function displayable()
256
+	{
257
+		return $this->displayable;
258
+	}
259
+
260
+
261
+
262
+	/**
263
+	 * @param boolean $displayable
264
+	 */
265
+	public function setDisplayable($displayable = false)
266
+	{
267
+		$this->displayable = filter_var($displayable, FILTER_VALIDATE_BOOLEAN);
268
+	}
269
+
270
+
271
+
272
+	/**
273
+	 * a public name for the form that can be displayed on the frontend of a site
274
+	 *
275
+	 * @return string
276
+	 */
277
+	public function formName()
278
+	{
279
+		return $this->form_name;
280
+	}
281
+
282
+
283
+
284
+	/**
285
+	 * @param string $form_name
286
+	 * @throws InvalidDataTypeException
287
+	 */
288
+	public function setFormName($form_name)
289
+	{
290
+		if (! is_string($form_name)) {
291
+			throw new InvalidDataTypeException('$form_name', $form_name, 'string');
292
+		}
293
+		$this->form_name = $form_name;
294
+	}
295
+
296
+
297
+
298
+	/**
299
+	 * a public name for the form that can be displayed, but only in the admin
300
+	 *
301
+	 * @return string
302
+	 */
303
+	public function adminName()
304
+	{
305
+		return $this->admin_name;
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * @param string $admin_name
312
+	 * @throws InvalidDataTypeException
313
+	 */
314
+	public function setAdminName($admin_name)
315
+	{
316
+		if (! is_string($admin_name)) {
317
+			throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
318
+		}
319
+		$this->admin_name = $admin_name;
320
+	}
321
+
322
+
323
+
324
+	/**
325
+	 * a URL friendly string that can be used for identifying the form
326
+	 *
327
+	 * @return string
328
+	 */
329
+	public function slug()
330
+	{
331
+		return $this->slug;
332
+	}
333
+
334
+
335
+
336
+	/**
337
+	 * @param string $slug
338
+	 * @throws InvalidDataTypeException
339
+	 */
340
+	public function setSlug($slug)
341
+	{
342
+		if (! is_string($slug)) {
343
+			throw new InvalidDataTypeException('$slug', $slug, 'string');
344
+		}
345
+		$this->slug = $slug;
346
+	}
347
+
348
+
349
+
350
+	/**
351
+	 * @return string
352
+	 */
353
+	public function submitBtnText()
354
+	{
355
+		return $this->submit_btn_text;
356
+	}
357
+
358
+
359
+
360
+	/**
361
+	 * @param string $submit_btn_text
362
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
363
+	 * @throws \InvalidArgumentException
364
+	 */
365
+	public function setSubmitBtnText($submit_btn_text)
366
+	{
367
+		if (! is_string($submit_btn_text)) {
368
+			throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
369
+		}
370
+		if (empty($submit_btn_text)) {
371
+			throw new InvalidArgumentException(
372
+				esc_html__('Can not set Submit button text because an empty string was provided.', 'event_espresso')
373
+			);
374
+		}
375
+		$this->submit_btn_text = $submit_btn_text;
376
+	}
377
+
378
+
379
+
380
+	/**
381
+	 * @return string
382
+	 */
383
+	public function formAction()
384
+	{
385
+		return ! empty($this->form_args)
386
+			? add_query_arg($this->form_args, $this->form_action)
387
+			: $this->form_action;
388
+	}
389
+
390
+
391
+
392
+	/**
393
+	 * @param string $form_action
394
+	 * @throws InvalidDataTypeException
395
+	 */
396
+	public function setFormAction($form_action)
397
+	{
398
+		if (! is_string($form_action)) {
399
+			throw new InvalidDataTypeException('$form_action', $form_action, 'string');
400
+		}
401
+		$this->form_action = $form_action;
402
+	}
403
+
404
+
405
+
406
+	/**
407
+	 * @param array $form_args
408
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
409
+	 * @throws \InvalidArgumentException
410
+	 */
411
+	public function addFormActionArgs($form_args = array())
412
+	{
413
+		if (is_object($form_args)) {
414
+			throw new InvalidDataTypeException(
415
+				'$form_args',
416
+				$form_args,
417
+				'anything other than an object was expected.'
418
+			);
419
+		}
420
+		if (empty($form_args)) {
421
+			throw new InvalidArgumentException(
422
+				esc_html__('The redirect arguments can not be an empty array.', 'event_espresso')
423
+			);
424
+		}
425
+		$this->form_args = array_merge($this->form_args, $form_args);
426
+	}
427
+
428
+
429
+
430
+	/**
431
+	 * @return string
432
+	 */
433
+	public function formConfig()
434
+	{
435
+		return $this->form_config;
436
+	}
437
+
438
+
439
+
440
+	/**
441
+	 * @param string $form_config
442
+	 * @throws DomainException
443
+	 */
444
+	public function setFormConfig($form_config)
445
+	{
446
+		if (
447
+		! in_array(
448
+			$form_config,
449
+			array(
450
+				FormHandler::ADD_FORM_TAGS_AND_SUBMIT,
451
+				FormHandler::ADD_FORM_TAGS_ONLY,
452
+				FormHandler::ADD_FORM_SUBMIT_ONLY,
453
+				FormHandler::DO_NOT_SETUP_FORM,
454
+			),
455
+			true
456
+		)
457
+		) {
458
+			throw new DomainException(
459
+				sprintf(
460
+					esc_html__('"%1$s" is not a valid value for the form config. Please use one of the class constants on \EventEspresso\core\libraries\form_sections\form_handlers\Form',
461
+						'event_espresso'),
462
+					$form_config
463
+				)
464
+			);
465
+		}
466
+		$this->form_config = $form_config;
467
+	}
468
+
469
+
470
+
471
+	/**
472
+	 * called after the form is instantiated
473
+	 * and used for performing any logic that needs to occur early
474
+	 * before any of the other methods are called.
475
+	 * returns true if everything is ok to proceed,
476
+	 * and false if no further form logic should be implemented
477
+	 *
478
+	 * @return boolean
479
+	 */
480
+	public function initialize()
481
+	{
482
+		$this->form_has_errors = \EE_Error::has_error(true);
483
+		return true;
484
+	}
485
+
486
+
487
+
488
+	/**
489
+	 * used for setting up css and js
490
+	 *
491
+	 * @return void
492
+	 * @throws LogicException
493
+	 * @throws \EE_Error
494
+	 */
495
+	public function enqueueStylesAndScripts()
496
+	{
497
+		$this->form(false)->enqueue_js();
498
+	}
499
+
500
+
501
+
502
+	/**
503
+	 * creates and returns the actual form
504
+	 *
505
+	 * @return EE_Form_Section_Proper
506
+	 */
507
+	abstract public function generate();
508
+
509
+
510
+
511
+	/**
512
+	 * creates and returns an EE_Submit_Input labeled "Submit"
513
+	 *
514
+	 * @param string $text
515
+	 * @return \EE_Submit_Input
516
+	 */
517
+	public function generateSubmitButton($text = '')
518
+	{
519
+		$text = ! empty($text) ? $text : $this->submitBtnText();
520
+		return new EE_Submit_Input(
521
+			array(
522
+				'html_name'             => 'ee-form-submit-' . $this->slug(),
523
+				'html_id'               => 'ee-form-submit-' . $this->slug(),
524
+				'html_class'            => 'ee-form-submit',
525
+				'html_label'            => '&nbsp;',
526
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
527
+				'default'               => $text,
528
+			)
529
+		);
530
+	}
531
+
532
+
533
+
534
+	/**
535
+	 * calls generateSubmitButton() and appends it onto the form along with a float clearing div
536
+	 *
537
+	 * @param string $text
538
+	 * @return void
539
+	 * @throws \LogicException
540
+	 * @throws \EE_Error
541
+	 */
542
+	public function appendSubmitButton($text = '')
543
+	{
544
+		if ($this->form->subsection_exists($this->slug() . '-submit-btn')) {
545
+			return;
546
+		}
547
+		$this->form->add_subsections(
548
+			array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)),
549
+			null,
550
+			false
551
+		);
552
+	}
553
+
554
+
555
+
556
+	/**
557
+	 * creates and returns an EE_Submit_Input labeled "Cancel"
558
+	 *
559
+	 * @param string $text
560
+	 * @return \EE_Submit_Input
561
+	 */
562
+	public function generateCancelButton($text = '')
563
+	{
564
+		$cancel_button = new EE_Submit_Input(
565
+			array(
566
+				'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
567
+				'html_id'               => 'ee-cancel-form-' . $this->slug(),
568
+				'html_class'            => 'ee-cancel-form',
569
+				'html_label'            => '&nbsp;',
570
+				'other_html_attributes' => ' rel="' . $this->slug() . '"',
571
+				'default'               => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'),
572
+			)
573
+		);
574
+		$cancel_button->set_button_css_attributes(false);
575
+		return $cancel_button;
576
+	}
577
+
578
+
579
+
580
+	/**
581
+	 * appends a float clearing div onto end of form
582
+	 *
583
+	 * @return void
584
+	 * @throws \EE_Error
585
+	 */
586
+	public function clearFormButtonFloats()
587
+	{
588
+		$this->form->add_subsections(
589
+			array(
590
+				'clear-submit-btn-float' => new \EE_Form_Section_HTML(
591
+					EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx()
592
+				),
593
+			),
594
+			null,
595
+			false
596
+		);
597
+	}
598
+
599
+
600
+
601
+	/**
602
+	 * takes the generated form and displays it along with ony other non-form HTML that may be required
603
+	 * returns a string of HTML that can be directly echoed in a template
604
+	 *
605
+	 * @return string
606
+	 * @throws LogicException
607
+	 * @throws \EE_Error
608
+	 */
609
+	public function display()
610
+	{
611
+		$form_html = apply_filters(
612
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__before_form',
613
+			''
614
+		);
615
+		$form_config = $this->formConfig();
616
+		if (
617
+			$form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
618
+			|| $form_config === FormHandler::ADD_FORM_TAGS_ONLY
619
+		) {
620
+			$form_html .= $this->form()->form_open($this->formAction());
621
+		}
622
+		$form_html .= $this->form(true)->get_html($this->form_has_errors);
623
+		if (
624
+			$form_config === FormHandler::ADD_FORM_TAGS_AND_SUBMIT
625
+			|| $form_config === FormHandler::ADD_FORM_TAGS_ONLY
626
+		) {
627
+			$form_html .= $this->form()->form_close();
628
+		}
629
+		$form_html .= apply_filters(
630
+			'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__display__after_form',
631
+			''
632
+		);
633
+		return $form_html;
634
+	}
635
+
636
+
637
+
638
+	/**
639
+	 * handles processing the form submission
640
+	 * returns true or false depending on whether the form was processed successfully or not
641
+	 *
642
+	 * @param array $submitted_form_data
643
+	 * @return array
644
+	 * @throws \EE_Error
645
+	 * @throws \LogicException
646
+	 * @throws InvalidFormSubmissionException
647
+	 */
648
+	public function process($submitted_form_data = array())
649
+	{
650
+		if (! $this->form()->was_submitted($submitted_form_data)) {
651
+			throw new InvalidFormSubmissionException($this->form_name);
652
+		}
653
+		$this->form(true)->receive_form_submission($submitted_form_data);
654
+		if (! $this->form()->is_valid()) {
655
+			throw new InvalidFormSubmissionException(
656
+				$this->form_name,
657
+				sprintf(
658
+					esc_html__(
659
+						'The "%1$s" form is invalid. Please correct the following errors and resubmit: %2$s %3$s',
660
+						'event_espresso'
661
+					),
662
+					$this->form_name,
663
+					'<br />',
664
+					$this->form()->submission_error_message()
665
+				)
666
+			);
667
+		}
668
+		return $this->form()->valid_data();
669
+	}
670 670
 
671 671
 
672 672
 
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
11 11
 use EventEspresso\core\exceptions\InvalidDataTypeException;
12 12
 use EventEspresso\core\exceptions\InvalidFormSubmissionException;
13 13
 
14
-if (! defined('EVENT_ESPRESSO_VERSION')) {
14
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
15 15
     exit('No direct script access allowed');
16 16
 }
17 17
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
      */
177 177
     public function form($for_display = false)
178 178
     {
179
-        if (! $this->formIsValid()) {
179
+        if ( ! $this->formIsValid()) {
180 180
             return null;
181 181
         }
182 182
         if ($for_display) {
@@ -200,9 +200,9 @@  discard block
 block discarded – undo
200 200
      */
201 201
     public function formIsValid()
202 202
     {
203
-        if (! $this->form instanceof \EE_Form_Section_Proper) {
203
+        if ( ! $this->form instanceof \EE_Form_Section_Proper) {
204 204
             static $generated = false;
205
-            if (! $generated) {
205
+            if ( ! $generated) {
206 206
                 $generated = true;
207 207
                 $form = apply_filters(
208 208
                     'FHEE__EventEspresso_core_libraries_form_sections_form_handlers_FormHandler__formIsValid__generated_form_object',
@@ -287,7 +287,7 @@  discard block
 block discarded – undo
287 287
      */
288 288
     public function setFormName($form_name)
289 289
     {
290
-        if (! is_string($form_name)) {
290
+        if ( ! is_string($form_name)) {
291 291
             throw new InvalidDataTypeException('$form_name', $form_name, 'string');
292 292
         }
293 293
         $this->form_name = $form_name;
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
      */
314 314
     public function setAdminName($admin_name)
315 315
     {
316
-        if (! is_string($admin_name)) {
316
+        if ( ! is_string($admin_name)) {
317 317
             throw new InvalidDataTypeException('$admin_name', $admin_name, 'string');
318 318
         }
319 319
         $this->admin_name = $admin_name;
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      */
340 340
     public function setSlug($slug)
341 341
     {
342
-        if (! is_string($slug)) {
342
+        if ( ! is_string($slug)) {
343 343
             throw new InvalidDataTypeException('$slug', $slug, 'string');
344 344
         }
345 345
         $this->slug = $slug;
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
      */
365 365
     public function setSubmitBtnText($submit_btn_text)
366 366
     {
367
-        if (! is_string($submit_btn_text)) {
367
+        if ( ! is_string($submit_btn_text)) {
368 368
             throw new InvalidDataTypeException('$submit_btn_text', $submit_btn_text, 'string');
369 369
         }
370 370
         if (empty($submit_btn_text)) {
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
      */
396 396
     public function setFormAction($form_action)
397 397
     {
398
-        if (! is_string($form_action)) {
398
+        if ( ! is_string($form_action)) {
399 399
             throw new InvalidDataTypeException('$form_action', $form_action, 'string');
400 400
         }
401 401
         $this->form_action = $form_action;
@@ -519,11 +519,11 @@  discard block
 block discarded – undo
519 519
         $text = ! empty($text) ? $text : $this->submitBtnText();
520 520
         return new EE_Submit_Input(
521 521
             array(
522
-                'html_name'             => 'ee-form-submit-' . $this->slug(),
523
-                'html_id'               => 'ee-form-submit-' . $this->slug(),
522
+                'html_name'             => 'ee-form-submit-'.$this->slug(),
523
+                'html_id'               => 'ee-form-submit-'.$this->slug(),
524 524
                 'html_class'            => 'ee-form-submit',
525 525
                 'html_label'            => '&nbsp;',
526
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
526
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
527 527
                 'default'               => $text,
528 528
             )
529 529
         );
@@ -541,11 +541,11 @@  discard block
 block discarded – undo
541 541
      */
542 542
     public function appendSubmitButton($text = '')
543 543
     {
544
-        if ($this->form->subsection_exists($this->slug() . '-submit-btn')) {
544
+        if ($this->form->subsection_exists($this->slug().'-submit-btn')) {
545 545
             return;
546 546
         }
547 547
         $this->form->add_subsections(
548
-            array($this->slug() . '-submit-btn' => $this->generateSubmitButton($text)),
548
+            array($this->slug().'-submit-btn' => $this->generateSubmitButton($text)),
549 549
             null,
550 550
             false
551 551
         );
@@ -563,11 +563,11 @@  discard block
 block discarded – undo
563 563
     {
564 564
         $cancel_button = new EE_Submit_Input(
565 565
             array(
566
-                'html_name'             => 'ee-form-submit-' . $this->slug(), // YES! Same name as submit !!!
567
-                'html_id'               => 'ee-cancel-form-' . $this->slug(),
566
+                'html_name'             => 'ee-form-submit-'.$this->slug(), // YES! Same name as submit !!!
567
+                'html_id'               => 'ee-cancel-form-'.$this->slug(),
568 568
                 'html_class'            => 'ee-cancel-form',
569 569
                 'html_label'            => '&nbsp;',
570
-                'other_html_attributes' => ' rel="' . $this->slug() . '"',
570
+                'other_html_attributes' => ' rel="'.$this->slug().'"',
571 571
                 'default'               => ! empty($text) ? $text : esc_html__('Cancel', 'event_espresso'),
572 572
             )
573 573
         );
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
         $this->form->add_subsections(
589 589
             array(
590 590
                 'clear-submit-btn-float' => new \EE_Form_Section_HTML(
591
-                    EEH_HTML::div('', '', 'clear-float') . EEH_HTML::divx()
591
+                    EEH_HTML::div('', '', 'clear-float').EEH_HTML::divx()
592 592
                 ),
593 593
             ),
594 594
             null,
@@ -647,11 +647,11 @@  discard block
 block discarded – undo
647 647
      */
648 648
     public function process($submitted_form_data = array())
649 649
     {
650
-        if (! $this->form()->was_submitted($submitted_form_data)) {
650
+        if ( ! $this->form()->was_submitted($submitted_form_data)) {
651 651
             throw new InvalidFormSubmissionException($this->form_name);
652 652
         }
653 653
         $this->form(true)->receive_form_submission($submitted_form_data);
654
-        if (! $this->form()->is_valid()) {
654
+        if ( ! $this->form()->is_valid()) {
655 655
             throw new InvalidFormSubmissionException(
656 656
                 $this->form_name,
657 657
                 sprintf(
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 2 patches
Indentation   +780 added lines, -780 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 if (! class_exists('WP_List_Table')) {
6
-    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
6
+	require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
7 7
 }
8 8
 
9 9
 
@@ -22,782 +22,782 @@  discard block
 block discarded – undo
22 22
 abstract class EE_Admin_List_Table extends WP_List_Table
23 23
 {
24 24
 
25
-    /**
26
-     * holds the data that will be processed for the table
27
-     *
28
-     * @var array $_data
29
-     */
30
-    protected $_data;
31
-
32
-
33
-    /**
34
-     * This holds the value of all the data available for the given view (for all pages).
35
-     *
36
-     * @var int $_all_data_count
37
-     */
38
-    protected $_all_data_count;
39
-
40
-
41
-    /**
42
-     * Will contain the count of trashed items for the view label.
43
-     *
44
-     * @var int $_trashed_count
45
-     */
46
-    protected $_trashed_count;
47
-
48
-
49
-    /**
50
-     * This is what will be referenced as the slug for the current screen
51
-     *
52
-     * @var string $_screen
53
-     */
54
-    protected $_screen;
55
-
56
-
57
-    /**
58
-     * this is the EE_Admin_Page object
59
-     *
60
-     * @var EE_Admin_Page $_admin_page
61
-     */
62
-    protected $_admin_page;
63
-
64
-
65
-    /**
66
-     * The current view
67
-     *
68
-     * @var string $_view
69
-     */
70
-    protected $_view;
71
-
72
-
73
-    /**
74
-     * array of possible views for this table
75
-     *
76
-     * @var array $_views
77
-     */
78
-    protected $_views;
79
-
80
-
81
-    /**
82
-     * An array of key => value pairs containing information about the current table
83
-     * array(
84
-     *        'plural' => 'plural label',
85
-     *        'singular' => 'singular label',
86
-     *        'ajax' => false, //whether to use ajax or not
87
-     *        'screen' => null, //string used to reference what screen this is
88
-     *        (WP_List_table converts to screen object)
89
-     * )
90
-     *
91
-     * @var array $_wp_list_args
92
-     */
93
-    protected $_wp_list_args;
94
-
95
-    /**
96
-     * an array of column names
97
-     * array(
98
-     *    'internal-name' => 'Title'
99
-     * )
100
-     *
101
-     * @var array $_columns
102
-     */
103
-    protected $_columns;
104
-
105
-    /**
106
-     * An array of sortable columns
107
-     * array(
108
-     *    'internal-name' => 'orderby' //or
109
-     *    'internal-name' => array( 'orderby', true )
110
-     * )
111
-     *
112
-     * @var array $_sortable_columns
113
-     */
114
-    protected $_sortable_columns;
115
-
116
-    /**
117
-     * callback method used to perform AJAX row reordering
118
-     *
119
-     * @var string $_ajax_sorting_callback
120
-     */
121
-    protected $_ajax_sorting_callback;
122
-
123
-    /**
124
-     * An array of hidden columns (if needed)
125
-     * array('internal-name', 'internal-name')
126
-     *
127
-     * @var array $_hidden_columns
128
-     */
129
-    protected $_hidden_columns;
130
-
131
-    /**
132
-     * holds the per_page value
133
-     *
134
-     * @var int $_per_page
135
-     */
136
-    protected $_per_page;
137
-
138
-    /**
139
-     * holds what page number is currently being viewed
140
-     *
141
-     * @var int $_current_page
142
-     */
143
-    protected $_current_page;
144
-
145
-    /**
146
-     * the reference string for the nonce_action
147
-     *
148
-     * @var string $_nonce_action_ref
149
-     */
150
-    protected $_nonce_action_ref;
151
-
152
-    /**
153
-     * property to hold incoming request data (as set by the admin_page_core)
154
-     *
155
-     * @var array $_req_data
156
-     */
157
-    protected $_req_data;
158
-
159
-
160
-    /**
161
-     * yes / no array for admin form fields
162
-     *
163
-     * @var array $_yes_no
164
-     */
165
-    protected $_yes_no = array();
166
-
167
-    /**
168
-     * Array describing buttons that should appear at the bottom of the page
169
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
170
-     * and the values are another array with the following keys
171
-     * array(
172
-     *    'route' => 'page_route',
173
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
174
-     * )
175
-     *
176
-     * @var array $_bottom_buttons
177
-     */
178
-    protected $_bottom_buttons = array();
179
-
180
-
181
-    /**
182
-     * Used to indicate what should be the primary column for the list table.
183
-     * If not present then falls back to what WP calculates
184
-     * as the primary column.
185
-     *
186
-     * @type string $_primary_column
187
-     */
188
-    protected $_primary_column = '';
189
-
190
-
191
-    /**
192
-     * Used to indicate whether the table has a checkbox column or not.
193
-     *
194
-     * @type bool $_has_checkbox_column
195
-     */
196
-    protected $_has_checkbox_column = false;
197
-
198
-
199
-    /**
200
-     * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
201
-     */
202
-    public function __construct(EE_Admin_Page $admin_page)
203
-    {
204
-        $this->_admin_page   = $admin_page;
205
-        $this->_req_data     = $this->_admin_page->get_request_data();
206
-        $this->_view         = $this->_admin_page->get_view();
207
-        $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
208
-        $this->_current_page = $this->get_pagenum();
209
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
210
-        $this->_yes_no       = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
211
-
212
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
213
-
214
-        $this->_setup_data();
215
-        $this->_add_view_counts();
216
-
217
-        $this->_nonce_action_ref = $this->_view;
218
-
219
-        $this->_set_properties();
220
-
221
-        //set primary column
222
-        add_filter('list_table_primary_column', array($this, 'set_primary_column'));
223
-
224
-        //set parent defaults
225
-        parent::__construct($this->_wp_list_args);
226
-
227
-        $this->prepare_items();
228
-    }
229
-
230
-
231
-    /**
232
-     * _setup_data
233
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
234
-     *
235
-     * @uses $this->_admin_page
236
-     * @return void
237
-     */
238
-    abstract protected function _setup_data();
239
-
240
-
241
-    /**
242
-     * set the properties that this class needs to be able to execute wp_list_table properly
243
-     * properties set:
244
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
245
-     * _columns = set the columns in an array.
246
-     * _sortable_columns = columns that are sortable (array).
247
-     * _hidden_columns = columns that are hidden (array)
248
-     * _default_orderby = the default orderby for sorting.
249
-     *
250
-     * @abstract
251
-     * @access protected
252
-     * @return void
253
-     */
254
-    abstract protected function _set_properties();
255
-
256
-
257
-    /**
258
-     * _get_table_filters
259
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
260
-     * get's shown in the table.
261
-     *
262
-     * @abstract
263
-     * @access protected
264
-     * @return string
265
-     */
266
-    abstract protected function _get_table_filters();
267
-
268
-
269
-    /**
270
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
271
-     * counts of the views is accurate.
272
-     *
273
-     * @abstract
274
-     * @access protected
275
-     * @return void
276
-     */
277
-    abstract protected function _add_view_counts();
278
-
279
-
280
-    /**
281
-     * _get_hidden_fields
282
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
283
-     *
284
-     * @return string
285
-     */
286
-    protected function _get_hidden_fields()
287
-    {
288
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
289
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
290
-        //if action is STILL empty, then we set it to default
291
-        $action = empty($action) ? 'default' : $action;
292
-        $field  = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
293
-        $field  .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
294
-        $field  .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
295
-
296
-        $bulk_actions = $this->_get_bulk_actions();
297
-        foreach ($bulk_actions as $bulk_action => $label) {
298
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
299
-        }
300
-
301
-        return $field;
302
-    }
303
-
304
-
305
-    /**
306
-     * _set_column_info
307
-     * we're using this to set the column headers property.
308
-     *
309
-     * @access protected
310
-     * @return void
311
-     */
312
-    protected function _set_column_info()
313
-    {
314
-        $columns   = $this->get_columns();
315
-        $hidden    = $this->get_hidden_columns();
316
-        $_sortable = $this->get_sortable_columns();
317
-
318
-        /**
319
-         * Dynamic hook allowing for adding sortable columns in this list table.
320
-         * Note that $this->screen->id is in the format
321
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
322
-         * table it is: event-espresso_page_espresso_messages.
323
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
324
-         * hook prefix ("event-espresso") will be different.
325
-         *
326
-         * @var array
327
-         */
328
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
329
-
330
-        $sortable = array();
331
-        foreach ($_sortable as $id => $data) {
332
-            if (empty($data)) {
333
-                continue;
334
-            }
335
-            //fix for offset errors with WP_List_Table default get_columninfo()
336
-            if (is_array($data)) {
337
-                $_data[0] = key($data);
338
-                $_data[1] = isset($data[1]) ? $data[1] : false;
339
-            } else {
340
-                $_data[0] = $data;
341
-            }
342
-
343
-            $data = (array)$data;
344
-
345
-            if (! isset($data[1])) {
346
-                $_data[1] = false;
347
-            }
348
-
349
-            $sortable[$id] = $_data;
350
-        }
351
-        $primary               = $this->get_primary_column_name();
352
-        $this->_column_headers = array($columns, $hidden, $sortable, $primary);
353
-    }
354
-
355
-
356
-    /**
357
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
358
-     *
359
-     * @return string
360
-     */
361
-    protected function get_primary_column_name()
362
-    {
363
-        foreach (class_parents($this) as $parent) {
364
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
365
-                return parent::get_primary_column_name();
366
-            }
367
-        }
368
-        return $this->_primary_column;
369
-    }
370
-
371
-
372
-    /**
373
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
374
-     *
375
-     * @param EE_Base_Class $item
376
-     * @param string        $column_name
377
-     * @param string        $primary
378
-     * @return string
379
-     */
380
-    protected function handle_row_actions($item, $column_name, $primary)
381
-    {
382
-        foreach (class_parents($this) as $parent) {
383
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
384
-                return parent::handle_row_actions($item, $column_name, $primary);
385
-            }
386
-        }
387
-        return '';
388
-    }
389
-
390
-
391
-    /**
392
-     * _get_bulk_actions
393
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
394
-     *
395
-     * @access protected
396
-     * @return array bulk_actions
397
-     */
398
-    protected function _get_bulk_actions()
399
-    {
400
-        $actions = array();
401
-        //the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table();
402
-        foreach ($this->_views as $view => $args) {
403
-            if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
404
-                //each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user.
405
-                foreach ($args['bulk_action'] as $route => $label) {
406
-                    if ($this->_admin_page->check_user_access($route, true)) {
407
-                        $actions[$route] = $label;
408
-                    }
409
-                }
410
-            }
411
-        }
412
-        return $actions;
413
-    }
414
-
415
-
416
-    /**
417
-     * _filters
418
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
419
-     * button.
420
-     *
421
-     * @access private
422
-     * @return string html showing filters
423
-     */
424
-    private function _filters()
425
-    {
426
-        $classname = get_class($this);
427
-        $filters   = apply_filters("FHEE__{$classname}__filters", (array)$this->_get_table_filters(), $this,
428
-            $this->_screen);
429
-
430
-        if (empty($filters)) {
431
-            return;
432
-        }
433
-        foreach ($filters as $filter) {
434
-            echo $filter;
435
-        }
436
-        //add filter button at end
437
-        echo '<input type="submit" class="button-secondary" value="' . __('Filter',
438
-                'event_espresso') . '" id="post-query-submit" />';
439
-        //add reset filters button at end
440
-        echo '<a class="button button-secondary"  href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters',
441
-                'event_espresso') . '</a>';
442
-    }
443
-
444
-
445
-    /**
446
-     * Callback for 'list_table_primary_column' WordPress filter
447
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
448
-     * column when class is instantiated.
449
-     *
450
-     * @see WP_List_Table::get_primary_column_name
451
-     * @param string $column_name
452
-     * @return string
453
-     */
454
-    public function set_primary_column($column_name)
455
-    {
456
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
457
-    }
458
-
459
-
460
-    /**
461
-     *
462
-     */
463
-    public function prepare_items()
464
-    {
465
-
466
-        $this->_set_column_info();
467
-        //$this->_column_headers = $this->get_column_info();
468
-        $total_items = $this->_all_data_count;
469
-        $this->process_bulk_action();
470
-
471
-        $this->items = $this->_data;
472
-        $this->set_pagination_args(
473
-            array(
474
-                'total_items' => $total_items,
475
-                'per_page'    => $this->_per_page,
476
-                'total_pages' => ceil($total_items / $this->_per_page),
477
-            )
478
-        );
479
-    }
480
-
481
-
482
-    /**
483
-     * This column is the default for when there is no defined column method for a registered column.
484
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
485
-     *
486
-     * @param EE_Base_Class $item
487
-     * @param string        $column_name The column being called.
488
-     * @return string html content for the column
489
-     */
490
-    public function column_default($item, $column_name)
491
-    {
492
-        /**
493
-         * Dynamic hook allowing for adding additional column content in this list table.
494
-         * Note that $this->screen->id is in the format
495
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
496
-         * table it is: event-espresso_page_espresso_messages.
497
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
498
-         * hook prefix ("event-espresso") will be different.
499
-         */
500
-        do_action('AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item,
501
-            $this->_screen);
502
-    }
503
-
504
-
505
-    /**
506
-     * Get a list of columns. The format is:
507
-     * 'internal-name' => 'Title'
508
-     *
509
-     * @since  3.1.0
510
-     * @access public
511
-     * @abstract
512
-     * @return array
513
-     */
514
-    public function get_columns()
515
-    {
516
-        /**
517
-         * Dynamic hook allowing for adding additional columns in this list table.
518
-         * Note that $this->screen->id is in the format
519
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
520
-         * table it is: event-espresso_page_espresso_messages.
521
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
522
-         * hook prefix ("event-espresso") will be different.
523
-         *
524
-         * @var array
525
-         */
526
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
527
-        return $columns;
528
-    }
529
-
530
-
531
-    /**
532
-     * Get an associative array ( id => link ) with the list
533
-     * of views available on this table.
534
-     *
535
-     * @since  3.1.0
536
-     * @access protected
537
-     * @return array
538
-     */
539
-    public function get_views()
540
-    {
541
-        return $this->_views;
542
-    }
543
-
544
-    public function display_views()
545
-    {
546
-        $views           = $this->get_views();
547
-        $assembled_views = array();
548
-
549
-        if (empty($views)) {
550
-            return;
551
-        }
552
-        echo "<ul class='subsubsub'>\n";
553
-        foreach ($views as $view) {
554
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
555
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
556
-                $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>';
557
-            }
558
-        }
559
-
560
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
561
-        echo "</ul>";
562
-    }
563
-
564
-
565
-    /**
566
-     * Generates content for a single row of the table
567
-     *
568
-     * @since  4.1
569
-     * @access public
570
-     * @param EE_Base_Class $item The current item
571
-     */
572
-    public function single_row($item)
573
-    {
574
-        $row_class = $this->_get_row_class($item);
575
-        echo '<tr class="' . esc_attr($row_class) . '">';
576
-        $this->single_row_columns($item);
577
-        echo '</tr>';
578
-    }
579
-
580
-
581
-    /**
582
-     * This simply sets up the row class for the table rows.
583
-     * Allows for easier overriding of child methods for setting up sorting.
584
-     *
585
-     * @param  EE_Base_Class $item the current item
586
-     * @return string
587
-     */
588
-    protected function _get_row_class($item)
589
-    {
590
-        static $row_class = '';
591
-        $row_class = ($row_class === '' ? 'alternate' : '');
592
-
593
-        $new_row_class = $row_class;
594
-
595
-        if (! empty($this->_ajax_sorting_callback)) {
596
-            $new_row_class .= ' rowsortable';
597
-        }
598
-
599
-        return $new_row_class;
600
-    }
601
-
602
-
603
-    /**
604
-     * @return array
605
-     */
606
-    public function get_sortable_columns()
607
-    {
608
-        return (array)$this->_sortable_columns;
609
-    }
610
-
611
-
612
-    /**
613
-     * @return string
614
-     */
615
-    public function get_ajax_sorting_callback()
616
-    {
617
-        return $this->_ajax_sorting_callback;
618
-    }
619
-
620
-
621
-    /**
622
-     * @return array
623
-     */
624
-    public function get_hidden_columns()
625
-    {
626
-        $user_id     = get_current_user_id();
627
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
628
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
629
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
630
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
631
-        }
632
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
633
-        return (array)get_user_option($ref, $user_id);
634
-    }
635
-
636
-
637
-    /**
638
-     * Generates the columns for a single row of the table.
639
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
640
-     * column.
641
-     *
642
-     * @since 3.1.0
643
-     * @param EE_Base_Class $item The current item
644
-     */
645
-    public function single_row_columns($item)
646
-    {
647
-        list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
648
-
649
-        global $wp_version;
650
-        $use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
651
-
652
-        foreach ($columns as $column_name => $column_display_name) {
653
-
654
-            /**
655
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are
656
-             * hidden or not instead of using "display:none;".  This bit of code provides backward compat.
657
-             */
658
-            $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
659
-            $style        = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
660
-
661
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
662
-            if ($primary === $column_name) {
663
-                $classes .= ' has-row-actions column-primary';
664
-            }
665
-
666
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
667
-
668
-            $class = "class='$classes'";
669
-
670
-            $attributes = "$class$style$data";
671
-
672
-            if ($column_name === 'cb') {
673
-                echo '<th scope="row" class="check-column">';
674
-                echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
675
-                    $this->column_cb($item), $item, $this);
676
-                echo '</th>';
677
-            } elseif (method_exists($this, 'column_' . $column_name)) {
678
-                echo "<td $attributes>";
679
-                echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
680
-                    call_user_func(array($this, 'column_' . $column_name), $item), $item, $this);
681
-                echo $this->handle_row_actions($item, $column_name, $primary);
682
-                echo "</td>";
683
-            } else {
684
-                echo "<td $attributes>";
685
-                echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
686
-                    $this->column_default($item, $column_name), $item, $column_name, $this);
687
-                echo $this->handle_row_actions($item, $column_name, $primary);
688
-                echo "</td>";
689
-            }
690
-        }
691
-    }
692
-
693
-
694
-    /**
695
-     * Extra controls to be displayed between bulk actions and pagination
696
-     *
697
-     * @access public
698
-     * @param string $which
699
-     * @throws \EE_Error
700
-     */
701
-    public function extra_tablenav($which)
702
-    {
703
-        if ($which === 'top') {
704
-            $this->_filters();
705
-            echo $this->_get_hidden_fields();
706
-        } else {
707
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
708
-            foreach ($this->_bottom_buttons as $type => $action) {
709
-                $route         = isset($action['route']) ? $action['route'] : '';
710
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
711
-                echo $this->_admin_page->get_action_link_or_button(
712
-                    $route,
713
-                    $type,
714
-                    $extra_request,
715
-                    'button button-secondary',
716
-                    '',
717
-                    false
718
-                );
719
-            }
720
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
721
-            echo '</div>';
722
-        }
723
-        //echo $this->_entries_per_page_dropdown;
724
-    }
725
-
726
-
727
-    /**
728
-     * Get an associative array ( option_name => option_title ) with the list
729
-     * of bulk actions available on this table.
730
-     *
731
-     * @since  3.1.0
732
-     * @access protected
733
-     * @return array
734
-     */
735
-    public function get_bulk_actions()
736
-    {
737
-        return (array)$this->_get_bulk_actions();
738
-    }
739
-
740
-    public function process_bulk_action()
741
-    {
742
-        //this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for reference in case there is a case where it gets used.
743
-    }
744
-
745
-
746
-    /**
747
-     * returns the EE admin page this list table is associated with
748
-     *
749
-     * @return EE_Admin_Page
750
-     */
751
-    public function get_admin_page()
752
-    {
753
-        return $this->_admin_page;
754
-    }
755
-
756
-
757
-    /**
758
-     * A "helper" function for all children to provide an html string of
759
-     * actions to output in their content.  It is preferable for child classes
760
-     * to use this method for generating their actions content so that it's
761
-     * filterable by plugins
762
-     *
763
-     * @param string        $action_container           what are the html container
764
-     *                                                  elements for this actions string?
765
-     * @param string        $action_class               What class is for the container
766
-     *                                                  element.
767
-     * @param string        $action_items               The contents for the action items
768
-     *                                                  container.  This is filtered before
769
-     *                                                  returned.
770
-     * @param string        $action_id                  What id (optional) is used for the
771
-     *                                                  container element.
772
-     * @param EE_Base_Class $item                       The object for the column displaying
773
-     *                                                  the actions.
774
-     * @return string The assembled action elements container.
775
-     */
776
-    protected function _action_string(
777
-        $action_items,
778
-        $item,
779
-        $action_container = 'ul',
780
-        $action_class = '',
781
-        $action_id = ''
782
-    ) {
783
-        $content      = '';
784
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
785
-        $action_id    = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
786
-        $content      .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
787
-        try {
788
-            $content .= apply_filters(
789
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
790
-                $action_items,
791
-                $item,
792
-                $this
793
-            );
794
-        } catch (\Exception $e) {
795
-            if (WP_DEBUG) {
796
-                \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
797
-            }
798
-            $content .= $action_items;
799
-        }
800
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
801
-        return $content;
802
-    }
25
+	/**
26
+	 * holds the data that will be processed for the table
27
+	 *
28
+	 * @var array $_data
29
+	 */
30
+	protected $_data;
31
+
32
+
33
+	/**
34
+	 * This holds the value of all the data available for the given view (for all pages).
35
+	 *
36
+	 * @var int $_all_data_count
37
+	 */
38
+	protected $_all_data_count;
39
+
40
+
41
+	/**
42
+	 * Will contain the count of trashed items for the view label.
43
+	 *
44
+	 * @var int $_trashed_count
45
+	 */
46
+	protected $_trashed_count;
47
+
48
+
49
+	/**
50
+	 * This is what will be referenced as the slug for the current screen
51
+	 *
52
+	 * @var string $_screen
53
+	 */
54
+	protected $_screen;
55
+
56
+
57
+	/**
58
+	 * this is the EE_Admin_Page object
59
+	 *
60
+	 * @var EE_Admin_Page $_admin_page
61
+	 */
62
+	protected $_admin_page;
63
+
64
+
65
+	/**
66
+	 * The current view
67
+	 *
68
+	 * @var string $_view
69
+	 */
70
+	protected $_view;
71
+
72
+
73
+	/**
74
+	 * array of possible views for this table
75
+	 *
76
+	 * @var array $_views
77
+	 */
78
+	protected $_views;
79
+
80
+
81
+	/**
82
+	 * An array of key => value pairs containing information about the current table
83
+	 * array(
84
+	 *        'plural' => 'plural label',
85
+	 *        'singular' => 'singular label',
86
+	 *        'ajax' => false, //whether to use ajax or not
87
+	 *        'screen' => null, //string used to reference what screen this is
88
+	 *        (WP_List_table converts to screen object)
89
+	 * )
90
+	 *
91
+	 * @var array $_wp_list_args
92
+	 */
93
+	protected $_wp_list_args;
94
+
95
+	/**
96
+	 * an array of column names
97
+	 * array(
98
+	 *    'internal-name' => 'Title'
99
+	 * )
100
+	 *
101
+	 * @var array $_columns
102
+	 */
103
+	protected $_columns;
104
+
105
+	/**
106
+	 * An array of sortable columns
107
+	 * array(
108
+	 *    'internal-name' => 'orderby' //or
109
+	 *    'internal-name' => array( 'orderby', true )
110
+	 * )
111
+	 *
112
+	 * @var array $_sortable_columns
113
+	 */
114
+	protected $_sortable_columns;
115
+
116
+	/**
117
+	 * callback method used to perform AJAX row reordering
118
+	 *
119
+	 * @var string $_ajax_sorting_callback
120
+	 */
121
+	protected $_ajax_sorting_callback;
122
+
123
+	/**
124
+	 * An array of hidden columns (if needed)
125
+	 * array('internal-name', 'internal-name')
126
+	 *
127
+	 * @var array $_hidden_columns
128
+	 */
129
+	protected $_hidden_columns;
130
+
131
+	/**
132
+	 * holds the per_page value
133
+	 *
134
+	 * @var int $_per_page
135
+	 */
136
+	protected $_per_page;
137
+
138
+	/**
139
+	 * holds what page number is currently being viewed
140
+	 *
141
+	 * @var int $_current_page
142
+	 */
143
+	protected $_current_page;
144
+
145
+	/**
146
+	 * the reference string for the nonce_action
147
+	 *
148
+	 * @var string $_nonce_action_ref
149
+	 */
150
+	protected $_nonce_action_ref;
151
+
152
+	/**
153
+	 * property to hold incoming request data (as set by the admin_page_core)
154
+	 *
155
+	 * @var array $_req_data
156
+	 */
157
+	protected $_req_data;
158
+
159
+
160
+	/**
161
+	 * yes / no array for admin form fields
162
+	 *
163
+	 * @var array $_yes_no
164
+	 */
165
+	protected $_yes_no = array();
166
+
167
+	/**
168
+	 * Array describing buttons that should appear at the bottom of the page
169
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
170
+	 * and the values are another array with the following keys
171
+	 * array(
172
+	 *    'route' => 'page_route',
173
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
174
+	 * )
175
+	 *
176
+	 * @var array $_bottom_buttons
177
+	 */
178
+	protected $_bottom_buttons = array();
179
+
180
+
181
+	/**
182
+	 * Used to indicate what should be the primary column for the list table.
183
+	 * If not present then falls back to what WP calculates
184
+	 * as the primary column.
185
+	 *
186
+	 * @type string $_primary_column
187
+	 */
188
+	protected $_primary_column = '';
189
+
190
+
191
+	/**
192
+	 * Used to indicate whether the table has a checkbox column or not.
193
+	 *
194
+	 * @type bool $_has_checkbox_column
195
+	 */
196
+	protected $_has_checkbox_column = false;
197
+
198
+
199
+	/**
200
+	 * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
201
+	 */
202
+	public function __construct(EE_Admin_Page $admin_page)
203
+	{
204
+		$this->_admin_page   = $admin_page;
205
+		$this->_req_data     = $this->_admin_page->get_request_data();
206
+		$this->_view         = $this->_admin_page->get_view();
207
+		$this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
208
+		$this->_current_page = $this->get_pagenum();
209
+		$this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
210
+		$this->_yes_no       = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
211
+
212
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
213
+
214
+		$this->_setup_data();
215
+		$this->_add_view_counts();
216
+
217
+		$this->_nonce_action_ref = $this->_view;
218
+
219
+		$this->_set_properties();
220
+
221
+		//set primary column
222
+		add_filter('list_table_primary_column', array($this, 'set_primary_column'));
223
+
224
+		//set parent defaults
225
+		parent::__construct($this->_wp_list_args);
226
+
227
+		$this->prepare_items();
228
+	}
229
+
230
+
231
+	/**
232
+	 * _setup_data
233
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
234
+	 *
235
+	 * @uses $this->_admin_page
236
+	 * @return void
237
+	 */
238
+	abstract protected function _setup_data();
239
+
240
+
241
+	/**
242
+	 * set the properties that this class needs to be able to execute wp_list_table properly
243
+	 * properties set:
244
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
245
+	 * _columns = set the columns in an array.
246
+	 * _sortable_columns = columns that are sortable (array).
247
+	 * _hidden_columns = columns that are hidden (array)
248
+	 * _default_orderby = the default orderby for sorting.
249
+	 *
250
+	 * @abstract
251
+	 * @access protected
252
+	 * @return void
253
+	 */
254
+	abstract protected function _set_properties();
255
+
256
+
257
+	/**
258
+	 * _get_table_filters
259
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
260
+	 * get's shown in the table.
261
+	 *
262
+	 * @abstract
263
+	 * @access protected
264
+	 * @return string
265
+	 */
266
+	abstract protected function _get_table_filters();
267
+
268
+
269
+	/**
270
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
271
+	 * counts of the views is accurate.
272
+	 *
273
+	 * @abstract
274
+	 * @access protected
275
+	 * @return void
276
+	 */
277
+	abstract protected function _add_view_counts();
278
+
279
+
280
+	/**
281
+	 * _get_hidden_fields
282
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
283
+	 *
284
+	 * @return string
285
+	 */
286
+	protected function _get_hidden_fields()
287
+	{
288
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
289
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
290
+		//if action is STILL empty, then we set it to default
291
+		$action = empty($action) ? 'default' : $action;
292
+		$field  = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
293
+		$field  .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
294
+		$field  .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
295
+
296
+		$bulk_actions = $this->_get_bulk_actions();
297
+		foreach ($bulk_actions as $bulk_action => $label) {
298
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
299
+		}
300
+
301
+		return $field;
302
+	}
303
+
304
+
305
+	/**
306
+	 * _set_column_info
307
+	 * we're using this to set the column headers property.
308
+	 *
309
+	 * @access protected
310
+	 * @return void
311
+	 */
312
+	protected function _set_column_info()
313
+	{
314
+		$columns   = $this->get_columns();
315
+		$hidden    = $this->get_hidden_columns();
316
+		$_sortable = $this->get_sortable_columns();
317
+
318
+		/**
319
+		 * Dynamic hook allowing for adding sortable columns in this list table.
320
+		 * Note that $this->screen->id is in the format
321
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
322
+		 * table it is: event-espresso_page_espresso_messages.
323
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
324
+		 * hook prefix ("event-espresso") will be different.
325
+		 *
326
+		 * @var array
327
+		 */
328
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
329
+
330
+		$sortable = array();
331
+		foreach ($_sortable as $id => $data) {
332
+			if (empty($data)) {
333
+				continue;
334
+			}
335
+			//fix for offset errors with WP_List_Table default get_columninfo()
336
+			if (is_array($data)) {
337
+				$_data[0] = key($data);
338
+				$_data[1] = isset($data[1]) ? $data[1] : false;
339
+			} else {
340
+				$_data[0] = $data;
341
+			}
342
+
343
+			$data = (array)$data;
344
+
345
+			if (! isset($data[1])) {
346
+				$_data[1] = false;
347
+			}
348
+
349
+			$sortable[$id] = $_data;
350
+		}
351
+		$primary               = $this->get_primary_column_name();
352
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
353
+	}
354
+
355
+
356
+	/**
357
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
358
+	 *
359
+	 * @return string
360
+	 */
361
+	protected function get_primary_column_name()
362
+	{
363
+		foreach (class_parents($this) as $parent) {
364
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
365
+				return parent::get_primary_column_name();
366
+			}
367
+		}
368
+		return $this->_primary_column;
369
+	}
370
+
371
+
372
+	/**
373
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
374
+	 *
375
+	 * @param EE_Base_Class $item
376
+	 * @param string        $column_name
377
+	 * @param string        $primary
378
+	 * @return string
379
+	 */
380
+	protected function handle_row_actions($item, $column_name, $primary)
381
+	{
382
+		foreach (class_parents($this) as $parent) {
383
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
384
+				return parent::handle_row_actions($item, $column_name, $primary);
385
+			}
386
+		}
387
+		return '';
388
+	}
389
+
390
+
391
+	/**
392
+	 * _get_bulk_actions
393
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
394
+	 *
395
+	 * @access protected
396
+	 * @return array bulk_actions
397
+	 */
398
+	protected function _get_bulk_actions()
399
+	{
400
+		$actions = array();
401
+		//the _views property should have the bulk_actions, so let's go through and extract them into a properly formatted array for the wp_list_table();
402
+		foreach ($this->_views as $view => $args) {
403
+			if ($this->_view === $view && isset($args['bulk_action']) && is_array($args['bulk_action'])) {
404
+				//each bulk action will correspond with a admin page route, so we can check whatever the capability is for that page route and skip adding the bulk action if no access for the current logged in user.
405
+				foreach ($args['bulk_action'] as $route => $label) {
406
+					if ($this->_admin_page->check_user_access($route, true)) {
407
+						$actions[$route] = $label;
408
+					}
409
+				}
410
+			}
411
+		}
412
+		return $actions;
413
+	}
414
+
415
+
416
+	/**
417
+	 * _filters
418
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
419
+	 * button.
420
+	 *
421
+	 * @access private
422
+	 * @return string html showing filters
423
+	 */
424
+	private function _filters()
425
+	{
426
+		$classname = get_class($this);
427
+		$filters   = apply_filters("FHEE__{$classname}__filters", (array)$this->_get_table_filters(), $this,
428
+			$this->_screen);
429
+
430
+		if (empty($filters)) {
431
+			return;
432
+		}
433
+		foreach ($filters as $filter) {
434
+			echo $filter;
435
+		}
436
+		//add filter button at end
437
+		echo '<input type="submit" class="button-secondary" value="' . __('Filter',
438
+				'event_espresso') . '" id="post-query-submit" />';
439
+		//add reset filters button at end
440
+		echo '<a class="button button-secondary"  href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters',
441
+				'event_espresso') . '</a>';
442
+	}
443
+
444
+
445
+	/**
446
+	 * Callback for 'list_table_primary_column' WordPress filter
447
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
448
+	 * column when class is instantiated.
449
+	 *
450
+	 * @see WP_List_Table::get_primary_column_name
451
+	 * @param string $column_name
452
+	 * @return string
453
+	 */
454
+	public function set_primary_column($column_name)
455
+	{
456
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
457
+	}
458
+
459
+
460
+	/**
461
+	 *
462
+	 */
463
+	public function prepare_items()
464
+	{
465
+
466
+		$this->_set_column_info();
467
+		//$this->_column_headers = $this->get_column_info();
468
+		$total_items = $this->_all_data_count;
469
+		$this->process_bulk_action();
470
+
471
+		$this->items = $this->_data;
472
+		$this->set_pagination_args(
473
+			array(
474
+				'total_items' => $total_items,
475
+				'per_page'    => $this->_per_page,
476
+				'total_pages' => ceil($total_items / $this->_per_page),
477
+			)
478
+		);
479
+	}
480
+
481
+
482
+	/**
483
+	 * This column is the default for when there is no defined column method for a registered column.
484
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
485
+	 *
486
+	 * @param EE_Base_Class $item
487
+	 * @param string        $column_name The column being called.
488
+	 * @return string html content for the column
489
+	 */
490
+	public function column_default($item, $column_name)
491
+	{
492
+		/**
493
+		 * Dynamic hook allowing for adding additional column content in this list table.
494
+		 * Note that $this->screen->id is in the format
495
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
496
+		 * table it is: event-espresso_page_espresso_messages.
497
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
498
+		 * hook prefix ("event-espresso") will be different.
499
+		 */
500
+		do_action('AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item,
501
+			$this->_screen);
502
+	}
503
+
504
+
505
+	/**
506
+	 * Get a list of columns. The format is:
507
+	 * 'internal-name' => 'Title'
508
+	 *
509
+	 * @since  3.1.0
510
+	 * @access public
511
+	 * @abstract
512
+	 * @return array
513
+	 */
514
+	public function get_columns()
515
+	{
516
+		/**
517
+		 * Dynamic hook allowing for adding additional columns in this list table.
518
+		 * Note that $this->screen->id is in the format
519
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
520
+		 * table it is: event-espresso_page_espresso_messages.
521
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
522
+		 * hook prefix ("event-espresso") will be different.
523
+		 *
524
+		 * @var array
525
+		 */
526
+		$columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
527
+		return $columns;
528
+	}
529
+
530
+
531
+	/**
532
+	 * Get an associative array ( id => link ) with the list
533
+	 * of views available on this table.
534
+	 *
535
+	 * @since  3.1.0
536
+	 * @access protected
537
+	 * @return array
538
+	 */
539
+	public function get_views()
540
+	{
541
+		return $this->_views;
542
+	}
543
+
544
+	public function display_views()
545
+	{
546
+		$views           = $this->get_views();
547
+		$assembled_views = array();
548
+
549
+		if (empty($views)) {
550
+			return;
551
+		}
552
+		echo "<ul class='subsubsub'>\n";
553
+		foreach ($views as $view) {
554
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
555
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
556
+				$assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>';
557
+			}
558
+		}
559
+
560
+		echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
561
+		echo "</ul>";
562
+	}
563
+
564
+
565
+	/**
566
+	 * Generates content for a single row of the table
567
+	 *
568
+	 * @since  4.1
569
+	 * @access public
570
+	 * @param EE_Base_Class $item The current item
571
+	 */
572
+	public function single_row($item)
573
+	{
574
+		$row_class = $this->_get_row_class($item);
575
+		echo '<tr class="' . esc_attr($row_class) . '">';
576
+		$this->single_row_columns($item);
577
+		echo '</tr>';
578
+	}
579
+
580
+
581
+	/**
582
+	 * This simply sets up the row class for the table rows.
583
+	 * Allows for easier overriding of child methods for setting up sorting.
584
+	 *
585
+	 * @param  EE_Base_Class $item the current item
586
+	 * @return string
587
+	 */
588
+	protected function _get_row_class($item)
589
+	{
590
+		static $row_class = '';
591
+		$row_class = ($row_class === '' ? 'alternate' : '');
592
+
593
+		$new_row_class = $row_class;
594
+
595
+		if (! empty($this->_ajax_sorting_callback)) {
596
+			$new_row_class .= ' rowsortable';
597
+		}
598
+
599
+		return $new_row_class;
600
+	}
601
+
602
+
603
+	/**
604
+	 * @return array
605
+	 */
606
+	public function get_sortable_columns()
607
+	{
608
+		return (array)$this->_sortable_columns;
609
+	}
610
+
611
+
612
+	/**
613
+	 * @return string
614
+	 */
615
+	public function get_ajax_sorting_callback()
616
+	{
617
+		return $this->_ajax_sorting_callback;
618
+	}
619
+
620
+
621
+	/**
622
+	 * @return array
623
+	 */
624
+	public function get_hidden_columns()
625
+	{
626
+		$user_id     = get_current_user_id();
627
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
628
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
629
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
630
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
631
+		}
632
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
633
+		return (array)get_user_option($ref, $user_id);
634
+	}
635
+
636
+
637
+	/**
638
+	 * Generates the columns for a single row of the table.
639
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
640
+	 * column.
641
+	 *
642
+	 * @since 3.1.0
643
+	 * @param EE_Base_Class $item The current item
644
+	 */
645
+	public function single_row_columns($item)
646
+	{
647
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
648
+
649
+		global $wp_version;
650
+		$use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
651
+
652
+		foreach ($columns as $column_name => $column_display_name) {
653
+
654
+			/**
655
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns are
656
+			 * hidden or not instead of using "display:none;".  This bit of code provides backward compat.
657
+			 */
658
+			$hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
659
+			$style        = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
660
+
661
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
662
+			if ($primary === $column_name) {
663
+				$classes .= ' has-row-actions column-primary';
664
+			}
665
+
666
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
667
+
668
+			$class = "class='$classes'";
669
+
670
+			$attributes = "$class$style$data";
671
+
672
+			if ($column_name === 'cb') {
673
+				echo '<th scope="row" class="check-column">';
674
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
675
+					$this->column_cb($item), $item, $this);
676
+				echo '</th>';
677
+			} elseif (method_exists($this, 'column_' . $column_name)) {
678
+				echo "<td $attributes>";
679
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
680
+					call_user_func(array($this, 'column_' . $column_name), $item), $item, $this);
681
+				echo $this->handle_row_actions($item, $column_name, $primary);
682
+				echo "</td>";
683
+			} else {
684
+				echo "<td $attributes>";
685
+				echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
686
+					$this->column_default($item, $column_name), $item, $column_name, $this);
687
+				echo $this->handle_row_actions($item, $column_name, $primary);
688
+				echo "</td>";
689
+			}
690
+		}
691
+	}
692
+
693
+
694
+	/**
695
+	 * Extra controls to be displayed between bulk actions and pagination
696
+	 *
697
+	 * @access public
698
+	 * @param string $which
699
+	 * @throws \EE_Error
700
+	 */
701
+	public function extra_tablenav($which)
702
+	{
703
+		if ($which === 'top') {
704
+			$this->_filters();
705
+			echo $this->_get_hidden_fields();
706
+		} else {
707
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
708
+			foreach ($this->_bottom_buttons as $type => $action) {
709
+				$route         = isset($action['route']) ? $action['route'] : '';
710
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
711
+				echo $this->_admin_page->get_action_link_or_button(
712
+					$route,
713
+					$type,
714
+					$extra_request,
715
+					'button button-secondary',
716
+					'',
717
+					false
718
+				);
719
+			}
720
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
721
+			echo '</div>';
722
+		}
723
+		//echo $this->_entries_per_page_dropdown;
724
+	}
725
+
726
+
727
+	/**
728
+	 * Get an associative array ( option_name => option_title ) with the list
729
+	 * of bulk actions available on this table.
730
+	 *
731
+	 * @since  3.1.0
732
+	 * @access protected
733
+	 * @return array
734
+	 */
735
+	public function get_bulk_actions()
736
+	{
737
+		return (array)$this->_get_bulk_actions();
738
+	}
739
+
740
+	public function process_bulk_action()
741
+	{
742
+		//this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for reference in case there is a case where it gets used.
743
+	}
744
+
745
+
746
+	/**
747
+	 * returns the EE admin page this list table is associated with
748
+	 *
749
+	 * @return EE_Admin_Page
750
+	 */
751
+	public function get_admin_page()
752
+	{
753
+		return $this->_admin_page;
754
+	}
755
+
756
+
757
+	/**
758
+	 * A "helper" function for all children to provide an html string of
759
+	 * actions to output in their content.  It is preferable for child classes
760
+	 * to use this method for generating their actions content so that it's
761
+	 * filterable by plugins
762
+	 *
763
+	 * @param string        $action_container           what are the html container
764
+	 *                                                  elements for this actions string?
765
+	 * @param string        $action_class               What class is for the container
766
+	 *                                                  element.
767
+	 * @param string        $action_items               The contents for the action items
768
+	 *                                                  container.  This is filtered before
769
+	 *                                                  returned.
770
+	 * @param string        $action_id                  What id (optional) is used for the
771
+	 *                                                  container element.
772
+	 * @param EE_Base_Class $item                       The object for the column displaying
773
+	 *                                                  the actions.
774
+	 * @return string The assembled action elements container.
775
+	 */
776
+	protected function _action_string(
777
+		$action_items,
778
+		$item,
779
+		$action_container = 'ul',
780
+		$action_class = '',
781
+		$action_id = ''
782
+	) {
783
+		$content      = '';
784
+		$action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
785
+		$action_id    = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
786
+		$content      .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
787
+		try {
788
+			$content .= apply_filters(
789
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
790
+				$action_items,
791
+				$item,
792
+				$this
793
+			);
794
+		} catch (\Exception $e) {
795
+			if (WP_DEBUG) {
796
+				\EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
797
+			}
798
+			$content .= $action_items;
799
+		}
800
+		$content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
801
+		return $content;
802
+	}
803 803
 }
Please login to merge, or discard this patch.
Spacing   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -1,9 +1,9 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5
-if (! class_exists('WP_List_Table')) {
6
-    require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');
5
+if ( ! class_exists('WP_List_Table')) {
6
+    require_once(ABSPATH.'wp-admin/includes/class-wp-list-table.php');
7 7
 }
8 8
 
9 9
 
@@ -206,10 +206,10 @@  discard block
 block discarded – undo
206 206
         $this->_view         = $this->_admin_page->get_view();
207 207
         $this->_views        = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
208 208
         $this->_current_page = $this->get_pagenum();
209
-        $this->_screen       = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
209
+        $this->_screen       = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
210 210
         $this->_yes_no       = array(__('No', 'event_espresso'), __('Yes', 'event_espresso'));
211 211
 
212
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 10);
212
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 10);
213 213
 
214 214
         $this->_setup_data();
215 215
         $this->_add_view_counts();
@@ -289,13 +289,13 @@  discard block
 block discarded – undo
289 289
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
290 290
         //if action is STILL empty, then we set it to default
291 291
         $action = empty($action) ? 'default' : $action;
292
-        $field  = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
293
-        $field  .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
294
-        $field  .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
292
+        $field  = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n";
293
+        $field  .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/
294
+        $field  .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n";
295 295
 
296 296
         $bulk_actions = $this->_get_bulk_actions();
297 297
         foreach ($bulk_actions as $bulk_action => $label) {
298
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce" value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
298
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce" value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
299 299
         }
300 300
 
301 301
         return $field;
@@ -340,9 +340,9 @@  discard block
 block discarded – undo
340 340
                 $_data[0] = $data;
341 341
             }
342 342
 
343
-            $data = (array)$data;
343
+            $data = (array) $data;
344 344
 
345
-            if (! isset($data[1])) {
345
+            if ( ! isset($data[1])) {
346 346
                 $_data[1] = false;
347 347
             }
348 348
 
@@ -424,7 +424,7 @@  discard block
 block discarded – undo
424 424
     private function _filters()
425 425
     {
426 426
         $classname = get_class($this);
427
-        $filters   = apply_filters("FHEE__{$classname}__filters", (array)$this->_get_table_filters(), $this,
427
+        $filters   = apply_filters("FHEE__{$classname}__filters", (array) $this->_get_table_filters(), $this,
428 428
             $this->_screen);
429 429
 
430 430
         if (empty($filters)) {
@@ -434,11 +434,11 @@  discard block
 block discarded – undo
434 434
             echo $filter;
435 435
         }
436 436
         //add filter button at end
437
-        echo '<input type="submit" class="button-secondary" value="' . __('Filter',
438
-                'event_espresso') . '" id="post-query-submit" />';
437
+        echo '<input type="submit" class="button-secondary" value="'.__('Filter',
438
+                'event_espresso').'" id="post-query-submit" />';
439 439
         //add reset filters button at end
440
-        echo '<a class="button button-secondary"  href="' . $this->_admin_page->get_current_page_view_url() . '" style="display:inline-block">' . __('Reset Filters',
441
-                'event_espresso') . '</a>';
440
+        echo '<a class="button button-secondary"  href="'.$this->_admin_page->get_current_page_view_url().'" style="display:inline-block">'.__('Reset Filters',
441
+                'event_espresso').'</a>';
442 442
     }
443 443
 
444 444
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
          * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
498 498
          * hook prefix ("event-espresso") will be different.
499 499
          */
500
-        do_action('AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id, $item,
500
+        do_action('AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id, $item,
501 501
             $this->_screen);
502 502
     }
503 503
 
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
          *
524 524
          * @var array
525 525
          */
526
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
526
+        $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
527 527
         return $columns;
528 528
     }
529 529
 
@@ -553,11 +553,11 @@  discard block
 block discarded – undo
553 553
         foreach ($views as $view) {
554 554
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
555 555
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
556
-                $assembled_views[$view['slug']] = "\t<li class='" . $view['class'] . "'>" . '<a href="' . $view['url'] . '">' . $view['label'] . '</a> <span class="count">(' . $count . ')</span>';
556
+                $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>".'<a href="'.$view['url'].'">'.$view['label'].'</a> <span class="count">('.$count.')</span>';
557 557
             }
558 558
         }
559 559
 
560
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
560
+        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : '';
561 561
         echo "</ul>";
562 562
     }
563 563
 
@@ -572,7 +572,7 @@  discard block
 block discarded – undo
572 572
     public function single_row($item)
573 573
     {
574 574
         $row_class = $this->_get_row_class($item);
575
-        echo '<tr class="' . esc_attr($row_class) . '">';
575
+        echo '<tr class="'.esc_attr($row_class).'">';
576 576
         $this->single_row_columns($item);
577 577
         echo '</tr>';
578 578
     }
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
         $new_row_class = $row_class;
594 594
 
595
-        if (! empty($this->_ajax_sorting_callback)) {
595
+        if ( ! empty($this->_ajax_sorting_callback)) {
596 596
             $new_row_class .= ' rowsortable';
597 597
         }
598 598
 
@@ -605,7 +605,7 @@  discard block
 block discarded – undo
605 605
      */
606 606
     public function get_sortable_columns()
607 607
     {
608
-        return (array)$this->_sortable_columns;
608
+        return (array) $this->_sortable_columns;
609 609
     }
610 610
 
611 611
 
@@ -624,13 +624,13 @@  discard block
 block discarded – undo
624 624
     public function get_hidden_columns()
625 625
     {
626 626
         $user_id     = get_current_user_id();
627
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
627
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
628 628
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
629
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
630
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
629
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
630
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
631 631
         }
632
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
633
-        return (array)get_user_option($ref, $user_id);
632
+        $ref = 'manage'.$this->screen->id.'columnshidden';
633
+        return (array) get_user_option($ref, $user_id);
634 634
     }
635 635
 
636 636
 
@@ -658,12 +658,12 @@  discard block
 block discarded – undo
658 658
             $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
659 659
             $style        = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
660 660
 
661
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
661
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
662 662
             if ($primary === $column_name) {
663 663
                 $classes .= ' has-row-actions column-primary';
664 664
             }
665 665
 
666
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
666
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
667 667
 
668 668
             $class = "class='$classes'";
669 669
 
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
                 echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
675 675
                     $this->column_cb($item), $item, $this);
676 676
                 echo '</th>';
677
-            } elseif (method_exists($this, 'column_' . $column_name)) {
677
+            } elseif (method_exists($this, 'column_'.$column_name)) {
678 678
                 echo "<td $attributes>";
679
-                echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
680
-                    call_user_func(array($this, 'column_' . $column_name), $item), $item, $this);
679
+                echo apply_filters('FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
680
+                    call_user_func(array($this, 'column_'.$column_name), $item), $item, $this);
681 681
                 echo $this->handle_row_actions($item, $column_name, $primary);
682 682
                 echo "</td>";
683 683
             } else {
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
      */
735 735
     public function get_bulk_actions()
736 736
     {
737
-        return (array)$this->_get_bulk_actions();
737
+        return (array) $this->_get_bulk_actions();
738 738
     }
739 739
 
740 740
     public function process_bulk_action()
@@ -781,9 +781,9 @@  discard block
 block discarded – undo
781 781
         $action_id = ''
782 782
     ) {
783 783
         $content      = '';
784
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
785
-        $action_id    = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
786
-        $content      .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
784
+        $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : '';
785
+        $action_id    = ! empty($action_id) ? ' id="'.$action_id.'"' : '';
786
+        $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
787 787
         try {
788 788
             $content .= apply_filters(
789 789
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
@@ -797,7 +797,7 @@  discard block
 block discarded – undo
797 797
             }
798 798
             $content .= $action_items;
799 799
         }
800
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
800
+        $content .= ! empty($action_container) ? '</'.$action_container.'>' : '';
801 801
         return $content;
802 802
     }
803 803
 }
Please login to merge, or discard this patch.
acceptance_tests/Helpers/CountrySettingsAdmin.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,7 +1,6 @@
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\Codeception\helpers;
3 3
 
4
-use Page\CoreAdmin;
5 4
 use Page\CountrySettingsAdmin as CountrySettings;
6 5
 
7 6
 trait CountrySettingsAdmin
Please login to merge, or discard this patch.
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -6,59 +6,59 @@
 block discarded – undo
6 6
 
7 7
 trait CountrySettingsAdmin
8 8
 {
9
-    /**
10
-     * Instructs the actor to browse to the country settings page.
11
-     * Assumes the actor is already logged in.
12
-     * @param string $additional_params
13
-     */
14
-    public function amOnCountrySettingsAdminPage($additional_params = '')
15
-    {
16
-        $this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
-    }
9
+	/**
10
+	 * Instructs the actor to browse to the country settings page.
11
+	 * Assumes the actor is already logged in.
12
+	 * @param string $additional_params
13
+	 */
14
+	public function amOnCountrySettingsAdminPage($additional_params = '')
15
+	{
16
+		$this->actor()->amOnAdminPage(CountrySettings::url($additional_params));
17
+	}
18 18
 
19 19
 
20
-    /**
21
-     * Instructs the actor to select the given decimal places radio option.
22
-     * Assumes the actor is already on the country settings page.
23
-     * @param string $decimal_places
24
-     * @param string $country_code
25
-     */
26
-    public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
-    {
28
-        $this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
-    }
20
+	/**
21
+	 * Instructs the actor to select the given decimal places radio option.
22
+	 * Assumes the actor is already on the country settings page.
23
+	 * @param string $decimal_places
24
+	 * @param string $country_code
25
+	 */
26
+	public function setCurrencyDecimalPlacesTo($decimal_places = '2', $country_code = 'US')
27
+	{
28
+		$this->actor()->click(CountrySettings::currencyDecimalPlacesRadioField($decimal_places, $country_code));
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Instructs the actor to select the given decimal mark radio option.
34
-     * Assumes the actor is already on the country settings page.
35
-     * @param string $decimal_mark
36
-     */
37
-    public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
-    {
39
-        $this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
-    }
32
+	/**
33
+	 * Instructs the actor to select the given decimal mark radio option.
34
+	 * Assumes the actor is already on the country settings page.
35
+	 * @param string $decimal_mark
36
+	 */
37
+	public function setCurrencyDecimalMarkTo($decimal_mark = '.')
38
+	{
39
+		$this->actor()->click(CountrySettings::currencyDecimalMarkRadioField($decimal_mark));
40
+	}
41 41
 
42 42
 
43
-    /**
44
-     * Instructs the actor to select the given thousands separator radio option.
45
-     * Assumes the actor is already on the country settings page.
46
-     * @param string $thousands_seperator
47
-     */
48
-    public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
-    {
50
-        $this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
-    }
43
+	/**
44
+	 * Instructs the actor to select the given thousands separator radio option.
45
+	 * Assumes the actor is already on the country settings page.
46
+	 * @param string $thousands_seperator
47
+	 */
48
+	public function setCurrencyThousandsSeparatorTo($thousands_seperator = ',')
49
+	{
50
+		$this->actor()->click(CountrySettings::currencyThousandsSeparatorField($thousands_seperator));
51
+	}
52 52
 
53 53
 
54
-    /**
55
-     * Clicks the country settings submit button.
56
-     * Assumes the actor is on the country settings admin page.
57
-     */
58
-    public function saveCountrySettings()
59
-    {
60
-        $this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
-        //no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
-        $this->actor()->wait(5);
63
-    }
54
+	/**
55
+	 * Clicks the country settings submit button.
56
+	 * Assumes the actor is on the country settings admin page.
57
+	 */
58
+	public function saveCountrySettings()
59
+	{
60
+		$this->actor()->click(CountrySettings::COUNTRY_SETTINGS_SAVE_BUTTON);
61
+		//no indicator on the page when stuff has been updated so just give a bit of time for it to finish.
62
+		$this->actor()->wait(5);
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Helpers/EventsAdmin.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -14,118 +14,118 @@
 block discarded – undo
14 14
 trait EventsAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * @param string $additional_params
19
-     */
20
-    public function amOnDefaultEventsListTablePage($additional_params = '')
21
-    {
22
-        $this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
-    }
24
-
25
-
26
-    /**
27
-     * Triggers the publishing of the Event.
28
-     */
29
-    public function publishEvent()
30
-    {
31
-        $this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
-    }
33
-
34
-
35
-    /**
36
-     * Triggers saving the Event.
37
-     */
38
-    public function saveEvent()
39
-    {
40
-        $this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
41
-    }
42
-
43
-
44
-    /**
45
-     * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
46
-     * First this will search using the given title and then attempt to edit from the results of the search.
47
-     *
48
-     * Assumes actor is already logged in.
49
-     * @param $event_title
50
-     */
51
-    public function amEditingTheEventWithTitle($event_title)
52
-    {
53
-        $this->amOnDefaultEventsListTablePage();
54
-        $this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
55
-        $this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
56
-        $this->actor()->waitForText('Displaying search results for');
57
-        $this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
58
-    }
59
-
60
-
61
-    /**
62
-     * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
63
-     * link for the event in the event list table.
64
-     * Assumes the actor is already logged in and on the Event list table page.
65
-     *
66
-     * @param string $event_title
67
-     */
68
-    public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
69
-    {
70
-        $this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
71
-        $this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
72
-    }
73
-
74
-
75
-    /**
76
-     * This performs the click action on the gear icon that triggers the advanced settings view state.
77
-     * Assumes the actor is already logged in and editing an event.
78
-     *
79
-     * @param int $row_number  What ticket row to toggle open/close.
80
-     */
81
-    public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
82
-    {
83
-        $this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
84
-    }
85
-
86
-
87
-    /**
88
-     * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
89
-     * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
90
-     * ticket is "open".
91
-     *
92
-     * @param int $row_number  What ticket row to toggle the checkbox for.
93
-     */
94
-    public function toggleTicketIsTaxableForTicketRow($row_number = 1)
95
-    {
96
-        $this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
97
-    }
98
-
99
-
100
-    /**
101
-     * Use to change the default registration status for the event.
102
-     * Assumes the view is already on the event editor.
103
-     * @param $registration_status
104
-     */
105
-    public function changeDefaultRegistrationStatusTo($registration_status)
106
-    {
107
-        $this->actor()->selectOption(
108
-            EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
109
-            $registration_status
110
-        );
111
-    }
112
-
113
-
114
-    /**
115
-     * Use this from the context of the event editor to select the given custom template for a given message type and
116
-     * messenger.
117
-     *
118
-     * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
119
-     * @param string $messenger_slug      The slug for the messenger (eg 'email')
120
-     * @param string $custom_template_label The visible label in the select input for the custom template you want
121
-     *                                      selected.
122
-     */
123
-    public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
124
-    {
125
-        $this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
126
-        $this->actor()->selectOption(
127
-            EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
128
-            $custom_template_label
129
-        );
130
-    }
17
+	/**
18
+	 * @param string $additional_params
19
+	 */
20
+	public function amOnDefaultEventsListTablePage($additional_params = '')
21
+	{
22
+		$this->actor()->amOnAdminPage(EventsPage::defaultEventsListTableUrl($additional_params));
23
+	}
24
+
25
+
26
+	/**
27
+	 * Triggers the publishing of the Event.
28
+	 */
29
+	public function publishEvent()
30
+	{
31
+		$this->actor()->click(EventsPage::EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR);
32
+	}
33
+
34
+
35
+	/**
36
+	 * Triggers saving the Event.
37
+	 */
38
+	public function saveEvent()
39
+	{
40
+		$this->actor()->click(EventsPage::EVENT_EDITOR_SAVE_BUTTON_SELECTOR);
41
+	}
42
+
43
+
44
+	/**
45
+	 * Navigates the actor to the event list table page and will attempt to edit the event for the given title.
46
+	 * First this will search using the given title and then attempt to edit from the results of the search.
47
+	 *
48
+	 * Assumes actor is already logged in.
49
+	 * @param $event_title
50
+	 */
51
+	public function amEditingTheEventWithTitle($event_title)
52
+	{
53
+		$this->amOnDefaultEventsListTablePage();
54
+		$this->actor()->fillField(EventsPage::EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR, $event_title);
55
+		$this->actor()->click(CoreAdmin::LIST_TABLE_SEARCH_SUBMIT_SELECTOR);
56
+		$this->actor()->waitForText('Displaying search results for');
57
+		$this->actor()->click(EventsPage::eventListTableEventTitleEditLink($event_title));
58
+	}
59
+
60
+
61
+	/**
62
+	 * Navigates the user to the single event page (frontend view) for the given event title via clicking the "View"
63
+	 * link for the event in the event list table.
64
+	 * Assumes the actor is already logged in and on the Event list table page.
65
+	 *
66
+	 * @param string $event_title
67
+	 */
68
+	public function amOnEventPageAfterClickingViewLinkInListTableForEvent($event_title)
69
+	{
70
+		$this->actor()->moveMouseOver(EventsPage::eventListTableEventTitleEditLinkSelectorForTitle($event_title));
71
+		$this->actor()->click(EventsPage::eventListTableEventTitleViewLinkSelectorForTitle($event_title));
72
+	}
73
+
74
+
75
+	/**
76
+	 * This performs the click action on the gear icon that triggers the advanced settings view state.
77
+	 * Assumes the actor is already logged in and editing an event.
78
+	 *
79
+	 * @param int $row_number  What ticket row to toggle open/close.
80
+	 */
81
+	public function toggleAdvancedSettingsViewForTicketRow($row_number = 1)
82
+	{
83
+		$this->actor()->click(EventsPage::eventEditorTicketAdvancedDetailsSelector($row_number));
84
+	}
85
+
86
+
87
+	/**
88
+	 * Toggles the TKT_is_taxable checkbox for the ticket in the given row.
89
+	 * Assumes the actor is already logged in and editing an event and that the advanced settings view state for that
90
+	 * ticket is "open".
91
+	 *
92
+	 * @param int $row_number  What ticket row to toggle the checkbox for.
93
+	 */
94
+	public function toggleTicketIsTaxableForTicketRow($row_number = 1)
95
+	{
96
+		$this->actor()->click(EventsPage::eventEditorTicketTaxableCheckboxSelector($row_number));
97
+	}
98
+
99
+
100
+	/**
101
+	 * Use to change the default registration status for the event.
102
+	 * Assumes the view is already on the event editor.
103
+	 * @param $registration_status
104
+	 */
105
+	public function changeDefaultRegistrationStatusTo($registration_status)
106
+	{
107
+		$this->actor()->selectOption(
108
+			EventsPage::EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR,
109
+			$registration_status
110
+		);
111
+	}
112
+
113
+
114
+	/**
115
+	 * Use this from the context of the event editor to select the given custom template for a given message type and
116
+	 * messenger.
117
+	 *
118
+	 * @param string $message_type_label  The visible label for the message type (eg Registration Approved)
119
+	 * @param string $messenger_slug      The slug for the messenger (eg 'email')
120
+	 * @param string $custom_template_label The visible label in the select input for the custom template you want
121
+	 *                                      selected.
122
+	 */
123
+	public function selectCustomTemplateFor($message_type_label, $messenger_slug, $custom_template_label)
124
+	{
125
+		$this->actor()->click(EventsPage::eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug));
126
+		$this->actor()->selectOption(
127
+			EventsPage::eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label),
128
+			$custom_template_label
129
+		);
130
+	}
131 131
 }
132 132
\ No newline at end of file
Please login to merge, or discard this patch.
acceptance_tests/Page/EventsAdmin.php 1 patch
Indentation   +222 added lines, -222 removed lines patch added patch discarded remove patch
@@ -14,231 +14,231 @@
 block discarded – undo
14 14
 class EventsAdmin extends CoreAdmin
15 15
 {
16 16
 
17
-    /**
18
-     * Selector for the Add new Event button in the admin.
19
-     * @var string
20
-     */
21
-    const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
-
23
-
24
-    /**
25
-     * Selector for the Event Title field in the event editor
26
-     * @var string
27
-     */
28
-    const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
-
30
-    /**
31
-     * Selector for the publish submit button in the event editor.
32
-     * @var string
33
-     */
34
-    const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
-
36
-
37
-    /**
38
-     * Selector for the save button in the event editor
39
-     */
40
-    const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
-
42
-
43
-    /**
44
-     * @var string
45
-     */
46
-    const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
17
+	/**
18
+	 * Selector for the Add new Event button in the admin.
19
+	 * @var string
20
+	 */
21
+	const ADD_NEW_EVENT_BUTTON_SELECTOR = '#add-new-event';
22
+
23
+
24
+	/**
25
+	 * Selector for the Event Title field in the event editor
26
+	 * @var string
27
+	 */
28
+	const EVENT_EDITOR_TITLE_FIELD_SELECTOR = "//input[@id='title']";
29
+
30
+	/**
31
+	 * Selector for the publish submit button in the event editor.
32
+	 * @var string
33
+	 */
34
+	const EVENT_EDITOR_PUBLISH_BUTTON_SELECTOR = "#publish";
35
+
36
+
37
+	/**
38
+	 * Selector for the save button in the event editor
39
+	 */
40
+	const EVENT_EDITOR_SAVE_BUTTON_SELECTOR = "#save-post";
41
+
42
+
43
+	/**
44
+	 * @var string
45
+	 */
46
+	const EVENT_EDITOR_DEFAULT_REGISTRATION_STATUS_FIELD_SELECTOR = '#EVT_default_registration_status';
47 47
 
48
-    /**
49
-     * Selector for the view link after publishing an event.
50
-     * @var string
51
-     */
52
-    const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
48
+	/**
49
+	 * Selector for the view link after publishing an event.
50
+	 * @var string
51
+	 */
52
+	const EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR = "//div[@id='message']/p/a";
53 53
 
54 54
 
55
-    /**
56
-     * Selector for the ID of the event in the event editor
57
-     * @var string
58
-     */
59
-    const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
55
+	/**
56
+	 * Selector for the ID of the event in the event editor
57
+	 * @var string
58
+	 */
59
+	const EVENT_EDITOR_EVT_ID_SELECTOR = "//input[@id='post_ID']";
60 60
 
61 61
 
62
-    /**
63
-     * Selector for the search input on the event list table page.
64
-     * @var string
65
-     */
66
-    const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
-
68
-
69
-
70
-
71
-    /**
72
-     * @param string $additional_params
73
-     * @return string
74
-     */
75
-    public static function defaultEventsListTableUrl($additional_params = '')
76
-    {
77
-        return self::adminUrl('espresso_events', 'default', $additional_params);
78
-    }
79
-
80
-
81
-    /**
82
-     * The selector for the DTTname field for the given row in the event editor.
83
-     * @param int $row_number
84
-     * @return string
85
-     */
86
-    public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
-    {
88
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
-    }
90
-
91
-
92
-    /**
93
-     * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
-     * @param int $row_number
95
-     * @return string
96
-     */
97
-    public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
-    {
99
-        return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
-    }
101
-
102
-
103
-    /**
104
-     * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
-     *
106
-     * @param string $field_name
107
-     * @param int    $row_number
108
-     * @return string
109
-     */
110
-    public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
-    {
112
-        return "//input[@id='event-datetime-$field_name-$row_number']";
113
-    }
114
-
115
-
116
-    /**
117
-     * The selector for the TKT_name field for the given display row in the event editor.
118
-     * @param int $row_number
119
-     * @return string
120
-     */
121
-    public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
-    {
123
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
-    }
125
-
126
-
127
-    public static function eventEditorTicketPriceFieldSelector($row_number = 1)
128
-    {
129
-        return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
130
-    }
131
-
132
-
133
-    public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
134
-    {
135
-        return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
136
-    }
137
-
138
-
139
-    public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
140
-    {
141
-        return "//span[@id='price-total-amount-$row_number']";
142
-    }
143
-
144
-
145
-    public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
146
-    {
147
-        return "//span[@id='price-total-amount-$row_number']";
148
-    }
149
-
150
-
151
-    public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
152
-    {
153
-        return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
154
-    }
155
-
156
-
157
-    /**
158
-     * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
159
-     * given ticket (row) and the given tax id (PRC_ID).
160
-     *
161
-     * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
162
-     *                        setup on a fresh install.
163
-     * @param int $row_number What row representing the ticket you want the locator for.
164
-     * @return string
165
-     */
166
-    public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
167
-    {
168
-        return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
169
-    }
170
-
171
-
172
-    /**
173
-     * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
174
-     * @param     $field_name
175
-     * @param int $row_number
176
-     * @return string
177
-     */
178
-    public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
179
-    {
180
-        return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
181
-    }
182
-
183
-
184
-    /**
185
-     * Returns the selector for the event title edit link in the events list table for the given Event Title.
186
-     * @param string $event_title
187
-     * @return string
188
-     */
189
-    public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
190
-    {
191
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
192
-    }
193
-
194
-
195
-    /**
196
-     * Locator for for the ID column in the event list table for a given event title.
197
-     * @param string $event_title
198
-     * @return string
199
-     */
200
-    public static function eventListTableEventIdSelectorForTitle($event_title)
201
-    {
202
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
203
-               . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
204
-    }
205
-
206
-
207
-    /**
208
-     * Locator for the view link in the row of an event list table for the given event title.
209
-     * @param string $event_title
210
-     * @return string
211
-     */
212
-    public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
213
-    {
214
-        return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
215
-               . "//ancestor::td//span[@class='view']/a";
216
-    }
217
-
218
-
219
-    /**
220
-     * Locator for the messenger tab in the Notifications metabox in the event editor.
221
-     * @param string $messenger_slug  The slug for the messenger (it's reference slug).
222
-     * @return string
223
-     */
224
-    public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
225
-    {
226
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
227
-               . "//a[@rel='ee-tab-$messenger_slug']";
228
-    }
229
-
230
-
231
-    /**
232
-     * Locator for the select input within the notifications metabox.
233
-     * Note, this assumes the tab content for the related messenger is already visible.
234
-     * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
235
-     * @return string
236
-     */
237
-    public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
238
-    {
239
-        return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
240
-               . "//table[@class='messages-custom-template-switcher']"
241
-               . "//tr/td[contains(.,'Registration Approved')]"
242
-               . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
243
-    }
62
+	/**
63
+	 * Selector for the search input on the event list table page.
64
+	 * @var string
65
+	 */
66
+	const EVENT_LIST_TABLE_SEARCH_INPUT_SELECTOR = '#toplevel_page_espresso_events-search-input';
67
+
68
+
69
+
70
+
71
+	/**
72
+	 * @param string $additional_params
73
+	 * @return string
74
+	 */
75
+	public static function defaultEventsListTableUrl($additional_params = '')
76
+	{
77
+		return self::adminUrl('espresso_events', 'default', $additional_params);
78
+	}
79
+
80
+
81
+	/**
82
+	 * The selector for the DTTname field for the given row in the event editor.
83
+	 * @param int $row_number
84
+	 * @return string
85
+	 */
86
+	public static function eventEditorDatetimeNameFieldSelector($row_number = 1)
87
+	{
88
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_name', $row_number);
89
+	}
90
+
91
+
92
+	/**
93
+	 * The selector for the DTT_EVT_start field for the given row in the event editor.d
94
+	 * @param int $row_number
95
+	 * @return string
96
+	 */
97
+	public static function eventEditorDatetimeStartDateFieldSelector($row_number = 1)
98
+	{
99
+		return self::eventEditorDatetimeFieldSelectorForField('DTT_EVT_start', $row_number);
100
+	}
101
+
102
+
103
+	/**
104
+	 * Wrapper for getting the selector for a given field and given row of a datetime in the event editor.
105
+	 *
106
+	 * @param string $field_name
107
+	 * @param int    $row_number
108
+	 * @return string
109
+	 */
110
+	public static function eventEditorDatetimeFieldSelectorForField($field_name, $row_number = 1)
111
+	{
112
+		return "//input[@id='event-datetime-$field_name-$row_number']";
113
+	}
114
+
115
+
116
+	/**
117
+	 * The selector for the TKT_name field for the given display row in the event editor.
118
+	 * @param int $row_number
119
+	 * @return string
120
+	 */
121
+	public static function eventEditorTicketNameFieldSelector($row_number = 1)
122
+	{
123
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_name', $row_number);
124
+	}
125
+
126
+
127
+	public static function eventEditorTicketPriceFieldSelector($row_number = 1)
128
+	{
129
+		return self::eventEditorTicketFieldSelectorForFieldInDisplayRow('TKT_base_price', $row_number);
130
+	}
131
+
132
+
133
+	public static function eventEditorTicketAdvancedDetailsSelector($row_number = 1)
134
+	{
135
+		return "//tr[@id='display-ticketrow-$row_number']//span[contains(@class, 'gear-icon')]";
136
+	}
137
+
138
+
139
+	public static function eventEditorTicketAdvancedDetailsSubtotalSelector($row_number = 1)
140
+	{
141
+		return "//span[@id='price-total-amount-$row_number']";
142
+	}
143
+
144
+
145
+	public static function eventEditorTicketAdvancedDetailsTotalSelector($row_number = 1)
146
+	{
147
+		return "//span[@id='price-total-amount-$row_number']";
148
+	}
149
+
150
+
151
+	public static function eventEditorTicketTaxableCheckboxSelector($row_number = 1)
152
+	{
153
+		return "//input[@id='edit-ticket-TKT_taxable-$row_number']";
154
+	}
155
+
156
+
157
+	/**
158
+	 * This returns the xpath locater for the Tax amount display container within the advanced settings view for the
159
+	 * given ticket (row) and the given tax id (PRC_ID).
160
+	 *
161
+	 * @param int $tax_id     The PRC_ID for the tax you want the locater for.  Note, this defaults to the default tax
162
+	 *                        setup on a fresh install.
163
+	 * @param int $row_number What row representing the ticket you want the locator for.
164
+	 * @return string
165
+	 */
166
+	public static function eventEditorTicketTaxAmountDisplayForTaxIdAndTicketRowSelector($tax_id = 2, $row_number = 1)
167
+	{
168
+		return "//span[@id='TKT-tax-amount-display-$tax_id-$row_number']";
169
+	}
170
+
171
+
172
+	/**
173
+	 * Wrapper for getting the selector for a given field and given display row of a ticket in the event editor.
174
+	 * @param     $field_name
175
+	 * @param int $row_number
176
+	 * @return string
177
+	 */
178
+	public static function eventEditorTicketFieldSelectorForFieldInDisplayRow($field_name, $row_number = 1)
179
+	{
180
+		return "//tr[@id='display-ticketrow-$row_number']//input[contains(@class, 'edit-ticket-$field_name')]";
181
+	}
182
+
183
+
184
+	/**
185
+	 * Returns the selector for the event title edit link in the events list table for the given Event Title.
186
+	 * @param string $event_title
187
+	 * @return string
188
+	 */
189
+	public static function eventListTableEventTitleEditLinkSelectorForTitle($event_title)
190
+	{
191
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']";
192
+	}
193
+
194
+
195
+	/**
196
+	 * Locator for for the ID column in the event list table for a given event title.
197
+	 * @param string $event_title
198
+	 * @return string
199
+	 */
200
+	public static function eventListTableEventIdSelectorForTitle($event_title)
201
+	{
202
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
203
+			   . "//ancestor::tr/th[contains(@class, 'check-column')]/input";
204
+	}
205
+
206
+
207
+	/**
208
+	 * Locator for the view link in the row of an event list table for the given event title.
209
+	 * @param string $event_title
210
+	 * @return string
211
+	 */
212
+	public static function eventListTableEventTitleViewLinkSelectorForTitle($event_title)
213
+	{
214
+		return "//td[contains(@class, 'column-name')]/strong/a[text()='$event_title']"
215
+			   . "//ancestor::td//span[@class='view']/a";
216
+	}
217
+
218
+
219
+	/**
220
+	 * Locator for the messenger tab in the Notifications metabox in the event editor.
221
+	 * @param string $messenger_slug  The slug for the messenger (it's reference slug).
222
+	 * @return string
223
+	 */
224
+	public static function eventEditorNotificationsMetaBoxMessengerTabSelector($messenger_slug)
225
+	{
226
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
227
+			   . "//a[@rel='ee-tab-$messenger_slug']";
228
+	}
229
+
230
+
231
+	/**
232
+	 * Locator for the select input within the notifications metabox.
233
+	 * Note, this assumes the tab content for the related messenger is already visible.
234
+	 * @param string $message_type_label The message type label (visible string in the table) you want the selector for.
235
+	 * @return string
236
+	 */
237
+	public static function eventEditorNotificationsMetaBoxSelectSelectorForMessageType($message_type_label)
238
+	{
239
+		return "//div[@id='espresso_events_Messages_Hooks_Extend_messages_metabox_metabox']"
240
+			   . "//table[@class='messages-custom-template-switcher']"
241
+			   . "//tr/td[contains(.,'Registration Approved')]"
242
+			   . "//ancestor::tr//select[contains(@class,'message-template-selector')]";
243
+	}
244 244
 }
Please login to merge, or discard this patch.
acceptance_tests/Page/CountrySettingsAdmin.php 1 patch
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -14,51 +14,51 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2';
17
+	const COUNTRY_SETTINGS_SAVE_BUTTON = '#country_settings_save_2';
18 18
 
19 19
 
20 20
 
21
-    /**
22
-     * Return the url for the country settings admin page.
23
-     * @param string $additional_params
24
-     * @return string
25
-     */
26
-    public static function url($additional_params = '')
27
-    {
28
-        return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params);
29
-    }
21
+	/**
22
+	 * Return the url for the country settings admin page.
23
+	 * @param string $additional_params
24
+	 * @return string
25
+	 */
26
+	public static function url($additional_params = '')
27
+	{
28
+		return self::adminUrl('espresso_general_settings', 'country_settings', $additional_params);
29
+	}
30 30
 
31 31
 
32
-    /**
33
-     * Return the decimal places (precision) radio field locator for selection.
34
-     * @param int    $decimal_place_value
35
-     * @param string $country_code
36
-     * @return string
37
-     */
38
-    public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US')
39
-    {
40
-        return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']";
41
-    }
32
+	/**
33
+	 * Return the decimal places (precision) radio field locator for selection.
34
+	 * @param int    $decimal_place_value
35
+	 * @param string $country_code
36
+	 * @return string
37
+	 */
38
+	public static function currencyDecimalPlacesRadioField($decimal_place_value = 2, $country_code = 'US')
39
+	{
40
+		return "//input[@id='CNT_cur_dec_plc-$country_code-$decimal_place_value']";
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Return the currency decimal mark field locator for selection.
46
-     * @param string $decimal_mark
47
-     * @return string
48
-     */
49
-    public static function currencyDecimalMarkRadioField($decimal_mark = '.')
50
-    {
51
-        return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']";
52
-    }
44
+	/**
45
+	 * Return the currency decimal mark field locator for selection.
46
+	 * @param string $decimal_mark
47
+	 * @return string
48
+	 */
49
+	public static function currencyDecimalMarkRadioField($decimal_mark = '.')
50
+	{
51
+		return "//input[@class='CNT_cur_dec_mrk' and @value='$decimal_mark']";
52
+	}
53 53
 
54 54
 
55
-    /**
56
-     * Return the currency thousands separator field locator for selection.
57
-     * @param string $thousands_separator
58
-     * @return string
59
-     */
60
-    public static function currencyThousandsSeparatorField($thousands_separator = ',')
61
-    {
62
-        return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']";
63
-    }
55
+	/**
56
+	 * Return the currency thousands separator field locator for selection.
57
+	 * @param string $thousands_separator
58
+	 * @return string
59
+	 */
60
+	public static function currencyThousandsSeparatorField($thousands_separator = ',')
61
+	{
62
+		return "//input[@class='CNT_cur_thsnds' and @value='$thousands_separator']";
63
+	}
64 64
 }
65 65
\ No newline at end of file
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 3 patches
Doc Comments   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -339,7 +339,7 @@  discard block
 block discarded – undo
339 339
      * Returns template for the additional datetime.
340 340
      * @param $template
341 341
      * @param $template_args
342
-     * @return mixed
342
+     * @return string
343 343
      * @throws DomainException
344 344
      */
345 345
     public function add_additional_datetime_button($template, $template_args)
@@ -356,7 +356,7 @@  discard block
 block discarded – undo
356 356
      * Returns the template for cloning a datetime.
357 357
      * @param $template
358 358
      * @param $template_args
359
-     * @return mixed
359
+     * @return string
360 360
      * @throws DomainException
361 361
      */
362 362
     public function add_datetime_clone_button($template, $template_args)
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
      * Returns the template for datetime timezones.
374 374
      * @param $template
375 375
      * @param $template_args
376
-     * @return mixed
376
+     * @return string
377 377
      * @throws DomainException
378 378
      */
379 379
     public function datetime_timezones_template($template, $template_args)
Please login to merge, or discard this patch.
Indentation   +1235 added lines, -1235 removed lines patch added patch discarded remove patch
@@ -14,1239 +14,1239 @@
 block discarded – undo
14 14
 {
15 15
 
16 16
 
17
-    /**
18
-     * Extend_Events_Admin_Page constructor.
19
-     *
20
-     * @param bool $routing
21
-     */
22
-    public function __construct($routing = true)
23
-    {
24
-        parent::__construct($routing);
25
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
27
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
28
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
29
-        }
30
-    }
31
-
32
-
33
-    /**
34
-     * Sets routes.
35
-     */
36
-    protected function _extend_page_config()
37
-    {
38
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
39
-        //is there a evt_id in the request?
40
-        $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
41
-            ? $this->_req_data['EVT_ID']
42
-            : 0;
43
-        $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
44
-        //tkt_id?
45
-        $tkt_id             = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
46
-            ? $this->_req_data['TKT_ID']
47
-            : 0;
48
-        $new_page_routes    = array(
49
-            'duplicate_event'          => array(
50
-                'func'       => '_duplicate_event',
51
-                'capability' => 'ee_edit_event',
52
-                'obj_id'     => $evt_id,
53
-                'noheader'   => true,
54
-            ),
55
-            'ticket_list_table'        => array(
56
-                'func'       => '_tickets_overview_list_table',
57
-                'capability' => 'ee_read_default_tickets',
58
-            ),
59
-            'trash_ticket'             => array(
60
-                'func'       => '_trash_or_restore_ticket',
61
-                'capability' => 'ee_delete_default_ticket',
62
-                'obj_id'     => $tkt_id,
63
-                'noheader'   => true,
64
-                'args'       => array('trash' => true),
65
-            ),
66
-            'trash_tickets'            => array(
67
-                'func'       => '_trash_or_restore_ticket',
68
-                'capability' => 'ee_delete_default_tickets',
69
-                'noheader'   => true,
70
-                'args'       => array('trash' => true),
71
-            ),
72
-            'restore_ticket'           => array(
73
-                'func'       => '_trash_or_restore_ticket',
74
-                'capability' => 'ee_delete_default_ticket',
75
-                'obj_id'     => $tkt_id,
76
-                'noheader'   => true,
77
-            ),
78
-            'restore_tickets'          => array(
79
-                'func'       => '_trash_or_restore_ticket',
80
-                'capability' => 'ee_delete_default_tickets',
81
-                'noheader'   => true,
82
-            ),
83
-            'delete_ticket'            => array(
84
-                'func'       => '_delete_ticket',
85
-                'capability' => 'ee_delete_default_ticket',
86
-                'obj_id'     => $tkt_id,
87
-                'noheader'   => true,
88
-            ),
89
-            'delete_tickets'           => array(
90
-                'func'       => '_delete_ticket',
91
-                'capability' => 'ee_delete_default_tickets',
92
-                'noheader'   => true,
93
-            ),
94
-            'import_page'              => array(
95
-                'func'       => '_import_page',
96
-                'capability' => 'import',
97
-            ),
98
-            'import'                   => array(
99
-                'func'       => '_import_events',
100
-                'capability' => 'import',
101
-                'noheader'   => true,
102
-            ),
103
-            'import_events'            => array(
104
-                'func'       => '_import_events',
105
-                'capability' => 'import',
106
-                'noheader'   => true,
107
-            ),
108
-            'export_events'            => array(
109
-                'func'       => '_events_export',
110
-                'capability' => 'export',
111
-                'noheader'   => true,
112
-            ),
113
-            'export_categories'        => array(
114
-                'func'       => '_categories_export',
115
-                'capability' => 'export',
116
-                'noheader'   => true,
117
-            ),
118
-            'sample_export_file'       => array(
119
-                'func'       => '_sample_export_file',
120
-                'capability' => 'export',
121
-                'noheader'   => true,
122
-            ),
123
-            'update_template_settings' => array(
124
-                'func'       => '_update_template_settings',
125
-                'capability' => 'manage_options',
126
-                'noheader'   => true,
127
-            ),
128
-        );
129
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
130
-        //partial route/config override
131
-        $this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
132
-        $this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
133
-        $this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
134
-        $this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
135
-        $this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
136
-        $this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
137
-        //add tickets tab but only if there are more than one default ticket!
138
-        $tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
139
-            array(array('TKT_is_default' => 1)),
140
-            'TKT_ID',
141
-            true
142
-        );
143
-        if ($tkt_count > 1) {
144
-            $new_page_config = array(
145
-                'ticket_list_table' => array(
146
-                    'nav'           => array(
147
-                        'label' => esc_html__('Default Tickets', 'event_espresso'),
148
-                        'order' => 60,
149
-                    ),
150
-                    'list_table'    => 'Tickets_List_Table',
151
-                    'require_nonce' => false,
152
-                ),
153
-            );
154
-        }
155
-        //template settings
156
-        $new_page_config['template_settings'] = array(
157
-            'nav'           => array(
158
-                'label' => esc_html__('Templates', 'event_espresso'),
159
-                'order' => 30,
160
-            ),
161
-            'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
162
-            'help_tabs'     => array(
163
-                'general_settings_templates_help_tab' => array(
164
-                    'title'    => esc_html__('Templates', 'event_espresso'),
165
-                    'filename' => 'general_settings_templates',
166
-                ),
167
-            ),
168
-            'help_tour'     => array('Templates_Help_Tour'),
169
-            'require_nonce' => false,
170
-        );
171
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
172
-        //add filters and actions
173
-        //modifying _views
174
-        add_filter(
175
-            'FHEE_event_datetime_metabox_add_additional_date_time_template',
176
-            array($this, 'add_additional_datetime_button'),
177
-            10,
178
-            2
179
-        );
180
-        add_filter(
181
-            'FHEE_event_datetime_metabox_clone_button_template',
182
-            array($this, 'add_datetime_clone_button'),
183
-            10,
184
-            2
185
-        );
186
-        add_filter(
187
-            'FHEE_event_datetime_metabox_timezones_template',
188
-            array($this, 'datetime_timezones_template'),
189
-            10,
190
-            2
191
-        );
192
-        //filters for event list table
193
-        add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
194
-        add_filter(
195
-            'FHEE__Events_Admin_List_Table__column_actions__action_links',
196
-            array($this, 'extra_list_table_actions'),
197
-            10,
198
-            2
199
-        );
200
-        //legend item
201
-        add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
202
-        add_action('admin_init', array($this, 'admin_init'));
203
-        //heartbeat stuff
204
-        add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
205
-    }
206
-
207
-
208
-    /**
209
-     * admin_init
210
-     */
211
-    public function admin_init()
212
-    {
213
-        EE_Registry::$i18n_js_strings = array_merge(
214
-            EE_Registry::$i18n_js_strings,
215
-            array(
216
-                'image_confirm'          => esc_html__(
217
-                    'Do you really want to delete this image? Please remember to update your event to complete the removal.',
218
-                    'event_espresso'
219
-                ),
220
-                'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
221
-                'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
222
-                'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
223
-                'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
224
-                'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
225
-            )
226
-        );
227
-    }
228
-
229
-
230
-    /**
231
-     * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
232
-     * accordingly.
233
-     *
234
-     * @param array $response The existing heartbeat response array.
235
-     * @param array $data     The incoming data package.
236
-     * @return array  possibly appended response.
237
-     */
238
-    public function heartbeat_response($response, $data)
239
-    {
240
-        /**
241
-         * check whether count of tickets is approaching the potential
242
-         * limits for the server.
243
-         */
244
-        if (! empty($data['input_count'])) {
245
-            $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
246
-                $data['input_count']
247
-            );
248
-        }
249
-        return $response;
250
-    }
251
-
252
-
253
-    /**
254
-     * Add per page screen options to the default ticket list table view.
255
-     */
256
-    protected function _add_screen_options_ticket_list_table()
257
-    {
258
-        $this->_per_page_screen_option();
259
-    }
260
-
261
-
262
-    /**
263
-     * @param string $return
264
-     * @param int    $id
265
-     * @param string $new_title
266
-     * @param string $new_slug
267
-     * @return string
268
-     */
269
-    public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
270
-    {
271
-        $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
272
-        //make sure this is only when editing
273
-        if (! empty($id)) {
274
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
275
-                array('action' => 'duplicate_event', 'EVT_ID' => $id),
276
-                $this->_admin_base_url
277
-            );
278
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
279
-            $return .= '<a href="'
280
-                       . $href
281
-                       . '" title="'
282
-                       . $title
283
-                       . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
284
-                       . $title
285
-                       . '</button>';
286
-        }
287
-        return $return;
288
-    }
289
-
290
-
291
-    /**
292
-     * Set the list table views for the default ticket list table view.
293
-     */
294
-    public function _set_list_table_views_ticket_list_table()
295
-    {
296
-        $this->_views = array(
297
-            'all'     => array(
298
-                'slug'        => 'all',
299
-                'label'       => esc_html__('All', 'event_espresso'),
300
-                'count'       => 0,
301
-                'bulk_action' => array(
302
-                    'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
303
-                ),
304
-            ),
305
-            'trashed' => array(
306
-                'slug'        => 'trashed',
307
-                'label'       => esc_html__('Trash', 'event_espresso'),
308
-                'count'       => 0,
309
-                'bulk_action' => array(
310
-                    'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
311
-                    'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
312
-                ),
313
-            ),
314
-        );
315
-    }
316
-
317
-
318
-    /**
319
-     * Enqueue scripts and styles for the event editor.
320
-     */
321
-    public function load_scripts_styles_edit()
322
-    {
323
-        wp_register_script(
324
-            'ee-event-editor-heartbeat',
325
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
326
-            array('ee_admin_js', 'heartbeat'),
327
-            EVENT_ESPRESSO_VERSION,
328
-            true
329
-        );
330
-        wp_enqueue_script('ee-accounting');
331
-        //styles
332
-        wp_enqueue_style('espresso-ui-theme');
333
-        wp_enqueue_script('event_editor_js');
334
-        wp_enqueue_script('ee-event-editor-heartbeat');
335
-    }
336
-
337
-
338
-    /**
339
-     * Returns template for the additional datetime.
340
-     * @param $template
341
-     * @param $template_args
342
-     * @return mixed
343
-     * @throws DomainException
344
-     */
345
-    public function add_additional_datetime_button($template, $template_args)
346
-    {
347
-        return EEH_Template::display_template(
348
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
349
-            $template_args,
350
-            true
351
-        );
352
-    }
353
-
354
-
355
-    /**
356
-     * Returns the template for cloning a datetime.
357
-     * @param $template
358
-     * @param $template_args
359
-     * @return mixed
360
-     * @throws DomainException
361
-     */
362
-    public function add_datetime_clone_button($template, $template_args)
363
-    {
364
-        return EEH_Template::display_template(
365
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
366
-            $template_args,
367
-            true
368
-        );
369
-    }
370
-
371
-
372
-    /**
373
-     * Returns the template for datetime timezones.
374
-     * @param $template
375
-     * @param $template_args
376
-     * @return mixed
377
-     * @throws DomainException
378
-     */
379
-    public function datetime_timezones_template($template, $template_args)
380
-    {
381
-        return EEH_Template::display_template(
382
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
383
-            $template_args,
384
-            true
385
-        );
386
-    }
387
-
388
-
389
-    /**
390
-     * Sets the views for the default list table view.
391
-     */
392
-    protected function _set_list_table_views_default()
393
-    {
394
-        parent::_set_list_table_views_default();
395
-        $new_views    = array(
396
-            'today' => array(
397
-                'slug'        => 'today',
398
-                'label'       => esc_html__('Today', 'event_espresso'),
399
-                'count'       => $this->total_events_today(),
400
-                'bulk_action' => array(
401
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
402
-                ),
403
-            ),
404
-            'month' => array(
405
-                'slug'        => 'month',
406
-                'label'       => esc_html__('This Month', 'event_espresso'),
407
-                'count'       => $this->total_events_this_month(),
408
-                'bulk_action' => array(
409
-                    'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
410
-                ),
411
-            ),
412
-        );
413
-        $this->_views = array_merge($this->_views, $new_views);
414
-    }
415
-
416
-
417
-    /**
418
-     * Returns the extra action links for the default list table view.
419
-     * @param array     $action_links
420
-     * @param \EE_Event $event
421
-     * @return array
422
-     * @throws EE_Error
423
-     */
424
-    public function extra_list_table_actions(array $action_links, \EE_Event $event)
425
-    {
426
-        if (EE_Registry::instance()->CAP->current_user_can(
427
-            'ee_read_registrations',
428
-            'espresso_registrations_reports',
429
-            $event->ID()
430
-        )
431
-        ) {
432
-            $reports_query_args = array(
433
-                'action' => 'reports',
434
-                'EVT_ID' => $event->ID(),
435
-            );
436
-            $reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
437
-            $action_links[]     = '<a href="'
438
-                                  . $reports_link
439
-                                  . '" title="'
440
-                                  . esc_attr__('View Report', 'event_espresso')
441
-                                  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
442
-                                  . "\n\t";
443
-        }
444
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
445
-            EE_Registry::instance()->load_helper('MSG_Template');
446
-            $action_links[] = EEH_MSG_Template::get_message_action_link(
447
-                'see_notifications_for',
448
-                null,
449
-                array('EVT_ID' => $event->ID())
450
-            );
451
-        }
452
-        return $action_links;
453
-    }
454
-
455
-
456
-    /**
457
-     * @param $items
458
-     * @return mixed
459
-     */
460
-    public function additional_legend_items($items)
461
-    {
462
-        if (EE_Registry::instance()->CAP->current_user_can(
463
-            'ee_read_registrations',
464
-            'espresso_registrations_reports'
465
-        )
466
-        ) {
467
-            $items['reports'] = array(
468
-                'class' => 'dashicons dashicons-chart-bar',
469
-                'desc'  => esc_html__('Event Reports', 'event_espresso'),
470
-            );
471
-        }
472
-        if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
473
-            $related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
474
-            if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
475
-                $items['view_related_messages'] = array(
476
-                    'class' => $related_for_icon['css_class'],
477
-                    'desc'  => $related_for_icon['label'],
478
-                );
479
-            }
480
-        }
481
-        return $items;
482
-    }
483
-
484
-
485
-    /**
486
-     * This is the callback method for the duplicate event route
487
-     * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
488
-     * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
489
-     * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
490
-     * After duplication the redirect is to the new event edit page.
491
-     *
492
-     * @return void
493
-     * @access protected
494
-     * @throws EE_Error If EE_Event is not available with given ID
495
-     */
496
-    protected function _duplicate_event()
497
-    {
498
-        // first make sure the ID for the event is in the request.
499
-        //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
500
-        if (! isset($this->_req_data['EVT_ID'])) {
501
-            EE_Error::add_error(
502
-                esc_html__(
503
-                    'In order to duplicate an event an Event ID is required.  None was given.',
504
-                    'event_espresso'
505
-                ),
506
-                __FILE__,
507
-                __FUNCTION__,
508
-                __LINE__
509
-            );
510
-            $this->_redirect_after_action(false, '', '', array(), true);
511
-            return;
512
-        }
513
-        //k we've got EVT_ID so let's use that to get the event we'll duplicate
514
-        $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
515
-        if (! $orig_event instanceof EE_Event) {
516
-            throw new EE_Error(
517
-                sprintf(
518
-                    esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
519
-                    $this->_req_data['EVT_ID']
520
-                )
521
-            );
522
-        }
523
-        //k now let's clone the $orig_event before getting relations
524
-        $new_event = clone $orig_event;
525
-        //original datetimes
526
-        $orig_datetimes = $orig_event->get_many_related('Datetime');
527
-        //other original relations
528
-        $orig_ven = $orig_event->get_many_related('Venue');
529
-        //reset the ID and modify other details to make it clear this is a dupe
530
-        $new_event->set('EVT_ID', 0);
531
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
532
-        $new_event->set('EVT_name', $new_name);
533
-        $new_event->set(
534
-            'EVT_slug',
535
-            wp_unique_post_slug(
536
-                sanitize_title($orig_event->name()),
537
-                0,
538
-                'publish',
539
-                'espresso_events',
540
-                0
541
-            )
542
-        );
543
-        $new_event->set('status', 'draft');
544
-        //duplicate discussion settings
545
-        $new_event->set('comment_status', $orig_event->get('comment_status'));
546
-        $new_event->set('ping_status', $orig_event->get('ping_status'));
547
-        //save the new event
548
-        $new_event->save();
549
-        //venues
550
-        foreach ($orig_ven as $ven) {
551
-            $new_event->_add_relation_to($ven, 'Venue');
552
-        }
553
-        $new_event->save();
554
-        //now we need to get the question group relations and handle that
555
-        //first primary question groups
556
-        $orig_primary_qgs = $orig_event->get_many_related(
557
-            'Question_Group',
558
-            array(array('Event_Question_Group.EQG_primary' => 1))
559
-        );
560
-        if (! empty($orig_primary_qgs)) {
561
-            foreach ($orig_primary_qgs as $id => $obj) {
562
-                if ($obj instanceof EE_Question_Group) {
563
-                    $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
564
-                }
565
-            }
566
-        }
567
-        //next additional attendee question groups
568
-        $orig_additional_qgs = $orig_event->get_many_related(
569
-            'Question_Group',
570
-            array(array('Event_Question_Group.EQG_primary' => 0))
571
-        );
572
-        if (! empty($orig_additional_qgs)) {
573
-            foreach ($orig_additional_qgs as $id => $obj) {
574
-                if ($obj instanceof EE_Question_Group) {
575
-                    $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
576
-                }
577
-            }
578
-        }
579
-        //now save
580
-        $new_event->save();
581
-        //k now that we have the new event saved we can loop through the datetimes and start adding relations.
582
-        $cloned_tickets = array();
583
-        foreach ($orig_datetimes as $orig_dtt) {
584
-            if (! $orig_dtt instanceof EE_Datetime) {
585
-                continue;
586
-            }
587
-            $new_dtt   = clone $orig_dtt;
588
-            $orig_tkts = $orig_dtt->tickets();
589
-            //save new dtt then add to event
590
-            $new_dtt->set('DTT_ID', 0);
591
-            $new_dtt->set('DTT_sold', 0);
592
-            $new_dtt->set_reserved(0);
593
-            $new_dtt->save();
594
-            $new_event->_add_relation_to($new_dtt, 'Datetime');
595
-            $new_event->save();
596
-            //now let's get the ticket relations setup.
597
-            foreach ((array)$orig_tkts as $orig_tkt) {
598
-                //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
599
-                if (! $orig_tkt instanceof EE_Ticket) {
600
-                    continue;
601
-                }
602
-                //is this ticket archived?  If it is then let's skip
603
-                if ($orig_tkt->get('TKT_deleted')) {
604
-                    continue;
605
-                }
606
-                // does this original ticket already exist in the clone_tickets cache?
607
-                //  If so we'll just use the new ticket from it.
608
-                if (isset($cloned_tickets[$orig_tkt->ID()])) {
609
-                    $new_tkt = $cloned_tickets[$orig_tkt->ID()];
610
-                } else {
611
-                    $new_tkt = clone $orig_tkt;
612
-                    //get relations on the $orig_tkt that we need to setup.
613
-                    $orig_prices = $orig_tkt->prices();
614
-                    $new_tkt->set('TKT_ID', 0);
615
-                    $new_tkt->set('TKT_sold', 0);
616
-                    $new_tkt->set('TKT_reserved', 0);
617
-                    $new_tkt->save(); //make sure new ticket has ID.
618
-                    //price relations on new ticket need to be setup.
619
-                    foreach ($orig_prices as $orig_price) {
620
-                        $new_price = clone $orig_price;
621
-                        $new_price->set('PRC_ID', 0);
622
-                        $new_price->save();
623
-                        $new_tkt->_add_relation_to($new_price, 'Price');
624
-                        $new_tkt->save();
625
-                    }
626
-                }
627
-                // k now we can add the new ticket as a relation to the new datetime
628
-                // and make sure its added to our cached $cloned_tickets array
629
-                // for use with later datetimes that have the same ticket.
630
-                $new_dtt->_add_relation_to($new_tkt, 'Ticket');
631
-                $new_dtt->save();
632
-                $cloned_tickets[$orig_tkt->ID()] = $new_tkt;
633
-            }
634
-        }
635
-        //clone taxonomy information
636
-        $taxonomies_to_clone_with = apply_filters(
637
-            'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
638
-            array('espresso_event_categories', 'espresso_event_type', 'post_tag')
639
-        );
640
-        //get terms for original event (notice)
641
-        $orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
642
-        //loop through terms and add them to new event.
643
-        foreach ($orig_terms as $term) {
644
-            wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
645
-        }
646
-        do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
647
-        //now let's redirect to the edit page for this duplicated event if we have a new event id.
648
-        if ($new_event->ID()) {
649
-            $redirect_args = array(
650
-                'post'   => $new_event->ID(),
651
-                'action' => 'edit',
652
-            );
653
-            EE_Error::add_success(
654
-                esc_html__(
655
-                    'Event successfully duplicated.  Please review the details below and make any necessary edits',
656
-                    'event_espresso'
657
-                )
658
-            );
659
-        } else {
660
-            $redirect_args = array(
661
-                'action' => 'default',
662
-            );
663
-            EE_Error::add_error(
664
-                esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
665
-                __FILE__,
666
-                __FUNCTION__,
667
-                __LINE__
668
-            );
669
-        }
670
-        $this->_redirect_after_action(false, '', '', $redirect_args, true);
671
-    }
672
-
673
-
674
-    /**
675
-     * Generates output for the import page.
676
-     * @throws DomainException
677
-     */
678
-    protected function _import_page()
679
-    {
680
-        $title                                      = esc_html__('Import', 'event_espresso');
681
-        $intro                                      = esc_html__(
682
-            'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
683
-            'event_espresso'
684
-        );
685
-        $form_url                                   = EVENTS_ADMIN_URL;
686
-        $action                                     = 'import_events';
687
-        $type                                       = 'csv';
688
-        $this->_template_args['form']               = EE_Import::instance()->upload_form(
689
-            $title, $intro, $form_url, $action, $type
690
-        );
691
-        $this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
692
-            array('action' => 'sample_export_file'),
693
-            $this->_admin_base_url
694
-        );
695
-        $content                                    = EEH_Template::display_template(
696
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
697
-            $this->_template_args,
698
-            true
699
-        );
700
-        $this->_template_args['admin_page_content'] = $content;
701
-        $this->display_admin_page_with_sidebar();
702
-    }
703
-
704
-
705
-    /**
706
-     * _import_events
707
-     * This handles displaying the screen and running imports for importing events.
708
-     *
709
-     * @return void
710
-     */
711
-    protected function _import_events()
712
-    {
713
-        require_once(EE_CLASSES . 'EE_Import.class.php');
714
-        $success = EE_Import::instance()->import();
715
-        $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
716
-    }
717
-
718
-
719
-    /**
720
-     * _events_export
721
-     * Will export all (or just the given event) to a Excel compatible file.
722
-     *
723
-     * @access protected
724
-     * @return void
725
-     */
726
-    protected function _events_export()
727
-    {
728
-        if (isset($this->_req_data['EVT_ID'])) {
729
-            $event_ids = $this->_req_data['EVT_ID'];
730
-        } elseif (isset($this->_req_data['EVT_IDs'])) {
731
-            $event_ids = $this->_req_data['EVT_IDs'];
732
-        } else {
733
-            $event_ids = null;
734
-        }
735
-        //todo: I don't like doing this but it'll do until we modify EE_Export Class.
736
-        $new_request_args = array(
737
-            'export' => 'report',
738
-            'action' => 'all_event_data',
739
-            'EVT_ID' => $event_ids,
740
-        );
741
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
742
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
743
-            require_once(EE_CLASSES . 'EE_Export.class.php');
744
-            $EE_Export = EE_Export::instance($this->_req_data);
745
-            $EE_Export->export();
746
-        }
747
-    }
748
-
749
-
750
-    /**
751
-     * handle category exports()
752
-     *
753
-     * @return void
754
-     */
755
-    protected function _categories_export()
756
-    {
757
-        //todo: I don't like doing this but it'll do until we modify EE_Export Class.
758
-        $new_request_args = array(
759
-            'export'       => 'report',
760
-            'action'       => 'categories',
761
-            'category_ids' => $this->_req_data['EVT_CAT_ID'],
762
-        );
763
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
764
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
765
-            require_once(EE_CLASSES . 'EE_Export.class.php');
766
-            $EE_Export = EE_Export::instance($this->_req_data);
767
-            $EE_Export->export();
768
-        }
769
-    }
770
-
771
-
772
-    /**
773
-     * Creates a sample CSV file for importing
774
-     */
775
-    protected function _sample_export_file()
776
-    {
777
-        //		require_once(EE_CLASSES . 'EE_Export.class.php');
778
-        EE_Export::instance()->export_sample();
779
-    }
780
-
781
-
782
-    /*************        Template Settings        *************/
783
-    /**
784
-     * Generates template settings page output
785
-     * @throws DomainException
786
-     * @throws EE_Error
787
-     */
788
-    protected function _template_settings()
789
-    {
790
-        $this->_template_args['values'] = $this->_yes_no_values;
791
-        /**
792
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
793
-         * from General_Settings_Admin_Page to here.
794
-         */
795
-        $this->_template_args = apply_filters(
796
-            'FHEE__General_Settings_Admin_Page__template_settings__template_args',
797
-            $this->_template_args
798
-        );
799
-        $this->_set_add_edit_form_tags('update_template_settings');
800
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
801
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
802
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
803
-            $this->_template_args,
804
-            true
805
-        );
806
-        $this->display_admin_page_with_sidebar();
807
-    }
808
-
809
-
810
-    /**
811
-     * Handler for updating template settings.
812
-     */
813
-    protected function _update_template_settings()
814
-    {
815
-        /**
816
-         * Note leaving this filter in for backward compatibility this was moved in 4.6.x
817
-         * from General_Settings_Admin_Page to here.
818
-         */
819
-        EE_Registry::instance()->CFG->template_settings = apply_filters(
820
-            'FHEE__General_Settings_Admin_Page__update_template_settings__data',
821
-            EE_Registry::instance()->CFG->template_settings,
822
-            $this->_req_data
823
-        );
824
-        //update custom post type slugs and detect if we need to flush rewrite rules
825
-        $old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
826
-        EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
827
-            ? EE_Registry::instance()->CFG->core->event_cpt_slug
828
-            : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
829
-        $what                                              = 'Template Settings';
830
-        $success                                           = $this->_update_espresso_configuration(
831
-            $what,
832
-            EE_Registry::instance()->CFG->template_settings,
833
-            __FILE__,
834
-            __FUNCTION__,
835
-            __LINE__
836
-        );
837
-        if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
838
-            update_option('ee_flush_rewrite_rules', true);
839
-        }
840
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
841
-    }
842
-
843
-
844
-    /**
845
-     * _premium_event_editor_meta_boxes
846
-     * add all metaboxes related to the event_editor
847
-     *
848
-     * @access protected
849
-     * @return void
850
-     * @throws EE_Error
851
-     */
852
-    protected function _premium_event_editor_meta_boxes()
853
-    {
854
-        $this->verify_cpt_object();
855
-        add_meta_box(
856
-            'espresso_event_editor_event_options',
857
-            esc_html__('Event Registration Options', 'event_espresso'),
858
-            array($this, 'registration_options_meta_box'),
859
-            $this->page_slug,
860
-            'side',
861
-            'core'
862
-        );
863
-    }
864
-
865
-
866
-    /**
867
-     * override caf metabox
868
-     *
869
-     * @return void
870
-     * @throws DomainException
871
-     */
872
-    public function registration_options_meta_box()
873
-    {
874
-        $yes_no_values                                    = array(
875
-            array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
876
-            array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
877
-        );
878
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
879
-            array(
880
-                EEM_Registration::status_id_cancelled,
881
-                EEM_Registration::status_id_declined,
882
-                EEM_Registration::status_id_incomplete,
883
-                EEM_Registration::status_id_wait_list,
884
-            ),
885
-            true
886
-        );
887
-        $template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
888
-        $template_args['_event']                          = $this->_cpt_model_obj;
889
-        $template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
890
-        $template_args['default_registration_status']     = EEH_Form_Fields::select_input(
891
-            'default_reg_status',
892
-            $default_reg_status_values,
893
-            $this->_cpt_model_obj->default_registration_status()
894
-        );
895
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
896
-            'display_desc',
897
-            $yes_no_values,
898
-            $this->_cpt_model_obj->display_description()
899
-        );
900
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
901
-            'display_ticket_selector',
902
-            $yes_no_values,
903
-            $this->_cpt_model_obj->display_ticket_selector(),
904
-            '',
905
-            '',
906
-            false
907
-        );
908
-        $template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
909
-            'EVT_default_registration_status',
910
-            $default_reg_status_values,
911
-            $this->_cpt_model_obj->default_registration_status()
912
-        );
913
-        $template_args['additional_registration_options'] = apply_filters(
914
-            'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
915
-            '',
916
-            $template_args,
917
-            $yes_no_values,
918
-            $default_reg_status_values
919
-        );
920
-        EEH_Template::display_template(
921
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
922
-            $template_args
923
-        );
924
-    }
925
-
926
-
927
-
928
-    /**
929
-     * wp_list_table_mods for caf
930
-     * ============================
931
-     */
932
-    /**
933
-     * hook into list table filters and provide filters for caffeinated list table
934
-     *
935
-     * @param  array $old_filters    any existing filters present
936
-     * @param  array $list_table_obj the list table object
937
-     * @return array                  new filters
938
-     */
939
-    public function list_table_filters($old_filters, $list_table_obj)
940
-    {
941
-        $filters = array();
942
-        //first month/year filters
943
-        $filters[] = $this->espresso_event_months_dropdown();
944
-        $status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
945
-        //active status dropdown
946
-        if ($status !== 'draft') {
947
-            $filters[] = $this->active_status_dropdown(
948
-                isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
949
-            );
950
-        }
951
-        //category filter
952
-        $filters[] = $this->category_dropdown();
953
-        return array_merge($old_filters, $filters);
954
-    }
955
-
956
-
957
-    /**
958
-     * espresso_event_months_dropdown
959
-     *
960
-     * @access public
961
-     * @return string                dropdown listing month/year selections for events.
962
-     */
963
-    public function espresso_event_months_dropdown()
964
-    {
965
-        // what we need to do is get all PRIMARY datetimes for all events to filter on.
966
-        // Note we need to include any other filters that are set!
967
-        $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
968
-        //categories?
969
-        $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
970
-            ? $this->_req_data['EVT_CAT']
971
-            : null;
972
-        //active status?
973
-        $active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
974
-        $cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
975
-        return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
976
-    }
977
-
978
-
979
-    /**
980
-     * returns a list of "active" statuses on the event
981
-     *
982
-     * @param  string $current_value whatever the current active status is
983
-     * @return string
984
-     */
985
-    public function active_status_dropdown($current_value = '')
986
-    {
987
-        $select_name = 'active_status';
988
-        $values      = array(
989
-            'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
990
-            'active'   => esc_html__('Active', 'event_espresso'),
991
-            'upcoming' => esc_html__('Upcoming', 'event_espresso'),
992
-            'expired'  => esc_html__('Expired', 'event_espresso'),
993
-            'inactive' => esc_html__('Inactive', 'event_espresso'),
994
-        );
995
-        $id          = 'id="espresso-active-status-dropdown-filter"';
996
-        $class       = 'wide';
997
-        return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
998
-    }
999
-
1000
-
1001
-    /**
1002
-     * output a dropdown of the categories for the category filter on the event admin list table
1003
-     *
1004
-     * @access  public
1005
-     * @return string html
1006
-     */
1007
-    public function category_dropdown()
1008
-    {
1009
-        $cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1010
-        return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1011
-    }
1012
-
1013
-
1014
-    /**
1015
-     * get total number of events today
1016
-     *
1017
-     * @access public
1018
-     * @return int
1019
-     * @throws EE_Error
1020
-     */
1021
-    public function total_events_today()
1022
-    {
1023
-        $start = EEM_Datetime::instance()->convert_datetime_for_query(
1024
-            'DTT_EVT_start',
1025
-            date('Y-m-d') . ' 00:00:00',
1026
-            'Y-m-d H:i:s',
1027
-            'UTC'
1028
-        );
1029
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1030
-            'DTT_EVT_start',
1031
-            date('Y-m-d') . ' 23:59:59',
1032
-            'Y-m-d H:i:s',
1033
-            'UTC'
1034
-        );
1035
-        $where = array(
1036
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1037
-        );
1038
-        $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1039
-        return $count;
1040
-    }
1041
-
1042
-
1043
-    /**
1044
-     * get total number of events this month
1045
-     *
1046
-     * @access public
1047
-     * @return int
1048
-     * @throws EE_Error
1049
-     */
1050
-    public function total_events_this_month()
1051
-    {
1052
-        //Dates
1053
-        $this_year_r     = date('Y');
1054
-        $this_month_r    = date('m');
1055
-        $days_this_month = date('t');
1056
-        $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1057
-            'DTT_EVT_start',
1058
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1059
-            'Y-m-d H:i:s',
1060
-            'UTC'
1061
-        );
1062
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1063
-            'DTT_EVT_start',
1064
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1065
-            'Y-m-d H:i:s',
1066
-            'UTC'
1067
-        );
1068
-        $where           = array(
1069
-            'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1070
-        );
1071
-        $count           = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1072
-        return $count;
1073
-    }
1074
-
1075
-
1076
-    /** DEFAULT TICKETS STUFF **/
1077
-
1078
-    /**
1079
-     * Output default tickets list table view.
1080
-     */
1081
-    public function _tickets_overview_list_table()
1082
-    {
1083
-        $this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1084
-        $this->display_admin_list_table_page_with_no_sidebar();
1085
-    }
1086
-
1087
-
1088
-    /**
1089
-     * @param int  $per_page
1090
-     * @param bool $count
1091
-     * @param bool $trashed
1092
-     * @return \EE_Soft_Delete_Base_Class[]|int
1093
-     */
1094
-    public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1095
-    {
1096
-        $orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1097
-        $order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1098
-        switch ($orderby) {
1099
-            case 'TKT_name':
1100
-                $orderby = array('TKT_name' => $order);
1101
-                break;
1102
-            case 'TKT_price':
1103
-                $orderby = array('TKT_price' => $order);
1104
-                break;
1105
-            case 'TKT_uses':
1106
-                $orderby = array('TKT_uses' => $order);
1107
-                break;
1108
-            case 'TKT_min':
1109
-                $orderby = array('TKT_min' => $order);
1110
-                break;
1111
-            case 'TKT_max':
1112
-                $orderby = array('TKT_max' => $order);
1113
-                break;
1114
-            case 'TKT_qty':
1115
-                $orderby = array('TKT_qty' => $order);
1116
-                break;
1117
-        }
1118
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1119
-            ? $this->_req_data['paged']
1120
-            : 1;
1121
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1122
-            ? $this->_req_data['perpage']
1123
-            : $per_page;
1124
-        $_where       = array(
1125
-            'TKT_is_default' => 1,
1126
-            'TKT_deleted'    => $trashed,
1127
-        );
1128
-        $offset       = ($current_page - 1) * $per_page;
1129
-        $limit        = array($offset, $per_page);
1130
-        if (isset($this->_req_data['s'])) {
1131
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1132
-            $_where['OR'] = array(
1133
-                'TKT_name'        => array('LIKE', $sstr),
1134
-                'TKT_description' => array('LIKE', $sstr),
1135
-            );
1136
-        }
1137
-        $query_params = array(
1138
-            $_where,
1139
-            'order_by' => $orderby,
1140
-            'limit'    => $limit,
1141
-            'group_by' => 'TKT_ID',
1142
-        );
1143
-        if ($count) {
1144
-            return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1145
-        } else {
1146
-            return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1147
-        }
1148
-    }
1149
-
1150
-
1151
-    /**
1152
-     * @param bool $trash
1153
-     * @throws EE_Error
1154
-     */
1155
-    protected function _trash_or_restore_ticket($trash = false)
1156
-    {
1157
-        $success = 1;
1158
-        $TKT     = EEM_Ticket::instance();
1159
-        //checkboxes?
1160
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1161
-            //if array has more than one element then success message should be plural
1162
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1163
-            //cycle thru the boxes
1164
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1165
-                if ($trash) {
1166
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1167
-                        $success = 0;
1168
-                    }
1169
-                } else {
1170
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1171
-                        $success = 0;
1172
-                    }
1173
-                }
1174
-            }
1175
-        } else {
1176
-            //grab single id and trash
1177
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1178
-            if ($trash) {
1179
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1180
-                    $success = 0;
1181
-                }
1182
-            } else {
1183
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1184
-                    $success = 0;
1185
-                }
1186
-            }
1187
-        }
1188
-        $action_desc = $trash ? 'moved to the trash' : 'restored';
1189
-        $query_args  = array(
1190
-            'action' => 'ticket_list_table',
1191
-            'status' => $trash ? '' : 'trashed',
1192
-        );
1193
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1194
-    }
1195
-
1196
-
1197
-    /**
1198
-     * Handles trashing default ticket.
1199
-     */
1200
-    protected function _delete_ticket()
1201
-    {
1202
-        $success = 1;
1203
-        //checkboxes?
1204
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1205
-            //if array has more than one element then success message should be plural
1206
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1207
-            //cycle thru the boxes
1208
-            while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1209
-                //delete
1210
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1211
-                    $success = 0;
1212
-                }
1213
-            }
1214
-        } else {
1215
-            //grab single id and trash
1216
-            $TKT_ID = absint($this->_req_data['TKT_ID']);
1217
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1218
-                $success = 0;
1219
-            }
1220
-        }
1221
-        $action_desc = 'deleted';
1222
-        $query_args  = array(
1223
-            'action' => 'ticket_list_table',
1224
-            'status' => 'trashed',
1225
-        );
1226
-        //fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1227
-        if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1228
-            array(array('TKT_is_default' => 1)),
1229
-            'TKT_ID',
1230
-            true
1231
-        )
1232
-        ) {
1233
-            $query_args = array();
1234
-        }
1235
-        $this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1236
-    }
1237
-
1238
-
1239
-    /**
1240
-     * @param int $TKT_ID
1241
-     * @return bool|int
1242
-     * @throws EE_Error
1243
-     */
1244
-    protected function _delete_the_ticket($TKT_ID)
1245
-    {
1246
-        $tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1247
-        $tkt->_remove_relations('Datetime');
1248
-        //delete all related prices first
1249
-        $tkt->delete_related_permanently('Price');
1250
-        return $tkt->delete_permanently();
1251
-    }
17
+	/**
18
+	 * Extend_Events_Admin_Page constructor.
19
+	 *
20
+	 * @param bool $routing
21
+	 */
22
+	public function __construct($routing = true)
23
+	{
24
+		parent::__construct($routing);
25
+		if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
+			define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
27
+			define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
28
+			define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
29
+		}
30
+	}
31
+
32
+
33
+	/**
34
+	 * Sets routes.
35
+	 */
36
+	protected function _extend_page_config()
37
+	{
38
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
39
+		//is there a evt_id in the request?
40
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
41
+			? $this->_req_data['EVT_ID']
42
+			: 0;
43
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
44
+		//tkt_id?
45
+		$tkt_id             = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID'])
46
+			? $this->_req_data['TKT_ID']
47
+			: 0;
48
+		$new_page_routes    = array(
49
+			'duplicate_event'          => array(
50
+				'func'       => '_duplicate_event',
51
+				'capability' => 'ee_edit_event',
52
+				'obj_id'     => $evt_id,
53
+				'noheader'   => true,
54
+			),
55
+			'ticket_list_table'        => array(
56
+				'func'       => '_tickets_overview_list_table',
57
+				'capability' => 'ee_read_default_tickets',
58
+			),
59
+			'trash_ticket'             => array(
60
+				'func'       => '_trash_or_restore_ticket',
61
+				'capability' => 'ee_delete_default_ticket',
62
+				'obj_id'     => $tkt_id,
63
+				'noheader'   => true,
64
+				'args'       => array('trash' => true),
65
+			),
66
+			'trash_tickets'            => array(
67
+				'func'       => '_trash_or_restore_ticket',
68
+				'capability' => 'ee_delete_default_tickets',
69
+				'noheader'   => true,
70
+				'args'       => array('trash' => true),
71
+			),
72
+			'restore_ticket'           => array(
73
+				'func'       => '_trash_or_restore_ticket',
74
+				'capability' => 'ee_delete_default_ticket',
75
+				'obj_id'     => $tkt_id,
76
+				'noheader'   => true,
77
+			),
78
+			'restore_tickets'          => array(
79
+				'func'       => '_trash_or_restore_ticket',
80
+				'capability' => 'ee_delete_default_tickets',
81
+				'noheader'   => true,
82
+			),
83
+			'delete_ticket'            => array(
84
+				'func'       => '_delete_ticket',
85
+				'capability' => 'ee_delete_default_ticket',
86
+				'obj_id'     => $tkt_id,
87
+				'noheader'   => true,
88
+			),
89
+			'delete_tickets'           => array(
90
+				'func'       => '_delete_ticket',
91
+				'capability' => 'ee_delete_default_tickets',
92
+				'noheader'   => true,
93
+			),
94
+			'import_page'              => array(
95
+				'func'       => '_import_page',
96
+				'capability' => 'import',
97
+			),
98
+			'import'                   => array(
99
+				'func'       => '_import_events',
100
+				'capability' => 'import',
101
+				'noheader'   => true,
102
+			),
103
+			'import_events'            => array(
104
+				'func'       => '_import_events',
105
+				'capability' => 'import',
106
+				'noheader'   => true,
107
+			),
108
+			'export_events'            => array(
109
+				'func'       => '_events_export',
110
+				'capability' => 'export',
111
+				'noheader'   => true,
112
+			),
113
+			'export_categories'        => array(
114
+				'func'       => '_categories_export',
115
+				'capability' => 'export',
116
+				'noheader'   => true,
117
+			),
118
+			'sample_export_file'       => array(
119
+				'func'       => '_sample_export_file',
120
+				'capability' => 'export',
121
+				'noheader'   => true,
122
+			),
123
+			'update_template_settings' => array(
124
+				'func'       => '_update_template_settings',
125
+				'capability' => 'manage_options',
126
+				'noheader'   => true,
127
+			),
128
+		);
129
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
130
+		//partial route/config override
131
+		$this->_page_config['import_events']['metaboxes'] = $this->_default_espresso_metaboxes;
132
+		$this->_page_config['create_new']['metaboxes'][]  = '_premium_event_editor_meta_boxes';
133
+		$this->_page_config['create_new']['qtips'][]      = 'EE_Event_Editor_Tips';
134
+		$this->_page_config['edit']['qtips'][]            = 'EE_Event_Editor_Tips';
135
+		$this->_page_config['edit']['metaboxes'][]        = '_premium_event_editor_meta_boxes';
136
+		$this->_page_config['default']['list_table']      = 'Extend_Events_Admin_List_Table';
137
+		//add tickets tab but only if there are more than one default ticket!
138
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(
139
+			array(array('TKT_is_default' => 1)),
140
+			'TKT_ID',
141
+			true
142
+		);
143
+		if ($tkt_count > 1) {
144
+			$new_page_config = array(
145
+				'ticket_list_table' => array(
146
+					'nav'           => array(
147
+						'label' => esc_html__('Default Tickets', 'event_espresso'),
148
+						'order' => 60,
149
+					),
150
+					'list_table'    => 'Tickets_List_Table',
151
+					'require_nonce' => false,
152
+				),
153
+			);
154
+		}
155
+		//template settings
156
+		$new_page_config['template_settings'] = array(
157
+			'nav'           => array(
158
+				'label' => esc_html__('Templates', 'event_espresso'),
159
+				'order' => 30,
160
+			),
161
+			'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
162
+			'help_tabs'     => array(
163
+				'general_settings_templates_help_tab' => array(
164
+					'title'    => esc_html__('Templates', 'event_espresso'),
165
+					'filename' => 'general_settings_templates',
166
+				),
167
+			),
168
+			'help_tour'     => array('Templates_Help_Tour'),
169
+			'require_nonce' => false,
170
+		);
171
+		$this->_page_config                   = array_merge($this->_page_config, $new_page_config);
172
+		//add filters and actions
173
+		//modifying _views
174
+		add_filter(
175
+			'FHEE_event_datetime_metabox_add_additional_date_time_template',
176
+			array($this, 'add_additional_datetime_button'),
177
+			10,
178
+			2
179
+		);
180
+		add_filter(
181
+			'FHEE_event_datetime_metabox_clone_button_template',
182
+			array($this, 'add_datetime_clone_button'),
183
+			10,
184
+			2
185
+		);
186
+		add_filter(
187
+			'FHEE_event_datetime_metabox_timezones_template',
188
+			array($this, 'datetime_timezones_template'),
189
+			10,
190
+			2
191
+		);
192
+		//filters for event list table
193
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
194
+		add_filter(
195
+			'FHEE__Events_Admin_List_Table__column_actions__action_links',
196
+			array($this, 'extra_list_table_actions'),
197
+			10,
198
+			2
199
+		);
200
+		//legend item
201
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
202
+		add_action('admin_init', array($this, 'admin_init'));
203
+		//heartbeat stuff
204
+		add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
205
+	}
206
+
207
+
208
+	/**
209
+	 * admin_init
210
+	 */
211
+	public function admin_init()
212
+	{
213
+		EE_Registry::$i18n_js_strings = array_merge(
214
+			EE_Registry::$i18n_js_strings,
215
+			array(
216
+				'image_confirm'          => esc_html__(
217
+					'Do you really want to delete this image? Please remember to update your event to complete the removal.',
218
+					'event_espresso'
219
+				),
220
+				'event_starts_on'        => esc_html__('Event Starts on', 'event_espresso'),
221
+				'event_ends_on'          => esc_html__('Event Ends on', 'event_espresso'),
222
+				'event_datetime_actions' => esc_html__('Actions', 'event_espresso'),
223
+				'event_clone_dt_msg'     => esc_html__('Clone this Event Date and Time', 'event_espresso'),
224
+				'remove_event_dt_msg'    => esc_html__('Remove this Event Time', 'event_espresso'),
225
+			)
226
+		);
227
+	}
228
+
229
+
230
+	/**
231
+	 * This will be used to listen for any heartbeat data packages coming via the WordPress heartbeat API and handle
232
+	 * accordingly.
233
+	 *
234
+	 * @param array $response The existing heartbeat response array.
235
+	 * @param array $data     The incoming data package.
236
+	 * @return array  possibly appended response.
237
+	 */
238
+	public function heartbeat_response($response, $data)
239
+	{
240
+		/**
241
+		 * check whether count of tickets is approaching the potential
242
+		 * limits for the server.
243
+		 */
244
+		if (! empty($data['input_count'])) {
245
+			$response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
246
+				$data['input_count']
247
+			);
248
+		}
249
+		return $response;
250
+	}
251
+
252
+
253
+	/**
254
+	 * Add per page screen options to the default ticket list table view.
255
+	 */
256
+	protected function _add_screen_options_ticket_list_table()
257
+	{
258
+		$this->_per_page_screen_option();
259
+	}
260
+
261
+
262
+	/**
263
+	 * @param string $return
264
+	 * @param int    $id
265
+	 * @param string $new_title
266
+	 * @param string $new_slug
267
+	 * @return string
268
+	 */
269
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug)
270
+	{
271
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
272
+		//make sure this is only when editing
273
+		if (! empty($id)) {
274
+			$href   = EE_Admin_Page::add_query_args_and_nonce(
275
+				array('action' => 'duplicate_event', 'EVT_ID' => $id),
276
+				$this->_admin_base_url
277
+			);
278
+			$title  = esc_attr__('Duplicate Event', 'event_espresso');
279
+			$return .= '<a href="'
280
+					   . $href
281
+					   . '" title="'
282
+					   . $title
283
+					   . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'
284
+					   . $title
285
+					   . '</button>';
286
+		}
287
+		return $return;
288
+	}
289
+
290
+
291
+	/**
292
+	 * Set the list table views for the default ticket list table view.
293
+	 */
294
+	public function _set_list_table_views_ticket_list_table()
295
+	{
296
+		$this->_views = array(
297
+			'all'     => array(
298
+				'slug'        => 'all',
299
+				'label'       => esc_html__('All', 'event_espresso'),
300
+				'count'       => 0,
301
+				'bulk_action' => array(
302
+					'trash_tickets' => esc_html__('Move to Trash', 'event_espresso'),
303
+				),
304
+			),
305
+			'trashed' => array(
306
+				'slug'        => 'trashed',
307
+				'label'       => esc_html__('Trash', 'event_espresso'),
308
+				'count'       => 0,
309
+				'bulk_action' => array(
310
+					'restore_tickets' => esc_html__('Restore from Trash', 'event_espresso'),
311
+					'delete_tickets'  => esc_html__('Delete Permanently', 'event_espresso'),
312
+				),
313
+			),
314
+		);
315
+	}
316
+
317
+
318
+	/**
319
+	 * Enqueue scripts and styles for the event editor.
320
+	 */
321
+	public function load_scripts_styles_edit()
322
+	{
323
+		wp_register_script(
324
+			'ee-event-editor-heartbeat',
325
+			EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
326
+			array('ee_admin_js', 'heartbeat'),
327
+			EVENT_ESPRESSO_VERSION,
328
+			true
329
+		);
330
+		wp_enqueue_script('ee-accounting');
331
+		//styles
332
+		wp_enqueue_style('espresso-ui-theme');
333
+		wp_enqueue_script('event_editor_js');
334
+		wp_enqueue_script('ee-event-editor-heartbeat');
335
+	}
336
+
337
+
338
+	/**
339
+	 * Returns template for the additional datetime.
340
+	 * @param $template
341
+	 * @param $template_args
342
+	 * @return mixed
343
+	 * @throws DomainException
344
+	 */
345
+	public function add_additional_datetime_button($template, $template_args)
346
+	{
347
+		return EEH_Template::display_template(
348
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
349
+			$template_args,
350
+			true
351
+		);
352
+	}
353
+
354
+
355
+	/**
356
+	 * Returns the template for cloning a datetime.
357
+	 * @param $template
358
+	 * @param $template_args
359
+	 * @return mixed
360
+	 * @throws DomainException
361
+	 */
362
+	public function add_datetime_clone_button($template, $template_args)
363
+	{
364
+		return EEH_Template::display_template(
365
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
366
+			$template_args,
367
+			true
368
+		);
369
+	}
370
+
371
+
372
+	/**
373
+	 * Returns the template for datetime timezones.
374
+	 * @param $template
375
+	 * @param $template_args
376
+	 * @return mixed
377
+	 * @throws DomainException
378
+	 */
379
+	public function datetime_timezones_template($template, $template_args)
380
+	{
381
+		return EEH_Template::display_template(
382
+			EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
383
+			$template_args,
384
+			true
385
+		);
386
+	}
387
+
388
+
389
+	/**
390
+	 * Sets the views for the default list table view.
391
+	 */
392
+	protected function _set_list_table_views_default()
393
+	{
394
+		parent::_set_list_table_views_default();
395
+		$new_views    = array(
396
+			'today' => array(
397
+				'slug'        => 'today',
398
+				'label'       => esc_html__('Today', 'event_espresso'),
399
+				'count'       => $this->total_events_today(),
400
+				'bulk_action' => array(
401
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
402
+				),
403
+			),
404
+			'month' => array(
405
+				'slug'        => 'month',
406
+				'label'       => esc_html__('This Month', 'event_espresso'),
407
+				'count'       => $this->total_events_this_month(),
408
+				'bulk_action' => array(
409
+					'trash_events' => esc_html__('Move to Trash', 'event_espresso'),
410
+				),
411
+			),
412
+		);
413
+		$this->_views = array_merge($this->_views, $new_views);
414
+	}
415
+
416
+
417
+	/**
418
+	 * Returns the extra action links for the default list table view.
419
+	 * @param array     $action_links
420
+	 * @param \EE_Event $event
421
+	 * @return array
422
+	 * @throws EE_Error
423
+	 */
424
+	public function extra_list_table_actions(array $action_links, \EE_Event $event)
425
+	{
426
+		if (EE_Registry::instance()->CAP->current_user_can(
427
+			'ee_read_registrations',
428
+			'espresso_registrations_reports',
429
+			$event->ID()
430
+		)
431
+		) {
432
+			$reports_query_args = array(
433
+				'action' => 'reports',
434
+				'EVT_ID' => $event->ID(),
435
+			);
436
+			$reports_link       = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
437
+			$action_links[]     = '<a href="'
438
+								  . $reports_link
439
+								  . '" title="'
440
+								  . esc_attr__('View Report', 'event_espresso')
441
+								  . '"><div class="dashicons dashicons-chart-bar"></div></a>'
442
+								  . "\n\t";
443
+		}
444
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
445
+			EE_Registry::instance()->load_helper('MSG_Template');
446
+			$action_links[] = EEH_MSG_Template::get_message_action_link(
447
+				'see_notifications_for',
448
+				null,
449
+				array('EVT_ID' => $event->ID())
450
+			);
451
+		}
452
+		return $action_links;
453
+	}
454
+
455
+
456
+	/**
457
+	 * @param $items
458
+	 * @return mixed
459
+	 */
460
+	public function additional_legend_items($items)
461
+	{
462
+		if (EE_Registry::instance()->CAP->current_user_can(
463
+			'ee_read_registrations',
464
+			'espresso_registrations_reports'
465
+		)
466
+		) {
467
+			$items['reports'] = array(
468
+				'class' => 'dashicons dashicons-chart-bar',
469
+				'desc'  => esc_html__('Event Reports', 'event_espresso'),
470
+			);
471
+		}
472
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_global_messages', 'view_filtered_messages')) {
473
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
474
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
475
+				$items['view_related_messages'] = array(
476
+					'class' => $related_for_icon['css_class'],
477
+					'desc'  => $related_for_icon['label'],
478
+				);
479
+			}
480
+		}
481
+		return $items;
482
+	}
483
+
484
+
485
+	/**
486
+	 * This is the callback method for the duplicate event route
487
+	 * Method looks for 'EVT_ID' in the request and retrieves that event and its details and duplicates them
488
+	 * into a new event.  We add a hook so that any plugins that add extra event details can hook into this
489
+	 * action.  Note that the dupe will have **DUPLICATE** as its title and slug.
490
+	 * After duplication the redirect is to the new event edit page.
491
+	 *
492
+	 * @return void
493
+	 * @access protected
494
+	 * @throws EE_Error If EE_Event is not available with given ID
495
+	 */
496
+	protected function _duplicate_event()
497
+	{
498
+		// first make sure the ID for the event is in the request.
499
+		//  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
500
+		if (! isset($this->_req_data['EVT_ID'])) {
501
+			EE_Error::add_error(
502
+				esc_html__(
503
+					'In order to duplicate an event an Event ID is required.  None was given.',
504
+					'event_espresso'
505
+				),
506
+				__FILE__,
507
+				__FUNCTION__,
508
+				__LINE__
509
+			);
510
+			$this->_redirect_after_action(false, '', '', array(), true);
511
+			return;
512
+		}
513
+		//k we've got EVT_ID so let's use that to get the event we'll duplicate
514
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
515
+		if (! $orig_event instanceof EE_Event) {
516
+			throw new EE_Error(
517
+				sprintf(
518
+					esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
519
+					$this->_req_data['EVT_ID']
520
+				)
521
+			);
522
+		}
523
+		//k now let's clone the $orig_event before getting relations
524
+		$new_event = clone $orig_event;
525
+		//original datetimes
526
+		$orig_datetimes = $orig_event->get_many_related('Datetime');
527
+		//other original relations
528
+		$orig_ven = $orig_event->get_many_related('Venue');
529
+		//reset the ID and modify other details to make it clear this is a dupe
530
+		$new_event->set('EVT_ID', 0);
531
+		$new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
532
+		$new_event->set('EVT_name', $new_name);
533
+		$new_event->set(
534
+			'EVT_slug',
535
+			wp_unique_post_slug(
536
+				sanitize_title($orig_event->name()),
537
+				0,
538
+				'publish',
539
+				'espresso_events',
540
+				0
541
+			)
542
+		);
543
+		$new_event->set('status', 'draft');
544
+		//duplicate discussion settings
545
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
546
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
547
+		//save the new event
548
+		$new_event->save();
549
+		//venues
550
+		foreach ($orig_ven as $ven) {
551
+			$new_event->_add_relation_to($ven, 'Venue');
552
+		}
553
+		$new_event->save();
554
+		//now we need to get the question group relations and handle that
555
+		//first primary question groups
556
+		$orig_primary_qgs = $orig_event->get_many_related(
557
+			'Question_Group',
558
+			array(array('Event_Question_Group.EQG_primary' => 1))
559
+		);
560
+		if (! empty($orig_primary_qgs)) {
561
+			foreach ($orig_primary_qgs as $id => $obj) {
562
+				if ($obj instanceof EE_Question_Group) {
563
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
564
+				}
565
+			}
566
+		}
567
+		//next additional attendee question groups
568
+		$orig_additional_qgs = $orig_event->get_many_related(
569
+			'Question_Group',
570
+			array(array('Event_Question_Group.EQG_primary' => 0))
571
+		);
572
+		if (! empty($orig_additional_qgs)) {
573
+			foreach ($orig_additional_qgs as $id => $obj) {
574
+				if ($obj instanceof EE_Question_Group) {
575
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
576
+				}
577
+			}
578
+		}
579
+		//now save
580
+		$new_event->save();
581
+		//k now that we have the new event saved we can loop through the datetimes and start adding relations.
582
+		$cloned_tickets = array();
583
+		foreach ($orig_datetimes as $orig_dtt) {
584
+			if (! $orig_dtt instanceof EE_Datetime) {
585
+				continue;
586
+			}
587
+			$new_dtt   = clone $orig_dtt;
588
+			$orig_tkts = $orig_dtt->tickets();
589
+			//save new dtt then add to event
590
+			$new_dtt->set('DTT_ID', 0);
591
+			$new_dtt->set('DTT_sold', 0);
592
+			$new_dtt->set_reserved(0);
593
+			$new_dtt->save();
594
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
595
+			$new_event->save();
596
+			//now let's get the ticket relations setup.
597
+			foreach ((array)$orig_tkts as $orig_tkt) {
598
+				//it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
599
+				if (! $orig_tkt instanceof EE_Ticket) {
600
+					continue;
601
+				}
602
+				//is this ticket archived?  If it is then let's skip
603
+				if ($orig_tkt->get('TKT_deleted')) {
604
+					continue;
605
+				}
606
+				// does this original ticket already exist in the clone_tickets cache?
607
+				//  If so we'll just use the new ticket from it.
608
+				if (isset($cloned_tickets[$orig_tkt->ID()])) {
609
+					$new_tkt = $cloned_tickets[$orig_tkt->ID()];
610
+				} else {
611
+					$new_tkt = clone $orig_tkt;
612
+					//get relations on the $orig_tkt that we need to setup.
613
+					$orig_prices = $orig_tkt->prices();
614
+					$new_tkt->set('TKT_ID', 0);
615
+					$new_tkt->set('TKT_sold', 0);
616
+					$new_tkt->set('TKT_reserved', 0);
617
+					$new_tkt->save(); //make sure new ticket has ID.
618
+					//price relations on new ticket need to be setup.
619
+					foreach ($orig_prices as $orig_price) {
620
+						$new_price = clone $orig_price;
621
+						$new_price->set('PRC_ID', 0);
622
+						$new_price->save();
623
+						$new_tkt->_add_relation_to($new_price, 'Price');
624
+						$new_tkt->save();
625
+					}
626
+				}
627
+				// k now we can add the new ticket as a relation to the new datetime
628
+				// and make sure its added to our cached $cloned_tickets array
629
+				// for use with later datetimes that have the same ticket.
630
+				$new_dtt->_add_relation_to($new_tkt, 'Ticket');
631
+				$new_dtt->save();
632
+				$cloned_tickets[$orig_tkt->ID()] = $new_tkt;
633
+			}
634
+		}
635
+		//clone taxonomy information
636
+		$taxonomies_to_clone_with = apply_filters(
637
+			'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone',
638
+			array('espresso_event_categories', 'espresso_event_type', 'post_tag')
639
+		);
640
+		//get terms for original event (notice)
641
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
642
+		//loop through terms and add them to new event.
643
+		foreach ($orig_terms as $term) {
644
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
645
+		}
646
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
647
+		//now let's redirect to the edit page for this duplicated event if we have a new event id.
648
+		if ($new_event->ID()) {
649
+			$redirect_args = array(
650
+				'post'   => $new_event->ID(),
651
+				'action' => 'edit',
652
+			);
653
+			EE_Error::add_success(
654
+				esc_html__(
655
+					'Event successfully duplicated.  Please review the details below and make any necessary edits',
656
+					'event_espresso'
657
+				)
658
+			);
659
+		} else {
660
+			$redirect_args = array(
661
+				'action' => 'default',
662
+			);
663
+			EE_Error::add_error(
664
+				esc_html__('Not able to duplicate event.  Something went wrong.', 'event_espresso'),
665
+				__FILE__,
666
+				__FUNCTION__,
667
+				__LINE__
668
+			);
669
+		}
670
+		$this->_redirect_after_action(false, '', '', $redirect_args, true);
671
+	}
672
+
673
+
674
+	/**
675
+	 * Generates output for the import page.
676
+	 * @throws DomainException
677
+	 */
678
+	protected function _import_page()
679
+	{
680
+		$title                                      = esc_html__('Import', 'event_espresso');
681
+		$intro                                      = esc_html__(
682
+			'If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ',
683
+			'event_espresso'
684
+		);
685
+		$form_url                                   = EVENTS_ADMIN_URL;
686
+		$action                                     = 'import_events';
687
+		$type                                       = 'csv';
688
+		$this->_template_args['form']               = EE_Import::instance()->upload_form(
689
+			$title, $intro, $form_url, $action, $type
690
+		);
691
+		$this->_template_args['sample_file_link']   = EE_Admin_Page::add_query_args_and_nonce(
692
+			array('action' => 'sample_export_file'),
693
+			$this->_admin_base_url
694
+		);
695
+		$content                                    = EEH_Template::display_template(
696
+			EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
697
+			$this->_template_args,
698
+			true
699
+		);
700
+		$this->_template_args['admin_page_content'] = $content;
701
+		$this->display_admin_page_with_sidebar();
702
+	}
703
+
704
+
705
+	/**
706
+	 * _import_events
707
+	 * This handles displaying the screen and running imports for importing events.
708
+	 *
709
+	 * @return void
710
+	 */
711
+	protected function _import_events()
712
+	{
713
+		require_once(EE_CLASSES . 'EE_Import.class.php');
714
+		$success = EE_Import::instance()->import();
715
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
716
+	}
717
+
718
+
719
+	/**
720
+	 * _events_export
721
+	 * Will export all (or just the given event) to a Excel compatible file.
722
+	 *
723
+	 * @access protected
724
+	 * @return void
725
+	 */
726
+	protected function _events_export()
727
+	{
728
+		if (isset($this->_req_data['EVT_ID'])) {
729
+			$event_ids = $this->_req_data['EVT_ID'];
730
+		} elseif (isset($this->_req_data['EVT_IDs'])) {
731
+			$event_ids = $this->_req_data['EVT_IDs'];
732
+		} else {
733
+			$event_ids = null;
734
+		}
735
+		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
736
+		$new_request_args = array(
737
+			'export' => 'report',
738
+			'action' => 'all_event_data',
739
+			'EVT_ID' => $event_ids,
740
+		);
741
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
742
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
743
+			require_once(EE_CLASSES . 'EE_Export.class.php');
744
+			$EE_Export = EE_Export::instance($this->_req_data);
745
+			$EE_Export->export();
746
+		}
747
+	}
748
+
749
+
750
+	/**
751
+	 * handle category exports()
752
+	 *
753
+	 * @return void
754
+	 */
755
+	protected function _categories_export()
756
+	{
757
+		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
758
+		$new_request_args = array(
759
+			'export'       => 'report',
760
+			'action'       => 'categories',
761
+			'category_ids' => $this->_req_data['EVT_CAT_ID'],
762
+		);
763
+		$this->_req_data  = array_merge($this->_req_data, $new_request_args);
764
+		if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
765
+			require_once(EE_CLASSES . 'EE_Export.class.php');
766
+			$EE_Export = EE_Export::instance($this->_req_data);
767
+			$EE_Export->export();
768
+		}
769
+	}
770
+
771
+
772
+	/**
773
+	 * Creates a sample CSV file for importing
774
+	 */
775
+	protected function _sample_export_file()
776
+	{
777
+		//		require_once(EE_CLASSES . 'EE_Export.class.php');
778
+		EE_Export::instance()->export_sample();
779
+	}
780
+
781
+
782
+	/*************        Template Settings        *************/
783
+	/**
784
+	 * Generates template settings page output
785
+	 * @throws DomainException
786
+	 * @throws EE_Error
787
+	 */
788
+	protected function _template_settings()
789
+	{
790
+		$this->_template_args['values'] = $this->_yes_no_values;
791
+		/**
792
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
793
+		 * from General_Settings_Admin_Page to here.
794
+		 */
795
+		$this->_template_args = apply_filters(
796
+			'FHEE__General_Settings_Admin_Page__template_settings__template_args',
797
+			$this->_template_args
798
+		);
799
+		$this->_set_add_edit_form_tags('update_template_settings');
800
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
801
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
802
+			EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
803
+			$this->_template_args,
804
+			true
805
+		);
806
+		$this->display_admin_page_with_sidebar();
807
+	}
808
+
809
+
810
+	/**
811
+	 * Handler for updating template settings.
812
+	 */
813
+	protected function _update_template_settings()
814
+	{
815
+		/**
816
+		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
817
+		 * from General_Settings_Admin_Page to here.
818
+		 */
819
+		EE_Registry::instance()->CFG->template_settings = apply_filters(
820
+			'FHEE__General_Settings_Admin_Page__update_template_settings__data',
821
+			EE_Registry::instance()->CFG->template_settings,
822
+			$this->_req_data
823
+		);
824
+		//update custom post type slugs and detect if we need to flush rewrite rules
825
+		$old_slug                                          = EE_Registry::instance()->CFG->core->event_cpt_slug;
826
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug'])
827
+			? EE_Registry::instance()->CFG->core->event_cpt_slug
828
+			: sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
829
+		$what                                              = 'Template Settings';
830
+		$success                                           = $this->_update_espresso_configuration(
831
+			$what,
832
+			EE_Registry::instance()->CFG->template_settings,
833
+			__FILE__,
834
+			__FUNCTION__,
835
+			__LINE__
836
+		);
837
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
838
+			update_option('ee_flush_rewrite_rules', true);
839
+		}
840
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
841
+	}
842
+
843
+
844
+	/**
845
+	 * _premium_event_editor_meta_boxes
846
+	 * add all metaboxes related to the event_editor
847
+	 *
848
+	 * @access protected
849
+	 * @return void
850
+	 * @throws EE_Error
851
+	 */
852
+	protected function _premium_event_editor_meta_boxes()
853
+	{
854
+		$this->verify_cpt_object();
855
+		add_meta_box(
856
+			'espresso_event_editor_event_options',
857
+			esc_html__('Event Registration Options', 'event_espresso'),
858
+			array($this, 'registration_options_meta_box'),
859
+			$this->page_slug,
860
+			'side',
861
+			'core'
862
+		);
863
+	}
864
+
865
+
866
+	/**
867
+	 * override caf metabox
868
+	 *
869
+	 * @return void
870
+	 * @throws DomainException
871
+	 */
872
+	public function registration_options_meta_box()
873
+	{
874
+		$yes_no_values                                    = array(
875
+			array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
876
+			array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
877
+		);
878
+		$default_reg_status_values                        = EEM_Registration::reg_status_array(
879
+			array(
880
+				EEM_Registration::status_id_cancelled,
881
+				EEM_Registration::status_id_declined,
882
+				EEM_Registration::status_id_incomplete,
883
+				EEM_Registration::status_id_wait_list,
884
+			),
885
+			true
886
+		);
887
+		$template_args['active_status']                   = $this->_cpt_model_obj->pretty_active_status(false);
888
+		$template_args['_event']                          = $this->_cpt_model_obj;
889
+		$template_args['additional_limit']                = $this->_cpt_model_obj->additional_limit();
890
+		$template_args['default_registration_status']     = EEH_Form_Fields::select_input(
891
+			'default_reg_status',
892
+			$default_reg_status_values,
893
+			$this->_cpt_model_obj->default_registration_status()
894
+		);
895
+		$template_args['display_description']             = EEH_Form_Fields::select_input(
896
+			'display_desc',
897
+			$yes_no_values,
898
+			$this->_cpt_model_obj->display_description()
899
+		);
900
+		$template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
901
+			'display_ticket_selector',
902
+			$yes_no_values,
903
+			$this->_cpt_model_obj->display_ticket_selector(),
904
+			'',
905
+			'',
906
+			false
907
+		);
908
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input(
909
+			'EVT_default_registration_status',
910
+			$default_reg_status_values,
911
+			$this->_cpt_model_obj->default_registration_status()
912
+		);
913
+		$template_args['additional_registration_options'] = apply_filters(
914
+			'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options',
915
+			'',
916
+			$template_args,
917
+			$yes_no_values,
918
+			$default_reg_status_values
919
+		);
920
+		EEH_Template::display_template(
921
+			EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
922
+			$template_args
923
+		);
924
+	}
925
+
926
+
927
+
928
+	/**
929
+	 * wp_list_table_mods for caf
930
+	 * ============================
931
+	 */
932
+	/**
933
+	 * hook into list table filters and provide filters for caffeinated list table
934
+	 *
935
+	 * @param  array $old_filters    any existing filters present
936
+	 * @param  array $list_table_obj the list table object
937
+	 * @return array                  new filters
938
+	 */
939
+	public function list_table_filters($old_filters, $list_table_obj)
940
+	{
941
+		$filters = array();
942
+		//first month/year filters
943
+		$filters[] = $this->espresso_event_months_dropdown();
944
+		$status    = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
945
+		//active status dropdown
946
+		if ($status !== 'draft') {
947
+			$filters[] = $this->active_status_dropdown(
948
+				isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : ''
949
+			);
950
+		}
951
+		//category filter
952
+		$filters[] = $this->category_dropdown();
953
+		return array_merge($old_filters, $filters);
954
+	}
955
+
956
+
957
+	/**
958
+	 * espresso_event_months_dropdown
959
+	 *
960
+	 * @access public
961
+	 * @return string                dropdown listing month/year selections for events.
962
+	 */
963
+	public function espresso_event_months_dropdown()
964
+	{
965
+		// what we need to do is get all PRIMARY datetimes for all events to filter on.
966
+		// Note we need to include any other filters that are set!
967
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null;
968
+		//categories?
969
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0
970
+			? $this->_req_data['EVT_CAT']
971
+			: null;
972
+		//active status?
973
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : null;
974
+		$cur_date      = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
975
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
976
+	}
977
+
978
+
979
+	/**
980
+	 * returns a list of "active" statuses on the event
981
+	 *
982
+	 * @param  string $current_value whatever the current active status is
983
+	 * @return string
984
+	 */
985
+	public function active_status_dropdown($current_value = '')
986
+	{
987
+		$select_name = 'active_status';
988
+		$values      = array(
989
+			'none'     => esc_html__('Show Active/Inactive', 'event_espresso'),
990
+			'active'   => esc_html__('Active', 'event_espresso'),
991
+			'upcoming' => esc_html__('Upcoming', 'event_espresso'),
992
+			'expired'  => esc_html__('Expired', 'event_espresso'),
993
+			'inactive' => esc_html__('Inactive', 'event_espresso'),
994
+		);
995
+		$id          = 'id="espresso-active-status-dropdown-filter"';
996
+		$class       = 'wide';
997
+		return EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
998
+	}
999
+
1000
+
1001
+	/**
1002
+	 * output a dropdown of the categories for the category filter on the event admin list table
1003
+	 *
1004
+	 * @access  public
1005
+	 * @return string html
1006
+	 */
1007
+	public function category_dropdown()
1008
+	{
1009
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
1010
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
1011
+	}
1012
+
1013
+
1014
+	/**
1015
+	 * get total number of events today
1016
+	 *
1017
+	 * @access public
1018
+	 * @return int
1019
+	 * @throws EE_Error
1020
+	 */
1021
+	public function total_events_today()
1022
+	{
1023
+		$start = EEM_Datetime::instance()->convert_datetime_for_query(
1024
+			'DTT_EVT_start',
1025
+			date('Y-m-d') . ' 00:00:00',
1026
+			'Y-m-d H:i:s',
1027
+			'UTC'
1028
+		);
1029
+		$end   = EEM_Datetime::instance()->convert_datetime_for_query(
1030
+			'DTT_EVT_start',
1031
+			date('Y-m-d') . ' 23:59:59',
1032
+			'Y-m-d H:i:s',
1033
+			'UTC'
1034
+		);
1035
+		$where = array(
1036
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1037
+		);
1038
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1039
+		return $count;
1040
+	}
1041
+
1042
+
1043
+	/**
1044
+	 * get total number of events this month
1045
+	 *
1046
+	 * @access public
1047
+	 * @return int
1048
+	 * @throws EE_Error
1049
+	 */
1050
+	public function total_events_this_month()
1051
+	{
1052
+		//Dates
1053
+		$this_year_r     = date('Y');
1054
+		$this_month_r    = date('m');
1055
+		$days_this_month = date('t');
1056
+		$start           = EEM_Datetime::instance()->convert_datetime_for_query(
1057
+			'DTT_EVT_start',
1058
+			$this_year_r . '-' . $this_month_r . '-01 00:00:00',
1059
+			'Y-m-d H:i:s',
1060
+			'UTC'
1061
+		);
1062
+		$end             = EEM_Datetime::instance()->convert_datetime_for_query(
1063
+			'DTT_EVT_start',
1064
+			$this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1065
+			'Y-m-d H:i:s',
1066
+			'UTC'
1067
+		);
1068
+		$where           = array(
1069
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end)),
1070
+		);
1071
+		$count           = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1072
+		return $count;
1073
+	}
1074
+
1075
+
1076
+	/** DEFAULT TICKETS STUFF **/
1077
+
1078
+	/**
1079
+	 * Output default tickets list table view.
1080
+	 */
1081
+	public function _tickets_overview_list_table()
1082
+	{
1083
+		$this->_search_btn_label = esc_html__('Tickets', 'event_espresso');
1084
+		$this->display_admin_list_table_page_with_no_sidebar();
1085
+	}
1086
+
1087
+
1088
+	/**
1089
+	 * @param int  $per_page
1090
+	 * @param bool $count
1091
+	 * @param bool $trashed
1092
+	 * @return \EE_Soft_Delete_Base_Class[]|int
1093
+	 */
1094
+	public function get_default_tickets($per_page = 10, $count = false, $trashed = false)
1095
+	{
1096
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1097
+		$order   = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1098
+		switch ($orderby) {
1099
+			case 'TKT_name':
1100
+				$orderby = array('TKT_name' => $order);
1101
+				break;
1102
+			case 'TKT_price':
1103
+				$orderby = array('TKT_price' => $order);
1104
+				break;
1105
+			case 'TKT_uses':
1106
+				$orderby = array('TKT_uses' => $order);
1107
+				break;
1108
+			case 'TKT_min':
1109
+				$orderby = array('TKT_min' => $order);
1110
+				break;
1111
+			case 'TKT_max':
1112
+				$orderby = array('TKT_max' => $order);
1113
+				break;
1114
+			case 'TKT_qty':
1115
+				$orderby = array('TKT_qty' => $order);
1116
+				break;
1117
+		}
1118
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1119
+			? $this->_req_data['paged']
1120
+			: 1;
1121
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1122
+			? $this->_req_data['perpage']
1123
+			: $per_page;
1124
+		$_where       = array(
1125
+			'TKT_is_default' => 1,
1126
+			'TKT_deleted'    => $trashed,
1127
+		);
1128
+		$offset       = ($current_page - 1) * $per_page;
1129
+		$limit        = array($offset, $per_page);
1130
+		if (isset($this->_req_data['s'])) {
1131
+			$sstr         = '%' . $this->_req_data['s'] . '%';
1132
+			$_where['OR'] = array(
1133
+				'TKT_name'        => array('LIKE', $sstr),
1134
+				'TKT_description' => array('LIKE', $sstr),
1135
+			);
1136
+		}
1137
+		$query_params = array(
1138
+			$_where,
1139
+			'order_by' => $orderby,
1140
+			'limit'    => $limit,
1141
+			'group_by' => 'TKT_ID',
1142
+		);
1143
+		if ($count) {
1144
+			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1145
+		} else {
1146
+			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1147
+		}
1148
+	}
1149
+
1150
+
1151
+	/**
1152
+	 * @param bool $trash
1153
+	 * @throws EE_Error
1154
+	 */
1155
+	protected function _trash_or_restore_ticket($trash = false)
1156
+	{
1157
+		$success = 1;
1158
+		$TKT     = EEM_Ticket::instance();
1159
+		//checkboxes?
1160
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1161
+			//if array has more than one element then success message should be plural
1162
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1163
+			//cycle thru the boxes
1164
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1165
+				if ($trash) {
1166
+					if (! $TKT->delete_by_ID($TKT_ID)) {
1167
+						$success = 0;
1168
+					}
1169
+				} else {
1170
+					if (! $TKT->restore_by_ID($TKT_ID)) {
1171
+						$success = 0;
1172
+					}
1173
+				}
1174
+			}
1175
+		} else {
1176
+			//grab single id and trash
1177
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1178
+			if ($trash) {
1179
+				if (! $TKT->delete_by_ID($TKT_ID)) {
1180
+					$success = 0;
1181
+				}
1182
+			} else {
1183
+				if (! $TKT->restore_by_ID($TKT_ID)) {
1184
+					$success = 0;
1185
+				}
1186
+			}
1187
+		}
1188
+		$action_desc = $trash ? 'moved to the trash' : 'restored';
1189
+		$query_args  = array(
1190
+			'action' => 'ticket_list_table',
1191
+			'status' => $trash ? '' : 'trashed',
1192
+		);
1193
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1194
+	}
1195
+
1196
+
1197
+	/**
1198
+	 * Handles trashing default ticket.
1199
+	 */
1200
+	protected function _delete_ticket()
1201
+	{
1202
+		$success = 1;
1203
+		//checkboxes?
1204
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1205
+			//if array has more than one element then success message should be plural
1206
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1207
+			//cycle thru the boxes
1208
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1209
+				//delete
1210
+				if (! $this->_delete_the_ticket($TKT_ID)) {
1211
+					$success = 0;
1212
+				}
1213
+			}
1214
+		} else {
1215
+			//grab single id and trash
1216
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1217
+			if (! $this->_delete_the_ticket($TKT_ID)) {
1218
+				$success = 0;
1219
+			}
1220
+		}
1221
+		$action_desc = 'deleted';
1222
+		$query_args  = array(
1223
+			'action' => 'ticket_list_table',
1224
+			'status' => 'trashed',
1225
+		);
1226
+		//fail safe.  If the default ticket count === 1 then we need to redirect to event overview.
1227
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(
1228
+			array(array('TKT_is_default' => 1)),
1229
+			'TKT_ID',
1230
+			true
1231
+		)
1232
+		) {
1233
+			$query_args = array();
1234
+		}
1235
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1236
+	}
1237
+
1238
+
1239
+	/**
1240
+	 * @param int $TKT_ID
1241
+	 * @return bool|int
1242
+	 * @throws EE_Error
1243
+	 */
1244
+	protected function _delete_the_ticket($TKT_ID)
1245
+	{
1246
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1247
+		$tkt->_remove_relations('Datetime');
1248
+		//delete all related prices first
1249
+		$tkt->delete_related_permanently('Price');
1250
+		return $tkt->delete_permanently();
1251
+	}
1252 1252
 }
Please login to merge, or discard this patch.
Spacing   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
     public function __construct($routing = true)
23 23
     {
24 24
         parent::__construct($routing);
25
-        if (! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
-            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
27
-            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
28
-            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
25
+        if ( ! defined('EVENTS_CAF_TEMPLATE_PATH')) {
26
+            define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
27
+            define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
28
+            define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
29 29
         }
30 30
     }
31 31
 
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
      */
36 36
     protected function _extend_page_config()
37 37
     {
38
-        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
38
+        $this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
39 39
         //is there a evt_id in the request?
40 40
         $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID'])
41 41
             ? $this->_req_data['EVT_ID']
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
             'help_tour'     => array('Templates_Help_Tour'),
169 169
             'require_nonce' => false,
170 170
         );
171
-        $this->_page_config                   = array_merge($this->_page_config, $new_page_config);
171
+        $this->_page_config = array_merge($this->_page_config, $new_page_config);
172 172
         //add filters and actions
173 173
         //modifying _views
174 174
         add_filter(
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
          * check whether count of tickets is approaching the potential
242 242
          * limits for the server.
243 243
          */
244
-        if (! empty($data['input_count'])) {
244
+        if ( ! empty($data['input_count'])) {
245 245
             $response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check(
246 246
                 $data['input_count']
247 247
             );
@@ -270,12 +270,12 @@  discard block
 block discarded – undo
270 270
     {
271 271
         $return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
272 272
         //make sure this is only when editing
273
-        if (! empty($id)) {
274
-            $href   = EE_Admin_Page::add_query_args_and_nonce(
273
+        if ( ! empty($id)) {
274
+            $href = EE_Admin_Page::add_query_args_and_nonce(
275 275
                 array('action' => 'duplicate_event', 'EVT_ID' => $id),
276 276
                 $this->_admin_base_url
277 277
             );
278
-            $title  = esc_attr__('Duplicate Event', 'event_espresso');
278
+            $title = esc_attr__('Duplicate Event', 'event_espresso');
279 279
             $return .= '<a href="'
280 280
                        . $href
281 281
                        . '" title="'
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
     {
323 323
         wp_register_script(
324 324
             'ee-event-editor-heartbeat',
325
-            EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js',
325
+            EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js',
326 326
             array('ee_admin_js', 'heartbeat'),
327 327
             EVENT_ESPRESSO_VERSION,
328 328
             true
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
     public function add_additional_datetime_button($template, $template_args)
346 346
     {
347 347
         return EEH_Template::display_template(
348
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php',
348
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php',
349 349
             $template_args,
350 350
             true
351 351
         );
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
     public function add_datetime_clone_button($template, $template_args)
363 363
     {
364 364
         return EEH_Template::display_template(
365
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php',
365
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php',
366 366
             $template_args,
367 367
             true
368 368
         );
@@ -379,7 +379,7 @@  discard block
 block discarded – undo
379 379
     public function datetime_timezones_template($template, $template_args)
380 380
     {
381 381
         return EEH_Template::display_template(
382
-            EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php',
382
+            EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php',
383 383
             $template_args,
384 384
             true
385 385
         );
@@ -392,7 +392,7 @@  discard block
 block discarded – undo
392 392
     protected function _set_list_table_views_default()
393 393
     {
394 394
         parent::_set_list_table_views_default();
395
-        $new_views    = array(
395
+        $new_views = array(
396 396
             'today' => array(
397 397
                 'slug'        => 'today',
398 398
                 'label'       => esc_html__('Today', 'event_espresso'),
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
     {
498 498
         // first make sure the ID for the event is in the request.
499 499
         //  If it isn't then we need to bail and redirect back to overview list table (cause how did we get here?)
500
-        if (! isset($this->_req_data['EVT_ID'])) {
500
+        if ( ! isset($this->_req_data['EVT_ID'])) {
501 501
             EE_Error::add_error(
502 502
                 esc_html__(
503 503
                     'In order to duplicate an event an Event ID is required.  None was given.',
@@ -512,7 +512,7 @@  discard block
 block discarded – undo
512 512
         }
513 513
         //k we've got EVT_ID so let's use that to get the event we'll duplicate
514 514
         $orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
515
-        if (! $orig_event instanceof EE_Event) {
515
+        if ( ! $orig_event instanceof EE_Event) {
516 516
             throw new EE_Error(
517 517
                 sprintf(
518 518
                     esc_html__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso'),
@@ -528,7 +528,7 @@  discard block
 block discarded – undo
528 528
         $orig_ven = $orig_event->get_many_related('Venue');
529 529
         //reset the ID and modify other details to make it clear this is a dupe
530 530
         $new_event->set('EVT_ID', 0);
531
-        $new_name = $new_event->name() . ' ' . esc_html__('**DUPLICATE**', 'event_espresso');
531
+        $new_name = $new_event->name().' '.esc_html__('**DUPLICATE**', 'event_espresso');
532 532
         $new_event->set('EVT_name', $new_name);
533 533
         $new_event->set(
534 534
             'EVT_slug',
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
             'Question_Group',
558 558
             array(array('Event_Question_Group.EQG_primary' => 1))
559 559
         );
560
-        if (! empty($orig_primary_qgs)) {
560
+        if ( ! empty($orig_primary_qgs)) {
561 561
             foreach ($orig_primary_qgs as $id => $obj) {
562 562
                 if ($obj instanceof EE_Question_Group) {
563 563
                     $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
@@ -569,7 +569,7 @@  discard block
 block discarded – undo
569 569
             'Question_Group',
570 570
             array(array('Event_Question_Group.EQG_primary' => 0))
571 571
         );
572
-        if (! empty($orig_additional_qgs)) {
572
+        if ( ! empty($orig_additional_qgs)) {
573 573
             foreach ($orig_additional_qgs as $id => $obj) {
574 574
                 if ($obj instanceof EE_Question_Group) {
575 575
                     $new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
@@ -581,7 +581,7 @@  discard block
 block discarded – undo
581 581
         //k now that we have the new event saved we can loop through the datetimes and start adding relations.
582 582
         $cloned_tickets = array();
583 583
         foreach ($orig_datetimes as $orig_dtt) {
584
-            if (! $orig_dtt instanceof EE_Datetime) {
584
+            if ( ! $orig_dtt instanceof EE_Datetime) {
585 585
                 continue;
586 586
             }
587 587
             $new_dtt   = clone $orig_dtt;
@@ -594,9 +594,9 @@  discard block
 block discarded – undo
594 594
             $new_event->_add_relation_to($new_dtt, 'Datetime');
595 595
             $new_event->save();
596 596
             //now let's get the ticket relations setup.
597
-            foreach ((array)$orig_tkts as $orig_tkt) {
597
+            foreach ((array) $orig_tkts as $orig_tkt) {
598 598
                 //it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
599
-                if (! $orig_tkt instanceof EE_Ticket) {
599
+                if ( ! $orig_tkt instanceof EE_Ticket) {
600 600
                     continue;
601 601
                 }
602 602
                 //is this ticket archived?  If it is then let's skip
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
             array('action' => 'sample_export_file'),
693 693
             $this->_admin_base_url
694 694
         );
695
-        $content                                    = EEH_Template::display_template(
696
-            EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',
695
+        $content = EEH_Template::display_template(
696
+            EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php',
697 697
             $this->_template_args,
698 698
             true
699 699
         );
@@ -710,7 +710,7 @@  discard block
 block discarded – undo
710 710
      */
711 711
     protected function _import_events()
712 712
     {
713
-        require_once(EE_CLASSES . 'EE_Import.class.php');
713
+        require_once(EE_CLASSES.'EE_Import.class.php');
714 714
         $success = EE_Import::instance()->import();
715 715
         $this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
716 716
     }
@@ -738,9 +738,9 @@  discard block
 block discarded – undo
738 738
             'action' => 'all_event_data',
739 739
             'EVT_ID' => $event_ids,
740 740
         );
741
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
742
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
743
-            require_once(EE_CLASSES . 'EE_Export.class.php');
741
+        $this->_req_data = array_merge($this->_req_data, $new_request_args);
742
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
743
+            require_once(EE_CLASSES.'EE_Export.class.php');
744 744
             $EE_Export = EE_Export::instance($this->_req_data);
745 745
             $EE_Export->export();
746 746
         }
@@ -760,9 +760,9 @@  discard block
 block discarded – undo
760 760
             'action'       => 'categories',
761 761
             'category_ids' => $this->_req_data['EVT_CAT_ID'],
762 762
         );
763
-        $this->_req_data  = array_merge($this->_req_data, $new_request_args);
764
-        if (is_readable(EE_CLASSES . 'EE_Export.class.php')) {
765
-            require_once(EE_CLASSES . 'EE_Export.class.php');
763
+        $this->_req_data = array_merge($this->_req_data, $new_request_args);
764
+        if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
765
+            require_once(EE_CLASSES.'EE_Export.class.php');
766 766
             $EE_Export = EE_Export::instance($this->_req_data);
767 767
             $EE_Export->export();
768 768
         }
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
         $this->_set_add_edit_form_tags('update_template_settings');
800 800
         $this->_set_publish_post_box_vars(null, false, false, null, false);
801 801
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
802
-            EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php',
802
+            EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php',
803 803
             $this->_template_args,
804 804
             true
805 805
         );
@@ -871,11 +871,11 @@  discard block
 block discarded – undo
871 871
      */
872 872
     public function registration_options_meta_box()
873 873
     {
874
-        $yes_no_values                                    = array(
874
+        $yes_no_values = array(
875 875
             array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')),
876 876
             array('id' => false, 'text' => esc_html__('No', 'event_espresso')),
877 877
         );
878
-        $default_reg_status_values                        = EEM_Registration::reg_status_array(
878
+        $default_reg_status_values = EEM_Registration::reg_status_array(
879 879
             array(
880 880
                 EEM_Registration::status_id_cancelled,
881 881
                 EEM_Registration::status_id_declined,
@@ -892,12 +892,12 @@  discard block
 block discarded – undo
892 892
             $default_reg_status_values,
893 893
             $this->_cpt_model_obj->default_registration_status()
894 894
         );
895
-        $template_args['display_description']             = EEH_Form_Fields::select_input(
895
+        $template_args['display_description'] = EEH_Form_Fields::select_input(
896 896
             'display_desc',
897 897
             $yes_no_values,
898 898
             $this->_cpt_model_obj->display_description()
899 899
         );
900
-        $template_args['display_ticket_selector']         = EEH_Form_Fields::select_input(
900
+        $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input(
901 901
             'display_ticket_selector',
902 902
             $yes_no_values,
903 903
             $this->_cpt_model_obj->display_ticket_selector(),
@@ -918,7 +918,7 @@  discard block
 block discarded – undo
918 918
             $default_reg_status_values
919 919
         );
920 920
         EEH_Template::display_template(
921
-            EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php',
921
+            EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php',
922 922
             $template_args
923 923
         );
924 924
     }
@@ -1022,13 +1022,13 @@  discard block
 block discarded – undo
1022 1022
     {
1023 1023
         $start = EEM_Datetime::instance()->convert_datetime_for_query(
1024 1024
             'DTT_EVT_start',
1025
-            date('Y-m-d') . ' 00:00:00',
1025
+            date('Y-m-d').' 00:00:00',
1026 1026
             'Y-m-d H:i:s',
1027 1027
             'UTC'
1028 1028
         );
1029
-        $end   = EEM_Datetime::instance()->convert_datetime_for_query(
1029
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1030 1030
             'DTT_EVT_start',
1031
-            date('Y-m-d') . ' 23:59:59',
1031
+            date('Y-m-d').' 23:59:59',
1032 1032
             'Y-m-d H:i:s',
1033 1033
             'UTC'
1034 1034
         );
@@ -1055,13 +1055,13 @@  discard block
 block discarded – undo
1055 1055
         $days_this_month = date('t');
1056 1056
         $start           = EEM_Datetime::instance()->convert_datetime_for_query(
1057 1057
             'DTT_EVT_start',
1058
-            $this_year_r . '-' . $this_month_r . '-01 00:00:00',
1058
+            $this_year_r.'-'.$this_month_r.'-01 00:00:00',
1059 1059
             'Y-m-d H:i:s',
1060 1060
             'UTC'
1061 1061
         );
1062
-        $end             = EEM_Datetime::instance()->convert_datetime_for_query(
1062
+        $end = EEM_Datetime::instance()->convert_datetime_for_query(
1063 1063
             'DTT_EVT_start',
1064
-            $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59',
1064
+            $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59',
1065 1065
             'Y-m-d H:i:s',
1066 1066
             'UTC'
1067 1067
         );
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
         $offset       = ($current_page - 1) * $per_page;
1129 1129
         $limit        = array($offset, $per_page);
1130 1130
         if (isset($this->_req_data['s'])) {
1131
-            $sstr         = '%' . $this->_req_data['s'] . '%';
1131
+            $sstr         = '%'.$this->_req_data['s'].'%';
1132 1132
             $_where['OR'] = array(
1133 1133
                 'TKT_name'        => array('LIKE', $sstr),
1134 1134
                 'TKT_description' => array('LIKE', $sstr),
@@ -1157,17 +1157,17 @@  discard block
 block discarded – undo
1157 1157
         $success = 1;
1158 1158
         $TKT     = EEM_Ticket::instance();
1159 1159
         //checkboxes?
1160
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1160
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1161 1161
             //if array has more than one element then success message should be plural
1162 1162
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1163 1163
             //cycle thru the boxes
1164 1164
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1165 1165
                 if ($trash) {
1166
-                    if (! $TKT->delete_by_ID($TKT_ID)) {
1166
+                    if ( ! $TKT->delete_by_ID($TKT_ID)) {
1167 1167
                         $success = 0;
1168 1168
                     }
1169 1169
                 } else {
1170
-                    if (! $TKT->restore_by_ID($TKT_ID)) {
1170
+                    if ( ! $TKT->restore_by_ID($TKT_ID)) {
1171 1171
                         $success = 0;
1172 1172
                     }
1173 1173
                 }
@@ -1176,11 +1176,11 @@  discard block
 block discarded – undo
1176 1176
             //grab single id and trash
1177 1177
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1178 1178
             if ($trash) {
1179
-                if (! $TKT->delete_by_ID($TKT_ID)) {
1179
+                if ( ! $TKT->delete_by_ID($TKT_ID)) {
1180 1180
                     $success = 0;
1181 1181
                 }
1182 1182
             } else {
1183
-                if (! $TKT->restore_by_ID($TKT_ID)) {
1183
+                if ( ! $TKT->restore_by_ID($TKT_ID)) {
1184 1184
                     $success = 0;
1185 1185
                 }
1186 1186
             }
@@ -1201,20 +1201,20 @@  discard block
 block discarded – undo
1201 1201
     {
1202 1202
         $success = 1;
1203 1203
         //checkboxes?
1204
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1204
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1205 1205
             //if array has more than one element then success message should be plural
1206 1206
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1207 1207
             //cycle thru the boxes
1208 1208
             while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1209 1209
                 //delete
1210
-                if (! $this->_delete_the_ticket($TKT_ID)) {
1210
+                if ( ! $this->_delete_the_ticket($TKT_ID)) {
1211 1211
                     $success = 0;
1212 1212
                 }
1213 1213
             }
1214 1214
         } else {
1215 1215
             //grab single id and trash
1216 1216
             $TKT_ID = absint($this->_req_data['TKT_ID']);
1217
-            if (! $this->_delete_the_ticket($TKT_ID)) {
1217
+            if ( ! $this->_delete_the_ticket($TKT_ID)) {
1218 1218
                 $success = 0;
1219 1219
             }
1220 1220
         }
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 3 patches
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -748,7 +748,7 @@  discard block
 block discarded – undo
748 748
      *
749 749
      * @access    public
750 750
      * @param    string $CNT_ISO
751
-     * @return mixed string | array
751
+     * @return string|null string | array
752 752
      * @throws DomainException
753 753
      */
754 754
     public function display_country_settings($CNT_ISO = '')
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
      *        delete_state
1065 1065
      *
1066 1066
      * @access    public
1067
-     * @return        boolean
1067
+     * @return        false|null
1068 1068
      */
1069 1069
     public function delete_state()
1070 1070
     {
Please login to merge, or discard this patch.
Indentation   +1371 added lines, -1371 removed lines patch added patch discarded remove patch
@@ -17,1386 +17,1386 @@
 block discarded – undo
17 17
 {
18 18
 
19 19
 
20
-    /**
21
-     * _question_group
22
-     * holds the specific question group object for the question group details screen
23
-     *
24
-     * @var object
25
-     */
26
-    protected $_question_group;
27
-
28
-
29
-    /**
30
-     * Initialize basic properties.
31
-     */
32
-    protected function _init_page_props()
33
-    {
34
-        $this->page_slug        = GEN_SET_PG_SLUG;
35
-        $this->page_label       = GEN_SET_LABEL;
36
-        $this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
-        $this->_admin_base_path = GEN_SET_ADMIN;
38
-    }
39
-
40
-
41
-    /**
42
-     * Set ajax hooks
43
-     */
44
-    protected function _ajax_hooks()
45
-    {
46
-        add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
47
-        add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
48
-        add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
49
-        add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
50
-    }
51
-
52
-
53
-    /**
54
-     * More page properties initialization.
55
-     */
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = GEN_SET_LABEL;
59
-        $this->_labels           = array(
60
-            'publishbox' => __('Update Settings', 'event_espresso'),
61
-        );
62
-    }
63
-
64
-
65
-    /**
66
-     * Set page routes property.
67
-     */
68
-    protected function _set_page_routes()
69
-    {
70
-        $this->_page_routes = array(
71
-
72
-            'critical_pages'                => array(
73
-                'func'       => '_espresso_page_settings',
74
-                'capability' => 'manage_options',
75
-            ),
76
-            'update_espresso_page_settings' => array(
77
-                'func'       => '_update_espresso_page_settings',
78
-                'capability' => 'manage_options',
79
-                'noheader'   => true,
80
-            ),
81
-            'default'                       => array(
82
-                'func'       => '_your_organization_settings',
83
-                'capability' => 'manage_options',
84
-            ),
85
-
86
-            'update_your_organization_settings' => array(
87
-                'func'       => '_update_your_organization_settings',
88
-                'capability' => 'manage_options',
89
-                'noheader'   => true,
90
-            ),
91
-
92
-            'admin_option_settings' => array(
93
-                'func'       => '_admin_option_settings',
94
-                'capability' => 'manage_options',
95
-            ),
96
-
97
-            'update_admin_option_settings' => array(
98
-                'func'       => '_update_admin_option_settings',
99
-                'capability' => 'manage_options',
100
-                'noheader'   => true,
101
-            ),
102
-
103
-            'country_settings' => array(
104
-                'func'       => '_country_settings',
105
-                'capability' => 'manage_options',
106
-            ),
107
-
108
-            'update_country_settings' => array(
109
-                'func'       => '_update_country_settings',
110
-                'capability' => 'manage_options',
111
-                'noheader'   => true,
112
-            ),
113
-
114
-            'display_country_settings' => array(
115
-                'func'       => 'display_country_settings',
116
-                'capability' => 'manage_options',
117
-                'noheader'   => true,
118
-            ),
119
-
120
-            'add_new_state' => array(
121
-                'func'       => 'add_new_state',
122
-                'capability' => 'manage_options',
123
-                'noheader'   => true,
124
-            ),
125
-
126
-            'delete_state' => array(
127
-                'func'       => 'delete_state',
128
-                'capability' => 'manage_options',
129
-                'noheader'   => true,
130
-            ),
131
-        );
132
-    }
133
-
134
-
135
-    /**
136
-     * Set page configuration property
137
-     */
138
-    protected function _set_page_config()
139
-    {
140
-        $this->_page_config = array(
141
-            'critical_pages'        => array(
142
-                'nav'           => array(
143
-                    'label' => __('Critical Pages', 'event_espresso'),
144
-                    'order' => 50,
145
-                ),
146
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
147
-                'help_tabs'     => array(
148
-                    'general_settings_critical_pages_help_tab' => array(
149
-                        'title'    => __('Critical Pages', 'event_espresso'),
150
-                        'filename' => 'general_settings_critical_pages',
151
-                    ),
152
-                ),
153
-                'help_tour'     => array('Critical_Pages_Help_Tour'),
154
-                'require_nonce' => false,
155
-            ),
156
-            'default'               => array(
157
-                'nav'           => array(
158
-                    'label' => __('Your Organization', 'event_espresso'),
159
-                    'order' => 20,
160
-                ),
161
-                'help_tabs'     => array(
162
-                    'general_settings_your_organization_help_tab' => array(
163
-                        'title'    => __('Your Organization', 'event_espresso'),
164
-                        'filename' => 'general_settings_your_organization',
165
-                    ),
166
-                ),
167
-                'help_tour'     => array('Your_Organization_Help_Tour'),
168
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
169
-                'require_nonce' => false,
170
-            ),
171
-            'admin_option_settings' => array(
172
-                'nav'           => array(
173
-                    'label' => __('Admin Options', 'event_espresso'),
174
-                    'order' => 60,
175
-                ),
176
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
177
-                'help_tabs'     => array(
178
-                    'general_settings_admin_options_help_tab' => array(
179
-                        'title'    => __('Admin Options', 'event_espresso'),
180
-                        'filename' => 'general_settings_admin_options',
181
-                    ),
182
-                ),
183
-                'help_tour'     => array('Admin_Options_Help_Tour'),
184
-                'require_nonce' => false,
185
-            ),
186
-            'country_settings'      => array(
187
-                'nav'           => array(
188
-                    'label' => __('Countries', 'event_espresso'),
189
-                    'order' => 70,
190
-                ),
191
-                'help_tabs'     => array(
192
-                    'general_settings_countries_help_tab' => array(
193
-                        'title'    => __('Countries', 'event_espresso'),
194
-                        'filename' => 'general_settings_countries',
195
-                    ),
196
-                ),
197
-                'help_tour'     => array('Countries_Help_Tour'),
198
-                'require_nonce' => false,
199
-            ),
200
-        );
201
-    }
202
-
203
-
204
-
205
-    protected function _add_screen_options()
206
-    {
207
-    }
208
-
209
-    protected function _add_feature_pointers()
210
-    {
211
-    }
212
-
213
-
214
-    /**
215
-     * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
216
-     */
217
-    public function load_scripts_styles()
218
-    {
219
-        //styles
220
-        wp_enqueue_style('espresso-ui-theme');
221
-        //scripts
222
-        wp_enqueue_script('ee_admin_js');
223
-    }
224
-
225
-
226
-    /**
227
-     * Execute logic running on `admin_init`
228
-     */
229
-    public function admin_init()
230
-    {
231
-        EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
232
-            '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.',
233
-            'event_espresso'
234
-        );
235
-        EE_Registry::$i18n_js_strings['error_occurred']          = __(
236
-            'An error occurred! Please refresh the page and try again.',
237
-            'event_espresso'
238
-        );
239
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = __(
240
-            'Are you sure you want to delete this State / Province?',
241
-            'event_espresso'
242
-        );
243
-        $protocol                                                = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
244
-        EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
245
-            'admin-ajax.php?page=espresso_general_settings',
246
-            $protocol
247
-        );
248
-    }
249
-
250
-    public function admin_notices()
251
-    {
252
-    }
253
-
254
-    public function admin_footer_scripts()
255
-    {
256
-    }
257
-
258
-
259
-    /**
260
-     * Enqueue scripts and styles for the default route.
261
-     */
262
-    public function load_scripts_styles_default()
263
-    {
264
-        //styles
265
-        wp_enqueue_style('thickbox');
266
-        //scripts
267
-        wp_enqueue_script('media-upload');
268
-        wp_enqueue_script('thickbox');
269
-        wp_register_script(
270
-            'organization_settings',
271
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
272
-            array('jquery', 'media-upload', 'thickbox'),
273
-            EVENT_ESPRESSO_VERSION,
274
-            true
275
-        );
276
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
277
-        wp_enqueue_script('organization_settings');
278
-        wp_enqueue_style('organization-css');
279
-        $confirm_image_delete = array(
280
-            'text' => __(
281
-                'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
282
-                'event_espresso'
283
-            ),
284
-        );
285
-        wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
286
-    }
287
-
288
-
289
-    /**
290
-     * Enqueue scripts and styles for the country settings route.
291
-     */
292
-    public function load_scripts_styles_country_settings()
293
-    {
294
-        //scripts
295
-        wp_register_script(
296
-            'gen_settings_countries',
297
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
298
-            array('ee_admin_js'),
299
-            EVENT_ESPRESSO_VERSION,
300
-            true
301
-        );
302
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
303
-        wp_enqueue_script('gen_settings_countries');
304
-        wp_enqueue_style('organization-css');
305
-    }
306
-
307
-
308
-    /*************        Espresso Pages        *************/
309
-    /**
310
-     * _espresso_page_settings
311
-     *
312
-     * @throws \EE_Error
313
-     */
314
-    protected function _espresso_page_settings()
315
-    {
316
-        // Check to make sure all of the main pages are setup properly,
317
-        // if not create the default pages and display an admin notice
318
-        EEH_Activation::verify_default_pages_exist();
319
-        $this->_transient_garbage_collection();
320
-        $this->_template_args['values']             = $this->_yes_no_values;
321
-        $this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
322
-            ? EE_Registry::instance()->CFG->core->reg_page_id
323
-            : null;
324
-        $this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
325
-            ? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
326
-            : false;
327
-        $this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
328
-            ? EE_Registry::instance()->CFG->core->txn_page_id
329
-            : null;
330
-        $this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
331
-            ? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
332
-            : false;
333
-        $this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
334
-            ? EE_Registry::instance()->CFG->core->thank_you_page_id
335
-            : null;
336
-        $this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
337
-            ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
338
-            : false;
339
-        $this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
340
-            ? EE_Registry::instance()->CFG->core->cancel_page_id
341
-            : null;
342
-        $this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
343
-            ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
344
-            : false;
345
-        $this->_set_add_edit_form_tags('update_espresso_page_settings');
346
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
347
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
348
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
349
-            $this->_template_args,
350
-            true
351
-        );
352
-        $this->display_admin_page_with_sidebar();
353
-    }
354
-
355
-
356
-    /**
357
-     * Handler for updating espresso page settings.
358
-     */
359
-    protected function _update_espresso_page_settings()
360
-    {
361
-        // capture incoming request data && set page IDs
362
-        EE_Registry::instance()->CFG->core->reg_page_id       = isset($this->_req_data['reg_page_id'])
363
-            ? absint($this->_req_data['reg_page_id'])
364
-            : EE_Registry::instance()->CFG->core->reg_page_id;
365
-        EE_Registry::instance()->CFG->core->txn_page_id       = isset($this->_req_data['txn_page_id'])
366
-            ? absint($this->_req_data['txn_page_id'])
367
-            : EE_Registry::instance()->CFG->core->txn_page_id;
368
-        EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
369
-            ? absint($this->_req_data['thank_you_page_id'])
370
-            : EE_Registry::instance()->CFG->core->thank_you_page_id;
371
-        EE_Registry::instance()->CFG->core->cancel_page_id    = isset($this->_req_data['cancel_page_id'])
372
-            ? absint($this->_req_data['cancel_page_id'])
373
-            : EE_Registry::instance()->CFG->core->cancel_page_id;
374
-
375
-        EE_Registry::instance()->CFG->core = apply_filters(
376
-            'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
377
-            EE_Registry::instance()->CFG->core,
378
-            $this->_req_data
379
-        );
380
-        $what                              = __('Critical Pages & Shortcodes', 'event_espresso');
381
-        $this->_redirect_after_action(
382
-            $this->_update_espresso_configuration(
383
-                $what,
384
-                EE_Registry::instance()->CFG->core,
385
-                __FILE__,
386
-                __FUNCTION__,
387
-                __LINE__
388
-            ),
389
-            $what,
390
-            '',
391
-            array(
392
-                'action' => 'critical_pages',
393
-            ),
394
-            true
395
-        );
396
-    }
397
-
398
-
399
-    /*************        Your Organization        *************/
400
-
401
-
402
-    /**
403
-     * Output for the Your Organization settings route.
404
-     * @throws DomainException
405
-     * @throws EE_Error
406
-     */
407
-    protected function _your_organization_settings()
408
-    {
409
-
410
-        $this->_template_args['site_license_key']       = isset(
411
-            EE_Registry::instance()->NET_CFG->core->site_license_key
412
-        )
413
-            ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
414
-            : '';
415
-        $this->_template_args['organization_name']      = isset(EE_Registry::instance()->CFG->organization->name)
416
-            ? EE_Registry::instance()->CFG->organization->get_pretty('name')
417
-            : '';
418
-        $this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1)
419
-            ? EE_Registry::instance()->CFG->organization->get_pretty('address_1')
420
-            : '';
421
-        $this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2)
422
-            ? EE_Registry::instance()->CFG->organization->get_pretty('address_2')
423
-            : '';
424
-        $this->_template_args['organization_city']      = isset(EE_Registry::instance()->CFG->organization->city)
425
-            ? EE_Registry::instance()->CFG->organization->get_pretty('city')
426
-            : '';
427
-        $this->_template_args['organization_zip']       = isset(EE_Registry::instance()->CFG->organization->zip)
428
-            ? EE_Registry::instance()->CFG->organization->get_pretty('zip')
429
-            : '';
430
-        $this->_template_args['organization_email']     = isset(EE_Registry::instance()->CFG->organization->email)
431
-            ? EE_Registry::instance()->CFG->organization->get_pretty('email')
432
-            : '';
433
-        $this->_template_args['organization_phone']     = isset(EE_Registry::instance()->CFG->organization->phone)
434
-            ? EE_Registry::instance()->CFG->organization->get_pretty('phone')
435
-            : '';
436
-        $this->_template_args['organization_vat']       = isset(EE_Registry::instance()->CFG->organization->vat)
437
-            ? EE_Registry::instance()->CFG->organization->get_pretty('vat')
438
-            : '';
439
-        $this->_template_args['currency_sign']          = isset(EE_Registry::instance()->CFG->currency->sign)
440
-            ? EE_Registry::instance()->CFG->currency->get_pretty('sign')
441
-            : '$';
442
-        $this->_template_args['organization_logo_url']  = isset(EE_Registry::instance()->CFG->organization->logo_url)
443
-            ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url')
444
-            : false;
445
-        $this->_template_args['organization_facebook']  = isset(EE_Registry::instance()->CFG->organization->facebook)
446
-            ? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
447
-            : '';
448
-        $this->_template_args['organization_twitter']   = isset(EE_Registry::instance()->CFG->organization->twitter)
449
-            ? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
450
-            : '';
451
-        $this->_template_args['organization_linkedin']  = isset(EE_Registry::instance()->CFG->organization->linkedin)
452
-            ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin')
453
-            : '';
454
-        $this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest)
455
-            ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest')
456
-            : '';
457
-        $this->_template_args['organization_google']    = isset(EE_Registry::instance()->CFG->organization->google)
458
-            ? EE_Registry::instance()->CFG->organization->get_pretty('google')
459
-            : '';
460
-        $this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram)
461
-            ? EE_Registry::instance()->CFG->organization->get_pretty('instagram')
462
-            : '';
463
-        //UXIP settings
464
-        $this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin)
465
-            ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin')
466
-            : true;
467
-
468
-        $STA_ID                         = isset(EE_Registry::instance()->CFG->organization->STA_ID)
469
-            ? EE_Registry::instance()->CFG->organization->STA_ID
470
-            : 4;
471
-        $this->_template_args['states'] = new EE_Question_Form_Input(
472
-            EE_Question::new_instance(array(
473
-                'QST_ID'           => 0,
474
-                'QST_display_text' => __('State/Province', 'event_espresso'),
475
-                'QST_system'       => 'admin-state',
476
-            )),
477
-            EE_Answer::new_instance(array(
478
-                'ANS_ID'    => 0,
479
-                'ANS_value' => $STA_ID,
480
-            )),
481
-            array(
482
-                'input_id'       => 'organization_state',
483
-                'input_name'     => 'organization_state',
484
-                'input_prefix'   => '',
485
-                'append_qstn_id' => false,
486
-            )
487
-        );
488
-
489
-        $CNT_ISO                           = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
490
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
491
-            : 'US';
492
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
493
-            EE_Question::new_instance(array(
494
-                'QST_ID'           => 0,
495
-                'QST_display_text' => __('Country', 'event_espresso'),
496
-                'QST_system'       => 'admin-country',
497
-            )),
498
-            EE_Answer::new_instance(array(
499
-                'ANS_ID'    => 0,
500
-                'ANS_value' => $CNT_ISO,
501
-            )),
502
-            array(
503
-                'input_id'       => 'organization_country',
504
-                'input_name'     => 'organization_country',
505
-                'input_prefix'   => '',
506
-                'append_qstn_id' => false,
507
-            )
508
-        );
509
-
510
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
511
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
512
-
513
-        //PUE verification stuff
514
-        $ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
515
-        $verify_fail                                       = get_option($ver_option_key);
516
-        $this->_template_args['site_license_key_verified'] = $verify_fail
517
-                                                             || ! empty($verify_fail)
518
-                                                             || (empty($this->_template_args['site_license_key'])
519
-                                                                 && empty($verify_fail)
520
-                                                             )
521
-            ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>'
522
-            : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
523
-
524
-        $this->_set_add_edit_form_tags('update_your_organization_settings');
525
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
526
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
527
-            GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
528
-            $this->_template_args,
529
-            true
530
-        );
531
-
532
-        $this->display_admin_page_with_sidebar();
533
-    }
534
-
535
-
536
-    /**
537
-     * Handler for updating organziation settings.
538
-     */
539
-    protected function _update_your_organization_settings()
540
-    {
541
-        if (is_main_site()) {
542
-            EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key'])
543
-                ? sanitize_text_field($this->_req_data['site_license_key'])
544
-                : EE_Registry::instance()->NET_CFG->core->site_license_key;
545
-        }
546
-        EE_Registry::instance()->CFG->organization->name      = isset($this->_req_data['organization_name'])
547
-            ? sanitize_text_field($this->_req_data['organization_name'])
548
-            : EE_Registry::instance()->CFG->organization->name;
549
-        EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1'])
550
-            ? sanitize_text_field($this->_req_data['organization_address_1'])
551
-            : EE_Registry::instance()->CFG->organization->address_1;
552
-        EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2'])
553
-            ? sanitize_text_field($this->_req_data['organization_address_2'])
554
-            : EE_Registry::instance()->CFG->organization->address_2;
555
-        EE_Registry::instance()->CFG->organization->city      = isset($this->_req_data['organization_city'])
556
-            ? sanitize_text_field($this->_req_data['organization_city'])
557
-            : EE_Registry::instance()->CFG->organization->city;
558
-        EE_Registry::instance()->CFG->organization->STA_ID    = isset($this->_req_data['organization_state'])
559
-            ? absint($this->_req_data['organization_state'])
560
-            : EE_Registry::instance()->CFG->organization->STA_ID;
561
-        EE_Registry::instance()->CFG->organization->CNT_ISO   = isset($this->_req_data['organization_country'])
562
-            ? sanitize_text_field($this->_req_data['organization_country'])
563
-            : EE_Registry::instance()->CFG->organization->CNT_ISO;
564
-        EE_Registry::instance()->CFG->organization->zip       = isset($this->_req_data['organization_zip'])
565
-            ? sanitize_text_field($this->_req_data['organization_zip'])
566
-            : EE_Registry::instance()->CFG->organization->zip;
567
-        EE_Registry::instance()->CFG->organization->email     = isset($this->_req_data['organization_email'])
568
-            ? sanitize_email($this->_req_data['organization_email'])
569
-            : EE_Registry::instance()->CFG->organization->email;
570
-        EE_Registry::instance()->CFG->organization->vat       = isset($this->_req_data['organization_vat'])
571
-            ? sanitize_text_field($this->_req_data['organization_vat'])
572
-            : EE_Registry::instance()->CFG->organization->vat;
573
-        EE_Registry::instance()->CFG->organization->phone     = isset($this->_req_data['organization_phone'])
574
-            ? sanitize_text_field($this->_req_data['organization_phone'])
575
-            : EE_Registry::instance()->CFG->organization->phone;
576
-        EE_Registry::instance()->CFG->organization->logo_url  = isset($this->_req_data['organization_logo_url'])
577
-            ? esc_url_raw($this->_req_data['organization_logo_url'])
578
-            : EE_Registry::instance()->CFG->organization->logo_url;
579
-        EE_Registry::instance()->CFG->organization->facebook  = isset($this->_req_data['organization_facebook'])
580
-            ? esc_url_raw($this->_req_data['organization_facebook'])
581
-            : EE_Registry::instance()->CFG->organization->facebook;
582
-        EE_Registry::instance()->CFG->organization->twitter   = isset($this->_req_data['organization_twitter'])
583
-            ? esc_url_raw($this->_req_data['organization_twitter'])
584
-            : EE_Registry::instance()->CFG->organization->twitter;
585
-        EE_Registry::instance()->CFG->organization->linkedin  = isset($this->_req_data['organization_linkedin'])
586
-            ? esc_url_raw($this->_req_data['organization_linkedin'])
587
-            : EE_Registry::instance()->CFG->organization->linkedin;
588
-        EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest'])
589
-            ? esc_url_raw($this->_req_data['organization_pinterest'])
590
-            : EE_Registry::instance()->CFG->organization->pinterest;
591
-        EE_Registry::instance()->CFG->organization->google    = isset($this->_req_data['organization_google'])
592
-            ? esc_url_raw($this->_req_data['organization_google'])
593
-            : EE_Registry::instance()->CFG->organization->google;
594
-        EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram'])
595
-            ? esc_url_raw($this->_req_data['organization_instagram'])
596
-            : EE_Registry::instance()->CFG->organization->instagram;
597
-        EE_Registry::instance()->CFG->core->ee_ueip_optin     = isset($this->_req_data['ueip_optin'])
598
-                                                                && ! empty($this->_req_data['ueip_optin'])
599
-            ? $this->_req_data['ueip_optin']
600
-            : EE_Registry::instance()->CFG->core->ee_ueip_optin;
601
-
602
-        EE_Registry::instance()->CFG->currency = new EE_Currency_Config(
603
-            EE_Registry::instance()->CFG->organization->CNT_ISO
604
-        );
605
-
606
-        EE_Registry::instance()->CFG = apply_filters(
607
-            'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
608
-            EE_Registry::instance()->CFG
609
-        );
610
-
611
-        $what    = 'Your Organization Settings';
612
-        $success = $this->_update_espresso_configuration(
613
-            $what,
614
-            EE_Registry::instance()->CFG,
615
-            __FILE__,
616
-            __FUNCTION__,
617
-            __LINE__
618
-        );
619
-
620
-        $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
621
-    }
622
-
623
-
624
-
625
-    /*************        Admin Options        *************/
626
-
627
-
628
-    /**
629
-     * _admin_option_settings
630
-     *
631
-     * @throws \EE_Error
632
-     * @throws \LogicException
633
-     */
634
-    protected function _admin_option_settings()
635
-    {
636
-        $this->_template_args['admin_page_content'] = '';
637
-        try {
638
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
639
-            // still need this for the old school form in Extend_General_Settings_Admin_Page
640
-            $this->_template_args['values'] = $this->_yes_no_values;
641
-            // also need to account for the do_action that was in the old template
642
-            $admin_options_settings_form->setTemplateArgs($this->_template_args);
643
-            $this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
644
-        } catch (Exception $e) {
645
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
646
-        }
647
-        $this->_set_add_edit_form_tags('update_admin_option_settings');
648
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
649
-        $this->display_admin_page_with_sidebar();
650
-    }
651
-
652
-
653
-    /**
654
-     * _update_admin_option_settings
655
-     *
656
-     * @throws \EE_Error
657
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
658
-     * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
659
-     * @throws \InvalidArgumentException
660
-     * @throws \LogicException
661
-     */
662
-    protected function _update_admin_option_settings()
663
-    {
664
-        try {
665
-            $admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
666
-            $admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
667
-            EE_Registry::instance()->CFG->admin = apply_filters(
668
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
669
-                EE_Registry::instance()->CFG->admin
670
-            );
671
-        } catch (Exception $e) {
672
-            EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
673
-        }
674
-        $this->_redirect_after_action(
675
-            apply_filters(
676
-                'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
677
-                $this->_update_espresso_configuration(
678
-                    'Admin Options',
679
-                    EE_Registry::instance()->CFG->admin,
680
-                    __FILE__, __FUNCTION__, __LINE__
681
-                )
682
-            ),
683
-            'Admin Options',
684
-            'updated',
685
-            array('action' => 'admin_option_settings')
686
-        );
687
-
688
-    }
689
-
690
-
691
-    /*************        Countries        *************/
692
-
693
-
694
-    /**
695
-     * Output Country Settings view.
696
-     * @throws DomainException
697
-     * @throws EE_Error
698
-     */
699
-    protected function _country_settings()
700
-    {
701
-        $CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
702
-            ? EE_Registry::instance()->CFG->organization->CNT_ISO
703
-            : 'US';
704
-        $CNT_ISO = isset($this->_req_data['country'])
705
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
706
-            : $CNT_ISO;
707
-
708
-        //load field generator helper
709
-
710
-        $this->_template_args['values'] = $this->_yes_no_values;
711
-
712
-        $this->_template_args['countries'] = new EE_Question_Form_Input(
713
-            EE_Question::new_instance(array(
714
-                'QST_ID'           => 0,
715
-                'QST_display_text' => __('Select Country', 'event_espresso'),
716
-                'QST_system'       => 'admin-country',
717
-            )),
718
-            EE_Answer::new_instance(array(
719
-                'ANS_ID'    => 0,
720
-                'ANS_value' => $CNT_ISO,
721
-            )),
722
-            array(
723
-                'input_id'       => 'country',
724
-                'input_name'     => 'country',
725
-                'input_prefix'   => '',
726
-                'append_qstn_id' => false,
727
-            )
728
-        );
729
-
730
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
731
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
732
-        $this->_template_args['country_details_settings'] = $this->display_country_settings();
733
-        $this->_template_args['country_states_settings']  = $this->display_country_states();
734
-
735
-        $this->_set_add_edit_form_tags('update_country_settings');
736
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
737
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
738
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
739
-            $this->_template_args,
740
-            true
741
-        );
742
-        $this->display_admin_page_with_no_sidebar();
743
-    }
744
-
745
-
746
-    /**
747
-     *        display_country_settings
748
-     *
749
-     * @access    public
750
-     * @param    string $CNT_ISO
751
-     * @return mixed string | array
752
-     * @throws DomainException
753
-     */
754
-    public function display_country_settings($CNT_ISO = '')
755
-    {
756
-
757
-        $CNT_ISO = isset($this->_req_data['country'])
758
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
759
-            : $CNT_ISO;
760
-        if (! $CNT_ISO) {
761
-            return '';
762
-        }
763
-
764
-        // for ajax
765
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
766
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
767
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
768
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
769
-        $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
770
-
771
-        $country_input_types            = array(
772
-            'CNT_active'      => array(
773
-                'type'             => 'RADIO_BTN',
774
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
775
-                'class'            => '',
776
-                'options'          => $this->_yes_no_values,
777
-                'use_desc_4_label' => true,
778
-            ),
779
-            'CNT_ISO'         => array(
780
-                'type'       => 'TEXT',
781
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
782
-                'class'      => 'small-text',
783
-            ),
784
-            'CNT_ISO3'        => array(
785
-                'type'       => 'TEXT',
786
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
787
-                'class'      => 'small-text',
788
-            ),
789
-            'RGN_ID'          => array(
790
-                'type'       => 'TEXT',
791
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
792
-                'class'      => 'small-text',
793
-            ),
794
-            'CNT_name'        => array(
795
-                'type'       => 'TEXT',
796
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
797
-                'class'      => 'regular-text',
798
-            ),
799
-            'CNT_cur_code'    => array(
800
-                'type'       => 'TEXT',
801
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
802
-                'class'      => 'small-text',
803
-            ),
804
-            'CNT_cur_single'  => array(
805
-                'type'       => 'TEXT',
806
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
807
-                'class'      => 'medium-text',
808
-            ),
809
-            'CNT_cur_plural'  => array(
810
-                'type'       => 'TEXT',
811
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
812
-                'class'      => 'medium-text',
813
-            ),
814
-            'CNT_cur_sign'    => array(
815
-                'type'         => 'TEXT',
816
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
817
-                'class'        => 'small-text',
818
-                'htmlentities' => false,
819
-            ),
820
-            'CNT_cur_sign_b4' => array(
821
-                'type'             => 'RADIO_BTN',
822
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
823
-                'class'            => '',
824
-                'options'          => $this->_yes_no_values,
825
-                'use_desc_4_label' => true,
826
-            ),
827
-            'CNT_cur_dec_plc' => array(
828
-                'type'       => 'RADIO_BTN',
829
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
830
-                'class'      => '',
831
-                'options'    => array(
832
-                    array('id' => 0, 'text' => ''),
833
-                    array('id' => 1, 'text' => ''),
834
-                    array('id' => 2, 'text' => ''),
835
-                    array('id' => 3, 'text' => ''),
836
-                ),
837
-            ),
838
-            'CNT_cur_dec_mrk' => array(
839
-                'type'             => 'RADIO_BTN',
840
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
841
-                'class'            => '',
842
-                'options'          => array(
843
-                    array(
844
-                        'id'   => ',',
845
-                        'text' => __(', (comma)', 'event_espresso'),
846
-                    ),
847
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
848
-                ),
849
-                'use_desc_4_label' => true,
850
-            ),
851
-            'CNT_cur_thsnds'  => array(
852
-                'type'             => 'RADIO_BTN',
853
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
854
-                'class'            => '',
855
-                'options'          => array(
856
-                    array(
857
-                        'id'   => ',',
858
-                        'text' => __(', (comma)', 'event_espresso'),
859
-                    ),
860
-                    array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
861
-                ),
862
-                'use_desc_4_label' => true,
863
-            ),
864
-            'CNT_tel_code'    => array(
865
-                'type'       => 'TEXT',
866
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
867
-                'class'      => 'small-text',
868
-            ),
869
-            'CNT_is_EU'       => array(
870
-                'type'             => 'RADIO_BTN',
871
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
872
-                'class'            => '',
873
-                'options'          => $this->_yes_no_values,
874
-                'use_desc_4_label' => true,
875
-            ),
876
-        );
877
-        $this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
878
-            $country,
879
-            $country_input_types
880
-        );
881
-        $country_details_settings       = EEH_Template::display_template(
882
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
883
-            $this->_template_args,
884
-            true
885
-        );
886
-
887
-        if (defined('DOING_AJAX')) {
888
-            $notices = EE_Error::get_notices(false, false, false);
889
-            echo wp_json_encode(array(
890
-                'return_data' => $country_details_settings,
891
-                'success'     => $notices['success'],
892
-                'errors'      => $notices['errors'],
893
-            ));
894
-            die();
895
-        } else {
896
-            return $country_details_settings;
897
-        }
898
-    }
899
-
900
-
901
-    /**
902
-     *        display_country_states
903
-     *
904
-     * @access    public
905
-     * @param    string $CNT_ISO
906
-     * @return string
907
-     * @throws DomainException
908
-     */
909
-    public function display_country_states($CNT_ISO = '')
910
-    {
911
-
912
-        $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
913
-
914
-        if (! $CNT_ISO) {
915
-            return '';
916
-        }
917
-        // for ajax
918
-        remove_all_filters('FHEE__EEH_Form_Fields__label_html');
919
-        remove_all_filters('FHEE__EEH_Form_Fields__input_html');
920
-        add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
921
-        add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
922
-        $states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
923
-
924
-        if ($states) {
925
-            foreach ($states as $STA_ID => $state) {
926
-                if ($state instanceof EE_State) {
927
-                    //STA_abbrev 	STA_name 	STA_active
928
-                    $state_input_types                                           = array(
929
-                        'STA_abbrev' => array(
930
-                            'type'       => 'TEXT',
931
-                            'input_name' => 'states[' . $STA_ID . ']',
932
-                            'class'      => 'mid-text',
933
-                        ),
934
-                        'STA_name'   => array(
935
-                            'type'       => 'TEXT',
936
-                            'input_name' => 'states[' . $STA_ID . ']',
937
-                            'class'      => 'regular-text',
938
-                        ),
939
-                        'STA_active' => array(
940
-                            'type'             => 'RADIO_BTN',
941
-                            'input_name'       => 'states[' . $STA_ID . ']',
942
-                            'options'          => $this->_yes_no_values,
943
-                            'use_desc_4_label' => true,
944
-                        ),
945
-                    );
946
-                    $this->_template_args['states'][$STA_ID]['inputs'] =
947
-                        EE_Question_Form_Input::generate_question_form_inputs_for_object(
948
-                            $state,
949
-                            $state_input_types
950
-                        );
951
-                    $query_args                                                  = array(
952
-                        'action'     => 'delete_state',
953
-                        'STA_ID'     => $STA_ID,
954
-                        'CNT_ISO'    => $CNT_ISO,
955
-                        'STA_abbrev' => $state->abbrev(),
956
-                    );
957
-                    $this->_template_args['states'][$STA_ID]['delete_state_url'] =
958
-                        EE_Admin_Page::add_query_args_and_nonce(
959
-                            $query_args,
960
-                            GEN_SET_ADMIN_URL
961
-                        );
962
-                }
963
-            }
964
-        } else {
965
-            $this->_template_args['states'] = false;
966
-        }
967
-
968
-        $this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
969
-            array('action' => 'add_new_state'),
970
-            GEN_SET_ADMIN_URL
971
-        );
972
-
973
-        $state_details_settings = EEH_Template::display_template(
974
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
975
-            $this->_template_args,
976
-            true
977
-        );
978
-
979
-        if (defined('DOING_AJAX')) {
980
-            $notices = EE_Error::get_notices(false, false, false);
981
-            echo wp_json_encode(array(
982
-                'return_data' => $state_details_settings,
983
-                'success'     => $notices['success'],
984
-                'errors'      => $notices['errors'],
985
-            ));
986
-            die();
987
-        } else {
988
-            return $state_details_settings;
989
-        }
990
-    }
991
-
992
-
993
-    /**
994
-     *        add_new_state
995
-     *
996
-     * @access    public
997
-     * @return void
998
-     * @throws EE_Error
999
-     */
1000
-    public function add_new_state()
1001
-    {
1002
-
1003
-        $success = true;
1004
-
1005
-        $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1006
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1007
-            : false;
1008
-        if (! $CNT_ISO) {
1009
-            EE_Error::add_error(
1010
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1011
-                __FILE__,
1012
-                __FUNCTION__,
1013
-                __LINE__
1014
-            );
1015
-            $success = false;
1016
-        }
1017
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1018
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1019
-            : false;
1020
-        if (! $STA_abbrev) {
1021
-            EE_Error::add_error(
1022
-                __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1023
-                __FILE__,
1024
-                __FUNCTION__,
1025
-                __LINE__
1026
-            );
1027
-            $success = false;
1028
-        }
1029
-        $STA_name = isset($this->_req_data['STA_name'])
1030
-            ? sanitize_text_field($this->_req_data['STA_name'])
1031
-            : false;
1032
-        if (! $STA_name) {
1033
-            EE_Error::add_error(
1034
-                __('No State name or an invalid State name was received.', 'event_espresso'),
1035
-                __FILE__,
1036
-                __FUNCTION__,
1037
-                __LINE__
1038
-            );
1039
-            $success = false;
1040
-        }
1041
-
1042
-        if ($success) {
1043
-            $cols_n_values = array(
1044
-                'CNT_ISO'    => $CNT_ISO,
1045
-                'STA_abbrev' => $STA_abbrev,
1046
-                'STA_name'   => $STA_name,
1047
-                'STA_active' => true,
1048
-            );
1049
-            $success       = EEM_State::instance()->insert($cols_n_values);
1050
-            EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1051
-        }
1052
-
1053
-        if (defined('DOING_AJAX')) {
1054
-            $notices = EE_Error::get_notices(false, false, false);
1055
-            echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1056
-            die();
1057
-        } else {
1058
-            $this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1059
-        }
1060
-    }
1061
-
1062
-
1063
-    /**
1064
-     *        delete_state
1065
-     *
1066
-     * @access    public
1067
-     * @return        boolean
1068
-     */
1069
-    public function delete_state()
1070
-    {
1071
-        $CNT_ISO    = isset($this->_req_data['CNT_ISO'])
1072
-            ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1073
-            : false;
1074
-        $STA_ID     = isset($this->_req_data['STA_ID'])
1075
-            ? sanitize_text_field($this->_req_data['STA_ID'])
1076
-            : false;
1077
-        $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1078
-            ? sanitize_text_field($this->_req_data['STA_abbrev'])
1079
-            : false;
1080
-        if (! $STA_ID) {
1081
-            EE_Error::add_error(
1082
-                __('No State ID or an invalid State ID was received.', 'event_espresso'),
1083
-                __FILE__,
1084
-                __FUNCTION__,
1085
-                __LINE__
1086
-            );
1087
-            return false;
1088
-        }
1089
-
1090
-        $success = EEM_State::instance()->delete_by_ID($STA_ID);
1091
-        if ($success !== false) {
1092
-            do_action(
1093
-                'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1094
-                $CNT_ISO,
1095
-                $STA_ID,
1096
-                array('STA_abbrev' => $STA_abbrev)
1097
-            );
1098
-            EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1099
-        }
1100
-        if (defined('DOING_AJAX')) {
1101
-            $notices                = EE_Error::get_notices(false, false);
1102
-            $notices['return_data'] = true;
1103
-            echo wp_json_encode($notices);
1104
-            die();
1105
-        } else {
1106
-            $this->_redirect_after_action(
1107
-                $success,
1108
-                'State',
1109
-                'deleted',
1110
-                array('action' => 'country_settings')
1111
-            );
1112
-        }
1113
-    }
1114
-
1115
-
1116
-    /**
1117
-     *        _update_country_settings
1118
-     *
1119
-     * @access    protected
1120
-     * @return void
1121
-     * @throws EE_Error
1122
-     */
1123
-    protected function _update_country_settings()
1124
-    {
1125
-        // grab the country ISO code
1126
-        $CNT_ISO = isset($this->_req_data['country'])
1127
-            ? strtoupper(sanitize_text_field($this->_req_data['country']))
1128
-            : false;
1129
-        if (! $CNT_ISO) {
1130
-            EE_Error::add_error(
1131
-                __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1132
-                __FILE__,
1133
-                __FUNCTION__,
1134
-                __LINE__
1135
-            );
1136
-
1137
-            return;
1138
-        }
1139
-        $cols_n_values                    = array();
1140
-        $cols_n_values['CNT_ISO3']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1141
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1142
-            : false;
1143
-        $cols_n_values['RGN_ID']          = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1144
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1145
-            : null;
1146
-        $cols_n_values['CNT_name']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1147
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1148
-            : null;
1149
-        $cols_n_values['CNT_cur_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1150
-            ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']))
1151
-            : 'USD';
1152
-        $cols_n_values['CNT_cur_single']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1153
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1154
-            : 'dollar';
1155
-        $cols_n_values['CNT_cur_plural']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1156
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1157
-            : 'dollars';
1158
-        $cols_n_values['CNT_cur_sign']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1159
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1160
-            : '$';
1161
-        $cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1162
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1163
-            : true;
1164
-        $cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1165
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1166
-            : 2;
1167
-        $cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1168
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1169
-            : '.';
1170
-        $cols_n_values['CNT_cur_thsnds']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1171
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1172
-            : ',';
1173
-        $cols_n_values['CNT_tel_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1174
-            ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1175
-            : null;
1176
-        $cols_n_values['CNT_is_EU']       = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1177
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1178
-            : false;
1179
-        $cols_n_values['CNT_active']      = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1180
-            ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1181
-            : false;
1182
-        // allow filtering of country data
1183
-        $cols_n_values = apply_filters(
1184
-            'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1185
-            $cols_n_values
1186
-        );
1187
-
1188
-        // where values
1189
-        $where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1190
-        // run the update
1191
-        $success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1192
-
1193
-        if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1194
-            // allow filtering of states data
1195
-            $states = apply_filters(
1196
-                'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1197
-                $this->_req_data['states']
1198
-            );
1199
-
1200
-            // loop thru state data ( looks like : states[75][STA_name] )
1201
-            foreach ($states as $STA_ID => $state) {
1202
-                $cols_n_values = array(
1203
-                    'CNT_ISO'    => $CNT_ISO,
1204
-                    'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1205
-                    'STA_name'   => sanitize_text_field($state['STA_name']),
1206
-                    'STA_active' => (bool)absint($state['STA_active']),
1207
-                );
1208
-                // where values
1209
-                $where_cols_n_values = array(array('STA_ID' => $STA_ID));
1210
-                // run the update
1211
-                $success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1212
-                if ($success !== false) {
1213
-                    do_action(
1214
-                        'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1215
-                        $CNT_ISO,
1216
-                        $STA_ID,
1217
-                        $cols_n_values
1218
-                    );
1219
-                }
1220
-            }
1221
-        }
1222
-        // check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1223
-        if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1224
-            && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1225
-        ) {
1226
-            EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1227
-            EE_Registry::instance()->CFG->update_espresso_config();
1228
-        }
1229
-
1230
-        if ($success !== false) {
1231
-            EE_Error::add_success(
1232
-                esc_html__('Country Settings updated successfully.', 'event_espresso')
1233
-            );
1234
-        }
1235
-        $this->_redirect_after_action(
1236
-            $success,
1237
-            '',
1238
-            '',
1239
-            array('action' => 'country_settings', 'country' => $CNT_ISO),
1240
-            true
1241
-        );
1242
-    }
1243
-
1244
-
1245
-    /**
1246
-     *        form_form_field_label_wrap
1247
-     *
1248
-     * @access        public
1249
-     * @param        string $label
1250
-     * @return        string
1251
-     */
1252
-    public function country_form_field_label_wrap($label, $required_text)
1253
-    {
1254
-        return '
20
+	/**
21
+	 * _question_group
22
+	 * holds the specific question group object for the question group details screen
23
+	 *
24
+	 * @var object
25
+	 */
26
+	protected $_question_group;
27
+
28
+
29
+	/**
30
+	 * Initialize basic properties.
31
+	 */
32
+	protected function _init_page_props()
33
+	{
34
+		$this->page_slug        = GEN_SET_PG_SLUG;
35
+		$this->page_label       = GEN_SET_LABEL;
36
+		$this->_admin_base_url  = GEN_SET_ADMIN_URL;
37
+		$this->_admin_base_path = GEN_SET_ADMIN;
38
+	}
39
+
40
+
41
+	/**
42
+	 * Set ajax hooks
43
+	 */
44
+	protected function _ajax_hooks()
45
+	{
46
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
47
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
48
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
49
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
50
+	}
51
+
52
+
53
+	/**
54
+	 * More page properties initialization.
55
+	 */
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = GEN_SET_LABEL;
59
+		$this->_labels           = array(
60
+			'publishbox' => __('Update Settings', 'event_espresso'),
61
+		);
62
+	}
63
+
64
+
65
+	/**
66
+	 * Set page routes property.
67
+	 */
68
+	protected function _set_page_routes()
69
+	{
70
+		$this->_page_routes = array(
71
+
72
+			'critical_pages'                => array(
73
+				'func'       => '_espresso_page_settings',
74
+				'capability' => 'manage_options',
75
+			),
76
+			'update_espresso_page_settings' => array(
77
+				'func'       => '_update_espresso_page_settings',
78
+				'capability' => 'manage_options',
79
+				'noheader'   => true,
80
+			),
81
+			'default'                       => array(
82
+				'func'       => '_your_organization_settings',
83
+				'capability' => 'manage_options',
84
+			),
85
+
86
+			'update_your_organization_settings' => array(
87
+				'func'       => '_update_your_organization_settings',
88
+				'capability' => 'manage_options',
89
+				'noheader'   => true,
90
+			),
91
+
92
+			'admin_option_settings' => array(
93
+				'func'       => '_admin_option_settings',
94
+				'capability' => 'manage_options',
95
+			),
96
+
97
+			'update_admin_option_settings' => array(
98
+				'func'       => '_update_admin_option_settings',
99
+				'capability' => 'manage_options',
100
+				'noheader'   => true,
101
+			),
102
+
103
+			'country_settings' => array(
104
+				'func'       => '_country_settings',
105
+				'capability' => 'manage_options',
106
+			),
107
+
108
+			'update_country_settings' => array(
109
+				'func'       => '_update_country_settings',
110
+				'capability' => 'manage_options',
111
+				'noheader'   => true,
112
+			),
113
+
114
+			'display_country_settings' => array(
115
+				'func'       => 'display_country_settings',
116
+				'capability' => 'manage_options',
117
+				'noheader'   => true,
118
+			),
119
+
120
+			'add_new_state' => array(
121
+				'func'       => 'add_new_state',
122
+				'capability' => 'manage_options',
123
+				'noheader'   => true,
124
+			),
125
+
126
+			'delete_state' => array(
127
+				'func'       => 'delete_state',
128
+				'capability' => 'manage_options',
129
+				'noheader'   => true,
130
+			),
131
+		);
132
+	}
133
+
134
+
135
+	/**
136
+	 * Set page configuration property
137
+	 */
138
+	protected function _set_page_config()
139
+	{
140
+		$this->_page_config = array(
141
+			'critical_pages'        => array(
142
+				'nav'           => array(
143
+					'label' => __('Critical Pages', 'event_espresso'),
144
+					'order' => 50,
145
+				),
146
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
147
+				'help_tabs'     => array(
148
+					'general_settings_critical_pages_help_tab' => array(
149
+						'title'    => __('Critical Pages', 'event_espresso'),
150
+						'filename' => 'general_settings_critical_pages',
151
+					),
152
+				),
153
+				'help_tour'     => array('Critical_Pages_Help_Tour'),
154
+				'require_nonce' => false,
155
+			),
156
+			'default'               => array(
157
+				'nav'           => array(
158
+					'label' => __('Your Organization', 'event_espresso'),
159
+					'order' => 20,
160
+				),
161
+				'help_tabs'     => array(
162
+					'general_settings_your_organization_help_tab' => array(
163
+						'title'    => __('Your Organization', 'event_espresso'),
164
+						'filename' => 'general_settings_your_organization',
165
+					),
166
+				),
167
+				'help_tour'     => array('Your_Organization_Help_Tour'),
168
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
169
+				'require_nonce' => false,
170
+			),
171
+			'admin_option_settings' => array(
172
+				'nav'           => array(
173
+					'label' => __('Admin Options', 'event_espresso'),
174
+					'order' => 60,
175
+				),
176
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
177
+				'help_tabs'     => array(
178
+					'general_settings_admin_options_help_tab' => array(
179
+						'title'    => __('Admin Options', 'event_espresso'),
180
+						'filename' => 'general_settings_admin_options',
181
+					),
182
+				),
183
+				'help_tour'     => array('Admin_Options_Help_Tour'),
184
+				'require_nonce' => false,
185
+			),
186
+			'country_settings'      => array(
187
+				'nav'           => array(
188
+					'label' => __('Countries', 'event_espresso'),
189
+					'order' => 70,
190
+				),
191
+				'help_tabs'     => array(
192
+					'general_settings_countries_help_tab' => array(
193
+						'title'    => __('Countries', 'event_espresso'),
194
+						'filename' => 'general_settings_countries',
195
+					),
196
+				),
197
+				'help_tour'     => array('Countries_Help_Tour'),
198
+				'require_nonce' => false,
199
+			),
200
+		);
201
+	}
202
+
203
+
204
+
205
+	protected function _add_screen_options()
206
+	{
207
+	}
208
+
209
+	protected function _add_feature_pointers()
210
+	{
211
+	}
212
+
213
+
214
+	/**
215
+	 * Enqueue global scripts and styles for all routes in the General Settings Admin Pages.
216
+	 */
217
+	public function load_scripts_styles()
218
+	{
219
+		//styles
220
+		wp_enqueue_style('espresso-ui-theme');
221
+		//scripts
222
+		wp_enqueue_script('ee_admin_js');
223
+	}
224
+
225
+
226
+	/**
227
+	 * Execute logic running on `admin_init`
228
+	 */
229
+	public function admin_init()
230
+	{
231
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __(
232
+			'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.',
233
+			'event_espresso'
234
+		);
235
+		EE_Registry::$i18n_js_strings['error_occurred']          = __(
236
+			'An error occurred! Please refresh the page and try again.',
237
+			'event_espresso'
238
+		);
239
+		EE_Registry::$i18n_js_strings['confirm_delete_state']    = __(
240
+			'Are you sure you want to delete this State / Province?',
241
+			'event_espresso'
242
+		);
243
+		$protocol                                                = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
244
+		EE_Registry::$i18n_js_strings['ajax_url']                = admin_url(
245
+			'admin-ajax.php?page=espresso_general_settings',
246
+			$protocol
247
+		);
248
+	}
249
+
250
+	public function admin_notices()
251
+	{
252
+	}
253
+
254
+	public function admin_footer_scripts()
255
+	{
256
+	}
257
+
258
+
259
+	/**
260
+	 * Enqueue scripts and styles for the default route.
261
+	 */
262
+	public function load_scripts_styles_default()
263
+	{
264
+		//styles
265
+		wp_enqueue_style('thickbox');
266
+		//scripts
267
+		wp_enqueue_script('media-upload');
268
+		wp_enqueue_script('thickbox');
269
+		wp_register_script(
270
+			'organization_settings',
271
+			GEN_SET_ASSETS_URL . 'your_organization_settings.js',
272
+			array('jquery', 'media-upload', 'thickbox'),
273
+			EVENT_ESPRESSO_VERSION,
274
+			true
275
+		);
276
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
277
+		wp_enqueue_script('organization_settings');
278
+		wp_enqueue_style('organization-css');
279
+		$confirm_image_delete = array(
280
+			'text' => __(
281
+				'Do you really want to delete this image? Please remember to save your settings to complete the removal.',
282
+				'event_espresso'
283
+			),
284
+		);
285
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
286
+	}
287
+
288
+
289
+	/**
290
+	 * Enqueue scripts and styles for the country settings route.
291
+	 */
292
+	public function load_scripts_styles_country_settings()
293
+	{
294
+		//scripts
295
+		wp_register_script(
296
+			'gen_settings_countries',
297
+			GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
298
+			array('ee_admin_js'),
299
+			EVENT_ESPRESSO_VERSION,
300
+			true
301
+		);
302
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
303
+		wp_enqueue_script('gen_settings_countries');
304
+		wp_enqueue_style('organization-css');
305
+	}
306
+
307
+
308
+	/*************        Espresso Pages        *************/
309
+	/**
310
+	 * _espresso_page_settings
311
+	 *
312
+	 * @throws \EE_Error
313
+	 */
314
+	protected function _espresso_page_settings()
315
+	{
316
+		// Check to make sure all of the main pages are setup properly,
317
+		// if not create the default pages and display an admin notice
318
+		EEH_Activation::verify_default_pages_exist();
319
+		$this->_transient_garbage_collection();
320
+		$this->_template_args['values']             = $this->_yes_no_values;
321
+		$this->_template_args['reg_page_id']        = isset(EE_Registry::instance()->CFG->core->reg_page_id)
322
+			? EE_Registry::instance()->CFG->core->reg_page_id
323
+			: null;
324
+		$this->_template_args['reg_page_obj']       = isset(EE_Registry::instance()->CFG->core->reg_page_id)
325
+			? get_page(EE_Registry::instance()->CFG->core->reg_page_id)
326
+			: false;
327
+		$this->_template_args['txn_page_id']        = isset(EE_Registry::instance()->CFG->core->txn_page_id)
328
+			? EE_Registry::instance()->CFG->core->txn_page_id
329
+			: null;
330
+		$this->_template_args['txn_page_obj']       = isset(EE_Registry::instance()->CFG->core->txn_page_id)
331
+			? get_page(EE_Registry::instance()->CFG->core->txn_page_id)
332
+			: false;
333
+		$this->_template_args['thank_you_page_id']  = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
334
+			? EE_Registry::instance()->CFG->core->thank_you_page_id
335
+			: null;
336
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id)
337
+			? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id)
338
+			: false;
339
+		$this->_template_args['cancel_page_id']     = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
340
+			? EE_Registry::instance()->CFG->core->cancel_page_id
341
+			: null;
342
+		$this->_template_args['cancel_page_obj']    = isset(EE_Registry::instance()->CFG->core->cancel_page_id)
343
+			? get_page(EE_Registry::instance()->CFG->core->cancel_page_id)
344
+			: false;
345
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
346
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
347
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
348
+			GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
349
+			$this->_template_args,
350
+			true
351
+		);
352
+		$this->display_admin_page_with_sidebar();
353
+	}
354
+
355
+
356
+	/**
357
+	 * Handler for updating espresso page settings.
358
+	 */
359
+	protected function _update_espresso_page_settings()
360
+	{
361
+		// capture incoming request data && set page IDs
362
+		EE_Registry::instance()->CFG->core->reg_page_id       = isset($this->_req_data['reg_page_id'])
363
+			? absint($this->_req_data['reg_page_id'])
364
+			: EE_Registry::instance()->CFG->core->reg_page_id;
365
+		EE_Registry::instance()->CFG->core->txn_page_id       = isset($this->_req_data['txn_page_id'])
366
+			? absint($this->_req_data['txn_page_id'])
367
+			: EE_Registry::instance()->CFG->core->txn_page_id;
368
+		EE_Registry::instance()->CFG->core->thank_you_page_id = isset($this->_req_data['thank_you_page_id'])
369
+			? absint($this->_req_data['thank_you_page_id'])
370
+			: EE_Registry::instance()->CFG->core->thank_you_page_id;
371
+		EE_Registry::instance()->CFG->core->cancel_page_id    = isset($this->_req_data['cancel_page_id'])
372
+			? absint($this->_req_data['cancel_page_id'])
373
+			: EE_Registry::instance()->CFG->core->cancel_page_id;
374
+
375
+		EE_Registry::instance()->CFG->core = apply_filters(
376
+			'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core',
377
+			EE_Registry::instance()->CFG->core,
378
+			$this->_req_data
379
+		);
380
+		$what                              = __('Critical Pages & Shortcodes', 'event_espresso');
381
+		$this->_redirect_after_action(
382
+			$this->_update_espresso_configuration(
383
+				$what,
384
+				EE_Registry::instance()->CFG->core,
385
+				__FILE__,
386
+				__FUNCTION__,
387
+				__LINE__
388
+			),
389
+			$what,
390
+			'',
391
+			array(
392
+				'action' => 'critical_pages',
393
+			),
394
+			true
395
+		);
396
+	}
397
+
398
+
399
+	/*************        Your Organization        *************/
400
+
401
+
402
+	/**
403
+	 * Output for the Your Organization settings route.
404
+	 * @throws DomainException
405
+	 * @throws EE_Error
406
+	 */
407
+	protected function _your_organization_settings()
408
+	{
409
+
410
+		$this->_template_args['site_license_key']       = isset(
411
+			EE_Registry::instance()->NET_CFG->core->site_license_key
412
+		)
413
+			? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
414
+			: '';
415
+		$this->_template_args['organization_name']      = isset(EE_Registry::instance()->CFG->organization->name)
416
+			? EE_Registry::instance()->CFG->organization->get_pretty('name')
417
+			: '';
418
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1)
419
+			? EE_Registry::instance()->CFG->organization->get_pretty('address_1')
420
+			: '';
421
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2)
422
+			? EE_Registry::instance()->CFG->organization->get_pretty('address_2')
423
+			: '';
424
+		$this->_template_args['organization_city']      = isset(EE_Registry::instance()->CFG->organization->city)
425
+			? EE_Registry::instance()->CFG->organization->get_pretty('city')
426
+			: '';
427
+		$this->_template_args['organization_zip']       = isset(EE_Registry::instance()->CFG->organization->zip)
428
+			? EE_Registry::instance()->CFG->organization->get_pretty('zip')
429
+			: '';
430
+		$this->_template_args['organization_email']     = isset(EE_Registry::instance()->CFG->organization->email)
431
+			? EE_Registry::instance()->CFG->organization->get_pretty('email')
432
+			: '';
433
+		$this->_template_args['organization_phone']     = isset(EE_Registry::instance()->CFG->organization->phone)
434
+			? EE_Registry::instance()->CFG->organization->get_pretty('phone')
435
+			: '';
436
+		$this->_template_args['organization_vat']       = isset(EE_Registry::instance()->CFG->organization->vat)
437
+			? EE_Registry::instance()->CFG->organization->get_pretty('vat')
438
+			: '';
439
+		$this->_template_args['currency_sign']          = isset(EE_Registry::instance()->CFG->currency->sign)
440
+			? EE_Registry::instance()->CFG->currency->get_pretty('sign')
441
+			: '$';
442
+		$this->_template_args['organization_logo_url']  = isset(EE_Registry::instance()->CFG->organization->logo_url)
443
+			? EE_Registry::instance()->CFG->organization->get_pretty('logo_url')
444
+			: false;
445
+		$this->_template_args['organization_facebook']  = isset(EE_Registry::instance()->CFG->organization->facebook)
446
+			? EE_Registry::instance()->CFG->organization->get_pretty('facebook')
447
+			: '';
448
+		$this->_template_args['organization_twitter']   = isset(EE_Registry::instance()->CFG->organization->twitter)
449
+			? EE_Registry::instance()->CFG->organization->get_pretty('twitter')
450
+			: '';
451
+		$this->_template_args['organization_linkedin']  = isset(EE_Registry::instance()->CFG->organization->linkedin)
452
+			? EE_Registry::instance()->CFG->organization->get_pretty('linkedin')
453
+			: '';
454
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest)
455
+			? EE_Registry::instance()->CFG->organization->get_pretty('pinterest')
456
+			: '';
457
+		$this->_template_args['organization_google']    = isset(EE_Registry::instance()->CFG->organization->google)
458
+			? EE_Registry::instance()->CFG->organization->get_pretty('google')
459
+			: '';
460
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram)
461
+			? EE_Registry::instance()->CFG->organization->get_pretty('instagram')
462
+			: '';
463
+		//UXIP settings
464
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin)
465
+			? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin')
466
+			: true;
467
+
468
+		$STA_ID                         = isset(EE_Registry::instance()->CFG->organization->STA_ID)
469
+			? EE_Registry::instance()->CFG->organization->STA_ID
470
+			: 4;
471
+		$this->_template_args['states'] = new EE_Question_Form_Input(
472
+			EE_Question::new_instance(array(
473
+				'QST_ID'           => 0,
474
+				'QST_display_text' => __('State/Province', 'event_espresso'),
475
+				'QST_system'       => 'admin-state',
476
+			)),
477
+			EE_Answer::new_instance(array(
478
+				'ANS_ID'    => 0,
479
+				'ANS_value' => $STA_ID,
480
+			)),
481
+			array(
482
+				'input_id'       => 'organization_state',
483
+				'input_name'     => 'organization_state',
484
+				'input_prefix'   => '',
485
+				'append_qstn_id' => false,
486
+			)
487
+		);
488
+
489
+		$CNT_ISO                           = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
490
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
491
+			: 'US';
492
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
493
+			EE_Question::new_instance(array(
494
+				'QST_ID'           => 0,
495
+				'QST_display_text' => __('Country', 'event_espresso'),
496
+				'QST_system'       => 'admin-country',
497
+			)),
498
+			EE_Answer::new_instance(array(
499
+				'ANS_ID'    => 0,
500
+				'ANS_value' => $CNT_ISO,
501
+			)),
502
+			array(
503
+				'input_id'       => 'organization_country',
504
+				'input_name'     => 'organization_country',
505
+				'input_prefix'   => '',
506
+				'append_qstn_id' => false,
507
+			)
508
+		);
509
+
510
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
511
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
512
+
513
+		//PUE verification stuff
514
+		$ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
515
+		$verify_fail                                       = get_option($ver_option_key);
516
+		$this->_template_args['site_license_key_verified'] = $verify_fail
517
+															 || ! empty($verify_fail)
518
+															 || (empty($this->_template_args['site_license_key'])
519
+																 && empty($verify_fail)
520
+															 )
521
+			? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>'
522
+			: '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
523
+
524
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
525
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
526
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
527
+			GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
528
+			$this->_template_args,
529
+			true
530
+		);
531
+
532
+		$this->display_admin_page_with_sidebar();
533
+	}
534
+
535
+
536
+	/**
537
+	 * Handler for updating organziation settings.
538
+	 */
539
+	protected function _update_your_organization_settings()
540
+	{
541
+		if (is_main_site()) {
542
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key'])
543
+				? sanitize_text_field($this->_req_data['site_license_key'])
544
+				: EE_Registry::instance()->NET_CFG->core->site_license_key;
545
+		}
546
+		EE_Registry::instance()->CFG->organization->name      = isset($this->_req_data['organization_name'])
547
+			? sanitize_text_field($this->_req_data['organization_name'])
548
+			: EE_Registry::instance()->CFG->organization->name;
549
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1'])
550
+			? sanitize_text_field($this->_req_data['organization_address_1'])
551
+			: EE_Registry::instance()->CFG->organization->address_1;
552
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2'])
553
+			? sanitize_text_field($this->_req_data['organization_address_2'])
554
+			: EE_Registry::instance()->CFG->organization->address_2;
555
+		EE_Registry::instance()->CFG->organization->city      = isset($this->_req_data['organization_city'])
556
+			? sanitize_text_field($this->_req_data['organization_city'])
557
+			: EE_Registry::instance()->CFG->organization->city;
558
+		EE_Registry::instance()->CFG->organization->STA_ID    = isset($this->_req_data['organization_state'])
559
+			? absint($this->_req_data['organization_state'])
560
+			: EE_Registry::instance()->CFG->organization->STA_ID;
561
+		EE_Registry::instance()->CFG->organization->CNT_ISO   = isset($this->_req_data['organization_country'])
562
+			? sanitize_text_field($this->_req_data['organization_country'])
563
+			: EE_Registry::instance()->CFG->organization->CNT_ISO;
564
+		EE_Registry::instance()->CFG->organization->zip       = isset($this->_req_data['organization_zip'])
565
+			? sanitize_text_field($this->_req_data['organization_zip'])
566
+			: EE_Registry::instance()->CFG->organization->zip;
567
+		EE_Registry::instance()->CFG->organization->email     = isset($this->_req_data['organization_email'])
568
+			? sanitize_email($this->_req_data['organization_email'])
569
+			: EE_Registry::instance()->CFG->organization->email;
570
+		EE_Registry::instance()->CFG->organization->vat       = isset($this->_req_data['organization_vat'])
571
+			? sanitize_text_field($this->_req_data['organization_vat'])
572
+			: EE_Registry::instance()->CFG->organization->vat;
573
+		EE_Registry::instance()->CFG->organization->phone     = isset($this->_req_data['organization_phone'])
574
+			? sanitize_text_field($this->_req_data['organization_phone'])
575
+			: EE_Registry::instance()->CFG->organization->phone;
576
+		EE_Registry::instance()->CFG->organization->logo_url  = isset($this->_req_data['organization_logo_url'])
577
+			? esc_url_raw($this->_req_data['organization_logo_url'])
578
+			: EE_Registry::instance()->CFG->organization->logo_url;
579
+		EE_Registry::instance()->CFG->organization->facebook  = isset($this->_req_data['organization_facebook'])
580
+			? esc_url_raw($this->_req_data['organization_facebook'])
581
+			: EE_Registry::instance()->CFG->organization->facebook;
582
+		EE_Registry::instance()->CFG->organization->twitter   = isset($this->_req_data['organization_twitter'])
583
+			? esc_url_raw($this->_req_data['organization_twitter'])
584
+			: EE_Registry::instance()->CFG->organization->twitter;
585
+		EE_Registry::instance()->CFG->organization->linkedin  = isset($this->_req_data['organization_linkedin'])
586
+			? esc_url_raw($this->_req_data['organization_linkedin'])
587
+			: EE_Registry::instance()->CFG->organization->linkedin;
588
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest'])
589
+			? esc_url_raw($this->_req_data['organization_pinterest'])
590
+			: EE_Registry::instance()->CFG->organization->pinterest;
591
+		EE_Registry::instance()->CFG->organization->google    = isset($this->_req_data['organization_google'])
592
+			? esc_url_raw($this->_req_data['organization_google'])
593
+			: EE_Registry::instance()->CFG->organization->google;
594
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram'])
595
+			? esc_url_raw($this->_req_data['organization_instagram'])
596
+			: EE_Registry::instance()->CFG->organization->instagram;
597
+		EE_Registry::instance()->CFG->core->ee_ueip_optin     = isset($this->_req_data['ueip_optin'])
598
+																&& ! empty($this->_req_data['ueip_optin'])
599
+			? $this->_req_data['ueip_optin']
600
+			: EE_Registry::instance()->CFG->core->ee_ueip_optin;
601
+
602
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(
603
+			EE_Registry::instance()->CFG->organization->CNT_ISO
604
+		);
605
+
606
+		EE_Registry::instance()->CFG = apply_filters(
607
+			'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG',
608
+			EE_Registry::instance()->CFG
609
+		);
610
+
611
+		$what    = 'Your Organization Settings';
612
+		$success = $this->_update_espresso_configuration(
613
+			$what,
614
+			EE_Registry::instance()->CFG,
615
+			__FILE__,
616
+			__FUNCTION__,
617
+			__LINE__
618
+		);
619
+
620
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
621
+	}
622
+
623
+
624
+
625
+	/*************        Admin Options        *************/
626
+
627
+
628
+	/**
629
+	 * _admin_option_settings
630
+	 *
631
+	 * @throws \EE_Error
632
+	 * @throws \LogicException
633
+	 */
634
+	protected function _admin_option_settings()
635
+	{
636
+		$this->_template_args['admin_page_content'] = '';
637
+		try {
638
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
639
+			// still need this for the old school form in Extend_General_Settings_Admin_Page
640
+			$this->_template_args['values'] = $this->_yes_no_values;
641
+			// also need to account for the do_action that was in the old template
642
+			$admin_options_settings_form->setTemplateArgs($this->_template_args);
643
+			$this->_template_args['admin_page_content'] = $admin_options_settings_form->display();
644
+		} catch (Exception $e) {
645
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
646
+		}
647
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
648
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
649
+		$this->display_admin_page_with_sidebar();
650
+	}
651
+
652
+
653
+	/**
654
+	 * _update_admin_option_settings
655
+	 *
656
+	 * @throws \EE_Error
657
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
658
+	 * @throws \EventEspresso\core\exceptions\InvalidFormSubmissionException
659
+	 * @throws \InvalidArgumentException
660
+	 * @throws \LogicException
661
+	 */
662
+	protected function _update_admin_option_settings()
663
+	{
664
+		try {
665
+			$admin_options_settings_form = new AdminOptionsSettings(EE_Registry::instance());
666
+			$admin_options_settings_form->process($this->_req_data[$admin_options_settings_form->slug()]);
667
+			EE_Registry::instance()->CFG->admin = apply_filters(
668
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin',
669
+				EE_Registry::instance()->CFG->admin
670
+			);
671
+		} catch (Exception $e) {
672
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
673
+		}
674
+		$this->_redirect_after_action(
675
+			apply_filters(
676
+				'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success',
677
+				$this->_update_espresso_configuration(
678
+					'Admin Options',
679
+					EE_Registry::instance()->CFG->admin,
680
+					__FILE__, __FUNCTION__, __LINE__
681
+				)
682
+			),
683
+			'Admin Options',
684
+			'updated',
685
+			array('action' => 'admin_option_settings')
686
+		);
687
+
688
+	}
689
+
690
+
691
+	/*************        Countries        *************/
692
+
693
+
694
+	/**
695
+	 * Output Country Settings view.
696
+	 * @throws DomainException
697
+	 * @throws EE_Error
698
+	 */
699
+	protected function _country_settings()
700
+	{
701
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
702
+			? EE_Registry::instance()->CFG->organization->CNT_ISO
703
+			: 'US';
704
+		$CNT_ISO = isset($this->_req_data['country'])
705
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
706
+			: $CNT_ISO;
707
+
708
+		//load field generator helper
709
+
710
+		$this->_template_args['values'] = $this->_yes_no_values;
711
+
712
+		$this->_template_args['countries'] = new EE_Question_Form_Input(
713
+			EE_Question::new_instance(array(
714
+				'QST_ID'           => 0,
715
+				'QST_display_text' => __('Select Country', 'event_espresso'),
716
+				'QST_system'       => 'admin-country',
717
+			)),
718
+			EE_Answer::new_instance(array(
719
+				'ANS_ID'    => 0,
720
+				'ANS_value' => $CNT_ISO,
721
+			)),
722
+			array(
723
+				'input_id'       => 'country',
724
+				'input_name'     => 'country',
725
+				'input_prefix'   => '',
726
+				'append_qstn_id' => false,
727
+			)
728
+		);
729
+
730
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
731
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
732
+		$this->_template_args['country_details_settings'] = $this->display_country_settings();
733
+		$this->_template_args['country_states_settings']  = $this->display_country_states();
734
+
735
+		$this->_set_add_edit_form_tags('update_country_settings');
736
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
737
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
738
+			GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
739
+			$this->_template_args,
740
+			true
741
+		);
742
+		$this->display_admin_page_with_no_sidebar();
743
+	}
744
+
745
+
746
+	/**
747
+	 *        display_country_settings
748
+	 *
749
+	 * @access    public
750
+	 * @param    string $CNT_ISO
751
+	 * @return mixed string | array
752
+	 * @throws DomainException
753
+	 */
754
+	public function display_country_settings($CNT_ISO = '')
755
+	{
756
+
757
+		$CNT_ISO = isset($this->_req_data['country'])
758
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
759
+			: $CNT_ISO;
760
+		if (! $CNT_ISO) {
761
+			return '';
762
+		}
763
+
764
+		// for ajax
765
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
766
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
767
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
768
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
769
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
770
+
771
+		$country_input_types            = array(
772
+			'CNT_active'      => array(
773
+				'type'             => 'RADIO_BTN',
774
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
775
+				'class'            => '',
776
+				'options'          => $this->_yes_no_values,
777
+				'use_desc_4_label' => true,
778
+			),
779
+			'CNT_ISO'         => array(
780
+				'type'       => 'TEXT',
781
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
782
+				'class'      => 'small-text',
783
+			),
784
+			'CNT_ISO3'        => array(
785
+				'type'       => 'TEXT',
786
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
787
+				'class'      => 'small-text',
788
+			),
789
+			'RGN_ID'          => array(
790
+				'type'       => 'TEXT',
791
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
792
+				'class'      => 'small-text',
793
+			),
794
+			'CNT_name'        => array(
795
+				'type'       => 'TEXT',
796
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
797
+				'class'      => 'regular-text',
798
+			),
799
+			'CNT_cur_code'    => array(
800
+				'type'       => 'TEXT',
801
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
802
+				'class'      => 'small-text',
803
+			),
804
+			'CNT_cur_single'  => array(
805
+				'type'       => 'TEXT',
806
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
807
+				'class'      => 'medium-text',
808
+			),
809
+			'CNT_cur_plural'  => array(
810
+				'type'       => 'TEXT',
811
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
812
+				'class'      => 'medium-text',
813
+			),
814
+			'CNT_cur_sign'    => array(
815
+				'type'         => 'TEXT',
816
+				'input_name'   => 'cntry[' . $CNT_ISO . ']',
817
+				'class'        => 'small-text',
818
+				'htmlentities' => false,
819
+			),
820
+			'CNT_cur_sign_b4' => array(
821
+				'type'             => 'RADIO_BTN',
822
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
823
+				'class'            => '',
824
+				'options'          => $this->_yes_no_values,
825
+				'use_desc_4_label' => true,
826
+			),
827
+			'CNT_cur_dec_plc' => array(
828
+				'type'       => 'RADIO_BTN',
829
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
830
+				'class'      => '',
831
+				'options'    => array(
832
+					array('id' => 0, 'text' => ''),
833
+					array('id' => 1, 'text' => ''),
834
+					array('id' => 2, 'text' => ''),
835
+					array('id' => 3, 'text' => ''),
836
+				),
837
+			),
838
+			'CNT_cur_dec_mrk' => array(
839
+				'type'             => 'RADIO_BTN',
840
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
841
+				'class'            => '',
842
+				'options'          => array(
843
+					array(
844
+						'id'   => ',',
845
+						'text' => __(', (comma)', 'event_espresso'),
846
+					),
847
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
848
+				),
849
+				'use_desc_4_label' => true,
850
+			),
851
+			'CNT_cur_thsnds'  => array(
852
+				'type'             => 'RADIO_BTN',
853
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
854
+				'class'            => '',
855
+				'options'          => array(
856
+					array(
857
+						'id'   => ',',
858
+						'text' => __(', (comma)', 'event_espresso'),
859
+					),
860
+					array('id' => '.', 'text' => __('. (decimal)', 'event_espresso')),
861
+				),
862
+				'use_desc_4_label' => true,
863
+			),
864
+			'CNT_tel_code'    => array(
865
+				'type'       => 'TEXT',
866
+				'input_name' => 'cntry[' . $CNT_ISO . ']',
867
+				'class'      => 'small-text',
868
+			),
869
+			'CNT_is_EU'       => array(
870
+				'type'             => 'RADIO_BTN',
871
+				'input_name'       => 'cntry[' . $CNT_ISO . ']',
872
+				'class'            => '',
873
+				'options'          => $this->_yes_no_values,
874
+				'use_desc_4_label' => true,
875
+			),
876
+		);
877
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object(
878
+			$country,
879
+			$country_input_types
880
+		);
881
+		$country_details_settings       = EEH_Template::display_template(
882
+			GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
883
+			$this->_template_args,
884
+			true
885
+		);
886
+
887
+		if (defined('DOING_AJAX')) {
888
+			$notices = EE_Error::get_notices(false, false, false);
889
+			echo wp_json_encode(array(
890
+				'return_data' => $country_details_settings,
891
+				'success'     => $notices['success'],
892
+				'errors'      => $notices['errors'],
893
+			));
894
+			die();
895
+		} else {
896
+			return $country_details_settings;
897
+		}
898
+	}
899
+
900
+
901
+	/**
902
+	 *        display_country_states
903
+	 *
904
+	 * @access    public
905
+	 * @param    string $CNT_ISO
906
+	 * @return string
907
+	 * @throws DomainException
908
+	 */
909
+	public function display_country_states($CNT_ISO = '')
910
+	{
911
+
912
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
913
+
914
+		if (! $CNT_ISO) {
915
+			return '';
916
+		}
917
+		// for ajax
918
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
919
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
920
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
921
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
922
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
923
+
924
+		if ($states) {
925
+			foreach ($states as $STA_ID => $state) {
926
+				if ($state instanceof EE_State) {
927
+					//STA_abbrev 	STA_name 	STA_active
928
+					$state_input_types                                           = array(
929
+						'STA_abbrev' => array(
930
+							'type'       => 'TEXT',
931
+							'input_name' => 'states[' . $STA_ID . ']',
932
+							'class'      => 'mid-text',
933
+						),
934
+						'STA_name'   => array(
935
+							'type'       => 'TEXT',
936
+							'input_name' => 'states[' . $STA_ID . ']',
937
+							'class'      => 'regular-text',
938
+						),
939
+						'STA_active' => array(
940
+							'type'             => 'RADIO_BTN',
941
+							'input_name'       => 'states[' . $STA_ID . ']',
942
+							'options'          => $this->_yes_no_values,
943
+							'use_desc_4_label' => true,
944
+						),
945
+					);
946
+					$this->_template_args['states'][$STA_ID]['inputs'] =
947
+						EE_Question_Form_Input::generate_question_form_inputs_for_object(
948
+							$state,
949
+							$state_input_types
950
+						);
951
+					$query_args                                                  = array(
952
+						'action'     => 'delete_state',
953
+						'STA_ID'     => $STA_ID,
954
+						'CNT_ISO'    => $CNT_ISO,
955
+						'STA_abbrev' => $state->abbrev(),
956
+					);
957
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] =
958
+						EE_Admin_Page::add_query_args_and_nonce(
959
+							$query_args,
960
+							GEN_SET_ADMIN_URL
961
+						);
962
+				}
963
+			}
964
+		} else {
965
+			$this->_template_args['states'] = false;
966
+		}
967
+
968
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(
969
+			array('action' => 'add_new_state'),
970
+			GEN_SET_ADMIN_URL
971
+		);
972
+
973
+		$state_details_settings = EEH_Template::display_template(
974
+			GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
975
+			$this->_template_args,
976
+			true
977
+		);
978
+
979
+		if (defined('DOING_AJAX')) {
980
+			$notices = EE_Error::get_notices(false, false, false);
981
+			echo wp_json_encode(array(
982
+				'return_data' => $state_details_settings,
983
+				'success'     => $notices['success'],
984
+				'errors'      => $notices['errors'],
985
+			));
986
+			die();
987
+		} else {
988
+			return $state_details_settings;
989
+		}
990
+	}
991
+
992
+
993
+	/**
994
+	 *        add_new_state
995
+	 *
996
+	 * @access    public
997
+	 * @return void
998
+	 * @throws EE_Error
999
+	 */
1000
+	public function add_new_state()
1001
+	{
1002
+
1003
+		$success = true;
1004
+
1005
+		$CNT_ISO = isset($this->_req_data['CNT_ISO'])
1006
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1007
+			: false;
1008
+		if (! $CNT_ISO) {
1009
+			EE_Error::add_error(
1010
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1011
+				__FILE__,
1012
+				__FUNCTION__,
1013
+				__LINE__
1014
+			);
1015
+			$success = false;
1016
+		}
1017
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1018
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1019
+			: false;
1020
+		if (! $STA_abbrev) {
1021
+			EE_Error::add_error(
1022
+				__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1023
+				__FILE__,
1024
+				__FUNCTION__,
1025
+				__LINE__
1026
+			);
1027
+			$success = false;
1028
+		}
1029
+		$STA_name = isset($this->_req_data['STA_name'])
1030
+			? sanitize_text_field($this->_req_data['STA_name'])
1031
+			: false;
1032
+		if (! $STA_name) {
1033
+			EE_Error::add_error(
1034
+				__('No State name or an invalid State name was received.', 'event_espresso'),
1035
+				__FILE__,
1036
+				__FUNCTION__,
1037
+				__LINE__
1038
+			);
1039
+			$success = false;
1040
+		}
1041
+
1042
+		if ($success) {
1043
+			$cols_n_values = array(
1044
+				'CNT_ISO'    => $CNT_ISO,
1045
+				'STA_abbrev' => $STA_abbrev,
1046
+				'STA_name'   => $STA_name,
1047
+				'STA_active' => true,
1048
+			);
1049
+			$success       = EEM_State::instance()->insert($cols_n_values);
1050
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1051
+		}
1052
+
1053
+		if (defined('DOING_AJAX')) {
1054
+			$notices = EE_Error::get_notices(false, false, false);
1055
+			echo wp_json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
1056
+			die();
1057
+		} else {
1058
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
1059
+		}
1060
+	}
1061
+
1062
+
1063
+	/**
1064
+	 *        delete_state
1065
+	 *
1066
+	 * @access    public
1067
+	 * @return        boolean
1068
+	 */
1069
+	public function delete_state()
1070
+	{
1071
+		$CNT_ISO    = isset($this->_req_data['CNT_ISO'])
1072
+			? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1073
+			: false;
1074
+		$STA_ID     = isset($this->_req_data['STA_ID'])
1075
+			? sanitize_text_field($this->_req_data['STA_ID'])
1076
+			: false;
1077
+		$STA_abbrev = isset($this->_req_data['STA_abbrev'])
1078
+			? sanitize_text_field($this->_req_data['STA_abbrev'])
1079
+			: false;
1080
+		if (! $STA_ID) {
1081
+			EE_Error::add_error(
1082
+				__('No State ID or an invalid State ID was received.', 'event_espresso'),
1083
+				__FILE__,
1084
+				__FUNCTION__,
1085
+				__LINE__
1086
+			);
1087
+			return false;
1088
+		}
1089
+
1090
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
1091
+		if ($success !== false) {
1092
+			do_action(
1093
+				'AHEE__General_Settings_Admin_Page__delete_state__state_deleted',
1094
+				$CNT_ISO,
1095
+				$STA_ID,
1096
+				array('STA_abbrev' => $STA_abbrev)
1097
+			);
1098
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
1099
+		}
1100
+		if (defined('DOING_AJAX')) {
1101
+			$notices                = EE_Error::get_notices(false, false);
1102
+			$notices['return_data'] = true;
1103
+			echo wp_json_encode($notices);
1104
+			die();
1105
+		} else {
1106
+			$this->_redirect_after_action(
1107
+				$success,
1108
+				'State',
1109
+				'deleted',
1110
+				array('action' => 'country_settings')
1111
+			);
1112
+		}
1113
+	}
1114
+
1115
+
1116
+	/**
1117
+	 *        _update_country_settings
1118
+	 *
1119
+	 * @access    protected
1120
+	 * @return void
1121
+	 * @throws EE_Error
1122
+	 */
1123
+	protected function _update_country_settings()
1124
+	{
1125
+		// grab the country ISO code
1126
+		$CNT_ISO = isset($this->_req_data['country'])
1127
+			? strtoupper(sanitize_text_field($this->_req_data['country']))
1128
+			: false;
1129
+		if (! $CNT_ISO) {
1130
+			EE_Error::add_error(
1131
+				__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1132
+				__FILE__,
1133
+				__FUNCTION__,
1134
+				__LINE__
1135
+			);
1136
+
1137
+			return;
1138
+		}
1139
+		$cols_n_values                    = array();
1140
+		$cols_n_values['CNT_ISO3']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])
1141
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']))
1142
+			: false;
1143
+		$cols_n_values['RGN_ID']          = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1144
+			? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID'])
1145
+			: null;
1146
+		$cols_n_values['CNT_name']        = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1147
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name'])
1148
+			: null;
1149
+		$cols_n_values['CNT_cur_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])
1150
+			? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']))
1151
+			: 'USD';
1152
+		$cols_n_values['CNT_cur_single']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1153
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'])
1154
+			: 'dollar';
1155
+		$cols_n_values['CNT_cur_plural']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1156
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'])
1157
+			: 'dollars';
1158
+		$cols_n_values['CNT_cur_sign']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1159
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'])
1160
+			: '$';
1161
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1162
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'])
1163
+			: true;
1164
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1165
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'])
1166
+			: 2;
1167
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1168
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'])
1169
+			: '.';
1170
+		$cols_n_values['CNT_cur_thsnds']  = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1171
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'])
1172
+			: ',';
1173
+		$cols_n_values['CNT_tel_code']    = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1174
+			? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'])
1175
+			: null;
1176
+		$cols_n_values['CNT_is_EU']       = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1177
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'])
1178
+			: false;
1179
+		$cols_n_values['CNT_active']      = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1180
+			? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active'])
1181
+			: false;
1182
+		// allow filtering of country data
1183
+		$cols_n_values = apply_filters(
1184
+			'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values',
1185
+			$cols_n_values
1186
+		);
1187
+
1188
+		// where values
1189
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
1190
+		// run the update
1191
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
1192
+
1193
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== false) {
1194
+			// allow filtering of states data
1195
+			$states = apply_filters(
1196
+				'FHEE__General_Settings_Admin_Page___update_country_settings__states',
1197
+				$this->_req_data['states']
1198
+			);
1199
+
1200
+			// loop thru state data ( looks like : states[75][STA_name] )
1201
+			foreach ($states as $STA_ID => $state) {
1202
+				$cols_n_values = array(
1203
+					'CNT_ISO'    => $CNT_ISO,
1204
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1205
+					'STA_name'   => sanitize_text_field($state['STA_name']),
1206
+					'STA_active' => (bool)absint($state['STA_active']),
1207
+				);
1208
+				// where values
1209
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
1210
+				// run the update
1211
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
1212
+				if ($success !== false) {
1213
+					do_action(
1214
+						'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved',
1215
+						$CNT_ISO,
1216
+						$STA_ID,
1217
+						$cols_n_values
1218
+					);
1219
+				}
1220
+			}
1221
+		}
1222
+		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
1223
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO)
1224
+			&& $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO
1225
+		) {
1226
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
1227
+			EE_Registry::instance()->CFG->update_espresso_config();
1228
+		}
1229
+
1230
+		if ($success !== false) {
1231
+			EE_Error::add_success(
1232
+				esc_html__('Country Settings updated successfully.', 'event_espresso')
1233
+			);
1234
+		}
1235
+		$this->_redirect_after_action(
1236
+			$success,
1237
+			'',
1238
+			'',
1239
+			array('action' => 'country_settings', 'country' => $CNT_ISO),
1240
+			true
1241
+		);
1242
+	}
1243
+
1244
+
1245
+	/**
1246
+	 *        form_form_field_label_wrap
1247
+	 *
1248
+	 * @access        public
1249
+	 * @param        string $label
1250
+	 * @return        string
1251
+	 */
1252
+	public function country_form_field_label_wrap($label, $required_text)
1253
+	{
1254
+		return '
1255 1255
 			<tr>
1256 1256
 				<th>
1257 1257
 					' . $label . '
1258 1258
 				</th>';
1259
-    }
1260
-
1261
-
1262
-    /**
1263
-     *        form_form_field_input__wrap
1264
-     *
1265
-     * @access        public
1266
-     * @param        string $label
1267
-     * @return        string
1268
-     */
1269
-    public function country_form_field_input__wrap($input, $label)
1270
-    {
1271
-        return '
1259
+	}
1260
+
1261
+
1262
+	/**
1263
+	 *        form_form_field_input__wrap
1264
+	 *
1265
+	 * @access        public
1266
+	 * @param        string $label
1267
+	 * @return        string
1268
+	 */
1269
+	public function country_form_field_input__wrap($input, $label)
1270
+	{
1271
+		return '
1272 1272
 				<td class="general-settings-country-input-td">
1273 1273
 					' . $input . '
1274 1274
 				</td>
1275 1275
 			</tr>';
1276
-    }
1277
-
1278
-
1279
-    /**
1280
-     *        form_form_field_label_wrap
1281
-     *
1282
-     * @access        public
1283
-     * @param        string $label
1284
-     * @param        string $required_text
1285
-     * @return        string
1286
-     */
1287
-    public function state_form_field_label_wrap($label, $required_text)
1288
-    {
1289
-        return $required_text;
1290
-    }
1291
-
1292
-
1293
-    /**
1294
-     *        form_form_field_input__wrap
1295
-     *
1296
-     * @access        public
1297
-     * @param        string $label
1298
-     * @return        string
1299
-     */
1300
-    public function state_form_field_input__wrap($input, $label)
1301
-    {
1302
-        return '
1276
+	}
1277
+
1278
+
1279
+	/**
1280
+	 *        form_form_field_label_wrap
1281
+	 *
1282
+	 * @access        public
1283
+	 * @param        string $label
1284
+	 * @param        string $required_text
1285
+	 * @return        string
1286
+	 */
1287
+	public function state_form_field_label_wrap($label, $required_text)
1288
+	{
1289
+		return $required_text;
1290
+	}
1291
+
1292
+
1293
+	/**
1294
+	 *        form_form_field_input__wrap
1295
+	 *
1296
+	 * @access        public
1297
+	 * @param        string $label
1298
+	 * @return        string
1299
+	 */
1300
+	public function state_form_field_input__wrap($input, $label)
1301
+	{
1302
+		return '
1303 1303
 				<td class="general-settings-country-state-input-td">
1304 1304
 					' . $input . '
1305 1305
 				</td>';
1306
-    }
1307
-
1308
-
1309
-    /***********/
1310
-
1311
-
1312
-    /**
1313
-     * displays edit and view links for critical EE pages
1314
-     *
1315
-     * @access public
1316
-     * @param int $ee_page_id
1317
-     * @return string
1318
-     */
1319
-    public static function edit_view_links($ee_page_id)
1320
-    {
1321
-        $links = '<a href="'
1322
-                 . add_query_arg(
1323
-                     array('post' => $ee_page_id, 'action' => 'edit'),
1324
-                     admin_url('post.php')
1325
-                 )
1326
-                 . '" >'
1327
-                 . __('Edit', 'event_espresso')
1328
-                 . '</a>';
1329
-        $links .= ' &nbsp;|&nbsp; ';
1330
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1331
-
1332
-        return $links;
1333
-    }
1334
-
1335
-
1336
-    /**
1337
-     * displays page and shortcode status for critical EE pages
1338
-     *
1339
-     * @param WP page object $ee_page
1340
-     * @return string
1341
-     */
1342
-    public static function page_and_shortcode_status($ee_page, $shortcode)
1343
-    {
1344
-
1345
-        // page status
1346
-        if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1347
-            $pg_colour = 'green';
1348
-            $pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1349
-        } else {
1350
-            $pg_colour = 'red';
1351
-            $pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1352
-        }
1353
-
1354
-        // shortcode status
1355
-        if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1356
-            $sc_colour = 'green';
1357
-            $sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1358
-        } else {
1359
-            $sc_colour = 'red';
1360
-            $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1361
-        }
1362
-
1363
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1364
-               . $pg_status
1365
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1366
-    }
1367
-
1368
-
1369
-    /**
1370
-     * generates a dropdown of all parent pages - copied from WP core
1371
-     *
1372
-     * @param int $default
1373
-     * @param int $parent
1374
-     * @param int $level
1375
-     */
1376
-    public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1377
-    {
1378
-        global $wpdb;
1379
-        $items = $wpdb->get_results(
1380
-            $wpdb->prepare(
1381
-                "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",
1382
-                $parent
1383
-            )
1384
-        );
1385
-
1386
-        if ($items) {
1387
-            foreach ($items as $item) {
1388
-                $pad = str_repeat('&nbsp;', $level * 3);
1389
-                if ($item->ID == $default) {
1390
-                    $current = ' selected="selected"';
1391
-                } else {
1392
-                    $current = '';
1393
-                }
1394
-
1395
-                echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1396
-                     . esc_html($item->post_title)
1397
-                     . "</option>";
1398
-                parent_dropdown($default, $item->ID, $level + 1);
1399
-            }
1400
-        }
1401
-    }
1306
+	}
1307
+
1308
+
1309
+	/***********/
1310
+
1311
+
1312
+	/**
1313
+	 * displays edit and view links for critical EE pages
1314
+	 *
1315
+	 * @access public
1316
+	 * @param int $ee_page_id
1317
+	 * @return string
1318
+	 */
1319
+	public static function edit_view_links($ee_page_id)
1320
+	{
1321
+		$links = '<a href="'
1322
+				 . add_query_arg(
1323
+					 array('post' => $ee_page_id, 'action' => 'edit'),
1324
+					 admin_url('post.php')
1325
+				 )
1326
+				 . '" >'
1327
+				 . __('Edit', 'event_espresso')
1328
+				 . '</a>';
1329
+		$links .= ' &nbsp;|&nbsp; ';
1330
+		$links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1331
+
1332
+		return $links;
1333
+	}
1334
+
1335
+
1336
+	/**
1337
+	 * displays page and shortcode status for critical EE pages
1338
+	 *
1339
+	 * @param WP page object $ee_page
1340
+	 * @return string
1341
+	 */
1342
+	public static function page_and_shortcode_status($ee_page, $shortcode)
1343
+	{
1344
+
1345
+		// page status
1346
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
1347
+			$pg_colour = 'green';
1348
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
1349
+		} else {
1350
+			$pg_colour = 'red';
1351
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
1352
+		}
1353
+
1354
+		// shortcode status
1355
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== false) {
1356
+			$sc_colour = 'green';
1357
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
1358
+		} else {
1359
+			$sc_colour = 'red';
1360
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1361
+		}
1362
+
1363
+		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1364
+			   . $pg_status
1365
+			   . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1366
+	}
1367
+
1368
+
1369
+	/**
1370
+	 * generates a dropdown of all parent pages - copied from WP core
1371
+	 *
1372
+	 * @param int $default
1373
+	 * @param int $parent
1374
+	 * @param int $level
1375
+	 */
1376
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0)
1377
+	{
1378
+		global $wpdb;
1379
+		$items = $wpdb->get_results(
1380
+			$wpdb->prepare(
1381
+				"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",
1382
+				$parent
1383
+			)
1384
+		);
1385
+
1386
+		if ($items) {
1387
+			foreach ($items as $item) {
1388
+				$pad = str_repeat('&nbsp;', $level * 3);
1389
+				if ($item->ID == $default) {
1390
+					$current = ' selected="selected"';
1391
+				} else {
1392
+					$current = '';
1393
+				}
1394
+
1395
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad "
1396
+					 . esc_html($item->post_title)
1397
+					 . "</option>";
1398
+				parent_dropdown($default, $item->ID, $level + 1);
1399
+			}
1400
+		}
1401
+	}
1402 1402
 }
Please login to merge, or discard this patch.
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -232,11 +232,11 @@  discard block
 block discarded – undo
232 232
             '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.',
233 233
             'event_espresso'
234 234
         );
235
-        EE_Registry::$i18n_js_strings['error_occurred']          = __(
235
+        EE_Registry::$i18n_js_strings['error_occurred'] = __(
236 236
             'An error occurred! Please refresh the page and try again.',
237 237
             'event_espresso'
238 238
         );
239
-        EE_Registry::$i18n_js_strings['confirm_delete_state']    = __(
239
+        EE_Registry::$i18n_js_strings['confirm_delete_state'] = __(
240 240
             'Are you sure you want to delete this State / Province?',
241 241
             'event_espresso'
242 242
         );
@@ -268,12 +268,12 @@  discard block
 block discarded – undo
268 268
         wp_enqueue_script('thickbox');
269 269
         wp_register_script(
270 270
             'organization_settings',
271
-            GEN_SET_ASSETS_URL . 'your_organization_settings.js',
271
+            GEN_SET_ASSETS_URL.'your_organization_settings.js',
272 272
             array('jquery', 'media-upload', 'thickbox'),
273 273
             EVENT_ESPRESSO_VERSION,
274 274
             true
275 275
         );
276
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
276
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
277 277
         wp_enqueue_script('organization_settings');
278 278
         wp_enqueue_style('organization-css');
279 279
         $confirm_image_delete = array(
@@ -294,12 +294,12 @@  discard block
 block discarded – undo
294 294
         //scripts
295 295
         wp_register_script(
296 296
             'gen_settings_countries',
297
-            GEN_SET_ASSETS_URL . 'gen_settings_countries.js',
297
+            GEN_SET_ASSETS_URL.'gen_settings_countries.js',
298 298
             array('ee_admin_js'),
299 299
             EVENT_ESPRESSO_VERSION,
300 300
             true
301 301
         );
302
-        wp_register_style('organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION);
302
+        wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
303 303
         wp_enqueue_script('gen_settings_countries');
304 304
         wp_enqueue_style('organization-css');
305 305
     }
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
         $this->_set_add_edit_form_tags('update_espresso_page_settings');
346 346
         $this->_set_publish_post_box_vars(null, false, false, null, false);
347 347
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
348
-            GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php',
348
+            GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php',
349 349
             $this->_template_args,
350 350
             true
351 351
         );
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
             EE_Registry::instance()->CFG->core,
378 378
             $this->_req_data
379 379
         );
380
-        $what                              = __('Critical Pages & Shortcodes', 'event_espresso');
380
+        $what = __('Critical Pages & Shortcodes', 'event_espresso');
381 381
         $this->_redirect_after_action(
382 382
             $this->_update_espresso_configuration(
383 383
                 $what,
@@ -407,7 +407,7 @@  discard block
 block discarded – undo
407 407
     protected function _your_organization_settings()
408 408
     {
409 409
 
410
-        $this->_template_args['site_license_key']       = isset(
410
+        $this->_template_args['site_license_key'] = isset(
411 411
             EE_Registry::instance()->NET_CFG->core->site_license_key
412 412
         )
413 413
             ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key')
@@ -511,7 +511,7 @@  discard block
 block discarded – undo
511 511
         add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
512 512
 
513 513
         //PUE verification stuff
514
-        $ver_option_key                                    = 'puvererr_' . basename(EE_PLUGIN_BASENAME);
514
+        $ver_option_key                                    = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
515 515
         $verify_fail                                       = get_option($ver_option_key);
516 516
         $this->_template_args['site_license_key_verified'] = $verify_fail
517 517
                                                              || ! empty($verify_fail)
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
         $this->_set_add_edit_form_tags('update_your_organization_settings');
525 525
         $this->_set_publish_post_box_vars(null, false, false, null, false);
526 526
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
527
-            GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php',
527
+            GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php',
528 528
             $this->_template_args,
529 529
             true
530 530
         );
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
         $this->_set_add_edit_form_tags('update_country_settings');
736 736
         $this->_set_publish_post_box_vars(null, false, false, null, false);
737 737
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
738
-            GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php',
738
+            GEN_SET_TEMPLATE_PATH.'countries_settings.template.php',
739 739
             $this->_template_args,
740 740
             true
741 741
         );
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
         $CNT_ISO = isset($this->_req_data['country'])
758 758
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
759 759
             : $CNT_ISO;
760
-        if (! $CNT_ISO) {
760
+        if ( ! $CNT_ISO) {
761 761
             return '';
762 762
         }
763 763
 
@@ -768,65 +768,65 @@  discard block
 block discarded – undo
768 768
         add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
769 769
         $country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
770 770
 
771
-        $country_input_types            = array(
771
+        $country_input_types = array(
772 772
             'CNT_active'      => array(
773 773
                 'type'             => 'RADIO_BTN',
774
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
774
+                'input_name'       => 'cntry['.$CNT_ISO.']',
775 775
                 'class'            => '',
776 776
                 'options'          => $this->_yes_no_values,
777 777
                 'use_desc_4_label' => true,
778 778
             ),
779 779
             'CNT_ISO'         => array(
780 780
                 'type'       => 'TEXT',
781
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
781
+                'input_name' => 'cntry['.$CNT_ISO.']',
782 782
                 'class'      => 'small-text',
783 783
             ),
784 784
             'CNT_ISO3'        => array(
785 785
                 'type'       => 'TEXT',
786
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
786
+                'input_name' => 'cntry['.$CNT_ISO.']',
787 787
                 'class'      => 'small-text',
788 788
             ),
789 789
             'RGN_ID'          => array(
790 790
                 'type'       => 'TEXT',
791
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
791
+                'input_name' => 'cntry['.$CNT_ISO.']',
792 792
                 'class'      => 'small-text',
793 793
             ),
794 794
             'CNT_name'        => array(
795 795
                 'type'       => 'TEXT',
796
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
796
+                'input_name' => 'cntry['.$CNT_ISO.']',
797 797
                 'class'      => 'regular-text',
798 798
             ),
799 799
             'CNT_cur_code'    => array(
800 800
                 'type'       => 'TEXT',
801
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
801
+                'input_name' => 'cntry['.$CNT_ISO.']',
802 802
                 'class'      => 'small-text',
803 803
             ),
804 804
             'CNT_cur_single'  => array(
805 805
                 'type'       => 'TEXT',
806
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
806
+                'input_name' => 'cntry['.$CNT_ISO.']',
807 807
                 'class'      => 'medium-text',
808 808
             ),
809 809
             'CNT_cur_plural'  => array(
810 810
                 'type'       => 'TEXT',
811
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
811
+                'input_name' => 'cntry['.$CNT_ISO.']',
812 812
                 'class'      => 'medium-text',
813 813
             ),
814 814
             'CNT_cur_sign'    => array(
815 815
                 'type'         => 'TEXT',
816
-                'input_name'   => 'cntry[' . $CNT_ISO . ']',
816
+                'input_name'   => 'cntry['.$CNT_ISO.']',
817 817
                 'class'        => 'small-text',
818 818
                 'htmlentities' => false,
819 819
             ),
820 820
             'CNT_cur_sign_b4' => array(
821 821
                 'type'             => 'RADIO_BTN',
822
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
822
+                'input_name'       => 'cntry['.$CNT_ISO.']',
823 823
                 'class'            => '',
824 824
                 'options'          => $this->_yes_no_values,
825 825
                 'use_desc_4_label' => true,
826 826
             ),
827 827
             'CNT_cur_dec_plc' => array(
828 828
                 'type'       => 'RADIO_BTN',
829
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
829
+                'input_name' => 'cntry['.$CNT_ISO.']',
830 830
                 'class'      => '',
831 831
                 'options'    => array(
832 832
                     array('id' => 0, 'text' => ''),
@@ -837,7 +837,7 @@  discard block
 block discarded – undo
837 837
             ),
838 838
             'CNT_cur_dec_mrk' => array(
839 839
                 'type'             => 'RADIO_BTN',
840
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
840
+                'input_name'       => 'cntry['.$CNT_ISO.']',
841 841
                 'class'            => '',
842 842
                 'options'          => array(
843 843
                     array(
@@ -850,7 +850,7 @@  discard block
 block discarded – undo
850 850
             ),
851 851
             'CNT_cur_thsnds'  => array(
852 852
                 'type'             => 'RADIO_BTN',
853
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
853
+                'input_name'       => 'cntry['.$CNT_ISO.']',
854 854
                 'class'            => '',
855 855
                 'options'          => array(
856 856
                     array(
@@ -863,12 +863,12 @@  discard block
 block discarded – undo
863 863
             ),
864 864
             'CNT_tel_code'    => array(
865 865
                 'type'       => 'TEXT',
866
-                'input_name' => 'cntry[' . $CNT_ISO . ']',
866
+                'input_name' => 'cntry['.$CNT_ISO.']',
867 867
                 'class'      => 'small-text',
868 868
             ),
869 869
             'CNT_is_EU'       => array(
870 870
                 'type'             => 'RADIO_BTN',
871
-                'input_name'       => 'cntry[' . $CNT_ISO . ']',
871
+                'input_name'       => 'cntry['.$CNT_ISO.']',
872 872
                 'class'            => '',
873 873
                 'options'          => $this->_yes_no_values,
874 874
                 'use_desc_4_label' => true,
@@ -878,8 +878,8 @@  discard block
 block discarded – undo
878 878
             $country,
879 879
             $country_input_types
880 880
         );
881
-        $country_details_settings       = EEH_Template::display_template(
882
-            GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php',
881
+        $country_details_settings = EEH_Template::display_template(
882
+            GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php',
883 883
             $this->_template_args,
884 884
             true
885 885
         );
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 
912 912
         $CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
913 913
 
914
-        if (! $CNT_ISO) {
914
+        if ( ! $CNT_ISO) {
915 915
             return '';
916 916
         }
917 917
         // for ajax
@@ -925,20 +925,20 @@  discard block
 block discarded – undo
925 925
             foreach ($states as $STA_ID => $state) {
926 926
                 if ($state instanceof EE_State) {
927 927
                     //STA_abbrev 	STA_name 	STA_active
928
-                    $state_input_types                                           = array(
928
+                    $state_input_types = array(
929 929
                         'STA_abbrev' => array(
930 930
                             'type'       => 'TEXT',
931
-                            'input_name' => 'states[' . $STA_ID . ']',
931
+                            'input_name' => 'states['.$STA_ID.']',
932 932
                             'class'      => 'mid-text',
933 933
                         ),
934 934
                         'STA_name'   => array(
935 935
                             'type'       => 'TEXT',
936
-                            'input_name' => 'states[' . $STA_ID . ']',
936
+                            'input_name' => 'states['.$STA_ID.']',
937 937
                             'class'      => 'regular-text',
938 938
                         ),
939 939
                         'STA_active' => array(
940 940
                             'type'             => 'RADIO_BTN',
941
-                            'input_name'       => 'states[' . $STA_ID . ']',
941
+                            'input_name'       => 'states['.$STA_ID.']',
942 942
                             'options'          => $this->_yes_no_values,
943 943
                             'use_desc_4_label' => true,
944 944
                         ),
@@ -948,7 +948,7 @@  discard block
 block discarded – undo
948 948
                             $state,
949 949
                             $state_input_types
950 950
                         );
951
-                    $query_args                                                  = array(
951
+                    $query_args = array(
952 952
                         'action'     => 'delete_state',
953 953
                         'STA_ID'     => $STA_ID,
954 954
                         'CNT_ISO'    => $CNT_ISO,
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
         );
972 972
 
973 973
         $state_details_settings = EEH_Template::display_template(
974
-            GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php',
974
+            GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php',
975 975
             $this->_template_args,
976 976
             true
977 977
         );
@@ -1005,7 +1005,7 @@  discard block
 block discarded – undo
1005 1005
         $CNT_ISO = isset($this->_req_data['CNT_ISO'])
1006 1006
             ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO']))
1007 1007
             : false;
1008
-        if (! $CNT_ISO) {
1008
+        if ( ! $CNT_ISO) {
1009 1009
             EE_Error::add_error(
1010 1010
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1011 1011
                 __FILE__,
@@ -1017,7 +1017,7 @@  discard block
 block discarded – undo
1017 1017
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1018 1018
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1019 1019
             : false;
1020
-        if (! $STA_abbrev) {
1020
+        if ( ! $STA_abbrev) {
1021 1021
             EE_Error::add_error(
1022 1022
                 __('No State ISO code or an invalid State ISO code was received.', 'event_espresso'),
1023 1023
                 __FILE__,
@@ -1029,7 +1029,7 @@  discard block
 block discarded – undo
1029 1029
         $STA_name = isset($this->_req_data['STA_name'])
1030 1030
             ? sanitize_text_field($this->_req_data['STA_name'])
1031 1031
             : false;
1032
-        if (! $STA_name) {
1032
+        if ( ! $STA_name) {
1033 1033
             EE_Error::add_error(
1034 1034
                 __('No State name or an invalid State name was received.', 'event_espresso'),
1035 1035
                 __FILE__,
@@ -1046,7 +1046,7 @@  discard block
 block discarded – undo
1046 1046
                 'STA_name'   => $STA_name,
1047 1047
                 'STA_active' => true,
1048 1048
             );
1049
-            $success       = EEM_State::instance()->insert($cols_n_values);
1049
+            $success = EEM_State::instance()->insert($cols_n_values);
1050 1050
             EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
1051 1051
         }
1052 1052
 
@@ -1077,7 +1077,7 @@  discard block
 block discarded – undo
1077 1077
         $STA_abbrev = isset($this->_req_data['STA_abbrev'])
1078 1078
             ? sanitize_text_field($this->_req_data['STA_abbrev'])
1079 1079
             : false;
1080
-        if (! $STA_ID) {
1080
+        if ( ! $STA_ID) {
1081 1081
             EE_Error::add_error(
1082 1082
                 __('No State ID or an invalid State ID was received.', 'event_espresso'),
1083 1083
                 __FILE__,
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
         $CNT_ISO = isset($this->_req_data['country'])
1127 1127
             ? strtoupper(sanitize_text_field($this->_req_data['country']))
1128 1128
             : false;
1129
-        if (! $CNT_ISO) {
1129
+        if ( ! $CNT_ISO) {
1130 1130
             EE_Error::add_error(
1131 1131
                 __('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'),
1132 1132
                 __FILE__,
@@ -1203,7 +1203,7 @@  discard block
 block discarded – undo
1203 1203
                     'CNT_ISO'    => $CNT_ISO,
1204 1204
                     'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
1205 1205
                     'STA_name'   => sanitize_text_field($state['STA_name']),
1206
-                    'STA_active' => (bool)absint($state['STA_active']),
1206
+                    'STA_active' => (bool) absint($state['STA_active']),
1207 1207
                 );
1208 1208
                 // where values
1209 1209
                 $where_cols_n_values = array(array('STA_ID' => $STA_ID));
@@ -1254,7 +1254,7 @@  discard block
 block discarded – undo
1254 1254
         return '
1255 1255
 			<tr>
1256 1256
 				<th>
1257
-					' . $label . '
1257
+					' . $label.'
1258 1258
 				</th>';
1259 1259
     }
1260 1260
 
@@ -1270,7 +1270,7 @@  discard block
 block discarded – undo
1270 1270
     {
1271 1271
         return '
1272 1272
 				<td class="general-settings-country-input-td">
1273
-					' . $input . '
1273
+					' . $input.'
1274 1274
 				</td>
1275 1275
 			</tr>';
1276 1276
     }
@@ -1301,7 +1301,7 @@  discard block
 block discarded – undo
1301 1301
     {
1302 1302
         return '
1303 1303
 				<td class="general-settings-country-state-input-td">
1304
-					' . $input . '
1304
+					' . $input.'
1305 1305
 				</td>';
1306 1306
     }
1307 1307
 
@@ -1327,7 +1327,7 @@  discard block
 block discarded – undo
1327 1327
                  . __('Edit', 'event_espresso')
1328 1328
                  . '</a>';
1329 1329
         $links .= ' &nbsp;|&nbsp; ';
1330
-        $links .= '<a href="' . get_permalink($ee_page_id) . '" >' . __('View', 'event_espresso') . '</a>';
1330
+        $links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
1331 1331
 
1332 1332
         return $links;
1333 1333
     }
@@ -1360,9 +1360,9 @@  discard block
 block discarded – undo
1360 1360
             $sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
1361 1361
         }
1362 1362
 
1363
-        return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>'
1363
+        return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'
1364 1364
                . $pg_status
1365
-               . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
1365
+               . '</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
1366 1366
     }
1367 1367
 
1368 1368
 
Please login to merge, or discard this patch.