Completed
Branch decaf-fixes/more-request-fixes (02d799)
by
unknown
07:01 queued 05:08
created
modules/gateways/Invoice/lib/invoice_functions.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -13,35 +13,35 @@  discard block
 block discarded – undo
13 13
  */
14 14
 function espresso_invoice_template_files($class_file)
15 15
 {
16
-    // read our template dir and build an array of files
17
-    $directory_handle = opendir(dirname($class_file) . '/lib/templates/css/');
18
-
19
-    /** @var RequestInterface $request */
20
-    $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
21
-
22
-    $files = [];
23
-    if ($directory_handle) { //if we managed to open the directory
24
-        // loop through all of the files
25
-        while (false !== ($fname = readdir($directory_handle))) {
26
-            // if the file is not this file, and does not start with a '.' or '..',
27
-            // then store it for later display
28
-            if ($fname !== '.'
29
-                && $fname !== 'index.php'
30
-                && $fname !== '..'
31
-                && $fname !== '.svn'
32
-                && $fname !== basename($request->getServerParam('PHP_SELF'))
33
-                && $fname !== '.DS_Store'
34
-                && $fname !== 'images'
35
-                && $fname !== 'print') {
36
-                // store the filename
37
-                $files[] = $fname;
38
-            }
39
-        }
40
-        // close the directory
41
-        closedir($directory_handle);
42
-    }
43
-
44
-    return $files;
16
+	// read our template dir and build an array of files
17
+	$directory_handle = opendir(dirname($class_file) . '/lib/templates/css/');
18
+
19
+	/** @var RequestInterface $request */
20
+	$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
21
+
22
+	$files = [];
23
+	if ($directory_handle) { //if we managed to open the directory
24
+		// loop through all of the files
25
+		while (false !== ($fname = readdir($directory_handle))) {
26
+			// if the file is not this file, and does not start with a '.' or '..',
27
+			// then store it for later display
28
+			if ($fname !== '.'
29
+				&& $fname !== 'index.php'
30
+				&& $fname !== '..'
31
+				&& $fname !== '.svn'
32
+				&& $fname !== basename($request->getServerParam('PHP_SELF'))
33
+				&& $fname !== '.DS_Store'
34
+				&& $fname !== 'images'
35
+				&& $fname !== 'print') {
36
+				// store the filename
37
+				$files[] = $fname;
38
+			}
39
+		}
40
+		// close the directory
41
+		closedir($directory_handle);
42
+	}
43
+
44
+	return $files;
45 45
 }
46 46
 
47 47
 
@@ -55,9 +55,9 @@  discard block
 block discarded – undo
55 55
  */
56 56
 function espresso_invoice_is_selected($input_item, $selected = '')
57 57
 {
58
-    if ($input_item === $selected) {
59
-        return 'selected="selected"';
60
-    } else {
61
-        return '';
62
-    }
58
+	if ($input_item === $selected) {
59
+		return 'selected="selected"';
60
+	} else {
61
+		return '';
62
+	}
63 63
 }
64 64
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 function espresso_invoice_template_files($class_file)
15 15
 {
16 16
     // read our template dir and build an array of files
17
-    $directory_handle = opendir(dirname($class_file) . '/lib/templates/css/');
17
+    $directory_handle = opendir(dirname($class_file).'/lib/templates/css/');
18 18
 
19 19
     /** @var RequestInterface $request */
20 20
     $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
Please login to merge, or discard this patch.
modules/batch/EED_Batch.module.php 2 patches
Indentation   +397 added lines, -397 removed lines patch added patch discarded remove patch
@@ -27,401 +27,401 @@
 block discarded – undo
27 27
 class EED_Batch extends EED_Module
28 28
 {
29 29
 
30
-    /**
31
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
32
-     * processes data only
33
-     */
34
-    const batch_job = 'job';
35
-
36
-    /**
37
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
38
-     * produces a file for download
39
-     */
40
-    const batch_file_job = 'file';
41
-
42
-    /**
43
-     * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT
44
-     * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ]
45
-     * at all
46
-     */
47
-    const batch_not_job = 'none';
48
-
49
-    /**
50
-     *
51
-     * @var string 'file', or 'job', or false to indicate its not a batch request at all
52
-     */
53
-    protected $_batch_request_type = null;
54
-
55
-    /**
56
-     * Because we want to use the response in both the localized JS and in the body
57
-     * we need to make this response available between method calls
58
-     *
59
-     * @var JobStepResponse
60
-     */
61
-    protected $_job_step_response = null;
62
-
63
-    /**
64
-     * @var LoaderInterface
65
-     */
66
-    protected $loader;
67
-
68
-
69
-    /**
70
-     * Gets the batch instance
71
-     *
72
-     * @return  EED_Module|EED_Batch
73
-     * @throws EE_Error
74
-     * @throws ReflectionException
75
-     */
76
-    public static function instance()
77
-    {
78
-        return parent::get_instance(__CLASS__);
79
-    }
80
-
81
-
82
-    /**
83
-     * Sets hooks to enable batch jobs on the frontend. Disabled by default
84
-     * because it's an attack vector and there are currently no implementations
85
-     *
86
-     * @throws EE_Error
87
-     * @throws ReflectionException
88
-     */
89
-    public static function set_hooks()
90
-    {
91
-        // because this is a possible attack vector, let's have this disabled until
92
-        // we at least have a real use for it on the frontend
93
-        if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
94
-            add_action('wp_enqueue_scripts', [self::instance(), 'enqueue_scripts']);
95
-            add_filter('template_include', [self::instance(), 'override_template'], 99);
96
-        }
97
-    }
98
-
99
-
100
-    /**
101
-     * Initializes some hooks for the admin in order to run batch jobs
102
-     *
103
-     * @throws EE_Error
104
-     * @throws ReflectionException
105
-     */
106
-    public static function set_hooks_admin()
107
-    {
108
-        add_action('admin_menu', [self::instance(), 'register_admin_pages']);
109
-        add_action('admin_enqueue_scripts', [self::instance(), 'enqueue_scripts']);
110
-
111
-        // ajax
112
-        add_action('wp_ajax_espresso_batch_continue', [self::instance(), 'batch_continue']);
113
-        add_action('wp_ajax_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']);
114
-        add_action('wp_ajax_nopriv_espresso_batch_continue', [self::instance(), 'batch_continue']);
115
-        add_action('wp_ajax_nopriv_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']);
116
-    }
117
-
118
-
119
-    /**
120
-     * @return LoaderInterface
121
-     * @throws InvalidArgumentException
122
-     * @throws InvalidDataTypeException
123
-     * @throws InvalidInterfaceException
124
-     * @since 4.9.80.p
125
-     */
126
-    protected function getLoader()
127
-    {
128
-        if (! $this->loader instanceof LoaderInterface) {
129
-            $this->loader = LoaderFactory::getLoader();
130
-        }
131
-        return $this->loader;
132
-    }
133
-
134
-
135
-    /**
136
-     * Enqueues batch scripts on the frontend or admin, and creates a job
137
-     */
138
-    public function enqueue_scripts()
139
-    {
140
-        $request = EED_Batch::getRequest();
141
-        if (
142
-            $request->getRequestParam('espresso_batch')
143
-            || $request->getRequestParam('page') === 'espresso_batch'
144
-        ) {
145
-            if (
146
-                ! $request->requestParamIsSet('default_nonce')
147
-                || ! wp_verify_nonce($request->getRequestParam('default_nonce'), 'default_nonce')
148
-            ) {
149
-                wp_die(
150
-                    esc_html__(
151
-                        'The link you clicked to start the batch job has expired. Please go back and refresh the previous page.',
152
-                        'event_espresso'
153
-                    )
154
-                );
155
-            }
156
-            switch ($this->batch_request_type()) {
157
-                case self::batch_job:
158
-                    $this->enqueue_scripts_styles_batch_create();
159
-                    break;
160
-                case self::batch_file_job:
161
-                    $this->enqueue_scripts_styles_batch_file_create();
162
-                    break;
163
-            }
164
-        }
165
-    }
166
-
167
-
168
-    /**
169
-     * Create a batch job, enqueues a script to run it, and localizes some data for it
170
-     */
171
-    public function enqueue_scripts_styles_batch_create()
172
-    {
173
-        $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
174
-        wp_enqueue_script(
175
-            'batch_runner_init',
176
-            BATCH_URL . 'assets/batch_runner_init.js',
177
-            ['batch_runner'],
178
-            EVENT_ESPRESSO_VERSION,
179
-            true
180
-        );
181
-        wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
182
-        wp_localize_script(
183
-            'batch_runner_init',
184
-            'ee_job_i18n',
185
-            [
186
-                'return_url' => EED_Batch::getRequest()->getRequestParam('return_url', '', 'url'),
187
-            ]
188
-        );
189
-    }
190
-
191
-
192
-    /**
193
-     * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it
194
-     */
195
-    public function enqueue_scripts_styles_batch_file_create()
196
-    {
197
-        $return_url = EED_Batch::getRequest()->getRequestParam('return_url', '', 'url');
198
-        // creates a job based on the request variable
199
-        $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
200
-        wp_enqueue_script(
201
-            'batch_file_runner_init',
202
-            BATCH_URL . 'assets/batch_file_runner_init.js',
203
-            ['batch_runner'],
204
-            EVENT_ESPRESSO_VERSION,
205
-            true
206
-        );
207
-        wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
208
-        wp_localize_script(
209
-            'batch_file_runner_init',
210
-            'ee_job_i18n',
211
-            [
212
-                'download_and_redirecting' => sprintf(
213
-                    wp_strip_all_tags(
214
-                        __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso')
215
-                    ),
216
-                    '<a href="' . $return_url . '">',
217
-                    '</a>'
218
-                ),
219
-                'return_url'               => $return_url,
220
-            ]
221
-        );
222
-    }
223
-
224
-
225
-    /**
226
-     * Enqueues scripts and styles common to any batch job, and creates
227
-     * a job from the request data, and stores the response in the
228
-     * $this->_job_step_response property
229
-     *
230
-     * @return JobStepResponse
231
-     */
232
-    protected function _enqueue_batch_job_scripts_and_styles_and_start_job()
233
-    {
234
-        $request = EED_Batch::getRequest();
235
-        // just copy the bits of EE admin's eei18n that we need in the JS
236
-        EE_Registry::$i18n_js_strings['batchJobError'] = __(
237
-            'An error occurred and the job has been stopped. Please refresh the page to try again.',
238
-            'event_espresso'
239
-        );
240
-        wp_register_script(
241
-            'progress_bar',
242
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
243
-            ['jquery'],
244
-            EVENT_ESPRESSO_VERSION,
245
-            true
246
-        );
247
-        wp_enqueue_style(
248
-            'progress_bar',
249
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
250
-            [],
251
-            EVENT_ESPRESSO_VERSION
252
-        );
253
-        wp_enqueue_script(
254
-            'batch_runner',
255
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
256
-            ['progress_bar', CoreAssetManager::JS_HANDLE_CORE],
257
-            EVENT_ESPRESSO_VERSION,
258
-            true
259
-        );
260
-        $job_handler_classname = stripslashes($request->getRequestParam('job_handler'));
261
-        $request_data          = $request->requestParams();
262
-        $request_data          = array_diff_key(
263
-            $request_data,
264
-            array_flip(['action', 'page', 'ee', 'batch'])
265
-        );
266
-        $batch_runner          = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
267
-        // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
268
-        $job_response = $batch_runner->create_job($job_handler_classname, $request_data);
269
-        // remember the response for later. We need it to display the page body
270
-        $this->_job_step_response = $job_response;
271
-        return $job_response;
272
-    }
273
-
274
-
275
-    /**
276
-     * If we are doing a frontend batch job, this makes it so WP shows our template's HTML
277
-     *
278
-     * @param string $template
279
-     * @return string
280
-     */
281
-    public function override_template($template)
282
-    {
283
-        $request = EED_Batch::getRequest();
284
-        if ($request->requestParamIsSet('batch') && $request->requestParamIsSet('espresso_batch')) {
285
-            return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html';
286
-        }
287
-        return $template;
288
-    }
289
-
290
-
291
-    /**
292
-     * Adds an admin page which doesn't appear in the admin menu
293
-     *
294
-     * @throws EE_Error
295
-     * @throws ReflectionException
296
-     */
297
-    public function register_admin_pages()
298
-    {
299
-        add_submenu_page(
300
-            '',                                        // parent slug. we don't want this to actually appear in the menu
301
-            esc_html__('Batch Job', 'event_espresso'), // page title
302
-            'n/a',                                     // menu title
303
-            'read',                                    // we want this page to actually be accessible to anyone,
304
-            'espresso_batch',                          // menu slug
305
-            [self::instance(), 'show_admin_page']
306
-        );
307
-    }
308
-
309
-
310
-    /**
311
-     * Renders the admin page, after most of the work was already done during enqueuing scripts
312
-     * of creating the job and localizing some data
313
-     */
314
-    public function show_admin_page()
315
-    {
316
-        echo EEH_Template::locate_template(
317
-            EE_MODULES . 'batch/templates/batch_wrapper.template.html',
318
-            ['batch_request_type' => $this->batch_request_type()]
319
-        );
320
-    }
321
-
322
-
323
-    /**
324
-     * Receives ajax calls for continuing a job
325
-     */
326
-    public function batch_continue()
327
-    {
328
-        $job_id       = EED_Batch::getRequest()->getRequestParam('job_id');
329
-        $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
330
-        $response_obj = $batch_runner->continue_job($job_id);
331
-        $this->_return_json($response_obj->to_array());
332
-    }
333
-
334
-
335
-    /**
336
-     * Receives the ajax call to cleanup a job
337
-     *
338
-     * @return void
339
-     */
340
-    public function batch_cleanup()
341
-    {
342
-        $job_id       = EED_Batch::getRequest()->getRequestParam('job_id');
343
-        $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
344
-        $response_obj = $batch_runner->cleanup_job($job_id);
345
-        $this->_return_json($response_obj->to_array());
346
-    }
347
-
348
-
349
-    /**
350
-     * Returns a json response
351
-     *
352
-     * @param array $data The data we want to send echo via in the JSON response's "data" element
353
-     *
354
-     * The returned json object is created from an array in the following format:
355
-     * array(
356
-     *    'notices' => '', // - contains any EE_Error formatted notices
357
-     *    'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
358
-     *    We're also going to include the template args with every package (so js can pick out any specific template
359
-     *    args that might be included in here)
360
-     *    'isEEajax' => true,//indicates this is a response from EE
361
-     * )
362
-     */
363
-    protected function _return_json($data)
364
-    {
365
-        $json = [
366
-            'notices'  => EE_Error::get_notices(),
367
-            'data'     => $data,
368
-            'isEEajax' => true
369
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
370
-        ];
371
-
372
-
373
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
374
-        if (null === error_get_last() || ! headers_sent()) {
375
-            header('Content-Type: application/json; charset=UTF-8');
376
-        }
377
-        echo wp_json_encode($json);
378
-        exit();
379
-    }
380
-
381
-
382
-    /**
383
-     * Gets the job step response which was done during the enqueuing of scripts
384
-     *
385
-     * @return JobStepResponse
386
-     */
387
-    public function job_step_response()
388
-    {
389
-        return $this->_job_step_response;
390
-    }
391
-
392
-
393
-    /**
394
-     * Gets the batch request type indicated in the current request
395
-     *
396
-     * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
397
-     */
398
-    public function batch_request_type()
399
-    {
400
-        $request = EED_Batch::getRequest();
401
-        if ($this->_batch_request_type === null) {
402
-            $batch = $request->getRequestParam('batch');
403
-            switch ($batch) {
404
-                case self::batch_job:
405
-                    $this->_batch_request_type = self::batch_job;
406
-                    break;
407
-                case self::batch_file_job:
408
-                    $this->_batch_request_type = self::batch_file_job;
409
-                    break;
410
-                default:
411
-                    // if we didn't find that it was a batch request, indicate it wasn't
412
-                    $this->_batch_request_type = self::batch_not_job;
413
-            }
414
-        }
415
-        return $this->_batch_request_type;
416
-    }
417
-
418
-
419
-    /**
420
-     * Unnecessary
421
-     *
422
-     * @param WP $WP
423
-     */
424
-    public function run($WP)
425
-    {
426
-    }
30
+	/**
31
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
32
+	 * processes data only
33
+	 */
34
+	const batch_job = 'job';
35
+
36
+	/**
37
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates to run a job that
38
+	 * produces a file for download
39
+	 */
40
+	const batch_file_job = 'file';
41
+
42
+	/**
43
+	 * Possibly value for $_REQUEST[ 'batch' ]. Indicates this request is NOT
44
+	 * for a batch job. It's the same as not providing the $_REQUEST[ 'batch' ]
45
+	 * at all
46
+	 */
47
+	const batch_not_job = 'none';
48
+
49
+	/**
50
+	 *
51
+	 * @var string 'file', or 'job', or false to indicate its not a batch request at all
52
+	 */
53
+	protected $_batch_request_type = null;
54
+
55
+	/**
56
+	 * Because we want to use the response in both the localized JS and in the body
57
+	 * we need to make this response available between method calls
58
+	 *
59
+	 * @var JobStepResponse
60
+	 */
61
+	protected $_job_step_response = null;
62
+
63
+	/**
64
+	 * @var LoaderInterface
65
+	 */
66
+	protected $loader;
67
+
68
+
69
+	/**
70
+	 * Gets the batch instance
71
+	 *
72
+	 * @return  EED_Module|EED_Batch
73
+	 * @throws EE_Error
74
+	 * @throws ReflectionException
75
+	 */
76
+	public static function instance()
77
+	{
78
+		return parent::get_instance(__CLASS__);
79
+	}
80
+
81
+
82
+	/**
83
+	 * Sets hooks to enable batch jobs on the frontend. Disabled by default
84
+	 * because it's an attack vector and there are currently no implementations
85
+	 *
86
+	 * @throws EE_Error
87
+	 * @throws ReflectionException
88
+	 */
89
+	public static function set_hooks()
90
+	{
91
+		// because this is a possible attack vector, let's have this disabled until
92
+		// we at least have a real use for it on the frontend
93
+		if (apply_filters('FHEE__EED_Batch__set_hooks__enable_frontend_batch', false)) {
94
+			add_action('wp_enqueue_scripts', [self::instance(), 'enqueue_scripts']);
95
+			add_filter('template_include', [self::instance(), 'override_template'], 99);
96
+		}
97
+	}
98
+
99
+
100
+	/**
101
+	 * Initializes some hooks for the admin in order to run batch jobs
102
+	 *
103
+	 * @throws EE_Error
104
+	 * @throws ReflectionException
105
+	 */
106
+	public static function set_hooks_admin()
107
+	{
108
+		add_action('admin_menu', [self::instance(), 'register_admin_pages']);
109
+		add_action('admin_enqueue_scripts', [self::instance(), 'enqueue_scripts']);
110
+
111
+		// ajax
112
+		add_action('wp_ajax_espresso_batch_continue', [self::instance(), 'batch_continue']);
113
+		add_action('wp_ajax_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']);
114
+		add_action('wp_ajax_nopriv_espresso_batch_continue', [self::instance(), 'batch_continue']);
115
+		add_action('wp_ajax_nopriv_espresso_batch_cleanup', [self::instance(), 'batch_cleanup']);
116
+	}
117
+
118
+
119
+	/**
120
+	 * @return LoaderInterface
121
+	 * @throws InvalidArgumentException
122
+	 * @throws InvalidDataTypeException
123
+	 * @throws InvalidInterfaceException
124
+	 * @since 4.9.80.p
125
+	 */
126
+	protected function getLoader()
127
+	{
128
+		if (! $this->loader instanceof LoaderInterface) {
129
+			$this->loader = LoaderFactory::getLoader();
130
+		}
131
+		return $this->loader;
132
+	}
133
+
134
+
135
+	/**
136
+	 * Enqueues batch scripts on the frontend or admin, and creates a job
137
+	 */
138
+	public function enqueue_scripts()
139
+	{
140
+		$request = EED_Batch::getRequest();
141
+		if (
142
+			$request->getRequestParam('espresso_batch')
143
+			|| $request->getRequestParam('page') === 'espresso_batch'
144
+		) {
145
+			if (
146
+				! $request->requestParamIsSet('default_nonce')
147
+				|| ! wp_verify_nonce($request->getRequestParam('default_nonce'), 'default_nonce')
148
+			) {
149
+				wp_die(
150
+					esc_html__(
151
+						'The link you clicked to start the batch job has expired. Please go back and refresh the previous page.',
152
+						'event_espresso'
153
+					)
154
+				);
155
+			}
156
+			switch ($this->batch_request_type()) {
157
+				case self::batch_job:
158
+					$this->enqueue_scripts_styles_batch_create();
159
+					break;
160
+				case self::batch_file_job:
161
+					$this->enqueue_scripts_styles_batch_file_create();
162
+					break;
163
+			}
164
+		}
165
+	}
166
+
167
+
168
+	/**
169
+	 * Create a batch job, enqueues a script to run it, and localizes some data for it
170
+	 */
171
+	public function enqueue_scripts_styles_batch_create()
172
+	{
173
+		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
174
+		wp_enqueue_script(
175
+			'batch_runner_init',
176
+			BATCH_URL . 'assets/batch_runner_init.js',
177
+			['batch_runner'],
178
+			EVENT_ESPRESSO_VERSION,
179
+			true
180
+		);
181
+		wp_localize_script('batch_runner_init', 'ee_job_response', $job_response->to_array());
182
+		wp_localize_script(
183
+			'batch_runner_init',
184
+			'ee_job_i18n',
185
+			[
186
+				'return_url' => EED_Batch::getRequest()->getRequestParam('return_url', '', 'url'),
187
+			]
188
+		);
189
+	}
190
+
191
+
192
+	/**
193
+	 * Creates a batch job which will download a file, enqueues a script to run the job, and localizes some data for it
194
+	 */
195
+	public function enqueue_scripts_styles_batch_file_create()
196
+	{
197
+		$return_url = EED_Batch::getRequest()->getRequestParam('return_url', '', 'url');
198
+		// creates a job based on the request variable
199
+		$job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
200
+		wp_enqueue_script(
201
+			'batch_file_runner_init',
202
+			BATCH_URL . 'assets/batch_file_runner_init.js',
203
+			['batch_runner'],
204
+			EVENT_ESPRESSO_VERSION,
205
+			true
206
+		);
207
+		wp_localize_script('batch_file_runner_init', 'ee_job_response', $job_response->to_array());
208
+		wp_localize_script(
209
+			'batch_file_runner_init',
210
+			'ee_job_i18n',
211
+			[
212
+				'download_and_redirecting' => sprintf(
213
+					wp_strip_all_tags(
214
+						__('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso')
215
+					),
216
+					'<a href="' . $return_url . '">',
217
+					'</a>'
218
+				),
219
+				'return_url'               => $return_url,
220
+			]
221
+		);
222
+	}
223
+
224
+
225
+	/**
226
+	 * Enqueues scripts and styles common to any batch job, and creates
227
+	 * a job from the request data, and stores the response in the
228
+	 * $this->_job_step_response property
229
+	 *
230
+	 * @return JobStepResponse
231
+	 */
232
+	protected function _enqueue_batch_job_scripts_and_styles_and_start_job()
233
+	{
234
+		$request = EED_Batch::getRequest();
235
+		// just copy the bits of EE admin's eei18n that we need in the JS
236
+		EE_Registry::$i18n_js_strings['batchJobError'] = __(
237
+			'An error occurred and the job has been stopped. Please refresh the page to try again.',
238
+			'event_espresso'
239
+		);
240
+		wp_register_script(
241
+			'progress_bar',
242
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
243
+			['jquery'],
244
+			EVENT_ESPRESSO_VERSION,
245
+			true
246
+		);
247
+		wp_enqueue_style(
248
+			'progress_bar',
249
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
250
+			[],
251
+			EVENT_ESPRESSO_VERSION
252
+		);
253
+		wp_enqueue_script(
254
+			'batch_runner',
255
+			EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
256
+			['progress_bar', CoreAssetManager::JS_HANDLE_CORE],
257
+			EVENT_ESPRESSO_VERSION,
258
+			true
259
+		);
260
+		$job_handler_classname = stripslashes($request->getRequestParam('job_handler'));
261
+		$request_data          = $request->requestParams();
262
+		$request_data          = array_diff_key(
263
+			$request_data,
264
+			array_flip(['action', 'page', 'ee', 'batch'])
265
+		);
266
+		$batch_runner          = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
267
+		// eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
268
+		$job_response = $batch_runner->create_job($job_handler_classname, $request_data);
269
+		// remember the response for later. We need it to display the page body
270
+		$this->_job_step_response = $job_response;
271
+		return $job_response;
272
+	}
273
+
274
+
275
+	/**
276
+	 * If we are doing a frontend batch job, this makes it so WP shows our template's HTML
277
+	 *
278
+	 * @param string $template
279
+	 * @return string
280
+	 */
281
+	public function override_template($template)
282
+	{
283
+		$request = EED_Batch::getRequest();
284
+		if ($request->requestParamIsSet('batch') && $request->requestParamIsSet('espresso_batch')) {
285
+			return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html';
286
+		}
287
+		return $template;
288
+	}
289
+
290
+
291
+	/**
292
+	 * Adds an admin page which doesn't appear in the admin menu
293
+	 *
294
+	 * @throws EE_Error
295
+	 * @throws ReflectionException
296
+	 */
297
+	public function register_admin_pages()
298
+	{
299
+		add_submenu_page(
300
+			'',                                        // parent slug. we don't want this to actually appear in the menu
301
+			esc_html__('Batch Job', 'event_espresso'), // page title
302
+			'n/a',                                     // menu title
303
+			'read',                                    // we want this page to actually be accessible to anyone,
304
+			'espresso_batch',                          // menu slug
305
+			[self::instance(), 'show_admin_page']
306
+		);
307
+	}
308
+
309
+
310
+	/**
311
+	 * Renders the admin page, after most of the work was already done during enqueuing scripts
312
+	 * of creating the job and localizing some data
313
+	 */
314
+	public function show_admin_page()
315
+	{
316
+		echo EEH_Template::locate_template(
317
+			EE_MODULES . 'batch/templates/batch_wrapper.template.html',
318
+			['batch_request_type' => $this->batch_request_type()]
319
+		);
320
+	}
321
+
322
+
323
+	/**
324
+	 * Receives ajax calls for continuing a job
325
+	 */
326
+	public function batch_continue()
327
+	{
328
+		$job_id       = EED_Batch::getRequest()->getRequestParam('job_id');
329
+		$batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
330
+		$response_obj = $batch_runner->continue_job($job_id);
331
+		$this->_return_json($response_obj->to_array());
332
+	}
333
+
334
+
335
+	/**
336
+	 * Receives the ajax call to cleanup a job
337
+	 *
338
+	 * @return void
339
+	 */
340
+	public function batch_cleanup()
341
+	{
342
+		$job_id       = EED_Batch::getRequest()->getRequestParam('job_id');
343
+		$batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
344
+		$response_obj = $batch_runner->cleanup_job($job_id);
345
+		$this->_return_json($response_obj->to_array());
346
+	}
347
+
348
+
349
+	/**
350
+	 * Returns a json response
351
+	 *
352
+	 * @param array $data The data we want to send echo via in the JSON response's "data" element
353
+	 *
354
+	 * The returned json object is created from an array in the following format:
355
+	 * array(
356
+	 *    'notices' => '', // - contains any EE_Error formatted notices
357
+	 *    'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
358
+	 *    We're also going to include the template args with every package (so js can pick out any specific template
359
+	 *    args that might be included in here)
360
+	 *    'isEEajax' => true,//indicates this is a response from EE
361
+	 * )
362
+	 */
363
+	protected function _return_json($data)
364
+	{
365
+		$json = [
366
+			'notices'  => EE_Error::get_notices(),
367
+			'data'     => $data,
368
+			'isEEajax' => true
369
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
370
+		];
371
+
372
+
373
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
374
+		if (null === error_get_last() || ! headers_sent()) {
375
+			header('Content-Type: application/json; charset=UTF-8');
376
+		}
377
+		echo wp_json_encode($json);
378
+		exit();
379
+	}
380
+
381
+
382
+	/**
383
+	 * Gets the job step response which was done during the enqueuing of scripts
384
+	 *
385
+	 * @return JobStepResponse
386
+	 */
387
+	public function job_step_response()
388
+	{
389
+		return $this->_job_step_response;
390
+	}
391
+
392
+
393
+	/**
394
+	 * Gets the batch request type indicated in the current request
395
+	 *
396
+	 * @return string: EED_Batch::batch_job, EED_Batch::batch_file_job, EED_Batch::batch_not_job
397
+	 */
398
+	public function batch_request_type()
399
+	{
400
+		$request = EED_Batch::getRequest();
401
+		if ($this->_batch_request_type === null) {
402
+			$batch = $request->getRequestParam('batch');
403
+			switch ($batch) {
404
+				case self::batch_job:
405
+					$this->_batch_request_type = self::batch_job;
406
+					break;
407
+				case self::batch_file_job:
408
+					$this->_batch_request_type = self::batch_file_job;
409
+					break;
410
+				default:
411
+					// if we didn't find that it was a batch request, indicate it wasn't
412
+					$this->_batch_request_type = self::batch_not_job;
413
+			}
414
+		}
415
+		return $this->_batch_request_type;
416
+	}
417
+
418
+
419
+	/**
420
+	 * Unnecessary
421
+	 *
422
+	 * @param WP $WP
423
+	 */
424
+	public function run($WP)
425
+	{
426
+	}
427 427
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
      */
126 126
     protected function getLoader()
127 127
     {
128
-        if (! $this->loader instanceof LoaderInterface) {
128
+        if ( ! $this->loader instanceof LoaderInterface) {
129 129
             $this->loader = LoaderFactory::getLoader();
130 130
         }
131 131
         return $this->loader;
@@ -173,7 +173,7 @@  discard block
 block discarded – undo
173 173
         $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
174 174
         wp_enqueue_script(
175 175
             'batch_runner_init',
176
-            BATCH_URL . 'assets/batch_runner_init.js',
176
+            BATCH_URL.'assets/batch_runner_init.js',
177 177
             ['batch_runner'],
178 178
             EVENT_ESPRESSO_VERSION,
179 179
             true
@@ -199,7 +199,7 @@  discard block
 block discarded – undo
199 199
         $job_response = $this->_enqueue_batch_job_scripts_and_styles_and_start_job();
200 200
         wp_enqueue_script(
201 201
             'batch_file_runner_init',
202
-            BATCH_URL . 'assets/batch_file_runner_init.js',
202
+            BATCH_URL.'assets/batch_file_runner_init.js',
203 203
             ['batch_runner'],
204 204
             EVENT_ESPRESSO_VERSION,
205 205
             true
@@ -213,7 +213,7 @@  discard block
 block discarded – undo
213 213
                     wp_strip_all_tags(
214 214
                         __('File Generation complete. Downloading, and %1$sredirecting%2$s...', 'event_espresso')
215 215
                     ),
216
-                    '<a href="' . $return_url . '">',
216
+                    '<a href="'.$return_url.'">',
217 217
                     '</a>'
218 218
                 ),
219 219
                 'return_url'               => $return_url,
@@ -239,20 +239,20 @@  discard block
 block discarded – undo
239 239
         );
240 240
         wp_register_script(
241 241
             'progress_bar',
242
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.js',
242
+            EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.js',
243 243
             ['jquery'],
244 244
             EVENT_ESPRESSO_VERSION,
245 245
             true
246 246
         );
247 247
         wp_enqueue_style(
248 248
             'progress_bar',
249
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/progress_bar.css',
249
+            EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/progress_bar.css',
250 250
             [],
251 251
             EVENT_ESPRESSO_VERSION
252 252
         );
253 253
         wp_enqueue_script(
254 254
             'batch_runner',
255
-            EE_PLUGIN_DIR_URL . 'core/libraries/batch/Assets/batch_runner.js',
255
+            EE_PLUGIN_DIR_URL.'core/libraries/batch/Assets/batch_runner.js',
256 256
             ['progress_bar', CoreAssetManager::JS_HANDLE_CORE],
257 257
             EVENT_ESPRESSO_VERSION,
258 258
             true
@@ -263,7 +263,7 @@  discard block
 block discarded – undo
263 263
             $request_data,
264 264
             array_flip(['action', 'page', 'ee', 'batch'])
265 265
         );
266
-        $batch_runner          = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
266
+        $batch_runner = $this->getLoader()->getShared('EventEspressoBatchRequest\BatchRequestProcessor');
267 267
         // eg 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport'
268 268
         $job_response = $batch_runner->create_job($job_handler_classname, $request_data);
269 269
         // remember the response for later. We need it to display the page body
@@ -282,7 +282,7 @@  discard block
 block discarded – undo
282 282
     {
283 283
         $request = EED_Batch::getRequest();
284 284
         if ($request->requestParamIsSet('batch') && $request->requestParamIsSet('espresso_batch')) {
285
-            return EE_MODULES . 'batch/templates/batch_frontend_wrapper.template.html';
285
+            return EE_MODULES.'batch/templates/batch_frontend_wrapper.template.html';
286 286
         }
287 287
         return $template;
288 288
     }
@@ -297,11 +297,11 @@  discard block
 block discarded – undo
297 297
     public function register_admin_pages()
298 298
     {
299 299
         add_submenu_page(
300
-            '',                                        // parent slug. we don't want this to actually appear in the menu
300
+            '', // parent slug. we don't want this to actually appear in the menu
301 301
             esc_html__('Batch Job', 'event_espresso'), // page title
302
-            'n/a',                                     // menu title
303
-            'read',                                    // we want this page to actually be accessible to anyone,
304
-            'espresso_batch',                          // menu slug
302
+            'n/a', // menu title
303
+            'read', // we want this page to actually be accessible to anyone,
304
+            'espresso_batch', // menu slug
305 305
             [self::instance(), 'show_admin_page']
306 306
         );
307 307
     }
@@ -314,7 +314,7 @@  discard block
 block discarded – undo
314 314
     public function show_admin_page()
315 315
     {
316 316
         echo EEH_Template::locate_template(
317
-            EE_MODULES . 'batch/templates/batch_wrapper.template.html',
317
+            EE_MODULES.'batch/templates/batch_wrapper.template.html',
318 318
             ['batch_request_type' => $this->batch_request_type()]
319 319
         );
320 320
     }
Please login to merge, or discard this patch.
core/services/request/ServerParams.php 2 patches
Indentation   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -7,185 +7,185 @@
 block discarded – undo
7 7
 class ServerParams
8 8
 {
9 9
 
10
-    /**
11
-     * IP address for request
12
-     *
13
-     * @var string
14
-     */
15
-    protected $ip_address;
16
-
17
-
18
-    /**
19
-     * @var ServerSanitizer
20
-     */
21
-    protected $sanitizer;
22
-
23
-    /**
24
-     * sanitized $_SERVER parameters
25
-     *
26
-     * @var array
27
-     */
28
-    protected $server;
29
-
30
-    /**
31
-     * @var string
32
-     */
33
-    protected $request_uri;
34
-
35
-    /**
36
-     * @var string
37
-     */
38
-    protected $user_agent;
39
-
40
-
41
-    /**
42
-     * ServerParams constructor.
43
-     *
44
-     * @param ServerSanitizer $sanitizer
45
-     * @param array           $server
46
-     */
47
-    public function __construct(ServerSanitizer $sanitizer, array $server = [])
48
-    {
49
-        $this->sanitizer  = $sanitizer;
50
-        $this->server     = $this->cleanServerParams($server);
51
-        $this->ip_address = $this->setVisitorIp();
52
-    }
53
-
54
-
55
-    /**
56
-     * @return array
57
-     */
58
-    private function cleanServerParams(array $server)
59
-    {
60
-        $cleaned = [];
61
-        $server  = ! empty($server) ? $server : $_SERVER;
62
-        foreach ($server as $key => $value) {
63
-            $cleaned[ $key ] = $this->sanitizer->clean($key, $value);
64
-            // \EEH_Debug_Tools::printr($cleaned[ $key ], $key, __FILE__, __LINE__);
65
-        }
66
-        return $cleaned;
67
-    }
68
-
69
-
70
-    /**
71
-     * @return array
72
-     */
73
-    public function getAllServerParams()
74
-    {
75
-        return $this->server;
76
-    }
77
-
78
-
79
-    /**
80
-     * @param string $key
81
-     * @param mixed|null $default
82
-     * @return array|int|float|string
83
-     */
84
-    public function getServerParam($key, $default = null)
85
-    {
86
-        return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
87
-    }
88
-
89
-
90
-    /**
91
-     * @param string                 $key
92
-     * @param array|int|float|string $value
93
-     * @return void
94
-     */
95
-    public function setServerParam($key, $value)
96
-    {
97
-        $this->server[ $key ] = $this->sanitizer->clean($key, $value);
98
-    }
99
-
100
-
101
-    /**
102
-     * @return bool
103
-     */
104
-    public function serverParamIsSet($key)
105
-    {
106
-        return isset($this->server[ $key ]);
107
-    }
108
-
109
-
110
-    /**
111
-     * @return string
112
-     */
113
-    public function ipAddress()
114
-    {
115
-        return $this->ip_address;
116
-    }
117
-
118
-
119
-    /**
120
-     * attempt to get IP address of current visitor from server
121
-     * plz see: http://stackoverflow.com/a/2031935/1475279
122
-     *
123
-     * @access public
124
-     * @return string
125
-     */
126
-    private function setVisitorIp()
127
-    {
128
-        $visitor_ip  = '0.0.0.0';
129
-        $server_keys = [
130
-            'HTTP_CLIENT_IP',
131
-            'HTTP_FORWARDED',
132
-            'HTTP_FORWARDED_FOR',
133
-            'HTTP_X_CLUSTER_CLIENT_IP',
134
-            'HTTP_X_FORWARDED',
135
-            'HTTP_X_FORWARDED_FOR',
136
-            'REMOTE_ADDR',
137
-        ];
138
-        foreach ($server_keys as $key) {
139
-            if (isset($this->server[ $key ])) {
140
-                $potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
141
-                foreach ($potential_ip as $ip) {
142
-                    if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
143
-                        $visitor_ip = $ip;
144
-                    }
145
-                }
146
-            }
147
-        }
148
-        return $visitor_ip;
149
-    }
150
-
151
-
152
-    /**
153
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
154
-     *
155
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
156
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
157
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
158
-     * @return string
159
-     */
160
-    public function requestUri($relativeToWpRoot = false)
161
-    {
162
-        if ($relativeToWpRoot) {
163
-            $home_path = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
164
-            return str_replace($home_path, '', $this->server['REQUEST_URI']);
165
-        }
166
-        return $this->server['REQUEST_URI'];
167
-    }
168
-
169
-
170
-    /**
171
-     * @return string
172
-     */
173
-    public function userAgent()
174
-    {
175
-        if (empty($this->user_agent)) {
176
-            $this->setUserAgent();
177
-        }
178
-        return $this->user_agent;
179
-    }
180
-
181
-
182
-    /**
183
-     * @param string $user_agent
184
-     */
185
-    public function setUserAgent($user_agent = '')
186
-    {
187
-        $this->user_agent = $user_agent === '' || ! is_string($user_agent)
188
-            ? $this->getServerParam('HTTP_USER_AGENT')
189
-            : esc_attr($user_agent);
190
-    }
10
+	/**
11
+	 * IP address for request
12
+	 *
13
+	 * @var string
14
+	 */
15
+	protected $ip_address;
16
+
17
+
18
+	/**
19
+	 * @var ServerSanitizer
20
+	 */
21
+	protected $sanitizer;
22
+
23
+	/**
24
+	 * sanitized $_SERVER parameters
25
+	 *
26
+	 * @var array
27
+	 */
28
+	protected $server;
29
+
30
+	/**
31
+	 * @var string
32
+	 */
33
+	protected $request_uri;
34
+
35
+	/**
36
+	 * @var string
37
+	 */
38
+	protected $user_agent;
39
+
40
+
41
+	/**
42
+	 * ServerParams constructor.
43
+	 *
44
+	 * @param ServerSanitizer $sanitizer
45
+	 * @param array           $server
46
+	 */
47
+	public function __construct(ServerSanitizer $sanitizer, array $server = [])
48
+	{
49
+		$this->sanitizer  = $sanitizer;
50
+		$this->server     = $this->cleanServerParams($server);
51
+		$this->ip_address = $this->setVisitorIp();
52
+	}
53
+
54
+
55
+	/**
56
+	 * @return array
57
+	 */
58
+	private function cleanServerParams(array $server)
59
+	{
60
+		$cleaned = [];
61
+		$server  = ! empty($server) ? $server : $_SERVER;
62
+		foreach ($server as $key => $value) {
63
+			$cleaned[ $key ] = $this->sanitizer->clean($key, $value);
64
+			// \EEH_Debug_Tools::printr($cleaned[ $key ], $key, __FILE__, __LINE__);
65
+		}
66
+		return $cleaned;
67
+	}
68
+
69
+
70
+	/**
71
+	 * @return array
72
+	 */
73
+	public function getAllServerParams()
74
+	{
75
+		return $this->server;
76
+	}
77
+
78
+
79
+	/**
80
+	 * @param string $key
81
+	 * @param mixed|null $default
82
+	 * @return array|int|float|string
83
+	 */
84
+	public function getServerParam($key, $default = null)
85
+	{
86
+		return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
87
+	}
88
+
89
+
90
+	/**
91
+	 * @param string                 $key
92
+	 * @param array|int|float|string $value
93
+	 * @return void
94
+	 */
95
+	public function setServerParam($key, $value)
96
+	{
97
+		$this->server[ $key ] = $this->sanitizer->clean($key, $value);
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return bool
103
+	 */
104
+	public function serverParamIsSet($key)
105
+	{
106
+		return isset($this->server[ $key ]);
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return string
112
+	 */
113
+	public function ipAddress()
114
+	{
115
+		return $this->ip_address;
116
+	}
117
+
118
+
119
+	/**
120
+	 * attempt to get IP address of current visitor from server
121
+	 * plz see: http://stackoverflow.com/a/2031935/1475279
122
+	 *
123
+	 * @access public
124
+	 * @return string
125
+	 */
126
+	private function setVisitorIp()
127
+	{
128
+		$visitor_ip  = '0.0.0.0';
129
+		$server_keys = [
130
+			'HTTP_CLIENT_IP',
131
+			'HTTP_FORWARDED',
132
+			'HTTP_FORWARDED_FOR',
133
+			'HTTP_X_CLUSTER_CLIENT_IP',
134
+			'HTTP_X_FORWARDED',
135
+			'HTTP_X_FORWARDED_FOR',
136
+			'REMOTE_ADDR',
137
+		];
138
+		foreach ($server_keys as $key) {
139
+			if (isset($this->server[ $key ])) {
140
+				$potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
141
+				foreach ($potential_ip as $ip) {
142
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
143
+						$visitor_ip = $ip;
144
+					}
145
+				}
146
+			}
147
+		}
148
+		return $visitor_ip;
149
+	}
150
+
151
+
152
+	/**
153
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
154
+	 *
155
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
156
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
157
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
158
+	 * @return string
159
+	 */
160
+	public function requestUri($relativeToWpRoot = false)
161
+	{
162
+		if ($relativeToWpRoot) {
163
+			$home_path = untrailingslashit(parse_url(home_url(), PHP_URL_PATH));
164
+			return str_replace($home_path, '', $this->server['REQUEST_URI']);
165
+		}
166
+		return $this->server['REQUEST_URI'];
167
+	}
168
+
169
+
170
+	/**
171
+	 * @return string
172
+	 */
173
+	public function userAgent()
174
+	{
175
+		if (empty($this->user_agent)) {
176
+			$this->setUserAgent();
177
+		}
178
+		return $this->user_agent;
179
+	}
180
+
181
+
182
+	/**
183
+	 * @param string $user_agent
184
+	 */
185
+	public function setUserAgent($user_agent = '')
186
+	{
187
+		$this->user_agent = $user_agent === '' || ! is_string($user_agent)
188
+			? $this->getServerParam('HTTP_USER_AGENT')
189
+			: esc_attr($user_agent);
190
+	}
191 191
 }
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
         $cleaned = [];
61 61
         $server  = ! empty($server) ? $server : $_SERVER;
62 62
         foreach ($server as $key => $value) {
63
-            $cleaned[ $key ] = $this->sanitizer->clean($key, $value);
63
+            $cleaned[$key] = $this->sanitizer->clean($key, $value);
64 64
             // \EEH_Debug_Tools::printr($cleaned[ $key ], $key, __FILE__, __LINE__);
65 65
         }
66 66
         return $cleaned;
@@ -83,7 +83,7 @@  discard block
 block discarded – undo
83 83
      */
84 84
     public function getServerParam($key, $default = null)
85 85
     {
86
-        return $this->serverParamIsSet($key) ? $this->server[ $key ] : $default;
86
+        return $this->serverParamIsSet($key) ? $this->server[$key] : $default;
87 87
     }
88 88
 
89 89
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     public function setServerParam($key, $value)
96 96
     {
97
-        $this->server[ $key ] = $this->sanitizer->clean($key, $value);
97
+        $this->server[$key] = $this->sanitizer->clean($key, $value);
98 98
     }
99 99
 
100 100
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function serverParamIsSet($key)
105 105
     {
106
-        return isset($this->server[ $key ]);
106
+        return isset($this->server[$key]);
107 107
     }
108 108
 
109 109
 
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
             'REMOTE_ADDR',
137 137
         ];
138 138
         foreach ($server_keys as $key) {
139
-            if (isset($this->server[ $key ])) {
140
-                $potential_ip = array_map('trim', explode(',', $this->server[ $key ]));
139
+            if (isset($this->server[$key])) {
140
+                $potential_ip = array_map('trim', explode(',', $this->server[$key]));
141 141
                 foreach ($potential_ip as $ip) {
142 142
                     if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== false) {
143 143
                         $visitor_ip = $ip;
Please login to merge, or discard this patch.
core/services/request/Request.php 1 patch
Indentation   +476 added lines, -476 removed lines patch added patch discarded remove patch
@@ -17,480 +17,480 @@
 block discarded – undo
17 17
 class Request implements InterminableInterface, RequestInterface, ReservedInstanceInterface
18 18
 {
19 19
 
20
-    /**
21
-     * $_COOKIE parameters
22
-     *
23
-     * @var array
24
-     */
25
-    protected $cookies;
26
-
27
-    /**
28
-     * $_FILES parameters
29
-     *
30
-     * @var array
31
-     */
32
-    protected $files;
33
-
34
-    /**
35
-     * true if current user appears to be some kind of bot
36
-     *
37
-     * @var bool
38
-     */
39
-    protected $is_bot;
40
-
41
-    /**
42
-     * @var RequestParams
43
-     */
44
-    protected $request_params;
45
-
46
-    /**
47
-     * @var RequestTypeContextCheckerInterface
48
-     */
49
-    protected $request_type;
50
-
51
-    /**
52
-     * @var ServerParams
53
-     */
54
-    protected $server_params;
55
-
56
-
57
-    public function __construct(
58
-        RequestParams $request_params,
59
-        ServerParams $server_params,
60
-        array $cookies = [],
61
-        array $files = []
62
-    ) {
63
-        $this->cookies = ! empty($cookies)
64
-            ? $cookies
65
-            : filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
-        $this->files          = ! empty($files) ? $files : $_FILES;
67
-        $this->request_params = $request_params;
68
-        $this->server_params  = $server_params;
69
-    }
70
-
71
-
72
-    /**
73
-     * @param RequestTypeContextCheckerInterface $type
74
-     */
75
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
-    {
77
-        $this->request_type = $type;
78
-    }
79
-
80
-
81
-    /**
82
-     * @return array
83
-     */
84
-    public function getParams()
85
-    {
86
-        return $this->request_params->getParams();
87
-    }
88
-
89
-
90
-    /**
91
-     * @return array
92
-     */
93
-    public function postParams()
94
-    {
95
-        return $this->request_params->postParams();
96
-    }
97
-
98
-
99
-    /**
100
-     * @return array
101
-     */
102
-    public function cookieParams()
103
-    {
104
-        return $this->cookies;
105
-    }
106
-
107
-
108
-    /**
109
-     * @return array
110
-     */
111
-    public function serverParams()
112
-    {
113
-        return $this->server_params->getAllServerParams();
114
-    }
115
-
116
-
117
-    /**
118
-     * @param string $key
119
-     * @param mixed|null $default
120
-     * @return array|int|float|string
121
-     */
122
-    public function getServerParam($key, $default = null)
123
-    {
124
-        return $this->server_params->getServerParam($key, $default);
125
-    }
126
-
127
-
128
-    /**
129
-     * @param string                 $key
130
-     * @param array|int|float|string $value
131
-     * @return void
132
-     */
133
-    public function setServerParam($key, $value)
134
-    {
135
-        $this->server_params->setServerParam($key, $value);
136
-    }
137
-
138
-
139
-    /**
140
-     * @param string $key
141
-     * @return bool
142
-     */
143
-    public function serverParamIsSet($key)
144
-    {
145
-        return $this->server_params->serverParamIsSet($key);
146
-    }
147
-
148
-
149
-    /**
150
-     * @return array
151
-     */
152
-    public function filesParams()
153
-    {
154
-        return $this->files;
155
-    }
156
-
157
-
158
-    /**
159
-     * returns sanitized contents of $_REQUEST
160
-     *
161
-     * @return array
162
-     */
163
-    public function requestParams()
164
-    {
165
-        return $this->request_params->requestParams();
166
-    }
167
-
168
-
169
-    /**
170
-     * @param string     $key
171
-     * @param mixed|null $value
172
-     * @param bool       $override_ee
173
-     * @return void
174
-     */
175
-    public function setRequestParam($key, $value, $override_ee = false)
176
-    {
177
-        $this->request_params->setRequestParam($key, $value, $override_ee);
178
-    }
179
-
180
-
181
-    /**
182
-     * returns sanitized value for a request param if the given key exists
183
-     *
184
-     * @param string     $key
185
-     * @param mixed|null $default
186
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
187
-     * @param string     $delimiter for CSV type strings that should be returned as an array
188
-     * @return array|bool|float|int|string
189
-     */
190
-    public function getRequestParam($key, $default = null, $type = 'string', $delimiter = ',')
191
-    {
192
-        return $this->request_params->getRequestParam($key, $default, $type, $delimiter);
193
-    }
194
-
195
-
196
-    /**
197
-     * check if param exists
198
-     *
199
-     * @param string $key
200
-     * @return bool
201
-     */
202
-    public function requestParamIsSet($key)
203
-    {
204
-        return $this->request_params->requestParamIsSet($key);
205
-    }
206
-
207
-
208
-    /**
209
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
210
-     * and return the sanitized value for the first match found
211
-     * wildcards can be either of the following:
212
-     *      ? to represent a single character of any type
213
-     *      * to represent one or more characters of any type
214
-     *
215
-     * @param string     $pattern
216
-     * @param mixed|null $default
217
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
218
-     * @param string     $delimiter for CSV type strings that should be returned as an array
219
-     * @return array|bool|float|int|string
220
-     */
221
-    public function getMatch($pattern, $default = null, $type = 'string', $delimiter = ',')
222
-    {
223
-        return $this->request_params->getMatch($pattern, $default, $type, $delimiter);
224
-    }
225
-
226
-
227
-    /**
228
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
229
-     * wildcards can be either of the following:
230
-     *      ? to represent a single character of any type
231
-     *      * to represent one or more characters of any type
232
-     * returns true if a match is found or false if not
233
-     *
234
-     * @param string $pattern
235
-     * @return bool
236
-     */
237
-    public function matches($pattern)
238
-    {
239
-        return $this->request_params->matches($pattern);
240
-    }
241
-
242
-
243
-    /**
244
-     * remove param
245
-     *
246
-     * @param      $key
247
-     * @param bool $unset_from_global_too
248
-     */
249
-    public function unSetRequestParam($key, $unset_from_global_too = false)
250
-    {
251
-        $this->request_params->unSetRequestParam($key, $unset_from_global_too);
252
-    }
253
-
254
-
255
-    /**
256
-     * remove params
257
-     *
258
-     * @param array $keys
259
-     * @param bool  $unset_from_global_too
260
-     */
261
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false)
262
-    {
263
-        $this->request_params->unSetRequestParams($keys, $unset_from_global_too);
264
-    }
265
-
266
-
267
-    /**
268
-     * @return string
269
-     */
270
-    public function ipAddress()
271
-    {
272
-        return $this->server_params->ipAddress();
273
-    }
274
-
275
-
276
-    /**
277
-     * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
278
-     *
279
-     * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
280
-     *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
281
-     *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
282
-     * @return string
283
-     */
284
-    public function requestUri($relativeToWpRoot = false)
285
-    {
286
-        return $this->server_params->requestUri();
287
-    }
288
-
289
-
290
-    /**
291
-     * @return string
292
-     */
293
-    public function userAgent()
294
-    {
295
-        return $this->server_params->userAgent();
296
-    }
297
-
298
-
299
-    /**
300
-     * @param string $user_agent
301
-     */
302
-    public function setUserAgent($user_agent = '')
303
-    {
304
-        $this->server_params->setUserAgent($user_agent);
305
-    }
306
-
307
-
308
-    /**
309
-     * @return bool
310
-     */
311
-    public function isBot()
312
-    {
313
-        return $this->is_bot;
314
-    }
315
-
316
-
317
-    /**
318
-     * @param bool $is_bot
319
-     */
320
-    public function setIsBot($is_bot)
321
-    {
322
-        $this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
323
-    }
324
-
325
-
326
-    /**
327
-     * @return bool
328
-     */
329
-    public function isActivation()
330
-    {
331
-        return $this->request_type->isActivation();
332
-    }
333
-
334
-
335
-    /**
336
-     * @param $is_activation
337
-     * @return bool
338
-     */
339
-    public function setIsActivation($is_activation)
340
-    {
341
-        return $this->request_type->setIsActivation($is_activation);
342
-    }
343
-
344
-
345
-    /**
346
-     * @return bool
347
-     */
348
-    public function isAdmin()
349
-    {
350
-        return $this->request_type->isAdmin();
351
-    }
352
-
353
-
354
-    /**
355
-     * @return bool
356
-     */
357
-    public function isAdminAjax()
358
-    {
359
-        return $this->request_type->isAdminAjax();
360
-    }
361
-
362
-
363
-    /**
364
-     * @return bool
365
-     */
366
-    public function isAjax()
367
-    {
368
-        return $this->request_type->isAjax();
369
-    }
370
-
371
-
372
-    /**
373
-     * @return bool
374
-     */
375
-    public function isEeAjax()
376
-    {
377
-        return $this->request_type->isEeAjax();
378
-    }
379
-
380
-
381
-    /**
382
-     * @return bool
383
-     */
384
-    public function isOtherAjax()
385
-    {
386
-        return $this->request_type->isOtherAjax();
387
-    }
388
-
389
-
390
-    /**
391
-     * @return bool
392
-     */
393
-    public function isApi()
394
-    {
395
-        return $this->request_type->isApi();
396
-    }
397
-
398
-
399
-    /**
400
-     * @return bool
401
-     */
402
-    public function isCli()
403
-    {
404
-        return $this->request_type->isCli();
405
-    }
406
-
407
-
408
-    /**
409
-     * @return bool
410
-     */
411
-    public function isCron()
412
-    {
413
-        return $this->request_type->isCron();
414
-    }
415
-
416
-
417
-    /**
418
-     * @return bool
419
-     */
420
-    public function isFeed()
421
-    {
422
-        return $this->request_type->isFeed();
423
-    }
424
-
425
-
426
-    /**
427
-     * @return bool
428
-     */
429
-    public function isFrontend()
430
-    {
431
-        return $this->request_type->isFrontend();
432
-    }
433
-
434
-
435
-    /**
436
-     * @return bool
437
-     */
438
-    public function isFrontAjax()
439
-    {
440
-        return $this->request_type->isFrontAjax();
441
-    }
442
-
443
-
444
-    /**
445
-     * @return bool
446
-     */
447
-    public function isIframe()
448
-    {
449
-        return $this->request_type->isIframe();
450
-    }
451
-
452
-
453
-    /**
454
-     * @return bool
455
-     */
456
-    public function isWordPressApi()
457
-    {
458
-        return $this->request_type->isWordPressApi();
459
-    }
460
-
461
-
462
-    /**
463
-     * @return bool
464
-     */
465
-    public function isWordPressHeartbeat()
466
-    {
467
-        return $this->request_type->isWordPressHeartbeat();
468
-    }
469
-
470
-
471
-    /**
472
-     * @return bool
473
-     */
474
-    public function isWordPressScrape()
475
-    {
476
-        return $this->request_type->isWordPressScrape();
477
-    }
478
-
479
-
480
-    /**
481
-     * @return string
482
-     */
483
-    public function slug()
484
-    {
485
-        return $this->request_type->slug();
486
-    }
487
-
488
-
489
-    /**
490
-     * @return RequestTypeContextCheckerInterface
491
-     */
492
-    public function getRequestType()
493
-    {
494
-        return $this->request_type;
495
-    }
20
+	/**
21
+	 * $_COOKIE parameters
22
+	 *
23
+	 * @var array
24
+	 */
25
+	protected $cookies;
26
+
27
+	/**
28
+	 * $_FILES parameters
29
+	 *
30
+	 * @var array
31
+	 */
32
+	protected $files;
33
+
34
+	/**
35
+	 * true if current user appears to be some kind of bot
36
+	 *
37
+	 * @var bool
38
+	 */
39
+	protected $is_bot;
40
+
41
+	/**
42
+	 * @var RequestParams
43
+	 */
44
+	protected $request_params;
45
+
46
+	/**
47
+	 * @var RequestTypeContextCheckerInterface
48
+	 */
49
+	protected $request_type;
50
+
51
+	/**
52
+	 * @var ServerParams
53
+	 */
54
+	protected $server_params;
55
+
56
+
57
+	public function __construct(
58
+		RequestParams $request_params,
59
+		ServerParams $server_params,
60
+		array $cookies = [],
61
+		array $files = []
62
+	) {
63
+		$this->cookies = ! empty($cookies)
64
+			? $cookies
65
+			: filter_input_array(INPUT_COOKIE, FILTER_SANITIZE_STRING);
66
+		$this->files          = ! empty($files) ? $files : $_FILES;
67
+		$this->request_params = $request_params;
68
+		$this->server_params  = $server_params;
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param RequestTypeContextCheckerInterface $type
74
+	 */
75
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type)
76
+	{
77
+		$this->request_type = $type;
78
+	}
79
+
80
+
81
+	/**
82
+	 * @return array
83
+	 */
84
+	public function getParams()
85
+	{
86
+		return $this->request_params->getParams();
87
+	}
88
+
89
+
90
+	/**
91
+	 * @return array
92
+	 */
93
+	public function postParams()
94
+	{
95
+		return $this->request_params->postParams();
96
+	}
97
+
98
+
99
+	/**
100
+	 * @return array
101
+	 */
102
+	public function cookieParams()
103
+	{
104
+		return $this->cookies;
105
+	}
106
+
107
+
108
+	/**
109
+	 * @return array
110
+	 */
111
+	public function serverParams()
112
+	{
113
+		return $this->server_params->getAllServerParams();
114
+	}
115
+
116
+
117
+	/**
118
+	 * @param string $key
119
+	 * @param mixed|null $default
120
+	 * @return array|int|float|string
121
+	 */
122
+	public function getServerParam($key, $default = null)
123
+	{
124
+		return $this->server_params->getServerParam($key, $default);
125
+	}
126
+
127
+
128
+	/**
129
+	 * @param string                 $key
130
+	 * @param array|int|float|string $value
131
+	 * @return void
132
+	 */
133
+	public function setServerParam($key, $value)
134
+	{
135
+		$this->server_params->setServerParam($key, $value);
136
+	}
137
+
138
+
139
+	/**
140
+	 * @param string $key
141
+	 * @return bool
142
+	 */
143
+	public function serverParamIsSet($key)
144
+	{
145
+		return $this->server_params->serverParamIsSet($key);
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return array
151
+	 */
152
+	public function filesParams()
153
+	{
154
+		return $this->files;
155
+	}
156
+
157
+
158
+	/**
159
+	 * returns sanitized contents of $_REQUEST
160
+	 *
161
+	 * @return array
162
+	 */
163
+	public function requestParams()
164
+	{
165
+		return $this->request_params->requestParams();
166
+	}
167
+
168
+
169
+	/**
170
+	 * @param string     $key
171
+	 * @param mixed|null $value
172
+	 * @param bool       $override_ee
173
+	 * @return void
174
+	 */
175
+	public function setRequestParam($key, $value, $override_ee = false)
176
+	{
177
+		$this->request_params->setRequestParam($key, $value, $override_ee);
178
+	}
179
+
180
+
181
+	/**
182
+	 * returns sanitized value for a request param if the given key exists
183
+	 *
184
+	 * @param string     $key
185
+	 * @param mixed|null $default
186
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
187
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
188
+	 * @return array|bool|float|int|string
189
+	 */
190
+	public function getRequestParam($key, $default = null, $type = 'string', $delimiter = ',')
191
+	{
192
+		return $this->request_params->getRequestParam($key, $default, $type, $delimiter);
193
+	}
194
+
195
+
196
+	/**
197
+	 * check if param exists
198
+	 *
199
+	 * @param string $key
200
+	 * @return bool
201
+	 */
202
+	public function requestParamIsSet($key)
203
+	{
204
+		return $this->request_params->requestParamIsSet($key);
205
+	}
206
+
207
+
208
+	/**
209
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
210
+	 * and return the sanitized value for the first match found
211
+	 * wildcards can be either of the following:
212
+	 *      ? to represent a single character of any type
213
+	 *      * to represent one or more characters of any type
214
+	 *
215
+	 * @param string     $pattern
216
+	 * @param mixed|null $default
217
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
218
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
219
+	 * @return array|bool|float|int|string
220
+	 */
221
+	public function getMatch($pattern, $default = null, $type = 'string', $delimiter = ',')
222
+	{
223
+		return $this->request_params->getMatch($pattern, $default, $type, $delimiter);
224
+	}
225
+
226
+
227
+	/**
228
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
229
+	 * wildcards can be either of the following:
230
+	 *      ? to represent a single character of any type
231
+	 *      * to represent one or more characters of any type
232
+	 * returns true if a match is found or false if not
233
+	 *
234
+	 * @param string $pattern
235
+	 * @return bool
236
+	 */
237
+	public function matches($pattern)
238
+	{
239
+		return $this->request_params->matches($pattern);
240
+	}
241
+
242
+
243
+	/**
244
+	 * remove param
245
+	 *
246
+	 * @param      $key
247
+	 * @param bool $unset_from_global_too
248
+	 */
249
+	public function unSetRequestParam($key, $unset_from_global_too = false)
250
+	{
251
+		$this->request_params->unSetRequestParam($key, $unset_from_global_too);
252
+	}
253
+
254
+
255
+	/**
256
+	 * remove params
257
+	 *
258
+	 * @param array $keys
259
+	 * @param bool  $unset_from_global_too
260
+	 */
261
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false)
262
+	{
263
+		$this->request_params->unSetRequestParams($keys, $unset_from_global_too);
264
+	}
265
+
266
+
267
+	/**
268
+	 * @return string
269
+	 */
270
+	public function ipAddress()
271
+	{
272
+		return $this->server_params->ipAddress();
273
+	}
274
+
275
+
276
+	/**
277
+	 * Gets the request's literal URI. Related to `requestUriAfterSiteHomeUri`, see its description for a comparison.
278
+	 *
279
+	 * @param boolean $relativeToWpRoot If home_url() is "http://mysite.com/wp/", and a request comes to
280
+	 *                                  "http://mysite.com/wp/wp-json", setting $relativeToWpRoot=true will return
281
+	 *                                  "/wp-json", whereas $relativeToWpRoot=false will return "/wp/wp-json/".
282
+	 * @return string
283
+	 */
284
+	public function requestUri($relativeToWpRoot = false)
285
+	{
286
+		return $this->server_params->requestUri();
287
+	}
288
+
289
+
290
+	/**
291
+	 * @return string
292
+	 */
293
+	public function userAgent()
294
+	{
295
+		return $this->server_params->userAgent();
296
+	}
297
+
298
+
299
+	/**
300
+	 * @param string $user_agent
301
+	 */
302
+	public function setUserAgent($user_agent = '')
303
+	{
304
+		$this->server_params->setUserAgent($user_agent);
305
+	}
306
+
307
+
308
+	/**
309
+	 * @return bool
310
+	 */
311
+	public function isBot()
312
+	{
313
+		return $this->is_bot;
314
+	}
315
+
316
+
317
+	/**
318
+	 * @param bool $is_bot
319
+	 */
320
+	public function setIsBot($is_bot)
321
+	{
322
+		$this->is_bot = filter_var($is_bot, FILTER_VALIDATE_BOOLEAN);
323
+	}
324
+
325
+
326
+	/**
327
+	 * @return bool
328
+	 */
329
+	public function isActivation()
330
+	{
331
+		return $this->request_type->isActivation();
332
+	}
333
+
334
+
335
+	/**
336
+	 * @param $is_activation
337
+	 * @return bool
338
+	 */
339
+	public function setIsActivation($is_activation)
340
+	{
341
+		return $this->request_type->setIsActivation($is_activation);
342
+	}
343
+
344
+
345
+	/**
346
+	 * @return bool
347
+	 */
348
+	public function isAdmin()
349
+	{
350
+		return $this->request_type->isAdmin();
351
+	}
352
+
353
+
354
+	/**
355
+	 * @return bool
356
+	 */
357
+	public function isAdminAjax()
358
+	{
359
+		return $this->request_type->isAdminAjax();
360
+	}
361
+
362
+
363
+	/**
364
+	 * @return bool
365
+	 */
366
+	public function isAjax()
367
+	{
368
+		return $this->request_type->isAjax();
369
+	}
370
+
371
+
372
+	/**
373
+	 * @return bool
374
+	 */
375
+	public function isEeAjax()
376
+	{
377
+		return $this->request_type->isEeAjax();
378
+	}
379
+
380
+
381
+	/**
382
+	 * @return bool
383
+	 */
384
+	public function isOtherAjax()
385
+	{
386
+		return $this->request_type->isOtherAjax();
387
+	}
388
+
389
+
390
+	/**
391
+	 * @return bool
392
+	 */
393
+	public function isApi()
394
+	{
395
+		return $this->request_type->isApi();
396
+	}
397
+
398
+
399
+	/**
400
+	 * @return bool
401
+	 */
402
+	public function isCli()
403
+	{
404
+		return $this->request_type->isCli();
405
+	}
406
+
407
+
408
+	/**
409
+	 * @return bool
410
+	 */
411
+	public function isCron()
412
+	{
413
+		return $this->request_type->isCron();
414
+	}
415
+
416
+
417
+	/**
418
+	 * @return bool
419
+	 */
420
+	public function isFeed()
421
+	{
422
+		return $this->request_type->isFeed();
423
+	}
424
+
425
+
426
+	/**
427
+	 * @return bool
428
+	 */
429
+	public function isFrontend()
430
+	{
431
+		return $this->request_type->isFrontend();
432
+	}
433
+
434
+
435
+	/**
436
+	 * @return bool
437
+	 */
438
+	public function isFrontAjax()
439
+	{
440
+		return $this->request_type->isFrontAjax();
441
+	}
442
+
443
+
444
+	/**
445
+	 * @return bool
446
+	 */
447
+	public function isIframe()
448
+	{
449
+		return $this->request_type->isIframe();
450
+	}
451
+
452
+
453
+	/**
454
+	 * @return bool
455
+	 */
456
+	public function isWordPressApi()
457
+	{
458
+		return $this->request_type->isWordPressApi();
459
+	}
460
+
461
+
462
+	/**
463
+	 * @return bool
464
+	 */
465
+	public function isWordPressHeartbeat()
466
+	{
467
+		return $this->request_type->isWordPressHeartbeat();
468
+	}
469
+
470
+
471
+	/**
472
+	 * @return bool
473
+	 */
474
+	public function isWordPressScrape()
475
+	{
476
+		return $this->request_type->isWordPressScrape();
477
+	}
478
+
479
+
480
+	/**
481
+	 * @return string
482
+	 */
483
+	public function slug()
484
+	{
485
+		return $this->request_type->slug();
486
+	}
487
+
488
+
489
+	/**
490
+	 * @return RequestTypeContextCheckerInterface
491
+	 */
492
+	public function getRequestType()
493
+	{
494
+		return $this->request_type;
495
+	}
496 496
 }
Please login to merge, or discard this patch.
core/services/request/RequestInterface.php 1 patch
Indentation   +171 added lines, -171 removed lines patch added patch discarded remove patch
@@ -16,183 +16,183 @@
 block discarded – undo
16 16
 interface RequestInterface extends RequestTypeContextCheckerInterface
17 17
 {
18 18
 
19
-    /**
20
-     * @param RequestTypeContextCheckerInterface $type
21
-     */
22
-    public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
19
+	/**
20
+	 * @param RequestTypeContextCheckerInterface $type
21
+	 */
22
+	public function setRequestTypeContextChecker(RequestTypeContextCheckerInterface $type);
23 23
 
24 24
 
25
-    /**
26
-     * @return array
27
-     */
28
-    public function getParams();
29
-
30
-
31
-    /**
32
-     * @return array
33
-     */
34
-    public function postParams();
35
-
36
-
37
-    /**
38
-     * @return array
39
-     */
40
-    public function cookieParams();
41
-
42
-
43
-    /**
44
-     * @return array
45
-     */
46
-    public function serverParams();
47
-
48
-
49
-    /**
50
-     * @param string $key
51
-     * @param mixed|null $default
52
-     * @return array|int|float|string
53
-     */
54
-    public function getServerParam($key, $default = null);
55
-
56
-
57
-    /**
58
-     * @param string                 $key
59
-     * @param array|int|float|string $value
60
-     * @return void
61
-     */
62
-    public function setServerParam($key, $value);
63
-
64
-
65
-    /**
66
-     * @param string $key
67
-     * @return bool
68
-     */
69
-    public function serverParamIsSet($key);
70
-
71
-
72
-    /**
73
-     * @return array
74
-     */
75
-    public function filesParams();
76
-
77
-
78
-    /**
79
-     * returns sanitized contents of $_REQUEST
80
-     *
81
-     * @return array
82
-     */
83
-    public function requestParams();
84
-
85
-
86
-    /**
87
-     * @param string $key
88
-     * @param string $value
89
-     * @param bool   $override_ee
90
-     * @return void
91
-     */
92
-    public function setRequestParam($key, $value, $override_ee = false);
25
+	/**
26
+	 * @return array
27
+	 */
28
+	public function getParams();
29
+
30
+
31
+	/**
32
+	 * @return array
33
+	 */
34
+	public function postParams();
35
+
36
+
37
+	/**
38
+	 * @return array
39
+	 */
40
+	public function cookieParams();
41
+
42
+
43
+	/**
44
+	 * @return array
45
+	 */
46
+	public function serverParams();
47
+
48
+
49
+	/**
50
+	 * @param string $key
51
+	 * @param mixed|null $default
52
+	 * @return array|int|float|string
53
+	 */
54
+	public function getServerParam($key, $default = null);
55
+
56
+
57
+	/**
58
+	 * @param string                 $key
59
+	 * @param array|int|float|string $value
60
+	 * @return void
61
+	 */
62
+	public function setServerParam($key, $value);
63
+
64
+
65
+	/**
66
+	 * @param string $key
67
+	 * @return bool
68
+	 */
69
+	public function serverParamIsSet($key);
70
+
71
+
72
+	/**
73
+	 * @return array
74
+	 */
75
+	public function filesParams();
76
+
77
+
78
+	/**
79
+	 * returns sanitized contents of $_REQUEST
80
+	 *
81
+	 * @return array
82
+	 */
83
+	public function requestParams();
84
+
85
+
86
+	/**
87
+	 * @param string $key
88
+	 * @param string $value
89
+	 * @param bool   $override_ee
90
+	 * @return void
91
+	 */
92
+	public function setRequestParam($key, $value, $override_ee = false);
93 93
 
94 94
 
95
-    /**
96
-     * returns   the value for a request param if the given key exists
97
-     *
98
-     * @param string     $key
99
-     * @param mixed|null $default
100
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
-     * @param string     $delimiter for CSV type strings that should be returned as an array
102
-     * @return array|bool|float|int|string
103
-     */
104
-    public function getRequestParam($key, $default = null, $type = 'string', $delimiter = ',');
95
+	/**
96
+	 * returns   the value for a request param if the given key exists
97
+	 *
98
+	 * @param string     $key
99
+	 * @param mixed|null $default
100
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
101
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
102
+	 * @return array|bool|float|int|string
103
+	 */
104
+	public function getRequestParam($key, $default = null, $type = 'string', $delimiter = ',');
105 105
 
106 106
 
107
-    /**
108
-     * check if param exists
109
-     *
110
-     * @param string $key
111
-     * @return bool
112
-     */
113
-    public function requestParamIsSet($key);
107
+	/**
108
+	 * check if param exists
109
+	 *
110
+	 * @param string $key
111
+	 * @return bool
112
+	 */
113
+	public function requestParamIsSet($key);
114 114
 
115 115
 
116
-    /**
117
-     * check if a request parameter exists whose key that matches the supplied wildcard pattern
118
-     * and return the value for the first match found
119
-     * wildcards can be either of the following:
120
-     *      ? to represent a single character of any type
121
-     *      * to represent one or more characters of any type
122
-     *
123
-     * @param string     $pattern
124
-     * @param mixed|null $default
125
-     * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
126
-     * @param string     $delimiter for CSV type strings that should be returned as an array
127
-     * @return array|bool|float|int|string
128
-     */
129
-    public function getMatch($pattern, $default = null, $type = 'string', $delimiter = ',');
130
-
131
-
132
-    /**
133
-     * check if a request parameter exists whose key matches the supplied wildcard pattern
134
-     * wildcards can be either of the following:
135
-     *      ? to represent a single character of any type
136
-     *      * to represent one or more characters of any type
137
-     * returns true if a match is found or false if not
138
-     *
139
-     * @param string $pattern
140
-     * @return false|int
141
-     */
142
-    public function matches($pattern);
143
-
144
-
145
-    /**
146
-     * remove param
147
-     *
148
-     * @param string $key
149
-     * @param bool   $unset_from_global_too
150
-     */
151
-    public function unSetRequestParam($key, $unset_from_global_too = false);
152
-
153
-
154
-    /**
155
-     * remove params
156
-     *
157
-     * @param array $keys
158
-     * @param bool  $unset_from_global_too
159
-     */
160
-    public function unSetRequestParams(array $keys, $unset_from_global_too = false);
161
-
162
-
163
-    /**
164
-     * @return string
165
-     */
166
-    public function ipAddress();
167
-
168
-
169
-    /**
170
-     * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
171
-     * @return string
172
-     */
173
-    public function requestUri($relativeToWpRoot = false);
174
-
175
-
176
-    /**
177
-     * @return string
178
-     */
179
-    public function userAgent();
180
-
181
-
182
-    /**
183
-     * @param string $user_agent
184
-     */
185
-    public function setUserAgent($user_agent = '');
186
-
187
-
188
-    /**
189
-     * @return bool
190
-     */
191
-    public function isBot();
192
-
193
-
194
-    /**
195
-     * @param bool $is_bot
196
-     */
197
-    public function setIsBot($is_bot);
116
+	/**
117
+	 * check if a request parameter exists whose key that matches the supplied wildcard pattern
118
+	 * and return the value for the first match found
119
+	 * wildcards can be either of the following:
120
+	 *      ? to represent a single character of any type
121
+	 *      * to represent one or more characters of any type
122
+	 *
123
+	 * @param string     $pattern
124
+	 * @param mixed|null $default
125
+	 * @param string     $type      the expected data type for the parameter's value, ie: string, int, bool, etc
126
+	 * @param string     $delimiter for CSV type strings that should be returned as an array
127
+	 * @return array|bool|float|int|string
128
+	 */
129
+	public function getMatch($pattern, $default = null, $type = 'string', $delimiter = ',');
130
+
131
+
132
+	/**
133
+	 * check if a request parameter exists whose key matches the supplied wildcard pattern
134
+	 * wildcards can be either of the following:
135
+	 *      ? to represent a single character of any type
136
+	 *      * to represent one or more characters of any type
137
+	 * returns true if a match is found or false if not
138
+	 *
139
+	 * @param string $pattern
140
+	 * @return false|int
141
+	 */
142
+	public function matches($pattern);
143
+
144
+
145
+	/**
146
+	 * remove param
147
+	 *
148
+	 * @param string $key
149
+	 * @param bool   $unset_from_global_too
150
+	 */
151
+	public function unSetRequestParam($key, $unset_from_global_too = false);
152
+
153
+
154
+	/**
155
+	 * remove params
156
+	 *
157
+	 * @param array $keys
158
+	 * @param bool  $unset_from_global_too
159
+	 */
160
+	public function unSetRequestParams(array $keys, $unset_from_global_too = false);
161
+
162
+
163
+	/**
164
+	 * @return string
165
+	 */
166
+	public function ipAddress();
167
+
168
+
169
+	/**
170
+	 * @param boolean $relativeToWpRoot whether to return the uri relative to WordPress' home URL, or not.
171
+	 * @return string
172
+	 */
173
+	public function requestUri($relativeToWpRoot = false);
174
+
175
+
176
+	/**
177
+	 * @return string
178
+	 */
179
+	public function userAgent();
180
+
181
+
182
+	/**
183
+	 * @param string $user_agent
184
+	 */
185
+	public function setUserAgent($user_agent = '');
186
+
187
+
188
+	/**
189
+	 * @return bool
190
+	 */
191
+	public function isBot();
192
+
193
+
194
+	/**
195
+	 * @param bool $is_bot
196
+	 */
197
+	public function setIsBot($is_bot);
198 198
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 1 patch
Indentation   +4085 added lines, -4085 removed lines patch added patch discarded remove patch
@@ -18,4155 +18,4155 @@
 block discarded – undo
18 18
 abstract class EE_Admin_Page extends EE_Base implements InterminableInterface
19 19
 {
20 20
 
21
-    /**
22
-     * @var LoaderInterface
23
-     */
24
-    protected $loader;
21
+	/**
22
+	 * @var LoaderInterface
23
+	 */
24
+	protected $loader;
25 25
 
26
-    /**
27
-     * @var RequestInterface
28
-     */
29
-    protected $request;
26
+	/**
27
+	 * @var RequestInterface
28
+	 */
29
+	protected $request;
30 30
 
31
-    // set in _init_page_props()
32
-    public $page_slug;
31
+	// set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    // set in define_page_props()
39
-    protected $_admin_base_url;
38
+	// set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    // set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	// set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    // navtabs
52
-    protected $_nav_tabs;
51
+	// navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    /**
57
-     * @var array $_help_tour
58
-     */
59
-    protected $_help_tour = [];
56
+	/**
57
+	 * @var array $_help_tour
58
+	 */
59
+	protected $_help_tour = [];
60 60
 
61 61
 
62
-    // template variables (used by templates)
63
-    protected $_template_path;
62
+	// template variables (used by templates)
63
+	protected $_template_path;
64 64
 
65
-    protected $_column_template_path;
65
+	protected $_column_template_path;
66 66
 
67
-    /**
68
-     * @var array $_template_args
69
-     */
70
-    protected $_template_args = [];
67
+	/**
68
+	 * @var array $_template_args
69
+	 */
70
+	protected $_template_args = [];
71 71
 
72
-    /**
73
-     * this will hold the list table object for a given view.
74
-     *
75
-     * @var EE_Admin_List_Table $_list_table_object
76
-     */
77
-    protected $_list_table_object;
72
+	/**
73
+	 * this will hold the list table object for a given view.
74
+	 *
75
+	 * @var EE_Admin_List_Table $_list_table_object
76
+	 */
77
+	protected $_list_table_object;
78 78
 
79
-    // bools
80
-    protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
79
+	// bools
80
+	protected $_is_UI_request = null; // this starts at null so we can have no header routes progress through two states.
81 81
 
82
-    protected $_routing;
82
+	protected $_routing;
83 83
 
84
-    // list table args
85
-    protected $_view;
84
+	// list table args
85
+	protected $_view;
86 86
 
87
-    protected $_views;
87
+	protected $_views;
88 88
 
89 89
 
90
-    // action => method pairs used for routing incoming requests
91
-    protected $_page_routes;
90
+	// action => method pairs used for routing incoming requests
91
+	protected $_page_routes;
92 92
 
93
-    /**
94
-     * @var array $_page_config
95
-     */
96
-    protected $_page_config;
93
+	/**
94
+	 * @var array $_page_config
95
+	 */
96
+	protected $_page_config;
97 97
 
98
-    /**
99
-     * the current page route and route config
100
-     *
101
-     * @var string $_route
102
-     */
103
-    protected $_route;
98
+	/**
99
+	 * the current page route and route config
100
+	 *
101
+	 * @var string $_route
102
+	 */
103
+	protected $_route;
104 104
 
105
-    /**
106
-     * @var string $_cpt_route
107
-     */
108
-    protected $_cpt_route;
105
+	/**
106
+	 * @var string $_cpt_route
107
+	 */
108
+	protected $_cpt_route;
109 109
 
110
-    /**
111
-     * @var array $_route_config
112
-     */
113
-    protected $_route_config;
110
+	/**
111
+	 * @var array $_route_config
112
+	 */
113
+	protected $_route_config;
114 114
 
115
-    /**
116
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
-     * actions.
118
-     *
119
-     * @since 4.6.x
120
-     * @var array.
121
-     */
122
-    protected $_default_route_query_args;
123
-
124
-    // set via request page and action args.
125
-    protected $_current_page;
126
-
127
-    protected $_current_view;
128
-
129
-    protected $_current_page_view_url;
130
-
131
-    // sanitized request action (and nonce)
132
-
133
-    /**
134
-     * @var string $_req_action
135
-     */
136
-    protected $_req_action;
137
-
138
-    /**
139
-     * @var string $_req_nonce
140
-     */
141
-    protected $_req_nonce;
142
-
143
-    // search related
144
-    protected $_search_btn_label;
145
-
146
-    protected $_search_box_callback;
147
-
148
-    /**
149
-     * WP Current Screen object
150
-     *
151
-     * @var WP_Screen
152
-     */
153
-    protected $_current_screen;
154
-
155
-    // for holding EE_Admin_Hooks object when needed (set via set_hook_object())
156
-    protected $_hook_obj;
157
-
158
-    // for holding incoming request data
159
-    protected $_req_data = [];
160
-
161
-    // yes / no array for admin form fields
162
-    protected $_yes_no_values = [];
163
-
164
-    // some default things shared by all child classes
165
-    protected $_default_espresso_metaboxes;
166
-
167
-    /**
168
-     *    EE_Registry Object
169
-     *
170
-     * @var    EE_Registry
171
-     */
172
-    protected $EE = null;
173
-
174
-
175
-    /**
176
-     * This is just a property that flags whether the given route is a caffeinated route or not.
177
-     *
178
-     * @var boolean
179
-     */
180
-    protected $_is_caf = false;
181
-
182
-
183
-    /**
184
-     * @Constructor
185
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
186
-     * @throws EE_Error
187
-     * @throws InvalidArgumentException
188
-     * @throws ReflectionException
189
-     * @throws InvalidDataTypeException
190
-     * @throws InvalidInterfaceException
191
-     */
192
-    public function __construct($routing = true)
193
-    {
194
-        $this->loader  = LoaderFactory::getLoader();
195
-        $this->request = $this->loader->getShared(RequestInterface::class);
196
-
197
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
198
-            $this->_is_caf = true;
199
-        }
200
-        $this->_yes_no_values = [
201
-            ['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
202
-            ['id' => false, 'text' => esc_html__('No', 'event_espresso')],
203
-        ];
204
-        // set the _req_data property.
205
-        $this->_req_data = $this->request->requestParams();
206
-        // routing enabled?
207
-        $this->_routing = $routing;
208
-        // set initial page props (child method)
209
-        $this->_init_page_props();
210
-        // set global defaults
211
-        $this->_set_defaults();
212
-        // set early because incoming requests could be ajax related and we need to register those hooks.
213
-        $this->_global_ajax_hooks();
214
-        $this->_ajax_hooks();
215
-        // other_page_hooks have to be early too.
216
-        $this->_do_other_page_hooks();
217
-        // This just allows us to have extending classes do something specific
218
-        // before the parent constructor runs _page_setup().
219
-        if (method_exists($this, '_before_page_setup')) {
220
-            $this->_before_page_setup();
221
-        }
222
-        // set up page dependencies
223
-        $this->_page_setup();
224
-    }
225
-
226
-
227
-    /**
228
-     * _init_page_props
229
-     * Child classes use to set at least the following properties:
230
-     * $page_slug.
231
-     * $page_label.
232
-     *
233
-     * @abstract
234
-     * @return void
235
-     */
236
-    abstract protected function _init_page_props();
237
-
238
-
239
-    /**
240
-     * _ajax_hooks
241
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
242
-     * Note: within the ajax callback methods.
243
-     *
244
-     * @abstract
245
-     * @return void
246
-     */
247
-    abstract protected function _ajax_hooks();
248
-
249
-
250
-    /**
251
-     * _define_page_props
252
-     * child classes define page properties in here.  Must include at least:
253
-     * $_admin_base_url = base_url for all admin pages
254
-     * $_admin_page_title = default admin_page_title for admin pages
255
-     * $_labels = array of default labels for various automatically generated elements:
256
-     *    array(
257
-     *        'buttons' => array(
258
-     *            'add' => esc_html__('label for add new button'),
259
-     *            'edit' => esc_html__('label for edit button'),
260
-     *            'delete' => esc_html__('label for delete button')
261
-     *            )
262
-     *        )
263
-     *
264
-     * @abstract
265
-     * @return void
266
-     */
267
-    abstract protected function _define_page_props();
268
-
269
-
270
-    /**
271
-     * _set_page_routes
272
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
273
-     * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
274
-     * have a 'default' route. Here's the format
275
-     * $this->_page_routes = array(
276
-     *        'default' => array(
277
-     *            'func' => '_default_method_handling_route',
278
-     *            'args' => array('array','of','args'),
279
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
280
-     *            ajax request, backend processing)
281
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
282
-     *            headers route after.  The string you enter here should match the defined route reference for a
283
-     *            headers sent route.
284
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
285
-     *            this route.
286
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
287
-     *            checks).
288
-     *        ),
289
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
290
-     *        handling method.
291
-     *        )
292
-     * )
293
-     *
294
-     * @abstract
295
-     * @return void
296
-     */
297
-    abstract protected function _set_page_routes();
298
-
299
-
300
-    /**
301
-     * _set_page_config
302
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
303
-     * array corresponds to the page_route for the loaded page. Format:
304
-     * $this->_page_config = array(
305
-     *        'default' => array(
306
-     *            'labels' => array(
307
-     *                'buttons' => array(
308
-     *                    'add' => esc_html__('label for adding item'),
309
-     *                    'edit' => esc_html__('label for editing item'),
310
-     *                    'delete' => esc_html__('label for deleting item')
311
-     *                ),
312
-     *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
313
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the
314
-     *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
315
-     *            _define_page_props() method
316
-     *            'nav' => array(
317
-     *                'label' => esc_html__('Label for Tab', 'event_espresso').
318
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
319
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
320
-     *                'order' => 10, //required to indicate tab position.
321
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
322
-     *                displayed then add this parameter.
323
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
324
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
325
-     *            metaboxes set for eventespresso admin pages.
326
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
327
-     *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
328
-     *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
329
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
330
-     *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
331
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
332
-     *            array indicates the max number of columns (4) and the default number of columns on page load (2).
333
-     *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
334
-     *            want to display.
335
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
336
-     *                'tab_id' => array(
337
-     *                    'title' => 'tab_title',
338
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
339
-     *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
340
-     *                    should match a file in the admin folder's "help_tabs" dir (ie..
341
-     *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
342
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
343
-     *                    attempt to use the callback which should match the name of a method in the class
344
-     *                    ),
345
-     *                'tab2_id' => array(
346
-     *                    'title' => 'tab2 title',
347
-     *                    'filename' => 'file_name_2'
348
-     *                    'callback' => 'callback_method_for_content',
349
-     *                 ),
350
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
351
-     *            help tab area on an admin page. @return void
352
-     *
353
-     * @link
354
-     *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
355
-     *                'help_tour' => array(
356
-     *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
357
-     *                in a folder for this admin page named "help_tours", a file name matching the key given here
358
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
359
-     *                ),
360
-     *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
361
-     *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
362
-     *                visited just set
363
-     *                'require_nonce' to FALSE
364
-     *                )
365
-     *                )
366
-     *
367
-     * @abstract
368
-     */
369
-    abstract protected function _set_page_config();
370
-
371
-
372
-
373
-
374
-
375
-    /** end sample help_tour methods **/
376
-    /**
377
-     * _add_screen_options
378
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
379
-     * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
380
-     * to a particular view.
381
-     *
382
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
383
-     *         see also WP_Screen object documents...
384
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
385
-     * @abstract
386
-     * @return void
387
-     */
388
-    abstract protected function _add_screen_options();
389
-
390
-
391
-    /**
392
-     * _add_feature_pointers
393
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
394
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
395
-     * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
396
-     * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
397
-     * extended) also see:
398
-     *
399
-     * @link   http://eamann.com/tech/wordpress-portland/
400
-     * @abstract
401
-     * @return void
402
-     */
403
-    abstract protected function _add_feature_pointers();
404
-
405
-
406
-    /**
407
-     * load_scripts_styles
408
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
409
-     * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
410
-     * scripts/styles per view by putting them in a dynamic function in this format
411
-     * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
412
-     *
413
-     * @abstract
414
-     * @return void
415
-     */
416
-    abstract public function load_scripts_styles();
417
-
418
-
419
-    /**
420
-     * admin_init
421
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
422
-     * all pages/views loaded by child class.
423
-     *
424
-     * @abstract
425
-     * @return void
426
-     */
427
-    abstract public function admin_init();
428
-
429
-
430
-    /**
431
-     * admin_notices
432
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
433
-     * all pages/views loaded by child class.
434
-     *
435
-     * @abstract
436
-     * @return void
437
-     */
438
-    abstract public function admin_notices();
439
-
440
-
441
-    /**
442
-     * admin_footer_scripts
443
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
-     * will apply to all pages/views loaded by child class.
445
-     *
446
-     * @return void
447
-     */
448
-    abstract public function admin_footer_scripts();
449
-
450
-
451
-    /**
452
-     * admin_footer
453
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
454
-     * apply to all pages/views loaded by child class.
455
-     *
456
-     * @return void
457
-     */
458
-    public function admin_footer()
459
-    {
460
-    }
461
-
462
-
463
-    /**
464
-     * _global_ajax_hooks
465
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
466
-     * Note: within the ajax callback methods.
467
-     *
468
-     * @abstract
469
-     * @return void
470
-     */
471
-    protected function _global_ajax_hooks()
472
-    {
473
-        // for lazy loading of metabox content
474
-        add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
475
-    }
476
-
477
-
478
-    public function ajax_metabox_content()
479
-    {
480
-        $content_id  = $this->request->getRequestParam('contentid', '');
481
-        $content_url = $this->request->getRequestParam('contenturl', '', 'url');
482
-        self::cached_rss_display($content_id, $content_url);
483
-        wp_die();
484
-    }
485
-
486
-
487
-    /**
488
-     * _page_setup
489
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
490
-     * doesn't match the object.
491
-     *
492
-     * @final
493
-     * @return void
494
-     * @throws EE_Error
495
-     * @throws InvalidArgumentException
496
-     * @throws ReflectionException
497
-     * @throws InvalidDataTypeException
498
-     * @throws InvalidInterfaceException
499
-     */
500
-    final protected function _page_setup()
501
-    {
502
-        // requires?
503
-        // admin_init stuff - global - we're setting this REALLY early
504
-        // so if EE_Admin pages have to hook into other WP pages they can.
505
-        // But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
-        add_action('admin_init', [$this, 'admin_init_global'], 5);
507
-        // next verify if we need to load anything...
508
-        $this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
-        $this->page_folder   = strtolower(
510
-            str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
-        );
512
-        global $ee_menu_slugs;
513
-        $ee_menu_slugs = (array) $ee_menu_slugs;
514
-        if (
515
-            ! defined('DOING_AJAX')
516
-            && (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
-        ) {
518
-            return;
519
-        }
520
-        // because WP List tables have two duplicate select inputs for choosing bulk actions,
521
-        // we need to copy the action from the second to the first
522
-        $action     = $this->request->getRequestParam('action', '-1', 'key');
523
-        $action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
-        $action     = $action !== '-1' ? $action : $action2;
525
-        $req_action = $action !== '-1' ? $action : 'default';
526
-
527
-        // if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
-        // then let's use the route as the action.
529
-        // This covers cases where we're coming in from a list table that isn't on the default route.
530
-        $route = $this->request->getRequestParam('route');
531
-        $this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
-            ? $route
533
-            : $req_action;
534
-        $this->_current_view = $this->_req_action;
535
-        $this->_req_nonce    = $this->_req_action . '_nonce';
536
-        $this->_define_page_props();
537
-        $this->_current_page_view_url = add_query_arg(
538
-            ['page' => $this->_current_page, 'action' => $this->_current_view],
539
-            $this->_admin_base_url
540
-        );
541
-        // default things
542
-        $this->_default_espresso_metaboxes = [
543
-            '_espresso_news_post_box',
544
-            '_espresso_links_post_box',
545
-            '_espresso_ratings_request',
546
-            '_espresso_sponsors_post_box',
547
-        ];
548
-        // set page configs
549
-        $this->_set_page_routes();
550
-        $this->_set_page_config();
551
-        // let's include any referrer data in our default_query_args for this route for "stickiness".
552
-        if ($this->request->requestParamIsSet('wp_referer')) {
553
-            $this->_default_route_query_args['wp_referer'] = $this->request->getRequestParam(
554
-                'wp_referer',
555
-                null,
556
-                'url'
557
-            );
558
-        }
559
-        // for caffeinated and other extended functionality.
560
-        //  If there is a _extend_page_config method
561
-        // then let's run that to modify the all the various page configuration arrays
562
-        if (method_exists($this, '_extend_page_config')) {
563
-            $this->_extend_page_config();
564
-        }
565
-        // for CPT and other extended functionality.
566
-        // If there is an _extend_page_config_for_cpt
567
-        // then let's run that to modify all the various page configuration arrays.
568
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
569
-            $this->_extend_page_config_for_cpt();
570
-        }
571
-        // filter routes and page_config so addons can add their stuff. Filtering done per class
572
-        $this->_page_routes = apply_filters(
573
-            'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
-            $this->_page_routes,
575
-            $this
576
-        );
577
-        $this->_page_config = apply_filters(
578
-            'FHEE__' . get_class($this) . '__page_setup__page_config',
579
-            $this->_page_config,
580
-            $this
581
-        );
582
-        // if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
-        // then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
-            add_action(
586
-                'AHEE__EE_Admin_Page__route_admin_request',
587
-                [$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
-                10,
589
-                2
590
-            );
591
-        }
592
-        // next route only if routing enabled
593
-        if ($this->_routing && ! defined('DOING_AJAX')) {
594
-            $this->_verify_routes();
595
-            // next let's just check user_access and kill if no access
596
-            $this->check_user_access();
597
-            if ($this->_is_UI_request) {
598
-                // admin_init stuff - global, all views for this page class, specific view
599
-                add_action('admin_init', [$this, 'admin_init'], 10);
600
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
-                    add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
-                }
603
-            } else {
604
-                // hijack regular WP loading and route admin request immediately
605
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
-                $this->route_admin_request();
607
-            }
608
-        }
609
-    }
610
-
611
-
612
-    /**
613
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
-     *
615
-     * @return void
616
-     * @throws ReflectionException
617
-     * @throws EE_Error
618
-     */
619
-    private function _do_other_page_hooks()
620
-    {
621
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
-        foreach ($registered_pages as $page) {
623
-            // now let's setup the file name and class that should be present
624
-            $classname = str_replace('.class.php', '', $page);
625
-            // autoloaders should take care of loading file
626
-            if (! class_exists($classname)) {
627
-                $error_msg[] = sprintf(
628
-                    esc_html__(
629
-                        'Something went wrong with loading the %s admin hooks page.',
630
-                        'event_espresso'
631
-                    ),
632
-                    $page
633
-                );
634
-                $error_msg[] = $error_msg[0]
635
-                               . "\r\n"
636
-                               . sprintf(
637
-                                   esc_html__(
638
-                                       'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
639
-                                       'event_espresso'
640
-                                   ),
641
-                                   $page,
642
-                                   '<br />',
643
-                                   '<strong>' . $classname . '</strong>'
644
-                               );
645
-                throw new EE_Error(implode('||', $error_msg));
646
-            }
647
-            $a = new ReflectionClass($classname);
648
-            // notice we are passing the instance of this class to the hook object.
649
-            $hookobj[] = $a->newInstance($this);
650
-        }
651
-    }
652
-
653
-
654
-    /**
655
-     * @throws ReflectionException
656
-     * @throws EE_Error
657
-     */
658
-    public function load_page_dependencies()
659
-    {
660
-        try {
661
-            $this->_load_page_dependencies();
662
-        } catch (EE_Error $e) {
663
-            $e->get_error();
664
-        }
665
-    }
666
-
667
-
668
-    /**
669
-     * load_page_dependencies
670
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
-     *
672
-     * @return void
673
-     * @throws DomainException
674
-     * @throws EE_Error
675
-     * @throws InvalidArgumentException
676
-     * @throws InvalidDataTypeException
677
-     * @throws InvalidInterfaceException
678
-     */
679
-    protected function _load_page_dependencies()
680
-    {
681
-        // let's set the current_screen and screen options to override what WP set
682
-        $this->_current_screen = get_current_screen();
683
-        // load admin_notices - global, page class, and view specific
684
-        add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
-        add_action('admin_notices', [$this, 'admin_notices'], 10);
686
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
-            add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
-        }
689
-        // load network admin_notices - global, page class, and view specific
690
-        add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
-            add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
-        }
694
-        // this will save any per_page screen options if they are present
695
-        $this->_set_per_page_screen_options();
696
-        // setup list table properties
697
-        $this->_set_list_table();
698
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
-        // However in some cases the metaboxes will need to be added within a route handling callback.
700
-        $this->_add_registered_meta_boxes();
701
-        $this->_add_screen_columns();
702
-        // add screen options - global, page child class, and view specific
703
-        $this->_add_global_screen_options();
704
-        $this->_add_screen_options();
705
-        $add_screen_options = "_add_screen_options_{$this->_current_view}";
706
-        if (method_exists($this, $add_screen_options)) {
707
-            $this->{$add_screen_options}();
708
-        }
709
-        // add help tab(s) and tours- set via page_config and qtips.
710
-        // $this->_add_help_tour();
711
-        $this->_add_help_tabs();
712
-        $this->_add_qtips();
713
-        // add feature_pointers - global, page child class, and view specific
714
-        $this->_add_feature_pointers();
715
-        $this->_add_global_feature_pointers();
716
-        $add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
717
-        if (method_exists($this, $add_feature_pointer)) {
718
-            $this->{$add_feature_pointer}();
719
-        }
720
-        // enqueue scripts/styles - global, page class, and view specific
721
-        add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
722
-        add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
723
-        if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
724
-            add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
725
-        }
726
-        add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
727
-        // admin_print_footer_scripts - global, page child class, and view specific.
728
-        // NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
729
-        // In most cases that's doing_it_wrong().  But adding hidden container elements etc.
730
-        // is a good use case. Notice the late priority we're giving these
731
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
732
-        add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
733
-        if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
734
-            add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
735
-        }
736
-        // admin footer scripts
737
-        add_action('admin_footer', [$this, 'admin_footer_global'], 99);
738
-        add_action('admin_footer', [$this, 'admin_footer'], 100);
739
-        if (method_exists($this, "admin_footer_{$this->_current_view}")) {
740
-            add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
741
-        }
742
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
743
-        // targeted hook
744
-        do_action(
745
-            "FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
746
-        );
747
-    }
748
-
749
-
750
-    /**
751
-     * _set_defaults
752
-     * This sets some global defaults for class properties.
753
-     */
754
-    private function _set_defaults()
755
-    {
756
-        $this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
757
-        $this->_event                = $this->_template_path = $this->_column_template_path = null;
758
-        $this->_nav_tabs             = $this->_views = $this->_page_routes = [];
759
-        $this->_page_config          = $this->_default_route_query_args = [];
760
-        $this->_default_nav_tab_name = 'overview';
761
-        // init template args
762
-        $this->_template_args = [
763
-            'admin_page_header'  => '',
764
-            'admin_page_content' => '',
765
-            'post_body_content'  => '',
766
-            'before_list_table'  => '',
767
-            'after_list_table'   => '',
768
-        ];
769
-    }
770
-
771
-
772
-    /**
773
-     * route_admin_request
774
-     *
775
-     * @return void
776
-     * @throws InvalidArgumentException
777
-     * @throws InvalidInterfaceException
778
-     * @throws InvalidDataTypeException
779
-     * @throws EE_Error
780
-     * @throws ReflectionException
781
-     * @see    _route_admin_request()
782
-     */
783
-    public function route_admin_request()
784
-    {
785
-        try {
786
-            $this->_route_admin_request();
787
-        } catch (EE_Error $e) {
788
-            $e->get_error();
789
-        }
790
-    }
791
-
792
-
793
-    public function set_wp_page_slug($wp_page_slug)
794
-    {
795
-        $this->_wp_page_slug = $wp_page_slug;
796
-        // if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
797
-        if (is_network_admin()) {
798
-            $this->_wp_page_slug .= '-network';
799
-        }
800
-    }
801
-
802
-
803
-    /**
804
-     * _verify_routes
805
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
806
-     * we know if we need to drop out.
807
-     *
808
-     * @return bool
809
-     * @throws EE_Error
810
-     */
811
-    protected function _verify_routes()
812
-    {
813
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
814
-        if (! $this->_current_page && ! defined('DOING_AJAX')) {
815
-            return false;
816
-        }
817
-        $this->_route = false;
818
-        // check that the page_routes array is not empty
819
-        if (empty($this->_page_routes)) {
820
-            // user error msg
821
-            $error_msg = sprintf(
822
-                esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
823
-                $this->_admin_page_title
824
-            );
825
-            // developer error msg
826
-            $error_msg .= '||' . $error_msg
827
-                          . esc_html__(
828
-                              ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
829
-                              'event_espresso'
830
-                          );
831
-            throw new EE_Error($error_msg);
832
-        }
833
-        // and that the requested page route exists
834
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
835
-            $this->_route        = $this->_page_routes[ $this->_req_action ];
836
-            $this->_route_config = isset($this->_page_config[ $this->_req_action ])
837
-                ? $this->_page_config[ $this->_req_action ] : [];
838
-        } else {
839
-            // user error msg
840
-            $error_msg = sprintf(
841
-                esc_html__(
842
-                    'The requested page route does not exist for the %s admin page.',
843
-                    'event_espresso'
844
-                ),
845
-                $this->_admin_page_title
846
-            );
847
-            // developer error msg
848
-            $error_msg .= '||' . $error_msg
849
-                          . sprintf(
850
-                              esc_html__(
851
-                                  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
-                                  'event_espresso'
853
-                              ),
854
-                              $this->_req_action
855
-                          );
856
-            throw new EE_Error($error_msg);
857
-        }
858
-        // and that a default route exists
859
-        if (! array_key_exists('default', $this->_page_routes)) {
860
-            // user error msg
861
-            $error_msg = sprintf(
862
-                esc_html__(
863
-                    'A default page route has not been set for the % admin page.',
864
-                    'event_espresso'
865
-                ),
866
-                $this->_admin_page_title
867
-            );
868
-            // developer error msg
869
-            $error_msg .= '||' . $error_msg
870
-                          . esc_html__(
871
-                              ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
-                              'event_espresso'
873
-                          );
874
-            throw new EE_Error($error_msg);
875
-        }
876
-        // first lets' catch if the UI request has EVER been set.
877
-        if ($this->_is_UI_request === null) {
878
-            // lets set if this is a UI request or not.
879
-            $this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
-            // wait a minute... we might have a noheader in the route array
881
-            $this->_is_UI_request = ! (
882
-                is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
-            )
884
-                ? $this->_is_UI_request
885
-                : false;
886
-        }
887
-        $this->_set_current_labels();
888
-        return true;
889
-    }
890
-
891
-
892
-    /**
893
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
-     *
895
-     * @param string $route the route name we're verifying
896
-     * @return bool we'll throw an exception if this isn't a valid route.
897
-     * @throws EE_Error
898
-     */
899
-    protected function _verify_route($route)
900
-    {
901
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
-            return true;
903
-        }
904
-        // user error msg
905
-        $error_msg = sprintf(
906
-            esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
-            $this->_admin_page_title
908
-        );
909
-        // developer error msg
910
-        $error_msg .= '||' . $error_msg
911
-                      . sprintf(
912
-                          esc_html__(
913
-                              ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
-                              'event_espresso'
915
-                          ),
916
-                          $route
917
-                      );
918
-        throw new EE_Error($error_msg);
919
-    }
920
-
921
-
922
-    /**
923
-     * perform nonce verification
924
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
-     * using this method (and save retyping!)
926
-     *
927
-     * @param string $nonce     The nonce sent
928
-     * @param string $nonce_ref The nonce reference string (name0)
929
-     * @return void
930
-     * @throws EE_Error
931
-     */
932
-    protected function _verify_nonce($nonce, $nonce_ref)
933
-    {
934
-        // verify nonce against expected value
935
-        if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
-            // these are not the droids you are looking for !!!
937
-            $msg = sprintf(
938
-                esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
-                '<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
-                '</a>'
941
-            );
942
-            if (WP_DEBUG) {
943
-                $msg .= "\n  ";
944
-                $msg .= sprintf(
945
-                    esc_html__(
946
-                        'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
-                        'event_espresso'
948
-                    ),
949
-                    __CLASS__
950
-                );
951
-            }
952
-            if (! defined('DOING_AJAX')) {
953
-                wp_die($msg);
954
-            }
955
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
-            $this->_return_json();
957
-        }
958
-    }
959
-
960
-
961
-    /**
962
-     * _route_admin_request()
963
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
-     * in the page routes and then will try to load the corresponding method.
966
-     *
967
-     * @return void
968
-     * @throws EE_Error
969
-     * @throws InvalidArgumentException
970
-     * @throws InvalidDataTypeException
971
-     * @throws InvalidInterfaceException
972
-     * @throws ReflectionException
973
-     */
974
-    protected function _route_admin_request()
975
-    {
976
-        if (! $this->_is_UI_request) {
977
-            $this->_verify_routes();
978
-        }
979
-        $nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
-        if ($this->_req_action !== 'default' && $nonce_check) {
981
-            // set nonce from post data
982
-            $nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
-            $this->_verify_nonce($nonce, $this->_req_nonce);
984
-        }
985
-        // set the nav_tabs array but ONLY if this is  UI_request
986
-        if ($this->_is_UI_request) {
987
-            $this->_set_nav_tabs();
988
-        }
989
-        // grab callback function
990
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
-        // check if callback has args
992
-        $args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
-        $error_msg = '';
994
-        // action right before calling route
995
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
-        if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
-        }
999
-        // right before calling the route, let's clean the _wp_http_referer
1000
-        $this->request->setServerParam(
1001
-            'REQUEST_URI',
1002
-            remove_query_arg(
1003
-                '_wp_http_referer',
1004
-                wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
-            )
1006
-        );
1007
-        if (! empty($func)) {
1008
-            if (is_array($func)) {
1009
-                list($class, $method) = $func;
1010
-            } elseif (strpos($func, '::') !== false) {
1011
-                list($class, $method) = explode('::', $func);
1012
-            } else {
1013
-                $class  = $this;
1014
-                $method = $func;
1015
-            }
1016
-            if (! (is_object($class) && $class === $this)) {
1017
-                // send along this admin page object for access by addons.
1018
-                $args['admin_page_object'] = $this;
1019
-            }
1020
-            if (
115
+	/**
116
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
117
+	 * actions.
118
+	 *
119
+	 * @since 4.6.x
120
+	 * @var array.
121
+	 */
122
+	protected $_default_route_query_args;
123
+
124
+	// set via request page and action args.
125
+	protected $_current_page;
126
+
127
+	protected $_current_view;
128
+
129
+	protected $_current_page_view_url;
130
+
131
+	// sanitized request action (and nonce)
132
+
133
+	/**
134
+	 * @var string $_req_action
135
+	 */
136
+	protected $_req_action;
137
+
138
+	/**
139
+	 * @var string $_req_nonce
140
+	 */
141
+	protected $_req_nonce;
142
+
143
+	// search related
144
+	protected $_search_btn_label;
145
+
146
+	protected $_search_box_callback;
147
+
148
+	/**
149
+	 * WP Current Screen object
150
+	 *
151
+	 * @var WP_Screen
152
+	 */
153
+	protected $_current_screen;
154
+
155
+	// for holding EE_Admin_Hooks object when needed (set via set_hook_object())
156
+	protected $_hook_obj;
157
+
158
+	// for holding incoming request data
159
+	protected $_req_data = [];
160
+
161
+	// yes / no array for admin form fields
162
+	protected $_yes_no_values = [];
163
+
164
+	// some default things shared by all child classes
165
+	protected $_default_espresso_metaboxes;
166
+
167
+	/**
168
+	 *    EE_Registry Object
169
+	 *
170
+	 * @var    EE_Registry
171
+	 */
172
+	protected $EE = null;
173
+
174
+
175
+	/**
176
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
177
+	 *
178
+	 * @var boolean
179
+	 */
180
+	protected $_is_caf = false;
181
+
182
+
183
+	/**
184
+	 * @Constructor
185
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
186
+	 * @throws EE_Error
187
+	 * @throws InvalidArgumentException
188
+	 * @throws ReflectionException
189
+	 * @throws InvalidDataTypeException
190
+	 * @throws InvalidInterfaceException
191
+	 */
192
+	public function __construct($routing = true)
193
+	{
194
+		$this->loader  = LoaderFactory::getLoader();
195
+		$this->request = $this->loader->getShared(RequestInterface::class);
196
+
197
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
198
+			$this->_is_caf = true;
199
+		}
200
+		$this->_yes_no_values = [
201
+			['id' => true, 'text' => esc_html__('Yes', 'event_espresso')],
202
+			['id' => false, 'text' => esc_html__('No', 'event_espresso')],
203
+		];
204
+		// set the _req_data property.
205
+		$this->_req_data = $this->request->requestParams();
206
+		// routing enabled?
207
+		$this->_routing = $routing;
208
+		// set initial page props (child method)
209
+		$this->_init_page_props();
210
+		// set global defaults
211
+		$this->_set_defaults();
212
+		// set early because incoming requests could be ajax related and we need to register those hooks.
213
+		$this->_global_ajax_hooks();
214
+		$this->_ajax_hooks();
215
+		// other_page_hooks have to be early too.
216
+		$this->_do_other_page_hooks();
217
+		// This just allows us to have extending classes do something specific
218
+		// before the parent constructor runs _page_setup().
219
+		if (method_exists($this, '_before_page_setup')) {
220
+			$this->_before_page_setup();
221
+		}
222
+		// set up page dependencies
223
+		$this->_page_setup();
224
+	}
225
+
226
+
227
+	/**
228
+	 * _init_page_props
229
+	 * Child classes use to set at least the following properties:
230
+	 * $page_slug.
231
+	 * $page_label.
232
+	 *
233
+	 * @abstract
234
+	 * @return void
235
+	 */
236
+	abstract protected function _init_page_props();
237
+
238
+
239
+	/**
240
+	 * _ajax_hooks
241
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
242
+	 * Note: within the ajax callback methods.
243
+	 *
244
+	 * @abstract
245
+	 * @return void
246
+	 */
247
+	abstract protected function _ajax_hooks();
248
+
249
+
250
+	/**
251
+	 * _define_page_props
252
+	 * child classes define page properties in here.  Must include at least:
253
+	 * $_admin_base_url = base_url for all admin pages
254
+	 * $_admin_page_title = default admin_page_title for admin pages
255
+	 * $_labels = array of default labels for various automatically generated elements:
256
+	 *    array(
257
+	 *        'buttons' => array(
258
+	 *            'add' => esc_html__('label for add new button'),
259
+	 *            'edit' => esc_html__('label for edit button'),
260
+	 *            'delete' => esc_html__('label for delete button')
261
+	 *            )
262
+	 *        )
263
+	 *
264
+	 * @abstract
265
+	 * @return void
266
+	 */
267
+	abstract protected function _define_page_props();
268
+
269
+
270
+	/**
271
+	 * _set_page_routes
272
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are
273
+	 * assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also
274
+	 * have a 'default' route. Here's the format
275
+	 * $this->_page_routes = array(
276
+	 *        'default' => array(
277
+	 *            'func' => '_default_method_handling_route',
278
+	 *            'args' => array('array','of','args'),
279
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e.
280
+	 *            ajax request, backend processing)
281
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a
282
+	 *            headers route after.  The string you enter here should match the defined route reference for a
283
+	 *            headers sent route.
284
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access
285
+	 *            this route.
286
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability
287
+	 *            checks).
288
+	 *        ),
289
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a
290
+	 *        handling method.
291
+	 *        )
292
+	 * )
293
+	 *
294
+	 * @abstract
295
+	 * @return void
296
+	 */
297
+	abstract protected function _set_page_routes();
298
+
299
+
300
+	/**
301
+	 * _set_page_config
302
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the
303
+	 * array corresponds to the page_route for the loaded page. Format:
304
+	 * $this->_page_config = array(
305
+	 *        'default' => array(
306
+	 *            'labels' => array(
307
+	 *                'buttons' => array(
308
+	 *                    'add' => esc_html__('label for adding item'),
309
+	 *                    'edit' => esc_html__('label for editing item'),
310
+	 *                    'delete' => esc_html__('label for deleting item')
311
+	 *                ),
312
+	 *                'publishbox' => esc_html__('Localized Title for Publish metabox', 'event_espresso')
313
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the
314
+	 *            page. If this isn't present then the defaults will be used as set for the $this->_labels in
315
+	 *            _define_page_props() method
316
+	 *            'nav' => array(
317
+	 *                'label' => esc_html__('Label for Tab', 'event_espresso').
318
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
319
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
320
+	 *                'order' => 10, //required to indicate tab position.
321
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is
322
+	 *                displayed then add this parameter.
323
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
324
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load
325
+	 *            metaboxes set for eventespresso admin pages.
326
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have
327
+	 *            metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added
328
+	 *            later.  We just use this flag to make sure the necessary js gets enqueued on page load.
329
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the
330
+	 *            given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
331
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The
332
+	 *            array indicates the max number of columns (4) and the default number of columns on page load (2).
333
+	 *            There is an option in the "screen_options" dropdown that is setup so users can pick what columns they
334
+	 *            want to display.
335
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
336
+	 *                'tab_id' => array(
337
+	 *                    'title' => 'tab_title',
338
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting
339
+	 *                    help tab content.  The fallback if it isn't present is to try a the callback.  Filename
340
+	 *                    should match a file in the admin folder's "help_tabs" dir (ie..
341
+	 *                    events/help_tabs/name_of_file_containing_content.help_tab.php)
342
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will
343
+	 *                    attempt to use the callback which should match the name of a method in the class
344
+	 *                    ),
345
+	 *                'tab2_id' => array(
346
+	 *                    'title' => 'tab2 title',
347
+	 *                    'filename' => 'file_name_2'
348
+	 *                    'callback' => 'callback_method_for_content',
349
+	 *                 ),
350
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the
351
+	 *            help tab area on an admin page. @return void
352
+	 *
353
+	 * @link
354
+	 *                http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
355
+	 *                'help_tour' => array(
356
+	 *                'name_of_help_tour_class', //all help tours should be a child class of EE_Help_Tour and located
357
+	 *                in a folder for this admin page named "help_tours", a file name matching the key given here
358
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
359
+	 *                ),
360
+	 *                'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default
361
+	 *                is true if it isn't present).  To remove the requirement for a nonce check when this route is
362
+	 *                visited just set
363
+	 *                'require_nonce' to FALSE
364
+	 *                )
365
+	 *                )
366
+	 *
367
+	 * @abstract
368
+	 */
369
+	abstract protected function _set_page_config();
370
+
371
+
372
+
373
+
374
+
375
+	/** end sample help_tour methods **/
376
+	/**
377
+	 * _add_screen_options
378
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for
379
+	 * doing so. Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options
380
+	 * to a particular view.
381
+	 *
382
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
383
+	 *         see also WP_Screen object documents...
384
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
385
+	 * @abstract
386
+	 * @return void
387
+	 */
388
+	abstract protected function _add_screen_options();
389
+
390
+
391
+	/**
392
+	 * _add_feature_pointers
393
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
394
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a
395
+	 * particular view. Note: this is just a placeholder for now.  Implementation will come down the road See:
396
+	 * WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
397
+	 * extended) also see:
398
+	 *
399
+	 * @link   http://eamann.com/tech/wordpress-portland/
400
+	 * @abstract
401
+	 * @return void
402
+	 */
403
+	abstract protected function _add_feature_pointers();
404
+
405
+
406
+	/**
407
+	 * load_scripts_styles
408
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for
409
+	 * their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific
410
+	 * scripts/styles per view by putting them in a dynamic function in this format
411
+	 * (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
412
+	 *
413
+	 * @abstract
414
+	 * @return void
415
+	 */
416
+	abstract public function load_scripts_styles();
417
+
418
+
419
+	/**
420
+	 * admin_init
421
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to
422
+	 * all pages/views loaded by child class.
423
+	 *
424
+	 * @abstract
425
+	 * @return void
426
+	 */
427
+	abstract public function admin_init();
428
+
429
+
430
+	/**
431
+	 * admin_notices
432
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to
433
+	 * all pages/views loaded by child class.
434
+	 *
435
+	 * @abstract
436
+	 * @return void
437
+	 */
438
+	abstract public function admin_notices();
439
+
440
+
441
+	/**
442
+	 * admin_footer_scripts
443
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
444
+	 * will apply to all pages/views loaded by child class.
445
+	 *
446
+	 * @return void
447
+	 */
448
+	abstract public function admin_footer_scripts();
449
+
450
+
451
+	/**
452
+	 * admin_footer
453
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will
454
+	 * apply to all pages/views loaded by child class.
455
+	 *
456
+	 * @return void
457
+	 */
458
+	public function admin_footer()
459
+	{
460
+	}
461
+
462
+
463
+	/**
464
+	 * _global_ajax_hooks
465
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
466
+	 * Note: within the ajax callback methods.
467
+	 *
468
+	 * @abstract
469
+	 * @return void
470
+	 */
471
+	protected function _global_ajax_hooks()
472
+	{
473
+		// for lazy loading of metabox content
474
+		add_action('wp_ajax_espresso-ajax-content', [$this, 'ajax_metabox_content'], 10);
475
+	}
476
+
477
+
478
+	public function ajax_metabox_content()
479
+	{
480
+		$content_id  = $this->request->getRequestParam('contentid', '');
481
+		$content_url = $this->request->getRequestParam('contenturl', '', 'url');
482
+		self::cached_rss_display($content_id, $content_url);
483
+		wp_die();
484
+	}
485
+
486
+
487
+	/**
488
+	 * _page_setup
489
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested
490
+	 * doesn't match the object.
491
+	 *
492
+	 * @final
493
+	 * @return void
494
+	 * @throws EE_Error
495
+	 * @throws InvalidArgumentException
496
+	 * @throws ReflectionException
497
+	 * @throws InvalidDataTypeException
498
+	 * @throws InvalidInterfaceException
499
+	 */
500
+	final protected function _page_setup()
501
+	{
502
+		// requires?
503
+		// admin_init stuff - global - we're setting this REALLY early
504
+		// so if EE_Admin pages have to hook into other WP pages they can.
505
+		// But keep in mind, not everything is available from the EE_Admin Page object at this point.
506
+		add_action('admin_init', [$this, 'admin_init_global'], 5);
507
+		// next verify if we need to load anything...
508
+		$this->_current_page = $this->request->getRequestParam('page', '', 'key');
509
+		$this->page_folder   = strtolower(
510
+			str_replace(['_Admin_Page', 'Extend_'], '', get_class($this))
511
+		);
512
+		global $ee_menu_slugs;
513
+		$ee_menu_slugs = (array) $ee_menu_slugs;
514
+		if (
515
+			! defined('DOING_AJAX')
516
+			&& (! $this->_current_page || ! isset($ee_menu_slugs[ $this->_current_page ]))
517
+		) {
518
+			return;
519
+		}
520
+		// because WP List tables have two duplicate select inputs for choosing bulk actions,
521
+		// we need to copy the action from the second to the first
522
+		$action     = $this->request->getRequestParam('action', '-1', 'key');
523
+		$action2    = $this->request->getRequestParam('action2', '-1', 'key');
524
+		$action     = $action !== '-1' ? $action : $action2;
525
+		$req_action = $action !== '-1' ? $action : 'default';
526
+
527
+		// if a specific 'route' has been set, and the action is 'default' OR we are doing_ajax
528
+		// then let's use the route as the action.
529
+		// This covers cases where we're coming in from a list table that isn't on the default route.
530
+		$route = $this->request->getRequestParam('route');
531
+		$this->_req_action = $route && ($req_action === 'default' || $this->request->isAjax())
532
+			? $route
533
+			: $req_action;
534
+		$this->_current_view = $this->_req_action;
535
+		$this->_req_nonce    = $this->_req_action . '_nonce';
536
+		$this->_define_page_props();
537
+		$this->_current_page_view_url = add_query_arg(
538
+			['page' => $this->_current_page, 'action' => $this->_current_view],
539
+			$this->_admin_base_url
540
+		);
541
+		// default things
542
+		$this->_default_espresso_metaboxes = [
543
+			'_espresso_news_post_box',
544
+			'_espresso_links_post_box',
545
+			'_espresso_ratings_request',
546
+			'_espresso_sponsors_post_box',
547
+		];
548
+		// set page configs
549
+		$this->_set_page_routes();
550
+		$this->_set_page_config();
551
+		// let's include any referrer data in our default_query_args for this route for "stickiness".
552
+		if ($this->request->requestParamIsSet('wp_referer')) {
553
+			$this->_default_route_query_args['wp_referer'] = $this->request->getRequestParam(
554
+				'wp_referer',
555
+				null,
556
+				'url'
557
+			);
558
+		}
559
+		// for caffeinated and other extended functionality.
560
+		//  If there is a _extend_page_config method
561
+		// then let's run that to modify the all the various page configuration arrays
562
+		if (method_exists($this, '_extend_page_config')) {
563
+			$this->_extend_page_config();
564
+		}
565
+		// for CPT and other extended functionality.
566
+		// If there is an _extend_page_config_for_cpt
567
+		// then let's run that to modify all the various page configuration arrays.
568
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
569
+			$this->_extend_page_config_for_cpt();
570
+		}
571
+		// filter routes and page_config so addons can add their stuff. Filtering done per class
572
+		$this->_page_routes = apply_filters(
573
+			'FHEE__' . get_class($this) . '__page_setup__page_routes',
574
+			$this->_page_routes,
575
+			$this
576
+		);
577
+		$this->_page_config = apply_filters(
578
+			'FHEE__' . get_class($this) . '__page_setup__page_config',
579
+			$this->_page_config,
580
+			$this
581
+		);
582
+		// if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present
583
+		// then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
584
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
585
+			add_action(
586
+				'AHEE__EE_Admin_Page__route_admin_request',
587
+				[$this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view],
588
+				10,
589
+				2
590
+			);
591
+		}
592
+		// next route only if routing enabled
593
+		if ($this->_routing && ! defined('DOING_AJAX')) {
594
+			$this->_verify_routes();
595
+			// next let's just check user_access and kill if no access
596
+			$this->check_user_access();
597
+			if ($this->_is_UI_request) {
598
+				// admin_init stuff - global, all views for this page class, specific view
599
+				add_action('admin_init', [$this, 'admin_init'], 10);
600
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
601
+					add_action('admin_init', [$this, 'admin_init_' . $this->_current_view], 15);
602
+				}
603
+			} else {
604
+				// hijack regular WP loading and route admin request immediately
605
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
606
+				$this->route_admin_request();
607
+			}
608
+		}
609
+	}
610
+
611
+
612
+	/**
613
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
614
+	 *
615
+	 * @return void
616
+	 * @throws ReflectionException
617
+	 * @throws EE_Error
618
+	 */
619
+	private function _do_other_page_hooks()
620
+	{
621
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, []);
622
+		foreach ($registered_pages as $page) {
623
+			// now let's setup the file name and class that should be present
624
+			$classname = str_replace('.class.php', '', $page);
625
+			// autoloaders should take care of loading file
626
+			if (! class_exists($classname)) {
627
+				$error_msg[] = sprintf(
628
+					esc_html__(
629
+						'Something went wrong with loading the %s admin hooks page.',
630
+						'event_espresso'
631
+					),
632
+					$page
633
+				);
634
+				$error_msg[] = $error_msg[0]
635
+							   . "\r\n"
636
+							   . sprintf(
637
+								   esc_html__(
638
+									   'There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
639
+									   'event_espresso'
640
+								   ),
641
+								   $page,
642
+								   '<br />',
643
+								   '<strong>' . $classname . '</strong>'
644
+							   );
645
+				throw new EE_Error(implode('||', $error_msg));
646
+			}
647
+			$a = new ReflectionClass($classname);
648
+			// notice we are passing the instance of this class to the hook object.
649
+			$hookobj[] = $a->newInstance($this);
650
+		}
651
+	}
652
+
653
+
654
+	/**
655
+	 * @throws ReflectionException
656
+	 * @throws EE_Error
657
+	 */
658
+	public function load_page_dependencies()
659
+	{
660
+		try {
661
+			$this->_load_page_dependencies();
662
+		} catch (EE_Error $e) {
663
+			$e->get_error();
664
+		}
665
+	}
666
+
667
+
668
+	/**
669
+	 * load_page_dependencies
670
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
671
+	 *
672
+	 * @return void
673
+	 * @throws DomainException
674
+	 * @throws EE_Error
675
+	 * @throws InvalidArgumentException
676
+	 * @throws InvalidDataTypeException
677
+	 * @throws InvalidInterfaceException
678
+	 */
679
+	protected function _load_page_dependencies()
680
+	{
681
+		// let's set the current_screen and screen options to override what WP set
682
+		$this->_current_screen = get_current_screen();
683
+		// load admin_notices - global, page class, and view specific
684
+		add_action('admin_notices', [$this, 'admin_notices_global'], 5);
685
+		add_action('admin_notices', [$this, 'admin_notices'], 10);
686
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
687
+			add_action('admin_notices', [$this, 'admin_notices_' . $this->_current_view], 15);
688
+		}
689
+		// load network admin_notices - global, page class, and view specific
690
+		add_action('network_admin_notices', [$this, 'network_admin_notices_global'], 5);
691
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
692
+			add_action('network_admin_notices', [$this, 'network_admin_notices_' . $this->_current_view]);
693
+		}
694
+		// this will save any per_page screen options if they are present
695
+		$this->_set_per_page_screen_options();
696
+		// setup list table properties
697
+		$this->_set_list_table();
698
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.
699
+		// However in some cases the metaboxes will need to be added within a route handling callback.
700
+		$this->_add_registered_meta_boxes();
701
+		$this->_add_screen_columns();
702
+		// add screen options - global, page child class, and view specific
703
+		$this->_add_global_screen_options();
704
+		$this->_add_screen_options();
705
+		$add_screen_options = "_add_screen_options_{$this->_current_view}";
706
+		if (method_exists($this, $add_screen_options)) {
707
+			$this->{$add_screen_options}();
708
+		}
709
+		// add help tab(s) and tours- set via page_config and qtips.
710
+		// $this->_add_help_tour();
711
+		$this->_add_help_tabs();
712
+		$this->_add_qtips();
713
+		// add feature_pointers - global, page child class, and view specific
714
+		$this->_add_feature_pointers();
715
+		$this->_add_global_feature_pointers();
716
+		$add_feature_pointer = "_add_feature_pointer_{$this->_current_view}";
717
+		if (method_exists($this, $add_feature_pointer)) {
718
+			$this->{$add_feature_pointer}();
719
+		}
720
+		// enqueue scripts/styles - global, page class, and view specific
721
+		add_action('admin_enqueue_scripts', [$this, 'load_global_scripts_styles'], 5);
722
+		add_action('admin_enqueue_scripts', [$this, 'load_scripts_styles'], 10);
723
+		if (method_exists($this, "load_scripts_styles_{$this->_current_view}")) {
724
+			add_action('admin_enqueue_scripts', [$this, "load_scripts_styles_{$this->_current_view}"], 15);
725
+		}
726
+		add_action('admin_enqueue_scripts', [$this, 'admin_footer_scripts_eei18n_js_strings'], 100);
727
+		// admin_print_footer_scripts - global, page child class, and view specific.
728
+		// NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.
729
+		// In most cases that's doing_it_wrong().  But adding hidden container elements etc.
730
+		// is a good use case. Notice the late priority we're giving these
731
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts_global'], 99);
732
+		add_action('admin_print_footer_scripts', [$this, 'admin_footer_scripts'], 100);
733
+		if (method_exists($this, "admin_footer_scripts_{$this->_current_view}")) {
734
+			add_action('admin_print_footer_scripts', [$this, "admin_footer_scripts_{$this->_current_view}"], 101);
735
+		}
736
+		// admin footer scripts
737
+		add_action('admin_footer', [$this, 'admin_footer_global'], 99);
738
+		add_action('admin_footer', [$this, 'admin_footer'], 100);
739
+		if (method_exists($this, "admin_footer_{$this->_current_view}")) {
740
+			add_action('admin_footer', [$this, "admin_footer_{$this->_current_view}"], 101);
741
+		}
742
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
743
+		// targeted hook
744
+		do_action(
745
+			"FHEE__EE_Admin_Page___load_page_dependencies__after_load__{$this->page_slug}__{$this->_req_action}"
746
+		);
747
+	}
748
+
749
+
750
+	/**
751
+	 * _set_defaults
752
+	 * This sets some global defaults for class properties.
753
+	 */
754
+	private function _set_defaults()
755
+	{
756
+		$this->_current_screen       = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = null;
757
+		$this->_event                = $this->_template_path = $this->_column_template_path = null;
758
+		$this->_nav_tabs             = $this->_views = $this->_page_routes = [];
759
+		$this->_page_config          = $this->_default_route_query_args = [];
760
+		$this->_default_nav_tab_name = 'overview';
761
+		// init template args
762
+		$this->_template_args = [
763
+			'admin_page_header'  => '',
764
+			'admin_page_content' => '',
765
+			'post_body_content'  => '',
766
+			'before_list_table'  => '',
767
+			'after_list_table'   => '',
768
+		];
769
+	}
770
+
771
+
772
+	/**
773
+	 * route_admin_request
774
+	 *
775
+	 * @return void
776
+	 * @throws InvalidArgumentException
777
+	 * @throws InvalidInterfaceException
778
+	 * @throws InvalidDataTypeException
779
+	 * @throws EE_Error
780
+	 * @throws ReflectionException
781
+	 * @see    _route_admin_request()
782
+	 */
783
+	public function route_admin_request()
784
+	{
785
+		try {
786
+			$this->_route_admin_request();
787
+		} catch (EE_Error $e) {
788
+			$e->get_error();
789
+		}
790
+	}
791
+
792
+
793
+	public function set_wp_page_slug($wp_page_slug)
794
+	{
795
+		$this->_wp_page_slug = $wp_page_slug;
796
+		// if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
797
+		if (is_network_admin()) {
798
+			$this->_wp_page_slug .= '-network';
799
+		}
800
+	}
801
+
802
+
803
+	/**
804
+	 * _verify_routes
805
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so
806
+	 * we know if we need to drop out.
807
+	 *
808
+	 * @return bool
809
+	 * @throws EE_Error
810
+	 */
811
+	protected function _verify_routes()
812
+	{
813
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
814
+		if (! $this->_current_page && ! defined('DOING_AJAX')) {
815
+			return false;
816
+		}
817
+		$this->_route = false;
818
+		// check that the page_routes array is not empty
819
+		if (empty($this->_page_routes)) {
820
+			// user error msg
821
+			$error_msg = sprintf(
822
+				esc_html__('No page routes have been set for the %s admin page.', 'event_espresso'),
823
+				$this->_admin_page_title
824
+			);
825
+			// developer error msg
826
+			$error_msg .= '||' . $error_msg
827
+						  . esc_html__(
828
+							  ' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.',
829
+							  'event_espresso'
830
+						  );
831
+			throw new EE_Error($error_msg);
832
+		}
833
+		// and that the requested page route exists
834
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
835
+			$this->_route        = $this->_page_routes[ $this->_req_action ];
836
+			$this->_route_config = isset($this->_page_config[ $this->_req_action ])
837
+				? $this->_page_config[ $this->_req_action ] : [];
838
+		} else {
839
+			// user error msg
840
+			$error_msg = sprintf(
841
+				esc_html__(
842
+					'The requested page route does not exist for the %s admin page.',
843
+					'event_espresso'
844
+				),
845
+				$this->_admin_page_title
846
+			);
847
+			// developer error msg
848
+			$error_msg .= '||' . $error_msg
849
+						  . sprintf(
850
+							  esc_html__(
851
+								  ' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.',
852
+								  'event_espresso'
853
+							  ),
854
+							  $this->_req_action
855
+						  );
856
+			throw new EE_Error($error_msg);
857
+		}
858
+		// and that a default route exists
859
+		if (! array_key_exists('default', $this->_page_routes)) {
860
+			// user error msg
861
+			$error_msg = sprintf(
862
+				esc_html__(
863
+					'A default page route has not been set for the % admin page.',
864
+					'event_espresso'
865
+				),
866
+				$this->_admin_page_title
867
+			);
868
+			// developer error msg
869
+			$error_msg .= '||' . $error_msg
870
+						  . esc_html__(
871
+							  ' Create a key in the "_page_routes" array named "default" and set its value to your default page method.',
872
+							  'event_espresso'
873
+						  );
874
+			throw new EE_Error($error_msg);
875
+		}
876
+		// first lets' catch if the UI request has EVER been set.
877
+		if ($this->_is_UI_request === null) {
878
+			// lets set if this is a UI request or not.
879
+			$this->_is_UI_request = ! $this->request->getRequestParam('noheader', false, 'bool');
880
+			// wait a minute... we might have a noheader in the route array
881
+			$this->_is_UI_request = ! (
882
+				is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader']
883
+			)
884
+				? $this->_is_UI_request
885
+				: false;
886
+		}
887
+		$this->_set_current_labels();
888
+		return true;
889
+	}
890
+
891
+
892
+	/**
893
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
894
+	 *
895
+	 * @param string $route the route name we're verifying
896
+	 * @return bool we'll throw an exception if this isn't a valid route.
897
+	 * @throws EE_Error
898
+	 */
899
+	protected function _verify_route($route)
900
+	{
901
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
902
+			return true;
903
+		}
904
+		// user error msg
905
+		$error_msg = sprintf(
906
+			esc_html__('The given page route does not exist for the %s admin page.', 'event_espresso'),
907
+			$this->_admin_page_title
908
+		);
909
+		// developer error msg
910
+		$error_msg .= '||' . $error_msg
911
+					  . sprintf(
912
+						  esc_html__(
913
+							  ' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property',
914
+							  'event_espresso'
915
+						  ),
916
+						  $route
917
+					  );
918
+		throw new EE_Error($error_msg);
919
+	}
920
+
921
+
922
+	/**
923
+	 * perform nonce verification
924
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces
925
+	 * using this method (and save retyping!)
926
+	 *
927
+	 * @param string $nonce     The nonce sent
928
+	 * @param string $nonce_ref The nonce reference string (name0)
929
+	 * @return void
930
+	 * @throws EE_Error
931
+	 */
932
+	protected function _verify_nonce($nonce, $nonce_ref)
933
+	{
934
+		// verify nonce against expected value
935
+		if (! wp_verify_nonce($nonce, $nonce_ref)) {
936
+			// these are not the droids you are looking for !!!
937
+			$msg = sprintf(
938
+				esc_html__('%sNonce Fail.%s', 'event_espresso'),
939
+				'<a href="https://www.youtube.com/watch?v=56_S0WeTkzs">',
940
+				'</a>'
941
+			);
942
+			if (WP_DEBUG) {
943
+				$msg .= "\n  ";
944
+				$msg .= sprintf(
945
+					esc_html__(
946
+						'In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!',
947
+						'event_espresso'
948
+					),
949
+					__CLASS__
950
+				);
951
+			}
952
+			if (! defined('DOING_AJAX')) {
953
+				wp_die($msg);
954
+			}
955
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
956
+			$this->_return_json();
957
+		}
958
+	}
959
+
960
+
961
+	/**
962
+	 * _route_admin_request()
963
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
964
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
965
+	 * in the page routes and then will try to load the corresponding method.
966
+	 *
967
+	 * @return void
968
+	 * @throws EE_Error
969
+	 * @throws InvalidArgumentException
970
+	 * @throws InvalidDataTypeException
971
+	 * @throws InvalidInterfaceException
972
+	 * @throws ReflectionException
973
+	 */
974
+	protected function _route_admin_request()
975
+	{
976
+		if (! $this->_is_UI_request) {
977
+			$this->_verify_routes();
978
+		}
979
+		$nonce_check = ! isset($this->_route_config['require_nonce']) || $this->_route_config['require_nonce'];
980
+		if ($this->_req_action !== 'default' && $nonce_check) {
981
+			// set nonce from post data
982
+			$nonce = $this->request->getRequestParam($this->_req_nonce, '');
983
+			$this->_verify_nonce($nonce, $this->_req_nonce);
984
+		}
985
+		// set the nav_tabs array but ONLY if this is  UI_request
986
+		if ($this->_is_UI_request) {
987
+			$this->_set_nav_tabs();
988
+		}
989
+		// grab callback function
990
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
991
+		// check if callback has args
992
+		$args      = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : [];
993
+		$error_msg = '';
994
+		// action right before calling route
995
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
996
+		if (! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
997
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
998
+		}
999
+		// right before calling the route, let's clean the _wp_http_referer
1000
+		$this->request->setServerParam(
1001
+			'REQUEST_URI',
1002
+			remove_query_arg(
1003
+				'_wp_http_referer',
1004
+				wp_unslash($this->request->getServerParam('REQUEST_URI'))
1005
+			)
1006
+		);
1007
+		if (! empty($func)) {
1008
+			if (is_array($func)) {
1009
+				list($class, $method) = $func;
1010
+			} elseif (strpos($func, '::') !== false) {
1011
+				list($class, $method) = explode('::', $func);
1012
+			} else {
1013
+				$class  = $this;
1014
+				$method = $func;
1015
+			}
1016
+			if (! (is_object($class) && $class === $this)) {
1017
+				// send along this admin page object for access by addons.
1018
+				$args['admin_page_object'] = $this;
1019
+			}
1020
+			if (
1021 1021
 // is it a method on a class that doesn't work?
1022
-                (
1023
-                    (
1024
-                        method_exists($class, $method)
1025
-                        && call_user_func_array([$class, $method], $args) === false
1026
-                    )
1027
-                    && (
1028
-                        // is it a standalone function that doesn't work?
1029
-                        function_exists($method)
1030
-                        && call_user_func_array(
1031
-                            $func,
1032
-                            array_merge(['admin_page_object' => $this], $args)
1033
-                        ) === false
1034
-                    )
1035
-                )
1036
-                || (
1037
-                    // is it neither a class method NOR a standalone function?
1038
-                    ! method_exists($class, $method)
1039
-                    && ! function_exists($method)
1040
-                )
1041
-            ) {
1042
-                // user error msg
1043
-                $error_msg = esc_html__(
1044
-                    'An error occurred. The  requested page route could not be found.',
1045
-                    'event_espresso'
1046
-                );
1047
-                // developer error msg
1048
-                $error_msg .= '||';
1049
-                $error_msg .= sprintf(
1050
-                    esc_html__(
1051
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1052
-                        'event_espresso'
1053
-                    ),
1054
-                    $method
1055
-                );
1056
-            }
1057
-            if (! empty($error_msg)) {
1058
-                throw new EE_Error($error_msg);
1059
-            }
1060
-        }
1061
-        // if we've routed and this route has a no headers route AND a sent_headers_route,
1062
-        // then we need to reset the routing properties to the new route.
1063
-        // now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1064
-        if (
1065
-            $this->_is_UI_request === false
1066
-            && is_array($this->_route)
1067
-            && ! empty($this->_route['headers_sent_route'])
1068
-        ) {
1069
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
1070
-        }
1071
-    }
1072
-
1073
-
1074
-    /**
1075
-     * This method just allows the resetting of page properties in the case where a no headers
1076
-     * route redirects to a headers route in its route config.
1077
-     *
1078
-     * @param string $new_route New (non header) route to redirect to.
1079
-     * @return   void
1080
-     * @throws ReflectionException
1081
-     * @throws InvalidArgumentException
1082
-     * @throws InvalidInterfaceException
1083
-     * @throws InvalidDataTypeException
1084
-     * @throws EE_Error
1085
-     * @since   4.3.0
1086
-     */
1087
-    protected function _reset_routing_properties($new_route)
1088
-    {
1089
-        $this->_is_UI_request = true;
1090
-        // now we set the current route to whatever the headers_sent_route is set at
1091
-        $this->request->setRequestParam('action', $new_route);
1092
-        // rerun page setup
1093
-        $this->_page_setup();
1094
-    }
1095
-
1096
-
1097
-    /**
1098
-     * _add_query_arg
1099
-     * adds nonce to array of arguments then calls WP add_query_arg function
1100
-     *(internally just uses EEH_URL's function with the same name)
1101
-     *
1102
-     * @param array  $args
1103
-     * @param string $url
1104
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1105
-     *                                        generated url in an associative array indexed by the key 'wp_referer';
1106
-     *                                        Example usage: If the current page is:
1107
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1108
-     *                                        &action=default&event_id=20&month_range=March%202015
1109
-     *                                        &_wpnonce=5467821
1110
-     *                                        and you call:
1111
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
1112
-     *                                        array(
1113
-     *                                        'action' => 'resend_something',
1114
-     *                                        'page=>espresso_registrations'
1115
-     *                                        ),
1116
-     *                                        $some_url,
1117
-     *                                        true
1118
-     *                                        );
1119
-     *                                        It will produce a url in this structure:
1120
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1121
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1122
-     *                                        month_range]=March%202015
1123
-     * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1124
-     * @return string
1125
-     */
1126
-    public static function add_query_args_and_nonce(
1127
-        $args = [],
1128
-        $url = false,
1129
-        $sticky = false,
1130
-        $exclude_nonce = false
1131
-    ) {
1132
-        // if there is a _wp_http_referer include the values from the request but only if sticky = true
1133
-        if ($sticky) {
1134
-            /** @var RequestInterface $request */
1135
-            $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1136
-            $request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1137
-            foreach ($request->requestParams() as $key => $value) {
1138
-                // do not add nonces
1139
-                if (strpos($key, 'nonce') !== false) {
1140
-                    continue;
1141
-                }
1142
-                $args[ 'wp_referer[' . $key . ']' ] = $value;
1143
-            }
1144
-        }
1145
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1146
-    }
1147
-
1148
-
1149
-    /**
1150
-     * This returns a generated link that will load the related help tab.
1151
-     *
1152
-     * @param string $help_tab_id the id for the connected help tab
1153
-     * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1154
-     * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1155
-     * @return string              generated link
1156
-     * @uses EEH_Template::get_help_tab_link()
1157
-     */
1158
-    protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1159
-    {
1160
-        return EEH_Template::get_help_tab_link(
1161
-            $help_tab_id,
1162
-            $this->page_slug,
1163
-            $this->_req_action,
1164
-            $icon_style,
1165
-            $help_text
1166
-        );
1167
-    }
1168
-
1169
-
1170
-    /**
1171
-     * _add_help_tabs
1172
-     * Note child classes define their help tabs within the page_config array.
1173
-     *
1174
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1175
-     * @return void
1176
-     * @throws DomainException
1177
-     * @throws EE_Error
1178
-     */
1179
-    protected function _add_help_tabs()
1180
-    {
1181
-        $tour_buttons = '';
1182
-        if (isset($this->_page_config[ $this->_req_action ])) {
1183
-            $config = $this->_page_config[ $this->_req_action ];
1184
-            // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1185
-            // is there a help tour for the current route?  if there is let's setup the tour buttons
1186
-            // if (isset($this->_help_tour[ $this->_req_action ])) {
1187
-            //     $tb = array();
1188
-            //     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1189
-            //     foreach ($this->_help_tour['tours'] as $tour) {
1190
-            //         // if this is the end tour then we don't need to setup a button
1191
-            //         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1192
-            //             continue;
1193
-            //         }
1194
-            //         $tb[] = '<button id="trigger-tour-'
1195
-            //                 . $tour->get_slug()
1196
-            //                 . '" class="button-primary trigger-ee-help-tour">'
1197
-            //                 . $tour->get_label()
1198
-            //                 . '</button>';
1199
-            //     }
1200
-            //     $tour_buttons .= implode('<br />', $tb);
1201
-            //     $tour_buttons .= '</div></div>';
1202
-            // }
1203
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1204
-            if (is_array($config) && isset($config['help_sidebar'])) {
1205
-                // check that the callback given is valid
1206
-                if (! method_exists($this, $config['help_sidebar'])) {
1207
-                    throw new EE_Error(
1208
-                        sprintf(
1209
-                            esc_html__(
1210
-                                'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1211
-                                'event_espresso'
1212
-                            ),
1213
-                            $config['help_sidebar'],
1214
-                            get_class($this)
1215
-                        )
1216
-                    );
1217
-                }
1218
-                $content = apply_filters(
1219
-                    'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1220
-                    $this->{$config['help_sidebar']}()
1221
-                );
1222
-                $content .= $tour_buttons; // add help tour buttons.
1223
-                // do we have any help tours setup?  Cause if we do we want to add the buttons
1224
-                $this->_current_screen->set_help_sidebar($content);
1225
-            }
1226
-            // if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1227
-            if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1228
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1229
-            }
1230
-            // handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1231
-            if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1232
-                $_ht['id']      = $this->page_slug;
1233
-                $_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1234
-                $_ht['content'] = '<p>'
1235
-                                  . esc_html__(
1236
-                                      'The buttons to the right allow you to start/restart any help tours available for this page',
1237
-                                      'event_espresso'
1238
-                                  ) . '</p>';
1239
-                $this->_current_screen->add_help_tab($_ht);
1240
-            }
1241
-            if (! isset($config['help_tabs'])) {
1242
-                return;
1243
-            } //no help tabs for this route
1244
-            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1245
-                // we're here so there ARE help tabs!
1246
-                // make sure we've got what we need
1247
-                if (! isset($cfg['title'])) {
1248
-                    throw new EE_Error(
1249
-                        esc_html__(
1250
-                            'The _page_config array is not set up properly for help tabs.  It is missing a title',
1251
-                            'event_espresso'
1252
-                        )
1253
-                    );
1254
-                }
1255
-                if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1256
-                    throw new EE_Error(
1257
-                        esc_html__(
1258
-                            'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1259
-                            'event_espresso'
1260
-                        )
1261
-                    );
1262
-                }
1263
-                // first priority goes to content.
1264
-                if (! empty($cfg['content'])) {
1265
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1266
-                    // second priority goes to filename
1267
-                } elseif (! empty($cfg['filename'])) {
1268
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1269
-                    // it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1270
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1271
-                                                             . basename($this->_get_dir())
1272
-                                                             . '/help_tabs/'
1273
-                                                             . $cfg['filename']
1274
-                                                             . '.help_tab.php' : $file_path;
1275
-                    // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1276
-                    if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1277
-                        EE_Error::add_error(
1278
-                            sprintf(
1279
-                                esc_html__(
1280
-                                    'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1281
-                                    'event_espresso'
1282
-                                ),
1283
-                                $tab_id,
1284
-                                key($config),
1285
-                                $file_path
1286
-                            ),
1287
-                            __FILE__,
1288
-                            __FUNCTION__,
1289
-                            __LINE__
1290
-                        );
1291
-                        return;
1292
-                    }
1293
-                    $template_args['admin_page_obj'] = $this;
1294
-                    $content                         = EEH_Template::display_template(
1295
-                        $file_path,
1296
-                        $template_args,
1297
-                        true
1298
-                    );
1299
-                } else {
1300
-                    $content = '';
1301
-                }
1302
-                // check if callback is valid
1303
-                if (
1304
-                    empty($content)
1305
-                    && (
1306
-                        ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1307
-                    )
1308
-                ) {
1309
-                    EE_Error::add_error(
1310
-                        sprintf(
1311
-                            esc_html__(
1312
-                                'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1313
-                                'event_espresso'
1314
-                            ),
1315
-                            $cfg['title']
1316
-                        ),
1317
-                        __FILE__,
1318
-                        __FUNCTION__,
1319
-                        __LINE__
1320
-                    );
1321
-                    return;
1322
-                }
1323
-                // setup config array for help tab method
1324
-                $id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1325
-                $_ht = [
1326
-                    'id'       => $id,
1327
-                    'title'    => $cfg['title'],
1328
-                    'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1329
-                    'content'  => $content,
1330
-                ];
1331
-                $this->_current_screen->add_help_tab($_ht);
1332
-            }
1333
-        }
1334
-    }
1335
-
1336
-
1337
-    /**
1338
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1339
-     * an array with properties for setting up usage of the joyride plugin
1340
-     *
1341
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1342
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1343
-     *         _set_page_config() comments
1344
-     * @return void
1345
-     * @throws InvalidArgumentException
1346
-     * @throws InvalidDataTypeException
1347
-     * @throws InvalidInterfaceException
1348
-     */
1349
-    protected function _add_help_tour()
1350
-    {
1351
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1352
-        // $tours = array();
1353
-        // $this->_help_tour = array();
1354
-        // // exit early if help tours are turned off globally
1355
-        // if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1356
-        //     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1357
-        // ) {
1358
-        //     return;
1359
-        // }
1360
-        // // loop through _page_config to find any help_tour defined
1361
-        // foreach ($this->_page_config as $route => $config) {
1362
-        //     // we're only going to set things up for this route
1363
-        //     if ($route !== $this->_req_action) {
1364
-        //         continue;
1365
-        //     }
1366
-        //     if (isset($config['help_tour'])) {
1367
-        //         foreach ($config['help_tour'] as $tour) {
1368
-        //             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1369
-        //             // let's see if we can get that file...
1370
-        //             // if not its possible this is a decaf route not set in caffeinated
1371
-        //             // so lets try and get the caffeinated equivalent
1372
-        //             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1373
-        //                                                      . basename($this->_get_dir())
1374
-        //                                                      . '/help_tours/'
1375
-        //                                                      . $tour
1376
-        //                                                      . '.class.php' : $file_path;
1377
-        //             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1378
-        //             if (! is_readable($file_path)) {
1379
-        //                 EE_Error::add_error(
1380
-        //                     sprintf(
1381
-        //                         esc_html__(
1382
-        //                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1383
-        //                             'event_espresso'
1384
-        //                         ),
1385
-        //                         $file_path,
1386
-        //                         $tour
1387
-        //                     ),
1388
-        //                     __FILE__,
1389
-        //                     __FUNCTION__,
1390
-        //                     __LINE__
1391
-        //                 );
1392
-        //                 return;
1393
-        //             }
1394
-        //             require_once $file_path;
1395
-        //             if (! class_exists($tour)) {
1396
-        //                 $error_msg[] = sprintf(
1397
-        //                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1398
-        //                     $tour
1399
-        //                 );
1400
-        //                 $error_msg[] = $error_msg[0] . "\r\n"
1401
-        //                                . sprintf(
1402
-        //                                    esc_html__(
1403
-        //                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1404
-        //                                        'event_espresso'
1405
-        //                                    ),
1406
-        //                                    $tour,
1407
-        //                                    '<br />',
1408
-        //                                    $tour,
1409
-        //                                    $this->_req_action,
1410
-        //                                    get_class($this)
1411
-        //                                );
1412
-        //                 throw new EE_Error(implode('||', $error_msg));
1413
-        //             }
1414
-        //             $tour_obj = new $tour($this->_is_caf);
1415
-        //             $tours[] = $tour_obj;
1416
-        //             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1417
-        //         }
1418
-        //         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1419
-        //         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1420
-        //         $tours[] = $end_stop_tour;
1421
-        //         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1422
-        //     }
1423
-        // }
1424
-        //
1425
-        // if (! empty($tours)) {
1426
-        //     $this->_help_tour['tours'] = $tours;
1427
-        // }
1428
-        // // that's it!  Now that the $_help_tours property is set (or not)
1429
-        // // the scripts and html should be taken care of automatically.
1430
-        //
1431
-        // /**
1432
-        //  * Allow extending the help tours variable.
1433
-        //  *
1434
-        //  * @param Array $_help_tour The array containing all help tour information to be displayed.
1435
-        //  */
1436
-        // $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1437
-    }
1438
-
1439
-
1440
-    /**
1441
-     * This simply sets up any qtips that have been defined in the page config
1442
-     *
1443
-     * @return void
1444
-     */
1445
-    protected function _add_qtips()
1446
-    {
1447
-        if (isset($this->_route_config['qtips'])) {
1448
-            $qtips = (array) $this->_route_config['qtips'];
1449
-            // load qtip loader
1450
-            $path = [
1451
-                $this->_get_dir() . '/qtips/',
1452
-                EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1453
-            ];
1454
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1455
-        }
1456
-    }
1457
-
1458
-
1459
-    /**
1460
-     * _set_nav_tabs
1461
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1462
-     * wish to add additional tabs or modify accordingly.
1463
-     *
1464
-     * @return void
1465
-     * @throws InvalidArgumentException
1466
-     * @throws InvalidInterfaceException
1467
-     * @throws InvalidDataTypeException
1468
-     */
1469
-    protected function _set_nav_tabs()
1470
-    {
1471
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1472
-        $i = 0;
1473
-        foreach ($this->_page_config as $slug => $config) {
1474
-            if (! is_array($config) || empty($config['nav'])) {
1475
-                continue;
1476
-            }
1477
-            // no nav tab for this config
1478
-            // check for persistent flag
1479
-            if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1480
-                // nav tab is only to appear when route requested.
1481
-                continue;
1482
-            }
1483
-            if (! $this->check_user_access($slug, true)) {
1484
-                // no nav tab because current user does not have access.
1485
-                continue;
1486
-            }
1487
-            $css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1488
-            $this->_nav_tabs[ $slug ] = [
1489
-                'url'       => isset($config['nav']['url'])
1490
-                    ? $config['nav']['url']
1491
-                    : self::add_query_args_and_nonce(
1492
-                        ['action' => $slug],
1493
-                        $this->_admin_base_url
1494
-                    ),
1495
-                'link_text' => isset($config['nav']['label'])
1496
-                    ? $config['nav']['label']
1497
-                    : ucwords(
1498
-                        str_replace('_', ' ', $slug)
1499
-                    ),
1500
-                'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1501
-                'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1502
-            ];
1503
-            $i++;
1504
-        }
1505
-        // if $this->_nav_tabs is empty then lets set the default
1506
-        if (empty($this->_nav_tabs)) {
1507
-            $this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1508
-                'url'       => $this->_admin_base_url,
1509
-                'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1510
-                'css_class' => 'nav-tab-active',
1511
-                'order'     => 10,
1512
-            ];
1513
-        }
1514
-        // now let's sort the tabs according to order
1515
-        usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1516
-    }
1517
-
1518
-
1519
-    /**
1520
-     * _set_current_labels
1521
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1522
-     * property array
1523
-     *
1524
-     * @return void
1525
-     */
1526
-    private function _set_current_labels()
1527
-    {
1528
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1529
-            foreach ($this->_route_config['labels'] as $label => $text) {
1530
-                if (is_array($text)) {
1531
-                    foreach ($text as $sublabel => $subtext) {
1532
-                        $this->_labels[ $label ][ $sublabel ] = $subtext;
1533
-                    }
1534
-                } else {
1535
-                    $this->_labels[ $label ] = $text;
1536
-                }
1537
-            }
1538
-        }
1539
-    }
1540
-
1541
-
1542
-    /**
1543
-     *        verifies user access for this admin page
1544
-     *
1545
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1546
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1547
-     *                               return false if verify fail.
1548
-     * @return bool
1549
-     * @throws InvalidArgumentException
1550
-     * @throws InvalidDataTypeException
1551
-     * @throws InvalidInterfaceException
1552
-     */
1553
-    public function check_user_access($route_to_check = '', $verify_only = false)
1554
-    {
1555
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1556
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1557
-        $capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1558
-                          && is_array(
1559
-                              $this->_page_routes[ $route_to_check ]
1560
-                          )
1561
-                          && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1562
-            ? $this->_page_routes[ $route_to_check ]['capability'] : null;
1563
-        if (empty($capability) && empty($route_to_check)) {
1564
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1565
-                : $this->_route['capability'];
1566
-        } else {
1567
-            $capability = empty($capability) ? 'manage_options' : $capability;
1568
-        }
1569
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1570
-        if (
1571
-            ! defined('DOING_AJAX')
1572
-            && (
1573
-                ! function_exists('is_admin')
1574
-                || ! EE_Registry::instance()->CAP->current_user_can(
1575
-                    $capability,
1576
-                    $this->page_slug
1577
-                    . '_'
1578
-                    . $route_to_check,
1579
-                    $id
1580
-                )
1581
-            )
1582
-        ) {
1583
-            if ($verify_only) {
1584
-                return false;
1585
-            }
1586
-            if (is_user_logged_in()) {
1587
-                wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1588
-            } else {
1589
-                return false;
1590
-            }
1591
-        }
1592
-        return true;
1593
-    }
1594
-
1595
-
1596
-    /**
1597
-     * admin_init_global
1598
-     * This runs all the code that we want executed within the WP admin_init hook.
1599
-     * This method executes for ALL EE Admin pages.
1600
-     *
1601
-     * @return void
1602
-     */
1603
-    public function admin_init_global()
1604
-    {
1605
-    }
1606
-
1607
-
1608
-    /**
1609
-     * wp_loaded_global
1610
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1611
-     * EE_Admin page and will execute on every EE Admin Page load
1612
-     *
1613
-     * @return void
1614
-     */
1615
-    public function wp_loaded()
1616
-    {
1617
-    }
1618
-
1619
-
1620
-    /**
1621
-     * admin_notices
1622
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1623
-     * ALL EE_Admin pages.
1624
-     *
1625
-     * @return void
1626
-     */
1627
-    public function admin_notices_global()
1628
-    {
1629
-        $this->_display_no_javascript_warning();
1630
-        $this->_display_espresso_notices();
1631
-    }
1632
-
1633
-
1634
-    public function network_admin_notices_global()
1635
-    {
1636
-        $this->_display_no_javascript_warning();
1637
-        $this->_display_espresso_notices();
1638
-    }
1639
-
1640
-
1641
-    /**
1642
-     * admin_footer_scripts_global
1643
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1644
-     * will apply on ALL EE_Admin pages.
1645
-     *
1646
-     * @return void
1647
-     */
1648
-    public function admin_footer_scripts_global()
1649
-    {
1650
-        $this->_add_admin_page_ajax_loading_img();
1651
-        $this->_add_admin_page_overlay();
1652
-        // if metaboxes are present we need to add the nonce field
1653
-        if (
1654
-            isset($this->_route_config['metaboxes'])
1655
-            || isset($this->_route_config['list_table'])
1656
-            || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1657
-        ) {
1658
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1659
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1660
-        }
1661
-    }
1662
-
1663
-
1664
-    /**
1665
-     * admin_footer_global
1666
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1667
-     * ALL EE_Admin Pages.
1668
-     *
1669
-     * @return void
1670
-     */
1671
-    public function admin_footer_global()
1672
-    {
1673
-        // dialog container for dialog helper
1674
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1675
-        $d_cont .= '<div class="ee-notices"></div>';
1676
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1677
-        $d_cont .= '</div>';
1678
-        echo $d_cont;
1679
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1680
-        // help tour stuff?
1681
-        // if (isset($this->_help_tour[ $this->_req_action ])) {
1682
-        //     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1683
-        // }
1684
-        // current set timezone for timezone js
1685
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1686
-    }
1687
-
1688
-
1689
-    /**
1690
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then
1691
-     * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1692
-     * help popups then in your templates or your content you set "triggers" for the content using the
1693
-     * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1694
-     * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1695
-     * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1696
-     * for the
1697
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1698
-     * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1699
-     *    'help_trigger_id' => array(
1700
-     *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1701
-     *        'content' => esc_html__('localized content for popup', 'event_espresso')
1702
-     *    )
1703
-     * );
1704
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1705
-     *
1706
-     * @param array $help_array
1707
-     * @param bool  $display
1708
-     * @return string content
1709
-     * @throws DomainException
1710
-     * @throws EE_Error
1711
-     */
1712
-    protected function _set_help_popup_content($help_array = [], $display = false)
1713
-    {
1714
-        $content    = '';
1715
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1716
-        // loop through the array and setup content
1717
-        foreach ($help_array as $trigger => $help) {
1718
-            // make sure the array is setup properly
1719
-            if (! isset($help['title']) || ! isset($help['content'])) {
1720
-                throw new EE_Error(
1721
-                    esc_html__(
1722
-                        'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1723
-                        'event_espresso'
1724
-                    )
1725
-                );
1726
-            }
1727
-            // we're good so let'd setup the template vars and then assign parsed template content to our content.
1728
-            $template_args = [
1729
-                'help_popup_id'      => $trigger,
1730
-                'help_popup_title'   => $help['title'],
1731
-                'help_popup_content' => $help['content'],
1732
-            ];
1733
-            $content       .= EEH_Template::display_template(
1734
-                EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1735
-                $template_args,
1736
-                true
1737
-            );
1738
-        }
1739
-        if ($display) {
1740
-            echo $content;
1741
-            return '';
1742
-        }
1743
-        return $content;
1744
-    }
1745
-
1746
-
1747
-    /**
1748
-     * All this does is retrieve the help content array if set by the EE_Admin_Page child
1749
-     *
1750
-     * @return array properly formatted array for help popup content
1751
-     * @throws EE_Error
1752
-     */
1753
-    private function _get_help_content()
1754
-    {
1755
-        // what is the method we're looking for?
1756
-        $method_name = '_help_popup_content_' . $this->_req_action;
1757
-        // if method doesn't exist let's get out.
1758
-        if (! method_exists($this, $method_name)) {
1759
-            return [];
1760
-        }
1761
-        // k we're good to go let's retrieve the help array
1762
-        $help_array = call_user_func([$this, $method_name]);
1763
-        // make sure we've got an array!
1764
-        if (! is_array($help_array)) {
1765
-            throw new EE_Error(
1766
-                esc_html__(
1767
-                    'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1768
-                    'event_espresso'
1769
-                )
1770
-            );
1771
-        }
1772
-        return $help_array;
1773
-    }
1774
-
1775
-
1776
-    /**
1777
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1778
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1779
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1780
-     *
1781
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1782
-     * @param boolean $display    if false then we return the trigger string
1783
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1784
-     * @return string
1785
-     * @throws DomainException
1786
-     * @throws EE_Error
1787
-     */
1788
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1789
-    {
1790
-        if (defined('DOING_AJAX')) {
1791
-            return '';
1792
-        }
1793
-        // let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1794
-        $help_array   = $this->_get_help_content();
1795
-        $help_content = '';
1796
-        if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1797
-            $help_array[ $trigger_id ] = [
1798
-                'title'   => esc_html__('Missing Content', 'event_espresso'),
1799
-                'content' => esc_html__(
1800
-                    'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1801
-                    'event_espresso'
1802
-                ),
1803
-            ];
1804
-            $help_content              = $this->_set_help_popup_content($help_array, false);
1805
-        }
1806
-        // let's setup the trigger
1807
-        $content = '<a class="ee-dialog" href="?height='
1808
-                   . $dimensions[0]
1809
-                   . '&width='
1810
-                   . $dimensions[1]
1811
-                   . '&inlineId='
1812
-                   . $trigger_id
1813
-                   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1814
-        $content .= $help_content;
1815
-        if ($display) {
1816
-            echo $content;
1817
-            return '';
1818
-        }
1819
-        return $content;
1820
-    }
1821
-
1822
-
1823
-    /**
1824
-     * _add_global_screen_options
1825
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1826
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1827
-     *
1828
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1829
-     *         see also WP_Screen object documents...
1830
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1831
-     * @abstract
1832
-     * @return void
1833
-     */
1834
-    private function _add_global_screen_options()
1835
-    {
1836
-    }
1837
-
1838
-
1839
-    /**
1840
-     * _add_global_feature_pointers
1841
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1842
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1843
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1844
-     *
1845
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1846
-     *         extended) also see:
1847
-     * @link   http://eamann.com/tech/wordpress-portland/
1848
-     * @abstract
1849
-     * @return void
1850
-     */
1851
-    private function _add_global_feature_pointers()
1852
-    {
1853
-    }
1854
-
1855
-
1856
-    /**
1857
-     * load_global_scripts_styles
1858
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1859
-     *
1860
-     * @return void
1861
-     */
1862
-    public function load_global_scripts_styles()
1863
-    {
1864
-        /** STYLES **/
1865
-        // add debugging styles
1866
-        if (WP_DEBUG) {
1867
-            add_action('admin_head', [$this, 'add_xdebug_style']);
1868
-        }
1869
-        // register all styles
1870
-        wp_register_style(
1871
-            'espresso-ui-theme',
1872
-            EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1873
-            [],
1874
-            EVENT_ESPRESSO_VERSION
1875
-        );
1876
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1877
-        // helpers styles
1878
-        wp_register_style(
1879
-            'ee-text-links',
1880
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1881
-            [],
1882
-            EVENT_ESPRESSO_VERSION
1883
-        );
1884
-        /** SCRIPTS **/
1885
-        // register all scripts
1886
-        wp_register_script(
1887
-            'ee-dialog',
1888
-            EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1889
-            ['jquery', 'jquery-ui-draggable'],
1890
-            EVENT_ESPRESSO_VERSION,
1891
-            true
1892
-        );
1893
-        wp_register_script(
1894
-            'ee_admin_js',
1895
-            EE_ADMIN_URL . 'assets/ee-admin-page.js',
1896
-            ['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1897
-            EVENT_ESPRESSO_VERSION,
1898
-            true
1899
-        );
1900
-        wp_register_script(
1901
-            'jquery-ui-timepicker-addon',
1902
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1903
-            ['jquery-ui-datepicker', 'jquery-ui-slider'],
1904
-            EVENT_ESPRESSO_VERSION,
1905
-            true
1906
-        );
1907
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1908
-        // if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1909
-        //     add_filter('FHEE_load_joyride', '__return_true');
1910
-        // }
1911
-        // script for sorting tables
1912
-        wp_register_script(
1913
-            'espresso_ajax_table_sorting',
1914
-            EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1915
-            ['ee_admin_js', 'jquery-ui-sortable'],
1916
-            EVENT_ESPRESSO_VERSION,
1917
-            true
1918
-        );
1919
-        // script for parsing uri's
1920
-        wp_register_script(
1921
-            'ee-parse-uri',
1922
-            EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1923
-            [],
1924
-            EVENT_ESPRESSO_VERSION,
1925
-            true
1926
-        );
1927
-        // and parsing associative serialized form elements
1928
-        wp_register_script(
1929
-            'ee-serialize-full-array',
1930
-            EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1931
-            ['jquery'],
1932
-            EVENT_ESPRESSO_VERSION,
1933
-            true
1934
-        );
1935
-        // helpers scripts
1936
-        wp_register_script(
1937
-            'ee-text-links',
1938
-            EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1939
-            ['jquery'],
1940
-            EVENT_ESPRESSO_VERSION,
1941
-            true
1942
-        );
1943
-        wp_register_script(
1944
-            'ee-moment-core',
1945
-            EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1946
-            [],
1947
-            EVENT_ESPRESSO_VERSION,
1948
-            true
1949
-        );
1950
-        wp_register_script(
1951
-            'ee-moment',
1952
-            EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1953
-            ['ee-moment-core'],
1954
-            EVENT_ESPRESSO_VERSION,
1955
-            true
1956
-        );
1957
-        wp_register_script(
1958
-            'ee-datepicker',
1959
-            EE_ADMIN_URL . 'assets/ee-datepicker.js',
1960
-            ['jquery-ui-timepicker-addon', 'ee-moment'],
1961
-            EVENT_ESPRESSO_VERSION,
1962
-            true
1963
-        );
1964
-        // google charts
1965
-        wp_register_script(
1966
-            'google-charts',
1967
-            'https://www.gstatic.com/charts/loader.js',
1968
-            [],
1969
-            EVENT_ESPRESSO_VERSION,
1970
-            false
1971
-        );
1972
-        // ENQUEUE ALL BASICS BY DEFAULT
1973
-        wp_enqueue_style('ee-admin-css');
1974
-        wp_enqueue_script('ee_admin_js');
1975
-        wp_enqueue_script('ee-accounting');
1976
-        wp_enqueue_script('jquery-validate');
1977
-        // taking care of metaboxes
1978
-        if (
1979
-            empty($this->_cpt_route)
1980
-            && (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1981
-        ) {
1982
-            wp_enqueue_script('dashboard');
1983
-        }
1984
-        // LOCALIZED DATA
1985
-        // localize script for ajax lazy loading
1986
-        $lazy_loader_container_ids = apply_filters(
1987
-            'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1988
-            ['espresso_news_post_box_content']
1989
-        );
1990
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1991
-        // disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1992
-        // /**
1993
-        //  * help tour stuff
1994
-        //  */
1995
-        // if (! empty($this->_help_tour)) {
1996
-        //     // register the js for kicking things off
1997
-        //     wp_enqueue_script(
1998
-        //         'ee-help-tour',
1999
-        //         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2000
-        //         array('jquery-joyride'),
2001
-        //         EVENT_ESPRESSO_VERSION,
2002
-        //         true
2003
-        //     );
2004
-        //     $tours = array();
2005
-        //     // setup tours for the js tour object
2006
-        //     foreach ($this->_help_tour['tours'] as $tour) {
2007
-        //         if ($tour instanceof EE_Help_Tour) {
2008
-        //             $tours[] = array(
2009
-        //                 'id'      => $tour->get_slug(),
2010
-        //                 'options' => $tour->get_options(),
2011
-        //             );
2012
-        //         }
2013
-        //     }
2014
-        //     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2015
-        //     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2016
-        // }
2017
-    }
2018
-
2019
-
2020
-    /**
2021
-     *        admin_footer_scripts_eei18n_js_strings
2022
-     *
2023
-     * @return        void
2024
-     */
2025
-    public function admin_footer_scripts_eei18n_js_strings()
2026
-    {
2027
-        EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2028
-        EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2029
-            __(
2030
-                'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2031
-                'event_espresso'
2032
-            )
2033
-        );
2034
-        EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2035
-        EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2036
-        EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2037
-        EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2038
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2039
-        EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2040
-        EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2041
-        EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2042
-        EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2043
-        EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2044
-        EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2045
-        EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2046
-        EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2047
-        EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2048
-        EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2049
-        EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2050
-        EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2051
-        EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2052
-        EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2053
-        EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2054
-        EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2055
-        EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2056
-        EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2057
-        EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2058
-        EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2059
-        EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2060
-        EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2061
-        EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2062
-        EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2063
-        EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2064
-        EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2065
-        EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2066
-        EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2067
-        EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2068
-        EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2069
-        EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2070
-        EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2071
-        EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2072
-    }
2073
-
2074
-
2075
-    /**
2076
-     *        load enhanced xdebug styles for ppl with failing eyesight
2077
-     *
2078
-     * @return        void
2079
-     */
2080
-    public function add_xdebug_style()
2081
-    {
2082
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2083
-    }
2084
-
2085
-
2086
-    /************************/
2087
-    /** LIST TABLE METHODS **/
2088
-    /************************/
2089
-    /**
2090
-     * this sets up the list table if the current view requires it.
2091
-     *
2092
-     * @return void
2093
-     * @throws EE_Error
2094
-     */
2095
-    protected function _set_list_table()
2096
-    {
2097
-        // first is this a list_table view?
2098
-        if (! isset($this->_route_config['list_table'])) {
2099
-            return;
2100
-        } //not a list_table view so get out.
2101
-        // list table functions are per view specific (because some admin pages might have more than one list table!)
2102
-        $list_table_view = '_set_list_table_views_' . $this->_req_action;
2103
-        if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2104
-            // user error msg
2105
-            $error_msg = esc_html__(
2106
-                'An error occurred. The requested list table views could not be found.',
2107
-                'event_espresso'
2108
-            );
2109
-            // developer error msg
2110
-            $error_msg .= '||'
2111
-                          . sprintf(
2112
-                              esc_html__(
2113
-                                  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2114
-                                  'event_espresso'
2115
-                              ),
2116
-                              $this->_req_action,
2117
-                              $list_table_view
2118
-                          );
2119
-            throw new EE_Error($error_msg);
2120
-        }
2121
-        // let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2122
-        $this->_views = apply_filters(
2123
-            'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2124
-            $this->_views
2125
-        );
2126
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2127
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2128
-        $this->_set_list_table_view();
2129
-        $this->_set_list_table_object();
2130
-    }
2131
-
2132
-
2133
-    /**
2134
-     * set current view for List Table
2135
-     *
2136
-     * @return void
2137
-     */
2138
-    protected function _set_list_table_view()
2139
-    {
2140
-        $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2141
-        $status = $this->request->getRequestParam('status', null, 'key');
2142
-        $this->_view = $status && array_key_exists($status, $this->_views)
2143
-            ? $status
2144
-            : $this->_view;
2145
-    }
2146
-
2147
-
2148
-    /**
2149
-     * _set_list_table_object
2150
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2151
-     *
2152
-     * @throws InvalidInterfaceException
2153
-     * @throws InvalidArgumentException
2154
-     * @throws InvalidDataTypeException
2155
-     * @throws EE_Error
2156
-     * @throws InvalidInterfaceException
2157
-     */
2158
-    protected function _set_list_table_object()
2159
-    {
2160
-        if (isset($this->_route_config['list_table'])) {
2161
-            if (! class_exists($this->_route_config['list_table'])) {
2162
-                throw new EE_Error(
2163
-                    sprintf(
2164
-                        esc_html__(
2165
-                            'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2166
-                            'event_espresso'
2167
-                        ),
2168
-                        $this->_route_config['list_table'],
2169
-                        get_class($this)
2170
-                    )
2171
-                );
2172
-            }
2173
-            $this->_list_table_object = $this->loader->getShared(
2174
-                $this->_route_config['list_table'],
2175
-                [$this]
2176
-            );
2177
-        }
2178
-    }
2179
-
2180
-
2181
-    /**
2182
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2183
-     *
2184
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2185
-     *                                                    urls.  The array should be indexed by the view it is being
2186
-     *                                                    added to.
2187
-     * @return array
2188
-     */
2189
-    public function get_list_table_view_RLs($extra_query_args = [])
2190
-    {
2191
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2192
-        if (empty($this->_views)) {
2193
-            $this->_views = [];
2194
-        }
2195
-        // cycle thru views
2196
-        foreach ($this->_views as $key => $view) {
2197
-            $query_args = [];
2198
-            // check for current view
2199
-            $this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2200
-            $query_args['action']                        = $this->_req_action;
2201
-            $query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2202
-            $query_args['status']                        = $view['slug'];
2203
-            // merge any other arguments sent in.
2204
-            if (isset($extra_query_args[ $view['slug'] ])) {
2205
-                $query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2206
-            }
2207
-            $this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2208
-        }
2209
-        return $this->_views;
2210
-    }
2211
-
2212
-
2213
-    /**
2214
-     * _entries_per_page_dropdown
2215
-     * generates a drop down box for selecting the number of visible rows in an admin page list table
2216
-     *
2217
-     * @param int $max_entries total number of rows in the table
2218
-     * @return string
2219
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2220
-     *         WP does it.
2221
-     */
2222
-    protected function _entries_per_page_dropdown($max_entries = 0)
2223
-    {
2224
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2225
-        $values   = [10, 25, 50, 100];
2226
-        $per_page = $this->request->getRequestParam('per_page', 10, 'int');
2227
-        if ($max_entries) {
2228
-            $values[] = $max_entries;
2229
-            sort($values);
2230
-        }
2231
-        $entries_per_page_dropdown = '
1022
+				(
1023
+					(
1024
+						method_exists($class, $method)
1025
+						&& call_user_func_array([$class, $method], $args) === false
1026
+					)
1027
+					&& (
1028
+						// is it a standalone function that doesn't work?
1029
+						function_exists($method)
1030
+						&& call_user_func_array(
1031
+							$func,
1032
+							array_merge(['admin_page_object' => $this], $args)
1033
+						) === false
1034
+					)
1035
+				)
1036
+				|| (
1037
+					// is it neither a class method NOR a standalone function?
1038
+					! method_exists($class, $method)
1039
+					&& ! function_exists($method)
1040
+				)
1041
+			) {
1042
+				// user error msg
1043
+				$error_msg = esc_html__(
1044
+					'An error occurred. The  requested page route could not be found.',
1045
+					'event_espresso'
1046
+				);
1047
+				// developer error msg
1048
+				$error_msg .= '||';
1049
+				$error_msg .= sprintf(
1050
+					esc_html__(
1051
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
1052
+						'event_espresso'
1053
+					),
1054
+					$method
1055
+				);
1056
+			}
1057
+			if (! empty($error_msg)) {
1058
+				throw new EE_Error($error_msg);
1059
+			}
1060
+		}
1061
+		// if we've routed and this route has a no headers route AND a sent_headers_route,
1062
+		// then we need to reset the routing properties to the new route.
1063
+		// now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
1064
+		if (
1065
+			$this->_is_UI_request === false
1066
+			&& is_array($this->_route)
1067
+			&& ! empty($this->_route['headers_sent_route'])
1068
+		) {
1069
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
1070
+		}
1071
+	}
1072
+
1073
+
1074
+	/**
1075
+	 * This method just allows the resetting of page properties in the case where a no headers
1076
+	 * route redirects to a headers route in its route config.
1077
+	 *
1078
+	 * @param string $new_route New (non header) route to redirect to.
1079
+	 * @return   void
1080
+	 * @throws ReflectionException
1081
+	 * @throws InvalidArgumentException
1082
+	 * @throws InvalidInterfaceException
1083
+	 * @throws InvalidDataTypeException
1084
+	 * @throws EE_Error
1085
+	 * @since   4.3.0
1086
+	 */
1087
+	protected function _reset_routing_properties($new_route)
1088
+	{
1089
+		$this->_is_UI_request = true;
1090
+		// now we set the current route to whatever the headers_sent_route is set at
1091
+		$this->request->setRequestParam('action', $new_route);
1092
+		// rerun page setup
1093
+		$this->_page_setup();
1094
+	}
1095
+
1096
+
1097
+	/**
1098
+	 * _add_query_arg
1099
+	 * adds nonce to array of arguments then calls WP add_query_arg function
1100
+	 *(internally just uses EEH_URL's function with the same name)
1101
+	 *
1102
+	 * @param array  $args
1103
+	 * @param string $url
1104
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the
1105
+	 *                                        generated url in an associative array indexed by the key 'wp_referer';
1106
+	 *                                        Example usage: If the current page is:
1107
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
1108
+	 *                                        &action=default&event_id=20&month_range=March%202015
1109
+	 *                                        &_wpnonce=5467821
1110
+	 *                                        and you call:
1111
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
1112
+	 *                                        array(
1113
+	 *                                        'action' => 'resend_something',
1114
+	 *                                        'page=>espresso_registrations'
1115
+	 *                                        ),
1116
+	 *                                        $some_url,
1117
+	 *                                        true
1118
+	 *                                        );
1119
+	 *                                        It will produce a url in this structure:
1120
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
1121
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
1122
+	 *                                        month_range]=March%202015
1123
+	 * @param bool   $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
1124
+	 * @return string
1125
+	 */
1126
+	public static function add_query_args_and_nonce(
1127
+		$args = [],
1128
+		$url = false,
1129
+		$sticky = false,
1130
+		$exclude_nonce = false
1131
+	) {
1132
+		// if there is a _wp_http_referer include the values from the request but only if sticky = true
1133
+		if ($sticky) {
1134
+			/** @var RequestInterface $request */
1135
+			$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
1136
+			$request->unSetRequestParams(['_wp_http_referer', 'wp_referer']);
1137
+			foreach ($request->requestParams() as $key => $value) {
1138
+				// do not add nonces
1139
+				if (strpos($key, 'nonce') !== false) {
1140
+					continue;
1141
+				}
1142
+				$args[ 'wp_referer[' . $key . ']' ] = $value;
1143
+			}
1144
+		}
1145
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
1146
+	}
1147
+
1148
+
1149
+	/**
1150
+	 * This returns a generated link that will load the related help tab.
1151
+	 *
1152
+	 * @param string $help_tab_id the id for the connected help tab
1153
+	 * @param string $icon_style  (optional) include css class for the style you want to use for the help icon.
1154
+	 * @param string $help_text   (optional) send help text you want to use for the link if default not to be used
1155
+	 * @return string              generated link
1156
+	 * @uses EEH_Template::get_help_tab_link()
1157
+	 */
1158
+	protected function _get_help_tab_link($help_tab_id, $icon_style = '', $help_text = '')
1159
+	{
1160
+		return EEH_Template::get_help_tab_link(
1161
+			$help_tab_id,
1162
+			$this->page_slug,
1163
+			$this->_req_action,
1164
+			$icon_style,
1165
+			$help_text
1166
+		);
1167
+	}
1168
+
1169
+
1170
+	/**
1171
+	 * _add_help_tabs
1172
+	 * Note child classes define their help tabs within the page_config array.
1173
+	 *
1174
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
1175
+	 * @return void
1176
+	 * @throws DomainException
1177
+	 * @throws EE_Error
1178
+	 */
1179
+	protected function _add_help_tabs()
1180
+	{
1181
+		$tour_buttons = '';
1182
+		if (isset($this->_page_config[ $this->_req_action ])) {
1183
+			$config = $this->_page_config[ $this->_req_action ];
1184
+			// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1185
+			// is there a help tour for the current route?  if there is let's setup the tour buttons
1186
+			// if (isset($this->_help_tour[ $this->_req_action ])) {
1187
+			//     $tb = array();
1188
+			//     $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1189
+			//     foreach ($this->_help_tour['tours'] as $tour) {
1190
+			//         // if this is the end tour then we don't need to setup a button
1191
+			//         if ($tour instanceof EE_Help_Tour_final_stop || ! $tour instanceof EE_Help_Tour) {
1192
+			//             continue;
1193
+			//         }
1194
+			//         $tb[] = '<button id="trigger-tour-'
1195
+			//                 . $tour->get_slug()
1196
+			//                 . '" class="button-primary trigger-ee-help-tour">'
1197
+			//                 . $tour->get_label()
1198
+			//                 . '</button>';
1199
+			//     }
1200
+			//     $tour_buttons .= implode('<br />', $tb);
1201
+			//     $tour_buttons .= '</div></div>';
1202
+			// }
1203
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1204
+			if (is_array($config) && isset($config['help_sidebar'])) {
1205
+				// check that the callback given is valid
1206
+				if (! method_exists($this, $config['help_sidebar'])) {
1207
+					throw new EE_Error(
1208
+						sprintf(
1209
+							esc_html__(
1210
+								'The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1211
+								'event_espresso'
1212
+							),
1213
+							$config['help_sidebar'],
1214
+							get_class($this)
1215
+						)
1216
+					);
1217
+				}
1218
+				$content = apply_filters(
1219
+					'FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar',
1220
+					$this->{$config['help_sidebar']}()
1221
+				);
1222
+				$content .= $tour_buttons; // add help tour buttons.
1223
+				// do we have any help tours setup?  Cause if we do we want to add the buttons
1224
+				$this->_current_screen->set_help_sidebar($content);
1225
+			}
1226
+			// if we DON'T have config help sidebar and there ARE tour buttons then we'll just add the tour buttons to the sidebar.
1227
+			if (! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1228
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1229
+			}
1230
+			// handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1231
+			if (! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1232
+				$_ht['id']      = $this->page_slug;
1233
+				$_ht['title']   = esc_html__('Help Tours', 'event_espresso');
1234
+				$_ht['content'] = '<p>'
1235
+								  . esc_html__(
1236
+									  'The buttons to the right allow you to start/restart any help tours available for this page',
1237
+									  'event_espresso'
1238
+								  ) . '</p>';
1239
+				$this->_current_screen->add_help_tab($_ht);
1240
+			}
1241
+			if (! isset($config['help_tabs'])) {
1242
+				return;
1243
+			} //no help tabs for this route
1244
+			foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1245
+				// we're here so there ARE help tabs!
1246
+				// make sure we've got what we need
1247
+				if (! isset($cfg['title'])) {
1248
+					throw new EE_Error(
1249
+						esc_html__(
1250
+							'The _page_config array is not set up properly for help tabs.  It is missing a title',
1251
+							'event_espresso'
1252
+						)
1253
+					);
1254
+				}
1255
+				if (! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1256
+					throw new EE_Error(
1257
+						esc_html__(
1258
+							'The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1259
+							'event_espresso'
1260
+						)
1261
+					);
1262
+				}
1263
+				// first priority goes to content.
1264
+				if (! empty($cfg['content'])) {
1265
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1266
+					// second priority goes to filename
1267
+				} elseif (! empty($cfg['filename'])) {
1268
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1269
+					// it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1270
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1271
+															 . basename($this->_get_dir())
1272
+															 . '/help_tabs/'
1273
+															 . $cfg['filename']
1274
+															 . '.help_tab.php' : $file_path;
1275
+					// if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1276
+					if (! isset($cfg['callback']) && ! is_readable($file_path)) {
1277
+						EE_Error::add_error(
1278
+							sprintf(
1279
+								esc_html__(
1280
+									'The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1281
+									'event_espresso'
1282
+								),
1283
+								$tab_id,
1284
+								key($config),
1285
+								$file_path
1286
+							),
1287
+							__FILE__,
1288
+							__FUNCTION__,
1289
+							__LINE__
1290
+						);
1291
+						return;
1292
+					}
1293
+					$template_args['admin_page_obj'] = $this;
1294
+					$content                         = EEH_Template::display_template(
1295
+						$file_path,
1296
+						$template_args,
1297
+						true
1298
+					);
1299
+				} else {
1300
+					$content = '';
1301
+				}
1302
+				// check if callback is valid
1303
+				if (
1304
+					empty($content)
1305
+					&& (
1306
+						! isset($cfg['callback']) || ! method_exists($this, $cfg['callback'])
1307
+					)
1308
+				) {
1309
+					EE_Error::add_error(
1310
+						sprintf(
1311
+							esc_html__(
1312
+								'The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1313
+								'event_espresso'
1314
+							),
1315
+							$cfg['title']
1316
+						),
1317
+						__FILE__,
1318
+						__FUNCTION__,
1319
+						__LINE__
1320
+					);
1321
+					return;
1322
+				}
1323
+				// setup config array for help tab method
1324
+				$id  = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1325
+				$_ht = [
1326
+					'id'       => $id,
1327
+					'title'    => $cfg['title'],
1328
+					'callback' => isset($cfg['callback']) && empty($content) ? [$this, $cfg['callback']] : null,
1329
+					'content'  => $content,
1330
+				];
1331
+				$this->_current_screen->add_help_tab($_ht);
1332
+			}
1333
+		}
1334
+	}
1335
+
1336
+
1337
+	/**
1338
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is
1339
+	 * an array with properties for setting up usage of the joyride plugin
1340
+	 *
1341
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1342
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the
1343
+	 *         _set_page_config() comments
1344
+	 * @return void
1345
+	 * @throws InvalidArgumentException
1346
+	 * @throws InvalidDataTypeException
1347
+	 * @throws InvalidInterfaceException
1348
+	 */
1349
+	protected function _add_help_tour()
1350
+	{
1351
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1352
+		// $tours = array();
1353
+		// $this->_help_tour = array();
1354
+		// // exit early if help tours are turned off globally
1355
+		// if ((defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)
1356
+		//     || ! EE_Registry::instance()->CFG->admin->help_tour_activation
1357
+		// ) {
1358
+		//     return;
1359
+		// }
1360
+		// // loop through _page_config to find any help_tour defined
1361
+		// foreach ($this->_page_config as $route => $config) {
1362
+		//     // we're only going to set things up for this route
1363
+		//     if ($route !== $this->_req_action) {
1364
+		//         continue;
1365
+		//     }
1366
+		//     if (isset($config['help_tour'])) {
1367
+		//         foreach ($config['help_tour'] as $tour) {
1368
+		//             $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1369
+		//             // let's see if we can get that file...
1370
+		//             // if not its possible this is a decaf route not set in caffeinated
1371
+		//             // so lets try and get the caffeinated equivalent
1372
+		//             $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES
1373
+		//                                                      . basename($this->_get_dir())
1374
+		//                                                      . '/help_tours/'
1375
+		//                                                      . $tour
1376
+		//                                                      . '.class.php' : $file_path;
1377
+		//             // if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1378
+		//             if (! is_readable($file_path)) {
1379
+		//                 EE_Error::add_error(
1380
+		//                     sprintf(
1381
+		//                         esc_html__(
1382
+		//                             'The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling',
1383
+		//                             'event_espresso'
1384
+		//                         ),
1385
+		//                         $file_path,
1386
+		//                         $tour
1387
+		//                     ),
1388
+		//                     __FILE__,
1389
+		//                     __FUNCTION__,
1390
+		//                     __LINE__
1391
+		//                 );
1392
+		//                 return;
1393
+		//             }
1394
+		//             require_once $file_path;
1395
+		//             if (! class_exists($tour)) {
1396
+		//                 $error_msg[] = sprintf(
1397
+		//                     esc_html__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'),
1398
+		//                     $tour
1399
+		//                 );
1400
+		//                 $error_msg[] = $error_msg[0] . "\r\n"
1401
+		//                                . sprintf(
1402
+		//                                    esc_html__(
1403
+		//                                        'There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1404
+		//                                        'event_espresso'
1405
+		//                                    ),
1406
+		//                                    $tour,
1407
+		//                                    '<br />',
1408
+		//                                    $tour,
1409
+		//                                    $this->_req_action,
1410
+		//                                    get_class($this)
1411
+		//                                );
1412
+		//                 throw new EE_Error(implode('||', $error_msg));
1413
+		//             }
1414
+		//             $tour_obj = new $tour($this->_is_caf);
1415
+		//             $tours[] = $tour_obj;
1416
+		//             $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($tour_obj);
1417
+		//         }
1418
+		//         // let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1419
+		//         $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1420
+		//         $tours[] = $end_stop_tour;
1421
+		//         $this->_help_tour[ $route ][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1422
+		//     }
1423
+		// }
1424
+		//
1425
+		// if (! empty($tours)) {
1426
+		//     $this->_help_tour['tours'] = $tours;
1427
+		// }
1428
+		// // that's it!  Now that the $_help_tours property is set (or not)
1429
+		// // the scripts and html should be taken care of automatically.
1430
+		//
1431
+		// /**
1432
+		//  * Allow extending the help tours variable.
1433
+		//  *
1434
+		//  * @param Array $_help_tour The array containing all help tour information to be displayed.
1435
+		//  */
1436
+		// $this->_help_tour = apply_filters('FHEE__EE_Admin_Page___add_help_tour___help_tour', $this->_help_tour);
1437
+	}
1438
+
1439
+
1440
+	/**
1441
+	 * This simply sets up any qtips that have been defined in the page config
1442
+	 *
1443
+	 * @return void
1444
+	 */
1445
+	protected function _add_qtips()
1446
+	{
1447
+		if (isset($this->_route_config['qtips'])) {
1448
+			$qtips = (array) $this->_route_config['qtips'];
1449
+			// load qtip loader
1450
+			$path = [
1451
+				$this->_get_dir() . '/qtips/',
1452
+				EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1453
+			];
1454
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1455
+		}
1456
+	}
1457
+
1458
+
1459
+	/**
1460
+	 * _set_nav_tabs
1461
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you
1462
+	 * wish to add additional tabs or modify accordingly.
1463
+	 *
1464
+	 * @return void
1465
+	 * @throws InvalidArgumentException
1466
+	 * @throws InvalidInterfaceException
1467
+	 * @throws InvalidDataTypeException
1468
+	 */
1469
+	protected function _set_nav_tabs()
1470
+	{
1471
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1472
+		$i = 0;
1473
+		foreach ($this->_page_config as $slug => $config) {
1474
+			if (! is_array($config) || empty($config['nav'])) {
1475
+				continue;
1476
+			}
1477
+			// no nav tab for this config
1478
+			// check for persistent flag
1479
+			if ($slug !== $this->_req_action && isset($config['nav']['persistent']) && ! $config['nav']['persistent']) {
1480
+				// nav tab is only to appear when route requested.
1481
+				continue;
1482
+			}
1483
+			if (! $this->check_user_access($slug, true)) {
1484
+				// no nav tab because current user does not have access.
1485
+				continue;
1486
+			}
1487
+			$css_class                = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1488
+			$this->_nav_tabs[ $slug ] = [
1489
+				'url'       => isset($config['nav']['url'])
1490
+					? $config['nav']['url']
1491
+					: self::add_query_args_and_nonce(
1492
+						['action' => $slug],
1493
+						$this->_admin_base_url
1494
+					),
1495
+				'link_text' => isset($config['nav']['label'])
1496
+					? $config['nav']['label']
1497
+					: ucwords(
1498
+						str_replace('_', ' ', $slug)
1499
+					),
1500
+				'css_class' => $this->_req_action === $slug ? $css_class . 'nav-tab-active' : $css_class,
1501
+				'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1502
+			];
1503
+			$i++;
1504
+		}
1505
+		// if $this->_nav_tabs is empty then lets set the default
1506
+		if (empty($this->_nav_tabs)) {
1507
+			$this->_nav_tabs[ $this->_default_nav_tab_name ] = [
1508
+				'url'       => $this->_admin_base_url,
1509
+				'link_text' => ucwords(str_replace('_', ' ', $this->_default_nav_tab_name)),
1510
+				'css_class' => 'nav-tab-active',
1511
+				'order'     => 10,
1512
+			];
1513
+		}
1514
+		// now let's sort the tabs according to order
1515
+		usort($this->_nav_tabs, [$this, '_sort_nav_tabs']);
1516
+	}
1517
+
1518
+
1519
+	/**
1520
+	 * _set_current_labels
1521
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes
1522
+	 * property array
1523
+	 *
1524
+	 * @return void
1525
+	 */
1526
+	private function _set_current_labels()
1527
+	{
1528
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1529
+			foreach ($this->_route_config['labels'] as $label => $text) {
1530
+				if (is_array($text)) {
1531
+					foreach ($text as $sublabel => $subtext) {
1532
+						$this->_labels[ $label ][ $sublabel ] = $subtext;
1533
+					}
1534
+				} else {
1535
+					$this->_labels[ $label ] = $text;
1536
+				}
1537
+			}
1538
+		}
1539
+	}
1540
+
1541
+
1542
+	/**
1543
+	 *        verifies user access for this admin page
1544
+	 *
1545
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1546
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just
1547
+	 *                               return false if verify fail.
1548
+	 * @return bool
1549
+	 * @throws InvalidArgumentException
1550
+	 * @throws InvalidDataTypeException
1551
+	 * @throws InvalidInterfaceException
1552
+	 */
1553
+	public function check_user_access($route_to_check = '', $verify_only = false)
1554
+	{
1555
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1556
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1557
+		$capability     = ! empty($route_to_check) && isset($this->_page_routes[ $route_to_check ])
1558
+						  && is_array(
1559
+							  $this->_page_routes[ $route_to_check ]
1560
+						  )
1561
+						  && ! empty($this->_page_routes[ $route_to_check ]['capability'])
1562
+			? $this->_page_routes[ $route_to_check ]['capability'] : null;
1563
+		if (empty($capability) && empty($route_to_check)) {
1564
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options'
1565
+				: $this->_route['capability'];
1566
+		} else {
1567
+			$capability = empty($capability) ? 'manage_options' : $capability;
1568
+		}
1569
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1570
+		if (
1571
+			! defined('DOING_AJAX')
1572
+			&& (
1573
+				! function_exists('is_admin')
1574
+				|| ! EE_Registry::instance()->CAP->current_user_can(
1575
+					$capability,
1576
+					$this->page_slug
1577
+					. '_'
1578
+					. $route_to_check,
1579
+					$id
1580
+				)
1581
+			)
1582
+		) {
1583
+			if ($verify_only) {
1584
+				return false;
1585
+			}
1586
+			if (is_user_logged_in()) {
1587
+				wp_die(esc_html__('You do not have access to this route.', 'event_espresso'));
1588
+			} else {
1589
+				return false;
1590
+			}
1591
+		}
1592
+		return true;
1593
+	}
1594
+
1595
+
1596
+	/**
1597
+	 * admin_init_global
1598
+	 * This runs all the code that we want executed within the WP admin_init hook.
1599
+	 * This method executes for ALL EE Admin pages.
1600
+	 *
1601
+	 * @return void
1602
+	 */
1603
+	public function admin_init_global()
1604
+	{
1605
+	}
1606
+
1607
+
1608
+	/**
1609
+	 * wp_loaded_global
1610
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an
1611
+	 * EE_Admin page and will execute on every EE Admin Page load
1612
+	 *
1613
+	 * @return void
1614
+	 */
1615
+	public function wp_loaded()
1616
+	{
1617
+	}
1618
+
1619
+
1620
+	/**
1621
+	 * admin_notices
1622
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on
1623
+	 * ALL EE_Admin pages.
1624
+	 *
1625
+	 * @return void
1626
+	 */
1627
+	public function admin_notices_global()
1628
+	{
1629
+		$this->_display_no_javascript_warning();
1630
+		$this->_display_espresso_notices();
1631
+	}
1632
+
1633
+
1634
+	public function network_admin_notices_global()
1635
+	{
1636
+		$this->_display_no_javascript_warning();
1637
+		$this->_display_espresso_notices();
1638
+	}
1639
+
1640
+
1641
+	/**
1642
+	 * admin_footer_scripts_global
1643
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
1644
+	 * will apply on ALL EE_Admin pages.
1645
+	 *
1646
+	 * @return void
1647
+	 */
1648
+	public function admin_footer_scripts_global()
1649
+	{
1650
+		$this->_add_admin_page_ajax_loading_img();
1651
+		$this->_add_admin_page_overlay();
1652
+		// if metaboxes are present we need to add the nonce field
1653
+		if (
1654
+			isset($this->_route_config['metaboxes'])
1655
+			|| isset($this->_route_config['list_table'])
1656
+			|| (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes'])
1657
+		) {
1658
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1659
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1660
+		}
1661
+	}
1662
+
1663
+
1664
+	/**
1665
+	 * admin_footer_global
1666
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particular method will apply on
1667
+	 * ALL EE_Admin Pages.
1668
+	 *
1669
+	 * @return void
1670
+	 */
1671
+	public function admin_footer_global()
1672
+	{
1673
+		// dialog container for dialog helper
1674
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1675
+		$d_cont .= '<div class="ee-notices"></div>';
1676
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1677
+		$d_cont .= '</div>';
1678
+		echo $d_cont;
1679
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1680
+		// help tour stuff?
1681
+		// if (isset($this->_help_tour[ $this->_req_action ])) {
1682
+		//     echo implode('<br />', $this->_help_tour[ $this->_req_action ]);
1683
+		// }
1684
+		// current set timezone for timezone js
1685
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1686
+	}
1687
+
1688
+
1689
+	/**
1690
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then
1691
+	 * we'll use the retrieved array to output the content using the template. For child classes: If you want to have
1692
+	 * help popups then in your templates or your content you set "triggers" for the content using the
1693
+	 * "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method
1694
+	 * for the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup
1695
+	 * method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content
1696
+	 * for the
1697
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined
1698
+	 * "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1699
+	 *    'help_trigger_id' => array(
1700
+	 *        'title' => esc_html__('localized title for popup', 'event_espresso'),
1701
+	 *        'content' => esc_html__('localized content for popup', 'event_espresso')
1702
+	 *    )
1703
+	 * );
1704
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1705
+	 *
1706
+	 * @param array $help_array
1707
+	 * @param bool  $display
1708
+	 * @return string content
1709
+	 * @throws DomainException
1710
+	 * @throws EE_Error
1711
+	 */
1712
+	protected function _set_help_popup_content($help_array = [], $display = false)
1713
+	{
1714
+		$content    = '';
1715
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1716
+		// loop through the array and setup content
1717
+		foreach ($help_array as $trigger => $help) {
1718
+			// make sure the array is setup properly
1719
+			if (! isset($help['title']) || ! isset($help['content'])) {
1720
+				throw new EE_Error(
1721
+					esc_html__(
1722
+						'Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1723
+						'event_espresso'
1724
+					)
1725
+				);
1726
+			}
1727
+			// we're good so let'd setup the template vars and then assign parsed template content to our content.
1728
+			$template_args = [
1729
+				'help_popup_id'      => $trigger,
1730
+				'help_popup_title'   => $help['title'],
1731
+				'help_popup_content' => $help['content'],
1732
+			];
1733
+			$content       .= EEH_Template::display_template(
1734
+				EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php',
1735
+				$template_args,
1736
+				true
1737
+			);
1738
+		}
1739
+		if ($display) {
1740
+			echo $content;
1741
+			return '';
1742
+		}
1743
+		return $content;
1744
+	}
1745
+
1746
+
1747
+	/**
1748
+	 * All this does is retrieve the help content array if set by the EE_Admin_Page child
1749
+	 *
1750
+	 * @return array properly formatted array for help popup content
1751
+	 * @throws EE_Error
1752
+	 */
1753
+	private function _get_help_content()
1754
+	{
1755
+		// what is the method we're looking for?
1756
+		$method_name = '_help_popup_content_' . $this->_req_action;
1757
+		// if method doesn't exist let's get out.
1758
+		if (! method_exists($this, $method_name)) {
1759
+			return [];
1760
+		}
1761
+		// k we're good to go let's retrieve the help array
1762
+		$help_array = call_user_func([$this, $method_name]);
1763
+		// make sure we've got an array!
1764
+		if (! is_array($help_array)) {
1765
+			throw new EE_Error(
1766
+				esc_html__(
1767
+					'Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.',
1768
+					'event_espresso'
1769
+				)
1770
+			);
1771
+		}
1772
+		return $help_array;
1773
+	}
1774
+
1775
+
1776
+	/**
1777
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1778
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1779
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1780
+	 *
1781
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1782
+	 * @param boolean $display    if false then we return the trigger string
1783
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1784
+	 * @return string
1785
+	 * @throws DomainException
1786
+	 * @throws EE_Error
1787
+	 */
1788
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = ['400', '640'])
1789
+	{
1790
+		if (defined('DOING_AJAX')) {
1791
+			return '';
1792
+		}
1793
+		// let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1794
+		$help_array   = $this->_get_help_content();
1795
+		$help_content = '';
1796
+		if (empty($help_array) || ! isset($help_array[ $trigger_id ])) {
1797
+			$help_array[ $trigger_id ] = [
1798
+				'title'   => esc_html__('Missing Content', 'event_espresso'),
1799
+				'content' => esc_html__(
1800
+					'A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1801
+					'event_espresso'
1802
+				),
1803
+			];
1804
+			$help_content              = $this->_set_help_popup_content($help_array, false);
1805
+		}
1806
+		// let's setup the trigger
1807
+		$content = '<a class="ee-dialog" href="?height='
1808
+				   . $dimensions[0]
1809
+				   . '&width='
1810
+				   . $dimensions[1]
1811
+				   . '&inlineId='
1812
+				   . $trigger_id
1813
+				   . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1814
+		$content .= $help_content;
1815
+		if ($display) {
1816
+			echo $content;
1817
+			return '';
1818
+		}
1819
+		return $content;
1820
+	}
1821
+
1822
+
1823
+	/**
1824
+	 * _add_global_screen_options
1825
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1826
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1827
+	 *
1828
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1829
+	 *         see also WP_Screen object documents...
1830
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1831
+	 * @abstract
1832
+	 * @return void
1833
+	 */
1834
+	private function _add_global_screen_options()
1835
+	{
1836
+	}
1837
+
1838
+
1839
+	/**
1840
+	 * _add_global_feature_pointers
1841
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1842
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1843
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1844
+	 *
1845
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be
1846
+	 *         extended) also see:
1847
+	 * @link   http://eamann.com/tech/wordpress-portland/
1848
+	 * @abstract
1849
+	 * @return void
1850
+	 */
1851
+	private function _add_global_feature_pointers()
1852
+	{
1853
+	}
1854
+
1855
+
1856
+	/**
1857
+	 * load_global_scripts_styles
1858
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1859
+	 *
1860
+	 * @return void
1861
+	 */
1862
+	public function load_global_scripts_styles()
1863
+	{
1864
+		/** STYLES **/
1865
+		// add debugging styles
1866
+		if (WP_DEBUG) {
1867
+			add_action('admin_head', [$this, 'add_xdebug_style']);
1868
+		}
1869
+		// register all styles
1870
+		wp_register_style(
1871
+			'espresso-ui-theme',
1872
+			EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css',
1873
+			[],
1874
+			EVENT_ESPRESSO_VERSION
1875
+		);
1876
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', [], EVENT_ESPRESSO_VERSION);
1877
+		// helpers styles
1878
+		wp_register_style(
1879
+			'ee-text-links',
1880
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css',
1881
+			[],
1882
+			EVENT_ESPRESSO_VERSION
1883
+		);
1884
+		/** SCRIPTS **/
1885
+		// register all scripts
1886
+		wp_register_script(
1887
+			'ee-dialog',
1888
+			EE_ADMIN_URL . 'assets/ee-dialog-helper.js',
1889
+			['jquery', 'jquery-ui-draggable'],
1890
+			EVENT_ESPRESSO_VERSION,
1891
+			true
1892
+		);
1893
+		wp_register_script(
1894
+			'ee_admin_js',
1895
+			EE_ADMIN_URL . 'assets/ee-admin-page.js',
1896
+			['espresso_core', 'ee-parse-uri', 'ee-dialog'],
1897
+			EVENT_ESPRESSO_VERSION,
1898
+			true
1899
+		);
1900
+		wp_register_script(
1901
+			'jquery-ui-timepicker-addon',
1902
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js',
1903
+			['jquery-ui-datepicker', 'jquery-ui-slider'],
1904
+			EVENT_ESPRESSO_VERSION,
1905
+			true
1906
+		);
1907
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1908
+		// if (EE_Registry::instance()->CFG->admin->help_tour_activation) {
1909
+		//     add_filter('FHEE_load_joyride', '__return_true');
1910
+		// }
1911
+		// script for sorting tables
1912
+		wp_register_script(
1913
+			'espresso_ajax_table_sorting',
1914
+			EE_ADMIN_URL . 'assets/espresso_ajax_table_sorting.js',
1915
+			['ee_admin_js', 'jquery-ui-sortable'],
1916
+			EVENT_ESPRESSO_VERSION,
1917
+			true
1918
+		);
1919
+		// script for parsing uri's
1920
+		wp_register_script(
1921
+			'ee-parse-uri',
1922
+			EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js',
1923
+			[],
1924
+			EVENT_ESPRESSO_VERSION,
1925
+			true
1926
+		);
1927
+		// and parsing associative serialized form elements
1928
+		wp_register_script(
1929
+			'ee-serialize-full-array',
1930
+			EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js',
1931
+			['jquery'],
1932
+			EVENT_ESPRESSO_VERSION,
1933
+			true
1934
+		);
1935
+		// helpers scripts
1936
+		wp_register_script(
1937
+			'ee-text-links',
1938
+			EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js',
1939
+			['jquery'],
1940
+			EVENT_ESPRESSO_VERSION,
1941
+			true
1942
+		);
1943
+		wp_register_script(
1944
+			'ee-moment-core',
1945
+			EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js',
1946
+			[],
1947
+			EVENT_ESPRESSO_VERSION,
1948
+			true
1949
+		);
1950
+		wp_register_script(
1951
+			'ee-moment',
1952
+			EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js',
1953
+			['ee-moment-core'],
1954
+			EVENT_ESPRESSO_VERSION,
1955
+			true
1956
+		);
1957
+		wp_register_script(
1958
+			'ee-datepicker',
1959
+			EE_ADMIN_URL . 'assets/ee-datepicker.js',
1960
+			['jquery-ui-timepicker-addon', 'ee-moment'],
1961
+			EVENT_ESPRESSO_VERSION,
1962
+			true
1963
+		);
1964
+		// google charts
1965
+		wp_register_script(
1966
+			'google-charts',
1967
+			'https://www.gstatic.com/charts/loader.js',
1968
+			[],
1969
+			EVENT_ESPRESSO_VERSION,
1970
+			false
1971
+		);
1972
+		// ENQUEUE ALL BASICS BY DEFAULT
1973
+		wp_enqueue_style('ee-admin-css');
1974
+		wp_enqueue_script('ee_admin_js');
1975
+		wp_enqueue_script('ee-accounting');
1976
+		wp_enqueue_script('jquery-validate');
1977
+		// taking care of metaboxes
1978
+		if (
1979
+			empty($this->_cpt_route)
1980
+			&& (isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes']))
1981
+		) {
1982
+			wp_enqueue_script('dashboard');
1983
+		}
1984
+		// LOCALIZED DATA
1985
+		// localize script for ajax lazy loading
1986
+		$lazy_loader_container_ids = apply_filters(
1987
+			'FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers',
1988
+			['espresso_news_post_box_content']
1989
+		);
1990
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1991
+		// disabled temporarily. see: https://github.com/eventespresso/eventsmart.com-website/issues/836
1992
+		// /**
1993
+		//  * help tour stuff
1994
+		//  */
1995
+		// if (! empty($this->_help_tour)) {
1996
+		//     // register the js for kicking things off
1997
+		//     wp_enqueue_script(
1998
+		//         'ee-help-tour',
1999
+		//         EE_ADMIN_URL . 'assets/ee-help-tour.js',
2000
+		//         array('jquery-joyride'),
2001
+		//         EVENT_ESPRESSO_VERSION,
2002
+		//         true
2003
+		//     );
2004
+		//     $tours = array();
2005
+		//     // setup tours for the js tour object
2006
+		//     foreach ($this->_help_tour['tours'] as $tour) {
2007
+		//         if ($tour instanceof EE_Help_Tour) {
2008
+		//             $tours[] = array(
2009
+		//                 'id'      => $tour->get_slug(),
2010
+		//                 'options' => $tour->get_options(),
2011
+		//             );
2012
+		//         }
2013
+		//     }
2014
+		//     wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
2015
+		//     // admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
2016
+		// }
2017
+	}
2018
+
2019
+
2020
+	/**
2021
+	 *        admin_footer_scripts_eei18n_js_strings
2022
+	 *
2023
+	 * @return        void
2024
+	 */
2025
+	public function admin_footer_scripts_eei18n_js_strings()
2026
+	{
2027
+		EE_Registry::$i18n_js_strings['ajax_url']       = WP_AJAX_URL;
2028
+		EE_Registry::$i18n_js_strings['confirm_delete'] = wp_strip_all_tags(
2029
+			__(
2030
+				'Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!',
2031
+				'event_espresso'
2032
+			)
2033
+		);
2034
+		EE_Registry::$i18n_js_strings['January']        = wp_strip_all_tags(__('January', 'event_espresso'));
2035
+		EE_Registry::$i18n_js_strings['February']       = wp_strip_all_tags(__('February', 'event_espresso'));
2036
+		EE_Registry::$i18n_js_strings['March']          = wp_strip_all_tags(__('March', 'event_espresso'));
2037
+		EE_Registry::$i18n_js_strings['April']          = wp_strip_all_tags(__('April', 'event_espresso'));
2038
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2039
+		EE_Registry::$i18n_js_strings['June']           = wp_strip_all_tags(__('June', 'event_espresso'));
2040
+		EE_Registry::$i18n_js_strings['July']           = wp_strip_all_tags(__('July', 'event_espresso'));
2041
+		EE_Registry::$i18n_js_strings['August']         = wp_strip_all_tags(__('August', 'event_espresso'));
2042
+		EE_Registry::$i18n_js_strings['September']      = wp_strip_all_tags(__('September', 'event_espresso'));
2043
+		EE_Registry::$i18n_js_strings['October']        = wp_strip_all_tags(__('October', 'event_espresso'));
2044
+		EE_Registry::$i18n_js_strings['November']       = wp_strip_all_tags(__('November', 'event_espresso'));
2045
+		EE_Registry::$i18n_js_strings['December']       = wp_strip_all_tags(__('December', 'event_espresso'));
2046
+		EE_Registry::$i18n_js_strings['Jan']            = wp_strip_all_tags(__('Jan', 'event_espresso'));
2047
+		EE_Registry::$i18n_js_strings['Feb']            = wp_strip_all_tags(__('Feb', 'event_espresso'));
2048
+		EE_Registry::$i18n_js_strings['Mar']            = wp_strip_all_tags(__('Mar', 'event_espresso'));
2049
+		EE_Registry::$i18n_js_strings['Apr']            = wp_strip_all_tags(__('Apr', 'event_espresso'));
2050
+		EE_Registry::$i18n_js_strings['May']            = wp_strip_all_tags(__('May', 'event_espresso'));
2051
+		EE_Registry::$i18n_js_strings['Jun']            = wp_strip_all_tags(__('Jun', 'event_espresso'));
2052
+		EE_Registry::$i18n_js_strings['Jul']            = wp_strip_all_tags(__('Jul', 'event_espresso'));
2053
+		EE_Registry::$i18n_js_strings['Aug']            = wp_strip_all_tags(__('Aug', 'event_espresso'));
2054
+		EE_Registry::$i18n_js_strings['Sep']            = wp_strip_all_tags(__('Sep', 'event_espresso'));
2055
+		EE_Registry::$i18n_js_strings['Oct']            = wp_strip_all_tags(__('Oct', 'event_espresso'));
2056
+		EE_Registry::$i18n_js_strings['Nov']            = wp_strip_all_tags(__('Nov', 'event_espresso'));
2057
+		EE_Registry::$i18n_js_strings['Dec']            = wp_strip_all_tags(__('Dec', 'event_espresso'));
2058
+		EE_Registry::$i18n_js_strings['Sunday']         = wp_strip_all_tags(__('Sunday', 'event_espresso'));
2059
+		EE_Registry::$i18n_js_strings['Monday']         = wp_strip_all_tags(__('Monday', 'event_espresso'));
2060
+		EE_Registry::$i18n_js_strings['Tuesday']        = wp_strip_all_tags(__('Tuesday', 'event_espresso'));
2061
+		EE_Registry::$i18n_js_strings['Wednesday']      = wp_strip_all_tags(__('Wednesday', 'event_espresso'));
2062
+		EE_Registry::$i18n_js_strings['Thursday']       = wp_strip_all_tags(__('Thursday', 'event_espresso'));
2063
+		EE_Registry::$i18n_js_strings['Friday']         = wp_strip_all_tags(__('Friday', 'event_espresso'));
2064
+		EE_Registry::$i18n_js_strings['Saturday']       = wp_strip_all_tags(__('Saturday', 'event_espresso'));
2065
+		EE_Registry::$i18n_js_strings['Sun']            = wp_strip_all_tags(__('Sun', 'event_espresso'));
2066
+		EE_Registry::$i18n_js_strings['Mon']            = wp_strip_all_tags(__('Mon', 'event_espresso'));
2067
+		EE_Registry::$i18n_js_strings['Tue']            = wp_strip_all_tags(__('Tue', 'event_espresso'));
2068
+		EE_Registry::$i18n_js_strings['Wed']            = wp_strip_all_tags(__('Wed', 'event_espresso'));
2069
+		EE_Registry::$i18n_js_strings['Thu']            = wp_strip_all_tags(__('Thu', 'event_espresso'));
2070
+		EE_Registry::$i18n_js_strings['Fri']            = wp_strip_all_tags(__('Fri', 'event_espresso'));
2071
+		EE_Registry::$i18n_js_strings['Sat']            = wp_strip_all_tags(__('Sat', 'event_espresso'));
2072
+	}
2073
+
2074
+
2075
+	/**
2076
+	 *        load enhanced xdebug styles for ppl with failing eyesight
2077
+	 *
2078
+	 * @return        void
2079
+	 */
2080
+	public function add_xdebug_style()
2081
+	{
2082
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
2083
+	}
2084
+
2085
+
2086
+	/************************/
2087
+	/** LIST TABLE METHODS **/
2088
+	/************************/
2089
+	/**
2090
+	 * this sets up the list table if the current view requires it.
2091
+	 *
2092
+	 * @return void
2093
+	 * @throws EE_Error
2094
+	 */
2095
+	protected function _set_list_table()
2096
+	{
2097
+		// first is this a list_table view?
2098
+		if (! isset($this->_route_config['list_table'])) {
2099
+			return;
2100
+		} //not a list_table view so get out.
2101
+		// list table functions are per view specific (because some admin pages might have more than one list table!)
2102
+		$list_table_view = '_set_list_table_views_' . $this->_req_action;
2103
+		if (! method_exists($this, $list_table_view) || $this->{$list_table_view}() === false) {
2104
+			// user error msg
2105
+			$error_msg = esc_html__(
2106
+				'An error occurred. The requested list table views could not be found.',
2107
+				'event_espresso'
2108
+			);
2109
+			// developer error msg
2110
+			$error_msg .= '||'
2111
+						  . sprintf(
2112
+							  esc_html__(
2113
+								  'List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.',
2114
+								  'event_espresso'
2115
+							  ),
2116
+							  $this->_req_action,
2117
+							  $list_table_view
2118
+						  );
2119
+			throw new EE_Error($error_msg);
2120
+		}
2121
+		// let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
2122
+		$this->_views = apply_filters(
2123
+			'FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action,
2124
+			$this->_views
2125
+		);
2126
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
2127
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
2128
+		$this->_set_list_table_view();
2129
+		$this->_set_list_table_object();
2130
+	}
2131
+
2132
+
2133
+	/**
2134
+	 * set current view for List Table
2135
+	 *
2136
+	 * @return void
2137
+	 */
2138
+	protected function _set_list_table_view()
2139
+	{
2140
+		$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
2141
+		$status = $this->request->getRequestParam('status', null, 'key');
2142
+		$this->_view = $status && array_key_exists($status, $this->_views)
2143
+			? $status
2144
+			: $this->_view;
2145
+	}
2146
+
2147
+
2148
+	/**
2149
+	 * _set_list_table_object
2150
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
2151
+	 *
2152
+	 * @throws InvalidInterfaceException
2153
+	 * @throws InvalidArgumentException
2154
+	 * @throws InvalidDataTypeException
2155
+	 * @throws EE_Error
2156
+	 * @throws InvalidInterfaceException
2157
+	 */
2158
+	protected function _set_list_table_object()
2159
+	{
2160
+		if (isset($this->_route_config['list_table'])) {
2161
+			if (! class_exists($this->_route_config['list_table'])) {
2162
+				throw new EE_Error(
2163
+					sprintf(
2164
+						esc_html__(
2165
+							'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
2166
+							'event_espresso'
2167
+						),
2168
+						$this->_route_config['list_table'],
2169
+						get_class($this)
2170
+					)
2171
+				);
2172
+			}
2173
+			$this->_list_table_object = $this->loader->getShared(
2174
+				$this->_route_config['list_table'],
2175
+				[$this]
2176
+			);
2177
+		}
2178
+	}
2179
+
2180
+
2181
+	/**
2182
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
2183
+	 *
2184
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
2185
+	 *                                                    urls.  The array should be indexed by the view it is being
2186
+	 *                                                    added to.
2187
+	 * @return array
2188
+	 */
2189
+	public function get_list_table_view_RLs($extra_query_args = [])
2190
+	{
2191
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2192
+		if (empty($this->_views)) {
2193
+			$this->_views = [];
2194
+		}
2195
+		// cycle thru views
2196
+		foreach ($this->_views as $key => $view) {
2197
+			$query_args = [];
2198
+			// check for current view
2199
+			$this->_views[ $key ]['class']               = $this->_view === $view['slug'] ? 'current' : '';
2200
+			$query_args['action']                        = $this->_req_action;
2201
+			$query_args[ $this->_req_action . '_nonce' ] = wp_create_nonce($query_args['action'] . '_nonce');
2202
+			$query_args['status']                        = $view['slug'];
2203
+			// merge any other arguments sent in.
2204
+			if (isset($extra_query_args[ $view['slug'] ])) {
2205
+				$query_args = array_merge($query_args, $extra_query_args[ $view['slug'] ]);
2206
+			}
2207
+			$this->_views[ $key ]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2208
+		}
2209
+		return $this->_views;
2210
+	}
2211
+
2212
+
2213
+	/**
2214
+	 * _entries_per_page_dropdown
2215
+	 * generates a drop down box for selecting the number of visible rows in an admin page list table
2216
+	 *
2217
+	 * @param int $max_entries total number of rows in the table
2218
+	 * @return string
2219
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how
2220
+	 *         WP does it.
2221
+	 */
2222
+	protected function _entries_per_page_dropdown($max_entries = 0)
2223
+	{
2224
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2225
+		$values   = [10, 25, 50, 100];
2226
+		$per_page = $this->request->getRequestParam('per_page', 10, 'int');
2227
+		if ($max_entries) {
2228
+			$values[] = $max_entries;
2229
+			sort($values);
2230
+		}
2231
+		$entries_per_page_dropdown = '
2232 2232
 			<div id="entries-per-page-dv" class="alignleft actions">
2233 2233
 				<label class="hide-if-no-js">
2234 2234
 					Show
2235 2235
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
2236
-        foreach ($values as $value) {
2237
-            if ($value < $max_entries) {
2238
-                $selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2239
-                $entries_per_page_dropdown .= '
2236
+		foreach ($values as $value) {
2237
+			if ($value < $max_entries) {
2238
+				$selected                  = $value === $per_page ? ' selected="' . $per_page . '"' : '';
2239
+				$entries_per_page_dropdown .= '
2240 2240
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
2241
-            }
2242
-        }
2243
-        $selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2244
-        $entries_per_page_dropdown .= '
2241
+			}
2242
+		}
2243
+		$selected                  = $max_entries === $per_page ? ' selected="' . $per_page . '"' : '';
2244
+		$entries_per_page_dropdown .= '
2245 2245
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
2246
-        $entries_per_page_dropdown .= '
2246
+		$entries_per_page_dropdown .= '
2247 2247
 					</select>
2248 2248
 					entries
2249 2249
 				</label>
2250 2250
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
2251 2251
 			</div>
2252 2252
 		';
2253
-        return $entries_per_page_dropdown;
2254
-    }
2255
-
2256
-
2257
-    /**
2258
-     *        _set_search_attributes
2259
-     *
2260
-     * @return        void
2261
-     */
2262
-    public function _set_search_attributes()
2263
-    {
2264
-        $this->_template_args['search']['btn_label'] = sprintf(
2265
-            esc_html__('Search %s', 'event_espresso'),
2266
-            empty($this->_search_btn_label) ? $this->page_label
2267
-                : $this->_search_btn_label
2268
-        );
2269
-        $this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2270
-    }
2271
-
2272
-
2273
-
2274
-    /*** END LIST TABLE METHODS **/
2275
-
2276
-
2277
-    /**
2278
-     * _add_registered_metaboxes
2279
-     *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2280
-     *
2281
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2282
-     * @return void
2283
-     * @throws EE_Error
2284
-     */
2285
-    private function _add_registered_meta_boxes()
2286
-    {
2287
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2288
-        // we only add meta boxes if the page_route calls for it
2289
-        if (
2290
-            is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2291
-            && is_array(
2292
-                $this->_route_config['metaboxes']
2293
-            )
2294
-        ) {
2295
-            // this simply loops through the callbacks provided
2296
-            // and checks if there is a corresponding callback registered by the child
2297
-            // if there is then we go ahead and process the metabox loader.
2298
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2299
-                // first check for Closures
2300
-                if ($metabox_callback instanceof Closure) {
2301
-                    $result = $metabox_callback();
2302
-                } elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2303
-                    $result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2304
-                } else {
2305
-                    $result = call_user_func([$this, &$metabox_callback]);
2306
-                }
2307
-                if ($result === false) {
2308
-                    // user error msg
2309
-                    $error_msg = esc_html__(
2310
-                        'An error occurred. The  requested metabox could not be found.',
2311
-                        'event_espresso'
2312
-                    );
2313
-                    // developer error msg
2314
-                    $error_msg .= '||'
2315
-                                  . sprintf(
2316
-                                      esc_html__(
2317
-                                          'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2318
-                                          'event_espresso'
2319
-                                      ),
2320
-                                      $metabox_callback
2321
-                                  );
2322
-                    throw new EE_Error($error_msg);
2323
-                }
2324
-            }
2325
-        }
2326
-    }
2327
-
2328
-
2329
-    /**
2330
-     * _add_screen_columns
2331
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2332
-     * the dynamic column template and we'll setup the column options for the page.
2333
-     *
2334
-     * @return void
2335
-     */
2336
-    private function _add_screen_columns()
2337
-    {
2338
-        if (
2339
-            is_array($this->_route_config)
2340
-            && isset($this->_route_config['columns'])
2341
-            && is_array($this->_route_config['columns'])
2342
-            && count($this->_route_config['columns']) === 2
2343
-        ) {
2344
-            add_screen_option(
2345
-                'layout_columns',
2346
-                [
2347
-                    'max'     => (int) $this->_route_config['columns'][0],
2348
-                    'default' => (int) $this->_route_config['columns'][1],
2349
-                ]
2350
-            );
2351
-            $this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2352
-            $screen_id                                           = $this->_current_screen->id;
2353
-            $screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2354
-            $total_columns                                       = ! empty($screen_columns)
2355
-                ? $screen_columns
2356
-                : $this->_route_config['columns'][1];
2357
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2358
-            $this->_template_args['current_page']                = $this->_wp_page_slug;
2359
-            $this->_template_args['screen']                      = $this->_current_screen;
2360
-            $this->_column_template_path                         = EE_ADMIN_TEMPLATE
2361
-                                                                   . 'admin_details_metabox_column_wrapper.template.php';
2362
-            // finally if we don't have has_metaboxes set in the route config
2363
-            // let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2364
-            $this->_route_config['has_metaboxes'] = true;
2365
-        }
2366
-    }
2367
-
2368
-
2369
-
2370
-    /** GLOBALLY AVAILABLE METABOXES **/
2371
-
2372
-
2373
-    /**
2374
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2375
-     * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2376
-     * these get loaded on.
2377
-     */
2378
-    private function _espresso_news_post_box()
2379
-    {
2380
-        $news_box_title = apply_filters(
2381
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2382
-            esc_html__('New @ Event Espresso', 'event_espresso')
2383
-        );
2384
-        add_meta_box(
2385
-            'espresso_news_post_box',
2386
-            $news_box_title,
2387
-            [
2388
-                $this,
2389
-                'espresso_news_post_box',
2390
-            ],
2391
-            $this->_wp_page_slug,
2392
-            'side'
2393
-        );
2394
-    }
2395
-
2396
-
2397
-    /**
2398
-     * Code for setting up espresso ratings request metabox.
2399
-     */
2400
-    protected function _espresso_ratings_request()
2401
-    {
2402
-        if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2403
-            return;
2404
-        }
2405
-        $ratings_box_title = apply_filters(
2406
-            'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2407
-            esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2408
-        );
2409
-        add_meta_box(
2410
-            'espresso_ratings_request',
2411
-            $ratings_box_title,
2412
-            [
2413
-                $this,
2414
-                'espresso_ratings_request',
2415
-            ],
2416
-            $this->_wp_page_slug,
2417
-            'side'
2418
-        );
2419
-    }
2420
-
2421
-
2422
-    /**
2423
-     * Code for setting up espresso ratings request metabox content.
2424
-     *
2425
-     * @throws DomainException
2426
-     */
2427
-    public function espresso_ratings_request()
2428
-    {
2429
-        EEH_Template::display_template(
2430
-            EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2431
-            []
2432
-        );
2433
-    }
2434
-
2435
-
2436
-    public static function cached_rss_display($rss_id, $url)
2437
-    {
2438
-        $loading   = '<p class="widget-loading hide-if-no-js">'
2439
-                     . esc_html__('Loading&#8230;', 'event_espresso')
2440
-                     . '</p><p class="hide-if-js">'
2441
-                     . esc_html__('This widget requires JavaScript.', 'event_espresso')
2442
-                     . '</p>';
2443
-        $pre       = '<div class="espresso-rss-display">' . "\n\t";
2444
-        $pre       .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2445
-        $post      = '</div>' . "\n";
2446
-        $cache_key = 'ee_rss_' . md5($rss_id);
2447
-        $output    = get_transient($cache_key);
2448
-        if ($output !== false) {
2449
-            echo $pre . $output . $post;
2450
-            return true;
2451
-        }
2452
-        if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2453
-            echo $pre . $loading . $post;
2454
-            return false;
2455
-        }
2456
-        ob_start();
2457
-        wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2458
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2459
-        return true;
2460
-    }
2461
-
2462
-
2463
-    public function espresso_news_post_box()
2464
-    {
2465
-        ?>
2253
+		return $entries_per_page_dropdown;
2254
+	}
2255
+
2256
+
2257
+	/**
2258
+	 *        _set_search_attributes
2259
+	 *
2260
+	 * @return        void
2261
+	 */
2262
+	public function _set_search_attributes()
2263
+	{
2264
+		$this->_template_args['search']['btn_label'] = sprintf(
2265
+			esc_html__('Search %s', 'event_espresso'),
2266
+			empty($this->_search_btn_label) ? $this->page_label
2267
+				: $this->_search_btn_label
2268
+		);
2269
+		$this->_template_args['search']['callback']  = 'search_' . $this->page_slug;
2270
+	}
2271
+
2272
+
2273
+
2274
+	/*** END LIST TABLE METHODS **/
2275
+
2276
+
2277
+	/**
2278
+	 * _add_registered_metaboxes
2279
+	 *  this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
2280
+	 *
2281
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
2282
+	 * @return void
2283
+	 * @throws EE_Error
2284
+	 */
2285
+	private function _add_registered_meta_boxes()
2286
+	{
2287
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2288
+		// we only add meta boxes if the page_route calls for it
2289
+		if (
2290
+			is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
2291
+			&& is_array(
2292
+				$this->_route_config['metaboxes']
2293
+			)
2294
+		) {
2295
+			// this simply loops through the callbacks provided
2296
+			// and checks if there is a corresponding callback registered by the child
2297
+			// if there is then we go ahead and process the metabox loader.
2298
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
2299
+				// first check for Closures
2300
+				if ($metabox_callback instanceof Closure) {
2301
+					$result = $metabox_callback();
2302
+				} elseif (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
2303
+					$result = call_user_func([$metabox_callback[0], $metabox_callback[1]]);
2304
+				} else {
2305
+					$result = call_user_func([$this, &$metabox_callback]);
2306
+				}
2307
+				if ($result === false) {
2308
+					// user error msg
2309
+					$error_msg = esc_html__(
2310
+						'An error occurred. The  requested metabox could not be found.',
2311
+						'event_espresso'
2312
+					);
2313
+					// developer error msg
2314
+					$error_msg .= '||'
2315
+								  . sprintf(
2316
+									  esc_html__(
2317
+										  'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
2318
+										  'event_espresso'
2319
+									  ),
2320
+									  $metabox_callback
2321
+								  );
2322
+					throw new EE_Error($error_msg);
2323
+				}
2324
+			}
2325
+		}
2326
+	}
2327
+
2328
+
2329
+	/**
2330
+	 * _add_screen_columns
2331
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as
2332
+	 * the dynamic column template and we'll setup the column options for the page.
2333
+	 *
2334
+	 * @return void
2335
+	 */
2336
+	private function _add_screen_columns()
2337
+	{
2338
+		if (
2339
+			is_array($this->_route_config)
2340
+			&& isset($this->_route_config['columns'])
2341
+			&& is_array($this->_route_config['columns'])
2342
+			&& count($this->_route_config['columns']) === 2
2343
+		) {
2344
+			add_screen_option(
2345
+				'layout_columns',
2346
+				[
2347
+					'max'     => (int) $this->_route_config['columns'][0],
2348
+					'default' => (int) $this->_route_config['columns'][1],
2349
+				]
2350
+			);
2351
+			$this->_template_args['num_columns']                 = $this->_route_config['columns'][0];
2352
+			$screen_id                                           = $this->_current_screen->id;
2353
+			$screen_columns                                      = (int) get_user_option("screen_layout_{$screen_id}");
2354
+			$total_columns                                       = ! empty($screen_columns)
2355
+				? $screen_columns
2356
+				: $this->_route_config['columns'][1];
2357
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
2358
+			$this->_template_args['current_page']                = $this->_wp_page_slug;
2359
+			$this->_template_args['screen']                      = $this->_current_screen;
2360
+			$this->_column_template_path                         = EE_ADMIN_TEMPLATE
2361
+																   . 'admin_details_metabox_column_wrapper.template.php';
2362
+			// finally if we don't have has_metaboxes set in the route config
2363
+			// let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
2364
+			$this->_route_config['has_metaboxes'] = true;
2365
+		}
2366
+	}
2367
+
2368
+
2369
+
2370
+	/** GLOBALLY AVAILABLE METABOXES **/
2371
+
2372
+
2373
+	/**
2374
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply
2375
+	 * referencing the callback in the _page_config array property.  This way you can be very specific about what pages
2376
+	 * these get loaded on.
2377
+	 */
2378
+	private function _espresso_news_post_box()
2379
+	{
2380
+		$news_box_title = apply_filters(
2381
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2382
+			esc_html__('New @ Event Espresso', 'event_espresso')
2383
+		);
2384
+		add_meta_box(
2385
+			'espresso_news_post_box',
2386
+			$news_box_title,
2387
+			[
2388
+				$this,
2389
+				'espresso_news_post_box',
2390
+			],
2391
+			$this->_wp_page_slug,
2392
+			'side'
2393
+		);
2394
+	}
2395
+
2396
+
2397
+	/**
2398
+	 * Code for setting up espresso ratings request metabox.
2399
+	 */
2400
+	protected function _espresso_ratings_request()
2401
+	{
2402
+		if (! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
2403
+			return;
2404
+		}
2405
+		$ratings_box_title = apply_filters(
2406
+			'FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title',
2407
+			esc_html__('Keep Event Espresso Decaf Free', 'event_espresso')
2408
+		);
2409
+		add_meta_box(
2410
+			'espresso_ratings_request',
2411
+			$ratings_box_title,
2412
+			[
2413
+				$this,
2414
+				'espresso_ratings_request',
2415
+			],
2416
+			$this->_wp_page_slug,
2417
+			'side'
2418
+		);
2419
+	}
2420
+
2421
+
2422
+	/**
2423
+	 * Code for setting up espresso ratings request metabox content.
2424
+	 *
2425
+	 * @throws DomainException
2426
+	 */
2427
+	public function espresso_ratings_request()
2428
+	{
2429
+		EEH_Template::display_template(
2430
+			EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php',
2431
+			[]
2432
+		);
2433
+	}
2434
+
2435
+
2436
+	public static function cached_rss_display($rss_id, $url)
2437
+	{
2438
+		$loading   = '<p class="widget-loading hide-if-no-js">'
2439
+					 . esc_html__('Loading&#8230;', 'event_espresso')
2440
+					 . '</p><p class="hide-if-js">'
2441
+					 . esc_html__('This widget requires JavaScript.', 'event_espresso')
2442
+					 . '</p>';
2443
+		$pre       = '<div class="espresso-rss-display">' . "\n\t";
2444
+		$pre       .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
2445
+		$post      = '</div>' . "\n";
2446
+		$cache_key = 'ee_rss_' . md5($rss_id);
2447
+		$output    = get_transient($cache_key);
2448
+		if ($output !== false) {
2449
+			echo $pre . $output . $post;
2450
+			return true;
2451
+		}
2452
+		if (! (defined('DOING_AJAX') && DOING_AJAX)) {
2453
+			echo $pre . $loading . $post;
2454
+			return false;
2455
+		}
2456
+		ob_start();
2457
+		wp_widget_rss_output($url, ['show_date' => 0, 'items' => 5]);
2458
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
2459
+		return true;
2460
+	}
2461
+
2462
+
2463
+	public function espresso_news_post_box()
2464
+	{
2465
+		?>
2466 2466
         <div class="padding">
2467 2467
             <div id="espresso_news_post_box_content" class="infolinks">
2468 2468
                 <?php
2469
-                // Get RSS Feed(s)
2470
-                self::cached_rss_display(
2471
-                    'espresso_news_post_box_content',
2472
-                    urlencode(
2473
-                        apply_filters(
2474
-                            'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2475
-                            'http://eventespresso.com/feed/'
2476
-                        )
2477
-                    )
2478
-                );
2479
-                ?>
2469
+				// Get RSS Feed(s)
2470
+				self::cached_rss_display(
2471
+					'espresso_news_post_box_content',
2472
+					urlencode(
2473
+						apply_filters(
2474
+							'FHEE__EE_Admin_Page__espresso_news_post_box__feed_url',
2475
+							'http://eventespresso.com/feed/'
2476
+						)
2477
+					)
2478
+				);
2479
+				?>
2480 2480
             </div>
2481 2481
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
2482 2482
         </div>
2483 2483
         <?php
2484
-    }
2485
-
2486
-
2487
-    private function _espresso_links_post_box()
2488
-    {
2489
-        // Hiding until we actually have content to put in here...
2490
-        // add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2491
-    }
2492
-
2493
-
2494
-    public function espresso_links_post_box()
2495
-    {
2496
-        // Hiding until we actually have content to put in here...
2497
-        // EEH_Template::display_template(
2498
-        //     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2499
-        // );
2500
-    }
2501
-
2502
-
2503
-    protected function _espresso_sponsors_post_box()
2504
-    {
2505
-        if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2506
-            add_meta_box(
2507
-                'espresso_sponsors_post_box',
2508
-                esc_html__('Event Espresso Highlights', 'event_espresso'),
2509
-                [$this, 'espresso_sponsors_post_box'],
2510
-                $this->_wp_page_slug,
2511
-                'side'
2512
-            );
2513
-        }
2514
-    }
2515
-
2516
-
2517
-    public function espresso_sponsors_post_box()
2518
-    {
2519
-        EEH_Template::display_template(
2520
-            EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2521
-        );
2522
-    }
2523
-
2524
-
2525
-    private function _publish_post_box()
2526
-    {
2527
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2528
-        // if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2529
-        // then we'll use that for the metabox label.
2530
-        // Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2531
-        if (! empty($this->_labels['publishbox'])) {
2532
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2533
-                : $this->_labels['publishbox'];
2534
-        } else {
2535
-            $box_label = esc_html__('Publish', 'event_espresso');
2536
-        }
2537
-        $box_label = apply_filters(
2538
-            'FHEE__EE_Admin_Page___publish_post_box__box_label',
2539
-            $box_label,
2540
-            $this->_req_action,
2541
-            $this
2542
-        );
2543
-        add_meta_box(
2544
-            $meta_box_ref,
2545
-            $box_label,
2546
-            [$this, 'editor_overview'],
2547
-            $this->_current_screen->id,
2548
-            'side',
2549
-            'high'
2550
-        );
2551
-    }
2552
-
2553
-
2554
-    public function editor_overview()
2555
-    {
2556
-        // if we have extra content set let's add it in if not make sure its empty
2557
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2558
-            ? $this->_template_args['publish_box_extra_content']
2559
-            : '';
2560
-        echo EEH_Template::display_template(
2561
-            EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2562
-            $this->_template_args,
2563
-            true
2564
-        );
2565
-    }
2566
-
2567
-
2568
-    /** end of globally available metaboxes section **/
2569
-
2570
-
2571
-    /**
2572
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2573
-     * protected method.
2574
-     *
2575
-     * @param string $name
2576
-     * @param int    $id
2577
-     * @param bool   $delete
2578
-     * @param string $save_close_redirect_URL
2579
-     * @param bool   $both_btns
2580
-     * @throws EE_Error
2581
-     * @throws InvalidArgumentException
2582
-     * @throws InvalidDataTypeException
2583
-     * @throws InvalidInterfaceException
2584
-     * @see   $this->_set_publish_post_box_vars for param details
2585
-     * @since 4.6.0
2586
-     */
2587
-    public function set_publish_post_box_vars(
2588
-        $name = '',
2589
-        $id = 0,
2590
-        $delete = false,
2591
-        $save_close_redirect_URL = '',
2592
-        $both_btns = true
2593
-    ) {
2594
-        $this->_set_publish_post_box_vars(
2595
-            $name,
2596
-            $id,
2597
-            $delete,
2598
-            $save_close_redirect_URL,
2599
-            $both_btns
2600
-        );
2601
-    }
2602
-
2603
-
2604
-    /**
2605
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2606
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2607
-     * save, and save and close buttons to work properly, then you will want to include a
2608
-     * values for the name and id arguments.
2609
-     *
2610
-     * @param string  $name                       key used for the action ID (i.e. event_id)
2611
-     * @param int     $id                         id attached to the item published
2612
-     * @param string  $delete                     page route callback for the delete action
2613
-     * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2614
-     * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2615
-     *                                            the Save button
2616
-     * @throws EE_Error
2617
-     * @throws InvalidArgumentException
2618
-     * @throws InvalidDataTypeException
2619
-     * @throws InvalidInterfaceException
2620
-     * @todo  Add in validation for name/id arguments.
2621
-     */
2622
-    protected function _set_publish_post_box_vars(
2623
-        $name = '',
2624
-        $id = 0,
2625
-        $delete = '',
2626
-        $save_close_redirect_URL = '',
2627
-        $both_btns = true
2628
-    ) {
2629
-        // if Save & Close, use a custom redirect URL or default to the main page?
2630
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL)
2631
-            ? $save_close_redirect_URL
2632
-            : $this->_admin_base_url;
2633
-        // create the Save & Close and Save buttons
2634
-        $this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2635
-        // if we have extra content set let's add it in if not make sure its empty
2636
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2637
-            ? $this->_template_args['publish_box_extra_content']
2638
-            : '';
2639
-        if ($delete && ! empty($id)) {
2640
-            // make sure we have a default if just true is sent.
2641
-            $delete           = ! empty($delete) ? $delete : 'delete';
2642
-            $delete_link_args = [$name => $id];
2643
-            $delete           = $this->get_action_link_or_button(
2644
-                $delete,
2645
-                $delete,
2646
-                $delete_link_args,
2647
-                'submitdelete deletion',
2648
-                '',
2649
-                false
2650
-            );
2651
-        }
2652
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2653
-        if (! empty($name) && ! empty($id)) {
2654
-            $hidden_field_arr[ $name ] = [
2655
-                'type'  => 'hidden',
2656
-                'value' => $id,
2657
-            ];
2658
-            $hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2659
-        } else {
2660
-            $hf = '';
2661
-        }
2662
-        // add hidden field
2663
-        $this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2664
-            ? $hf[ $name ]['field']
2665
-            : $hf;
2666
-    }
2667
-
2668
-
2669
-    /**
2670
-     * displays an error message to ppl who have javascript disabled
2671
-     *
2672
-     * @return void
2673
-     */
2674
-    private function _display_no_javascript_warning()
2675
-    {
2676
-        ?>
2484
+	}
2485
+
2486
+
2487
+	private function _espresso_links_post_box()
2488
+	{
2489
+		// Hiding until we actually have content to put in here...
2490
+		// add_meta_box('espresso_links_post_box', esc_html__('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2491
+	}
2492
+
2493
+
2494
+	public function espresso_links_post_box()
2495
+	{
2496
+		// Hiding until we actually have content to put in here...
2497
+		// EEH_Template::display_template(
2498
+		//     EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php'
2499
+		// );
2500
+	}
2501
+
2502
+
2503
+	protected function _espresso_sponsors_post_box()
2504
+	{
2505
+		if (apply_filters('FHEE_show_sponsors_meta_box', true)) {
2506
+			add_meta_box(
2507
+				'espresso_sponsors_post_box',
2508
+				esc_html__('Event Espresso Highlights', 'event_espresso'),
2509
+				[$this, 'espresso_sponsors_post_box'],
2510
+				$this->_wp_page_slug,
2511
+				'side'
2512
+			);
2513
+		}
2514
+	}
2515
+
2516
+
2517
+	public function espresso_sponsors_post_box()
2518
+	{
2519
+		EEH_Template::display_template(
2520
+			EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php'
2521
+		);
2522
+	}
2523
+
2524
+
2525
+	private function _publish_post_box()
2526
+	{
2527
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2528
+		// if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array
2529
+		// then we'll use that for the metabox label.
2530
+		// Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2531
+		if (! empty($this->_labels['publishbox'])) {
2532
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][ $this->_req_action ]
2533
+				: $this->_labels['publishbox'];
2534
+		} else {
2535
+			$box_label = esc_html__('Publish', 'event_espresso');
2536
+		}
2537
+		$box_label = apply_filters(
2538
+			'FHEE__EE_Admin_Page___publish_post_box__box_label',
2539
+			$box_label,
2540
+			$this->_req_action,
2541
+			$this
2542
+		);
2543
+		add_meta_box(
2544
+			$meta_box_ref,
2545
+			$box_label,
2546
+			[$this, 'editor_overview'],
2547
+			$this->_current_screen->id,
2548
+			'side',
2549
+			'high'
2550
+		);
2551
+	}
2552
+
2553
+
2554
+	public function editor_overview()
2555
+	{
2556
+		// if we have extra content set let's add it in if not make sure its empty
2557
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2558
+			? $this->_template_args['publish_box_extra_content']
2559
+			: '';
2560
+		echo EEH_Template::display_template(
2561
+			EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php',
2562
+			$this->_template_args,
2563
+			true
2564
+		);
2565
+	}
2566
+
2567
+
2568
+	/** end of globally available metaboxes section **/
2569
+
2570
+
2571
+	/**
2572
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2573
+	 * protected method.
2574
+	 *
2575
+	 * @param string $name
2576
+	 * @param int    $id
2577
+	 * @param bool   $delete
2578
+	 * @param string $save_close_redirect_URL
2579
+	 * @param bool   $both_btns
2580
+	 * @throws EE_Error
2581
+	 * @throws InvalidArgumentException
2582
+	 * @throws InvalidDataTypeException
2583
+	 * @throws InvalidInterfaceException
2584
+	 * @see   $this->_set_publish_post_box_vars for param details
2585
+	 * @since 4.6.0
2586
+	 */
2587
+	public function set_publish_post_box_vars(
2588
+		$name = '',
2589
+		$id = 0,
2590
+		$delete = false,
2591
+		$save_close_redirect_URL = '',
2592
+		$both_btns = true
2593
+	) {
2594
+		$this->_set_publish_post_box_vars(
2595
+			$name,
2596
+			$id,
2597
+			$delete,
2598
+			$save_close_redirect_URL,
2599
+			$both_btns
2600
+		);
2601
+	}
2602
+
2603
+
2604
+	/**
2605
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2606
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2607
+	 * save, and save and close buttons to work properly, then you will want to include a
2608
+	 * values for the name and id arguments.
2609
+	 *
2610
+	 * @param string  $name                       key used for the action ID (i.e. event_id)
2611
+	 * @param int     $id                         id attached to the item published
2612
+	 * @param string  $delete                     page route callback for the delete action
2613
+	 * @param string  $save_close_redirect_URL    custom URL to redirect to after Save & Close has been completed
2614
+	 * @param boolean $both_btns                  whether to display BOTH the "Save & Close" and "Save" buttons or just
2615
+	 *                                            the Save button
2616
+	 * @throws EE_Error
2617
+	 * @throws InvalidArgumentException
2618
+	 * @throws InvalidDataTypeException
2619
+	 * @throws InvalidInterfaceException
2620
+	 * @todo  Add in validation for name/id arguments.
2621
+	 */
2622
+	protected function _set_publish_post_box_vars(
2623
+		$name = '',
2624
+		$id = 0,
2625
+		$delete = '',
2626
+		$save_close_redirect_URL = '',
2627
+		$both_btns = true
2628
+	) {
2629
+		// if Save & Close, use a custom redirect URL or default to the main page?
2630
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL)
2631
+			? $save_close_redirect_URL
2632
+			: $this->_admin_base_url;
2633
+		// create the Save & Close and Save buttons
2634
+		$this->_set_save_buttons($both_btns, [], [], $save_close_redirect_URL);
2635
+		// if we have extra content set let's add it in if not make sure its empty
2636
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content'])
2637
+			? $this->_template_args['publish_box_extra_content']
2638
+			: '';
2639
+		if ($delete && ! empty($id)) {
2640
+			// make sure we have a default if just true is sent.
2641
+			$delete           = ! empty($delete) ? $delete : 'delete';
2642
+			$delete_link_args = [$name => $id];
2643
+			$delete           = $this->get_action_link_or_button(
2644
+				$delete,
2645
+				$delete,
2646
+				$delete_link_args,
2647
+				'submitdelete deletion',
2648
+				'',
2649
+				false
2650
+			);
2651
+		}
2652
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2653
+		if (! empty($name) && ! empty($id)) {
2654
+			$hidden_field_arr[ $name ] = [
2655
+				'type'  => 'hidden',
2656
+				'value' => $id,
2657
+			];
2658
+			$hf                        = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2659
+		} else {
2660
+			$hf = '';
2661
+		}
2662
+		// add hidden field
2663
+		$this->_template_args['publish_hidden_fields'] = is_array($hf) && ! empty($name)
2664
+			? $hf[ $name ]['field']
2665
+			: $hf;
2666
+	}
2667
+
2668
+
2669
+	/**
2670
+	 * displays an error message to ppl who have javascript disabled
2671
+	 *
2672
+	 * @return void
2673
+	 */
2674
+	private function _display_no_javascript_warning()
2675
+	{
2676
+		?>
2677 2677
         <noscript>
2678 2678
             <div id="no-js-message" class="error">
2679 2679
                 <p style="font-size:1.3em;">
2680 2680
                     <span style="color:red;"><?php esc_html_e('Warning!', 'event_espresso'); ?></span>
2681 2681
                     <?php esc_html_e(
2682
-                        'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2683
-                        'event_espresso'
2684
-                    ); ?>
2682
+						'Javascript is currently turned off for your browser. Javascript must be enabled in order for all of the features on this page to function properly. Please turn your javascript back on.',
2683
+						'event_espresso'
2684
+					); ?>
2685 2685
                 </p>
2686 2686
             </div>
2687 2687
         </noscript>
2688 2688
         <?php
2689
-    }
2690
-
2691
-
2692
-    /**
2693
-     * displays espresso success and/or error notices
2694
-     *
2695
-     * @return void
2696
-     */
2697
-    private function _display_espresso_notices()
2698
-    {
2699
-        $notices = $this->_get_transient(true);
2700
-        echo stripslashes($notices);
2701
-    }
2702
-
2703
-
2704
-    /**
2705
-     * spinny things pacify the masses
2706
-     *
2707
-     * @return void
2708
-     */
2709
-    protected function _add_admin_page_ajax_loading_img()
2710
-    {
2711
-        ?>
2689
+	}
2690
+
2691
+
2692
+	/**
2693
+	 * displays espresso success and/or error notices
2694
+	 *
2695
+	 * @return void
2696
+	 */
2697
+	private function _display_espresso_notices()
2698
+	{
2699
+		$notices = $this->_get_transient(true);
2700
+		echo stripslashes($notices);
2701
+	}
2702
+
2703
+
2704
+	/**
2705
+	 * spinny things pacify the masses
2706
+	 *
2707
+	 * @return void
2708
+	 */
2709
+	protected function _add_admin_page_ajax_loading_img()
2710
+	{
2711
+		?>
2712 2712
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2713 2713
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php
2714
-                esc_html_e('loading...', 'event_espresso'); ?></span>
2714
+				esc_html_e('loading...', 'event_espresso'); ?></span>
2715 2715
         </div>
2716 2716
         <?php
2717
-    }
2717
+	}
2718 2718
 
2719 2719
 
2720
-    /**
2721
-     * add admin page overlay for modal boxes
2722
-     *
2723
-     * @return void
2724
-     */
2725
-    protected function _add_admin_page_overlay()
2726
-    {
2727
-        ?>
2720
+	/**
2721
+	 * add admin page overlay for modal boxes
2722
+	 *
2723
+	 * @return void
2724
+	 */
2725
+	protected function _add_admin_page_overlay()
2726
+	{
2727
+		?>
2728 2728
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2729 2729
         <?php
2730
-    }
2731
-
2732
-
2733
-    /**
2734
-     * facade for add_meta_box
2735
-     *
2736
-     * @param string  $action        where the metabox get's displayed
2737
-     * @param string  $title         Title of Metabox (output in metabox header)
2738
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2739
-     *                               instead of the one created in here.
2740
-     * @param array   $callback_args an array of args supplied for the metabox
2741
-     * @param string  $column        what metabox column
2742
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2743
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2744
-     *                               created but just set our own callback for wp's add_meta_box.
2745
-     * @throws DomainException
2746
-     */
2747
-    public function _add_admin_page_meta_box(
2748
-        $action,
2749
-        $title,
2750
-        $callback,
2751
-        $callback_args,
2752
-        $column = 'normal',
2753
-        $priority = 'high',
2754
-        $create_func = true
2755
-    ) {
2756
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2757
-        // if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2758
-        if (empty($callback_args) && $create_func) {
2759
-            $callback_args = [
2760
-                'template_path' => $this->_template_path,
2761
-                'template_args' => $this->_template_args,
2762
-            ];
2763
-        }
2764
-        // if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2765
-        $call_back_func = $create_func
2766
-            ? function ($post, $metabox) {
2767
-                do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2768
-                echo EEH_Template::display_template(
2769
-                    $metabox['args']['template_path'],
2770
-                    $metabox['args']['template_args'],
2771
-                    true
2772
-                );
2773
-            }
2774
-            : $callback;
2775
-        add_meta_box(
2776
-            str_replace('_', '-', $action) . '-mbox',
2777
-            $title,
2778
-            $call_back_func,
2779
-            $this->_wp_page_slug,
2780
-            $column,
2781
-            $priority,
2782
-            $callback_args
2783
-        );
2784
-    }
2785
-
2786
-
2787
-    /**
2788
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2789
-     *
2790
-     * @throws DomainException
2791
-     * @throws EE_Error
2792
-     */
2793
-    public function display_admin_page_with_metabox_columns()
2794
-    {
2795
-        $this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2796
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2797
-            $this->_column_template_path,
2798
-            $this->_template_args,
2799
-            true
2800
-        );
2801
-        // the final wrapper
2802
-        $this->admin_page_wrapper();
2803
-    }
2804
-
2805
-
2806
-    /**
2807
-     * generates  HTML wrapper for an admin details page
2808
-     *
2809
-     * @return void
2810
-     * @throws EE_Error
2811
-     * @throws DomainException
2812
-     */
2813
-    public function display_admin_page_with_sidebar()
2814
-    {
2815
-        $this->_display_admin_page(true);
2816
-    }
2817
-
2818
-
2819
-    /**
2820
-     * generates  HTML wrapper for an admin details page (except no sidebar)
2821
-     *
2822
-     * @return void
2823
-     * @throws EE_Error
2824
-     * @throws DomainException
2825
-     */
2826
-    public function display_admin_page_with_no_sidebar()
2827
-    {
2828
-        $this->_display_admin_page();
2829
-    }
2830
-
2831
-
2832
-    /**
2833
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2834
-     *
2835
-     * @return void
2836
-     * @throws EE_Error
2837
-     * @throws DomainException
2838
-     */
2839
-    public function display_about_admin_page()
2840
-    {
2841
-        $this->_display_admin_page(false, true);
2842
-    }
2843
-
2844
-
2845
-    /**
2846
-     * display_admin_page
2847
-     * contains the code for actually displaying an admin page
2848
-     *
2849
-     * @param boolean $sidebar true with sidebar, false without
2850
-     * @param boolean $about   use the about admin wrapper instead of the default.
2851
-     * @return void
2852
-     * @throws DomainException
2853
-     * @throws EE_Error
2854
-     */
2855
-    private function _display_admin_page($sidebar = false, $about = false)
2856
-    {
2857
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2858
-        // custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2859
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2860
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2861
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2862
-        $this->_template_args['current_page']              = $this->_wp_page_slug;
2863
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2864
-            ? 'poststuff'
2865
-            : 'espresso-default-admin';
2866
-        $template_path                                     = $sidebar
2867
-            ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2868
-            : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2869
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2870
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2871
-        }
2872
-        $template_path                                     = ! empty($this->_column_template_path)
2873
-            ? $this->_column_template_path : $template_path;
2874
-        $this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2875
-            ? $this->_template_args['admin_page_content']
2876
-            : '';
2877
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2878
-            ? $this->_template_args['before_admin_page_content']
2879
-            : '';
2880
-        $this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2881
-            ? $this->_template_args['after_admin_page_content']
2882
-            : '';
2883
-        $this->_template_args['admin_page_content']        = EEH_Template::display_template(
2884
-            $template_path,
2885
-            $this->_template_args,
2886
-            true
2887
-        );
2888
-        // the final template wrapper
2889
-        $this->admin_page_wrapper($about);
2890
-    }
2891
-
2892
-
2893
-    /**
2894
-     * This is used to display caf preview pages.
2895
-     *
2896
-     * @param string $utm_campaign_source what is the key used for google analytics link
2897
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2898
-     *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2899
-     * @return void
2900
-     * @throws DomainException
2901
-     * @throws EE_Error
2902
-     * @throws InvalidArgumentException
2903
-     * @throws InvalidDataTypeException
2904
-     * @throws InvalidInterfaceException
2905
-     * @since 4.3.2
2906
-     */
2907
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2908
-    {
2909
-        // let's generate a default preview action button if there isn't one already present.
2910
-        $this->_labels['buttons']['buy_now']           = esc_html__(
2911
-            'Upgrade to Event Espresso 4 Right Now',
2912
-            'event_espresso'
2913
-        );
2914
-        $buy_now_url                                   = add_query_arg(
2915
-            [
2916
-                'ee_ver'       => 'ee4',
2917
-                'utm_source'   => 'ee4_plugin_admin',
2918
-                'utm_medium'   => 'link',
2919
-                'utm_campaign' => $utm_campaign_source,
2920
-                'utm_content'  => 'buy_now_button',
2921
-            ],
2922
-            'http://eventespresso.com/pricing/'
2923
-        );
2924
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2925
-            ? $this->get_action_link_or_button(
2926
-                '',
2927
-                'buy_now',
2928
-                [],
2929
-                'button-primary button-large',
2930
-                $buy_now_url,
2931
-                true
2932
-            )
2933
-            : $this->_template_args['preview_action_button'];
2934
-        $this->_template_args['admin_page_content']    = EEH_Template::display_template(
2935
-            EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2936
-            $this->_template_args,
2937
-            true
2938
-        );
2939
-        $this->_display_admin_page($display_sidebar);
2940
-    }
2941
-
2942
-
2943
-    /**
2944
-     * display_admin_list_table_page_with_sidebar
2945
-     * generates HTML wrapper for an admin_page with list_table
2946
-     *
2947
-     * @return void
2948
-     * @throws EE_Error
2949
-     * @throws DomainException
2950
-     */
2951
-    public function display_admin_list_table_page_with_sidebar()
2952
-    {
2953
-        $this->_display_admin_list_table_page(true);
2954
-    }
2955
-
2956
-
2957
-    /**
2958
-     * display_admin_list_table_page_with_no_sidebar
2959
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2960
-     *
2961
-     * @return void
2962
-     * @throws EE_Error
2963
-     * @throws DomainException
2964
-     */
2965
-    public function display_admin_list_table_page_with_no_sidebar()
2966
-    {
2967
-        $this->_display_admin_list_table_page();
2968
-    }
2969
-
2970
-
2971
-    /**
2972
-     * generates html wrapper for an admin_list_table page
2973
-     *
2974
-     * @param boolean $sidebar whether to display with sidebar or not.
2975
-     * @return void
2976
-     * @throws DomainException
2977
-     * @throws EE_Error
2978
-     */
2979
-    private function _display_admin_list_table_page($sidebar = false)
2980
-    {
2981
-        // setup search attributes
2982
-        $this->_set_search_attributes();
2983
-        $this->_template_args['current_page']     = $this->_wp_page_slug;
2984
-        $template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2985
-        $this->_template_args['table_url']        = defined('DOING_AJAX')
2986
-            ? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2987
-            : add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2988
-        $this->_template_args['list_table']       = $this->_list_table_object;
2989
-        $this->_template_args['current_route']    = $this->_req_action;
2990
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2991
-        $ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2992
-        if (! empty($ajax_sorting_callback)) {
2993
-            $sortable_list_table_form_fields = wp_nonce_field(
2994
-                $ajax_sorting_callback . '_nonce',
2995
-                $ajax_sorting_callback . '_nonce',
2996
-                false,
2997
-                false
2998
-            );
2999
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3000
-                                                . $this->page_slug
3001
-                                                . '" />';
3002
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3003
-                                                . $ajax_sorting_callback
3004
-                                                . '" />';
3005
-        } else {
3006
-            $sortable_list_table_form_fields = '';
3007
-        }
3008
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3009
-        $hidden_form_fields                                      =
3010
-            isset($this->_template_args['list_table_hidden_fields'])
3011
-                ? $this->_template_args['list_table_hidden_fields']
3012
-                : '';
3013
-        $nonce_ref                                               = $this->_req_action . '_nonce';
3014
-        $hidden_form_fields                                      .= '<input type="hidden" name="'
3015
-                                                                    . $nonce_ref
3016
-                                                                    . '" value="'
3017
-                                                                    . wp_create_nonce($nonce_ref)
3018
-                                                                    . '">';
3019
-        $this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3020
-        // display message about search results?
3021
-        $search = $this->request->getRequestParam('s');
3022
-        $this->_template_args['before_list_table'] .= ! empty($search)
3023
-            ? '<p class="ee-search-results">' . sprintf(
3024
-                esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3025
-                trim($search, '%')
3026
-            ) . '</p>'
3027
-            : '';
3028
-        // filter before_list_table template arg
3029
-        $this->_template_args['before_list_table'] = apply_filters(
3030
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3031
-            $this->_template_args['before_list_table'],
3032
-            $this->page_slug,
3033
-            $this->request->requestParams(),
3034
-            $this->_req_action
3035
-        );
3036
-        // convert to array and filter again
3037
-        // arrays are easier to inject new items in a specific location,
3038
-        // but would not be backwards compatible, so we have to add a new filter
3039
-        $this->_template_args['before_list_table'] = implode(
3040
-            " \n",
3041
-            (array) apply_filters(
3042
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3043
-                (array) $this->_template_args['before_list_table'],
3044
-                $this->page_slug,
3045
-                $this->request->requestParams(),
3046
-                $this->_req_action
3047
-            )
3048
-        );
3049
-        // filter after_list_table template arg
3050
-        $this->_template_args['after_list_table'] = apply_filters(
3051
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3052
-            $this->_template_args['after_list_table'],
3053
-            $this->page_slug,
3054
-            $this->request->requestParams(),
3055
-            $this->_req_action
3056
-        );
3057
-        // convert to array and filter again
3058
-        // arrays are easier to inject new items in a specific location,
3059
-        // but would not be backwards compatible, so we have to add a new filter
3060
-        $this->_template_args['after_list_table']   = implode(
3061
-            " \n",
3062
-            (array) apply_filters(
3063
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3064
-                (array) $this->_template_args['after_list_table'],
3065
-                $this->page_slug,
3066
-                $this->request->requestParams(),
3067
-                $this->_req_action
3068
-            )
3069
-        );
3070
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3071
-            $template_path,
3072
-            $this->_template_args,
3073
-            true
3074
-        );
3075
-        // the final template wrapper
3076
-        if ($sidebar) {
3077
-            $this->display_admin_page_with_sidebar();
3078
-        } else {
3079
-            $this->display_admin_page_with_no_sidebar();
3080
-        }
3081
-    }
3082
-
3083
-
3084
-    /**
3085
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3086
-     * html string for the legend.
3087
-     * $items are expected in an array in the following format:
3088
-     * $legend_items = array(
3089
-     *        'item_id' => array(
3090
-     *            'icon' => 'http://url_to_icon_being_described.png',
3091
-     *            'desc' => esc_html__('localized description of item');
3092
-     *        )
3093
-     * );
3094
-     *
3095
-     * @param array $items see above for format of array
3096
-     * @return string html string of legend
3097
-     * @throws DomainException
3098
-     */
3099
-    protected function _display_legend($items)
3100
-    {
3101
-        $this->_template_args['items'] = apply_filters(
3102
-            'FHEE__EE_Admin_Page___display_legend__items',
3103
-            (array) $items,
3104
-            $this
3105
-        );
3106
-        return EEH_Template::display_template(
3107
-            EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3108
-            $this->_template_args,
3109
-            true
3110
-        );
3111
-    }
3112
-
3113
-
3114
-    /**
3115
-     * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3116
-     * The returned json object is created from an array in the following format:
3117
-     * array(
3118
-     *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3119
-     *  'success' => FALSE, //(default FALSE) - contains any special success message.
3120
-     *  'notices' => '', // - contains any EE_Error formatted notices
3121
-     *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3122
-     *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3123
-     *  We're also going to include the template args with every package (so js can pick out any specific template args
3124
-     *  that might be included in here)
3125
-     * )
3126
-     * The json object is populated by whatever is set in the $_template_args property.
3127
-     *
3128
-     * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3129
-     *                                 instead of displayed.
3130
-     * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3131
-     * @return void
3132
-     * @throws EE_Error
3133
-     */
3134
-    protected function _return_json($sticky_notices = false, $notices_arguments = [])
3135
-    {
3136
-        // make sure any EE_Error notices have been handled.
3137
-        $this->_process_notices($notices_arguments, true, $sticky_notices);
3138
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3139
-        unset($this->_template_args['data']);
3140
-        $json = [
3141
-            'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3142
-            'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3143
-            'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3144
-            'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3145
-            'notices'   => EE_Error::get_notices(),
3146
-            'content'   => isset($this->_template_args['admin_page_content'])
3147
-                ? $this->_template_args['admin_page_content'] : '',
3148
-            'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3149
-            'isEEajax'  => true
3150
-            // special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3151
-        ];
3152
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
3153
-        if (null === error_get_last() || ! headers_sent()) {
3154
-            header('Content-Type: application/json; charset=UTF-8');
3155
-        }
3156
-        echo wp_json_encode($json);
3157
-        exit();
3158
-    }
3159
-
3160
-
3161
-    /**
3162
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3163
-     *
3164
-     * @return void
3165
-     * @throws EE_Error
3166
-     */
3167
-    public function return_json()
3168
-    {
3169
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3170
-            $this->_return_json();
3171
-        } else {
3172
-            throw new EE_Error(
3173
-                sprintf(
3174
-                    esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3175
-                    __FUNCTION__
3176
-                )
3177
-            );
3178
-        }
3179
-    }
3180
-
3181
-
3182
-    /**
3183
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3184
-     * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3185
-     *
3186
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3187
-     */
3188
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
3189
-    {
3190
-        $this->_hook_obj = $hook_obj;
3191
-    }
3192
-
3193
-
3194
-    /**
3195
-     *        generates  HTML wrapper with Tabbed nav for an admin page
3196
-     *
3197
-     * @param boolean $about whether to use the special about page wrapper or default.
3198
-     * @return void
3199
-     * @throws DomainException
3200
-     * @throws EE_Error
3201
-     */
3202
-    public function admin_page_wrapper($about = false)
3203
-    {
3204
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3205
-        $this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3206
-        $this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3207
-        $this->_template_args['admin_page_title']          = $this->_admin_page_title;
3208
-        $this->_template_args['before_admin_page_content'] = apply_filters(
3209
-            "FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3210
-            isset($this->_template_args['before_admin_page_content'])
3211
-                ? $this->_template_args['before_admin_page_content']
3212
-                : ''
3213
-        );
3214
-        $this->_template_args['after_admin_page_content']  = apply_filters(
3215
-            "FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3216
-            isset($this->_template_args['after_admin_page_content'])
3217
-                ? $this->_template_args['after_admin_page_content']
3218
-                : ''
3219
-        );
3220
-        $this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3221
-        // load settings page wrapper template
3222
-        $template_path = ! defined('DOING_AJAX')
3223
-            ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3224
-            : EE_ADMIN_TEMPLATE
3225
-              . 'admin_wrapper_ajax.template.php';
3226
-        // about page?
3227
-        $template_path = $about
3228
-            ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3229
-            : $template_path;
3230
-        if (defined('DOING_AJAX')) {
3231
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template(
3232
-                $template_path,
3233
-                $this->_template_args,
3234
-                true
3235
-            );
3236
-            $this->_return_json();
3237
-        } else {
3238
-            EEH_Template::display_template($template_path, $this->_template_args);
3239
-        }
3240
-    }
3241
-
3242
-
3243
-    /**
3244
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3245
-     *
3246
-     * @return string html
3247
-     * @throws EE_Error
3248
-     */
3249
-    protected function _get_main_nav_tabs()
3250
-    {
3251
-        // let's generate the html using the EEH_Tabbed_Content helper.
3252
-        // We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3253
-        // (rather than setting in the page_routes array)
3254
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3255
-    }
3256
-
3257
-
3258
-    /**
3259
-     *        sort nav tabs
3260
-     *
3261
-     * @param $a
3262
-     * @param $b
3263
-     * @return int
3264
-     */
3265
-    private function _sort_nav_tabs($a, $b)
3266
-    {
3267
-        if ($a['order'] === $b['order']) {
3268
-            return 0;
3269
-        }
3270
-        return ($a['order'] < $b['order']) ? -1 : 1;
3271
-    }
3272
-
3273
-
3274
-    /**
3275
-     *    generates HTML for the forms used on admin pages
3276
-     *
3277
-     * @param array  $input_vars   - array of input field details
3278
-     * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3279
-     *                             use)
3280
-     * @param bool   $id
3281
-     * @return string
3282
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3283
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3284
-     */
3285
-    protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3286
-    {
3287
-        $content = $generator === 'string'
3288
-            ? EEH_Form_Fields::get_form_fields($input_vars, $id)
3289
-            : EEH_Form_Fields::get_form_fields_array($input_vars);
3290
-        return $content;
3291
-    }
3292
-
3293
-
3294
-    /**
3295
-     * generates the "Save" and "Save & Close" buttons for edit forms
3296
-     *
3297
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3298
-     *                                   Close" button.
3299
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3300
-     *                                   'Save', [1] => 'save & close')
3301
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3302
-     *                                   via the "name" value in the button).  We can also use this to just dump
3303
-     *                                   default actions by submitting some other value.
3304
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3305
-     *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3306
-     *                                   close (normal form handling).
3307
-     */
3308
-    protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3309
-    {
3310
-        // make sure $text and $actions are in an array
3311
-        $text          = (array) $text;
3312
-        $actions       = (array) $actions;
3313
-        $referrer_url  = empty($referrer)
3314
-            ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3315
-              . $this->request->getServerParam('REQUEST_URI')
3316
-              . '" />'
3317
-            : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3318
-              . $referrer
3319
-              . '" />';
3320
-        $button_text   = ! empty($text)
3321
-            ? $text
3322
-            : [
3323
-                esc_html__('Save', 'event_espresso'),
3324
-                esc_html__('Save and Close', 'event_espresso'),
3325
-            ];
3326
-        $default_names = ['save', 'save_and_close'];
3327
-        // add in a hidden index for the current page (so save and close redirects properly)
3328
-        $this->_template_args['save_buttons'] = $referrer_url;
3329
-        foreach ($button_text as $key => $button) {
3330
-            $ref                                  = $default_names[ $key ];
3331
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3332
-                                                     . $ref
3333
-                                                     . '" value="'
3334
-                                                     . $button
3335
-                                                     . '" name="'
3336
-                                                     . (! empty($actions) ? $actions[ $key ] : $ref)
3337
-                                                     . '" id="'
3338
-                                                     . $this->_current_view . '_' . $ref
3339
-                                                     . '" />';
3340
-            if (! $both) {
3341
-                break;
3342
-            }
3343
-        }
3344
-    }
3345
-
3346
-
3347
-    /**
3348
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3349
-     *
3350
-     * @param string $route
3351
-     * @param array  $additional_hidden_fields
3352
-     * @see   $this->_set_add_edit_form_tags() for details on params
3353
-     * @since 4.6.0
3354
-     */
3355
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3356
-    {
3357
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3358
-    }
3359
-
3360
-
3361
-    /**
3362
-     * set form open and close tags on add/edit pages.
3363
-     *
3364
-     * @param string $route                    the route you want the form to direct to
3365
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3366
-     * @return void
3367
-     */
3368
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3369
-    {
3370
-        if (empty($route)) {
3371
-            $user_msg = esc_html__(
3372
-                'An error occurred. No action was set for this page\'s form.',
3373
-                'event_espresso'
3374
-            );
3375
-            $dev_msg  = $user_msg . "\n"
3376
-                        . sprintf(
3377
-                            esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3378
-                            __FUNCTION__,
3379
-                            __CLASS__
3380
-                        );
3381
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3382
-        }
3383
-        // open form
3384
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3385
-                                                             . $this->_admin_base_url
3386
-                                                             . '" id="'
3387
-                                                             . $route
3388
-                                                             . '_event_form" >';
3389
-        // add nonce
3390
-        $nonce                                             =
3391
-            wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3392
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3393
-        // add REQUIRED form action
3394
-        $hidden_fields = [
3395
-            'action' => ['type' => 'hidden', 'value' => $route],
3396
-        ];
3397
-        // merge arrays
3398
-        $hidden_fields = is_array($additional_hidden_fields)
3399
-            ? array_merge($hidden_fields, $additional_hidden_fields)
3400
-            : $hidden_fields;
3401
-        // generate form fields
3402
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3403
-        // add fields to form
3404
-        foreach ((array) $form_fields as $field_name => $form_field) {
3405
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3406
-        }
3407
-        // close form
3408
-        $this->_template_args['after_admin_page_content'] = '</form>';
3409
-    }
3410
-
3411
-
3412
-    /**
3413
-     * Public Wrapper for _redirect_after_action() method since its
3414
-     * discovered it would be useful for external code to have access.
3415
-     *
3416
-     * @param bool   $success
3417
-     * @param string $what
3418
-     * @param string $action_desc
3419
-     * @param array  $query_args
3420
-     * @param bool   $override_overwrite
3421
-     * @throws EE_Error
3422
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
3423
-     * @since 4.5.0
3424
-     */
3425
-    public function redirect_after_action(
3426
-        $success = false,
3427
-        $what = 'item',
3428
-        $action_desc = 'processed',
3429
-        $query_args = [],
3430
-        $override_overwrite = false
3431
-    ) {
3432
-        $this->_redirect_after_action(
3433
-            $success,
3434
-            $what,
3435
-            $action_desc,
3436
-            $query_args,
3437
-            $override_overwrite
3438
-        );
3439
-    }
3440
-
3441
-
3442
-    /**
3443
-     * Helper method for merging existing request data with the returned redirect url.
3444
-     *
3445
-     * This is typically used for redirects after an action so that if the original view was a filtered view those
3446
-     * filters are still applied.
3447
-     *
3448
-     * @param array $new_route_data
3449
-     * @return array
3450
-     */
3451
-    protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3452
-    {
3453
-        foreach ($this->request->requestParams() as $ref => $value) {
3454
-            // unset nonces
3455
-            if (strpos($ref, 'nonce') !== false) {
3456
-                $this->request->unSetRequestParam($ref);
3457
-                continue;
3458
-            }
3459
-            // urlencode values.
3460
-            $value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3461
-            $this->request->setRequestParam($ref, $value);
3462
-        }
3463
-        return array_merge($this->request->requestParams(), $new_route_data);
3464
-    }
3465
-
3466
-
3467
-    /**
3468
-     *    _redirect_after_action
3469
-     *
3470
-     * @param int    $success            - whether success was for two or more records, or just one, or none
3471
-     * @param string $what               - what the action was performed on
3472
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
3473
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3474
-     *                                   action is completed
3475
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3476
-     *                                   override this so that they show.
3477
-     * @return void
3478
-     * @throws EE_Error
3479
-     */
3480
-    protected function _redirect_after_action(
3481
-        $success = 0,
3482
-        $what = 'item',
3483
-        $action_desc = 'processed',
3484
-        $query_args = [],
3485
-        $override_overwrite = false
3486
-    ) {
3487
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3488
-        // class name for actions/filters.
3489
-        $classname = get_class($this);
3490
-        // set redirect url.
3491
-        // Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3492
-        // otherwise we go with whatever is set as the _admin_base_url
3493
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3494
-        $notices      = EE_Error::get_notices(false);
3495
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
3496
-        if (! $override_overwrite || ! empty($notices['errors'])) {
3497
-            EE_Error::overwrite_success();
3498
-        }
3499
-        if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3500
-            // how many records affected ? more than one record ? or just one ?
3501
-            if ($success > 1) {
3502
-                // set plural msg
3503
-                EE_Error::add_success(
3504
-                    sprintf(
3505
-                        esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3506
-                        $what,
3507
-                        $action_desc
3508
-                    ),
3509
-                    __FILE__,
3510
-                    __FUNCTION__,
3511
-                    __LINE__
3512
-                );
3513
-            } elseif ($success === 1) {
3514
-                // set singular msg
3515
-                EE_Error::add_success(
3516
-                    sprintf(
3517
-                        esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3518
-                        $what,
3519
-                        $action_desc
3520
-                    ),
3521
-                    __FILE__,
3522
-                    __FUNCTION__,
3523
-                    __LINE__
3524
-                );
3525
-            }
3526
-        }
3527
-        // check that $query_args isn't something crazy
3528
-        if (! is_array($query_args)) {
3529
-            $query_args = [];
3530
-        }
3531
-        /**
3532
-         * Allow injecting actions before the query_args are modified for possible different
3533
-         * redirections on save and close actions
3534
-         *
3535
-         * @param array $query_args       The original query_args array coming into the
3536
-         *                                method.
3537
-         * @since 4.2.0
3538
-         */
3539
-        do_action(
3540
-            "AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3541
-            $query_args
3542
-        );
3543
-        // calculate where we're going (if we have a "save and close" button pushed)
3544
-
3545
-        if (
3546
-            $this->request->requestParamIsSet('save_and_close')
3547
-            && $this->request->requestParamIsSet('save_and_close_referrer')
3548
-        ) {
3549
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3550
-            $parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3551
-            // regenerate query args array from referrer URL
3552
-            parse_str($parsed_url['query'], $query_args);
3553
-            // correct page and action will be in the query args now
3554
-            $redirect_url = admin_url('admin.php');
3555
-        }
3556
-        // merge any default query_args set in _default_route_query_args property
3557
-        if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3558
-            $args_to_merge = [];
3559
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
3560
-                // is there a wp_referer array in our _default_route_query_args property?
3561
-                if ($query_param === 'wp_referer') {
3562
-                    $query_value = (array) $query_value;
3563
-                    foreach ($query_value as $reference => $value) {
3564
-                        if (strpos($reference, 'nonce') !== false) {
3565
-                            continue;
3566
-                        }
3567
-                        // finally we will override any arguments in the referer with
3568
-                        // what might be set on the _default_route_query_args array.
3569
-                        if (isset($this->_default_route_query_args[ $reference ])) {
3570
-                            $args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3571
-                        } else {
3572
-                            $args_to_merge[ $reference ] = urlencode($value);
3573
-                        }
3574
-                    }
3575
-                    continue;
3576
-                }
3577
-                $args_to_merge[ $query_param ] = $query_value;
3578
-            }
3579
-            // now let's merge these arguments but override with what was specifically sent in to the
3580
-            // redirect.
3581
-            $query_args = array_merge($args_to_merge, $query_args);
3582
-        }
3583
-        $this->_process_notices($query_args);
3584
-        // generate redirect url
3585
-        // if redirecting to anything other than the main page, add a nonce
3586
-        if (isset($query_args['action'])) {
3587
-            // manually generate wp_nonce and merge that with the query vars
3588
-            // becuz the wp_nonce_url function wrecks havoc on some vars
3589
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3590
-        }
3591
-        // we're adding some hooks and filters in here for processing any things just before redirects
3592
-        // (example: an admin page has done an insert or update and we want to run something after that).
3593
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3594
-        $redirect_url = apply_filters(
3595
-            'FHEE_redirect_' . $classname . $this->_req_action,
3596
-            self::add_query_args_and_nonce($query_args, $redirect_url),
3597
-            $query_args
3598
-        );
3599
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3600
-        if (defined('DOING_AJAX')) {
3601
-            $default_data                    = [
3602
-                'close'        => true,
3603
-                'redirect_url' => $redirect_url,
3604
-                'where'        => 'main',
3605
-                'what'         => 'append',
3606
-            ];
3607
-            $this->_template_args['success'] = $success;
3608
-            $this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3609
-                $default_data,
3610
-                $this->_template_args['data']
3611
-            ) : $default_data;
3612
-            $this->_return_json();
3613
-        }
3614
-        wp_safe_redirect($redirect_url);
3615
-        exit();
3616
-    }
3617
-
3618
-
3619
-    /**
3620
-     * process any notices before redirecting (or returning ajax request)
3621
-     * This method sets the $this->_template_args['notices'] attribute;
3622
-     *
3623
-     * @param array $query_args         any query args that need to be used for notice transient ('action')
3624
-     * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3625
-     *                                  page_routes haven't been defined yet.
3626
-     * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3627
-     *                                  still save a transient for the notice.
3628
-     * @return void
3629
-     * @throws EE_Error
3630
-     */
3631
-    protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3632
-    {
3633
-        // first let's set individual error properties if doing_ajax and the properties aren't already set.
3634
-        if (defined('DOING_AJAX') && DOING_AJAX) {
3635
-            $notices = EE_Error::get_notices(false);
3636
-            if (empty($this->_template_args['success'])) {
3637
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3638
-            }
3639
-            if (empty($this->_template_args['errors'])) {
3640
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3641
-            }
3642
-            if (empty($this->_template_args['attention'])) {
3643
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3644
-            }
3645
-        }
3646
-        $this->_template_args['notices'] = EE_Error::get_notices();
3647
-        // IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3648
-        if (! defined('DOING_AJAX') || $sticky_notices) {
3649
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
3650
-            $this->_add_transient(
3651
-                $route,
3652
-                $this->_template_args['notices'],
3653
-                true,
3654
-                $skip_route_verify
3655
-            );
3656
-        }
3657
-    }
3658
-
3659
-
3660
-    /**
3661
-     * get_action_link_or_button
3662
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
3663
-     *
3664
-     * @param string $action        use this to indicate which action the url is generated with.
3665
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3666
-     *                              property.
3667
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3668
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3669
-     * @param string $base_url      If this is not provided
3670
-     *                              the _admin_base_url will be used as the default for the button base_url.
3671
-     *                              Otherwise this value will be used.
3672
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3673
-     * @return string
3674
-     * @throws InvalidArgumentException
3675
-     * @throws InvalidInterfaceException
3676
-     * @throws InvalidDataTypeException
3677
-     * @throws EE_Error
3678
-     */
3679
-    public function get_action_link_or_button(
3680
-        $action,
3681
-        $type = 'add',
3682
-        $extra_request = [],
3683
-        $class = 'button-primary',
3684
-        $base_url = '',
3685
-        $exclude_nonce = false
3686
-    ) {
3687
-        // first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3688
-        if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3689
-            throw new EE_Error(
3690
-                sprintf(
3691
-                    esc_html__(
3692
-                        'There is no page route for given action for the button.  This action was given: %s',
3693
-                        'event_espresso'
3694
-                    ),
3695
-                    $action
3696
-                )
3697
-            );
3698
-        }
3699
-        if (! isset($this->_labels['buttons'][ $type ])) {
3700
-            throw new EE_Error(
3701
-                sprintf(
3702
-                    esc_html__(
3703
-                        'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3704
-                        'event_espresso'
3705
-                    ),
3706
-                    $type
3707
-                )
3708
-            );
3709
-        }
3710
-        // finally check user access for this button.
3711
-        $has_access = $this->check_user_access($action, true);
3712
-        if (! $has_access) {
3713
-            return '';
3714
-        }
3715
-        $_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3716
-        $query_args = [
3717
-            'action' => $action,
3718
-        ];
3719
-        // merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3720
-        if (! empty($extra_request)) {
3721
-            $query_args = array_merge($extra_request, $query_args);
3722
-        }
3723
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3724
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3725
-    }
3726
-
3727
-
3728
-    /**
3729
-     * _per_page_screen_option
3730
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3731
-     *
3732
-     * @return void
3733
-     * @throws InvalidArgumentException
3734
-     * @throws InvalidInterfaceException
3735
-     * @throws InvalidDataTypeException
3736
-     */
3737
-    protected function _per_page_screen_option()
3738
-    {
3739
-        $option = 'per_page';
3740
-        $args   = [
3741
-            'label'   => apply_filters(
3742
-                'FHEE__EE_Admin_Page___per_page_screen_options___label',
3743
-                $this->_admin_page_title,
3744
-                $this
3745
-            ),
3746
-            'default' => (int) apply_filters(
3747
-                'FHEE__EE_Admin_Page___per_page_screen_options__default',
3748
-                20
3749
-            ),
3750
-            'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3751
-        ];
3752
-        // ONLY add the screen option if the user has access to it.
3753
-        if ($this->check_user_access($this->_current_view, true)) {
3754
-            add_screen_option($option, $args);
3755
-        }
3756
-    }
3757
-
3758
-
3759
-    /**
3760
-     * set_per_page_screen_option
3761
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3762
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3763
-     * admin_menu.
3764
-     *
3765
-     * @return void
3766
-     */
3767
-    private function _set_per_page_screen_options()
3768
-    {
3769
-        if ($this->request->requestParamIsSet('wp_screen_options')) {
3770
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3771
-            if (! $user = wp_get_current_user()) {
3772
-                return;
3773
-            }
3774
-            $option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3775
-            if (! $option) {
3776
-                return;
3777
-            }
3778
-            $value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3779
-            $map_option = $option;
3780
-            $option     = str_replace('-', '_', $option);
3781
-            switch ($map_option) {
3782
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3783
-                    $max_value = apply_filters(
3784
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3785
-                        999,
3786
-                        $this->_current_page,
3787
-                        $this->_current_view
3788
-                    );
3789
-                    if ($value < 1) {
3790
-                        return;
3791
-                    }
3792
-                    $value = min($value, $max_value);
3793
-                    break;
3794
-                default:
3795
-                    $value = apply_filters(
3796
-                        'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3797
-                        false,
3798
-                        $option,
3799
-                        $value
3800
-                    );
3801
-                    if (false === $value) {
3802
-                        return;
3803
-                    }
3804
-                    break;
3805
-            }
3806
-            update_user_meta($user->ID, $option, $value);
3807
-            wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3808
-            exit;
3809
-        }
3810
-    }
3811
-
3812
-
3813
-    /**
3814
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3815
-     *
3816
-     * @param array $data array that will be assigned to template args.
3817
-     */
3818
-    public function set_template_args($data)
3819
-    {
3820
-        $this->_template_args = array_merge($this->_template_args, (array) $data);
3821
-    }
3822
-
3823
-
3824
-    /**
3825
-     * This makes available the WP transient system for temporarily moving data between routes
3826
-     *
3827
-     * @param string $route             the route that should receive the transient
3828
-     * @param array  $data              the data that gets sent
3829
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3830
-     *                                  normal route transient.
3831
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3832
-     *                                  when we are adding a transient before page_routes have been defined.
3833
-     * @return void
3834
-     * @throws EE_Error
3835
-     */
3836
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3837
-    {
3838
-        $user_id = get_current_user_id();
3839
-        if (! $skip_route_verify) {
3840
-            $this->_verify_route($route);
3841
-        }
3842
-        // now let's set the string for what kind of transient we're setting
3843
-        $transient = $notices
3844
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3845
-            : 'rte_tx_' . $route . '_' . $user_id;
3846
-        $data      = $notices ? ['notices' => $data] : $data;
3847
-        // is there already a transient for this route?  If there is then let's ADD to that transient
3848
-        $existing = is_multisite() && is_network_admin()
3849
-            ? get_site_transient($transient)
3850
-            : get_transient($transient);
3851
-        if ($existing) {
3852
-            $data = array_merge((array) $data, (array) $existing);
3853
-        }
3854
-        if (is_multisite() && is_network_admin()) {
3855
-            set_site_transient($transient, $data, 8);
3856
-        } else {
3857
-            set_transient($transient, $data, 8);
3858
-        }
3859
-    }
3860
-
3861
-
3862
-    /**
3863
-     * this retrieves the temporary transient that has been set for moving data between routes.
3864
-     *
3865
-     * @param bool   $notices true we get notices transient. False we just return normal route transient
3866
-     * @param string $route
3867
-     * @return mixed data
3868
-     */
3869
-    protected function _get_transient($notices = false, $route = '')
3870
-    {
3871
-        $user_id   = get_current_user_id();
3872
-        $route     = ! $route ? $this->_req_action : $route;
3873
-        $transient = $notices
3874
-            ? 'ee_rte_n_tx_' . $route . '_' . $user_id
3875
-            : 'rte_tx_' . $route . '_' . $user_id;
3876
-        $data      = is_multisite() && is_network_admin()
3877
-            ? get_site_transient($transient)
3878
-            : get_transient($transient);
3879
-        // delete transient after retrieval (just in case it hasn't expired);
3880
-        if (is_multisite() && is_network_admin()) {
3881
-            delete_site_transient($transient);
3882
-        } else {
3883
-            delete_transient($transient);
3884
-        }
3885
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3886
-    }
3887
-
3888
-
3889
-    /**
3890
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3891
-     * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3892
-     * default route callback on the EE_Admin page you want it run.)
3893
-     *
3894
-     * @return void
3895
-     */
3896
-    protected function _transient_garbage_collection()
3897
-    {
3898
-        global $wpdb;
3899
-        // retrieve all existing transients
3900
-        $query =
3901
-            "SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3902
-        if ($results = $wpdb->get_results($query)) {
3903
-            foreach ($results as $result) {
3904
-                $transient = str_replace('_transient_', '', $result->option_name);
3905
-                get_transient($transient);
3906
-                if (is_multisite() && is_network_admin()) {
3907
-                    get_site_transient($transient);
3908
-                }
3909
-            }
3910
-        }
3911
-    }
3912
-
3913
-
3914
-    /**
3915
-     * get_view
3916
-     *
3917
-     * @return string content of _view property
3918
-     */
3919
-    public function get_view()
3920
-    {
3921
-        return $this->_view;
3922
-    }
3923
-
3924
-
3925
-    /**
3926
-     * getter for the protected $_views property
3927
-     *
3928
-     * @return array
3929
-     */
3930
-    public function get_views()
3931
-    {
3932
-        return $this->_views;
3933
-    }
3934
-
3935
-
3936
-    /**
3937
-     * get_current_page
3938
-     *
3939
-     * @return string _current_page property value
3940
-     */
3941
-    public function get_current_page()
3942
-    {
3943
-        return $this->_current_page;
3944
-    }
3945
-
3946
-
3947
-    /**
3948
-     * get_current_view
3949
-     *
3950
-     * @return string _current_view property value
3951
-     */
3952
-    public function get_current_view()
3953
-    {
3954
-        return $this->_current_view;
3955
-    }
3956
-
3957
-
3958
-    /**
3959
-     * get_current_screen
3960
-     *
3961
-     * @return object The current WP_Screen object
3962
-     */
3963
-    public function get_current_screen()
3964
-    {
3965
-        return $this->_current_screen;
3966
-    }
3967
-
3968
-
3969
-    /**
3970
-     * get_current_page_view_url
3971
-     *
3972
-     * @return string This returns the url for the current_page_view.
3973
-     */
3974
-    public function get_current_page_view_url()
3975
-    {
3976
-        return $this->_current_page_view_url;
3977
-    }
3978
-
3979
-
3980
-    /**
3981
-     * just returns the Request
3982
-     *
3983
-     * @return RequestInterface
3984
-     */
3985
-    public function get_request()
3986
-    {
3987
-        return $this->request;
3988
-    }
3989
-
3990
-
3991
-    /**
3992
-     * just returns the _req_data property
3993
-     *
3994
-     * @return array
3995
-     */
3996
-    public function get_request_data()
3997
-    {
3998
-        return $this->request->requestParams();
3999
-    }
4000
-
4001
-
4002
-    /**
4003
-     * returns the _req_data protected property
4004
-     *
4005
-     * @return string
4006
-     */
4007
-    public function get_req_action()
4008
-    {
4009
-        return $this->_req_action;
4010
-    }
4011
-
4012
-
4013
-    /**
4014
-     * @return bool  value of $_is_caf property
4015
-     */
4016
-    public function is_caf()
4017
-    {
4018
-        return $this->_is_caf;
4019
-    }
4020
-
4021
-
4022
-    /**
4023
-     * @return mixed
4024
-     */
4025
-    public function default_espresso_metaboxes()
4026
-    {
4027
-        return $this->_default_espresso_metaboxes;
4028
-    }
4029
-
4030
-
4031
-    /**
4032
-     * @return mixed
4033
-     */
4034
-    public function admin_base_url()
4035
-    {
4036
-        return $this->_admin_base_url;
4037
-    }
4038
-
4039
-
4040
-    /**
4041
-     * @return mixed
4042
-     */
4043
-    public function wp_page_slug()
4044
-    {
4045
-        return $this->_wp_page_slug;
4046
-    }
4047
-
4048
-
4049
-    /**
4050
-     * updates  espresso configuration settings
4051
-     *
4052
-     * @param string                   $tab
4053
-     * @param EE_Config_Base|EE_Config $config
4054
-     * @param string                   $file file where error occurred
4055
-     * @param string                   $func function  where error occurred
4056
-     * @param string                   $line line no where error occurred
4057
-     * @return boolean
4058
-     */
4059
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4060
-    {
4061
-        // remove any options that are NOT going to be saved with the config settings.
4062
-        if (isset($config->core->ee_ueip_optin)) {
4063
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
4064
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4065
-            update_option('ee_ueip_has_notified', true);
4066
-        }
4067
-        // and save it (note we're also doing the network save here)
4068
-        $net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4069
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
4070
-        if ($config_saved && $net_saved) {
4071
-            EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4072
-            return true;
4073
-        }
4074
-        EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4075
-        return false;
4076
-    }
4077
-
4078
-
4079
-    /**
4080
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4081
-     *
4082
-     * @return array
4083
-     */
4084
-    public function get_yes_no_values()
4085
-    {
4086
-        return $this->_yes_no_values;
4087
-    }
4088
-
4089
-
4090
-    protected function _get_dir()
4091
-    {
4092
-        $reflector = new ReflectionClass(get_class($this));
4093
-        return dirname($reflector->getFileName());
4094
-    }
4095
-
4096
-
4097
-    /**
4098
-     * A helper for getting a "next link".
4099
-     *
4100
-     * @param string $url   The url to link to
4101
-     * @param string $class The class to use.
4102
-     * @return string
4103
-     */
4104
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4105
-    {
4106
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4107
-    }
4108
-
4109
-
4110
-    /**
4111
-     * A helper for getting a "previous link".
4112
-     *
4113
-     * @param string $url   The url to link to
4114
-     * @param string $class The class to use.
4115
-     * @return string
4116
-     */
4117
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4118
-    {
4119
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
4120
-    }
4121
-
4122
-
4123
-
4124
-
4125
-
4126
-
4127
-
4128
-    // below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4129
-
4130
-
4131
-    /**
4132
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4133
-     * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4134
-     * _req_data array.
4135
-     *
4136
-     * @return bool success/fail
4137
-     * @throws EE_Error
4138
-     * @throws InvalidArgumentException
4139
-     * @throws ReflectionException
4140
-     * @throws InvalidDataTypeException
4141
-     * @throws InvalidInterfaceException
4142
-     */
4143
-    protected function _process_resend_registration()
4144
-    {
4145
-        $this->_template_args['success'] = EED_Messages::process_resend($this->request->requestParams());
4146
-        do_action(
4147
-            'AHEE__EE_Admin_Page___process_resend_registration',
4148
-            $this->_template_args['success'],
4149
-            $this->request->requestParams()
4150
-        );
4151
-        return $this->_template_args['success'];
4152
-    }
4153
-
4154
-
4155
-    /**
4156
-     * This automatically processes any payment message notifications when manual payment has been applied.
4157
-     *
4158
-     * @param EE_Payment $payment
4159
-     * @return bool success/fail
4160
-     */
4161
-    protected function _process_payment_notification(EE_Payment $payment)
4162
-    {
4163
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4164
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4165
-        $this->_template_args['success'] = apply_filters(
4166
-            'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4167
-            false,
4168
-            $payment
4169
-        );
4170
-        return $this->_template_args['success'];
4171
-    }
2730
+	}
2731
+
2732
+
2733
+	/**
2734
+	 * facade for add_meta_box
2735
+	 *
2736
+	 * @param string  $action        where the metabox get's displayed
2737
+	 * @param string  $title         Title of Metabox (output in metabox header)
2738
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback
2739
+	 *                               instead of the one created in here.
2740
+	 * @param array   $callback_args an array of args supplied for the metabox
2741
+	 * @param string  $column        what metabox column
2742
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2743
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function
2744
+	 *                               created but just set our own callback for wp's add_meta_box.
2745
+	 * @throws DomainException
2746
+	 */
2747
+	public function _add_admin_page_meta_box(
2748
+		$action,
2749
+		$title,
2750
+		$callback,
2751
+		$callback_args,
2752
+		$column = 'normal',
2753
+		$priority = 'high',
2754
+		$create_func = true
2755
+	) {
2756
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2757
+		// if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2758
+		if (empty($callback_args) && $create_func) {
2759
+			$callback_args = [
2760
+				'template_path' => $this->_template_path,
2761
+				'template_args' => $this->_template_args,
2762
+			];
2763
+		}
2764
+		// if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2765
+		$call_back_func = $create_func
2766
+			? function ($post, $metabox) {
2767
+				do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2768
+				echo EEH_Template::display_template(
2769
+					$metabox['args']['template_path'],
2770
+					$metabox['args']['template_args'],
2771
+					true
2772
+				);
2773
+			}
2774
+			: $callback;
2775
+		add_meta_box(
2776
+			str_replace('_', '-', $action) . '-mbox',
2777
+			$title,
2778
+			$call_back_func,
2779
+			$this->_wp_page_slug,
2780
+			$column,
2781
+			$priority,
2782
+			$callback_args
2783
+		);
2784
+	}
2785
+
2786
+
2787
+	/**
2788
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2789
+	 *
2790
+	 * @throws DomainException
2791
+	 * @throws EE_Error
2792
+	 */
2793
+	public function display_admin_page_with_metabox_columns()
2794
+	{
2795
+		$this->_template_args['post_body_content']  = $this->_template_args['admin_page_content'];
2796
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2797
+			$this->_column_template_path,
2798
+			$this->_template_args,
2799
+			true
2800
+		);
2801
+		// the final wrapper
2802
+		$this->admin_page_wrapper();
2803
+	}
2804
+
2805
+
2806
+	/**
2807
+	 * generates  HTML wrapper for an admin details page
2808
+	 *
2809
+	 * @return void
2810
+	 * @throws EE_Error
2811
+	 * @throws DomainException
2812
+	 */
2813
+	public function display_admin_page_with_sidebar()
2814
+	{
2815
+		$this->_display_admin_page(true);
2816
+	}
2817
+
2818
+
2819
+	/**
2820
+	 * generates  HTML wrapper for an admin details page (except no sidebar)
2821
+	 *
2822
+	 * @return void
2823
+	 * @throws EE_Error
2824
+	 * @throws DomainException
2825
+	 */
2826
+	public function display_admin_page_with_no_sidebar()
2827
+	{
2828
+		$this->_display_admin_page();
2829
+	}
2830
+
2831
+
2832
+	/**
2833
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2834
+	 *
2835
+	 * @return void
2836
+	 * @throws EE_Error
2837
+	 * @throws DomainException
2838
+	 */
2839
+	public function display_about_admin_page()
2840
+	{
2841
+		$this->_display_admin_page(false, true);
2842
+	}
2843
+
2844
+
2845
+	/**
2846
+	 * display_admin_page
2847
+	 * contains the code for actually displaying an admin page
2848
+	 *
2849
+	 * @param boolean $sidebar true with sidebar, false without
2850
+	 * @param boolean $about   use the about admin wrapper instead of the default.
2851
+	 * @return void
2852
+	 * @throws DomainException
2853
+	 * @throws EE_Error
2854
+	 */
2855
+	private function _display_admin_page($sidebar = false, $about = false)
2856
+	{
2857
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2858
+		// custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2859
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2860
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2861
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2862
+		$this->_template_args['current_page']              = $this->_wp_page_slug;
2863
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2864
+			? 'poststuff'
2865
+			: 'espresso-default-admin';
2866
+		$template_path                                     = $sidebar
2867
+			? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2868
+			: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2869
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2870
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2871
+		}
2872
+		$template_path                                     = ! empty($this->_column_template_path)
2873
+			? $this->_column_template_path : $template_path;
2874
+		$this->_template_args['post_body_content']         = isset($this->_template_args['admin_page_content'])
2875
+			? $this->_template_args['admin_page_content']
2876
+			: '';
2877
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content'])
2878
+			? $this->_template_args['before_admin_page_content']
2879
+			: '';
2880
+		$this->_template_args['after_admin_page_content']  = isset($this->_template_args['after_admin_page_content'])
2881
+			? $this->_template_args['after_admin_page_content']
2882
+			: '';
2883
+		$this->_template_args['admin_page_content']        = EEH_Template::display_template(
2884
+			$template_path,
2885
+			$this->_template_args,
2886
+			true
2887
+		);
2888
+		// the final template wrapper
2889
+		$this->admin_page_wrapper($about);
2890
+	}
2891
+
2892
+
2893
+	/**
2894
+	 * This is used to display caf preview pages.
2895
+	 *
2896
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2897
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE
2898
+	 *                                    = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2899
+	 * @return void
2900
+	 * @throws DomainException
2901
+	 * @throws EE_Error
2902
+	 * @throws InvalidArgumentException
2903
+	 * @throws InvalidDataTypeException
2904
+	 * @throws InvalidInterfaceException
2905
+	 * @since 4.3.2
2906
+	 */
2907
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2908
+	{
2909
+		// let's generate a default preview action button if there isn't one already present.
2910
+		$this->_labels['buttons']['buy_now']           = esc_html__(
2911
+			'Upgrade to Event Espresso 4 Right Now',
2912
+			'event_espresso'
2913
+		);
2914
+		$buy_now_url                                   = add_query_arg(
2915
+			[
2916
+				'ee_ver'       => 'ee4',
2917
+				'utm_source'   => 'ee4_plugin_admin',
2918
+				'utm_medium'   => 'link',
2919
+				'utm_campaign' => $utm_campaign_source,
2920
+				'utm_content'  => 'buy_now_button',
2921
+			],
2922
+			'http://eventespresso.com/pricing/'
2923
+		);
2924
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2925
+			? $this->get_action_link_or_button(
2926
+				'',
2927
+				'buy_now',
2928
+				[],
2929
+				'button-primary button-large',
2930
+				$buy_now_url,
2931
+				true
2932
+			)
2933
+			: $this->_template_args['preview_action_button'];
2934
+		$this->_template_args['admin_page_content']    = EEH_Template::display_template(
2935
+			EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php',
2936
+			$this->_template_args,
2937
+			true
2938
+		);
2939
+		$this->_display_admin_page($display_sidebar);
2940
+	}
2941
+
2942
+
2943
+	/**
2944
+	 * display_admin_list_table_page_with_sidebar
2945
+	 * generates HTML wrapper for an admin_page with list_table
2946
+	 *
2947
+	 * @return void
2948
+	 * @throws EE_Error
2949
+	 * @throws DomainException
2950
+	 */
2951
+	public function display_admin_list_table_page_with_sidebar()
2952
+	{
2953
+		$this->_display_admin_list_table_page(true);
2954
+	}
2955
+
2956
+
2957
+	/**
2958
+	 * display_admin_list_table_page_with_no_sidebar
2959
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2960
+	 *
2961
+	 * @return void
2962
+	 * @throws EE_Error
2963
+	 * @throws DomainException
2964
+	 */
2965
+	public function display_admin_list_table_page_with_no_sidebar()
2966
+	{
2967
+		$this->_display_admin_list_table_page();
2968
+	}
2969
+
2970
+
2971
+	/**
2972
+	 * generates html wrapper for an admin_list_table page
2973
+	 *
2974
+	 * @param boolean $sidebar whether to display with sidebar or not.
2975
+	 * @return void
2976
+	 * @throws DomainException
2977
+	 * @throws EE_Error
2978
+	 */
2979
+	private function _display_admin_list_table_page($sidebar = false)
2980
+	{
2981
+		// setup search attributes
2982
+		$this->_set_search_attributes();
2983
+		$this->_template_args['current_page']     = $this->_wp_page_slug;
2984
+		$template_path                            = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2985
+		$this->_template_args['table_url']        = defined('DOING_AJAX')
2986
+			? add_query_arg(['noheader' => 'true', 'route' => $this->_req_action], $this->_admin_base_url)
2987
+			: add_query_arg(['route' => $this->_req_action], $this->_admin_base_url);
2988
+		$this->_template_args['list_table']       = $this->_list_table_object;
2989
+		$this->_template_args['current_route']    = $this->_req_action;
2990
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2991
+		$ajax_sorting_callback                    = $this->_list_table_object->get_ajax_sorting_callback();
2992
+		if (! empty($ajax_sorting_callback)) {
2993
+			$sortable_list_table_form_fields = wp_nonce_field(
2994
+				$ajax_sorting_callback . '_nonce',
2995
+				$ajax_sorting_callback . '_nonce',
2996
+				false,
2997
+				false
2998
+			);
2999
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'
3000
+												. $this->page_slug
3001
+												. '" />';
3002
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'
3003
+												. $ajax_sorting_callback
3004
+												. '" />';
3005
+		} else {
3006
+			$sortable_list_table_form_fields = '';
3007
+		}
3008
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
3009
+		$hidden_form_fields                                      =
3010
+			isset($this->_template_args['list_table_hidden_fields'])
3011
+				? $this->_template_args['list_table_hidden_fields']
3012
+				: '';
3013
+		$nonce_ref                                               = $this->_req_action . '_nonce';
3014
+		$hidden_form_fields                                      .= '<input type="hidden" name="'
3015
+																	. $nonce_ref
3016
+																	. '" value="'
3017
+																	. wp_create_nonce($nonce_ref)
3018
+																	. '">';
3019
+		$this->_template_args['list_table_hidden_fields']        = $hidden_form_fields;
3020
+		// display message about search results?
3021
+		$search = $this->request->getRequestParam('s');
3022
+		$this->_template_args['before_list_table'] .= ! empty($search)
3023
+			? '<p class="ee-search-results">' . sprintf(
3024
+				esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
3025
+				trim($search, '%')
3026
+			) . '</p>'
3027
+			: '';
3028
+		// filter before_list_table template arg
3029
+		$this->_template_args['before_list_table'] = apply_filters(
3030
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
3031
+			$this->_template_args['before_list_table'],
3032
+			$this->page_slug,
3033
+			$this->request->requestParams(),
3034
+			$this->_req_action
3035
+		);
3036
+		// convert to array and filter again
3037
+		// arrays are easier to inject new items in a specific location,
3038
+		// but would not be backwards compatible, so we have to add a new filter
3039
+		$this->_template_args['before_list_table'] = implode(
3040
+			" \n",
3041
+			(array) apply_filters(
3042
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
3043
+				(array) $this->_template_args['before_list_table'],
3044
+				$this->page_slug,
3045
+				$this->request->requestParams(),
3046
+				$this->_req_action
3047
+			)
3048
+		);
3049
+		// filter after_list_table template arg
3050
+		$this->_template_args['after_list_table'] = apply_filters(
3051
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
3052
+			$this->_template_args['after_list_table'],
3053
+			$this->page_slug,
3054
+			$this->request->requestParams(),
3055
+			$this->_req_action
3056
+		);
3057
+		// convert to array and filter again
3058
+		// arrays are easier to inject new items in a specific location,
3059
+		// but would not be backwards compatible, so we have to add a new filter
3060
+		$this->_template_args['after_list_table']   = implode(
3061
+			" \n",
3062
+			(array) apply_filters(
3063
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
3064
+				(array) $this->_template_args['after_list_table'],
3065
+				$this->page_slug,
3066
+				$this->request->requestParams(),
3067
+				$this->_req_action
3068
+			)
3069
+		);
3070
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3071
+			$template_path,
3072
+			$this->_template_args,
3073
+			true
3074
+		);
3075
+		// the final template wrapper
3076
+		if ($sidebar) {
3077
+			$this->display_admin_page_with_sidebar();
3078
+		} else {
3079
+			$this->display_admin_page_with_no_sidebar();
3080
+		}
3081
+	}
3082
+
3083
+
3084
+	/**
3085
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the
3086
+	 * html string for the legend.
3087
+	 * $items are expected in an array in the following format:
3088
+	 * $legend_items = array(
3089
+	 *        'item_id' => array(
3090
+	 *            'icon' => 'http://url_to_icon_being_described.png',
3091
+	 *            'desc' => esc_html__('localized description of item');
3092
+	 *        )
3093
+	 * );
3094
+	 *
3095
+	 * @param array $items see above for format of array
3096
+	 * @return string html string of legend
3097
+	 * @throws DomainException
3098
+	 */
3099
+	protected function _display_legend($items)
3100
+	{
3101
+		$this->_template_args['items'] = apply_filters(
3102
+			'FHEE__EE_Admin_Page___display_legend__items',
3103
+			(array) $items,
3104
+			$this
3105
+		);
3106
+		return EEH_Template::display_template(
3107
+			EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php',
3108
+			$this->_template_args,
3109
+			true
3110
+		);
3111
+	}
3112
+
3113
+
3114
+	/**
3115
+	 * This is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
3116
+	 * The returned json object is created from an array in the following format:
3117
+	 * array(
3118
+	 *  'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
3119
+	 *  'success' => FALSE, //(default FALSE) - contains any special success message.
3120
+	 *  'notices' => '', // - contains any EE_Error formatted notices
3121
+	 *  'content' => 'string can be html', //this is a string of formatted content (can be html)
3122
+	 *  'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js.
3123
+	 *  We're also going to include the template args with every package (so js can pick out any specific template args
3124
+	 *  that might be included in here)
3125
+	 * )
3126
+	 * The json object is populated by whatever is set in the $_template_args property.
3127
+	 *
3128
+	 * @param bool  $sticky_notices    Used to indicate whether you want to ensure notices are added to a transient
3129
+	 *                                 instead of displayed.
3130
+	 * @param array $notices_arguments Use this to pass any additional args on to the _process_notices.
3131
+	 * @return void
3132
+	 * @throws EE_Error
3133
+	 */
3134
+	protected function _return_json($sticky_notices = false, $notices_arguments = [])
3135
+	{
3136
+		// make sure any EE_Error notices have been handled.
3137
+		$this->_process_notices($notices_arguments, true, $sticky_notices);
3138
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : [];
3139
+		unset($this->_template_args['data']);
3140
+		$json = [
3141
+			'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
3142
+			'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
3143
+			'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
3144
+			'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
3145
+			'notices'   => EE_Error::get_notices(),
3146
+			'content'   => isset($this->_template_args['admin_page_content'])
3147
+				? $this->_template_args['admin_page_content'] : '',
3148
+			'data'      => array_merge($data, ['template_args' => $this->_template_args]),
3149
+			'isEEajax'  => true
3150
+			// special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
3151
+		];
3152
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
3153
+		if (null === error_get_last() || ! headers_sent()) {
3154
+			header('Content-Type: application/json; charset=UTF-8');
3155
+		}
3156
+		echo wp_json_encode($json);
3157
+		exit();
3158
+	}
3159
+
3160
+
3161
+	/**
3162
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
3163
+	 *
3164
+	 * @return void
3165
+	 * @throws EE_Error
3166
+	 */
3167
+	public function return_json()
3168
+	{
3169
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3170
+			$this->_return_json();
3171
+		} else {
3172
+			throw new EE_Error(
3173
+				sprintf(
3174
+					esc_html__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'),
3175
+					__FUNCTION__
3176
+				)
3177
+			);
3178
+		}
3179
+	}
3180
+
3181
+
3182
+	/**
3183
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within
3184
+	 * them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
3185
+	 *
3186
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
3187
+	 */
3188
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
3189
+	{
3190
+		$this->_hook_obj = $hook_obj;
3191
+	}
3192
+
3193
+
3194
+	/**
3195
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
3196
+	 *
3197
+	 * @param boolean $about whether to use the special about page wrapper or default.
3198
+	 * @return void
3199
+	 * @throws DomainException
3200
+	 * @throws EE_Error
3201
+	 */
3202
+	public function admin_page_wrapper($about = false)
3203
+	{
3204
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3205
+		$this->_nav_tabs                                   = $this->_get_main_nav_tabs();
3206
+		$this->_template_args['nav_tabs']                  = $this->_nav_tabs;
3207
+		$this->_template_args['admin_page_title']          = $this->_admin_page_title;
3208
+		$this->_template_args['before_admin_page_content'] = apply_filters(
3209
+			"FHEE_before_admin_page_content{$this->_current_page}{$this->_current_view}",
3210
+			isset($this->_template_args['before_admin_page_content'])
3211
+				? $this->_template_args['before_admin_page_content']
3212
+				: ''
3213
+		);
3214
+		$this->_template_args['after_admin_page_content']  = apply_filters(
3215
+			"FHEE_after_admin_page_content{$this->_current_page}{$this->_current_view}",
3216
+			isset($this->_template_args['after_admin_page_content'])
3217
+				? $this->_template_args['after_admin_page_content']
3218
+				: ''
3219
+		);
3220
+		$this->_template_args['after_admin_page_content']  .= $this->_set_help_popup_content();
3221
+		// load settings page wrapper template
3222
+		$template_path = ! defined('DOING_AJAX')
3223
+			? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php'
3224
+			: EE_ADMIN_TEMPLATE
3225
+			  . 'admin_wrapper_ajax.template.php';
3226
+		// about page?
3227
+		$template_path = $about
3228
+			? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php'
3229
+			: $template_path;
3230
+		if (defined('DOING_AJAX')) {
3231
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template(
3232
+				$template_path,
3233
+				$this->_template_args,
3234
+				true
3235
+			);
3236
+			$this->_return_json();
3237
+		} else {
3238
+			EEH_Template::display_template($template_path, $this->_template_args);
3239
+		}
3240
+	}
3241
+
3242
+
3243
+	/**
3244
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
3245
+	 *
3246
+	 * @return string html
3247
+	 * @throws EE_Error
3248
+	 */
3249
+	protected function _get_main_nav_tabs()
3250
+	{
3251
+		// let's generate the html using the EEH_Tabbed_Content helper.
3252
+		// We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute
3253
+		// (rather than setting in the page_routes array)
3254
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
3255
+	}
3256
+
3257
+
3258
+	/**
3259
+	 *        sort nav tabs
3260
+	 *
3261
+	 * @param $a
3262
+	 * @param $b
3263
+	 * @return int
3264
+	 */
3265
+	private function _sort_nav_tabs($a, $b)
3266
+	{
3267
+		if ($a['order'] === $b['order']) {
3268
+			return 0;
3269
+		}
3270
+		return ($a['order'] < $b['order']) ? -1 : 1;
3271
+	}
3272
+
3273
+
3274
+	/**
3275
+	 *    generates HTML for the forms used on admin pages
3276
+	 *
3277
+	 * @param array  $input_vars   - array of input field details
3278
+	 * @param string $generator    (options are 'string' or 'array', basically use this to indicate which generator to
3279
+	 *                             use)
3280
+	 * @param bool   $id
3281
+	 * @return string
3282
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
3283
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
3284
+	 */
3285
+	protected function _generate_admin_form_fields($input_vars = [], $generator = 'string', $id = false)
3286
+	{
3287
+		$content = $generator === 'string'
3288
+			? EEH_Form_Fields::get_form_fields($input_vars, $id)
3289
+			: EEH_Form_Fields::get_form_fields_array($input_vars);
3290
+		return $content;
3291
+	}
3292
+
3293
+
3294
+	/**
3295
+	 * generates the "Save" and "Save & Close" buttons for edit forms
3296
+	 *
3297
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save &
3298
+	 *                                   Close" button.
3299
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] =>
3300
+	 *                                   'Save', [1] => 'save & close')
3301
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e.
3302
+	 *                                   via the "name" value in the button).  We can also use this to just dump
3303
+	 *                                   default actions by submitting some other value.
3304
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it
3305
+	 *                                   will use the $referrer string. IF null, then we don't do ANYTHING on save and
3306
+	 *                                   close (normal form handling).
3307
+	 */
3308
+	protected function _set_save_buttons($both = true, $text = [], $actions = [], $referrer = null)
3309
+	{
3310
+		// make sure $text and $actions are in an array
3311
+		$text          = (array) $text;
3312
+		$actions       = (array) $actions;
3313
+		$referrer_url  = empty($referrer)
3314
+			? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3315
+			  . $this->request->getServerParam('REQUEST_URI')
3316
+			  . '" />'
3317
+			: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'
3318
+			  . $referrer
3319
+			  . '" />';
3320
+		$button_text   = ! empty($text)
3321
+			? $text
3322
+			: [
3323
+				esc_html__('Save', 'event_espresso'),
3324
+				esc_html__('Save and Close', 'event_espresso'),
3325
+			];
3326
+		$default_names = ['save', 'save_and_close'];
3327
+		// add in a hidden index for the current page (so save and close redirects properly)
3328
+		$this->_template_args['save_buttons'] = $referrer_url;
3329
+		foreach ($button_text as $key => $button) {
3330
+			$ref                                  = $default_names[ $key ];
3331
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '
3332
+													 . $ref
3333
+													 . '" value="'
3334
+													 . $button
3335
+													 . '" name="'
3336
+													 . (! empty($actions) ? $actions[ $key ] : $ref)
3337
+													 . '" id="'
3338
+													 . $this->_current_view . '_' . $ref
3339
+													 . '" />';
3340
+			if (! $both) {
3341
+				break;
3342
+			}
3343
+		}
3344
+	}
3345
+
3346
+
3347
+	/**
3348
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
3349
+	 *
3350
+	 * @param string $route
3351
+	 * @param array  $additional_hidden_fields
3352
+	 * @see   $this->_set_add_edit_form_tags() for details on params
3353
+	 * @since 4.6.0
3354
+	 */
3355
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3356
+	{
3357
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
3358
+	}
3359
+
3360
+
3361
+	/**
3362
+	 * set form open and close tags on add/edit pages.
3363
+	 *
3364
+	 * @param string $route                    the route you want the form to direct to
3365
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
3366
+	 * @return void
3367
+	 */
3368
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = [])
3369
+	{
3370
+		if (empty($route)) {
3371
+			$user_msg = esc_html__(
3372
+				'An error occurred. No action was set for this page\'s form.',
3373
+				'event_espresso'
3374
+			);
3375
+			$dev_msg  = $user_msg . "\n"
3376
+						. sprintf(
3377
+							esc_html__('The $route argument is required for the %s->%s method.', 'event_espresso'),
3378
+							__FUNCTION__,
3379
+							__CLASS__
3380
+						);
3381
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
3382
+		}
3383
+		// open form
3384
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'
3385
+															 . $this->_admin_base_url
3386
+															 . '" id="'
3387
+															 . $route
3388
+															 . '_event_form" >';
3389
+		// add nonce
3390
+		$nonce                                             =
3391
+			wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
3392
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
3393
+		// add REQUIRED form action
3394
+		$hidden_fields = [
3395
+			'action' => ['type' => 'hidden', 'value' => $route],
3396
+		];
3397
+		// merge arrays
3398
+		$hidden_fields = is_array($additional_hidden_fields)
3399
+			? array_merge($hidden_fields, $additional_hidden_fields)
3400
+			: $hidden_fields;
3401
+		// generate form fields
3402
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
3403
+		// add fields to form
3404
+		foreach ((array) $form_fields as $field_name => $form_field) {
3405
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
3406
+		}
3407
+		// close form
3408
+		$this->_template_args['after_admin_page_content'] = '</form>';
3409
+	}
3410
+
3411
+
3412
+	/**
3413
+	 * Public Wrapper for _redirect_after_action() method since its
3414
+	 * discovered it would be useful for external code to have access.
3415
+	 *
3416
+	 * @param bool   $success
3417
+	 * @param string $what
3418
+	 * @param string $action_desc
3419
+	 * @param array  $query_args
3420
+	 * @param bool   $override_overwrite
3421
+	 * @throws EE_Error
3422
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
3423
+	 * @since 4.5.0
3424
+	 */
3425
+	public function redirect_after_action(
3426
+		$success = false,
3427
+		$what = 'item',
3428
+		$action_desc = 'processed',
3429
+		$query_args = [],
3430
+		$override_overwrite = false
3431
+	) {
3432
+		$this->_redirect_after_action(
3433
+			$success,
3434
+			$what,
3435
+			$action_desc,
3436
+			$query_args,
3437
+			$override_overwrite
3438
+		);
3439
+	}
3440
+
3441
+
3442
+	/**
3443
+	 * Helper method for merging existing request data with the returned redirect url.
3444
+	 *
3445
+	 * This is typically used for redirects after an action so that if the original view was a filtered view those
3446
+	 * filters are still applied.
3447
+	 *
3448
+	 * @param array $new_route_data
3449
+	 * @return array
3450
+	 */
3451
+	protected function mergeExistingRequestParamsWithRedirectArgs(array $new_route_data)
3452
+	{
3453
+		foreach ($this->request->requestParams() as $ref => $value) {
3454
+			// unset nonces
3455
+			if (strpos($ref, 'nonce') !== false) {
3456
+				$this->request->unSetRequestParam($ref);
3457
+				continue;
3458
+			}
3459
+			// urlencode values.
3460
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
3461
+			$this->request->setRequestParam($ref, $value);
3462
+		}
3463
+		return array_merge($this->request->requestParams(), $new_route_data);
3464
+	}
3465
+
3466
+
3467
+	/**
3468
+	 *    _redirect_after_action
3469
+	 *
3470
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
3471
+	 * @param string $what               - what the action was performed on
3472
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
3473
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin
3474
+	 *                                   action is completed
3475
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to
3476
+	 *                                   override this so that they show.
3477
+	 * @return void
3478
+	 * @throws EE_Error
3479
+	 */
3480
+	protected function _redirect_after_action(
3481
+		$success = 0,
3482
+		$what = 'item',
3483
+		$action_desc = 'processed',
3484
+		$query_args = [],
3485
+		$override_overwrite = false
3486
+	) {
3487
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3488
+		// class name for actions/filters.
3489
+		$classname = get_class($this);
3490
+		// set redirect url.
3491
+		// Note if there is a "page" index in the $query_args then we go with vanilla admin.php route,
3492
+		// otherwise we go with whatever is set as the _admin_base_url
3493
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
3494
+		$notices      = EE_Error::get_notices(false);
3495
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
3496
+		if (! $override_overwrite || ! empty($notices['errors'])) {
3497
+			EE_Error::overwrite_success();
3498
+		}
3499
+		if (! empty($what) && ! empty($action_desc) && empty($notices['errors'])) {
3500
+			// how many records affected ? more than one record ? or just one ?
3501
+			if ($success > 1) {
3502
+				// set plural msg
3503
+				EE_Error::add_success(
3504
+					sprintf(
3505
+						esc_html__('The "%s" have been successfully %s.', 'event_espresso'),
3506
+						$what,
3507
+						$action_desc
3508
+					),
3509
+					__FILE__,
3510
+					__FUNCTION__,
3511
+					__LINE__
3512
+				);
3513
+			} elseif ($success === 1) {
3514
+				// set singular msg
3515
+				EE_Error::add_success(
3516
+					sprintf(
3517
+						esc_html__('The "%s" has been successfully %s.', 'event_espresso'),
3518
+						$what,
3519
+						$action_desc
3520
+					),
3521
+					__FILE__,
3522
+					__FUNCTION__,
3523
+					__LINE__
3524
+				);
3525
+			}
3526
+		}
3527
+		// check that $query_args isn't something crazy
3528
+		if (! is_array($query_args)) {
3529
+			$query_args = [];
3530
+		}
3531
+		/**
3532
+		 * Allow injecting actions before the query_args are modified for possible different
3533
+		 * redirections on save and close actions
3534
+		 *
3535
+		 * @param array $query_args       The original query_args array coming into the
3536
+		 *                                method.
3537
+		 * @since 4.2.0
3538
+		 */
3539
+		do_action(
3540
+			"AHEE__{$classname}___redirect_after_action__before_redirect_modification_{$this->_req_action}",
3541
+			$query_args
3542
+		);
3543
+		// calculate where we're going (if we have a "save and close" button pushed)
3544
+
3545
+		if (
3546
+			$this->request->requestParamIsSet('save_and_close')
3547
+			&& $this->request->requestParamIsSet('save_and_close_referrer')
3548
+		) {
3549
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
3550
+			$parsed_url = parse_url($this->request->getRequestParam('save_and_close_referrer', '', 'url'));
3551
+			// regenerate query args array from referrer URL
3552
+			parse_str($parsed_url['query'], $query_args);
3553
+			// correct page and action will be in the query args now
3554
+			$redirect_url = admin_url('admin.php');
3555
+		}
3556
+		// merge any default query_args set in _default_route_query_args property
3557
+		if (! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
3558
+			$args_to_merge = [];
3559
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
3560
+				// is there a wp_referer array in our _default_route_query_args property?
3561
+				if ($query_param === 'wp_referer') {
3562
+					$query_value = (array) $query_value;
3563
+					foreach ($query_value as $reference => $value) {
3564
+						if (strpos($reference, 'nonce') !== false) {
3565
+							continue;
3566
+						}
3567
+						// finally we will override any arguments in the referer with
3568
+						// what might be set on the _default_route_query_args array.
3569
+						if (isset($this->_default_route_query_args[ $reference ])) {
3570
+							$args_to_merge[ $reference ] = urlencode($this->_default_route_query_args[ $reference ]);
3571
+						} else {
3572
+							$args_to_merge[ $reference ] = urlencode($value);
3573
+						}
3574
+					}
3575
+					continue;
3576
+				}
3577
+				$args_to_merge[ $query_param ] = $query_value;
3578
+			}
3579
+			// now let's merge these arguments but override with what was specifically sent in to the
3580
+			// redirect.
3581
+			$query_args = array_merge($args_to_merge, $query_args);
3582
+		}
3583
+		$this->_process_notices($query_args);
3584
+		// generate redirect url
3585
+		// if redirecting to anything other than the main page, add a nonce
3586
+		if (isset($query_args['action'])) {
3587
+			// manually generate wp_nonce and merge that with the query vars
3588
+			// becuz the wp_nonce_url function wrecks havoc on some vars
3589
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
3590
+		}
3591
+		// we're adding some hooks and filters in here for processing any things just before redirects
3592
+		// (example: an admin page has done an insert or update and we want to run something after that).
3593
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
3594
+		$redirect_url = apply_filters(
3595
+			'FHEE_redirect_' . $classname . $this->_req_action,
3596
+			self::add_query_args_and_nonce($query_args, $redirect_url),
3597
+			$query_args
3598
+		);
3599
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
3600
+		if (defined('DOING_AJAX')) {
3601
+			$default_data                    = [
3602
+				'close'        => true,
3603
+				'redirect_url' => $redirect_url,
3604
+				'where'        => 'main',
3605
+				'what'         => 'append',
3606
+			];
3607
+			$this->_template_args['success'] = $success;
3608
+			$this->_template_args['data']    = ! empty($this->_template_args['data']) ? array_merge(
3609
+				$default_data,
3610
+				$this->_template_args['data']
3611
+			) : $default_data;
3612
+			$this->_return_json();
3613
+		}
3614
+		wp_safe_redirect($redirect_url);
3615
+		exit();
3616
+	}
3617
+
3618
+
3619
+	/**
3620
+	 * process any notices before redirecting (or returning ajax request)
3621
+	 * This method sets the $this->_template_args['notices'] attribute;
3622
+	 *
3623
+	 * @param array $query_args         any query args that need to be used for notice transient ('action')
3624
+	 * @param bool  $skip_route_verify  This is typically used when we are processing notices REALLY early and
3625
+	 *                                  page_routes haven't been defined yet.
3626
+	 * @param bool  $sticky_notices     This is used to flag that regardless of whether this is doing_ajax or not, we
3627
+	 *                                  still save a transient for the notice.
3628
+	 * @return void
3629
+	 * @throws EE_Error
3630
+	 */
3631
+	protected function _process_notices($query_args = [], $skip_route_verify = false, $sticky_notices = true)
3632
+	{
3633
+		// first let's set individual error properties if doing_ajax and the properties aren't already set.
3634
+		if (defined('DOING_AJAX') && DOING_AJAX) {
3635
+			$notices = EE_Error::get_notices(false);
3636
+			if (empty($this->_template_args['success'])) {
3637
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
3638
+			}
3639
+			if (empty($this->_template_args['errors'])) {
3640
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
3641
+			}
3642
+			if (empty($this->_template_args['attention'])) {
3643
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
3644
+			}
3645
+		}
3646
+		$this->_template_args['notices'] = EE_Error::get_notices();
3647
+		// IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
3648
+		if (! defined('DOING_AJAX') || $sticky_notices) {
3649
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
3650
+			$this->_add_transient(
3651
+				$route,
3652
+				$this->_template_args['notices'],
3653
+				true,
3654
+				$skip_route_verify
3655
+			);
3656
+		}
3657
+	}
3658
+
3659
+
3660
+	/**
3661
+	 * get_action_link_or_button
3662
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
3663
+	 *
3664
+	 * @param string $action        use this to indicate which action the url is generated with.
3665
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key)
3666
+	 *                              property.
3667
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
3668
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
3669
+	 * @param string $base_url      If this is not provided
3670
+	 *                              the _admin_base_url will be used as the default for the button base_url.
3671
+	 *                              Otherwise this value will be used.
3672
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
3673
+	 * @return string
3674
+	 * @throws InvalidArgumentException
3675
+	 * @throws InvalidInterfaceException
3676
+	 * @throws InvalidDataTypeException
3677
+	 * @throws EE_Error
3678
+	 */
3679
+	public function get_action_link_or_button(
3680
+		$action,
3681
+		$type = 'add',
3682
+		$extra_request = [],
3683
+		$class = 'button-primary',
3684
+		$base_url = '',
3685
+		$exclude_nonce = false
3686
+	) {
3687
+		// first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
3688
+		if (empty($base_url) && ! isset($this->_page_routes[ $action ])) {
3689
+			throw new EE_Error(
3690
+				sprintf(
3691
+					esc_html__(
3692
+						'There is no page route for given action for the button.  This action was given: %s',
3693
+						'event_espresso'
3694
+					),
3695
+					$action
3696
+				)
3697
+			);
3698
+		}
3699
+		if (! isset($this->_labels['buttons'][ $type ])) {
3700
+			throw new EE_Error(
3701
+				sprintf(
3702
+					esc_html__(
3703
+						'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
3704
+						'event_espresso'
3705
+					),
3706
+					$type
3707
+				)
3708
+			);
3709
+		}
3710
+		// finally check user access for this button.
3711
+		$has_access = $this->check_user_access($action, true);
3712
+		if (! $has_access) {
3713
+			return '';
3714
+		}
3715
+		$_base_url  = ! $base_url ? $this->_admin_base_url : $base_url;
3716
+		$query_args = [
3717
+			'action' => $action,
3718
+		];
3719
+		// merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
3720
+		if (! empty($extra_request)) {
3721
+			$query_args = array_merge($extra_request, $query_args);
3722
+		}
3723
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
3724
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][ $type ], $class);
3725
+	}
3726
+
3727
+
3728
+	/**
3729
+	 * _per_page_screen_option
3730
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3731
+	 *
3732
+	 * @return void
3733
+	 * @throws InvalidArgumentException
3734
+	 * @throws InvalidInterfaceException
3735
+	 * @throws InvalidDataTypeException
3736
+	 */
3737
+	protected function _per_page_screen_option()
3738
+	{
3739
+		$option = 'per_page';
3740
+		$args   = [
3741
+			'label'   => apply_filters(
3742
+				'FHEE__EE_Admin_Page___per_page_screen_options___label',
3743
+				$this->_admin_page_title,
3744
+				$this
3745
+			),
3746
+			'default' => (int) apply_filters(
3747
+				'FHEE__EE_Admin_Page___per_page_screen_options__default',
3748
+				20
3749
+			),
3750
+			'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3751
+		];
3752
+		// ONLY add the screen option if the user has access to it.
3753
+		if ($this->check_user_access($this->_current_view, true)) {
3754
+			add_screen_option($option, $args);
3755
+		}
3756
+	}
3757
+
3758
+
3759
+	/**
3760
+	 * set_per_page_screen_option
3761
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3762
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than
3763
+	 * admin_menu.
3764
+	 *
3765
+	 * @return void
3766
+	 */
3767
+	private function _set_per_page_screen_options()
3768
+	{
3769
+		if ($this->request->requestParamIsSet('wp_screen_options')) {
3770
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3771
+			if (! $user = wp_get_current_user()) {
3772
+				return;
3773
+			}
3774
+			$option = $this->request->getRequestParam('wp_screen_options[option]', '', 'key');
3775
+			if (! $option) {
3776
+				return;
3777
+			}
3778
+			$value  = $this->request->getRequestParam('wp_screen_options[value]', 0, 'int');
3779
+			$map_option = $option;
3780
+			$option     = str_replace('-', '_', $option);
3781
+			switch ($map_option) {
3782
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3783
+					$max_value = apply_filters(
3784
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__max_value',
3785
+						999,
3786
+						$this->_current_page,
3787
+						$this->_current_view
3788
+					);
3789
+					if ($value < 1) {
3790
+						return;
3791
+					}
3792
+					$value = min($value, $max_value);
3793
+					break;
3794
+				default:
3795
+					$value = apply_filters(
3796
+						'FHEE__EE_Admin_Page___set_per_page_screen_options__value',
3797
+						false,
3798
+						$option,
3799
+						$value
3800
+					);
3801
+					if (false === $value) {
3802
+						return;
3803
+					}
3804
+					break;
3805
+			}
3806
+			update_user_meta($user->ID, $option, $value);
3807
+			wp_safe_redirect(remove_query_arg(['pagenum', 'apage', 'paged'], wp_get_referer()));
3808
+			exit;
3809
+		}
3810
+	}
3811
+
3812
+
3813
+	/**
3814
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3815
+	 *
3816
+	 * @param array $data array that will be assigned to template args.
3817
+	 */
3818
+	public function set_template_args($data)
3819
+	{
3820
+		$this->_template_args = array_merge($this->_template_args, (array) $data);
3821
+	}
3822
+
3823
+
3824
+	/**
3825
+	 * This makes available the WP transient system for temporarily moving data between routes
3826
+	 *
3827
+	 * @param string $route             the route that should receive the transient
3828
+	 * @param array  $data              the data that gets sent
3829
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a
3830
+	 *                                  normal route transient.
3831
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used
3832
+	 *                                  when we are adding a transient before page_routes have been defined.
3833
+	 * @return void
3834
+	 * @throws EE_Error
3835
+	 */
3836
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3837
+	{
3838
+		$user_id = get_current_user_id();
3839
+		if (! $skip_route_verify) {
3840
+			$this->_verify_route($route);
3841
+		}
3842
+		// now let's set the string for what kind of transient we're setting
3843
+		$transient = $notices
3844
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3845
+			: 'rte_tx_' . $route . '_' . $user_id;
3846
+		$data      = $notices ? ['notices' => $data] : $data;
3847
+		// is there already a transient for this route?  If there is then let's ADD to that transient
3848
+		$existing = is_multisite() && is_network_admin()
3849
+			? get_site_transient($transient)
3850
+			: get_transient($transient);
3851
+		if ($existing) {
3852
+			$data = array_merge((array) $data, (array) $existing);
3853
+		}
3854
+		if (is_multisite() && is_network_admin()) {
3855
+			set_site_transient($transient, $data, 8);
3856
+		} else {
3857
+			set_transient($transient, $data, 8);
3858
+		}
3859
+	}
3860
+
3861
+
3862
+	/**
3863
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3864
+	 *
3865
+	 * @param bool   $notices true we get notices transient. False we just return normal route transient
3866
+	 * @param string $route
3867
+	 * @return mixed data
3868
+	 */
3869
+	protected function _get_transient($notices = false, $route = '')
3870
+	{
3871
+		$user_id   = get_current_user_id();
3872
+		$route     = ! $route ? $this->_req_action : $route;
3873
+		$transient = $notices
3874
+			? 'ee_rte_n_tx_' . $route . '_' . $user_id
3875
+			: 'rte_tx_' . $route . '_' . $user_id;
3876
+		$data      = is_multisite() && is_network_admin()
3877
+			? get_site_transient($transient)
3878
+			: get_transient($transient);
3879
+		// delete transient after retrieval (just in case it hasn't expired);
3880
+		if (is_multisite() && is_network_admin()) {
3881
+			delete_site_transient($transient);
3882
+		} else {
3883
+			delete_transient($transient);
3884
+		}
3885
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3886
+	}
3887
+
3888
+
3889
+	/**
3890
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but
3891
+	 * would not be called later. This will be assigned to run on a specific EE Admin page. (place the method in the
3892
+	 * default route callback on the EE_Admin page you want it run.)
3893
+	 *
3894
+	 * @return void
3895
+	 */
3896
+	protected function _transient_garbage_collection()
3897
+	{
3898
+		global $wpdb;
3899
+		// retrieve all existing transients
3900
+		$query =
3901
+			"SELECT option_name FROM {$wpdb->options} WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3902
+		if ($results = $wpdb->get_results($query)) {
3903
+			foreach ($results as $result) {
3904
+				$transient = str_replace('_transient_', '', $result->option_name);
3905
+				get_transient($transient);
3906
+				if (is_multisite() && is_network_admin()) {
3907
+					get_site_transient($transient);
3908
+				}
3909
+			}
3910
+		}
3911
+	}
3912
+
3913
+
3914
+	/**
3915
+	 * get_view
3916
+	 *
3917
+	 * @return string content of _view property
3918
+	 */
3919
+	public function get_view()
3920
+	{
3921
+		return $this->_view;
3922
+	}
3923
+
3924
+
3925
+	/**
3926
+	 * getter for the protected $_views property
3927
+	 *
3928
+	 * @return array
3929
+	 */
3930
+	public function get_views()
3931
+	{
3932
+		return $this->_views;
3933
+	}
3934
+
3935
+
3936
+	/**
3937
+	 * get_current_page
3938
+	 *
3939
+	 * @return string _current_page property value
3940
+	 */
3941
+	public function get_current_page()
3942
+	{
3943
+		return $this->_current_page;
3944
+	}
3945
+
3946
+
3947
+	/**
3948
+	 * get_current_view
3949
+	 *
3950
+	 * @return string _current_view property value
3951
+	 */
3952
+	public function get_current_view()
3953
+	{
3954
+		return $this->_current_view;
3955
+	}
3956
+
3957
+
3958
+	/**
3959
+	 * get_current_screen
3960
+	 *
3961
+	 * @return object The current WP_Screen object
3962
+	 */
3963
+	public function get_current_screen()
3964
+	{
3965
+		return $this->_current_screen;
3966
+	}
3967
+
3968
+
3969
+	/**
3970
+	 * get_current_page_view_url
3971
+	 *
3972
+	 * @return string This returns the url for the current_page_view.
3973
+	 */
3974
+	public function get_current_page_view_url()
3975
+	{
3976
+		return $this->_current_page_view_url;
3977
+	}
3978
+
3979
+
3980
+	/**
3981
+	 * just returns the Request
3982
+	 *
3983
+	 * @return RequestInterface
3984
+	 */
3985
+	public function get_request()
3986
+	{
3987
+		return $this->request;
3988
+	}
3989
+
3990
+
3991
+	/**
3992
+	 * just returns the _req_data property
3993
+	 *
3994
+	 * @return array
3995
+	 */
3996
+	public function get_request_data()
3997
+	{
3998
+		return $this->request->requestParams();
3999
+	}
4000
+
4001
+
4002
+	/**
4003
+	 * returns the _req_data protected property
4004
+	 *
4005
+	 * @return string
4006
+	 */
4007
+	public function get_req_action()
4008
+	{
4009
+		return $this->_req_action;
4010
+	}
4011
+
4012
+
4013
+	/**
4014
+	 * @return bool  value of $_is_caf property
4015
+	 */
4016
+	public function is_caf()
4017
+	{
4018
+		return $this->_is_caf;
4019
+	}
4020
+
4021
+
4022
+	/**
4023
+	 * @return mixed
4024
+	 */
4025
+	public function default_espresso_metaboxes()
4026
+	{
4027
+		return $this->_default_espresso_metaboxes;
4028
+	}
4029
+
4030
+
4031
+	/**
4032
+	 * @return mixed
4033
+	 */
4034
+	public function admin_base_url()
4035
+	{
4036
+		return $this->_admin_base_url;
4037
+	}
4038
+
4039
+
4040
+	/**
4041
+	 * @return mixed
4042
+	 */
4043
+	public function wp_page_slug()
4044
+	{
4045
+		return $this->_wp_page_slug;
4046
+	}
4047
+
4048
+
4049
+	/**
4050
+	 * updates  espresso configuration settings
4051
+	 *
4052
+	 * @param string                   $tab
4053
+	 * @param EE_Config_Base|EE_Config $config
4054
+	 * @param string                   $file file where error occurred
4055
+	 * @param string                   $func function  where error occurred
4056
+	 * @param string                   $line line no where error occurred
4057
+	 * @return boolean
4058
+	 */
4059
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
4060
+	{
4061
+		// remove any options that are NOT going to be saved with the config settings.
4062
+		if (isset($config->core->ee_ueip_optin)) {
4063
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
4064
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
4065
+			update_option('ee_ueip_has_notified', true);
4066
+		}
4067
+		// and save it (note we're also doing the network save here)
4068
+		$net_saved    = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
4069
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
4070
+		if ($config_saved && $net_saved) {
4071
+			EE_Error::add_success(sprintf(esc_html__('"%s" have been successfully updated.', 'event_espresso'), $tab));
4072
+			return true;
4073
+		}
4074
+		EE_Error::add_error(sprintf(esc_html__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
4075
+		return false;
4076
+	}
4077
+
4078
+
4079
+	/**
4080
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
4081
+	 *
4082
+	 * @return array
4083
+	 */
4084
+	public function get_yes_no_values()
4085
+	{
4086
+		return $this->_yes_no_values;
4087
+	}
4088
+
4089
+
4090
+	protected function _get_dir()
4091
+	{
4092
+		$reflector = new ReflectionClass(get_class($this));
4093
+		return dirname($reflector->getFileName());
4094
+	}
4095
+
4096
+
4097
+	/**
4098
+	 * A helper for getting a "next link".
4099
+	 *
4100
+	 * @param string $url   The url to link to
4101
+	 * @param string $class The class to use.
4102
+	 * @return string
4103
+	 */
4104
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
4105
+	{
4106
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4107
+	}
4108
+
4109
+
4110
+	/**
4111
+	 * A helper for getting a "previous link".
4112
+	 *
4113
+	 * @param string $url   The url to link to
4114
+	 * @param string $class The class to use.
4115
+	 * @return string
4116
+	 */
4117
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
4118
+	{
4119
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
4120
+	}
4121
+
4122
+
4123
+
4124
+
4125
+
4126
+
4127
+
4128
+	// below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
4129
+
4130
+
4131
+	/**
4132
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller
4133
+	 * knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the
4134
+	 * _req_data array.
4135
+	 *
4136
+	 * @return bool success/fail
4137
+	 * @throws EE_Error
4138
+	 * @throws InvalidArgumentException
4139
+	 * @throws ReflectionException
4140
+	 * @throws InvalidDataTypeException
4141
+	 * @throws InvalidInterfaceException
4142
+	 */
4143
+	protected function _process_resend_registration()
4144
+	{
4145
+		$this->_template_args['success'] = EED_Messages::process_resend($this->request->requestParams());
4146
+		do_action(
4147
+			'AHEE__EE_Admin_Page___process_resend_registration',
4148
+			$this->_template_args['success'],
4149
+			$this->request->requestParams()
4150
+		);
4151
+		return $this->_template_args['success'];
4152
+	}
4153
+
4154
+
4155
+	/**
4156
+	 * This automatically processes any payment message notifications when manual payment has been applied.
4157
+	 *
4158
+	 * @param EE_Payment $payment
4159
+	 * @return bool success/fail
4160
+	 */
4161
+	protected function _process_payment_notification(EE_Payment $payment)
4162
+	{
4163
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
4164
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
4165
+		$this->_template_args['success'] = apply_filters(
4166
+			'FHEE__EE_Admin_Page___process_admin_payment_notification__success',
4167
+			false,
4168
+			$payment
4169
+		);
4170
+		return $this->_template_args['success'];
4171
+	}
4172 4172
 }
Please login to merge, or discard this patch.
core/admin/EE_Admin_List_Table.core.php 2 patches
Indentation   +842 added lines, -842 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3 3
 if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
4
+	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -20,855 +20,855 @@  discard block
 block discarded – undo
20 20
 abstract class EE_Admin_List_Table extends WP_List_Table
21 21
 {
22 22
 
23
-    /**
24
-     * holds the data that will be processed for the table
25
-     *
26
-     * @var array $_data
27
-     */
28
-    protected $_data;
29
-
30
-
31
-    /**
32
-     * This holds the value of all the data available for the given view (for all pages).
33
-     *
34
-     * @var int $_all_data_count
35
-     */
36
-    protected $_all_data_count;
37
-
38
-
39
-    /**
40
-     * Will contain the count of trashed items for the view label.
41
-     *
42
-     * @var int $_trashed_count
43
-     */
44
-    protected $_trashed_count;
45
-
46
-
47
-    /**
48
-     * This is what will be referenced as the slug for the current screen
49
-     *
50
-     * @var string $_screen
51
-     */
52
-    protected $_screen;
53
-
54
-
55
-    /**
56
-     * this is the EE_Admin_Page object
57
-     *
58
-     * @var EE_Admin_Page $_admin_page
59
-     */
60
-    protected $_admin_page;
61
-
62
-
63
-    /**
64
-     * The current view
65
-     *
66
-     * @var string $_view
67
-     */
68
-    protected $_view;
69
-
70
-
71
-    /**
72
-     * array of possible views for this table
73
-     *
74
-     * @var array $_views
75
-     */
76
-    protected $_views;
77
-
78
-
79
-    /**
80
-     * An array of key => value pairs containing information about the current table
81
-     * array(
82
-     *        'plural' => 'plural label',
83
-     *        'singular' => 'singular label',
84
-     *        'ajax' => false, //whether to use ajax or not
85
-     *        'screen' => null, //string used to reference what screen this is
86
-     *        (WP_List_table converts to screen object)
87
-     * )
88
-     *
89
-     * @var array $_wp_list_args
90
-     */
91
-    protected $_wp_list_args;
92
-
93
-    /**
94
-     * an array of column names
95
-     * array(
96
-     *    'internal-name' => 'Title'
97
-     * )
98
-     *
99
-     * @var array $_columns
100
-     */
101
-    protected $_columns;
102
-
103
-    /**
104
-     * An array of sortable columns
105
-     * array(
106
-     *    'internal-name' => 'orderby' //or
107
-     *    'internal-name' => array( 'orderby', true )
108
-     * )
109
-     *
110
-     * @var array $_sortable_columns
111
-     */
112
-    protected $_sortable_columns;
113
-
114
-    /**
115
-     * callback method used to perform AJAX row reordering
116
-     *
117
-     * @var string $_ajax_sorting_callback
118
-     */
119
-    protected $_ajax_sorting_callback;
120
-
121
-    /**
122
-     * An array of hidden columns (if needed)
123
-     * array('internal-name', 'internal-name')
124
-     *
125
-     * @var array $_hidden_columns
126
-     */
127
-    protected $_hidden_columns;
128
-
129
-    /**
130
-     * holds the per_page value
131
-     *
132
-     * @var int $_per_page
133
-     */
134
-    protected $_per_page;
135
-
136
-    /**
137
-     * holds what page number is currently being viewed
138
-     *
139
-     * @var int $_current_page
140
-     */
141
-    protected $_current_page;
142
-
143
-    /**
144
-     * the reference string for the nonce_action
145
-     *
146
-     * @var string $_nonce_action_ref
147
-     */
148
-    protected $_nonce_action_ref;
149
-
150
-    /**
151
-     * property to hold incoming request data (as set by the admin_page_core)
152
-     *
153
-     * @var array $_req_data
154
-     */
155
-    protected $_req_data;
156
-
157
-
158
-    /**
159
-     * yes / no array for admin form fields
160
-     *
161
-     * @var array $_yes_no
162
-     */
163
-    protected $_yes_no = array();
164
-
165
-    /**
166
-     * Array describing buttons that should appear at the bottom of the page
167
-     * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
-     * and the values are another array with the following keys
169
-     * array(
170
-     *    'route' => 'page_route',
171
-     *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
-     * )
173
-     *
174
-     * @var array $_bottom_buttons
175
-     */
176
-    protected $_bottom_buttons = array();
177
-
178
-
179
-    /**
180
-     * Used to indicate what should be the primary column for the list table.
181
-     * If not present then falls back to what WP calculates
182
-     * as the primary column.
183
-     *
184
-     * @type string $_primary_column
185
-     */
186
-    protected $_primary_column = '';
187
-
188
-
189
-    /**
190
-     * Used to indicate whether the table has a checkbox column or not.
191
-     *
192
-     * @type bool $_has_checkbox_column
193
-     */
194
-    protected $_has_checkbox_column = false;
195
-
196
-
197
-    /**
198
-     * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
-     */
200
-    public function __construct(EE_Admin_Page $admin_page)
201
-    {
202
-        $this->_admin_page = $admin_page;
203
-        $this->_req_data = $this->_admin_page->get_request_data();
204
-        $this->_view = $this->_admin_page->get_view();
205
-        $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
-        $this->_current_page = $this->get_pagenum();
207
-        $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
-        $this->_yes_no = array(esc_html__('No', 'event_espresso'), esc_html__('Yes', 'event_espresso'));
209
-
210
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 20);
211
-
212
-        $this->_setup_data();
213
-        $this->_add_view_counts();
214
-
215
-        $this->_nonce_action_ref = $this->_view;
216
-
217
-        $this->_set_properties();
218
-
219
-        // set primary column
220
-        add_filter('list_table_primary_column', array($this, 'set_primary_column'));
221
-
222
-        // set parent defaults
223
-        parent::__construct($this->_wp_list_args);
224
-
225
-        $this->prepare_items();
226
-    }
227
-
228
-
229
-    /**
230
-     * _setup_data
231
-     * this method is used to setup the $_data, $_all_data_count, and _per_page properties
232
-     *
233
-     * @uses $this->_admin_page
234
-     * @return void
235
-     */
236
-    abstract protected function _setup_data();
237
-
238
-
239
-    /**
240
-     * set the properties that this class needs to be able to execute wp_list_table properly
241
-     * properties set:
242
-     * _wp_list_args = what the arguments required for the parent _wp_list_table.
243
-     * _columns = set the columns in an array.
244
-     * _sortable_columns = columns that are sortable (array).
245
-     * _hidden_columns = columns that are hidden (array)
246
-     * _default_orderby = the default orderby for sorting.
247
-     *
248
-     * @abstract
249
-     * @access protected
250
-     * @return void
251
-     */
252
-    abstract protected function _set_properties();
253
-
254
-
255
-    /**
256
-     * _get_table_filters
257
-     * We use this to assemble and return any filters that are associated with this table that help further refine what
258
-     * get's shown in the table.
259
-     *
260
-     * @abstract
261
-     * @access protected
262
-     * @return string
263
-     */
264
-    abstract protected function _get_table_filters();
265
-
266
-
267
-    /**
268
-     * this is a method that child class will do to add counts to the views array so when views are displayed the
269
-     * counts of the views is accurate.
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _add_view_counts();
276
-
277
-
278
-    /**
279
-     * _get_hidden_fields
280
-     * returns a html string of hidden fields so if any table filters are used the current view will be respected.
281
-     *
282
-     * @return string
283
-     */
284
-    protected function _get_hidden_fields()
285
-    {
286
-        $action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
287
-        $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
288
-        // if action is STILL empty, then we set it to default
289
-        $action = empty($action) ? 'default' : $action;
290
-        $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
291
-        $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
292
-        $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
293
-
294
-        $bulk_actions = $this->_get_bulk_actions();
295
-        foreach ($bulk_actions as $bulk_action => $label) {
296
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
297
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
298
-        }
299
-
300
-        return $field;
301
-    }
302
-
303
-
304
-    /**
305
-     * _set_column_info
306
-     * we're using this to set the column headers property.
307
-     *
308
-     * @access protected
309
-     * @return void
310
-     */
311
-    protected function _set_column_info()
312
-    {
313
-        $columns = $this->get_columns();
314
-        $hidden = $this->get_hidden_columns();
315
-        $_sortable = $this->get_sortable_columns();
316
-
317
-        /**
318
-         * Dynamic hook allowing for adding sortable columns in this list table.
319
-         * Note that $this->screen->id is in the format
320
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
321
-         * table it is: event-espresso_page_espresso_messages.
322
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
323
-         * hook prefix ("event-espresso") will be different.
324
-         *
325
-         * @var array
326
-         */
327
-        $_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
328
-
329
-        $sortable = array();
330
-        foreach ($_sortable as $id => $data) {
331
-            if (empty($data)) {
332
-                continue;
333
-            }
334
-            // fix for offset errors with WP_List_Table default get_columninfo()
335
-            if (is_array($data)) {
336
-                $_data[0] = key($data);
337
-                $_data[1] = isset($data[1]) ? $data[1] : false;
338
-            } else {
339
-                $_data[0] = $data;
340
-            }
341
-
342
-            $data = (array) $data;
343
-
344
-            if (! isset($data[1])) {
345
-                $_data[1] = false;
346
-            }
347
-
348
-            $sortable[ $id ] = $_data;
349
-        }
350
-        $primary = $this->get_primary_column_name();
351
-        $this->_column_headers = array($columns, $hidden, $sortable, $primary);
352
-    }
353
-
354
-
355
-    /**
356
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
357
-     *
358
-     * @return string
359
-     */
360
-    protected function get_primary_column_name()
361
-    {
362
-        foreach (class_parents($this) as $parent) {
363
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
364
-                return parent::get_primary_column_name();
365
-            }
366
-        }
367
-        return $this->_primary_column;
368
-    }
369
-
370
-
371
-    /**
372
-     * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
373
-     *
374
-     * @param EE_Base_Class $item
375
-     * @param string        $column_name
376
-     * @param string        $primary
377
-     * @return string
378
-     */
379
-    protected function handle_row_actions($item, $column_name, $primary)
380
-    {
381
-        foreach (class_parents($this) as $parent) {
382
-            if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
383
-                return parent::handle_row_actions($item, $column_name, $primary);
384
-            }
385
-        }
386
-        return '';
387
-    }
388
-
389
-
390
-    /**
391
-     * _get_bulk_actions
392
-     * This is a wrapper called by WP_List_Table::get_bulk_actions()
393
-     *
394
-     * @access protected
395
-     * @return array bulk_actions
396
-     */
397
-    protected function _get_bulk_actions()
398
-    {
399
-        $actions = array();
400
-        // the _views property should have the bulk_actions, so let's go through and extract them into a properly
401
-        // 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
405
-                // for that page route and skip adding the bulk action if no access for the current logged in user.
406
-                foreach ($args['bulk_action'] as $route => $label) {
407
-                    if ($this->_admin_page->check_user_access($route, true)) {
408
-                        $actions[ $route ] = $label;
409
-                    }
410
-                }
411
-            }
412
-        }
413
-        return $actions;
414
-    }
415
-
416
-
417
-    /**
418
-     * Generate the table navigation above or below the table.
419
-     * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
420
-     *
421
-     * @since 4.9.44.rc.001
422
-     */
423
-    public function display_tablenav($which)
424
-    {
425
-        if ('top' === $which) {
426
-            wp_nonce_field('bulk-' . $this->_args['plural']);
427
-        }
428
-        ?>
23
+	/**
24
+	 * holds the data that will be processed for the table
25
+	 *
26
+	 * @var array $_data
27
+	 */
28
+	protected $_data;
29
+
30
+
31
+	/**
32
+	 * This holds the value of all the data available for the given view (for all pages).
33
+	 *
34
+	 * @var int $_all_data_count
35
+	 */
36
+	protected $_all_data_count;
37
+
38
+
39
+	/**
40
+	 * Will contain the count of trashed items for the view label.
41
+	 *
42
+	 * @var int $_trashed_count
43
+	 */
44
+	protected $_trashed_count;
45
+
46
+
47
+	/**
48
+	 * This is what will be referenced as the slug for the current screen
49
+	 *
50
+	 * @var string $_screen
51
+	 */
52
+	protected $_screen;
53
+
54
+
55
+	/**
56
+	 * this is the EE_Admin_Page object
57
+	 *
58
+	 * @var EE_Admin_Page $_admin_page
59
+	 */
60
+	protected $_admin_page;
61
+
62
+
63
+	/**
64
+	 * The current view
65
+	 *
66
+	 * @var string $_view
67
+	 */
68
+	protected $_view;
69
+
70
+
71
+	/**
72
+	 * array of possible views for this table
73
+	 *
74
+	 * @var array $_views
75
+	 */
76
+	protected $_views;
77
+
78
+
79
+	/**
80
+	 * An array of key => value pairs containing information about the current table
81
+	 * array(
82
+	 *        'plural' => 'plural label',
83
+	 *        'singular' => 'singular label',
84
+	 *        'ajax' => false, //whether to use ajax or not
85
+	 *        'screen' => null, //string used to reference what screen this is
86
+	 *        (WP_List_table converts to screen object)
87
+	 * )
88
+	 *
89
+	 * @var array $_wp_list_args
90
+	 */
91
+	protected $_wp_list_args;
92
+
93
+	/**
94
+	 * an array of column names
95
+	 * array(
96
+	 *    'internal-name' => 'Title'
97
+	 * )
98
+	 *
99
+	 * @var array $_columns
100
+	 */
101
+	protected $_columns;
102
+
103
+	/**
104
+	 * An array of sortable columns
105
+	 * array(
106
+	 *    'internal-name' => 'orderby' //or
107
+	 *    'internal-name' => array( 'orderby', true )
108
+	 * )
109
+	 *
110
+	 * @var array $_sortable_columns
111
+	 */
112
+	protected $_sortable_columns;
113
+
114
+	/**
115
+	 * callback method used to perform AJAX row reordering
116
+	 *
117
+	 * @var string $_ajax_sorting_callback
118
+	 */
119
+	protected $_ajax_sorting_callback;
120
+
121
+	/**
122
+	 * An array of hidden columns (if needed)
123
+	 * array('internal-name', 'internal-name')
124
+	 *
125
+	 * @var array $_hidden_columns
126
+	 */
127
+	protected $_hidden_columns;
128
+
129
+	/**
130
+	 * holds the per_page value
131
+	 *
132
+	 * @var int $_per_page
133
+	 */
134
+	protected $_per_page;
135
+
136
+	/**
137
+	 * holds what page number is currently being viewed
138
+	 *
139
+	 * @var int $_current_page
140
+	 */
141
+	protected $_current_page;
142
+
143
+	/**
144
+	 * the reference string for the nonce_action
145
+	 *
146
+	 * @var string $_nonce_action_ref
147
+	 */
148
+	protected $_nonce_action_ref;
149
+
150
+	/**
151
+	 * property to hold incoming request data (as set by the admin_page_core)
152
+	 *
153
+	 * @var array $_req_data
154
+	 */
155
+	protected $_req_data;
156
+
157
+
158
+	/**
159
+	 * yes / no array for admin form fields
160
+	 *
161
+	 * @var array $_yes_no
162
+	 */
163
+	protected $_yes_no = array();
164
+
165
+	/**
166
+	 * Array describing buttons that should appear at the bottom of the page
167
+	 * Keys are strings that represent the button's function (specifically a key in _labels['buttons']),
168
+	 * and the values are another array with the following keys
169
+	 * array(
170
+	 *    'route' => 'page_route',
171
+	 *    'extra_request' => array('evt_id' => 1 ); //extra request vars that need to be included in the button.
172
+	 * )
173
+	 *
174
+	 * @var array $_bottom_buttons
175
+	 */
176
+	protected $_bottom_buttons = array();
177
+
178
+
179
+	/**
180
+	 * Used to indicate what should be the primary column for the list table.
181
+	 * If not present then falls back to what WP calculates
182
+	 * as the primary column.
183
+	 *
184
+	 * @type string $_primary_column
185
+	 */
186
+	protected $_primary_column = '';
187
+
188
+
189
+	/**
190
+	 * Used to indicate whether the table has a checkbox column or not.
191
+	 *
192
+	 * @type bool $_has_checkbox_column
193
+	 */
194
+	protected $_has_checkbox_column = false;
195
+
196
+
197
+	/**
198
+	 * @param \EE_Admin_Page $admin_page we use this for obtaining everything we need in the list table
199
+	 */
200
+	public function __construct(EE_Admin_Page $admin_page)
201
+	{
202
+		$this->_admin_page = $admin_page;
203
+		$this->_req_data = $this->_admin_page->get_request_data();
204
+		$this->_view = $this->_admin_page->get_view();
205
+		$this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206
+		$this->_current_page = $this->get_pagenum();
207
+		$this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
208
+		$this->_yes_no = array(esc_html__('No', 'event_espresso'), esc_html__('Yes', 'event_espresso'));
209
+
210
+		$this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 20);
211
+
212
+		$this->_setup_data();
213
+		$this->_add_view_counts();
214
+
215
+		$this->_nonce_action_ref = $this->_view;
216
+
217
+		$this->_set_properties();
218
+
219
+		// set primary column
220
+		add_filter('list_table_primary_column', array($this, 'set_primary_column'));
221
+
222
+		// set parent defaults
223
+		parent::__construct($this->_wp_list_args);
224
+
225
+		$this->prepare_items();
226
+	}
227
+
228
+
229
+	/**
230
+	 * _setup_data
231
+	 * this method is used to setup the $_data, $_all_data_count, and _per_page properties
232
+	 *
233
+	 * @uses $this->_admin_page
234
+	 * @return void
235
+	 */
236
+	abstract protected function _setup_data();
237
+
238
+
239
+	/**
240
+	 * set the properties that this class needs to be able to execute wp_list_table properly
241
+	 * properties set:
242
+	 * _wp_list_args = what the arguments required for the parent _wp_list_table.
243
+	 * _columns = set the columns in an array.
244
+	 * _sortable_columns = columns that are sortable (array).
245
+	 * _hidden_columns = columns that are hidden (array)
246
+	 * _default_orderby = the default orderby for sorting.
247
+	 *
248
+	 * @abstract
249
+	 * @access protected
250
+	 * @return void
251
+	 */
252
+	abstract protected function _set_properties();
253
+
254
+
255
+	/**
256
+	 * _get_table_filters
257
+	 * We use this to assemble and return any filters that are associated with this table that help further refine what
258
+	 * get's shown in the table.
259
+	 *
260
+	 * @abstract
261
+	 * @access protected
262
+	 * @return string
263
+	 */
264
+	abstract protected function _get_table_filters();
265
+
266
+
267
+	/**
268
+	 * this is a method that child class will do to add counts to the views array so when views are displayed the
269
+	 * counts of the views is accurate.
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _add_view_counts();
276
+
277
+
278
+	/**
279
+	 * _get_hidden_fields
280
+	 * returns a html string of hidden fields so if any table filters are used the current view will be respected.
281
+	 *
282
+	 * @return string
283
+	 */
284
+	protected function _get_hidden_fields()
285
+	{
286
+		$action = isset($this->_req_data['route']) ? $this->_req_data['route'] : '';
287
+		$action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
288
+		// if action is STILL empty, then we set it to default
289
+		$action = empty($action) ? 'default' : $action;
290
+		$field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
291
+		$field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
292
+		$field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
293
+
294
+		$bulk_actions = $this->_get_bulk_actions();
295
+		foreach ($bulk_actions as $bulk_action => $label) {
296
+			$field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
297
+					  . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
298
+		}
299
+
300
+		return $field;
301
+	}
302
+
303
+
304
+	/**
305
+	 * _set_column_info
306
+	 * we're using this to set the column headers property.
307
+	 *
308
+	 * @access protected
309
+	 * @return void
310
+	 */
311
+	protected function _set_column_info()
312
+	{
313
+		$columns = $this->get_columns();
314
+		$hidden = $this->get_hidden_columns();
315
+		$_sortable = $this->get_sortable_columns();
316
+
317
+		/**
318
+		 * Dynamic hook allowing for adding sortable columns in this list table.
319
+		 * Note that $this->screen->id is in the format
320
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
321
+		 * table it is: event-espresso_page_espresso_messages.
322
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
323
+		 * hook prefix ("event-espresso") will be different.
324
+		 *
325
+		 * @var array
326
+		 */
327
+		$_sortable = apply_filters("FHEE_manage_{$this->screen->id}_sortable_columns", $_sortable, $this->_screen);
328
+
329
+		$sortable = array();
330
+		foreach ($_sortable as $id => $data) {
331
+			if (empty($data)) {
332
+				continue;
333
+			}
334
+			// fix for offset errors with WP_List_Table default get_columninfo()
335
+			if (is_array($data)) {
336
+				$_data[0] = key($data);
337
+				$_data[1] = isset($data[1]) ? $data[1] : false;
338
+			} else {
339
+				$_data[0] = $data;
340
+			}
341
+
342
+			$data = (array) $data;
343
+
344
+			if (! isset($data[1])) {
345
+				$_data[1] = false;
346
+			}
347
+
348
+			$sortable[ $id ] = $_data;
349
+		}
350
+		$primary = $this->get_primary_column_name();
351
+		$this->_column_headers = array($columns, $hidden, $sortable, $primary);
352
+	}
353
+
354
+
355
+	/**
356
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
357
+	 *
358
+	 * @return string
359
+	 */
360
+	protected function get_primary_column_name()
361
+	{
362
+		foreach (class_parents($this) as $parent) {
363
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'get_primary_column_name')) {
364
+				return parent::get_primary_column_name();
365
+			}
366
+		}
367
+		return $this->_primary_column;
368
+	}
369
+
370
+
371
+	/**
372
+	 * Added for WP4.1 backward compat (@see https://events.codebasehq.com/projects/event-espresso/tickets/8814)
373
+	 *
374
+	 * @param EE_Base_Class $item
375
+	 * @param string        $column_name
376
+	 * @param string        $primary
377
+	 * @return string
378
+	 */
379
+	protected function handle_row_actions($item, $column_name, $primary)
380
+	{
381
+		foreach (class_parents($this) as $parent) {
382
+			if ($parent === 'WP_List_Table' && method_exists($parent, 'handle_row_actions')) {
383
+				return parent::handle_row_actions($item, $column_name, $primary);
384
+			}
385
+		}
386
+		return '';
387
+	}
388
+
389
+
390
+	/**
391
+	 * _get_bulk_actions
392
+	 * This is a wrapper called by WP_List_Table::get_bulk_actions()
393
+	 *
394
+	 * @access protected
395
+	 * @return array bulk_actions
396
+	 */
397
+	protected function _get_bulk_actions()
398
+	{
399
+		$actions = array();
400
+		// the _views property should have the bulk_actions, so let's go through and extract them into a properly
401
+		// 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
405
+				// for that page route and skip adding the bulk action if no access for the current logged in user.
406
+				foreach ($args['bulk_action'] as $route => $label) {
407
+					if ($this->_admin_page->check_user_access($route, true)) {
408
+						$actions[ $route ] = $label;
409
+					}
410
+				}
411
+			}
412
+		}
413
+		return $actions;
414
+	}
415
+
416
+
417
+	/**
418
+	 * Generate the table navigation above or below the table.
419
+	 * Overrides the parent table nav in WP_List_Table so we can hide the bulk action div if there are no bulk actions.
420
+	 *
421
+	 * @since 4.9.44.rc.001
422
+	 */
423
+	public function display_tablenav($which)
424
+	{
425
+		if ('top' === $which) {
426
+			wp_nonce_field('bulk-' . $this->_args['plural']);
427
+		}
428
+		?>
429 429
         <div class="tablenav <?php echo esc_attr($which); ?>">
430 430
             <?php if ($this->_get_bulk_actions()) { ?>
431 431
                 <div class="alignleft actions bulkactions">
432 432
                     <?php $this->bulk_actions(); ?>
433 433
                 </div>
434 434
             <?php }
435
-            $this->extra_tablenav($which);
436
-            $this->pagination($which);
437
-            ?>
435
+			$this->extra_tablenav($which);
436
+			$this->pagination($which);
437
+			?>
438 438
 
439 439
             <br class="clear"/>
440 440
         </div>
441 441
         <?php
442
-    }
443
-
444
-
445
-    /**
446
-     * _filters
447
-     * This receives the filters array from children _get_table_filters() and assembles the string including the filter
448
-     * button.
449
-     *
450
-     * @access private
451
-     * @return string html showing filters
452
-     */
453
-    private function _filters()
454
-    {
455
-        $classname = get_class($this);
456
-        $filters = apply_filters(
457
-            "FHEE__{$classname}__filters",
458
-            (array) $this->_get_table_filters(),
459
-            $this,
460
-            $this->_screen
461
-        );
462
-
463
-        if (empty($filters)) {
464
-            return;
465
-        }
466
-        foreach ($filters as $filter) {
467
-            echo $filter;
468
-        }
469
-        // add filter button at end
470
-        echo '<input type="submit" class="button-secondary" value="'
471
-             . esc_html__('Filter', 'event_espresso')
472
-             . '" id="post-query-submit" />';
473
-        // add reset filters button at end
474
-        echo '<a class="button button-secondary"  href="'
475
-             . $this->_admin_page->get_current_page_view_url()
476
-             . '" style="display:inline-block">'
477
-             . esc_html__('Reset Filters', 'event_espresso')
478
-             . '</a>';
479
-    }
480
-
481
-
482
-    /**
483
-     * Callback for 'list_table_primary_column' WordPress filter
484
-     * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
485
-     * column when class is instantiated.
486
-     *
487
-     * @see WP_List_Table::get_primary_column_name
488
-     * @param string $column_name
489
-     * @return string
490
-     */
491
-    public function set_primary_column($column_name)
492
-    {
493
-        return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
494
-    }
495
-
496
-
497
-    /**
498
-     *
499
-     */
500
-    public function prepare_items()
501
-    {
502
-
503
-        $this->_set_column_info();
504
-        // $this->_column_headers = $this->get_column_info();
505
-        $total_items = $this->_all_data_count;
506
-        $this->process_bulk_action();
507
-
508
-        $this->items = $this->_data;
509
-        $this->set_pagination_args(
510
-            array(
511
-                'total_items' => $total_items,
512
-                'per_page'    => $this->_per_page,
513
-                'total_pages' => ceil($total_items / $this->_per_page),
514
-            )
515
-        );
516
-    }
517
-
518
-
519
-    /**
520
-     * This column is the default for when there is no defined column method for a registered column.
521
-     * This can be overridden by child classes, but allows for hooking in for custom columns.
522
-     *
523
-     * @param EE_Base_Class $item
524
-     * @param string        $column_name The column being called.
525
-     * @return string html content for the column
526
-     */
527
-    public function column_default($item, $column_name)
528
-    {
529
-        /**
530
-         * Dynamic hook allowing for adding additional column content in this list table.
531
-         * Note that $this->screen->id is in the format
532
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
533
-         * table it is: event-espresso_page_espresso_messages.
534
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
535
-         * hook prefix ("event-espresso") will be different.
536
-         */
537
-        do_action(
538
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
539
-            $item,
540
-            $this->_screen
541
-        );
542
-    }
543
-
544
-
545
-    /**
546
-     * Get a list of columns. The format is:
547
-     * 'internal-name' => 'Title'
548
-     *
549
-     * @since  3.1.0
550
-     * @access public
551
-     * @abstract
552
-     * @return array
553
-     */
554
-    public function get_columns()
555
-    {
556
-        /**
557
-         * Dynamic hook allowing for adding additional columns in this list table.
558
-         * Note that $this->screen->id is in the format
559
-         * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
560
-         * table it is: event-espresso_page_espresso_messages.
561
-         * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
562
-         * hook prefix ("event-espresso") will be different.
563
-         *
564
-         * @var array
565
-         */
566
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
567
-        return $columns;
568
-    }
569
-
570
-
571
-    /**
572
-     * Get an associative array ( id => link ) with the list
573
-     * of views available on this table.
574
-     *
575
-     * @since  3.1.0
576
-     * @access protected
577
-     * @return array
578
-     */
579
-    public function get_views()
580
-    {
581
-        return $this->_views;
582
-    }
583
-
584
-
585
-    /**
586
-     * Generate the views html.
587
-     */
588
-    public function display_views()
589
-    {
590
-        $views = $this->get_views();
591
-        $assembled_views = array();
592
-
593
-        if (empty($views)) {
594
-            return;
595
-        }
596
-        echo "<ul class='subsubsub'>\n";
597
-        foreach ($views as $view) {
598
-            $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
599
-            if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
600
-                $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>"
601
-                                                    . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
602
-                                                    . ' <span class="count">(' . $count . ')</span>';
603
-            }
604
-        }
605
-
606
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
607
-        echo "</ul>";
608
-    }
609
-
610
-
611
-    /**
612
-     * Generates content for a single row of the table
613
-     *
614
-     * @since  4.1
615
-     * @access public
616
-     * @param EE_Base_Class $item The current item
617
-     */
618
-    public function single_row($item)
619
-    {
620
-        $row_class = $this->_get_row_class($item);
621
-        echo '<tr class="' . esc_attr($row_class) . '">';
622
-        $this->single_row_columns($item);
623
-        echo '</tr>';
624
-    }
625
-
626
-
627
-    /**
628
-     * This simply sets up the row class for the table rows.
629
-     * Allows for easier overriding of child methods for setting up sorting.
630
-     *
631
-     * @param  EE_Base_Class $item the current item
632
-     * @return string
633
-     */
634
-    protected function _get_row_class($item)
635
-    {
636
-        static $row_class = '';
637
-        $row_class = ($row_class === '' ? 'alternate' : '');
638
-
639
-        $new_row_class = $row_class;
640
-
641
-        if (! empty($this->_ajax_sorting_callback)) {
642
-            $new_row_class .= ' rowsortable';
643
-        }
644
-
645
-        return $new_row_class;
646
-    }
647
-
648
-
649
-    /**
650
-     * @return array
651
-     */
652
-    public function get_sortable_columns()
653
-    {
654
-        return (array) $this->_sortable_columns;
655
-    }
656
-
657
-
658
-    /**
659
-     * @return string
660
-     */
661
-    public function get_ajax_sorting_callback()
662
-    {
663
-        return $this->_ajax_sorting_callback;
664
-    }
665
-
666
-
667
-    /**
668
-     * @return array
669
-     */
670
-    public function get_hidden_columns()
671
-    {
672
-        $user_id = get_current_user_id();
673
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
674
-        if (empty($has_default) && ! empty($this->_hidden_columns)) {
675
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
676
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
677
-        }
678
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
679
-        return (array) get_user_option($ref, $user_id);
680
-    }
681
-
682
-
683
-    /**
684
-     * Generates the columns for a single row of the table.
685
-     * Overridden from wp_list_table so as to allow us to filter the column content for a given
686
-     * column.
687
-     *
688
-     * @since 3.1.0
689
-     * @param EE_Base_Class $item The current item
690
-     */
691
-    public function single_row_columns($item)
692
-    {
693
-        list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
694
-
695
-        global $wp_version;
696
-        $use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
697
-
698
-        foreach ($columns as $column_name => $column_display_name) {
699
-
700
-            /**
701
-             * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
702
-             * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
703
-             */
704
-            $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
705
-            $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
706
-
707
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
708
-            if ($primary === $column_name) {
709
-                $classes .= ' has-row-actions column-primary';
710
-            }
711
-
712
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
713
-
714
-            $class = "class='$classes'";
715
-
716
-            $attributes = "$class$style$data";
717
-
718
-            if ($column_name === 'cb') {
719
-                echo '<th scope="row" class="check-column">';
720
-                echo apply_filters(
721
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
722
-                    $this->column_cb($item),
723
-                    $item,
724
-                    $this
725
-                );
726
-                echo '</th>';
727
-            } elseif (method_exists($this, 'column_' . $column_name)) {
728
-                echo "<td $attributes>";
729
-                echo apply_filters(
730
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
731
-                    call_user_func(array($this, 'column_' . $column_name), $item),
732
-                    $item,
733
-                    $this
734
-                );
735
-                echo $this->handle_row_actions($item, $column_name, $primary);
736
-                echo "</td>";
737
-            } else {
738
-                echo "<td $attributes>";
739
-                echo apply_filters(
740
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
741
-                    $this->column_default($item, $column_name),
742
-                    $item,
743
-                    $column_name,
744
-                    $this
745
-                );
746
-                echo $this->handle_row_actions($item, $column_name, $primary);
747
-                echo "</td>";
748
-            }
749
-        }
750
-    }
751
-
752
-
753
-    /**
754
-     * Extra controls to be displayed between bulk actions and pagination
755
-     *
756
-     * @access public
757
-     * @param string $which
758
-     * @throws \EE_Error
759
-     */
760
-    public function extra_tablenav($which)
761
-    {
762
-        if ($which === 'top') {
763
-            $this->_filters();
764
-            echo $this->_get_hidden_fields();
765
-        } else {
766
-            echo '<div class="list-table-bottom-buttons alignleft actions">';
767
-            foreach ($this->_bottom_buttons as $type => $action) {
768
-                $route = isset($action['route']) ? $action['route'] : '';
769
-                $extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
770
-                echo $this->_admin_page->get_action_link_or_button(
771
-                    $route,
772
-                    $type,
773
-                    $extra_request,
774
-                    'button button-secondary',
775
-                    '',
776
-                    false
777
-                );
778
-            }
779
-            do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
780
-            echo '</div>';
781
-        }
782
-        // echo $this->_entries_per_page_dropdown;
783
-    }
784
-
785
-
786
-    /**
787
-     * Get an associative array ( option_name => option_title ) with the list
788
-     * of bulk actions available on this table.
789
-     *
790
-     * @since  3.1.0
791
-     * @access protected
792
-     * @return array
793
-     */
794
-    public function get_bulk_actions()
795
-    {
796
-        return (array) $this->_get_bulk_actions();
797
-    }
798
-
799
-    /**
800
-     * Processing bulk actions.
801
-     */
802
-    public function process_bulk_action()
803
-    {
804
-        // this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
805
-        // reference in case there is a case where it gets used.
806
-    }
807
-
808
-
809
-    /**
810
-     * returns the EE admin page this list table is associated with
811
-     *
812
-     * @return EE_Admin_Page
813
-     */
814
-    public function get_admin_page()
815
-    {
816
-        return $this->_admin_page;
817
-    }
818
-
819
-
820
-    /**
821
-     * A "helper" function for all children to provide an html string of
822
-     * actions to output in their content.  It is preferable for child classes
823
-     * to use this method for generating their actions content so that it's
824
-     * filterable by plugins
825
-     *
826
-     * @param string        $action_container           what are the html container
827
-     *                                                  elements for this actions string?
828
-     * @param string        $action_class               What class is for the container
829
-     *                                                  element.
830
-     * @param string        $action_items               The contents for the action items
831
-     *                                                  container.  This is filtered before
832
-     *                                                  returned.
833
-     * @param string        $action_id                  What id (optional) is used for the
834
-     *                                                  container element.
835
-     * @param EE_Base_Class $item                       The object for the column displaying
836
-     *                                                  the actions.
837
-     * @return string The assembled action elements container.
838
-     */
839
-    protected function _action_string(
840
-        $action_items,
841
-        $item,
842
-        $action_container = 'ul',
843
-        $action_class = '',
844
-        $action_id = ''
845
-    ) {
846
-        $content = '';
847
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
848
-        $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
849
-        $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
850
-        try {
851
-            $content .= apply_filters(
852
-                'FHEE__EE_Admin_List_Table___action_string__action_items',
853
-                $action_items,
854
-                $item,
855
-                $this
856
-            );
857
-        } catch (\Exception $e) {
858
-            if (WP_DEBUG) {
859
-                \EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
860
-            }
861
-            $content .= $action_items;
862
-        }
863
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
864
-        return $content;
865
-    }
866
-
867
-
868
-    protected function getReturnUrl()
869
-    {
870
-        $host       = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
871
-        $uri        = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
872
-        return urlencode("//{$host}{$uri}");
873
-    }
442
+	}
443
+
444
+
445
+	/**
446
+	 * _filters
447
+	 * This receives the filters array from children _get_table_filters() and assembles the string including the filter
448
+	 * button.
449
+	 *
450
+	 * @access private
451
+	 * @return string html showing filters
452
+	 */
453
+	private function _filters()
454
+	{
455
+		$classname = get_class($this);
456
+		$filters = apply_filters(
457
+			"FHEE__{$classname}__filters",
458
+			(array) $this->_get_table_filters(),
459
+			$this,
460
+			$this->_screen
461
+		);
462
+
463
+		if (empty($filters)) {
464
+			return;
465
+		}
466
+		foreach ($filters as $filter) {
467
+			echo $filter;
468
+		}
469
+		// add filter button at end
470
+		echo '<input type="submit" class="button-secondary" value="'
471
+			 . esc_html__('Filter', 'event_espresso')
472
+			 . '" id="post-query-submit" />';
473
+		// add reset filters button at end
474
+		echo '<a class="button button-secondary"  href="'
475
+			 . $this->_admin_page->get_current_page_view_url()
476
+			 . '" style="display:inline-block">'
477
+			 . esc_html__('Reset Filters', 'event_espresso')
478
+			 . '</a>';
479
+	}
480
+
481
+
482
+	/**
483
+	 * Callback for 'list_table_primary_column' WordPress filter
484
+	 * If child EE_Admin_List_Table classes set the _primary_column property then that will be set as the primary
485
+	 * column when class is instantiated.
486
+	 *
487
+	 * @see WP_List_Table::get_primary_column_name
488
+	 * @param string $column_name
489
+	 * @return string
490
+	 */
491
+	public function set_primary_column($column_name)
492
+	{
493
+		return ! empty($this->_primary_column) ? $this->_primary_column : $column_name;
494
+	}
495
+
496
+
497
+	/**
498
+	 *
499
+	 */
500
+	public function prepare_items()
501
+	{
502
+
503
+		$this->_set_column_info();
504
+		// $this->_column_headers = $this->get_column_info();
505
+		$total_items = $this->_all_data_count;
506
+		$this->process_bulk_action();
507
+
508
+		$this->items = $this->_data;
509
+		$this->set_pagination_args(
510
+			array(
511
+				'total_items' => $total_items,
512
+				'per_page'    => $this->_per_page,
513
+				'total_pages' => ceil($total_items / $this->_per_page),
514
+			)
515
+		);
516
+	}
517
+
518
+
519
+	/**
520
+	 * This column is the default for when there is no defined column method for a registered column.
521
+	 * This can be overridden by child classes, but allows for hooking in for custom columns.
522
+	 *
523
+	 * @param EE_Base_Class $item
524
+	 * @param string        $column_name The column being called.
525
+	 * @return string html content for the column
526
+	 */
527
+	public function column_default($item, $column_name)
528
+	{
529
+		/**
530
+		 * Dynamic hook allowing for adding additional column content in this list table.
531
+		 * Note that $this->screen->id is in the format
532
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
533
+		 * table it is: event-espresso_page_espresso_messages.
534
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
535
+		 * hook prefix ("event-espresso") will be different.
536
+		 */
537
+		do_action(
538
+			'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
539
+			$item,
540
+			$this->_screen
541
+		);
542
+	}
543
+
544
+
545
+	/**
546
+	 * Get a list of columns. The format is:
547
+	 * 'internal-name' => 'Title'
548
+	 *
549
+	 * @since  3.1.0
550
+	 * @access public
551
+	 * @abstract
552
+	 * @return array
553
+	 */
554
+	public function get_columns()
555
+	{
556
+		/**
557
+		 * Dynamic hook allowing for adding additional columns in this list table.
558
+		 * Note that $this->screen->id is in the format
559
+		 * {sanitize_title($top_level_menu_label)}_page_{$espresso_admin_page_slug}.  So for the messages list
560
+		 * table it is: event-espresso_page_espresso_messages.
561
+		 * However, take note that if the top level menu label has been translated (i.e. "Event Espresso"). then the
562
+		 * hook prefix ("event-espresso") will be different.
563
+		 *
564
+		 * @var array
565
+		 */
566
+		$columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
567
+		return $columns;
568
+	}
569
+
570
+
571
+	/**
572
+	 * Get an associative array ( id => link ) with the list
573
+	 * of views available on this table.
574
+	 *
575
+	 * @since  3.1.0
576
+	 * @access protected
577
+	 * @return array
578
+	 */
579
+	public function get_views()
580
+	{
581
+		return $this->_views;
582
+	}
583
+
584
+
585
+	/**
586
+	 * Generate the views html.
587
+	 */
588
+	public function display_views()
589
+	{
590
+		$views = $this->get_views();
591
+		$assembled_views = array();
592
+
593
+		if (empty($views)) {
594
+			return;
595
+		}
596
+		echo "<ul class='subsubsub'>\n";
597
+		foreach ($views as $view) {
598
+			$count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
599
+			if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
600
+				$assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>"
601
+													. '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
602
+													. ' <span class="count">(' . $count . ')</span>';
603
+			}
604
+		}
605
+
606
+		echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
607
+		echo "</ul>";
608
+	}
609
+
610
+
611
+	/**
612
+	 * Generates content for a single row of the table
613
+	 *
614
+	 * @since  4.1
615
+	 * @access public
616
+	 * @param EE_Base_Class $item The current item
617
+	 */
618
+	public function single_row($item)
619
+	{
620
+		$row_class = $this->_get_row_class($item);
621
+		echo '<tr class="' . esc_attr($row_class) . '">';
622
+		$this->single_row_columns($item);
623
+		echo '</tr>';
624
+	}
625
+
626
+
627
+	/**
628
+	 * This simply sets up the row class for the table rows.
629
+	 * Allows for easier overriding of child methods for setting up sorting.
630
+	 *
631
+	 * @param  EE_Base_Class $item the current item
632
+	 * @return string
633
+	 */
634
+	protected function _get_row_class($item)
635
+	{
636
+		static $row_class = '';
637
+		$row_class = ($row_class === '' ? 'alternate' : '');
638
+
639
+		$new_row_class = $row_class;
640
+
641
+		if (! empty($this->_ajax_sorting_callback)) {
642
+			$new_row_class .= ' rowsortable';
643
+		}
644
+
645
+		return $new_row_class;
646
+	}
647
+
648
+
649
+	/**
650
+	 * @return array
651
+	 */
652
+	public function get_sortable_columns()
653
+	{
654
+		return (array) $this->_sortable_columns;
655
+	}
656
+
657
+
658
+	/**
659
+	 * @return string
660
+	 */
661
+	public function get_ajax_sorting_callback()
662
+	{
663
+		return $this->_ajax_sorting_callback;
664
+	}
665
+
666
+
667
+	/**
668
+	 * @return array
669
+	 */
670
+	public function get_hidden_columns()
671
+	{
672
+		$user_id = get_current_user_id();
673
+		$has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
674
+		if (empty($has_default) && ! empty($this->_hidden_columns)) {
675
+			update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
676
+			update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
677
+		}
678
+		$ref = 'manage' . $this->screen->id . 'columnshidden';
679
+		return (array) get_user_option($ref, $user_id);
680
+	}
681
+
682
+
683
+	/**
684
+	 * Generates the columns for a single row of the table.
685
+	 * Overridden from wp_list_table so as to allow us to filter the column content for a given
686
+	 * column.
687
+	 *
688
+	 * @since 3.1.0
689
+	 * @param EE_Base_Class $item The current item
690
+	 */
691
+	public function single_row_columns($item)
692
+	{
693
+		list($columns, $hidden, $sortable, $primary) = $this->get_column_info();
694
+
695
+		global $wp_version;
696
+		$use_hidden_class = version_compare($wp_version, '4.3-RC', '>=');
697
+
698
+		foreach ($columns as $column_name => $column_display_name) {
699
+
700
+			/**
701
+			 * With WordPress version 4.3.RC+ WordPress started using the hidden css class to control whether columns
702
+			 * are hidden or not instead of using "display:none;".  This bit of code provides backward compat.
703
+			 */
704
+			$hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
705
+			$style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
706
+
707
+			$classes = $column_name . ' column-' . $column_name . $hidden_class;
708
+			if ($primary === $column_name) {
709
+				$classes .= ' has-row-actions column-primary';
710
+			}
711
+
712
+			$data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
713
+
714
+			$class = "class='$classes'";
715
+
716
+			$attributes = "$class$style$data";
717
+
718
+			if ($column_name === 'cb') {
719
+				echo '<th scope="row" class="check-column">';
720
+				echo apply_filters(
721
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_cb_content',
722
+					$this->column_cb($item),
723
+					$item,
724
+					$this
725
+				);
726
+				echo '</th>';
727
+			} elseif (method_exists($this, 'column_' . $column_name)) {
728
+				echo "<td $attributes>";
729
+				echo apply_filters(
730
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
731
+					call_user_func(array($this, 'column_' . $column_name), $item),
732
+					$item,
733
+					$this
734
+				);
735
+				echo $this->handle_row_actions($item, $column_name, $primary);
736
+				echo "</td>";
737
+			} else {
738
+				echo "<td $attributes>";
739
+				echo apply_filters(
740
+					'FHEE__EE_Admin_List_Table__single_row_columns__column_default__column_content',
741
+					$this->column_default($item, $column_name),
742
+					$item,
743
+					$column_name,
744
+					$this
745
+				);
746
+				echo $this->handle_row_actions($item, $column_name, $primary);
747
+				echo "</td>";
748
+			}
749
+		}
750
+	}
751
+
752
+
753
+	/**
754
+	 * Extra controls to be displayed between bulk actions and pagination
755
+	 *
756
+	 * @access public
757
+	 * @param string $which
758
+	 * @throws \EE_Error
759
+	 */
760
+	public function extra_tablenav($which)
761
+	{
762
+		if ($which === 'top') {
763
+			$this->_filters();
764
+			echo $this->_get_hidden_fields();
765
+		} else {
766
+			echo '<div class="list-table-bottom-buttons alignleft actions">';
767
+			foreach ($this->_bottom_buttons as $type => $action) {
768
+				$route = isset($action['route']) ? $action['route'] : '';
769
+				$extra_request = isset($action['extra_request']) ? $action['extra_request'] : '';
770
+				echo $this->_admin_page->get_action_link_or_button(
771
+					$route,
772
+					$type,
773
+					$extra_request,
774
+					'button button-secondary',
775
+					'',
776
+					false
777
+				);
778
+			}
779
+			do_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', $this, $this->_screen);
780
+			echo '</div>';
781
+		}
782
+		// echo $this->_entries_per_page_dropdown;
783
+	}
784
+
785
+
786
+	/**
787
+	 * Get an associative array ( option_name => option_title ) with the list
788
+	 * of bulk actions available on this table.
789
+	 *
790
+	 * @since  3.1.0
791
+	 * @access protected
792
+	 * @return array
793
+	 */
794
+	public function get_bulk_actions()
795
+	{
796
+		return (array) $this->_get_bulk_actions();
797
+	}
798
+
799
+	/**
800
+	 * Processing bulk actions.
801
+	 */
802
+	public function process_bulk_action()
803
+	{
804
+		// this is not used it is handled by the child EE_Admin_Page class (routes).  However, including here for
805
+		// reference in case there is a case where it gets used.
806
+	}
807
+
808
+
809
+	/**
810
+	 * returns the EE admin page this list table is associated with
811
+	 *
812
+	 * @return EE_Admin_Page
813
+	 */
814
+	public function get_admin_page()
815
+	{
816
+		return $this->_admin_page;
817
+	}
818
+
819
+
820
+	/**
821
+	 * A "helper" function for all children to provide an html string of
822
+	 * actions to output in their content.  It is preferable for child classes
823
+	 * to use this method for generating their actions content so that it's
824
+	 * filterable by plugins
825
+	 *
826
+	 * @param string        $action_container           what are the html container
827
+	 *                                                  elements for this actions string?
828
+	 * @param string        $action_class               What class is for the container
829
+	 *                                                  element.
830
+	 * @param string        $action_items               The contents for the action items
831
+	 *                                                  container.  This is filtered before
832
+	 *                                                  returned.
833
+	 * @param string        $action_id                  What id (optional) is used for the
834
+	 *                                                  container element.
835
+	 * @param EE_Base_Class $item                       The object for the column displaying
836
+	 *                                                  the actions.
837
+	 * @return string The assembled action elements container.
838
+	 */
839
+	protected function _action_string(
840
+		$action_items,
841
+		$item,
842
+		$action_container = 'ul',
843
+		$action_class = '',
844
+		$action_id = ''
845
+	) {
846
+		$content = '';
847
+		$action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
848
+		$action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
849
+		$content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
850
+		try {
851
+			$content .= apply_filters(
852
+				'FHEE__EE_Admin_List_Table___action_string__action_items',
853
+				$action_items,
854
+				$item,
855
+				$this
856
+			);
857
+		} catch (\Exception $e) {
858
+			if (WP_DEBUG) {
859
+				\EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
860
+			}
861
+			$content .= $action_items;
862
+		}
863
+		$content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
864
+		return $content;
865
+	}
866
+
867
+
868
+	protected function getReturnUrl()
869
+	{
870
+		$host       = $this->_admin_page->get_request()->getServerParam('HTTP_HOST');
871
+		$uri        = $this->_admin_page->get_request()->getServerParam('REQUEST_URI');
872
+		return urlencode("//{$host}{$uri}");
873
+	}
874 874
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (! class_exists('WP_List_Table')) {
4
-    require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
3
+if ( ! class_exists('WP_List_Table')) {
4
+    require_once ABSPATH.'wp-admin/includes/class-wp-list-table.php';
5 5
 }
6 6
 
7 7
 
@@ -204,10 +204,10 @@  discard block
 block discarded – undo
204 204
         $this->_view = $this->_admin_page->get_view();
205 205
         $this->_views = empty($this->_views) ? $this->_admin_page->get_list_table_view_RLs() : $this->_views;
206 206
         $this->_current_page = $this->get_pagenum();
207
-        $this->_screen = $this->_admin_page->get_current_page() . '_' . $this->_admin_page->get_current_view();
207
+        $this->_screen = $this->_admin_page->get_current_page().'_'.$this->_admin_page->get_current_view();
208 208
         $this->_yes_no = array(esc_html__('No', 'event_espresso'), esc_html__('Yes', 'event_espresso'));
209 209
 
210
-        $this->_per_page = $this->get_items_per_page($this->_screen . '_per_page', 20);
210
+        $this->_per_page = $this->get_items_per_page($this->_screen.'_per_page', 20);
211 211
 
212 212
         $this->_setup_data();
213 213
         $this->_add_view_counts();
@@ -287,14 +287,14 @@  discard block
 block discarded – undo
287 287
         $action = empty($action) && isset($this->_req_data['action']) ? $this->_req_data['action'] : $action;
288 288
         // if action is STILL empty, then we set it to default
289 289
         $action = empty($action) ? 'default' : $action;
290
-        $field = '<input type="hidden" name="page" value="' . $this->_req_data['page'] . '" />' . "\n";
291
-        $field .= '<input type="hidden" name="route" value="' . $action . '" />' . "\n";/**/
292
-        $field .= '<input type="hidden" name="perpage" value="' . $this->_per_page . '" />' . "\n";
290
+        $field = '<input type="hidden" name="page" value="'.$this->_req_data['page'].'" />'."\n";
291
+        $field .= '<input type="hidden" name="route" value="'.$action.'" />'."\n"; /**/
292
+        $field .= '<input type="hidden" name="perpage" value="'.$this->_per_page.'" />'."\n";
293 293
 
294 294
         $bulk_actions = $this->_get_bulk_actions();
295 295
         foreach ($bulk_actions as $bulk_action => $label) {
296
-            $field .= '<input type="hidden" name="' . $bulk_action . '_nonce"'
297
-                      . ' value="' . wp_create_nonce($bulk_action . '_nonce') . '" />' . "\n";
296
+            $field .= '<input type="hidden" name="'.$bulk_action.'_nonce"'
297
+                      . ' value="'.wp_create_nonce($bulk_action.'_nonce').'" />'."\n";
298 298
         }
299 299
 
300 300
         return $field;
@@ -341,11 +341,11 @@  discard block
 block discarded – undo
341 341
 
342 342
             $data = (array) $data;
343 343
 
344
-            if (! isset($data[1])) {
344
+            if ( ! isset($data[1])) {
345 345
                 $_data[1] = false;
346 346
             }
347 347
 
348
-            $sortable[ $id ] = $_data;
348
+            $sortable[$id] = $_data;
349 349
         }
350 350
         $primary = $this->get_primary_column_name();
351 351
         $this->_column_headers = array($columns, $hidden, $sortable, $primary);
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
                 // for that page route and skip adding the bulk action if no access for the current logged in user.
406 406
                 foreach ($args['bulk_action'] as $route => $label) {
407 407
                     if ($this->_admin_page->check_user_access($route, true)) {
408
-                        $actions[ $route ] = $label;
408
+                        $actions[$route] = $label;
409 409
                     }
410 410
                 }
411 411
             }
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
     public function display_tablenav($which)
424 424
     {
425 425
         if ('top' === $which) {
426
-            wp_nonce_field('bulk-' . $this->_args['plural']);
426
+            wp_nonce_field('bulk-'.$this->_args['plural']);
427 427
         }
428 428
         ?>
429 429
         <div class="tablenav <?php echo esc_attr($which); ?>">
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
          * hook prefix ("event-espresso") will be different.
536 536
          */
537 537
         do_action(
538
-            'AHEE__EE_Admin_List_Table__column_' . $column_name . '__' . $this->screen->id,
538
+            'AHEE__EE_Admin_List_Table__column_'.$column_name.'__'.$this->screen->id,
539 539
             $item,
540 540
             $this->_screen
541 541
         );
@@ -563,7 +563,7 @@  discard block
 block discarded – undo
563 563
          *
564 564
          * @var array
565 565
          */
566
-        $columns = apply_filters('FHEE_manage_' . $this->screen->id . '_columns', $this->_columns, $this->_screen);
566
+        $columns = apply_filters('FHEE_manage_'.$this->screen->id.'_columns', $this->_columns, $this->_screen);
567 567
         return $columns;
568 568
     }
569 569
 
@@ -597,13 +597,13 @@  discard block
 block discarded – undo
597 597
         foreach ($views as $view) {
598 598
             $count = isset($view['count']) && ! empty($view['count']) ? absint($view['count']) : 0;
599 599
             if (isset($view['slug'], $view['class'], $view['url'], $view['label'])) {
600
-                $assembled_views[ $view['slug'] ] = "\t<li class='" . $view['class'] . "'>"
601
-                                                    . '<a href="' . $view['url'] . '">' . $view['label'] . '</a>'
602
-                                                    . ' <span class="count">(' . $count . ')</span>';
600
+                $assembled_views[$view['slug']] = "\t<li class='".$view['class']."'>"
601
+                                                    . '<a href="'.$view['url'].'">'.$view['label'].'</a>'
602
+                                                    . ' <span class="count">('.$count.')</span>';
603 603
             }
604 604
         }
605 605
 
606
-        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views) . "</li>\n" : '';
606
+        echo ! empty($assembled_views) ? implode(" |</li>\n", $assembled_views)."</li>\n" : '';
607 607
         echo "</ul>";
608 608
     }
609 609
 
@@ -618,7 +618,7 @@  discard block
 block discarded – undo
618 618
     public function single_row($item)
619 619
     {
620 620
         $row_class = $this->_get_row_class($item);
621
-        echo '<tr class="' . esc_attr($row_class) . '">';
621
+        echo '<tr class="'.esc_attr($row_class).'">';
622 622
         $this->single_row_columns($item);
623 623
         echo '</tr>';
624 624
     }
@@ -638,7 +638,7 @@  discard block
 block discarded – undo
638 638
 
639 639
         $new_row_class = $row_class;
640 640
 
641
-        if (! empty($this->_ajax_sorting_callback)) {
641
+        if ( ! empty($this->_ajax_sorting_callback)) {
642 642
             $new_row_class .= ' rowsortable';
643 643
         }
644 644
 
@@ -670,12 +670,12 @@  discard block
 block discarded – undo
670 670
     public function get_hidden_columns()
671 671
     {
672 672
         $user_id = get_current_user_id();
673
-        $has_default = get_user_option('default' . $this->screen->id . 'columnshidden', $user_id);
673
+        $has_default = get_user_option('default'.$this->screen->id.'columnshidden', $user_id);
674 674
         if (empty($has_default) && ! empty($this->_hidden_columns)) {
675
-            update_user_option($user_id, 'default' . $this->screen->id . 'columnshidden', true);
676
-            update_user_option($user_id, 'manage' . $this->screen->id . 'columnshidden', $this->_hidden_columns, true);
675
+            update_user_option($user_id, 'default'.$this->screen->id.'columnshidden', true);
676
+            update_user_option($user_id, 'manage'.$this->screen->id.'columnshidden', $this->_hidden_columns, true);
677 677
         }
678
-        $ref = 'manage' . $this->screen->id . 'columnshidden';
678
+        $ref = 'manage'.$this->screen->id.'columnshidden';
679 679
         return (array) get_user_option($ref, $user_id);
680 680
     }
681 681
 
@@ -704,12 +704,12 @@  discard block
 block discarded – undo
704 704
             $hidden_class = $use_hidden_class && in_array($column_name, $hidden) ? ' hidden' : '';
705 705
             $style = ! $use_hidden_class && in_array($column_name, $hidden) ? ' style="display:none;"' : '';
706 706
 
707
-            $classes = $column_name . ' column-' . $column_name . $hidden_class;
707
+            $classes = $column_name.' column-'.$column_name.$hidden_class;
708 708
             if ($primary === $column_name) {
709 709
                 $classes .= ' has-row-actions column-primary';
710 710
             }
711 711
 
712
-            $data = ' data-colname="' . wp_strip_all_tags($column_display_name) . '"';
712
+            $data = ' data-colname="'.wp_strip_all_tags($column_display_name).'"';
713 713
 
714 714
             $class = "class='$classes'";
715 715
 
@@ -724,11 +724,11 @@  discard block
 block discarded – undo
724 724
                     $this
725 725
                 );
726 726
                 echo '</th>';
727
-            } elseif (method_exists($this, 'column_' . $column_name)) {
727
+            } elseif (method_exists($this, 'column_'.$column_name)) {
728 728
                 echo "<td $attributes>";
729 729
                 echo apply_filters(
730
-                    'FHEE__EE_Admin_List_Table__single_row_columns__column_' . $column_name . '__column_content',
731
-                    call_user_func(array($this, 'column_' . $column_name), $item),
730
+                    'FHEE__EE_Admin_List_Table__single_row_columns__column_'.$column_name.'__column_content',
731
+                    call_user_func(array($this, 'column_'.$column_name), $item),
732 732
                     $item,
733 733
                     $this
734 734
                 );
@@ -844,9 +844,9 @@  discard block
 block discarded – undo
844 844
         $action_id = ''
845 845
     ) {
846 846
         $content = '';
847
-        $action_class = ! empty($action_class) ? ' class="' . $action_class . '"' : '';
848
-        $action_id = ! empty($action_id) ? ' id="' . $action_id . '"' : '';
849
-        $content .= ! empty($action_container) ? '<' . $action_container . $action_class . $action_id . '>' : '';
847
+        $action_class = ! empty($action_class) ? ' class="'.$action_class.'"' : '';
848
+        $action_id = ! empty($action_id) ? ' id="'.$action_id.'"' : '';
849
+        $content .= ! empty($action_container) ? '<'.$action_container.$action_class.$action_id.'>' : '';
850 850
         try {
851 851
             $content .= apply_filters(
852 852
                 'FHEE__EE_Admin_List_Table___action_string__action_items',
@@ -860,7 +860,7 @@  discard block
 block discarded – undo
860 860
             }
861 861
             $content .= $action_items;
862 862
         }
863
-        $content .= ! empty($action_container) ? '</' . $action_container . '>' : '';
863
+        $content .= ! empty($action_container) ? '</'.$action_container.'>' : '';
864 864
         return $content;
865 865
     }
866 866
 
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Validatable.form.php 1 patch
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -20,151 +20,151 @@
 block discarded – undo
20 20
 abstract class EE_Form_Section_Validatable extends EE_Form_Section_Base
21 21
 {
22 22
 
23
-    /**
24
-     * Array of validation errors in this section. Does not contain validation errors in subsections, however.
25
-     * Those are stored individually on each subsection.
26
-     *
27
-     * @var EE_Validation_Error[]
28
-     */
29
-    protected $_validation_errors = array();
30
-
31
-
32
-
33
-    /**
34
-     * Errors on this form section. Note: EE_Form_Section_Proper
35
-     * has another function for getting all errors in this form section and subsections
36
-     * called get_validation_errors_accumulated
37
-     *
38
-     * @return EE_Validation_Error[]
39
-     */
40
-    public function get_validation_errors()
41
-    {
42
-        return $this->_validation_errors;
43
-    }
44
-
45
-
46
-
47
-    /**
48
-     * returns a comma-separated list of all the validation errors in it.
49
-     * If we want this to be customizable, we may decide to create a strategy for displaying it
50
-     *
51
-     * @return string
52
-     */
53
-    public function get_validation_error_string()
54
-    {
55
-        $validation_error_messages = array();
56
-        if ($this->get_validation_errors()) {
57
-            foreach ($this->get_validation_errors() as $validation_error) {
58
-                if ($validation_error instanceof EE_Validation_Error) {
59
-                    $validation_error_messages[] = $validation_error->getMessage();
60
-                }
61
-            }
62
-        }
63
-        return implode(", ", $validation_error_messages);
64
-    }
65
-
66
-
67
-
68
-    /**
69
-     * Performs validation on this form section (and subsections). Should be called after _normalize()
70
-     *
71
-     * @return boolean of whether or not the form section is valid
72
-     */
73
-    abstract protected function _validate();
74
-
75
-
76
-
77
-    /**
78
-     * Checks if this field has any validation errors
79
-     *
80
-     * @return boolean
81
-     */
82
-    public function is_valid()
83
-    {
84
-        if (count($this->_validation_errors)) {
85
-            return false;
86
-        } else {
87
-            return true;
88
-        }
89
-    }
90
-
91
-
92
-
93
-    /**
94
-     * Sanitizes input for this form section
95
-     *
96
-     * @param array $req_data is the full request data
97
-     * @return boolean of whether a normalization error occurred
98
-     * @throws EE_Validation_Error
99
-     */
100
-    abstract protected function _normalize($req_data);
101
-
102
-
103
-
104
-    /**
105
-     * Creates a validation error from the arguments provided, and adds it to the form section's list.
106
-     * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and
107
-     * adds it to the list of validation errors of errors
108
-     *
109
-     * @param mixed     $message_or_object  internationalized string describing the validation error; or it could be a
110
-     *                                      proper EE_Validation_Error object
111
-     * @param string    $error_code         a short key which can be used to uniquely identify the error
112
-     * @param Exception $previous_exception if there was an exception that caused the error, that exception
113
-     * @return void
114
-     */
115
-    public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null)
116
-    {
117
-        if ($message_or_object instanceof EE_Validation_Error) {
118
-            $validation_error = $message_or_object;
119
-            $validation_error->set_form_section($this);
120
-        } else {
121
-            $validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception);
122
-        }
123
-        $this->_validation_errors[] = $validation_error;
124
-    }
125
-
126
-
127
-
128
-    /**
129
-     * When generating the JS for the jquery validation rules like<br>
130
-     * <code>$( "#myform" ).validate({
131
-     * rules: {
132
-     * password: "required",
133
-     * password_again: {
134
-     * equalTo: "#password"
135
-     * }
136
-     * }
137
-     * });</code>
138
-     * gets the sections like
139
-     * <br><code>password: "required",
140
-     * password_again: {
141
-     * equalTo: "#password"
142
-     * }</code>
143
-     * except we leave it as a PHP object, and leave wp_localize_script to
144
-     * turn it into a JSON object which can be used by the js
145
-     *
146
-     * @return array
147
-     */
148
-    abstract public function get_jquery_validation_rules();
149
-
150
-
151
-
152
-    /**
153
-     * Checks if this form section's data is present in the req data specified
154
-     *
155
-     * @param array $req_data usually post data, if null that's what's used
156
-     * @return boolean
157
-     */
158
-    abstract public function form_data_present_in($req_data = null);
159
-
160
-
161
-
162
-    /**
163
-     * Removes teh sensitive data from this form section (usually done after
164
-     * utilizing the data business function, but before saving it somewhere. Eg,
165
-     * may remove a password from the form after verifying it was correct)
166
-     *
167
-     * @return void
168
-     */
169
-    abstract public function clean_sensitive_data();
23
+	/**
24
+	 * Array of validation errors in this section. Does not contain validation errors in subsections, however.
25
+	 * Those are stored individually on each subsection.
26
+	 *
27
+	 * @var EE_Validation_Error[]
28
+	 */
29
+	protected $_validation_errors = array();
30
+
31
+
32
+
33
+	/**
34
+	 * Errors on this form section. Note: EE_Form_Section_Proper
35
+	 * has another function for getting all errors in this form section and subsections
36
+	 * called get_validation_errors_accumulated
37
+	 *
38
+	 * @return EE_Validation_Error[]
39
+	 */
40
+	public function get_validation_errors()
41
+	{
42
+		return $this->_validation_errors;
43
+	}
44
+
45
+
46
+
47
+	/**
48
+	 * returns a comma-separated list of all the validation errors in it.
49
+	 * If we want this to be customizable, we may decide to create a strategy for displaying it
50
+	 *
51
+	 * @return string
52
+	 */
53
+	public function get_validation_error_string()
54
+	{
55
+		$validation_error_messages = array();
56
+		if ($this->get_validation_errors()) {
57
+			foreach ($this->get_validation_errors() as $validation_error) {
58
+				if ($validation_error instanceof EE_Validation_Error) {
59
+					$validation_error_messages[] = $validation_error->getMessage();
60
+				}
61
+			}
62
+		}
63
+		return implode(", ", $validation_error_messages);
64
+	}
65
+
66
+
67
+
68
+	/**
69
+	 * Performs validation on this form section (and subsections). Should be called after _normalize()
70
+	 *
71
+	 * @return boolean of whether or not the form section is valid
72
+	 */
73
+	abstract protected function _validate();
74
+
75
+
76
+
77
+	/**
78
+	 * Checks if this field has any validation errors
79
+	 *
80
+	 * @return boolean
81
+	 */
82
+	public function is_valid()
83
+	{
84
+		if (count($this->_validation_errors)) {
85
+			return false;
86
+		} else {
87
+			return true;
88
+		}
89
+	}
90
+
91
+
92
+
93
+	/**
94
+	 * Sanitizes input for this form section
95
+	 *
96
+	 * @param array $req_data is the full request data
97
+	 * @return boolean of whether a normalization error occurred
98
+	 * @throws EE_Validation_Error
99
+	 */
100
+	abstract protected function _normalize($req_data);
101
+
102
+
103
+
104
+	/**
105
+	 * Creates a validation error from the arguments provided, and adds it to the form section's list.
106
+	 * If such an EE_Validation_Error object is passed in as the first arg, simply sets this as its form section, and
107
+	 * adds it to the list of validation errors of errors
108
+	 *
109
+	 * @param mixed     $message_or_object  internationalized string describing the validation error; or it could be a
110
+	 *                                      proper EE_Validation_Error object
111
+	 * @param string    $error_code         a short key which can be used to uniquely identify the error
112
+	 * @param Exception $previous_exception if there was an exception that caused the error, that exception
113
+	 * @return void
114
+	 */
115
+	public function add_validation_error($message_or_object, $error_code = null, $previous_exception = null)
116
+	{
117
+		if ($message_or_object instanceof EE_Validation_Error) {
118
+			$validation_error = $message_or_object;
119
+			$validation_error->set_form_section($this);
120
+		} else {
121
+			$validation_error = new EE_Validation_Error($message_or_object, $error_code, $this, $previous_exception);
122
+		}
123
+		$this->_validation_errors[] = $validation_error;
124
+	}
125
+
126
+
127
+
128
+	/**
129
+	 * When generating the JS for the jquery validation rules like<br>
130
+	 * <code>$( "#myform" ).validate({
131
+	 * rules: {
132
+	 * password: "required",
133
+	 * password_again: {
134
+	 * equalTo: "#password"
135
+	 * }
136
+	 * }
137
+	 * });</code>
138
+	 * gets the sections like
139
+	 * <br><code>password: "required",
140
+	 * password_again: {
141
+	 * equalTo: "#password"
142
+	 * }</code>
143
+	 * except we leave it as a PHP object, and leave wp_localize_script to
144
+	 * turn it into a JSON object which can be used by the js
145
+	 *
146
+	 * @return array
147
+	 */
148
+	abstract public function get_jquery_validation_rules();
149
+
150
+
151
+
152
+	/**
153
+	 * Checks if this form section's data is present in the req data specified
154
+	 *
155
+	 * @param array $req_data usually post data, if null that's what's used
156
+	 * @return boolean
157
+	 */
158
+	abstract public function form_data_present_in($req_data = null);
159
+
160
+
161
+
162
+	/**
163
+	 * Removes teh sensitive data from this form section (usually done after
164
+	 * utilizing the data business function, but before saving it somewhere. Eg,
165
+	 * may remove a password from the form after verifying it was correct)
166
+	 *
167
+	 * @return void
168
+	 */
169
+	abstract public function clean_sensitive_data();
170 170
 }
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 1 patch
Indentation   +606 added lines, -606 removed lines patch added patch discarded remove patch
@@ -14,610 +14,610 @@
 block discarded – undo
14 14
 class EEG_Paypal_Pro extends EE_Onsite_Gateway
15 15
 {
16 16
 
17
-    /**
18
-     * @var $_paypal_api_username string
19
-     */
20
-    protected $_api_username = null;
21
-
22
-    /**
23
-     * @var $_api_password string
24
-     */
25
-    protected $_api_password = null;
26
-
27
-    /**
28
-     * @var $_api_signature string
29
-     */
30
-    protected $_api_signature = null;
31
-
32
-    /**
33
-     * @var $_credit_card_types array with the keys for credit card types accepted on this account
34
-     */
35
-    protected $_credit_card_types    = null;
36
-
37
-    protected $_currencies_supported = array(
38
-        'USD',
39
-        'GBP',
40
-        'CAD',
41
-        'AUD',
42
-        'BRL',
43
-        'CHF',
44
-        'CZK',
45
-        'DKK',
46
-        'EUR',
47
-        'HKD',
48
-        'HUF',
49
-        'ILS',
50
-        'JPY',
51
-        'MXN',
52
-        'MYR',
53
-        'NOK',
54
-        'NZD',
55
-        'PHP',
56
-        'PLN',
57
-        'SEK',
58
-        'SGD',
59
-        'THB',
60
-        'TRY',
61
-        'TWD',
62
-        'RUB',
63
-        'INR',
64
-    );
65
-
66
-
67
-
68
-    /**
69
-     * @param EEI_Payment $payment
70
-     * @param array       $billing_info {
71
-     * @type string $credit_card
72
-     * @type string $credit_card_type
73
-     * @type string $exp_month always 2 characters
74
-     * @type string $exp_year always 4 characters
75
-     * @type string $cvv
76
-     * }
77
-     * @see      parent::do_direct_payment for more info
78
-     * @return EE_Payment|EEI_Payment
79
-     * @throws EE_Error
80
-     */
81
-    public function do_direct_payment($payment, $billing_info = null)
82
-    {
83
-        $transaction = $payment->transaction();
84
-        if (! $transaction instanceof EEI_Transaction) {
85
-            throw new EE_Error(
86
-                esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
87
-            );
88
-        }
89
-        $primary_registrant = $transaction->primary_registration();
90
-        if (! $primary_registrant instanceof EEI_Registration) {
91
-            throw new EE_Error(
92
-                esc_html__(
93
-                    'No primary registration on transaction while paying with PayPal Pro.',
94
-                    'event_espresso'
95
-                )
96
-            );
97
-        }
98
-        $attendee = $primary_registrant->attendee();
99
-        if (! $attendee instanceof EEI_Attendee) {
100
-            throw new EE_Error(
101
-                esc_html__(
102
-                    'No attendee on primary registration while paying with PayPal Pro.',
103
-                    'event_espresso'
104
-                )
105
-            );
106
-        }
107
-        $gateway_formatter = $this->_get_gateway_formatter();
108
-        $order_description = substr($gateway_formatter->formatOrderDescription($payment), 0, 127);
109
-        // charge for the full amount. Show itemized list
110
-        if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
111
-            $item_num = 1;
112
-            $total_line_item = $transaction->total_line_item();
113
-            $order_items = array();
114
-            foreach ($total_line_item->get_items() as $line_item) {
115
-                // ignore line items with a quantity of 0
116
-                if ($line_item->quantity() == 0) {
117
-                    continue;
118
-                }
119
-                // For percent items, whose unit_price is 0, use the total instead.
120
-                if ($line_item->is_percent()) {
121
-                    $unit_price = $line_item->total();
122
-                    $line_item_quantity = 1;
123
-                } else {
124
-                    $unit_price = $line_item->unit_price();
125
-                    $line_item_quantity = $line_item->quantity();
126
-                }
127
-                $item = array(
128
-                    // Item Name.  127 char max.
129
-                    'l_name'                 => substr(
130
-                        $gateway_formatter->formatLineItemName($line_item, $payment),
131
-                        0,
132
-                        127
133
-                    ),
134
-                    // Item description.  127 char max.
135
-                    'l_desc'                 => substr(
136
-                        $gateway_formatter->formatLineItemDesc($line_item, $payment),
137
-                        0,
138
-                        127
139
-                    ),
140
-                    // Cost of individual item.
141
-                    'l_amt'                  => $unit_price,
142
-                    // Item Number.  127 char max.
143
-                    'l_number'               => $item_num++,
144
-                    // Item quantity.  Must be any positive integer.
145
-                    'l_qty'                  => $line_item_quantity,
146
-                    // Item's sales tax amount.
147
-                    'l_taxamt'               => '',
148
-                    // eBay auction number of item.
149
-                    'l_ebayitemnumber'       => '',
150
-                    // eBay transaction ID of purchased item.
151
-                    'l_ebayitemauctiontxnid' => '',
152
-                    // eBay order ID for the item.
153
-                    'l_ebayitemorderid'      => '',
154
-                );
155
-                // add to array of all items
156
-                array_push($order_items, $item);
157
-            }
158
-            $item_amount = $total_line_item->get_items_total();
159
-            $tax_amount = $total_line_item->get_total_tax();
160
-        } else {
161
-            $order_items = array();
162
-            $item_amount = $payment->amount();
163
-            $tax_amount = 0;
164
-            array_push($order_items, array(
165
-                // Item Name.  127 char max.
166
-                'l_name'   => substr(
167
-                    $gateway_formatter->formatPartialPaymentLineItemName($payment),
168
-                    0,
169
-                    127
170
-                ),
171
-                // Item description.  127 char max.
172
-                'l_desc'   => substr(
173
-                    $gateway_formatter->formatPartialPaymentLineItemDesc($payment),
174
-                    0,
175
-                    127
176
-                ),
177
-                // Cost of individual item.
178
-                'l_amt'    => $payment->amount(),
179
-                // Item Number.  127 char max.
180
-                'l_number' => 1,
181
-                // Item quantity.  Must be any positive integer.
182
-                'l_qty'    => 1,
183
-            ));
184
-        }
185
-
186
-
187
-        /** @var RequestInterface $request */
188
-        $request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
189
-        // Populate data arrays with order data.
190
-        $DPFields = array(
191
-            // How you want to obtain payment ?
192
-            // Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
193
-            // Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
194
-            'paymentaction'    => 'Sale',
195
-            // Required.  IP address of the payer's browser.
196
-            'ipaddress'        => $request->ipAddress(),
197
-            // Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
198
-            'returnfmfdetails' => '1',
199
-        );
200
-        $CCDetails = array(
201
-            // Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
202
-            // If Maestro or Solo, the currency code must be GBP.
203
-            //  In addition, either start date or issue number must be specified.
204
-            'creditcardtype' => $billing_info['credit_card_type'],
205
-            // Required.  Credit card number.  No spaces or punctuation.
206
-            'acct'           => $billing_info['credit_card'],
207
-            // Required.  Credit card expiration date.  Format is MMYYYY
208
-            'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
209
-            // Requirements determined by your PayPal account settings.  Security digits for credit card.
210
-            'cvv2'           => $billing_info['cvv'],
211
-        );
212
-        $PayerInfo = array(
213
-            // Email address of payer.
214
-            'email'       => $billing_info['email'],
215
-            // Unique PayPal customer ID for payer.
216
-            'payerid'     => '',
217
-            // Status of payer.  Values are verified or unverified
218
-            'payerstatus' => '',
219
-            // Payer's business name.
220
-            'business'    => '',
221
-        );
222
-        $PayerName = array(
223
-            // Payer's salutation.  20 char max.
224
-            'salutation' => '',
225
-            // Payer's first name.  25 char max.
226
-            'firstname'  => substr($billing_info['first_name'], 0, 25),
227
-            // Payer's middle name.  25 char max.
228
-            'middlename' => '',
229
-            // Payer's last name.  25 char max.
230
-            'lastname'   => substr($billing_info['last_name'], 0, 25),
231
-            // Payer's suffix.  12 char max.
232
-            'suffix'     => '',
233
-        );
234
-        $BillingAddress = array(
235
-            // Required.  First street address.
236
-            'street'      => $billing_info['address'],
237
-            // Second street address.
238
-            'street2'     => $billing_info['address2'],
239
-            // Required.  Name of City.
240
-            'city'        => $billing_info['city'],
241
-            // Required. Name of State or Province.
242
-            'state'       => substr($billing_info['state'], 0, 40),
243
-            // Required.  Country code.
244
-            'countrycode' => $billing_info['country'],
245
-            // Required.  Postal code of payer.
246
-            'zip'         => $billing_info['zip'],
247
-        );
248
-        // check if the registration info contains the needed fields for paypal pro
249
-        // (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
250
-        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
251
-            $use_registration_address_info = true;
252
-        } else {
253
-            $use_registration_address_info = false;
254
-        }
255
-        // so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
256
-        // If not, use the billing info again
257
-        $ShippingAddress = array(
258
-            'shiptoname'     => substr($use_registration_address_info
259
-                ? $attendee->full_name()
260
-                : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
261
-            'shiptostreet'   => substr($use_registration_address_info
262
-                ? $attendee->address()
263
-                : $billing_info['address'], 0, 100),
264
-            'shiptostreet2'  => substr($use_registration_address_info
265
-                ? $attendee->address2() : $billing_info['address2'], 0, 100),
266
-            'shiptocity'     => substr($use_registration_address_info
267
-                ? $attendee->city()
268
-                : $billing_info['city'], 0, 40),
269
-            'shiptostate'          => substr($use_registration_address_info
270
-                ? $attendee->state_name()
271
-                : $billing_info['state'], 0, 40),
272
-            'shiptocountry'  => $use_registration_address_info
273
-                ? $attendee->country_ID()
274
-                : $billing_info['country'],
275
-            'shiptozip'      => substr($use_registration_address_info
276
-                ? $attendee->zip()
277
-                : $billing_info['zip'], 0, 20),
278
-            'shiptophonenum' => substr($use_registration_address_info
279
-                ? $attendee->phone()
280
-                : $billing_info['phone'], 0, 20),
281
-        );
282
-        $PaymentDetails = array(
283
-            // Required.  Total amount of order, including shipping, handling, and tax.
284
-            'amt'          => $gateway_formatter->formatCurrency($payment->amount()),
285
-            // Required.  Three-letter currency code.  Default is USD.
286
-            'currencycode' => $payment->currency_code(),
287
-            // Required if you include itemized cart details. (L_AMTn, etc.)
288
-            // Subtotal of items not including S&H, or tax.
289
-            'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
290
-            // Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
291
-            'shippingamt'  => '',
292
-            // Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
293
-            'handlingamt'  => '',
294
-            // Required if you specify itemized cart tax details.
295
-            // Sum of tax for all items on the order.  Total sales tax.
296
-            'taxamt'       => $gateway_formatter->formatCurrency($tax_amount),
297
-            // Description of the order the customer is purchasing.  127 char max.
298
-            'desc'         => $order_description,
299
-            // Free-form field for your own use.  256 char max.
300
-            'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
301
-            // Your own invoice or tracking number
302
-            'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
303
-            // URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
304
-            'notifyurl'    => '',
305
-            'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
306
-        );
307
-        // Wrap all data arrays into a single, "master" array which will be passed into the class function.
308
-        $PayPalRequestData = array(
309
-            'DPFields'        => $DPFields,
310
-            'CCDetails'       => $CCDetails,
311
-            'PayerInfo'       => $PayerInfo,
312
-            'PayerName'       => $PayerName,
313
-            'BillingAddress'  => $BillingAddress,
314
-            'ShippingAddress' => $ShippingAddress,
315
-            'PaymentDetails'  => $PaymentDetails,
316
-            'OrderItems'      => $order_items,
317
-        );
318
-        $this->_log_clean_request($PayPalRequestData, $payment);
319
-        try {
320
-            $PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
321
-            // remove PCI-sensitive data so it doesn't get stored
322
-            $PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
323
-            if (isset($PayPalResult['L_ERRORCODE0']) && $PayPalResult['L_ERRORCODE0'] === '10002') {
324
-                $message = esc_html__('PayPal did not accept your API username, password, or signature. Please double-check these credentials and if debug mode is on.', 'event_espresso');
325
-            } elseif (isset($PayPalResult['L_LONGMESSAGE0'])) {
326
-                $message = $PayPalResult['L_LONGMESSAGE0'];
327
-            } else {
328
-                $message = $PayPalResult['ACK'];
329
-            }
330
-            if (empty($PayPalResult['RAWRESPONSE'])) {
331
-                $payment->set_status($this->_pay_model->failed_status());
332
-                $payment->set_gateway_response(esc_html__('No response received from Paypal Pro', 'event_espresso'));
333
-                $payment->set_details($PayPalResult);
334
-            } else {
335
-                if ($this->_APICallSuccessful($PayPalResult)) {
336
-                    $payment->set_status($this->_pay_model->approved_status());
337
-                } else {
338
-                    $payment->set_status($this->_pay_model->declined_status());
339
-                }
340
-                // make sure we interpret the AMT as a float, not an international string
341
-                // (where periods are thousand separators)
342
-                $payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
343
-                $payment->set_gateway_response($message);
344
-                $payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
345
-                    ? $PayPalResult['TRANSACTIONID']
346
-                    : null);
347
-                $primary_registration_code = $primary_registrant instanceof EE_Registration
348
-                    ? $primary_registrant->reg_code()
349
-                    : '';
350
-                $payment->set_extra_accntng($primary_registration_code);
351
-                $payment->set_details($PayPalResult);
352
-            }
353
-        } catch (Exception $e) {
354
-            $payment->set_status($this->_pay_model->failed_status());
355
-            $payment->set_gateway_response($e->getMessage());
356
-        }
357
-        // $payment->set_status( $this->_pay_model->declined_status() );
358
-        // $payment->set_gateway_response( '' );
359
-        return $payment;
360
-    }
361
-
362
-
363
-
364
-    /**
365
-     * CLeans out sensitive CC data and then logs it, and returns the cleaned request
366
-     *
367
-     * @param array       $request
368
-     * @param EEI_Payment $payment
369
-     * @return void
370
-     */
371
-    private function _log_clean_request($request, $payment)
372
-    {
373
-        $cleaned_request_data = $request;
374
-        unset($cleaned_request_data['CCDetails']['acct']);
375
-        unset($cleaned_request_data['CCDetails']['cvv2']);
376
-        unset($cleaned_request_data['CCDetails']['expdate']);
377
-        $this->log(array('Paypal Request' => $cleaned_request_data), $payment);
378
-    }
379
-
380
-
381
-
382
-    /**
383
-     * Cleans the response, logs it, and returns it
384
-     *
385
-     * @param array       $response
386
-     * @param EEI_Payment $payment
387
-     * @return array cleaned
388
-     */
389
-    private function _log_clean_response($response, $payment)
390
-    {
391
-        unset($response['REQUESTDATA']['CREDITCARDTYPE']);
392
-        unset($response['REQUESTDATA']['ACCT']);
393
-        unset($response['REQUESTDATA']['EXPDATE']);
394
-        unset($response['REQUESTDATA']['CVV2']);
395
-        unset($response['RAWREQUEST']);
396
-        $this->log(array('Paypal Response' => $response), $payment);
397
-        return $response;
398
-    }
399
-
400
-
401
-
402
-    /**
403
-     * @param $DataArray
404
-     * @return array
405
-     */
406
-    private function prep_and_curl_request($DataArray)
407
-    {
408
-        // Create empty holders for each portion of the NVP string
409
-        $DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
410
-        $CCDetailsNVP = '';
411
-        $PayerInfoNVP = '';
412
-        $PayerNameNVP = '';
413
-        $BillingAddressNVP = '';
414
-        $ShippingAddressNVP = '';
415
-        $PaymentDetailsNVP = '';
416
-        $OrderItemsNVP = '';
417
-        $Secure3DNVP = '';
418
-        // DP Fields
419
-        $DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
420
-        foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
421
-            $DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
422
-        }
423
-        // CC Details Fields
424
-        $CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
425
-        foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
426
-            $CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
427
-        }
428
-        // PayerInfo Type Fields
429
-        $PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
430
-        foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
431
-            $PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
432
-        }
433
-        // Payer Name Fields
434
-        $PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
435
-        foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
436
-            $PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
437
-        }
438
-        // Address Fields (Billing)
439
-        $BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
440
-        foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
441
-            $BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
442
-        }
443
-        // Payment Details Type Fields
444
-        $PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
445
-        foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
446
-            $PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
447
-        }
448
-        // Payment Details Item Type Fields
449
-        $OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
450
-        $n = 0;
451
-        foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
452
-            $CurrentItem = $OrderItems[ $OrderItemsVar ];
453
-            foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
454
-                $OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
455
-            }
456
-            $n++;
457
-        }
458
-        // Ship To Address Fields
459
-        $ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
460
-        foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
461
-            $ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
462
-        }
463
-        // 3D Secure Fields
464
-        $Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
465
-        foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
466
-            $Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
467
-        }
468
-        // Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
469
-        $NVPRequest = 'USER='
470
-                      . $this->_api_username
471
-                      . '&PWD='
472
-                      . $this->_api_password
473
-                      . '&VERSION=64.0'
474
-                      . '&SIGNATURE='
475
-                      . $this->_api_signature
476
-                      . $DPFieldsNVP
477
-                      . $CCDetailsNVP
478
-                      . $PayerInfoNVP
479
-                      . $PayerNameNVP
480
-                      . $BillingAddressNVP
481
-                      . $PaymentDetailsNVP
482
-                      . $OrderItemsNVP
483
-                      . $ShippingAddressNVP
484
-                      . $Secure3DNVP;
485
-        $NVPResponse = $this->_CURLRequest($NVPRequest);
486
-        $NVPRequestArray = $this->_NVPToArray($NVPRequest);
487
-        $NVPResponseArray = $this->_NVPToArray($NVPResponse);
488
-        $Errors = $this->_GetErrors($NVPResponseArray);
489
-        $NVPResponseArray['ERRORS'] = $Errors;
490
-        $NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
491
-        $NVPResponseArray['RAWREQUEST'] = $NVPRequest;
492
-        $NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
493
-        return $NVPResponseArray;
494
-    }
495
-
496
-
497
-
498
-    /**
499
-     * @param $Request
500
-     * @return mixed
501
-     */
502
-    private function _CURLRequest($Request)
503
-    {
504
-        $EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
505
-        $curl = curl_init();
506
-        curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
507
-        curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
508
-        curl_setopt($curl, CURLOPT_TIMEOUT, 60);
509
-        curl_setopt($curl, CURLOPT_URL, $EndPointURL);
510
-        curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
511
-        curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
512
-        curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
513
-        // execute the curl POST
514
-        $Response = curl_exec($curl);
515
-        curl_close($curl);
516
-        return $Response;
517
-    }
518
-
519
-
520
-
521
-    /**
522
-     * @param $NVPString
523
-     * @return array
524
-     */
525
-    private function _NVPToArray($NVPString)
526
-    {
527
-        // prepare responses into array
528
-        $proArray = array();
529
-        while (strlen($NVPString)) {
530
-            // name
531
-            $keypos = strpos($NVPString, '=');
532
-            $keyval = substr($NVPString, 0, $keypos);
533
-            // value
534
-            $valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
535
-            $valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
536
-            // decoding the response
537
-            $proArray[ $keyval ] = urldecode($valval);
538
-            $NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
539
-        }
540
-        return $proArray;
541
-    }
542
-
543
-
544
-
545
-    /**
546
-     * @param array $PayPalResult
547
-     * @return bool
548
-     */
549
-    private function _APICallSuccessful($PayPalResult)
550
-    {
551
-        $approved = false;
552
-        // check main response message from PayPal
553
-        if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
554
-            $ack = strtoupper($PayPalResult['ACK']);
555
-            $approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
556
-        }
557
-        return $approved;
558
-    }
559
-
560
-
561
-
562
-    /**
563
-     * @param $DataArray
564
-     * @return array
565
-     */
566
-    private function _GetErrors($DataArray)
567
-    {
568
-        $Errors = array();
569
-        $n = 0;
570
-        while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
571
-            $LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
572
-            $LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
573
-                ? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
574
-                : '';
575
-            $LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
576
-                ? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
577
-                : '';
578
-            $LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
579
-                ? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
580
-                : '';
581
-            $CurrentItem = array(
582
-                'L_ERRORCODE'    => $LErrorCode,
583
-                'L_SHORTMESSAGE' => $LShortMessage,
584
-                'L_LONGMESSAGE'  => $LLongMessage,
585
-                'L_SEVERITYCODE' => $LSeverityCode,
586
-            );
587
-            array_push($Errors, $CurrentItem);
588
-            $n++;
589
-        }
590
-        return $Errors;
591
-    }
592
-
593
-
594
-
595
-    /**
596
-     *        nothing to see here...  move along....
597
-     *
598
-     * @access protected
599
-     * @param $Errors
600
-     * @return string
601
-     */
602
-    private function _DisplayErrors($Errors)
603
-    {
604
-        $error = '';
605
-        foreach ($Errors as $ErrorVar => $ErrorVal) {
606
-            $CurrentError = $Errors[ $ErrorVar ];
607
-            foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
608
-                $CurrentVarName = '';
609
-                if ($CurrentErrorVar == 'L_ERRORCODE') {
610
-                    $CurrentVarName = 'Error Code';
611
-                } elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
612
-                    $CurrentVarName = 'Short Message';
613
-                } elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
614
-                    $CurrentVarName = 'Long Message';
615
-                } elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
616
-                    $CurrentVarName = 'Severity Code';
617
-                }
618
-                $error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
619
-            }
620
-        }
621
-        return $error;
622
-    }
17
+	/**
18
+	 * @var $_paypal_api_username string
19
+	 */
20
+	protected $_api_username = null;
21
+
22
+	/**
23
+	 * @var $_api_password string
24
+	 */
25
+	protected $_api_password = null;
26
+
27
+	/**
28
+	 * @var $_api_signature string
29
+	 */
30
+	protected $_api_signature = null;
31
+
32
+	/**
33
+	 * @var $_credit_card_types array with the keys for credit card types accepted on this account
34
+	 */
35
+	protected $_credit_card_types    = null;
36
+
37
+	protected $_currencies_supported = array(
38
+		'USD',
39
+		'GBP',
40
+		'CAD',
41
+		'AUD',
42
+		'BRL',
43
+		'CHF',
44
+		'CZK',
45
+		'DKK',
46
+		'EUR',
47
+		'HKD',
48
+		'HUF',
49
+		'ILS',
50
+		'JPY',
51
+		'MXN',
52
+		'MYR',
53
+		'NOK',
54
+		'NZD',
55
+		'PHP',
56
+		'PLN',
57
+		'SEK',
58
+		'SGD',
59
+		'THB',
60
+		'TRY',
61
+		'TWD',
62
+		'RUB',
63
+		'INR',
64
+	);
65
+
66
+
67
+
68
+	/**
69
+	 * @param EEI_Payment $payment
70
+	 * @param array       $billing_info {
71
+	 * @type string $credit_card
72
+	 * @type string $credit_card_type
73
+	 * @type string $exp_month always 2 characters
74
+	 * @type string $exp_year always 4 characters
75
+	 * @type string $cvv
76
+	 * }
77
+	 * @see      parent::do_direct_payment for more info
78
+	 * @return EE_Payment|EEI_Payment
79
+	 * @throws EE_Error
80
+	 */
81
+	public function do_direct_payment($payment, $billing_info = null)
82
+	{
83
+		$transaction = $payment->transaction();
84
+		if (! $transaction instanceof EEI_Transaction) {
85
+			throw new EE_Error(
86
+				esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso')
87
+			);
88
+		}
89
+		$primary_registrant = $transaction->primary_registration();
90
+		if (! $primary_registrant instanceof EEI_Registration) {
91
+			throw new EE_Error(
92
+				esc_html__(
93
+					'No primary registration on transaction while paying with PayPal Pro.',
94
+					'event_espresso'
95
+				)
96
+			);
97
+		}
98
+		$attendee = $primary_registrant->attendee();
99
+		if (! $attendee instanceof EEI_Attendee) {
100
+			throw new EE_Error(
101
+				esc_html__(
102
+					'No attendee on primary registration while paying with PayPal Pro.',
103
+					'event_espresso'
104
+				)
105
+			);
106
+		}
107
+		$gateway_formatter = $this->_get_gateway_formatter();
108
+		$order_description = substr($gateway_formatter->formatOrderDescription($payment), 0, 127);
109
+		// charge for the full amount. Show itemized list
110
+		if ($this->_money->compare_floats($payment->amount(), $transaction->total(), '==')) {
111
+			$item_num = 1;
112
+			$total_line_item = $transaction->total_line_item();
113
+			$order_items = array();
114
+			foreach ($total_line_item->get_items() as $line_item) {
115
+				// ignore line items with a quantity of 0
116
+				if ($line_item->quantity() == 0) {
117
+					continue;
118
+				}
119
+				// For percent items, whose unit_price is 0, use the total instead.
120
+				if ($line_item->is_percent()) {
121
+					$unit_price = $line_item->total();
122
+					$line_item_quantity = 1;
123
+				} else {
124
+					$unit_price = $line_item->unit_price();
125
+					$line_item_quantity = $line_item->quantity();
126
+				}
127
+				$item = array(
128
+					// Item Name.  127 char max.
129
+					'l_name'                 => substr(
130
+						$gateway_formatter->formatLineItemName($line_item, $payment),
131
+						0,
132
+						127
133
+					),
134
+					// Item description.  127 char max.
135
+					'l_desc'                 => substr(
136
+						$gateway_formatter->formatLineItemDesc($line_item, $payment),
137
+						0,
138
+						127
139
+					),
140
+					// Cost of individual item.
141
+					'l_amt'                  => $unit_price,
142
+					// Item Number.  127 char max.
143
+					'l_number'               => $item_num++,
144
+					// Item quantity.  Must be any positive integer.
145
+					'l_qty'                  => $line_item_quantity,
146
+					// Item's sales tax amount.
147
+					'l_taxamt'               => '',
148
+					// eBay auction number of item.
149
+					'l_ebayitemnumber'       => '',
150
+					// eBay transaction ID of purchased item.
151
+					'l_ebayitemauctiontxnid' => '',
152
+					// eBay order ID for the item.
153
+					'l_ebayitemorderid'      => '',
154
+				);
155
+				// add to array of all items
156
+				array_push($order_items, $item);
157
+			}
158
+			$item_amount = $total_line_item->get_items_total();
159
+			$tax_amount = $total_line_item->get_total_tax();
160
+		} else {
161
+			$order_items = array();
162
+			$item_amount = $payment->amount();
163
+			$tax_amount = 0;
164
+			array_push($order_items, array(
165
+				// Item Name.  127 char max.
166
+				'l_name'   => substr(
167
+					$gateway_formatter->formatPartialPaymentLineItemName($payment),
168
+					0,
169
+					127
170
+				),
171
+				// Item description.  127 char max.
172
+				'l_desc'   => substr(
173
+					$gateway_formatter->formatPartialPaymentLineItemDesc($payment),
174
+					0,
175
+					127
176
+				),
177
+				// Cost of individual item.
178
+				'l_amt'    => $payment->amount(),
179
+				// Item Number.  127 char max.
180
+				'l_number' => 1,
181
+				// Item quantity.  Must be any positive integer.
182
+				'l_qty'    => 1,
183
+			));
184
+		}
185
+
186
+
187
+		/** @var RequestInterface $request */
188
+		$request = LoaderFactory::getLoader()->getShared(RequestInterface::class);
189
+		// Populate data arrays with order data.
190
+		$DPFields = array(
191
+			// How you want to obtain payment ?
192
+			// Authorization indicates the payment is a basic auth subject to settlement with Auth & Capture.
193
+			// Sale indicates that this is a final sale for which you are requesting payment.  Default is Sale.
194
+			'paymentaction'    => 'Sale',
195
+			// Required.  IP address of the payer's browser.
196
+			'ipaddress'        => $request->ipAddress(),
197
+			// Flag to determine whether you want the results returned by FMF.  1 or 0.  Default is 0.
198
+			'returnfmfdetails' => '1',
199
+		);
200
+		$CCDetails = array(
201
+			// Required. Type of credit card.  Visa, MasterCard, Discover, Amex, Maestro, Solo.
202
+			// If Maestro or Solo, the currency code must be GBP.
203
+			//  In addition, either start date or issue number must be specified.
204
+			'creditcardtype' => $billing_info['credit_card_type'],
205
+			// Required.  Credit card number.  No spaces or punctuation.
206
+			'acct'           => $billing_info['credit_card'],
207
+			// Required.  Credit card expiration date.  Format is MMYYYY
208
+			'expdate'        => $billing_info['exp_month'] . $billing_info['exp_year'],
209
+			// Requirements determined by your PayPal account settings.  Security digits for credit card.
210
+			'cvv2'           => $billing_info['cvv'],
211
+		);
212
+		$PayerInfo = array(
213
+			// Email address of payer.
214
+			'email'       => $billing_info['email'],
215
+			// Unique PayPal customer ID for payer.
216
+			'payerid'     => '',
217
+			// Status of payer.  Values are verified or unverified
218
+			'payerstatus' => '',
219
+			// Payer's business name.
220
+			'business'    => '',
221
+		);
222
+		$PayerName = array(
223
+			// Payer's salutation.  20 char max.
224
+			'salutation' => '',
225
+			// Payer's first name.  25 char max.
226
+			'firstname'  => substr($billing_info['first_name'], 0, 25),
227
+			// Payer's middle name.  25 char max.
228
+			'middlename' => '',
229
+			// Payer's last name.  25 char max.
230
+			'lastname'   => substr($billing_info['last_name'], 0, 25),
231
+			// Payer's suffix.  12 char max.
232
+			'suffix'     => '',
233
+		);
234
+		$BillingAddress = array(
235
+			// Required.  First street address.
236
+			'street'      => $billing_info['address'],
237
+			// Second street address.
238
+			'street2'     => $billing_info['address2'],
239
+			// Required.  Name of City.
240
+			'city'        => $billing_info['city'],
241
+			// Required. Name of State or Province.
242
+			'state'       => substr($billing_info['state'], 0, 40),
243
+			// Required.  Country code.
244
+			'countrycode' => $billing_info['country'],
245
+			// Required.  Postal code of payer.
246
+			'zip'         => $billing_info['zip'],
247
+		);
248
+		// check if the registration info contains the needed fields for paypal pro
249
+		// (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
250
+		if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
251
+			$use_registration_address_info = true;
252
+		} else {
253
+			$use_registration_address_info = false;
254
+		}
255
+		// so if the attendee has enough data to fill out PayPal Pro's shipping info, use it.
256
+		// If not, use the billing info again
257
+		$ShippingAddress = array(
258
+			'shiptoname'     => substr($use_registration_address_info
259
+				? $attendee->full_name()
260
+				: $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
261
+			'shiptostreet'   => substr($use_registration_address_info
262
+				? $attendee->address()
263
+				: $billing_info['address'], 0, 100),
264
+			'shiptostreet2'  => substr($use_registration_address_info
265
+				? $attendee->address2() : $billing_info['address2'], 0, 100),
266
+			'shiptocity'     => substr($use_registration_address_info
267
+				? $attendee->city()
268
+				: $billing_info['city'], 0, 40),
269
+			'shiptostate'          => substr($use_registration_address_info
270
+				? $attendee->state_name()
271
+				: $billing_info['state'], 0, 40),
272
+			'shiptocountry'  => $use_registration_address_info
273
+				? $attendee->country_ID()
274
+				: $billing_info['country'],
275
+			'shiptozip'      => substr($use_registration_address_info
276
+				? $attendee->zip()
277
+				: $billing_info['zip'], 0, 20),
278
+			'shiptophonenum' => substr($use_registration_address_info
279
+				? $attendee->phone()
280
+				: $billing_info['phone'], 0, 20),
281
+		);
282
+		$PaymentDetails = array(
283
+			// Required.  Total amount of order, including shipping, handling, and tax.
284
+			'amt'          => $gateway_formatter->formatCurrency($payment->amount()),
285
+			// Required.  Three-letter currency code.  Default is USD.
286
+			'currencycode' => $payment->currency_code(),
287
+			// Required if you include itemized cart details. (L_AMTn, etc.)
288
+			// Subtotal of items not including S&H, or tax.
289
+			'itemamt'      => $gateway_formatter->formatCurrency($item_amount),//
290
+			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
291
+			'shippingamt'  => '',
292
+			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
293
+			'handlingamt'  => '',
294
+			// Required if you specify itemized cart tax details.
295
+			// Sum of tax for all items on the order.  Total sales tax.
296
+			'taxamt'       => $gateway_formatter->formatCurrency($tax_amount),
297
+			// Description of the order the customer is purchasing.  127 char max.
298
+			'desc'         => $order_description,
299
+			// Free-form field for your own use.  256 char max.
300
+			'custom'       => $primary_registrant ? $primary_registrant->ID() : '',
301
+			// Your own invoice or tracking number
302
+			'invnum'       => wp_generate_password(12, false),// $transaction->ID(),
303
+			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
304
+			'notifyurl'    => '',
305
+			'buttonsource' => 'EventEspresso_SP',// EE will blow up if you change this
306
+		);
307
+		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
308
+		$PayPalRequestData = array(
309
+			'DPFields'        => $DPFields,
310
+			'CCDetails'       => $CCDetails,
311
+			'PayerInfo'       => $PayerInfo,
312
+			'PayerName'       => $PayerName,
313
+			'BillingAddress'  => $BillingAddress,
314
+			'ShippingAddress' => $ShippingAddress,
315
+			'PaymentDetails'  => $PaymentDetails,
316
+			'OrderItems'      => $order_items,
317
+		);
318
+		$this->_log_clean_request($PayPalRequestData, $payment);
319
+		try {
320
+			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
321
+			// remove PCI-sensitive data so it doesn't get stored
322
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
323
+			if (isset($PayPalResult['L_ERRORCODE0']) && $PayPalResult['L_ERRORCODE0'] === '10002') {
324
+				$message = esc_html__('PayPal did not accept your API username, password, or signature. Please double-check these credentials and if debug mode is on.', 'event_espresso');
325
+			} elseif (isset($PayPalResult['L_LONGMESSAGE0'])) {
326
+				$message = $PayPalResult['L_LONGMESSAGE0'];
327
+			} else {
328
+				$message = $PayPalResult['ACK'];
329
+			}
330
+			if (empty($PayPalResult['RAWRESPONSE'])) {
331
+				$payment->set_status($this->_pay_model->failed_status());
332
+				$payment->set_gateway_response(esc_html__('No response received from Paypal Pro', 'event_espresso'));
333
+				$payment->set_details($PayPalResult);
334
+			} else {
335
+				if ($this->_APICallSuccessful($PayPalResult)) {
336
+					$payment->set_status($this->_pay_model->approved_status());
337
+				} else {
338
+					$payment->set_status($this->_pay_model->declined_status());
339
+				}
340
+				// make sure we interpret the AMT as a float, not an international string
341
+				// (where periods are thousand separators)
342
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
343
+				$payment->set_gateway_response($message);
344
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID'])
345
+					? $PayPalResult['TRANSACTIONID']
346
+					: null);
347
+				$primary_registration_code = $primary_registrant instanceof EE_Registration
348
+					? $primary_registrant->reg_code()
349
+					: '';
350
+				$payment->set_extra_accntng($primary_registration_code);
351
+				$payment->set_details($PayPalResult);
352
+			}
353
+		} catch (Exception $e) {
354
+			$payment->set_status($this->_pay_model->failed_status());
355
+			$payment->set_gateway_response($e->getMessage());
356
+		}
357
+		// $payment->set_status( $this->_pay_model->declined_status() );
358
+		// $payment->set_gateway_response( '' );
359
+		return $payment;
360
+	}
361
+
362
+
363
+
364
+	/**
365
+	 * CLeans out sensitive CC data and then logs it, and returns the cleaned request
366
+	 *
367
+	 * @param array       $request
368
+	 * @param EEI_Payment $payment
369
+	 * @return void
370
+	 */
371
+	private function _log_clean_request($request, $payment)
372
+	{
373
+		$cleaned_request_data = $request;
374
+		unset($cleaned_request_data['CCDetails']['acct']);
375
+		unset($cleaned_request_data['CCDetails']['cvv2']);
376
+		unset($cleaned_request_data['CCDetails']['expdate']);
377
+		$this->log(array('Paypal Request' => $cleaned_request_data), $payment);
378
+	}
379
+
380
+
381
+
382
+	/**
383
+	 * Cleans the response, logs it, and returns it
384
+	 *
385
+	 * @param array       $response
386
+	 * @param EEI_Payment $payment
387
+	 * @return array cleaned
388
+	 */
389
+	private function _log_clean_response($response, $payment)
390
+	{
391
+		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
392
+		unset($response['REQUESTDATA']['ACCT']);
393
+		unset($response['REQUESTDATA']['EXPDATE']);
394
+		unset($response['REQUESTDATA']['CVV2']);
395
+		unset($response['RAWREQUEST']);
396
+		$this->log(array('Paypal Response' => $response), $payment);
397
+		return $response;
398
+	}
399
+
400
+
401
+
402
+	/**
403
+	 * @param $DataArray
404
+	 * @return array
405
+	 */
406
+	private function prep_and_curl_request($DataArray)
407
+	{
408
+		// Create empty holders for each portion of the NVP string
409
+		$DPFieldsNVP = '&METHOD=DoDirectPayment&BUTTONSOURCE=AngellEYE_PHP_Class_DDP';
410
+		$CCDetailsNVP = '';
411
+		$PayerInfoNVP = '';
412
+		$PayerNameNVP = '';
413
+		$BillingAddressNVP = '';
414
+		$ShippingAddressNVP = '';
415
+		$PaymentDetailsNVP = '';
416
+		$OrderItemsNVP = '';
417
+		$Secure3DNVP = '';
418
+		// DP Fields
419
+		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
420
+		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal) {
421
+			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
422
+		}
423
+		// CC Details Fields
424
+		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
425
+		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal) {
426
+			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
427
+		}
428
+		// PayerInfo Type Fields
429
+		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
430
+		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal) {
431
+			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
432
+		}
433
+		// Payer Name Fields
434
+		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
435
+		foreach ($PayerName as $PayerNameVar => $PayerNameVal) {
436
+			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
437
+		}
438
+		// Address Fields (Billing)
439
+		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
440
+		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal) {
441
+			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
442
+		}
443
+		// Payment Details Type Fields
444
+		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
445
+		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal) {
446
+			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
447
+		}
448
+		// Payment Details Item Type Fields
449
+		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
450
+		$n = 0;
451
+		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
452
+			$CurrentItem = $OrderItems[ $OrderItemsVar ];
453
+			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal) {
454
+				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
455
+			}
456
+			$n++;
457
+		}
458
+		// Ship To Address Fields
459
+		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
460
+		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal) {
461
+			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
462
+		}
463
+		// 3D Secure Fields
464
+		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
465
+		foreach ($Secure3D as $Secure3DVar => $Secure3DVal) {
466
+			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
467
+		}
468
+		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
469
+		$NVPRequest = 'USER='
470
+					  . $this->_api_username
471
+					  . '&PWD='
472
+					  . $this->_api_password
473
+					  . '&VERSION=64.0'
474
+					  . '&SIGNATURE='
475
+					  . $this->_api_signature
476
+					  . $DPFieldsNVP
477
+					  . $CCDetailsNVP
478
+					  . $PayerInfoNVP
479
+					  . $PayerNameNVP
480
+					  . $BillingAddressNVP
481
+					  . $PaymentDetailsNVP
482
+					  . $OrderItemsNVP
483
+					  . $ShippingAddressNVP
484
+					  . $Secure3DNVP;
485
+		$NVPResponse = $this->_CURLRequest($NVPRequest);
486
+		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
487
+		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
488
+		$Errors = $this->_GetErrors($NVPResponseArray);
489
+		$NVPResponseArray['ERRORS'] = $Errors;
490
+		$NVPResponseArray['REQUESTDATA'] = $NVPRequestArray;
491
+		$NVPResponseArray['RAWREQUEST'] = $NVPRequest;
492
+		$NVPResponseArray['RAWRESPONSE'] = $NVPResponse;
493
+		return $NVPResponseArray;
494
+	}
495
+
496
+
497
+
498
+	/**
499
+	 * @param $Request
500
+	 * @return mixed
501
+	 */
502
+	private function _CURLRequest($Request)
503
+	{
504
+		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
505
+		$curl = curl_init();
506
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', true));
507
+		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
508
+		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
509
+		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
510
+		curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
511
+		curl_setopt($curl, CURLOPT_POSTFIELDS, $Request);
512
+		curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
513
+		// execute the curl POST
514
+		$Response = curl_exec($curl);
515
+		curl_close($curl);
516
+		return $Response;
517
+	}
518
+
519
+
520
+
521
+	/**
522
+	 * @param $NVPString
523
+	 * @return array
524
+	 */
525
+	private function _NVPToArray($NVPString)
526
+	{
527
+		// prepare responses into array
528
+		$proArray = array();
529
+		while (strlen($NVPString)) {
530
+			// name
531
+			$keypos = strpos($NVPString, '=');
532
+			$keyval = substr($NVPString, 0, $keypos);
533
+			// value
534
+			$valuepos = strpos($NVPString, '&') ? strpos($NVPString, '&') : strlen($NVPString);
535
+			$valval = substr($NVPString, $keypos + 1, $valuepos - $keypos - 1);
536
+			// decoding the response
537
+			$proArray[ $keyval ] = urldecode($valval);
538
+			$NVPString = substr($NVPString, $valuepos + 1, strlen($NVPString));
539
+		}
540
+		return $proArray;
541
+	}
542
+
543
+
544
+
545
+	/**
546
+	 * @param array $PayPalResult
547
+	 * @return bool
548
+	 */
549
+	private function _APICallSuccessful($PayPalResult)
550
+	{
551
+		$approved = false;
552
+		// check main response message from PayPal
553
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
554
+			$ack = strtoupper($PayPalResult['ACK']);
555
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
556
+		}
557
+		return $approved;
558
+	}
559
+
560
+
561
+
562
+	/**
563
+	 * @param $DataArray
564
+	 * @return array
565
+	 */
566
+	private function _GetErrors($DataArray)
567
+	{
568
+		$Errors = array();
569
+		$n = 0;
570
+		while (isset($DataArray[ 'L_ERRORCODE' . $n . '' ])) {
571
+			$LErrorCode = isset($DataArray[ 'L_ERRORCODE' . $n . '' ]) ? $DataArray[ 'L_ERRORCODE' . $n . '' ] : '';
572
+			$LShortMessage = isset($DataArray[ 'L_SHORTMESSAGE' . $n . '' ])
573
+				? $DataArray[ 'L_SHORTMESSAGE' . $n . '' ]
574
+				: '';
575
+			$LLongMessage = isset($DataArray[ 'L_LONGMESSAGE' . $n . '' ])
576
+				? $DataArray[ 'L_LONGMESSAGE' . $n . '' ]
577
+				: '';
578
+			$LSeverityCode = isset($DataArray[ 'L_SEVERITYCODE' . $n . '' ])
579
+				? $DataArray[ 'L_SEVERITYCODE' . $n . '' ]
580
+				: '';
581
+			$CurrentItem = array(
582
+				'L_ERRORCODE'    => $LErrorCode,
583
+				'L_SHORTMESSAGE' => $LShortMessage,
584
+				'L_LONGMESSAGE'  => $LLongMessage,
585
+				'L_SEVERITYCODE' => $LSeverityCode,
586
+			);
587
+			array_push($Errors, $CurrentItem);
588
+			$n++;
589
+		}
590
+		return $Errors;
591
+	}
592
+
593
+
594
+
595
+	/**
596
+	 *        nothing to see here...  move along....
597
+	 *
598
+	 * @access protected
599
+	 * @param $Errors
600
+	 * @return string
601
+	 */
602
+	private function _DisplayErrors($Errors)
603
+	{
604
+		$error = '';
605
+		foreach ($Errors as $ErrorVar => $ErrorVal) {
606
+			$CurrentError = $Errors[ $ErrorVar ];
607
+			foreach ($CurrentError as $CurrentErrorVar => $CurrentErrorVal) {
608
+				$CurrentVarName = '';
609
+				if ($CurrentErrorVar == 'L_ERRORCODE') {
610
+					$CurrentVarName = 'Error Code';
611
+				} elseif ($CurrentErrorVar == 'L_SHORTMESSAGE') {
612
+					$CurrentVarName = 'Short Message';
613
+				} elseif ($CurrentErrorVar == 'L_LONGMESSAGE') {
614
+					$CurrentVarName = 'Long Message';
615
+				} elseif ($CurrentErrorVar == 'L_SEVERITYCODE') {
616
+					$CurrentVarName = 'Severity Code';
617
+				}
618
+				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
619
+			}
620
+		}
621
+		return $error;
622
+	}
623 623
 }
Please login to merge, or discard this patch.