Completed
Branch BUG-10246-use-wp-json-encode (801029)
by
unknown
47:49 queued 36:06
created
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 1 patch
Indentation   +1348 added lines, -1348 removed lines patch added patch discarded remove patch
@@ -13,1354 +13,1354 @@
 block discarded – undo
13 13
 class EE_Form_Section_Proper extends EE_Form_Section_Validatable
14 14
 {
15 15
 
16
-    const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
17
-
18
-    /**
19
-     * Subsections
20
-     *
21
-     * @var EE_Form_Section_Validatable[]
22
-     */
23
-    protected $_subsections = array();
24
-
25
-    /**
26
-     * Strategy for laying out the form
27
-     *
28
-     * @var EE_Form_Section_Layout_Base
29
-     */
30
-    protected $_layout_strategy;
31
-
32
-    /**
33
-     * Whether or not this form has received and validated a form submission yet
34
-     *
35
-     * @var boolean
36
-     */
37
-    protected $_received_submission = false;
38
-
39
-    /**
40
-     * message displayed to users upon successful form submission
41
-     *
42
-     * @var string
43
-     */
44
-    protected $_form_submission_success_message = '';
45
-
46
-    /**
47
-     * message displayed to users upon unsuccessful form submission
48
-     *
49
-     * @var string
50
-     */
51
-    protected $_form_submission_error_message = '';
52
-
53
-    /**
54
-     * Stores all the data that will localized for form validation
55
-     *
56
-     * @var array
57
-     */
58
-    static protected $_js_localization = array();
59
-
60
-    /**
61
-     * whether or not the form's localized validation JS vars have been set
62
-     *
63
-     * @type boolean
64
-     */
65
-    static protected $_scripts_localized = false;
66
-
67
-
68
-
69
-    /**
70
-     * when constructing a proper form section, calls _construct_finalize on children
71
-     * so that they know who their parent is, and what name they've been given.
72
-     *
73
-     * @param array $options_array   {
74
-     * @type        $subsections     EE_Form_Section_Validatable[] where keys are the section's name
75
-     * @type        $include         string[] numerically-indexed where values are section names to be included,
76
-     *                               and in that order. This is handy if you want
77
-     *                               the subsections to be ordered differently than the default, and if you override
78
-     *                               which fields are shown
79
-     * @type        $exclude         string[] values are subsections to be excluded. This is handy if you want
80
-     *                               to remove certain default subsections (note: if you specify BOTH 'include' AND
81
-     *                               'exclude', the inclusions will be applied first, and the exclusions will exclude
82
-     *                               items from that list of inclusions)
83
-     * @type        $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
84
-     *                               } @see EE_Form_Section_Validatable::__construct()
85
-     * @throws \EE_Error
86
-     */
87
-    public function __construct($options_array = array())
88
-    {
89
-        $options_array = (array)apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array,
90
-            $this);
91
-        //call parent first, as it may be setting the name
92
-        parent::__construct($options_array);
93
-        //if they've included subsections in the constructor, add them now
94
-        if (isset($options_array['include'])) {
95
-            //we are going to make sure we ONLY have those subsections to include
96
-            //AND we are going to make sure they're in that specified order
97
-            $reordered_subsections = array();
98
-            foreach ($options_array['include'] as $input_name) {
99
-                if (isset($this->_subsections[$input_name])) {
100
-                    $reordered_subsections[$input_name] = $this->_subsections[$input_name];
101
-                }
102
-            }
103
-            $this->_subsections = $reordered_subsections;
104
-        }
105
-        if (isset($options_array['exclude'])) {
106
-            $exclude = $options_array['exclude'];
107
-            $this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
108
-        }
109
-        if (isset($options_array['layout_strategy'])) {
110
-            $this->_layout_strategy = $options_array['layout_strategy'];
111
-        }
112
-        if ( ! $this->_layout_strategy) {
113
-            $this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
114
-        }
115
-        $this->_layout_strategy->_construct_finalize($this);
116
-        //ok so we are definitely going to want the forms JS,
117
-        //so enqueue it or remember to enqueue it during wp_enqueue_scripts
118
-        if (did_action('wp_enqueue_scripts')
119
-            || did_action('admin_enqueue_scripts')
120
-        ) {
121
-            //ok so they've constructed this object after when they should have.
122
-            //just enqueue the generic form scripts and initialize the form immediately in the JS
123
-            \EE_Form_Section_Proper::wp_enqueue_scripts(true);
124
-        } else {
125
-            add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
126
-            add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
127
-        }
128
-        add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
129
-        if (isset($options_array['name'])) {
130
-            $this->_construct_finalize(null, $options_array['name']);
131
-        }
132
-    }
133
-
134
-
135
-
136
-    /**
137
-     * Finishes construction given the parent form section and this form section's name
138
-     *
139
-     * @param EE_Form_Section_Proper $parent_form_section
140
-     * @param string                 $name
141
-     * @throws \EE_Error
142
-     */
143
-    public function _construct_finalize($parent_form_section, $name)
144
-    {
145
-        parent::_construct_finalize($parent_form_section, $name);
146
-        $this->_set_default_name_if_empty();
147
-        $this->_set_default_html_id_if_empty();
148
-        foreach ($this->_subsections as $subsection_name => $subsection) {
149
-            if ($subsection instanceof EE_Form_Section_Base) {
150
-                $subsection->_construct_finalize($this, $subsection_name);
151
-            } else {
152
-                throw new EE_Error(
153
-                    sprintf(
154
-                        __('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
155
-                            'event_espresso'),
156
-                        $subsection_name,
157
-                        get_class($this),
158
-                        $subsection ? get_class($subsection) : __('NULL', 'event_espresso')
159
-                    )
160
-                );
161
-            }
162
-        }
163
-        do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
164
-    }
165
-
166
-
167
-
168
-    /**
169
-     * Gets the layout strategy for this form section
170
-     *
171
-     * @return EE_Form_Section_Layout_Base
172
-     */
173
-    public function get_layout_strategy()
174
-    {
175
-        return $this->_layout_strategy;
176
-    }
177
-
178
-
179
-
180
-    /**
181
-     * Gets the HTML for a single input for this form section according
182
-     * to the layout strategy
183
-     *
184
-     * @param EE_Form_Input_Base $input
185
-     * @return string
186
-     */
187
-    public function get_html_for_input($input)
188
-    {
189
-        return $this->_layout_strategy->layout_input($input);
190
-    }
191
-
192
-
193
-
194
-    /**
195
-     * was_submitted - checks if form inputs are present in request data
196
-     * Basically an alias for form_data_present_in() (which is used by both
197
-     * proper form sections and form inputs)
198
-     *
199
-     * @param null $form_data
200
-     * @return boolean
201
-     */
202
-    public function was_submitted($form_data = null)
203
-    {
204
-        return $this->form_data_present_in($form_data);
205
-    }
206
-
207
-
208
-
209
-    /**
210
-     * After the form section is initially created, call this to sanitize the data in the submission
211
-     * which relates to this form section, validate it, and set it as properties on the form.
212
-     *
213
-     * @param array|null $req_data should usually be $_POST (the default).
214
-     *                             However, you CAN supply a different array.
215
-     *                             Consider using set_defaults() instead however.
216
-     *                             (If you rendered the form in the page using echo $form_x->get_html()
217
-     *                             the inputs will have the correct name in the request data for this function
218
-     *                             to find them and populate the form with them.
219
-     *                             If you have a flat form (with only input subsections),
220
-     *                             you can supply a flat array where keys
221
-     *                             are the form input names and values are their values)
222
-     * @param boolean    $validate whether or not to perform validation on this data. Default is,
223
-     *                             of course, to validate that data, and set errors on the invalid values.
224
-     *                             But if the data has already been validated
225
-     *                             (eg you validated the data then stored it in the DB)
226
-     *                             you may want to skip this step.
227
-     */
228
-    public function receive_form_submission($req_data = null, $validate = true)
229
-    {
230
-        $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this,
231
-            $validate);
232
-        if ($req_data === null) {
233
-            $req_data = array_merge($_GET, $_POST);
234
-        }
235
-        $req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data,
236
-            $this);
237
-        $this->_normalize($req_data);
238
-        if ($validate) {
239
-            $this->_validate();
240
-            //if it's invalid, we're going to want to re-display so remember what they submitted
241
-            if ( ! $this->is_valid()) {
242
-                $this->store_submitted_form_data_in_session();
243
-            }
244
-        }
245
-        do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
246
-    }
247
-
248
-
249
-
250
-    /**
251
-     * caches the originally submitted input values in the session
252
-     * so that they can be used to repopulate the form if it failed validation
253
-     *
254
-     * @return boolean whether or not the data was successfully stored in the session
255
-     */
256
-    protected function store_submitted_form_data_in_session()
257
-    {
258
-        return EE_Registry::instance()->SSN->set_session_data(
259
-            array(
260
-                \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
261
-            )
262
-        );
263
-    }
264
-
265
-
266
-
267
-    /**
268
-     * retrieves the originally submitted input values in the session
269
-     * so that they can be used to repopulate the form if it failed validation
270
-     *
271
-     * @return array
272
-     */
273
-    protected function get_submitted_form_data_from_session()
274
-    {
275
-        $session = EE_Registry::instance()->SSN;
276
-        if ($session instanceof EE_Session) {
277
-            return $session->get_session_data(
278
-                \EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
279
-            );
280
-        } else {
281
-            return array();
282
-        }
283
-    }
284
-
285
-
286
-
287
-    /**
288
-     * flushed the originally submitted input values from the session
289
-     *
290
-     * @return boolean whether or not the data was successfully removed from the session
291
-     */
292
-    protected function flush_submitted_form_data_from_session()
293
-    {
294
-        return EE_Registry::instance()->SSN->reset_data(
295
-            array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
296
-        );
297
-    }
298
-
299
-
300
-
301
-    /**
302
-     * Populates this form and its subsections with data from the session.
303
-     * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
304
-     * validation errors when displaying too)
305
-     * Returns true if the form was populated from the session, false otherwise
306
-     *
307
-     * @return boolean
308
-     */
309
-    public function populate_from_session()
310
-    {
311
-        $form_data_in_session = $this->get_submitted_form_data_from_session();
312
-        if (empty($form_data_in_session)) {
313
-            return false;
314
-        }
315
-        $this->receive_form_submission($form_data_in_session);
316
-        $this->flush_submitted_form_data_from_session();
317
-        if ($this->form_data_present_in($form_data_in_session)) {
318
-            return true;
319
-        } else {
320
-            return false;
321
-        }
322
-    }
323
-
324
-
325
-
326
-    /**
327
-     * Populates the default data for the form, given an array where keys are
328
-     * the input names, and values are their values (preferably normalized to be their
329
-     * proper PHP types, not all strings... although that should be ok too).
330
-     * Proper subsections are sub-arrays, the key being the subsection's name, and
331
-     * the value being an array formatted in teh same way
332
-     *
333
-     * @param array $default_data
334
-     */
335
-    public function populate_defaults($default_data)
336
-    {
337
-        foreach ($this->subsections() as $subsection_name => $subsection) {
338
-            if (isset($default_data[$subsection_name])) {
339
-                if ($subsection instanceof EE_Form_Input_Base) {
340
-                    $subsection->set_default($default_data[$subsection_name]);
341
-                } elseif ($subsection instanceof EE_Form_Section_Proper) {
342
-                    $subsection->populate_defaults($default_data[$subsection_name]);
343
-                }
344
-            }
345
-        }
346
-    }
347
-
348
-
349
-
350
-    /**
351
-     * returns true if subsection exists
352
-     *
353
-     * @param string $name
354
-     * @return boolean
355
-     */
356
-    public function subsection_exists($name)
357
-    {
358
-        return isset($this->_subsections[$name]) ? true : false;
359
-    }
360
-
361
-
362
-
363
-    /**
364
-     * Gets the subsection specified by its name
365
-     *
366
-     * @param string  $name
367
-     * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
368
-     *                                                      so that the inputs will be properly configured.
369
-     *                                                      However, some client code may be ok
370
-     *                                                      with construction finalize being called later
371
-     *                                                      (realizing that the subsections' html names
372
-     *                                                      might not be set yet, etc.)
373
-     * @return EE_Form_Section_Base
374
-     * @throws \EE_Error
375
-     */
376
-    public function get_subsection($name, $require_construction_to_be_finalized = true)
377
-    {
378
-        if ($require_construction_to_be_finalized) {
379
-            $this->ensure_construct_finalized_called();
380
-        }
381
-        return $this->subsection_exists($name) ? $this->_subsections[$name] : null;
382
-    }
383
-
384
-
385
-
386
-    /**
387
-     * Gets all the validatable subsections of this form section
388
-     *
389
-     * @return EE_Form_Section_Validatable[]
390
-     */
391
-    public function get_validatable_subsections()
392
-    {
393
-        $validatable_subsections = array();
394
-        foreach ($this->subsections() as $name => $obj) {
395
-            if ($obj instanceof EE_Form_Section_Validatable) {
396
-                $validatable_subsections[$name] = $obj;
397
-            }
398
-        }
399
-        return $validatable_subsections;
400
-    }
401
-
402
-
403
-
404
-    /**
405
-     * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
406
-     * throw an EE_Error.
407
-     *
408
-     * @param string  $name
409
-     * @param boolean $require_construction_to_be_finalized most client code should
410
-     *                                                      leave this as TRUE so that the inputs will be properly
411
-     *                                                      configured. However, some client code may be ok with
412
-     *                                                      construction finalize being called later
413
-     *                                                      (realizing that the subsections' html names might not be
414
-     *                                                      set yet, etc.)
415
-     * @return EE_Form_Input_Base
416
-     * @throws EE_Error
417
-     */
418
-    public function get_input($name, $require_construction_to_be_finalized = true)
419
-    {
420
-        $subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
421
-        if ( ! $subsection instanceof EE_Form_Input_Base) {
422
-            throw new EE_Error(
423
-                sprintf(
424
-                    __(
425
-                        "Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
426
-                        'event_espresso'
427
-                    ),
428
-                    $name,
429
-                    get_class($this),
430
-                    $subsection ? get_class($subsection) : __("NULL", 'event_espresso')
431
-                )
432
-            );
433
-        }
434
-        return $subsection;
435
-    }
436
-
437
-
438
-
439
-    /**
440
-     * Like get_input(), gets the proper subsection of the form given the name,
441
-     * otherwise throws an EE_Error
442
-     *
443
-     * @param string  $name
444
-     * @param boolean $require_construction_to_be_finalized most client code should
445
-     *                                                      leave this as TRUE so that the inputs will be properly
446
-     *                                                      configured. However, some client code may be ok with
447
-     *                                                      construction finalize being called later
448
-     *                                                      (realizing that the subsections' html names might not be
449
-     *                                                      set yet, etc.)
450
-     * @return EE_Form_Section_Proper
451
-     * @throws EE_Error
452
-     */
453
-    public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
454
-    {
455
-        $subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
456
-        if ( ! $subsection instanceof EE_Form_Section_Proper) {
457
-            throw new EE_Error(
458
-                sprintf(
459
-                    __("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),
460
-                    $name,
461
-                    get_class($this)
462
-                )
463
-            );
464
-        }
465
-        return $subsection;
466
-    }
467
-
468
-
469
-
470
-    /**
471
-     * Gets the value of the specified input. Should be called after receive_form_submission()
472
-     * or populate_defaults() on the form, where the normalized value on the input is set.
473
-     *
474
-     * @param string $name
475
-     * @return mixed depending on the input's type and its normalization strategy
476
-     * @throws \EE_Error
477
-     */
478
-    public function get_input_value($name)
479
-    {
480
-        $input = $this->get_input($name);
481
-        return $input->normalized_value();
482
-    }
483
-
484
-
485
-
486
-    /**
487
-     * Checks if this form section itself is valid, and then checks its subsections
488
-     *
489
-     * @throws EE_Error
490
-     * @return boolean
491
-     */
492
-    public function is_valid()
493
-    {
494
-        if ( ! $this->has_received_submission()) {
495
-            throw new EE_Error(
496
-                sprintf(
497
-                    __(
498
-                        "You cannot check if a form is valid before receiving the form submission using receive_form_submission",
499
-                        "event_espresso"
500
-                    )
501
-                )
502
-            );
503
-        }
504
-        if ( ! parent::is_valid()) {
505
-            return false;
506
-        }
507
-        // ok so no general errors to this entire form section.
508
-        // so let's check the subsections, but only set errors if that hasn't been done yet
509
-        $set_submission_errors = $this->submission_error_message() === '' ? true : false;
510
-        foreach ($this->get_validatable_subsections() as $subsection) {
511
-            if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') {
512
-                if ($set_submission_errors) {
513
-                    $this->set_submission_error_message($subsection->get_validation_error_string());
514
-                }
515
-                return false;
516
-            }
517
-        }
518
-        return true;
519
-    }
520
-
521
-
522
-
523
-    /**
524
-     * gets teh default name of this form section if none is specified
525
-     *
526
-     * @return string
527
-     */
528
-    protected function _set_default_name_if_empty()
529
-    {
530
-        if ( ! $this->_name) {
531
-            $classname = get_class($this);
532
-            $default_name = str_replace("EE_", "", $classname);
533
-            $this->_name = $default_name;
534
-        }
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Returns the HTML for the form, except for the form opening and closing tags
541
-     * (as the form section doesn't know where you necessarily want to send the information to),
542
-     * and except for a submit button. Enqueus JS and CSS; if called early enough we will
543
-     * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
544
-     * Not doing_it_wrong because theoretically this CAN be used properly,
545
-     * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
546
-     * any CSS.
547
-     *
548
-     * @throws \EE_Error
549
-     */
550
-    public function get_html_and_js()
551
-    {
552
-        $this->enqueue_js();
553
-        return $this->get_html();
554
-    }
555
-
556
-
557
-
558
-    /**
559
-     * returns HTML for displaying this form section. recursively calls display_section() on all subsections
560
-     *
561
-     * @param bool $display_previously_submitted_data
562
-     * @return string
563
-     */
564
-    public function get_html($display_previously_submitted_data = true)
565
-    {
566
-        $this->ensure_construct_finalized_called();
567
-        if ($display_previously_submitted_data) {
568
-            $this->populate_from_session();
569
-        }
570
-        return $this->_layout_strategy->layout_form();
571
-    }
572
-
573
-
574
-
575
-    /**
576
-     * enqueues JS and CSS for the form.
577
-     * It is preferred to call this before wp_enqueue_scripts so the
578
-     * scripts and styles can be put in the header, but if called later
579
-     * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
580
-     * only be in the header; but in HTML5 its ok in the body.
581
-     * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
582
-     * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
583
-     *
584
-     * @return string
585
-     * @throws \EE_Error
586
-     */
587
-    public function enqueue_js()
588
-    {
589
-        $this->_enqueue_and_localize_form_js();
590
-        foreach ($this->subsections() as $subsection) {
591
-            $subsection->enqueue_js();
592
-        }
593
-    }
594
-
595
-
596
-
597
-    /**
598
-     * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
599
-     * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
600
-     * the wp_enqueue_scripts hook.
601
-     * However, registering the form js and localizing it can happen when we
602
-     * actually output the form (which is preferred, seeing how teh form's fields
603
-     * could change until it's actually outputted)
604
-     *
605
-     * @param boolean $init_form_validation_automatically whether or not we want the form validation
606
-     *                                                    to be triggered automatically or not
607
-     * @return void
608
-     */
609
-    public static function wp_enqueue_scripts($init_form_validation_automatically = true)
610
-    {
611
-        add_filter('FHEE_load_jquery_validate', '__return_true');
612
-        wp_register_script(
613
-            'ee_form_section_validation',
614
-            EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js',
615
-            array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
616
-            EVENT_ESPRESSO_VERSION,
617
-            true
618
-        );
619
-        wp_localize_script(
620
-            'ee_form_section_validation',
621
-            'ee_form_section_validation_init',
622
-            array('init' => $init_form_validation_automatically ? true : false)
623
-        );
624
-    }
625
-
626
-
627
-
628
-    /**
629
-     * gets the variables used by form_section_validation.js.
630
-     * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
631
-     * but before the wordpress hook wp_loaded
632
-     *
633
-     * @throws \EE_Error
634
-     */
635
-    public function _enqueue_and_localize_form_js()
636
-    {
637
-        $this->ensure_construct_finalized_called();
638
-        //actually, we don't want to localize just yet. There may be other forms on the page.
639
-        //so we need to add our form section data to a static variable accessible by all form sections
640
-        //and localize it just before the footer
641
-        $this->localize_validation_rules();
642
-        add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
643
-        add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
644
-    }
645
-
646
-
647
-
648
-    /**
649
-     * add our form section data to a static variable accessible by all form sections
650
-     *
651
-     * @param bool $return_for_subsection
652
-     * @return void
653
-     * @throws \EE_Error
654
-     */
655
-    public function localize_validation_rules($return_for_subsection = false)
656
-    {
657
-        // we only want to localize vars ONCE for the entire form,
658
-        // so if the form section doesn't have a parent, then it must be the top dog
659
-        if ($return_for_subsection || ! $this->parent_section()) {
660
-            EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
661
-                'form_section_id'  => $this->html_id(true),
662
-                'validation_rules' => $this->get_jquery_validation_rules(),
663
-                'other_data'       => $this->get_other_js_data(),
664
-                'errors'           => $this->subsection_validation_errors_by_html_name(),
665
-            );
666
-            EE_Form_Section_Proper::$_scripts_localized = true;
667
-        }
668
-    }
669
-
670
-
671
-
672
-    /**
673
-     * Gets an array of extra data that will be useful for client-side javascript.
674
-     * This is primarily data added by inputs and forms in addition to any
675
-     * scripts they might enqueue
676
-     *
677
-     * @param array $form_other_js_data
678
-     * @return array
679
-     */
680
-    public function get_other_js_data($form_other_js_data = array())
681
-    {
682
-        foreach ($this->subsections() as $subsection) {
683
-            $form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
684
-        }
685
-        return $form_other_js_data;
686
-    }
687
-
688
-
689
-
690
-    /**
691
-     * Gets a flat array of inputs for this form section and its subsections.
692
-     * Keys are their form names, and values are the inputs themselves
693
-     *
694
-     * @return EE_Form_Input_Base
695
-     */
696
-    public function inputs_in_subsections()
697
-    {
698
-        $inputs = array();
699
-        foreach ($this->subsections() as $subsection) {
700
-            if ($subsection instanceof EE_Form_Input_Base) {
701
-                $inputs[$subsection->html_name()] = $subsection;
702
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
703
-                $inputs += $subsection->inputs_in_subsections();
704
-            }
705
-        }
706
-        return $inputs;
707
-    }
708
-
709
-
710
-
711
-    /**
712
-     * Gets a flat array of all the validation errors.
713
-     * Keys are html names (because those should be unique)
714
-     * and values are a string of all their validation errors
715
-     *
716
-     * @return string[]
717
-     */
718
-    public function subsection_validation_errors_by_html_name()
719
-    {
720
-        $inputs = $this->inputs();
721
-        $errors = array();
722
-        foreach ($inputs as $form_input) {
723
-            if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
724
-                $errors[$form_input->html_name()] = $form_input->get_validation_error_string();
725
-            }
726
-        }
727
-        return $errors;
728
-    }
729
-
730
-
731
-
732
-    /**
733
-     * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
734
-     * Should be setup by each form during the _enqueues_and_localize_form_js
735
-     */
736
-    public static function localize_script_for_all_forms()
737
-    {
738
-        //allow inputs and stuff to hook in their JS and stuff here
739
-        do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
740
-        EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
741
-        $email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
742
-            ? EE_Registry::instance()->CFG->registration->email_validation_level
743
-            : 'wp_default';
744
-        EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
745
-        wp_enqueue_script('ee_form_section_validation');
746
-        wp_localize_script(
747
-            'ee_form_section_validation',
748
-            'ee_form_section_vars',
749
-            EE_Form_Section_Proper::$_js_localization
750
-        );
751
-    }
752
-
753
-
754
-
755
-    /**
756
-     * ensure_scripts_localized
757
-     */
758
-    public function ensure_scripts_localized()
759
-    {
760
-        if ( ! EE_Form_Section_Proper::$_scripts_localized) {
761
-            $this->_enqueue_and_localize_form_js();
762
-        }
763
-    }
764
-
765
-
766
-
767
-    /**
768
-     * Gets the hard-coded validation error messages to be used in the JS. The convention
769
-     * is that the key here should be the same as the custom validation rule put in the JS file
770
-     *
771
-     * @return array keys are custom validation rules, and values are internationalized strings
772
-     */
773
-    private static function _get_localized_error_messages()
774
-    {
775
-        return array(
776
-            'validUrl' => __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
777
-            'regex'    => __('Please check your input', 'event_espresso'),
778
-        );
779
-    }
780
-
781
-
782
-
783
-    /**
784
-     * @return array
785
-     */
786
-    public static function js_localization()
787
-    {
788
-        return self::$_js_localization;
789
-    }
790
-
791
-
792
-
793
-    /**
794
-     * @return array
795
-     */
796
-    public static function reset_js_localization()
797
-    {
798
-        self::$_js_localization = array();
799
-    }
800
-
801
-
802
-
803
-    /**
804
-     * Gets the JS to put inside the jquery validation rules for subsection of this form section.
805
-     * See parent function for more...
806
-     *
807
-     * @return array
808
-     */
809
-    public function get_jquery_validation_rules()
810
-    {
811
-        $jquery_validation_rules = array();
812
-        foreach ($this->get_validatable_subsections() as $subsection) {
813
-            $jquery_validation_rules = array_merge(
814
-                $jquery_validation_rules,
815
-                $subsection->get_jquery_validation_rules()
816
-            );
817
-        }
818
-        return $jquery_validation_rules;
819
-    }
820
-
821
-
822
-
823
-    /**
824
-     * Sanitizes all the data and sets the sanitized value of each field
825
-     *
826
-     * @param array $req_data like $_POST
827
-     * @return void
828
-     */
829
-    protected function _normalize($req_data)
830
-    {
831
-        $this->_received_submission = true;
832
-        $this->_validation_errors = array();
833
-        foreach ($this->get_validatable_subsections() as $subsection) {
834
-            try {
835
-                $subsection->_normalize($req_data);
836
-            } catch (EE_Validation_Error $e) {
837
-                $subsection->add_validation_error($e);
838
-            }
839
-        }
840
-    }
841
-
842
-
843
-
844
-    /**
845
-     * Performs validation on this form section and its subsections.
846
-     * For each subsection,
847
-     * calls _validate_{subsection_name} on THIS form (if the function exists)
848
-     * and passes it the subsection, then calls _validate on that subsection.
849
-     * If you need to perform validation on the form as a whole (considering multiple)
850
-     * you would be best to override this _validate method,
851
-     * calling parent::_validate() first.
852
-     */
853
-    protected function _validate()
854
-    {
855
-        foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
856
-            if (method_exists($this, '_validate_' . $subsection_name)) {
857
-                call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
858
-            }
859
-            $subsection->_validate();
860
-        }
861
-    }
862
-
863
-
864
-
865
-    /**
866
-     * Gets all the validated inputs for the form section
867
-     *
868
-     * @return array
869
-     */
870
-    public function valid_data()
871
-    {
872
-        $inputs = array();
873
-        foreach ($this->subsections() as $subsection_name => $subsection) {
874
-            if ($subsection instanceof EE_Form_Section_Proper) {
875
-                $inputs[$subsection_name] = $subsection->valid_data();
876
-            } else if ($subsection instanceof EE_Form_Input_Base) {
877
-                $inputs[$subsection_name] = $subsection->normalized_value();
878
-            }
879
-        }
880
-        return $inputs;
881
-    }
882
-
883
-
884
-
885
-    /**
886
-     * Gets all the inputs on this form section
887
-     *
888
-     * @return EE_Form_Input_Base[]
889
-     */
890
-    public function inputs()
891
-    {
892
-        $inputs = array();
893
-        foreach ($this->subsections() as $subsection_name => $subsection) {
894
-            if ($subsection instanceof EE_Form_Input_Base) {
895
-                $inputs[$subsection_name] = $subsection;
896
-            }
897
-        }
898
-        return $inputs;
899
-    }
900
-
901
-
902
-
903
-    /**
904
-     * Gets all the subsections which are a proper form
905
-     *
906
-     * @return EE_Form_Section_Proper[]
907
-     */
908
-    public function subforms()
909
-    {
910
-        $form_sections = array();
911
-        foreach ($this->subsections() as $name => $obj) {
912
-            if ($obj instanceof EE_Form_Section_Proper) {
913
-                $form_sections[$name] = $obj;
914
-            }
915
-        }
916
-        return $form_sections;
917
-    }
918
-
919
-
920
-
921
-    /**
922
-     * Gets all the subsections (inputs, proper subsections, or html-only sections).
923
-     * Consider using inputs() or subforms()
924
-     * if you only want form inputs or proper form sections.
925
-     *
926
-     * @return EE_Form_Section_Proper[]
927
-     */
928
-    public function subsections()
929
-    {
930
-        $this->ensure_construct_finalized_called();
931
-        return $this->_subsections;
932
-    }
933
-
934
-
935
-
936
-    /**
937
-     * Returns a simple array where keys are input names, and values are their normalized
938
-     * values. (Similar to calling get_input_value on inputs)
939
-     *
940
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
941
-     *                                        or just this forms' direct children inputs
942
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
943
-     *                                        or allow multidimensional array
944
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
945
-     *                                        with array keys being input names
946
-     *                                        (regardless of whether they are from a subsection or not),
947
-     *                                        and if $flatten is FALSE it can be a multidimensional array
948
-     *                                        where keys are always subsection names and values are either
949
-     *                                        the input's normalized value, or an array like the top-level array
950
-     */
951
-    public function input_values($include_subform_inputs = false, $flatten = false)
952
-    {
953
-        return $this->_input_values(false, $include_subform_inputs, $flatten);
954
-    }
955
-
956
-
957
-
958
-    /**
959
-     * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
960
-     * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
961
-     * is not necessarily the value we want to display to users. This creates an array
962
-     * where keys are the input names, and values are their display values
963
-     *
964
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
965
-     *                                        or just this forms' direct children inputs
966
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
967
-     *                                        or allow multidimensional array
968
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array
969
-     *                                        with array keys being input names
970
-     *                                        (regardless of whether they are from a subsection or not),
971
-     *                                        and if $flatten is FALSE it can be a multidimensional array
972
-     *                                        where keys are always subsection names and values are either
973
-     *                                        the input's normalized value, or an array like the top-level array
974
-     */
975
-    public function input_pretty_values($include_subform_inputs = false, $flatten = false)
976
-    {
977
-        return $this->_input_values(true, $include_subform_inputs, $flatten);
978
-    }
979
-
980
-
981
-
982
-    /**
983
-     * Gets the input values from the form
984
-     *
985
-     * @param boolean $pretty                 Whether to retrieve the pretty value,
986
-     *                                        or just the normalized value
987
-     * @param boolean $include_subform_inputs Whether to include inputs from subforms,
988
-     *                                        or just this forms' direct children inputs
989
-     * @param boolean $flatten                Whether to force the results into 1-dimensional array,
990
-     *                                        or allow multidimensional array
991
-     * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
992
-     *                                        input names (regardless of whether they are from a subsection or not),
993
-     *                                        and if $flatten is FALSE it can be a multidimensional array
994
-     *                                        where keys are always subsection names and values are either
995
-     *                                        the input's normalized value, or an array like the top-level array
996
-     */
997
-    public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
998
-    {
999
-        $input_values = array();
1000
-        foreach ($this->subsections() as $subsection_name => $subsection) {
1001
-            if ($subsection instanceof EE_Form_Input_Base) {
1002
-                $input_values[$subsection_name] = $pretty
1003
-                    ? $subsection->pretty_value()
1004
-                    : $subsection->normalized_value();
1005
-            } else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1006
-                $subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
1007
-                if ($flatten) {
1008
-                    $input_values = array_merge($input_values, $subform_input_values);
1009
-                } else {
1010
-                    $input_values[$subsection_name] = $subform_input_values;
1011
-                }
1012
-            }
1013
-        }
1014
-        return $input_values;
1015
-    }
1016
-
1017
-
1018
-
1019
-    /**
1020
-     * Gets the originally submitted input values from the form
1021
-     *
1022
-     * @param boolean $include_subforms  Whether to include inputs from subforms,
1023
-     *                                   or just this forms' direct children inputs
1024
-     * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1025
-     *                                   with array keys being input names
1026
-     *                                   (regardless of whether they are from a subsection or not),
1027
-     *                                   and if $flatten is FALSE it can be a multidimensional array
1028
-     *                                   where keys are always subsection names and values are either
1029
-     *                                   the input's normalized value, or an array like the top-level array
1030
-     */
1031
-    public function submitted_values($include_subforms = false)
1032
-    {
1033
-        $submitted_values = array();
1034
-        foreach ($this->subsections() as $subsection) {
1035
-            if ($subsection instanceof EE_Form_Input_Base) {
1036
-                // is this input part of an array of inputs?
1037
-                if (strpos($subsection->html_name(), '[') !== false) {
1038
-                    $full_input_name = \EEH_Array::convert_array_values_to_keys(
1039
-                        explode('[', str_replace(']', '', $subsection->html_name())),
1040
-                        $subsection->raw_value()
1041
-                    );
1042
-                    $submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1043
-                } else {
1044
-                    $submitted_values[$subsection->html_name()] = $subsection->raw_value();
1045
-                }
1046
-            } else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1047
-                $subform_input_values = $subsection->submitted_values($include_subforms);
1048
-                $submitted_values = array_replace_recursive($submitted_values, $subform_input_values);
1049
-            }
1050
-        }
1051
-        return $submitted_values;
1052
-    }
1053
-
1054
-
1055
-
1056
-    /**
1057
-     * Indicates whether or not this form has received a submission yet
1058
-     * (ie, had receive_form_submission called on it yet)
1059
-     *
1060
-     * @return boolean
1061
-     * @throws \EE_Error
1062
-     */
1063
-    public function has_received_submission()
1064
-    {
1065
-        $this->ensure_construct_finalized_called();
1066
-        return $this->_received_submission;
1067
-    }
1068
-
1069
-
1070
-
1071
-    /**
1072
-     * Equivalent to passing 'exclude' in the constructor's options array.
1073
-     * Removes the listed inputs from the form
1074
-     *
1075
-     * @param array $inputs_to_exclude values are the input names
1076
-     * @return void
1077
-     */
1078
-    public function exclude(array $inputs_to_exclude = array())
1079
-    {
1080
-        foreach ($inputs_to_exclude as $input_to_exclude_name) {
1081
-            unset($this->_subsections[$input_to_exclude_name]);
1082
-        }
1083
-    }
1084
-
1085
-
1086
-
1087
-    /**
1088
-     * @param array $inputs_to_hide
1089
-     * @throws \EE_Error
1090
-     */
1091
-    public function hide($inputs_to_hide = array())
1092
-    {
1093
-        foreach ($inputs_to_hide as $input_to_hide) {
1094
-            $input = $this->get_input($input_to_hide);
1095
-            $input->set_display_strategy(new EE_Hidden_Display_Strategy());
1096
-        }
1097
-    }
1098
-
1099
-
1100
-
1101
-    /**
1102
-     * add_subsections
1103
-     * Adds the listed subsections to the form section.
1104
-     * If $subsection_name_to_target is provided,
1105
-     * then new subsections are added before or after that subsection,
1106
-     * otherwise to the start or end of the entire subsections array.
1107
-     *
1108
-     * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1109
-     *                                                          where keys are their names
1110
-     * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1111
-     *                                                          should be added before or after
1112
-     *                                                          IF $subsection_name_to_target is null,
1113
-     *                                                          then $new_subsections will be added to
1114
-     *                                                          the beginning or end of the entire subsections array
1115
-     * @param boolean                $add_before                whether to add $new_subsections, before or after
1116
-     *                                                          $subsection_name_to_target,
1117
-     *                                                          or if $subsection_name_to_target is null,
1118
-     *                                                          before or after entire subsections array
1119
-     * @return void
1120
-     * @throws \EE_Error
1121
-     */
1122
-    public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1123
-    {
1124
-        foreach ($new_subsections as $subsection_name => $subsection) {
1125
-            if ( ! $subsection instanceof EE_Form_Section_Base) {
1126
-                EE_Error::add_error(
1127
-                    sprintf(
1128
-                        __(
1129
-                            "Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1130
-                            "event_espresso"
1131
-                        ),
1132
-                        get_class($subsection),
1133
-                        $subsection_name,
1134
-                        $this->name()
1135
-                    )
1136
-                );
1137
-                unset($new_subsections[$subsection_name]);
1138
-            }
1139
-        }
1140
-        $this->_subsections = EEH_Array::insert_into_array(
1141
-            $this->_subsections,
1142
-            $new_subsections,
1143
-            $subsection_name_to_target,
1144
-            $add_before
1145
-        );
1146
-        if ($this->_construction_finalized) {
1147
-            foreach ($this->_subsections as $name => $subsection) {
1148
-                $subsection->_construct_finalize($this, $name);
1149
-            }
1150
-        }
1151
-    }
1152
-
1153
-
1154
-
1155
-    /**
1156
-     * Just gets all validatable subsections to clean their sensitive data
1157
-     */
1158
-    public function clean_sensitive_data()
1159
-    {
1160
-        foreach ($this->get_validatable_subsections() as $subsection) {
1161
-            $subsection->clean_sensitive_data();
1162
-        }
1163
-    }
1164
-
1165
-
1166
-
1167
-    /**
1168
-     * @param string $form_submission_error_message
1169
-     */
1170
-    public function set_submission_error_message($form_submission_error_message = '')
1171
-    {
1172
-        $this->_form_submission_error_message .= ! empty($form_submission_error_message)
1173
-            ? $form_submission_error_message
1174
-            : __('Form submission failed due to errors', 'event_espresso');
1175
-    }
1176
-
1177
-
1178
-
1179
-    /**
1180
-     * @return string
1181
-     */
1182
-    public function submission_error_message()
1183
-    {
1184
-        return $this->_form_submission_error_message;
1185
-    }
1186
-
1187
-
1188
-
1189
-    /**
1190
-     * @param string $form_submission_success_message
1191
-     */
1192
-    public function set_submission_success_message($form_submission_success_message)
1193
-    {
1194
-        $this->_form_submission_success_message .= ! empty($form_submission_success_message)
1195
-            ? $form_submission_success_message
1196
-            : __('Form submitted successfully', 'event_espresso');
1197
-    }
1198
-
1199
-
1200
-
1201
-    /**
1202
-     * @return string
1203
-     */
1204
-    public function submission_success_message()
1205
-    {
1206
-        return $this->_form_submission_success_message;
1207
-    }
1208
-
1209
-
1210
-
1211
-    /**
1212
-     * Returns the prefix that should be used on child of this form section for
1213
-     * their html names. If this form section itself has a parent, prepends ITS
1214
-     * prefix onto this form section's prefix. Used primarily by
1215
-     * EE_Form_Input_Base::_set_default_html_name_if_empty
1216
-     *
1217
-     * @return string
1218
-     * @throws \EE_Error
1219
-     */
1220
-    public function html_name_prefix()
1221
-    {
1222
-        if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1223
-            return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1224
-        } else {
1225
-            return $this->name();
1226
-        }
1227
-    }
1228
-
1229
-
1230
-
1231
-    /**
1232
-     * Gets the name, but first checks _construct_finalize has been called. If not,
1233
-     * calls it (assumes there is no parent and that we want the name to be whatever
1234
-     * was set, which is probably nothing, or the classname)
1235
-     *
1236
-     * @return string
1237
-     * @throws \EE_Error
1238
-     */
1239
-    public function name()
1240
-    {
1241
-        $this->ensure_construct_finalized_called();
1242
-        return parent::name();
1243
-    }
1244
-
1245
-
1246
-
1247
-    /**
1248
-     * @return EE_Form_Section_Proper
1249
-     * @throws \EE_Error
1250
-     */
1251
-    public function parent_section()
1252
-    {
1253
-        $this->ensure_construct_finalized_called();
1254
-        return parent::parent_section();
1255
-    }
1256
-
1257
-
1258
-
1259
-    /**
1260
-     * make sure construction finalized was called, otherwise children might not be ready
1261
-     *
1262
-     * @return void
1263
-     * @throws \EE_Error
1264
-     */
1265
-    public function ensure_construct_finalized_called()
1266
-    {
1267
-        if ( ! $this->_construction_finalized) {
1268
-            $this->_construct_finalize($this->_parent_section, $this->_name);
1269
-        }
1270
-    }
1271
-
1272
-
1273
-
1274
-    /**
1275
-     * Checks if any of this form section's inputs, or any of its children's inputs,
1276
-     * are in teh form data. If any are found, returns true. Else false
1277
-     *
1278
-     * @param array $req_data
1279
-     * @return boolean
1280
-     */
1281
-    public function form_data_present_in($req_data = null)
1282
-    {
1283
-        if ($req_data === null) {
1284
-            $req_data = $_POST;
1285
-        }
1286
-        foreach ($this->subsections() as $subsection) {
1287
-            if ($subsection instanceof EE_Form_Input_Base) {
1288
-                if ($subsection->form_data_present_in($req_data)) {
1289
-                    return true;
1290
-                }
1291
-            } elseif ($subsection instanceof EE_Form_Section_Proper) {
1292
-                if ($subsection->form_data_present_in($req_data)) {
1293
-                    return true;
1294
-                }
1295
-            }
1296
-        }
1297
-        return false;
1298
-    }
1299
-
1300
-
1301
-
1302
-    /**
1303
-     * Gets validation errors for this form section and subsections
1304
-     * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1305
-     * gets the validation errors for ALL subsection
1306
-     *
1307
-     * @return EE_Validation_Error[]
1308
-     */
1309
-    public function get_validation_errors_accumulated()
1310
-    {
1311
-        $validation_errors = $this->get_validation_errors();
1312
-        foreach ($this->get_validatable_subsections() as $subsection) {
1313
-            if ($subsection instanceof EE_Form_Section_Proper) {
1314
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1315
-            } else {
1316
-                $validation_errors_on_this_subsection = $subsection->get_validation_errors();
1317
-            }
1318
-            if ($validation_errors_on_this_subsection) {
1319
-                $validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1320
-            }
1321
-        }
1322
-        return $validation_errors;
1323
-    }
1324
-
1325
-
1326
-
1327
-    /**
1328
-     * This isn't just the name of an input, it's a path pointing to an input. The
1329
-     * path is similar to a folder path: slash (/) means to descend into a subsection,
1330
-     * dot-dot-slash (../) means to ascend into the parent section.
1331
-     * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1332
-     * which will be returned.
1333
-     * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1334
-     * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1335
-     * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1336
-     * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1337
-     * Etc
1338
-     *
1339
-     * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1340
-     * @return EE_Form_Section_Base
1341
-     */
1342
-    public function find_section_from_path($form_section_path)
1343
-    {
1344
-        //check if we can find the input from purely going straight up the tree
1345
-        $input = parent::find_section_from_path($form_section_path);
1346
-        if ($input instanceof EE_Form_Section_Base) {
1347
-            return $input;
1348
-        }
1349
-        $next_slash_pos = strpos($form_section_path, '/');
1350
-        if ($next_slash_pos !== false) {
1351
-            $child_section_name = substr($form_section_path, 0, $next_slash_pos);
1352
-            $subpath = substr($form_section_path, $next_slash_pos + 1);
1353
-        } else {
1354
-            $child_section_name = $form_section_path;
1355
-            $subpath = '';
1356
-        }
1357
-        $child_section = $this->get_subsection($child_section_name);
1358
-        if ($child_section instanceof EE_Form_Section_Base) {
1359
-            return $child_section->find_section_from_path($subpath);
1360
-        } else {
1361
-            return null;
1362
-        }
1363
-    }
16
+	const SUBMITTED_FORM_DATA_SSN_KEY = 'submitted_form_data';
17
+
18
+	/**
19
+	 * Subsections
20
+	 *
21
+	 * @var EE_Form_Section_Validatable[]
22
+	 */
23
+	protected $_subsections = array();
24
+
25
+	/**
26
+	 * Strategy for laying out the form
27
+	 *
28
+	 * @var EE_Form_Section_Layout_Base
29
+	 */
30
+	protected $_layout_strategy;
31
+
32
+	/**
33
+	 * Whether or not this form has received and validated a form submission yet
34
+	 *
35
+	 * @var boolean
36
+	 */
37
+	protected $_received_submission = false;
38
+
39
+	/**
40
+	 * message displayed to users upon successful form submission
41
+	 *
42
+	 * @var string
43
+	 */
44
+	protected $_form_submission_success_message = '';
45
+
46
+	/**
47
+	 * message displayed to users upon unsuccessful form submission
48
+	 *
49
+	 * @var string
50
+	 */
51
+	protected $_form_submission_error_message = '';
52
+
53
+	/**
54
+	 * Stores all the data that will localized for form validation
55
+	 *
56
+	 * @var array
57
+	 */
58
+	static protected $_js_localization = array();
59
+
60
+	/**
61
+	 * whether or not the form's localized validation JS vars have been set
62
+	 *
63
+	 * @type boolean
64
+	 */
65
+	static protected $_scripts_localized = false;
66
+
67
+
68
+
69
+	/**
70
+	 * when constructing a proper form section, calls _construct_finalize on children
71
+	 * so that they know who their parent is, and what name they've been given.
72
+	 *
73
+	 * @param array $options_array   {
74
+	 * @type        $subsections     EE_Form_Section_Validatable[] where keys are the section's name
75
+	 * @type        $include         string[] numerically-indexed where values are section names to be included,
76
+	 *                               and in that order. This is handy if you want
77
+	 *                               the subsections to be ordered differently than the default, and if you override
78
+	 *                               which fields are shown
79
+	 * @type        $exclude         string[] values are subsections to be excluded. This is handy if you want
80
+	 *                               to remove certain default subsections (note: if you specify BOTH 'include' AND
81
+	 *                               'exclude', the inclusions will be applied first, and the exclusions will exclude
82
+	 *                               items from that list of inclusions)
83
+	 * @type        $layout_strategy EE_Form_Section_Layout_Base strategy for laying out the form
84
+	 *                               } @see EE_Form_Section_Validatable::__construct()
85
+	 * @throws \EE_Error
86
+	 */
87
+	public function __construct($options_array = array())
88
+	{
89
+		$options_array = (array)apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array,
90
+			$this);
91
+		//call parent first, as it may be setting the name
92
+		parent::__construct($options_array);
93
+		//if they've included subsections in the constructor, add them now
94
+		if (isset($options_array['include'])) {
95
+			//we are going to make sure we ONLY have those subsections to include
96
+			//AND we are going to make sure they're in that specified order
97
+			$reordered_subsections = array();
98
+			foreach ($options_array['include'] as $input_name) {
99
+				if (isset($this->_subsections[$input_name])) {
100
+					$reordered_subsections[$input_name] = $this->_subsections[$input_name];
101
+				}
102
+			}
103
+			$this->_subsections = $reordered_subsections;
104
+		}
105
+		if (isset($options_array['exclude'])) {
106
+			$exclude = $options_array['exclude'];
107
+			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
108
+		}
109
+		if (isset($options_array['layout_strategy'])) {
110
+			$this->_layout_strategy = $options_array['layout_strategy'];
111
+		}
112
+		if ( ! $this->_layout_strategy) {
113
+			$this->_layout_strategy = is_admin() ? new EE_Admin_Two_Column_Layout() : new EE_Two_Column_Layout();
114
+		}
115
+		$this->_layout_strategy->_construct_finalize($this);
116
+		//ok so we are definitely going to want the forms JS,
117
+		//so enqueue it or remember to enqueue it during wp_enqueue_scripts
118
+		if (did_action('wp_enqueue_scripts')
119
+			|| did_action('admin_enqueue_scripts')
120
+		) {
121
+			//ok so they've constructed this object after when they should have.
122
+			//just enqueue the generic form scripts and initialize the form immediately in the JS
123
+			\EE_Form_Section_Proper::wp_enqueue_scripts(true);
124
+		} else {
125
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
126
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
127
+		}
128
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
129
+		if (isset($options_array['name'])) {
130
+			$this->_construct_finalize(null, $options_array['name']);
131
+		}
132
+	}
133
+
134
+
135
+
136
+	/**
137
+	 * Finishes construction given the parent form section and this form section's name
138
+	 *
139
+	 * @param EE_Form_Section_Proper $parent_form_section
140
+	 * @param string                 $name
141
+	 * @throws \EE_Error
142
+	 */
143
+	public function _construct_finalize($parent_form_section, $name)
144
+	{
145
+		parent::_construct_finalize($parent_form_section, $name);
146
+		$this->_set_default_name_if_empty();
147
+		$this->_set_default_html_id_if_empty();
148
+		foreach ($this->_subsections as $subsection_name => $subsection) {
149
+			if ($subsection instanceof EE_Form_Section_Base) {
150
+				$subsection->_construct_finalize($this, $subsection_name);
151
+			} else {
152
+				throw new EE_Error(
153
+					sprintf(
154
+						__('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"',
155
+							'event_espresso'),
156
+						$subsection_name,
157
+						get_class($this),
158
+						$subsection ? get_class($subsection) : __('NULL', 'event_espresso')
159
+					)
160
+				);
161
+			}
162
+		}
163
+		do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
164
+	}
165
+
166
+
167
+
168
+	/**
169
+	 * Gets the layout strategy for this form section
170
+	 *
171
+	 * @return EE_Form_Section_Layout_Base
172
+	 */
173
+	public function get_layout_strategy()
174
+	{
175
+		return $this->_layout_strategy;
176
+	}
177
+
178
+
179
+
180
+	/**
181
+	 * Gets the HTML for a single input for this form section according
182
+	 * to the layout strategy
183
+	 *
184
+	 * @param EE_Form_Input_Base $input
185
+	 * @return string
186
+	 */
187
+	public function get_html_for_input($input)
188
+	{
189
+		return $this->_layout_strategy->layout_input($input);
190
+	}
191
+
192
+
193
+
194
+	/**
195
+	 * was_submitted - checks if form inputs are present in request data
196
+	 * Basically an alias for form_data_present_in() (which is used by both
197
+	 * proper form sections and form inputs)
198
+	 *
199
+	 * @param null $form_data
200
+	 * @return boolean
201
+	 */
202
+	public function was_submitted($form_data = null)
203
+	{
204
+		return $this->form_data_present_in($form_data);
205
+	}
206
+
207
+
208
+
209
+	/**
210
+	 * After the form section is initially created, call this to sanitize the data in the submission
211
+	 * which relates to this form section, validate it, and set it as properties on the form.
212
+	 *
213
+	 * @param array|null $req_data should usually be $_POST (the default).
214
+	 *                             However, you CAN supply a different array.
215
+	 *                             Consider using set_defaults() instead however.
216
+	 *                             (If you rendered the form in the page using echo $form_x->get_html()
217
+	 *                             the inputs will have the correct name in the request data for this function
218
+	 *                             to find them and populate the form with them.
219
+	 *                             If you have a flat form (with only input subsections),
220
+	 *                             you can supply a flat array where keys
221
+	 *                             are the form input names and values are their values)
222
+	 * @param boolean    $validate whether or not to perform validation on this data. Default is,
223
+	 *                             of course, to validate that data, and set errors on the invalid values.
224
+	 *                             But if the data has already been validated
225
+	 *                             (eg you validated the data then stored it in the DB)
226
+	 *                             you may want to skip this step.
227
+	 */
228
+	public function receive_form_submission($req_data = null, $validate = true)
229
+	{
230
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this,
231
+			$validate);
232
+		if ($req_data === null) {
233
+			$req_data = array_merge($_GET, $_POST);
234
+		}
235
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data,
236
+			$this);
237
+		$this->_normalize($req_data);
238
+		if ($validate) {
239
+			$this->_validate();
240
+			//if it's invalid, we're going to want to re-display so remember what they submitted
241
+			if ( ! $this->is_valid()) {
242
+				$this->store_submitted_form_data_in_session();
243
+			}
244
+		}
245
+		do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
246
+	}
247
+
248
+
249
+
250
+	/**
251
+	 * caches the originally submitted input values in the session
252
+	 * so that they can be used to repopulate the form if it failed validation
253
+	 *
254
+	 * @return boolean whether or not the data was successfully stored in the session
255
+	 */
256
+	protected function store_submitted_form_data_in_session()
257
+	{
258
+		return EE_Registry::instance()->SSN->set_session_data(
259
+			array(
260
+				\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY => $this->submitted_values(true),
261
+			)
262
+		);
263
+	}
264
+
265
+
266
+
267
+	/**
268
+	 * retrieves the originally submitted input values in the session
269
+	 * so that they can be used to repopulate the form if it failed validation
270
+	 *
271
+	 * @return array
272
+	 */
273
+	protected function get_submitted_form_data_from_session()
274
+	{
275
+		$session = EE_Registry::instance()->SSN;
276
+		if ($session instanceof EE_Session) {
277
+			return $session->get_session_data(
278
+				\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY
279
+			);
280
+		} else {
281
+			return array();
282
+		}
283
+	}
284
+
285
+
286
+
287
+	/**
288
+	 * flushed the originally submitted input values from the session
289
+	 *
290
+	 * @return boolean whether or not the data was successfully removed from the session
291
+	 */
292
+	protected function flush_submitted_form_data_from_session()
293
+	{
294
+		return EE_Registry::instance()->SSN->reset_data(
295
+			array(\EE_Form_Section_Proper::SUBMITTED_FORM_DATA_SSN_KEY)
296
+		);
297
+	}
298
+
299
+
300
+
301
+	/**
302
+	 * Populates this form and its subsections with data from the session.
303
+	 * (Wrapper for EE_Form_Section_Proper::receive_form_submission, so it shows
304
+	 * validation errors when displaying too)
305
+	 * Returns true if the form was populated from the session, false otherwise
306
+	 *
307
+	 * @return boolean
308
+	 */
309
+	public function populate_from_session()
310
+	{
311
+		$form_data_in_session = $this->get_submitted_form_data_from_session();
312
+		if (empty($form_data_in_session)) {
313
+			return false;
314
+		}
315
+		$this->receive_form_submission($form_data_in_session);
316
+		$this->flush_submitted_form_data_from_session();
317
+		if ($this->form_data_present_in($form_data_in_session)) {
318
+			return true;
319
+		} else {
320
+			return false;
321
+		}
322
+	}
323
+
324
+
325
+
326
+	/**
327
+	 * Populates the default data for the form, given an array where keys are
328
+	 * the input names, and values are their values (preferably normalized to be their
329
+	 * proper PHP types, not all strings... although that should be ok too).
330
+	 * Proper subsections are sub-arrays, the key being the subsection's name, and
331
+	 * the value being an array formatted in teh same way
332
+	 *
333
+	 * @param array $default_data
334
+	 */
335
+	public function populate_defaults($default_data)
336
+	{
337
+		foreach ($this->subsections() as $subsection_name => $subsection) {
338
+			if (isset($default_data[$subsection_name])) {
339
+				if ($subsection instanceof EE_Form_Input_Base) {
340
+					$subsection->set_default($default_data[$subsection_name]);
341
+				} elseif ($subsection instanceof EE_Form_Section_Proper) {
342
+					$subsection->populate_defaults($default_data[$subsection_name]);
343
+				}
344
+			}
345
+		}
346
+	}
347
+
348
+
349
+
350
+	/**
351
+	 * returns true if subsection exists
352
+	 *
353
+	 * @param string $name
354
+	 * @return boolean
355
+	 */
356
+	public function subsection_exists($name)
357
+	{
358
+		return isset($this->_subsections[$name]) ? true : false;
359
+	}
360
+
361
+
362
+
363
+	/**
364
+	 * Gets the subsection specified by its name
365
+	 *
366
+	 * @param string  $name
367
+	 * @param boolean $require_construction_to_be_finalized most client code should leave this as TRUE
368
+	 *                                                      so that the inputs will be properly configured.
369
+	 *                                                      However, some client code may be ok
370
+	 *                                                      with construction finalize being called later
371
+	 *                                                      (realizing that the subsections' html names
372
+	 *                                                      might not be set yet, etc.)
373
+	 * @return EE_Form_Section_Base
374
+	 * @throws \EE_Error
375
+	 */
376
+	public function get_subsection($name, $require_construction_to_be_finalized = true)
377
+	{
378
+		if ($require_construction_to_be_finalized) {
379
+			$this->ensure_construct_finalized_called();
380
+		}
381
+		return $this->subsection_exists($name) ? $this->_subsections[$name] : null;
382
+	}
383
+
384
+
385
+
386
+	/**
387
+	 * Gets all the validatable subsections of this form section
388
+	 *
389
+	 * @return EE_Form_Section_Validatable[]
390
+	 */
391
+	public function get_validatable_subsections()
392
+	{
393
+		$validatable_subsections = array();
394
+		foreach ($this->subsections() as $name => $obj) {
395
+			if ($obj instanceof EE_Form_Section_Validatable) {
396
+				$validatable_subsections[$name] = $obj;
397
+			}
398
+		}
399
+		return $validatable_subsections;
400
+	}
401
+
402
+
403
+
404
+	/**
405
+	 * Gets an input by the given name. If not found, or if its not an EE_FOrm_Input_Base child,
406
+	 * throw an EE_Error.
407
+	 *
408
+	 * @param string  $name
409
+	 * @param boolean $require_construction_to_be_finalized most client code should
410
+	 *                                                      leave this as TRUE so that the inputs will be properly
411
+	 *                                                      configured. However, some client code may be ok with
412
+	 *                                                      construction finalize being called later
413
+	 *                                                      (realizing that the subsections' html names might not be
414
+	 *                                                      set yet, etc.)
415
+	 * @return EE_Form_Input_Base
416
+	 * @throws EE_Error
417
+	 */
418
+	public function get_input($name, $require_construction_to_be_finalized = true)
419
+	{
420
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
421
+		if ( ! $subsection instanceof EE_Form_Input_Base) {
422
+			throw new EE_Error(
423
+				sprintf(
424
+					__(
425
+						"Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'",
426
+						'event_espresso'
427
+					),
428
+					$name,
429
+					get_class($this),
430
+					$subsection ? get_class($subsection) : __("NULL", 'event_espresso')
431
+				)
432
+			);
433
+		}
434
+		return $subsection;
435
+	}
436
+
437
+
438
+
439
+	/**
440
+	 * Like get_input(), gets the proper subsection of the form given the name,
441
+	 * otherwise throws an EE_Error
442
+	 *
443
+	 * @param string  $name
444
+	 * @param boolean $require_construction_to_be_finalized most client code should
445
+	 *                                                      leave this as TRUE so that the inputs will be properly
446
+	 *                                                      configured. However, some client code may be ok with
447
+	 *                                                      construction finalize being called later
448
+	 *                                                      (realizing that the subsections' html names might not be
449
+	 *                                                      set yet, etc.)
450
+	 * @return EE_Form_Section_Proper
451
+	 * @throws EE_Error
452
+	 */
453
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = true)
454
+	{
455
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
456
+		if ( ! $subsection instanceof EE_Form_Section_Proper) {
457
+			throw new EE_Error(
458
+				sprintf(
459
+					__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),
460
+					$name,
461
+					get_class($this)
462
+				)
463
+			);
464
+		}
465
+		return $subsection;
466
+	}
467
+
468
+
469
+
470
+	/**
471
+	 * Gets the value of the specified input. Should be called after receive_form_submission()
472
+	 * or populate_defaults() on the form, where the normalized value on the input is set.
473
+	 *
474
+	 * @param string $name
475
+	 * @return mixed depending on the input's type and its normalization strategy
476
+	 * @throws \EE_Error
477
+	 */
478
+	public function get_input_value($name)
479
+	{
480
+		$input = $this->get_input($name);
481
+		return $input->normalized_value();
482
+	}
483
+
484
+
485
+
486
+	/**
487
+	 * Checks if this form section itself is valid, and then checks its subsections
488
+	 *
489
+	 * @throws EE_Error
490
+	 * @return boolean
491
+	 */
492
+	public function is_valid()
493
+	{
494
+		if ( ! $this->has_received_submission()) {
495
+			throw new EE_Error(
496
+				sprintf(
497
+					__(
498
+						"You cannot check if a form is valid before receiving the form submission using receive_form_submission",
499
+						"event_espresso"
500
+					)
501
+				)
502
+			);
503
+		}
504
+		if ( ! parent::is_valid()) {
505
+			return false;
506
+		}
507
+		// ok so no general errors to this entire form section.
508
+		// so let's check the subsections, but only set errors if that hasn't been done yet
509
+		$set_submission_errors = $this->submission_error_message() === '' ? true : false;
510
+		foreach ($this->get_validatable_subsections() as $subsection) {
511
+			if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') {
512
+				if ($set_submission_errors) {
513
+					$this->set_submission_error_message($subsection->get_validation_error_string());
514
+				}
515
+				return false;
516
+			}
517
+		}
518
+		return true;
519
+	}
520
+
521
+
522
+
523
+	/**
524
+	 * gets teh default name of this form section if none is specified
525
+	 *
526
+	 * @return string
527
+	 */
528
+	protected function _set_default_name_if_empty()
529
+	{
530
+		if ( ! $this->_name) {
531
+			$classname = get_class($this);
532
+			$default_name = str_replace("EE_", "", $classname);
533
+			$this->_name = $default_name;
534
+		}
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Returns the HTML for the form, except for the form opening and closing tags
541
+	 * (as the form section doesn't know where you necessarily want to send the information to),
542
+	 * and except for a submit button. Enqueus JS and CSS; if called early enough we will
543
+	 * try to enqueue them in the header, otherwise they'll be enqueued in the footer.
544
+	 * Not doing_it_wrong because theoretically this CAN be used properly,
545
+	 * provided its used during "wp_enqueue_scripts", or it doesn't need to enqueue
546
+	 * any CSS.
547
+	 *
548
+	 * @throws \EE_Error
549
+	 */
550
+	public function get_html_and_js()
551
+	{
552
+		$this->enqueue_js();
553
+		return $this->get_html();
554
+	}
555
+
556
+
557
+
558
+	/**
559
+	 * returns HTML for displaying this form section. recursively calls display_section() on all subsections
560
+	 *
561
+	 * @param bool $display_previously_submitted_data
562
+	 * @return string
563
+	 */
564
+	public function get_html($display_previously_submitted_data = true)
565
+	{
566
+		$this->ensure_construct_finalized_called();
567
+		if ($display_previously_submitted_data) {
568
+			$this->populate_from_session();
569
+		}
570
+		return $this->_layout_strategy->layout_form();
571
+	}
572
+
573
+
574
+
575
+	/**
576
+	 * enqueues JS and CSS for the form.
577
+	 * It is preferred to call this before wp_enqueue_scripts so the
578
+	 * scripts and styles can be put in the header, but if called later
579
+	 * they will be put in the footer (which is OK for JS, but in HTML4 CSS should
580
+	 * only be in the header; but in HTML5 its ok in the body.
581
+	 * See http://stackoverflow.com/questions/4957446/load-external-css-file-in-body-tag.
582
+	 * So if your form enqueues CSS, it's preferred to call this before wp_enqueue_scripts.)
583
+	 *
584
+	 * @return string
585
+	 * @throws \EE_Error
586
+	 */
587
+	public function enqueue_js()
588
+	{
589
+		$this->_enqueue_and_localize_form_js();
590
+		foreach ($this->subsections() as $subsection) {
591
+			$subsection->enqueue_js();
592
+		}
593
+	}
594
+
595
+
596
+
597
+	/**
598
+	 * adds a filter so that jquery validate gets enqueued in EE_System::wp_enqueue_scripts().
599
+	 * This must be done BEFORE wp_enqueue_scripts() gets called, which is on
600
+	 * the wp_enqueue_scripts hook.
601
+	 * However, registering the form js and localizing it can happen when we
602
+	 * actually output the form (which is preferred, seeing how teh form's fields
603
+	 * could change until it's actually outputted)
604
+	 *
605
+	 * @param boolean $init_form_validation_automatically whether or not we want the form validation
606
+	 *                                                    to be triggered automatically or not
607
+	 * @return void
608
+	 */
609
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true)
610
+	{
611
+		add_filter('FHEE_load_jquery_validate', '__return_true');
612
+		wp_register_script(
613
+			'ee_form_section_validation',
614
+			EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js',
615
+			array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'),
616
+			EVENT_ESPRESSO_VERSION,
617
+			true
618
+		);
619
+		wp_localize_script(
620
+			'ee_form_section_validation',
621
+			'ee_form_section_validation_init',
622
+			array('init' => $init_form_validation_automatically ? true : false)
623
+		);
624
+	}
625
+
626
+
627
+
628
+	/**
629
+	 * gets the variables used by form_section_validation.js.
630
+	 * This needs to be called AFTER we've called $this->_enqueue_jquery_validate_script,
631
+	 * but before the wordpress hook wp_loaded
632
+	 *
633
+	 * @throws \EE_Error
634
+	 */
635
+	public function _enqueue_and_localize_form_js()
636
+	{
637
+		$this->ensure_construct_finalized_called();
638
+		//actually, we don't want to localize just yet. There may be other forms on the page.
639
+		//so we need to add our form section data to a static variable accessible by all form sections
640
+		//and localize it just before the footer
641
+		$this->localize_validation_rules();
642
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
643
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
644
+	}
645
+
646
+
647
+
648
+	/**
649
+	 * add our form section data to a static variable accessible by all form sections
650
+	 *
651
+	 * @param bool $return_for_subsection
652
+	 * @return void
653
+	 * @throws \EE_Error
654
+	 */
655
+	public function localize_validation_rules($return_for_subsection = false)
656
+	{
657
+		// we only want to localize vars ONCE for the entire form,
658
+		// so if the form section doesn't have a parent, then it must be the top dog
659
+		if ($return_for_subsection || ! $this->parent_section()) {
660
+			EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
661
+				'form_section_id'  => $this->html_id(true),
662
+				'validation_rules' => $this->get_jquery_validation_rules(),
663
+				'other_data'       => $this->get_other_js_data(),
664
+				'errors'           => $this->subsection_validation_errors_by_html_name(),
665
+			);
666
+			EE_Form_Section_Proper::$_scripts_localized = true;
667
+		}
668
+	}
669
+
670
+
671
+
672
+	/**
673
+	 * Gets an array of extra data that will be useful for client-side javascript.
674
+	 * This is primarily data added by inputs and forms in addition to any
675
+	 * scripts they might enqueue
676
+	 *
677
+	 * @param array $form_other_js_data
678
+	 * @return array
679
+	 */
680
+	public function get_other_js_data($form_other_js_data = array())
681
+	{
682
+		foreach ($this->subsections() as $subsection) {
683
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
684
+		}
685
+		return $form_other_js_data;
686
+	}
687
+
688
+
689
+
690
+	/**
691
+	 * Gets a flat array of inputs for this form section and its subsections.
692
+	 * Keys are their form names, and values are the inputs themselves
693
+	 *
694
+	 * @return EE_Form_Input_Base
695
+	 */
696
+	public function inputs_in_subsections()
697
+	{
698
+		$inputs = array();
699
+		foreach ($this->subsections() as $subsection) {
700
+			if ($subsection instanceof EE_Form_Input_Base) {
701
+				$inputs[$subsection->html_name()] = $subsection;
702
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
703
+				$inputs += $subsection->inputs_in_subsections();
704
+			}
705
+		}
706
+		return $inputs;
707
+	}
708
+
709
+
710
+
711
+	/**
712
+	 * Gets a flat array of all the validation errors.
713
+	 * Keys are html names (because those should be unique)
714
+	 * and values are a string of all their validation errors
715
+	 *
716
+	 * @return string[]
717
+	 */
718
+	public function subsection_validation_errors_by_html_name()
719
+	{
720
+		$inputs = $this->inputs();
721
+		$errors = array();
722
+		foreach ($inputs as $form_input) {
723
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
724
+				$errors[$form_input->html_name()] = $form_input->get_validation_error_string();
725
+			}
726
+		}
727
+		return $errors;
728
+	}
729
+
730
+
731
+
732
+	/**
733
+	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
734
+	 * Should be setup by each form during the _enqueues_and_localize_form_js
735
+	 */
736
+	public static function localize_script_for_all_forms()
737
+	{
738
+		//allow inputs and stuff to hook in their JS and stuff here
739
+		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
740
+		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
741
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
742
+			? EE_Registry::instance()->CFG->registration->email_validation_level
743
+			: 'wp_default';
744
+		EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
745
+		wp_enqueue_script('ee_form_section_validation');
746
+		wp_localize_script(
747
+			'ee_form_section_validation',
748
+			'ee_form_section_vars',
749
+			EE_Form_Section_Proper::$_js_localization
750
+		);
751
+	}
752
+
753
+
754
+
755
+	/**
756
+	 * ensure_scripts_localized
757
+	 */
758
+	public function ensure_scripts_localized()
759
+	{
760
+		if ( ! EE_Form_Section_Proper::$_scripts_localized) {
761
+			$this->_enqueue_and_localize_form_js();
762
+		}
763
+	}
764
+
765
+
766
+
767
+	/**
768
+	 * Gets the hard-coded validation error messages to be used in the JS. The convention
769
+	 * is that the key here should be the same as the custom validation rule put in the JS file
770
+	 *
771
+	 * @return array keys are custom validation rules, and values are internationalized strings
772
+	 */
773
+	private static function _get_localized_error_messages()
774
+	{
775
+		return array(
776
+			'validUrl' => __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
777
+			'regex'    => __('Please check your input', 'event_espresso'),
778
+		);
779
+	}
780
+
781
+
782
+
783
+	/**
784
+	 * @return array
785
+	 */
786
+	public static function js_localization()
787
+	{
788
+		return self::$_js_localization;
789
+	}
790
+
791
+
792
+
793
+	/**
794
+	 * @return array
795
+	 */
796
+	public static function reset_js_localization()
797
+	{
798
+		self::$_js_localization = array();
799
+	}
800
+
801
+
802
+
803
+	/**
804
+	 * Gets the JS to put inside the jquery validation rules for subsection of this form section.
805
+	 * See parent function for more...
806
+	 *
807
+	 * @return array
808
+	 */
809
+	public function get_jquery_validation_rules()
810
+	{
811
+		$jquery_validation_rules = array();
812
+		foreach ($this->get_validatable_subsections() as $subsection) {
813
+			$jquery_validation_rules = array_merge(
814
+				$jquery_validation_rules,
815
+				$subsection->get_jquery_validation_rules()
816
+			);
817
+		}
818
+		return $jquery_validation_rules;
819
+	}
820
+
821
+
822
+
823
+	/**
824
+	 * Sanitizes all the data and sets the sanitized value of each field
825
+	 *
826
+	 * @param array $req_data like $_POST
827
+	 * @return void
828
+	 */
829
+	protected function _normalize($req_data)
830
+	{
831
+		$this->_received_submission = true;
832
+		$this->_validation_errors = array();
833
+		foreach ($this->get_validatable_subsections() as $subsection) {
834
+			try {
835
+				$subsection->_normalize($req_data);
836
+			} catch (EE_Validation_Error $e) {
837
+				$subsection->add_validation_error($e);
838
+			}
839
+		}
840
+	}
841
+
842
+
843
+
844
+	/**
845
+	 * Performs validation on this form section and its subsections.
846
+	 * For each subsection,
847
+	 * calls _validate_{subsection_name} on THIS form (if the function exists)
848
+	 * and passes it the subsection, then calls _validate on that subsection.
849
+	 * If you need to perform validation on the form as a whole (considering multiple)
850
+	 * you would be best to override this _validate method,
851
+	 * calling parent::_validate() first.
852
+	 */
853
+	protected function _validate()
854
+	{
855
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
856
+			if (method_exists($this, '_validate_' . $subsection_name)) {
857
+				call_user_func_array(array($this, '_validate_' . $subsection_name), array($subsection));
858
+			}
859
+			$subsection->_validate();
860
+		}
861
+	}
862
+
863
+
864
+
865
+	/**
866
+	 * Gets all the validated inputs for the form section
867
+	 *
868
+	 * @return array
869
+	 */
870
+	public function valid_data()
871
+	{
872
+		$inputs = array();
873
+		foreach ($this->subsections() as $subsection_name => $subsection) {
874
+			if ($subsection instanceof EE_Form_Section_Proper) {
875
+				$inputs[$subsection_name] = $subsection->valid_data();
876
+			} else if ($subsection instanceof EE_Form_Input_Base) {
877
+				$inputs[$subsection_name] = $subsection->normalized_value();
878
+			}
879
+		}
880
+		return $inputs;
881
+	}
882
+
883
+
884
+
885
+	/**
886
+	 * Gets all the inputs on this form section
887
+	 *
888
+	 * @return EE_Form_Input_Base[]
889
+	 */
890
+	public function inputs()
891
+	{
892
+		$inputs = array();
893
+		foreach ($this->subsections() as $subsection_name => $subsection) {
894
+			if ($subsection instanceof EE_Form_Input_Base) {
895
+				$inputs[$subsection_name] = $subsection;
896
+			}
897
+		}
898
+		return $inputs;
899
+	}
900
+
901
+
902
+
903
+	/**
904
+	 * Gets all the subsections which are a proper form
905
+	 *
906
+	 * @return EE_Form_Section_Proper[]
907
+	 */
908
+	public function subforms()
909
+	{
910
+		$form_sections = array();
911
+		foreach ($this->subsections() as $name => $obj) {
912
+			if ($obj instanceof EE_Form_Section_Proper) {
913
+				$form_sections[$name] = $obj;
914
+			}
915
+		}
916
+		return $form_sections;
917
+	}
918
+
919
+
920
+
921
+	/**
922
+	 * Gets all the subsections (inputs, proper subsections, or html-only sections).
923
+	 * Consider using inputs() or subforms()
924
+	 * if you only want form inputs or proper form sections.
925
+	 *
926
+	 * @return EE_Form_Section_Proper[]
927
+	 */
928
+	public function subsections()
929
+	{
930
+		$this->ensure_construct_finalized_called();
931
+		return $this->_subsections;
932
+	}
933
+
934
+
935
+
936
+	/**
937
+	 * Returns a simple array where keys are input names, and values are their normalized
938
+	 * values. (Similar to calling get_input_value on inputs)
939
+	 *
940
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
941
+	 *                                        or just this forms' direct children inputs
942
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
943
+	 *                                        or allow multidimensional array
944
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
945
+	 *                                        with array keys being input names
946
+	 *                                        (regardless of whether they are from a subsection or not),
947
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
948
+	 *                                        where keys are always subsection names and values are either
949
+	 *                                        the input's normalized value, or an array like the top-level array
950
+	 */
951
+	public function input_values($include_subform_inputs = false, $flatten = false)
952
+	{
953
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
954
+	}
955
+
956
+
957
+
958
+	/**
959
+	 * Similar to EE_Form_Section_Proper::input_values(), except this returns the 'display_value'
960
+	 * of each input. On some inputs (especially radio boxes or checkboxes), the value stored
961
+	 * is not necessarily the value we want to display to users. This creates an array
962
+	 * where keys are the input names, and values are their display values
963
+	 *
964
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
965
+	 *                                        or just this forms' direct children inputs
966
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
967
+	 *                                        or allow multidimensional array
968
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array
969
+	 *                                        with array keys being input names
970
+	 *                                        (regardless of whether they are from a subsection or not),
971
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
972
+	 *                                        where keys are always subsection names and values are either
973
+	 *                                        the input's normalized value, or an array like the top-level array
974
+	 */
975
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false)
976
+	{
977
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
978
+	}
979
+
980
+
981
+
982
+	/**
983
+	 * Gets the input values from the form
984
+	 *
985
+	 * @param boolean $pretty                 Whether to retrieve the pretty value,
986
+	 *                                        or just the normalized value
987
+	 * @param boolean $include_subform_inputs Whether to include inputs from subforms,
988
+	 *                                        or just this forms' direct children inputs
989
+	 * @param boolean $flatten                Whether to force the results into 1-dimensional array,
990
+	 *                                        or allow multidimensional array
991
+	 * @return array if $flatten is TRUE it will always be a 1-dimensional array with array keys being
992
+	 *                                        input names (regardless of whether they are from a subsection or not),
993
+	 *                                        and if $flatten is FALSE it can be a multidimensional array
994
+	 *                                        where keys are always subsection names and values are either
995
+	 *                                        the input's normalized value, or an array like the top-level array
996
+	 */
997
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false)
998
+	{
999
+		$input_values = array();
1000
+		foreach ($this->subsections() as $subsection_name => $subsection) {
1001
+			if ($subsection instanceof EE_Form_Input_Base) {
1002
+				$input_values[$subsection_name] = $pretty
1003
+					? $subsection->pretty_value()
1004
+					: $subsection->normalized_value();
1005
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
1006
+				$subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
1007
+				if ($flatten) {
1008
+					$input_values = array_merge($input_values, $subform_input_values);
1009
+				} else {
1010
+					$input_values[$subsection_name] = $subform_input_values;
1011
+				}
1012
+			}
1013
+		}
1014
+		return $input_values;
1015
+	}
1016
+
1017
+
1018
+
1019
+	/**
1020
+	 * Gets the originally submitted input values from the form
1021
+	 *
1022
+	 * @param boolean $include_subforms  Whether to include inputs from subforms,
1023
+	 *                                   or just this forms' direct children inputs
1024
+	 * @return array                     if $flatten is TRUE it will always be a 1-dimensional array
1025
+	 *                                   with array keys being input names
1026
+	 *                                   (regardless of whether they are from a subsection or not),
1027
+	 *                                   and if $flatten is FALSE it can be a multidimensional array
1028
+	 *                                   where keys are always subsection names and values are either
1029
+	 *                                   the input's normalized value, or an array like the top-level array
1030
+	 */
1031
+	public function submitted_values($include_subforms = false)
1032
+	{
1033
+		$submitted_values = array();
1034
+		foreach ($this->subsections() as $subsection) {
1035
+			if ($subsection instanceof EE_Form_Input_Base) {
1036
+				// is this input part of an array of inputs?
1037
+				if (strpos($subsection->html_name(), '[') !== false) {
1038
+					$full_input_name = \EEH_Array::convert_array_values_to_keys(
1039
+						explode('[', str_replace(']', '', $subsection->html_name())),
1040
+						$subsection->raw_value()
1041
+					);
1042
+					$submitted_values = array_replace_recursive($submitted_values, $full_input_name);
1043
+				} else {
1044
+					$submitted_values[$subsection->html_name()] = $subsection->raw_value();
1045
+				}
1046
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subforms) {
1047
+				$subform_input_values = $subsection->submitted_values($include_subforms);
1048
+				$submitted_values = array_replace_recursive($submitted_values, $subform_input_values);
1049
+			}
1050
+		}
1051
+		return $submitted_values;
1052
+	}
1053
+
1054
+
1055
+
1056
+	/**
1057
+	 * Indicates whether or not this form has received a submission yet
1058
+	 * (ie, had receive_form_submission called on it yet)
1059
+	 *
1060
+	 * @return boolean
1061
+	 * @throws \EE_Error
1062
+	 */
1063
+	public function has_received_submission()
1064
+	{
1065
+		$this->ensure_construct_finalized_called();
1066
+		return $this->_received_submission;
1067
+	}
1068
+
1069
+
1070
+
1071
+	/**
1072
+	 * Equivalent to passing 'exclude' in the constructor's options array.
1073
+	 * Removes the listed inputs from the form
1074
+	 *
1075
+	 * @param array $inputs_to_exclude values are the input names
1076
+	 * @return void
1077
+	 */
1078
+	public function exclude(array $inputs_to_exclude = array())
1079
+	{
1080
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
1081
+			unset($this->_subsections[$input_to_exclude_name]);
1082
+		}
1083
+	}
1084
+
1085
+
1086
+
1087
+	/**
1088
+	 * @param array $inputs_to_hide
1089
+	 * @throws \EE_Error
1090
+	 */
1091
+	public function hide($inputs_to_hide = array())
1092
+	{
1093
+		foreach ($inputs_to_hide as $input_to_hide) {
1094
+			$input = $this->get_input($input_to_hide);
1095
+			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
1096
+		}
1097
+	}
1098
+
1099
+
1100
+
1101
+	/**
1102
+	 * add_subsections
1103
+	 * Adds the listed subsections to the form section.
1104
+	 * If $subsection_name_to_target is provided,
1105
+	 * then new subsections are added before or after that subsection,
1106
+	 * otherwise to the start or end of the entire subsections array.
1107
+	 *
1108
+	 * @param EE_Form_Section_Base[] $new_subsections           array of new form subsections
1109
+	 *                                                          where keys are their names
1110
+	 * @param string                 $subsection_name_to_target an existing for section that $new_subsections
1111
+	 *                                                          should be added before or after
1112
+	 *                                                          IF $subsection_name_to_target is null,
1113
+	 *                                                          then $new_subsections will be added to
1114
+	 *                                                          the beginning or end of the entire subsections array
1115
+	 * @param boolean                $add_before                whether to add $new_subsections, before or after
1116
+	 *                                                          $subsection_name_to_target,
1117
+	 *                                                          or if $subsection_name_to_target is null,
1118
+	 *                                                          before or after entire subsections array
1119
+	 * @return void
1120
+	 * @throws \EE_Error
1121
+	 */
1122
+	public function add_subsections($new_subsections, $subsection_name_to_target = null, $add_before = true)
1123
+	{
1124
+		foreach ($new_subsections as $subsection_name => $subsection) {
1125
+			if ( ! $subsection instanceof EE_Form_Section_Base) {
1126
+				EE_Error::add_error(
1127
+					sprintf(
1128
+						__(
1129
+							"Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.",
1130
+							"event_espresso"
1131
+						),
1132
+						get_class($subsection),
1133
+						$subsection_name,
1134
+						$this->name()
1135
+					)
1136
+				);
1137
+				unset($new_subsections[$subsection_name]);
1138
+			}
1139
+		}
1140
+		$this->_subsections = EEH_Array::insert_into_array(
1141
+			$this->_subsections,
1142
+			$new_subsections,
1143
+			$subsection_name_to_target,
1144
+			$add_before
1145
+		);
1146
+		if ($this->_construction_finalized) {
1147
+			foreach ($this->_subsections as $name => $subsection) {
1148
+				$subsection->_construct_finalize($this, $name);
1149
+			}
1150
+		}
1151
+	}
1152
+
1153
+
1154
+
1155
+	/**
1156
+	 * Just gets all validatable subsections to clean their sensitive data
1157
+	 */
1158
+	public function clean_sensitive_data()
1159
+	{
1160
+		foreach ($this->get_validatable_subsections() as $subsection) {
1161
+			$subsection->clean_sensitive_data();
1162
+		}
1163
+	}
1164
+
1165
+
1166
+
1167
+	/**
1168
+	 * @param string $form_submission_error_message
1169
+	 */
1170
+	public function set_submission_error_message($form_submission_error_message = '')
1171
+	{
1172
+		$this->_form_submission_error_message .= ! empty($form_submission_error_message)
1173
+			? $form_submission_error_message
1174
+			: __('Form submission failed due to errors', 'event_espresso');
1175
+	}
1176
+
1177
+
1178
+
1179
+	/**
1180
+	 * @return string
1181
+	 */
1182
+	public function submission_error_message()
1183
+	{
1184
+		return $this->_form_submission_error_message;
1185
+	}
1186
+
1187
+
1188
+
1189
+	/**
1190
+	 * @param string $form_submission_success_message
1191
+	 */
1192
+	public function set_submission_success_message($form_submission_success_message)
1193
+	{
1194
+		$this->_form_submission_success_message .= ! empty($form_submission_success_message)
1195
+			? $form_submission_success_message
1196
+			: __('Form submitted successfully', 'event_espresso');
1197
+	}
1198
+
1199
+
1200
+
1201
+	/**
1202
+	 * @return string
1203
+	 */
1204
+	public function submission_success_message()
1205
+	{
1206
+		return $this->_form_submission_success_message;
1207
+	}
1208
+
1209
+
1210
+
1211
+	/**
1212
+	 * Returns the prefix that should be used on child of this form section for
1213
+	 * their html names. If this form section itself has a parent, prepends ITS
1214
+	 * prefix onto this form section's prefix. Used primarily by
1215
+	 * EE_Form_Input_Base::_set_default_html_name_if_empty
1216
+	 *
1217
+	 * @return string
1218
+	 * @throws \EE_Error
1219
+	 */
1220
+	public function html_name_prefix()
1221
+	{
1222
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
1223
+			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
1224
+		} else {
1225
+			return $this->name();
1226
+		}
1227
+	}
1228
+
1229
+
1230
+
1231
+	/**
1232
+	 * Gets the name, but first checks _construct_finalize has been called. If not,
1233
+	 * calls it (assumes there is no parent and that we want the name to be whatever
1234
+	 * was set, which is probably nothing, or the classname)
1235
+	 *
1236
+	 * @return string
1237
+	 * @throws \EE_Error
1238
+	 */
1239
+	public function name()
1240
+	{
1241
+		$this->ensure_construct_finalized_called();
1242
+		return parent::name();
1243
+	}
1244
+
1245
+
1246
+
1247
+	/**
1248
+	 * @return EE_Form_Section_Proper
1249
+	 * @throws \EE_Error
1250
+	 */
1251
+	public function parent_section()
1252
+	{
1253
+		$this->ensure_construct_finalized_called();
1254
+		return parent::parent_section();
1255
+	}
1256
+
1257
+
1258
+
1259
+	/**
1260
+	 * make sure construction finalized was called, otherwise children might not be ready
1261
+	 *
1262
+	 * @return void
1263
+	 * @throws \EE_Error
1264
+	 */
1265
+	public function ensure_construct_finalized_called()
1266
+	{
1267
+		if ( ! $this->_construction_finalized) {
1268
+			$this->_construct_finalize($this->_parent_section, $this->_name);
1269
+		}
1270
+	}
1271
+
1272
+
1273
+
1274
+	/**
1275
+	 * Checks if any of this form section's inputs, or any of its children's inputs,
1276
+	 * are in teh form data. If any are found, returns true. Else false
1277
+	 *
1278
+	 * @param array $req_data
1279
+	 * @return boolean
1280
+	 */
1281
+	public function form_data_present_in($req_data = null)
1282
+	{
1283
+		if ($req_data === null) {
1284
+			$req_data = $_POST;
1285
+		}
1286
+		foreach ($this->subsections() as $subsection) {
1287
+			if ($subsection instanceof EE_Form_Input_Base) {
1288
+				if ($subsection->form_data_present_in($req_data)) {
1289
+					return true;
1290
+				}
1291
+			} elseif ($subsection instanceof EE_Form_Section_Proper) {
1292
+				if ($subsection->form_data_present_in($req_data)) {
1293
+					return true;
1294
+				}
1295
+			}
1296
+		}
1297
+		return false;
1298
+	}
1299
+
1300
+
1301
+
1302
+	/**
1303
+	 * Gets validation errors for this form section and subsections
1304
+	 * Similar to EE_Form_Section_Validatable::get_validation_errors() except this
1305
+	 * gets the validation errors for ALL subsection
1306
+	 *
1307
+	 * @return EE_Validation_Error[]
1308
+	 */
1309
+	public function get_validation_errors_accumulated()
1310
+	{
1311
+		$validation_errors = $this->get_validation_errors();
1312
+		foreach ($this->get_validatable_subsections() as $subsection) {
1313
+			if ($subsection instanceof EE_Form_Section_Proper) {
1314
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1315
+			} else {
1316
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1317
+			}
1318
+			if ($validation_errors_on_this_subsection) {
1319
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1320
+			}
1321
+		}
1322
+		return $validation_errors;
1323
+	}
1324
+
1325
+
1326
+
1327
+	/**
1328
+	 * This isn't just the name of an input, it's a path pointing to an input. The
1329
+	 * path is similar to a folder path: slash (/) means to descend into a subsection,
1330
+	 * dot-dot-slash (../) means to ascend into the parent section.
1331
+	 * After a series of slashes and dot-dot-slashes, there should be the name of an input,
1332
+	 * which will be returned.
1333
+	 * Eg, if you want the related input to be conditional on a sibling input name 'foobar'
1334
+	 * just use 'foobar'. If you want it to be conditional on an aunt/uncle input name
1335
+	 * 'baz', use '../baz'. If you want it to be conditional on a cousin input,
1336
+	 * the child of 'baz_section' named 'baz_child', use '../baz_section/baz_child'.
1337
+	 * Etc
1338
+	 *
1339
+	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1340
+	 * @return EE_Form_Section_Base
1341
+	 */
1342
+	public function find_section_from_path($form_section_path)
1343
+	{
1344
+		//check if we can find the input from purely going straight up the tree
1345
+		$input = parent::find_section_from_path($form_section_path);
1346
+		if ($input instanceof EE_Form_Section_Base) {
1347
+			return $input;
1348
+		}
1349
+		$next_slash_pos = strpos($form_section_path, '/');
1350
+		if ($next_slash_pos !== false) {
1351
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1352
+			$subpath = substr($form_section_path, $next_slash_pos + 1);
1353
+		} else {
1354
+			$child_section_name = $form_section_path;
1355
+			$subpath = '';
1356
+		}
1357
+		$child_section = $this->get_subsection($child_section_name);
1358
+		if ($child_section instanceof EE_Form_Section_Base) {
1359
+			return $child_section->find_section_from_path($subpath);
1360
+		} else {
1361
+			return null;
1362
+		}
1363
+	}
1364 1364
 
1365 1365
 }
1366 1366
 
Please login to merge, or discard this patch.
core/libraries/payment_methods/EE_Payment_Method_Manager.lib.php 1 patch
Indentation   +407 added lines, -407 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 
5 5
 
@@ -17,407 +17,407 @@  discard block
 block discarded – undo
17 17
 class EE_Payment_Method_Manager
18 18
 {
19 19
 
20
-    /**
21
-     *    instance of the EE_Payment_Method_Manager object
22
-     *
23
-     * @var    $_instance
24
-     * @access    private
25
-     */
26
-    private static $_instance;
27
-
28
-    /**
29
-     * @var array keys are classnames without 'EE_PMT_', values are their filepaths
30
-     */
31
-    protected $_payment_method_types = array();
32
-
33
-
34
-
35
-    /**
36
-     * @singleton method used to instantiate class object
37
-     * @access    public
38
-     * @return EE_Payment_Method_Manager instance
39
-     */
40
-    public static function instance()
41
-    {
42
-        // check if class object is instantiated, and instantiated properly
43
-        if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
44
-            self::$_instance = new self();
45
-        }
46
-        EE_Registry::instance()->load_lib('PMT_Base');
47
-        return self::$_instance;
48
-    }
49
-
50
-
51
-
52
-    /**
53
-     * Resets the instance and returns a new one
54
-     *
55
-     * @return EE_Payment_Method_Manager
56
-     */
57
-    public static function reset()
58
-    {
59
-        self::$_instance = null;
60
-        return self::instance();
61
-    }
62
-
63
-
64
-
65
-    /**
66
-     * If necessary, re-register payment methods
67
-     *
68
-     * @param boolean $force_recheck whether to recheck for payment method types,
69
-     *                               or just re-use the PMTs we found last time we checked during this request (if
70
-     *                               we have not yet checked during this request, then we need to check anyways)
71
-     */
72
-    public function maybe_register_payment_methods($force_recheck = false)
73
-    {
74
-        if ( ! $this->_payment_method_types || $force_recheck) {
75
-            $this->_register_payment_methods();
76
-            //if in admin lets ensure caps are set.
77
-            if (is_admin()) {
78
-                add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
79
-                EE_Registry::instance()->CAP->init_caps();
80
-            }
81
-        }
82
-    }
83
-
84
-
85
-
86
-    /**
87
-     *        register_payment_methods
88
-     *
89
-     * @return array
90
-     */
91
-    protected function _register_payment_methods()
92
-    {
93
-        // grab list of installed modules
94
-        $pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
95
-        // filter list of modules to register
96
-        $pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
97
-            $pm_to_register);
98
-        // loop through folders
99
-        foreach ($pm_to_register as $pm_path) {
100
-            $this->register_payment_method($pm_path);
101
-        }
102
-        do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
103
-        // filter list of installed modules
104
-        //keep them organized alphabetically by the payment method type's name
105
-        ksort($this->_payment_method_types);
106
-        return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
107
-            $this->_payment_method_types);
108
-    }
109
-
110
-
111
-
112
-    /**
113
-     *    register_payment_method- makes core aware of this payment method
114
-     *
115
-     * @access public
116
-     * @param string $payment_method_path - full path up to and including payment method folder
117
-     * @return boolean
118
-     */
119
-    public function register_payment_method($payment_method_path = '')
120
-    {
121
-        do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
122
-        $module_ext = '.pm.php';
123
-        // make all separators match
124
-        $payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
125
-        // grab and sanitize module name
126
-        $module_dir = basename($payment_method_path);
127
-        // create classname from module directory name
128
-        $module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
129
-        // add class prefix
130
-        $module_class = 'EE_PMT_' . $module;
131
-        // does the module exist ?
132
-        if ( ! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
133
-            $msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.',
134
-                'event_espresso'), $module);
135
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
136
-            return false;
137
-        }
138
-        if (WP_DEBUG === true) {
139
-            EEH_Debug_Tools::instance()->start_timer();
140
-        }
141
-        // load the module class file
142
-        require_once($payment_method_path . DS . $module_class . $module_ext);
143
-        if (WP_DEBUG === true) {
144
-            EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class");
145
-        }
146
-        // verify that class exists
147
-        if ( ! class_exists($module_class)) {
148
-            $msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
149
-            EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
150
-            return false;
151
-        }
152
-        // add to array of registered modules
153
-        $this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
154
-        return true;
155
-    }
156
-
157
-
158
-
159
-    /**
160
-     * Checks if a payment method has been registered, and if so includes it
161
-     *
162
-     * @param string  $payment_method_name like 'Paypal_Pro', (ie classname without the prefix 'EEPM_')
163
-     * @param boolean $force_recheck       whether to force re-checking for new payment method types
164
-     * @return boolean
165
-     */
166
-    public function payment_method_type_exists($payment_method_name, $force_recheck = false)
167
-    {
168
-        if (
169
-            $force_recheck
170
-            || ! is_array($this->_payment_method_types)
171
-            || ! isset($this->_payment_method_types[$payment_method_name])
172
-        ) {
173
-            $this->maybe_register_payment_methods($force_recheck);
174
-        }
175
-        if (isset($this->_payment_method_types[$payment_method_name])) {
176
-            require_once($this->_payment_method_types[$payment_method_name]);
177
-            return true;
178
-        } else {
179
-            return false;
180
-        }
181
-    }
182
-
183
-
184
-
185
-    /**
186
-     * Returns all the classnames of the various payment method types
187
-     *
188
-     * @param boolean $with_prefixes TRUE: get payment method type classnames; false just their 'names'
189
-     *                               (what you'd find in wp_esp_payment_method.PMD_type)
190
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
191
-     * @return array
192
-     */
193
-    public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
194
-    {
195
-        $this->maybe_register_payment_methods($force_recheck);
196
-        if ($with_prefixes) {
197
-            $classnames = array_keys($this->_payment_method_types);
198
-            $payment_methods = array();
199
-            foreach ($classnames as $classname) {
200
-                $payment_methods[] = $this->payment_method_class_from_type($classname);
201
-            }
202
-            return $payment_methods;
203
-        } else {
204
-            return array_keys($this->_payment_method_types);
205
-        }
206
-    }
207
-
208
-
209
-
210
-    /**
211
-     * Gets an object of each payment method type, none of which are bound to a
212
-     * payment method instance
213
-     *
214
-     * @param boolean $force_recheck whether to force re-checking for new payment method types
215
-     * @return EE_PMT_Base[]
216
-     */
217
-    public function payment_method_types($force_recheck = false)
218
-    {
219
-        $this->maybe_register_payment_methods($force_recheck);
220
-        $pmt_objs = array();
221
-        foreach ($this->payment_method_type_names(true) as $classname) {
222
-            $pmt_objs[] = new $classname;
223
-        }
224
-        return $pmt_objs;
225
-    }
226
-
227
-
228
-
229
-    /**
230
-     * Changes the payment method's classname into the payment method type's name
231
-     * (as used on the payment method's table's PMD_type field)
232
-     *
233
-     * @param string $classname
234
-     * @return string
235
-     */
236
-    public function payment_method_type_sans_class_prefix($classname)
237
-    {
238
-        return str_replace("EE_PMT_", "", $classname);
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * Does the opposite of payment-method_type_sans_prefix
245
-     *
246
-     * @param string $type
247
-     * @return string
248
-     */
249
-    public function payment_method_class_from_type($type)
250
-    {
251
-        $this->maybe_register_payment_methods();
252
-        return "EE_PMT_" . $type;
253
-    }
254
-
255
-
256
-
257
-    /**
258
-     * Activates a payment method of the given type.
259
-     *
260
-     * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
261
-     * @return \EE_Payment_Method
262
-     * @throws \EE_Error
263
-     */
264
-    public function activate_a_payment_method_of_type($payment_method_type)
265
-    {
266
-        $payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
267
-        if ( ! $payment_method instanceof EE_Payment_Method) {
268
-            $pm_type_class = $this->payment_method_class_from_type($payment_method_type);
269
-            if (class_exists($pm_type_class)) {
270
-                /** @var $pm_type_obj EE_PMT_Base */
271
-                $pm_type_obj = new $pm_type_class;
272
-                $payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
273
-                if ( ! $payment_method) {
274
-                    $payment_method = $this->create_payment_method_of_type($pm_type_obj);
275
-                }
276
-                $payment_method->set_type($payment_method_type);
277
-                $this->initialize_payment_method($payment_method);
278
-            } else {
279
-                throw new EE_Error(
280
-                    sprintf(
281
-                        __('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'),
282
-                        $pm_type_class)
283
-                );
284
-            }
285
-        }
286
-        $payment_method->set_active();
287
-        $payment_method->save();
288
-        $this->set_usable_currencies_on_payment_method($payment_method);
289
-        if ($payment_method->type() === 'Invoice') {
290
-            /** @type EE_Message_Resource_Manager $message_resource_manager */
291
-            $message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
292
-            $message_resource_manager->ensure_message_type_is_active('invoice', 'html');
293
-            $message_resource_manager->ensure_messenger_is_active('pdf');
294
-            EE_Error::add_persistent_admin_notice(
295
-                'invoice_pm_requirements_notice',
296
-                sprintf(
297
-                    __('The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
298
-                        'event_espresso'),
299
-                    '<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
300
-                    '</a>'
301
-                ),
302
-                true
303
-            );
304
-        }
305
-        return $payment_method;
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * Creates a payment method of the specified type. Does not save it.
312
-     *
313
-     * @global WP_User    $current_user
314
-     * @param EE_PMT_Base $pm_type_obj
315
-     * @return EE_Payment_Method
316
-     * @throws \EE_Error
317
-     */
318
-    public function create_payment_method_of_type($pm_type_obj)
319
-    {
320
-        global $current_user;
321
-        $payment_method = EE_Payment_Method::new_instance(
322
-            array(
323
-                'PMD_type'       => $pm_type_obj->system_name(),
324
-                'PMD_name'       => $pm_type_obj->pretty_name(),
325
-                'PMD_admin_name' => $pm_type_obj->pretty_name(),
326
-                'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
327
-                'PMD_wp_user'    => $current_user->ID,
328
-                'PMD_order'      => EEM_Payment_Method::instance()->count(
329
-                        array(array('PMD_type' => array('!=', 'Admin_Only')))
330
-                    ) * 10,
331
-            )
332
-        );
333
-        return $payment_method;
334
-    }
335
-
336
-
337
-
338
-    /**
339
-     * Sets the initial payment method properties (including extra meta)
340
-     *
341
-     * @param EE_Payment_Method $payment_method
342
-     * @return EE_Payment_Method
343
-     * @throws \EE_Error
344
-     */
345
-    public function initialize_payment_method($payment_method)
346
-    {
347
-        $pm_type_obj = $payment_method->type_obj();
348
-        $payment_method->set_description($pm_type_obj->default_description());
349
-        if ( ! $payment_method->button_url()) {
350
-            $payment_method->set_button_url($pm_type_obj->default_button_url());
351
-        }
352
-        //now add setup its default extra meta properties
353
-        $extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
354
-        if ( ! empty($extra_metas)) {
355
-            //verify the payment method has an ID before adding extra meta
356
-            if ( ! $payment_method->ID()) {
357
-                $payment_method->save();
358
-            }
359
-            foreach ($extra_metas as $meta_name => $input) {
360
-                $payment_method->update_extra_meta($meta_name, $input->raw_value());
361
-            }
362
-        }
363
-        return $payment_method;
364
-    }
365
-
366
-
367
-
368
-    /**
369
-     * Makes sure the payment method is related to the specified payment method
370
-     *
371
-     * @param EE_Payment_Method $payment_method
372
-     * @return EE_Payment_Method
373
-     * @throws \EE_Error
374
-     */
375
-    public function set_usable_currencies_on_payment_method($payment_method)
376
-    {
377
-        foreach ($payment_method->get_all_usable_currencies() as $currency_obj) {
378
-            $payment_method->_add_relation_to($currency_obj, 'Currency');
379
-        }
380
-        return $payment_method;
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * Deactivates a payment method of the given payment method slug.
387
-     *
388
-     * @param string $payment_method_slug The slug for the payment method to deactivate.
389
-     * @return int count of rows updated.
390
-     */
391
-    public function deactivate_payment_method($payment_method_slug)
392
-    {
393
-        EE_Log::instance()->log(
394
-            __FILE__,
395
-            __FUNCTION__,
396
-            sprintf(
397
-                __('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'),
398
-                $payment_method_slug
399
-            ),
400
-            'payment_method_change'
401
-        );
402
-        $count_updated = EEM_Payment_Method::instance()->update(
403
-            array('PMD_scope' => array()),
404
-            array(array('PMD_slug' => $payment_method_slug))
405
-        );
406
-        return $count_updated;
407
-    }
408
-
409
-
410
-
411
-    /**
412
-     * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method
413
-     * access caps.
414
-     *
415
-     * @param array $caps capabilities being filtered
416
-     * @return array
417
-     */
418
-    public function add_payment_method_caps($caps)
419
-    {
420
-        /* add dynamic caps from payment methods
20
+	/**
21
+	 *    instance of the EE_Payment_Method_Manager object
22
+	 *
23
+	 * @var    $_instance
24
+	 * @access    private
25
+	 */
26
+	private static $_instance;
27
+
28
+	/**
29
+	 * @var array keys are classnames without 'EE_PMT_', values are their filepaths
30
+	 */
31
+	protected $_payment_method_types = array();
32
+
33
+
34
+
35
+	/**
36
+	 * @singleton method used to instantiate class object
37
+	 * @access    public
38
+	 * @return EE_Payment_Method_Manager instance
39
+	 */
40
+	public static function instance()
41
+	{
42
+		// check if class object is instantiated, and instantiated properly
43
+		if ( ! self::$_instance instanceof EE_Payment_Method_Manager) {
44
+			self::$_instance = new self();
45
+		}
46
+		EE_Registry::instance()->load_lib('PMT_Base');
47
+		return self::$_instance;
48
+	}
49
+
50
+
51
+
52
+	/**
53
+	 * Resets the instance and returns a new one
54
+	 *
55
+	 * @return EE_Payment_Method_Manager
56
+	 */
57
+	public static function reset()
58
+	{
59
+		self::$_instance = null;
60
+		return self::instance();
61
+	}
62
+
63
+
64
+
65
+	/**
66
+	 * If necessary, re-register payment methods
67
+	 *
68
+	 * @param boolean $force_recheck whether to recheck for payment method types,
69
+	 *                               or just re-use the PMTs we found last time we checked during this request (if
70
+	 *                               we have not yet checked during this request, then we need to check anyways)
71
+	 */
72
+	public function maybe_register_payment_methods($force_recheck = false)
73
+	{
74
+		if ( ! $this->_payment_method_types || $force_recheck) {
75
+			$this->_register_payment_methods();
76
+			//if in admin lets ensure caps are set.
77
+			if (is_admin()) {
78
+				add_filter('FHEE__EE_Capabilities__init_caps_map__caps', array($this, 'add_payment_method_caps'));
79
+				EE_Registry::instance()->CAP->init_caps();
80
+			}
81
+		}
82
+	}
83
+
84
+
85
+
86
+	/**
87
+	 *        register_payment_methods
88
+	 *
89
+	 * @return array
90
+	 */
91
+	protected function _register_payment_methods()
92
+	{
93
+		// grab list of installed modules
94
+		$pm_to_register = glob(EE_PAYMENT_METHODS . '*', GLOB_ONLYDIR);
95
+		// filter list of modules to register
96
+		$pm_to_register = apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__payment_methods_to_register',
97
+			$pm_to_register);
98
+		// loop through folders
99
+		foreach ($pm_to_register as $pm_path) {
100
+			$this->register_payment_method($pm_path);
101
+		}
102
+		do_action('FHEE__EE_Payment_Method_Manager__register_payment_methods__registered_payment_methods');
103
+		// filter list of installed modules
104
+		//keep them organized alphabetically by the payment method type's name
105
+		ksort($this->_payment_method_types);
106
+		return apply_filters('FHEE__EE_Payment_Method_Manager__register_payment_methods__installed_payment_methods',
107
+			$this->_payment_method_types);
108
+	}
109
+
110
+
111
+
112
+	/**
113
+	 *    register_payment_method- makes core aware of this payment method
114
+	 *
115
+	 * @access public
116
+	 * @param string $payment_method_path - full path up to and including payment method folder
117
+	 * @return boolean
118
+	 */
119
+	public function register_payment_method($payment_method_path = '')
120
+	{
121
+		do_action('AHEE__EE_Payment_Method_Manager__register_payment_method__begin', $payment_method_path);
122
+		$module_ext = '.pm.php';
123
+		// make all separators match
124
+		$payment_method_path = rtrim(str_replace('/\\', DS, $payment_method_path), DS);
125
+		// grab and sanitize module name
126
+		$module_dir = basename($payment_method_path);
127
+		// create classname from module directory name
128
+		$module = str_replace(' ', '_', str_replace('_', ' ', $module_dir));
129
+		// add class prefix
130
+		$module_class = 'EE_PMT_' . $module;
131
+		// does the module exist ?
132
+		if ( ! is_readable($payment_method_path . DS . $module_class . $module_ext)) {
133
+			$msg = sprintf(__('The requested %s payment method file could not be found or is not readable due to file permissions.',
134
+				'event_espresso'), $module);
135
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
136
+			return false;
137
+		}
138
+		if (WP_DEBUG === true) {
139
+			EEH_Debug_Tools::instance()->start_timer();
140
+		}
141
+		// load the module class file
142
+		require_once($payment_method_path . DS . $module_class . $module_ext);
143
+		if (WP_DEBUG === true) {
144
+			EEH_Debug_Tools::instance()->stop_timer("Requiring payment method $module_class");
145
+		}
146
+		// verify that class exists
147
+		if ( ! class_exists($module_class)) {
148
+			$msg = sprintf(__('The requested %s module class does not exist.', 'event_espresso'), $module_class);
149
+			EE_Error::add_error($msg . '||' . $msg, __FILE__, __FUNCTION__, __LINE__);
150
+			return false;
151
+		}
152
+		// add to array of registered modules
153
+		$this->_payment_method_types[$module] = $payment_method_path . DS . $module_class . $module_ext;
154
+		return true;
155
+	}
156
+
157
+
158
+
159
+	/**
160
+	 * Checks if a payment method has been registered, and if so includes it
161
+	 *
162
+	 * @param string  $payment_method_name like 'Paypal_Pro', (ie classname without the prefix 'EEPM_')
163
+	 * @param boolean $force_recheck       whether to force re-checking for new payment method types
164
+	 * @return boolean
165
+	 */
166
+	public function payment_method_type_exists($payment_method_name, $force_recheck = false)
167
+	{
168
+		if (
169
+			$force_recheck
170
+			|| ! is_array($this->_payment_method_types)
171
+			|| ! isset($this->_payment_method_types[$payment_method_name])
172
+		) {
173
+			$this->maybe_register_payment_methods($force_recheck);
174
+		}
175
+		if (isset($this->_payment_method_types[$payment_method_name])) {
176
+			require_once($this->_payment_method_types[$payment_method_name]);
177
+			return true;
178
+		} else {
179
+			return false;
180
+		}
181
+	}
182
+
183
+
184
+
185
+	/**
186
+	 * Returns all the classnames of the various payment method types
187
+	 *
188
+	 * @param boolean $with_prefixes TRUE: get payment method type classnames; false just their 'names'
189
+	 *                               (what you'd find in wp_esp_payment_method.PMD_type)
190
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
191
+	 * @return array
192
+	 */
193
+	public function payment_method_type_names($with_prefixes = false, $force_recheck = false)
194
+	{
195
+		$this->maybe_register_payment_methods($force_recheck);
196
+		if ($with_prefixes) {
197
+			$classnames = array_keys($this->_payment_method_types);
198
+			$payment_methods = array();
199
+			foreach ($classnames as $classname) {
200
+				$payment_methods[] = $this->payment_method_class_from_type($classname);
201
+			}
202
+			return $payment_methods;
203
+		} else {
204
+			return array_keys($this->_payment_method_types);
205
+		}
206
+	}
207
+
208
+
209
+
210
+	/**
211
+	 * Gets an object of each payment method type, none of which are bound to a
212
+	 * payment method instance
213
+	 *
214
+	 * @param boolean $force_recheck whether to force re-checking for new payment method types
215
+	 * @return EE_PMT_Base[]
216
+	 */
217
+	public function payment_method_types($force_recheck = false)
218
+	{
219
+		$this->maybe_register_payment_methods($force_recheck);
220
+		$pmt_objs = array();
221
+		foreach ($this->payment_method_type_names(true) as $classname) {
222
+			$pmt_objs[] = new $classname;
223
+		}
224
+		return $pmt_objs;
225
+	}
226
+
227
+
228
+
229
+	/**
230
+	 * Changes the payment method's classname into the payment method type's name
231
+	 * (as used on the payment method's table's PMD_type field)
232
+	 *
233
+	 * @param string $classname
234
+	 * @return string
235
+	 */
236
+	public function payment_method_type_sans_class_prefix($classname)
237
+	{
238
+		return str_replace("EE_PMT_", "", $classname);
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * Does the opposite of payment-method_type_sans_prefix
245
+	 *
246
+	 * @param string $type
247
+	 * @return string
248
+	 */
249
+	public function payment_method_class_from_type($type)
250
+	{
251
+		$this->maybe_register_payment_methods();
252
+		return "EE_PMT_" . $type;
253
+	}
254
+
255
+
256
+
257
+	/**
258
+	 * Activates a payment method of the given type.
259
+	 *
260
+	 * @param string $payment_method_type the PMT_type; for EE_PMT_Invoice this would be 'Invoice'
261
+	 * @return \EE_Payment_Method
262
+	 * @throws \EE_Error
263
+	 */
264
+	public function activate_a_payment_method_of_type($payment_method_type)
265
+	{
266
+		$payment_method = EEM_Payment_Method::instance()->get_one_of_type($payment_method_type);
267
+		if ( ! $payment_method instanceof EE_Payment_Method) {
268
+			$pm_type_class = $this->payment_method_class_from_type($payment_method_type);
269
+			if (class_exists($pm_type_class)) {
270
+				/** @var $pm_type_obj EE_PMT_Base */
271
+				$pm_type_obj = new $pm_type_class;
272
+				$payment_method = EEM_Payment_Method::instance()->get_one_by_slug($pm_type_obj->system_name());
273
+				if ( ! $payment_method) {
274
+					$payment_method = $this->create_payment_method_of_type($pm_type_obj);
275
+				}
276
+				$payment_method->set_type($payment_method_type);
277
+				$this->initialize_payment_method($payment_method);
278
+			} else {
279
+				throw new EE_Error(
280
+					sprintf(
281
+						__('There is no payment method of type %1$s, so it could not be activated', 'event_espresso'),
282
+						$pm_type_class)
283
+				);
284
+			}
285
+		}
286
+		$payment_method->set_active();
287
+		$payment_method->save();
288
+		$this->set_usable_currencies_on_payment_method($payment_method);
289
+		if ($payment_method->type() === 'Invoice') {
290
+			/** @type EE_Message_Resource_Manager $message_resource_manager */
291
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
292
+			$message_resource_manager->ensure_message_type_is_active('invoice', 'html');
293
+			$message_resource_manager->ensure_messenger_is_active('pdf');
294
+			EE_Error::add_persistent_admin_notice(
295
+				'invoice_pm_requirements_notice',
296
+				sprintf(
297
+					__('The Invoice payment method has been activated. It requires the invoice message type, html messenger, and pdf messenger be activated as well for the %1$smessages system%2$s, so it has been automatically verified that they are also active.',
298
+						'event_espresso'),
299
+					'<a href="' . admin_url('admin.php?page=espresso_messages') . '">',
300
+					'</a>'
301
+				),
302
+				true
303
+			);
304
+		}
305
+		return $payment_method;
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * Creates a payment method of the specified type. Does not save it.
312
+	 *
313
+	 * @global WP_User    $current_user
314
+	 * @param EE_PMT_Base $pm_type_obj
315
+	 * @return EE_Payment_Method
316
+	 * @throws \EE_Error
317
+	 */
318
+	public function create_payment_method_of_type($pm_type_obj)
319
+	{
320
+		global $current_user;
321
+		$payment_method = EE_Payment_Method::new_instance(
322
+			array(
323
+				'PMD_type'       => $pm_type_obj->system_name(),
324
+				'PMD_name'       => $pm_type_obj->pretty_name(),
325
+				'PMD_admin_name' => $pm_type_obj->pretty_name(),
326
+				'PMD_slug'       => $pm_type_obj->system_name(),//automatically converted to slug
327
+				'PMD_wp_user'    => $current_user->ID,
328
+				'PMD_order'      => EEM_Payment_Method::instance()->count(
329
+						array(array('PMD_type' => array('!=', 'Admin_Only')))
330
+					) * 10,
331
+			)
332
+		);
333
+		return $payment_method;
334
+	}
335
+
336
+
337
+
338
+	/**
339
+	 * Sets the initial payment method properties (including extra meta)
340
+	 *
341
+	 * @param EE_Payment_Method $payment_method
342
+	 * @return EE_Payment_Method
343
+	 * @throws \EE_Error
344
+	 */
345
+	public function initialize_payment_method($payment_method)
346
+	{
347
+		$pm_type_obj = $payment_method->type_obj();
348
+		$payment_method->set_description($pm_type_obj->default_description());
349
+		if ( ! $payment_method->button_url()) {
350
+			$payment_method->set_button_url($pm_type_obj->default_button_url());
351
+		}
352
+		//now add setup its default extra meta properties
353
+		$extra_metas = $pm_type_obj->settings_form()->extra_meta_inputs();
354
+		if ( ! empty($extra_metas)) {
355
+			//verify the payment method has an ID before adding extra meta
356
+			if ( ! $payment_method->ID()) {
357
+				$payment_method->save();
358
+			}
359
+			foreach ($extra_metas as $meta_name => $input) {
360
+				$payment_method->update_extra_meta($meta_name, $input->raw_value());
361
+			}
362
+		}
363
+		return $payment_method;
364
+	}
365
+
366
+
367
+
368
+	/**
369
+	 * Makes sure the payment method is related to the specified payment method
370
+	 *
371
+	 * @param EE_Payment_Method $payment_method
372
+	 * @return EE_Payment_Method
373
+	 * @throws \EE_Error
374
+	 */
375
+	public function set_usable_currencies_on_payment_method($payment_method)
376
+	{
377
+		foreach ($payment_method->get_all_usable_currencies() as $currency_obj) {
378
+			$payment_method->_add_relation_to($currency_obj, 'Currency');
379
+		}
380
+		return $payment_method;
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * Deactivates a payment method of the given payment method slug.
387
+	 *
388
+	 * @param string $payment_method_slug The slug for the payment method to deactivate.
389
+	 * @return int count of rows updated.
390
+	 */
391
+	public function deactivate_payment_method($payment_method_slug)
392
+	{
393
+		EE_Log::instance()->log(
394
+			__FILE__,
395
+			__FUNCTION__,
396
+			sprintf(
397
+				__('Payment method with slug %1$s is being deactivated by site admin', 'event_espresso'),
398
+				$payment_method_slug
399
+			),
400
+			'payment_method_change'
401
+		);
402
+		$count_updated = EEM_Payment_Method::instance()->update(
403
+			array('PMD_scope' => array()),
404
+			array(array('PMD_slug' => $payment_method_slug))
405
+		);
406
+		return $count_updated;
407
+	}
408
+
409
+
410
+
411
+	/**
412
+	 * callback for FHEE__EE_Capabilities__init_caps_map__caps filter to add dynamic payment method
413
+	 * access caps.
414
+	 *
415
+	 * @param array $caps capabilities being filtered
416
+	 * @return array
417
+	 */
418
+	public function add_payment_method_caps($caps)
419
+	{
420
+		/* add dynamic caps from payment methods
421 421
          * at the time of writing, october 20 2014, these are the caps added:
422 422
          * ee_payment_method_admin_only
423 423
          * ee_payment_method_aim
@@ -431,10 +431,10 @@  discard block
 block discarded – undo
431 431
          * their related capability automatically added too, so long as they are
432 432
          * registered properly using EE_Register_Payment_Method::register()
433 433
          */
434
-        foreach ($this->payment_method_types() as $payment_method_type_obj) {
435
-            $caps['administrator'][] = $payment_method_type_obj->cap_name();
436
-        }
437
-        return $caps;
438
-    }
434
+		foreach ($this->payment_method_types() as $payment_method_type_obj) {
435
+			$caps['administrator'][] = $payment_method_type_obj->cap_name();
436
+		}
437
+		return $caps;
438
+	}
439 439
 
440 440
 }
Please login to merge, or discard this patch.
core/libraries/plugin_api/db/EEME_Base.lib.php 2 patches
Indentation   +46 added lines, -46 removed lines patch added patch discarded remove patch
@@ -71,10 +71,10 @@  discard block
 block discarded – undo
71 71
 	 */
72 72
 	public function __construct(){
73 73
 		if( ! $this->_model_name_extended){
74
-            throw new EE_Error(
75
-                __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
-                "event_espresso" )
77
-            );
74
+			throw new EE_Error(
75
+				__( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
+				"event_espresso" )
77
+			);
78 78
 		}
79 79
 		$construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end';
80 80
 		if ( did_action( $construct_end_action )) {
@@ -95,30 +95,30 @@  discard block
 block discarded – undo
95 95
 
96 96
 
97 97
 
98
-    /**
99
-     * @param array $existing_tables
100
-     * @return array
101
-     */
102
-    public function add_extra_tables_on_filter( $existing_tables ){
103
-        return array_merge( (array)$existing_tables, $this->_extra_tables );
98
+	/**
99
+	 * @param array $existing_tables
100
+	 * @return array
101
+	 */
102
+	public function add_extra_tables_on_filter( $existing_tables ){
103
+		return array_merge( (array)$existing_tables, $this->_extra_tables );
104 104
 	}
105 105
 
106 106
 
107 107
 
108
-    /**
109
-     * @param array $existing_fields
110
-     * @return array
111
-     */
112
-    public function add_extra_fields_on_filter( $existing_fields ){
108
+	/**
109
+	 * @param array $existing_fields
110
+	 * @return array
111
+	 */
112
+	public function add_extra_fields_on_filter( $existing_fields ){
113 113
 		if( $this->_extra_fields){
114 114
 			foreach($this->_extra_fields as $table_alias => $fields){
115 115
 				if( ! isset( $existing_fields[ $table_alias ] ) ){
116 116
 					$existing_fields[ $table_alias ] = array();
117 117
 				}
118 118
 				$existing_fields[$table_alias] = array_merge(
119
-                    (array)$existing_fields[$table_alias],
120
-                    $this->_extra_fields[$table_alias]
121
-                );
119
+					(array)$existing_fields[$table_alias],
120
+					$this->_extra_fields[$table_alias]
121
+				);
122 122
 
123 123
 			}
124 124
 		}
@@ -127,12 +127,12 @@  discard block
 block discarded – undo
127 127
 
128 128
 
129 129
 
130
-    /**
131
-     * @param array $existing_relations
132
-     * @return array
133
-     */
134
-    public function add_extra_relations_on_filter( $existing_relations ){
135
-        return  array_merge((array)$existing_relations,$this->_extra_relations);
130
+	/**
131
+	 * @param array $existing_relations
132
+	 * @return array
133
+	 */
134
+	public function add_extra_relations_on_filter( $existing_relations ){
135
+		return  array_merge((array)$existing_relations,$this->_extra_relations);
136 136
 	}
137 137
 
138 138
 
@@ -168,8 +168,8 @@  discard block
 block discarded – undo
168 168
 				remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10);
169 169
 			}
170 170
 		}
171
-        /** @var EEM_Base $model_to_reset */
172
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
171
+		/** @var EEM_Base $model_to_reset */
172
+		$model_to_reset = 'EEM_' . $this->_model_name_extended;
173 173
 		if ( class_exists( $model_to_reset ) ) {
174 174
 			$model_to_reset::reset();
175 175
 		}
@@ -177,13 +177,13 @@  discard block
 block discarded – undo
177 177
 
178 178
 
179 179
 
180
-    /**
181
-     * @param string $callback_method_name
182
-     * @param array  $args
183
-     * @return mixed
184
-     * @throws EE_Error
185
-     */
186
-    public function __call( $callback_method_name, $args){
180
+	/**
181
+	 * @param string $callback_method_name
182
+	 * @param array  $args
183
+	 * @return mixed
184
+	 * @throws EE_Error
185
+	 */
186
+	public function __call( $callback_method_name, $args){
187 187
 		if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){
188 188
 			//it's a dynamic callback for a method name
189 189
 			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
@@ -194,23 +194,23 @@  discard block
 block discarded – undo
194 194
 				return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model);
195 195
 			}else{
196 196
 				throw new EE_Error(
197
-				    sprintf(
198
-				        __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),
199
-                        $this->_model_name_extended,
200
-                        get_class($this),
201
-                        $extending_method,$extending_method
202
-                    )
203
-                );
197
+					sprintf(
198
+						__("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),
199
+						$this->_model_name_extended,
200
+						get_class($this),
201
+						$extending_method,$extending_method
202
+					)
203
+				);
204 204
 			}
205 205
 
206 206
 		}else{
207 207
 			throw new EE_Error(
208
-			    sprintf(
209
-			        __("There is no method named '%s' on '%s'", "event_espresso"),
210
-                    $callback_method_name,
211
-                    get_class($this)
212
-                )
213
-            );
208
+				sprintf(
209
+					__("There is no method named '%s' on '%s'", "event_espresso"),
210
+					$callback_method_name,
211
+					get_class($this)
212
+				)
213
+			);
214 214
 		}
215 215
 	}
216 216
 
Please login to merge, or discard this patch.
Spacing   +41 added lines, -41 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION'))
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('No direct script access allowed');
5 5
 
6 6
 /**
@@ -69,27 +69,27 @@  discard block
 block discarded – undo
69 69
 	/**
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	public function __construct(){
73
-		if( ! $this->_model_name_extended){
72
+	public function __construct() {
73
+		if ( ! $this->_model_name_extended) {
74 74
             throw new EE_Error(
75
-                __( "When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
-                "event_espresso" )
75
+                __("When declaring a model extension, you must define its _model_name_extended property. It should be a model name like 'Attendee' or 'Event'",
76
+                "event_espresso")
77 77
             );
78 78
 		}
79 79
 		$construct_end_action = 'AHEE__EEM_'.$this->_model_name_extended.'__construct__end';
80
-		if ( did_action( $construct_end_action )) {
80
+		if (did_action($construct_end_action)) {
81 81
 			throw new EE_Error(
82 82
 				sprintf(
83
-					__( "Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"),
83
+					__("Hooked in model extension '%s' too late! The model %s has already been used! We know because the action %s has been fired", "event_espresso"),
84 84
 					get_class($this),
85 85
 					$this->_model_name_extended,
86 86
 					$construct_end_action
87 87
 				)
88 88
 			);
89 89
 		}
90
-		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter'));
91
-		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter'));
92
-		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter'));
90
+		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter'));
91
+		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter'));
92
+		add_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter'));
93 93
 		$this->_register_extending_methods();
94 94
 	}
95 95
 
@@ -99,8 +99,8 @@  discard block
 block discarded – undo
99 99
      * @param array $existing_tables
100 100
      * @return array
101 101
      */
102
-    public function add_extra_tables_on_filter( $existing_tables ){
103
-        return array_merge( (array)$existing_tables, $this->_extra_tables );
102
+    public function add_extra_tables_on_filter($existing_tables) {
103
+        return array_merge((array) $existing_tables, $this->_extra_tables);
104 104
 	}
105 105
 
106 106
 
@@ -109,14 +109,14 @@  discard block
 block discarded – undo
109 109
      * @param array $existing_fields
110 110
      * @return array
111 111
      */
112
-    public function add_extra_fields_on_filter( $existing_fields ){
113
-		if( $this->_extra_fields){
114
-			foreach($this->_extra_fields as $table_alias => $fields){
115
-				if( ! isset( $existing_fields[ $table_alias ] ) ){
116
-					$existing_fields[ $table_alias ] = array();
112
+    public function add_extra_fields_on_filter($existing_fields) {
113
+		if ($this->_extra_fields) {
114
+			foreach ($this->_extra_fields as $table_alias => $fields) {
115
+				if ( ! isset($existing_fields[$table_alias])) {
116
+					$existing_fields[$table_alias] = array();
117 117
 				}
118 118
 				$existing_fields[$table_alias] = array_merge(
119
-                    (array)$existing_fields[$table_alias],
119
+                    (array) $existing_fields[$table_alias],
120 120
                     $this->_extra_fields[$table_alias]
121 121
                 );
122 122
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
      * @param array $existing_relations
132 132
      * @return array
133 133
      */
134
-    public function add_extra_relations_on_filter( $existing_relations ){
135
-        return  array_merge((array)$existing_relations,$this->_extra_relations);
134
+    public function add_extra_relations_on_filter($existing_relations) {
135
+        return  array_merge((array) $existing_relations, $this->_extra_relations);
136 136
 	}
137 137
 
138 138
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	 * scans the child of EEME_Base for functions starting with ext_, and magically makes them functions on the
142 142
 	 * model extended. (Internally uses filters, and the __call magic method)
143 143
 	 */
144
-	protected function _register_extending_methods(){
144
+	protected function _register_extending_methods() {
145 145
 		$all_methods = get_class_methods(get_class($this));
146
-		foreach($all_methods as $method_name){
147
-			if(strpos($method_name, self::extending_method_prefix) === 0){
146
+		foreach ($all_methods as $method_name) {
147
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
148 148
 				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
149 149
 				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
150
-				add_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10,10);
150
+				add_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10, 10);
151 151
 			}
152 152
 		}
153 153
 	}
@@ -156,21 +156,21 @@  discard block
 block discarded – undo
156 156
 	 * scans the child of EEME_Base for functions starting with ext_, and magically REMOVES them as functions on the
157 157
 	 * model extended. (Internally uses filters, and the __call magic method)
158 158
 	 */
159
-	public function deregister(){
160
-		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables',array($this,'add_extra_tables_on_filter'));
161
-		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields',array($this,'add_extra_fields_on_filter'));
162
-		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations',array($this,'add_extra_relations_on_filter'));
159
+	public function deregister() {
160
+		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__tables', array($this, 'add_extra_tables_on_filter'));
161
+		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__fields', array($this, 'add_extra_fields_on_filter'));
162
+		remove_filter('FHEE__EEM_'.$this->_model_name_extended.'__construct__model_relations', array($this, 'add_extra_relations_on_filter'));
163 163
 		$all_methods = get_class_methods(get_class($this));
164
-		foreach($all_methods as $method_name){
165
-			if(strpos($method_name, self::extending_method_prefix) === 0){
164
+		foreach ($all_methods as $method_name) {
165
+			if (strpos($method_name, self::extending_method_prefix) === 0) {
166 166
 				$method_name_on_model = str_replace(self::extending_method_prefix, '', $method_name);
167 167
 				$callback_name = "FHEE__EEM_{$this->_model_name_extended}__$method_name_on_model";
168
-				remove_filter($callback_name,array($this,self::dynamic_callback_method_prefix.$method_name_on_model),10);
168
+				remove_filter($callback_name, array($this, self::dynamic_callback_method_prefix.$method_name_on_model), 10);
169 169
 			}
170 170
 		}
171 171
         /** @var EEM_Base $model_to_reset */
172
-        $model_to_reset = 'EEM_' . $this->_model_name_extended;
173
-		if ( class_exists( $model_to_reset ) ) {
172
+        $model_to_reset = 'EEM_'.$this->_model_name_extended;
173
+		if (class_exists($model_to_reset)) {
174 174
 			$model_to_reset::reset();
175 175
 		}
176 176
 	}
@@ -183,27 +183,27 @@  discard block
 block discarded – undo
183 183
      * @return mixed
184 184
      * @throws EE_Error
185 185
      */
186
-    public function __call( $callback_method_name, $args){
187
-		if(strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0){
186
+    public function __call($callback_method_name, $args) {
187
+		if (strpos($callback_method_name, self::dynamic_callback_method_prefix) === 0) {
188 188
 			//it's a dynamic callback for a method name
189 189
 			$method_called_on_model = str_replace(self::dynamic_callback_method_prefix, '', $callback_method_name);
190
-			list( $original_return_val, $model_called, $args_provided_to_method_on_model ) = (array) $args;
190
+			list($original_return_val, $model_called, $args_provided_to_method_on_model) = (array) $args;
191 191
 			$this->_ = $model_called;
192 192
 			$extending_method = self::extending_method_prefix.$method_called_on_model;
193
-			if(method_exists($this, $extending_method)){
194
-				return call_user_func_array(array($this,$extending_method), $args_provided_to_method_on_model);
195
-			}else{
193
+			if (method_exists($this, $extending_method)) {
194
+				return call_user_func_array(array($this, $extending_method), $args_provided_to_method_on_model);
195
+			} else {
196 196
 				throw new EE_Error(
197 197
 				    sprintf(
198 198
 				        __("An odd error occurred. Model '%s' had a method called on it that it didn't recognize. So it passed it onto the model extension '%s' (because it had a function named '%s' which should be able to handle it), but the function '%s' doesnt exist!)", "event_espresso"),
199 199
                         $this->_model_name_extended,
200 200
                         get_class($this),
201
-                        $extending_method,$extending_method
201
+                        $extending_method, $extending_method
202 202
                     )
203 203
                 );
204 204
 			}
205 205
 
206
-		}else{
206
+		} else {
207 207
 			throw new EE_Error(
208 208
 			    sprintf(
209 209
 			        __("There is no method named '%s' on '%s'", "event_espresso"),
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 2 patches
Indentation   +3264 added lines, -3264 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
-    exit('No direct script access allowed');
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -28,2112 +28,2112 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    //set in _init_page_props()
32
-    public $page_slug;
31
+	//set in _init_page_props()
32
+	public $page_slug;
33 33
 
34
-    public $page_label;
34
+	public $page_label;
35 35
 
36
-    public $page_folder;
36
+	public $page_folder;
37 37
 
38
-    //set in define_page_props()
39
-    protected $_admin_base_url;
38
+	//set in define_page_props()
39
+	protected $_admin_base_url;
40 40
 
41
-    protected $_admin_base_path;
41
+	protected $_admin_base_path;
42 42
 
43
-    protected $_admin_page_title;
43
+	protected $_admin_page_title;
44 44
 
45
-    protected $_labels;
45
+	protected $_labels;
46 46
 
47 47
 
48
-    //set early within EE_Admin_Init
49
-    protected $_wp_page_slug;
48
+	//set early within EE_Admin_Init
49
+	protected $_wp_page_slug;
50 50
 
51
-    //navtabs
52
-    protected $_nav_tabs;
51
+	//navtabs
52
+	protected $_nav_tabs;
53 53
 
54
-    protected $_default_nav_tab_name;
54
+	protected $_default_nav_tab_name;
55 55
 
56
-    //helptourstops
57
-    protected $_help_tour = array();
56
+	//helptourstops
57
+	protected $_help_tour = array();
58 58
 
59 59
 
60
-    //template variables (used by templates)
61
-    protected $_template_path;
60
+	//template variables (used by templates)
61
+	protected $_template_path;
62 62
 
63
-    protected $_column_template_path;
63
+	protected $_column_template_path;
64 64
 
65
-    /**
66
-     * @var array $_template_args
67
-     */
68
-    protected $_template_args = array();
65
+	/**
66
+	 * @var array $_template_args
67
+	 */
68
+	protected $_template_args = array();
69 69
 
70
-    /**
71
-     * this will hold the list table object for a given view.
72
-     *
73
-     * @var EE_Admin_List_Table $_list_table_object
74
-     */
75
-    protected $_list_table_object;
70
+	/**
71
+	 * this will hold the list table object for a given view.
72
+	 *
73
+	 * @var EE_Admin_List_Table $_list_table_object
74
+	 */
75
+	protected $_list_table_object;
76 76
 
77
-    //bools
78
-    protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
77
+	//bools
78
+	protected $_is_UI_request = null; //this starts at null so we can have no header routes progress through two states.
79 79
 
80
-    protected $_routing;
80
+	protected $_routing;
81 81
 
82
-    //list table args
83
-    protected $_view;
82
+	//list table args
83
+	protected $_view;
84 84
 
85
-    protected $_views;
85
+	protected $_views;
86 86
 
87 87
 
88
-    //action => method pairs used for routing incoming requests
89
-    protected $_page_routes;
88
+	//action => method pairs used for routing incoming requests
89
+	protected $_page_routes;
90 90
 
91
-    protected $_page_config;
91
+	protected $_page_config;
92 92
 
93
-    //the current page route and route config
94
-    protected $_route;
93
+	//the current page route and route config
94
+	protected $_route;
95 95
 
96
-    protected $_route_config;
96
+	protected $_route_config;
97 97
 
98
-    /**
99
-     * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
-     * actions.
101
-     *
102
-     * @since 4.6.x
103
-     * @var array.
104
-     */
105
-    protected $_default_route_query_args;
98
+	/**
99
+	 * Used to hold default query args for list table routes to help preserve stickiness of filters for carried out
100
+	 * actions.
101
+	 *
102
+	 * @since 4.6.x
103
+	 * @var array.
104
+	 */
105
+	protected $_default_route_query_args;
106 106
 
107
-    //set via request page and action args.
108
-    protected $_current_page;
107
+	//set via request page and action args.
108
+	protected $_current_page;
109 109
 
110
-    protected $_current_view;
110
+	protected $_current_view;
111 111
 
112
-    protected $_current_page_view_url;
112
+	protected $_current_page_view_url;
113 113
 
114
-    //sanitized request action (and nonce)
115
-    /**
116
-     * @var string $_req_action
117
-     */
118
-    protected $_req_action;
114
+	//sanitized request action (and nonce)
115
+	/**
116
+	 * @var string $_req_action
117
+	 */
118
+	protected $_req_action;
119 119
 
120
-    /**
121
-     * @var string $_req_nonce
122
-     */
123
-    protected $_req_nonce;
120
+	/**
121
+	 * @var string $_req_nonce
122
+	 */
123
+	protected $_req_nonce;
124 124
 
125
-    //search related
126
-    protected $_search_btn_label;
125
+	//search related
126
+	protected $_search_btn_label;
127 127
 
128
-    protected $_search_box_callback;
128
+	protected $_search_box_callback;
129 129
 
130
-    /**
131
-     * WP Current Screen object
132
-     *
133
-     * @var WP_Screen
134
-     */
135
-    protected $_current_screen;
130
+	/**
131
+	 * WP Current Screen object
132
+	 *
133
+	 * @var WP_Screen
134
+	 */
135
+	protected $_current_screen;
136 136
 
137
-    //for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
-    protected $_hook_obj;
137
+	//for holding EE_Admin_Hooks object when needed (set via set_hook_object())
138
+	protected $_hook_obj;
139 139
 
140
-    //for holding incoming request data
141
-    protected $_req_data;
140
+	//for holding incoming request data
141
+	protected $_req_data;
142 142
 
143
-    // yes / no array for admin form fields
144
-    protected $_yes_no_values = array();
145
-
146
-    //some default things shared by all child classes
147
-    protected $_default_espresso_metaboxes;
148
-
149
-    /**
150
-     *    EE_Registry Object
151
-     *
152
-     * @var    EE_Registry
153
-     * @access    protected
154
-     */
155
-    protected $EE = null;
156
-
157
-
158
-
159
-    /**
160
-     * This is just a property that flags whether the given route is a caffeinated route or not.
161
-     *
162
-     * @var boolean
163
-     */
164
-    protected $_is_caf = false;
165
-
166
-
167
-
168
-    /**
169
-     * @Constructor
170
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
-     * @access public
172
-     */
173
-    public function __construct($routing = true)
174
-    {
175
-        if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
-            $this->_is_caf = true;
177
-        }
178
-        $this->_yes_no_values = array(
179
-                array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
-                array('id' => false, 'text' => __('No', 'event_espresso')),
181
-        );
182
-        //set the _req_data property.
183
-        $this->_req_data = array_merge($_GET, $_POST);
184
-        //routing enabled?
185
-        $this->_routing = $routing;
186
-        //set initial page props (child method)
187
-        $this->_init_page_props();
188
-        //set global defaults
189
-        $this->_set_defaults();
190
-        //set early because incoming requests could be ajax related and we need to register those hooks.
191
-        $this->_global_ajax_hooks();
192
-        $this->_ajax_hooks();
193
-        //other_page_hooks have to be early too.
194
-        $this->_do_other_page_hooks();
195
-        //This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
-        if (method_exists($this, '_before_page_setup')) {
197
-            $this->_before_page_setup();
198
-        }
199
-        //set up page dependencies
200
-        $this->_page_setup();
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * _init_page_props
207
-     * Child classes use to set at least the following properties:
208
-     * $page_slug.
209
-     * $page_label.
210
-     *
211
-     * @abstract
212
-     * @access protected
213
-     * @return void
214
-     */
215
-    abstract protected function _init_page_props();
216
-
217
-
218
-
219
-    /**
220
-     * _ajax_hooks
221
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
-     * Note: within the ajax callback methods.
223
-     *
224
-     * @abstract
225
-     * @access protected
226
-     * @return void
227
-     */
228
-    abstract protected function _ajax_hooks();
229
-
230
-
231
-
232
-    /**
233
-     * _define_page_props
234
-     * child classes define page properties in here.  Must include at least:
235
-     * $_admin_base_url = base_url for all admin pages
236
-     * $_admin_page_title = default admin_page_title for admin pages
237
-     * $_labels = array of default labels for various automatically generated elements:
238
-     *    array(
239
-     *        'buttons' => array(
240
-     *            'add' => __('label for add new button'),
241
-     *            'edit' => __('label for edit button'),
242
-     *            'delete' => __('label for delete button')
243
-     *            )
244
-     *        )
245
-     *
246
-     * @abstract
247
-     * @access protected
248
-     * @return void
249
-     */
250
-    abstract protected function _define_page_props();
251
-
252
-
253
-
254
-    /**
255
-     * _set_page_routes
256
-     * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
-     * route. Here's the format
258
-     * $this->_page_routes = array(
259
-     *        'default' => array(
260
-     *            'func' => '_default_method_handling_route',
261
-     *            'args' => array('array','of','args'),
262
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
-     *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
-     *        ),
267
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
-     *        )
269
-     * )
270
-     *
271
-     * @abstract
272
-     * @access protected
273
-     * @return void
274
-     */
275
-    abstract protected function _set_page_routes();
276
-
277
-
278
-
279
-    /**
280
-     * _set_page_config
281
-     * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
-     * Format:
283
-     * $this->_page_config = array(
284
-     *        'default' => array(
285
-     *            'labels' => array(
286
-     *                'buttons' => array(
287
-     *                    'add' => __('label for adding item'),
288
-     *                    'edit' => __('label for editing item'),
289
-     *                    'delete' => __('label for deleting item')
290
-     *                ),
291
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
-     *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
-     *            'nav' => array(
294
-     *                'label' => __('Label for Tab', 'event_espresso').
295
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
-     *                'order' => 10, //required to indicate tab position.
298
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
-     *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
-     *            this flag to make sure the necessary js gets enqueued on page load.
303
-     *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
-     *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
-     *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
307
-     *                'tab_id' => array(
308
-     *                    'title' => 'tab_title',
309
-     *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
-     *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
-     *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
-     *                    ),
313
-     *                'tab2_id' => array(
314
-     *                    'title' => 'tab2 title',
315
-     *                    'filename' => 'file_name_2'
316
-     *                    'callback' => 'callback_method_for_content',
317
-     *                 ),
318
-     *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
-     *            'help_tour' => array(
320
-     *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
-     *            ),
323
-     *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
-     *            'require_nonce' to FALSE
325
-     *            )
326
-     * )
327
-     *
328
-     * @abstract
329
-     * @access protected
330
-     * @return void
331
-     */
332
-    abstract protected function _set_page_config();
333
-
334
-
335
-
336
-
337
-
338
-    /** end sample help_tour methods **/
339
-    /**
340
-     * _add_screen_options
341
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
-     * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
-     *
344
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
-     *         see also WP_Screen object documents...
346
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
-     * @abstract
348
-     * @access protected
349
-     * @return void
350
-     */
351
-    abstract protected function _add_screen_options();
352
-
353
-
354
-
355
-    /**
356
-     * _add_feature_pointers
357
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
-     * Note: this is just a placeholder for now.  Implementation will come down the road
360
-     * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
-     *
362
-     * @link   http://eamann.com/tech/wordpress-portland/
363
-     * @abstract
364
-     * @access protected
365
-     * @return void
366
-     */
367
-    abstract protected function _add_feature_pointers();
368
-
369
-
370
-
371
-    /**
372
-     * load_scripts_styles
373
-     * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
-     * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
-     *
376
-     * @abstract
377
-     * @access public
378
-     * @return void
379
-     */
380
-    abstract public function load_scripts_styles();
381
-
382
-
383
-
384
-    /**
385
-     * admin_init
386
-     * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
-     *
388
-     * @abstract
389
-     * @access public
390
-     * @return void
391
-     */
392
-    abstract public function admin_init();
393
-
394
-
395
-
396
-    /**
397
-     * admin_notices
398
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
-     *
400
-     * @abstract
401
-     * @access public
402
-     * @return void
403
-     */
404
-    abstract public function admin_notices();
405
-
406
-
407
-
408
-    /**
409
-     * admin_footer_scripts
410
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
-     *
412
-     * @access public
413
-     * @return void
414
-     */
415
-    abstract public function admin_footer_scripts();
416
-
417
-
418
-
419
-    /**
420
-     * admin_footer
421
-     * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
-     *
423
-     * @access  public
424
-     * @return void
425
-     */
426
-    public function admin_footer()
427
-    {
428
-    }
429
-
430
-
431
-
432
-    /**
433
-     * _global_ajax_hooks
434
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
-     * Note: within the ajax callback methods.
436
-     *
437
-     * @abstract
438
-     * @access protected
439
-     * @return void
440
-     */
441
-    protected function _global_ajax_hooks()
442
-    {
443
-        //for lazy loading of metabox content
444
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
-    }
446
-
447
-
448
-
449
-    public function ajax_metabox_content()
450
-    {
451
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
-        self::cached_rss_display($contentid, $url);
454
-        wp_die();
455
-    }
456
-
457
-
458
-
459
-    /**
460
-     * _page_setup
461
-     * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
-     *
463
-     * @final
464
-     * @access protected
465
-     * @return void
466
-     */
467
-    final protected function _page_setup()
468
-    {
469
-        //requires?
470
-        //admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
471
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
472
-        //next verify if we need to load anything...
473
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
-        $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
-        global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
477
-        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
-            return false;
479
-        }
480
-        // becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
481
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
-        }
484
-        // then set blank or -1 action values to 'default'
485
-        $this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
-        //if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
487
-        $this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
-        $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
492
-        $this->_define_page_props();
493
-        $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
-        //default things
495
-        $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
-        //set page configs
497
-        $this->_set_page_routes();
498
-        $this->_set_page_config();
499
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
500
-        if (isset($this->_req_data['wp_referer'])) {
501
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
-        }
503
-        //for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
504
-        if (method_exists($this, '_extend_page_config')) {
505
-            $this->_extend_page_config();
506
-        }
507
-        //for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
508
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
509
-            $this->_extend_page_config_for_cpt();
510
-        }
511
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
-        //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
-        }
518
-        //next route only if routing enabled
519
-        if ($this->_routing && ! defined('DOING_AJAX')) {
520
-            $this->_verify_routes();
521
-            //next let's just check user_access and kill if no access
522
-            $this->check_user_access();
523
-            if ($this->_is_UI_request) {
524
-                //admin_init stuff - global, all views for this page class, specific view
525
-                add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
-                }
529
-            } else {
530
-                //hijack regular WP loading and route admin request immediately
531
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
-                $this->route_admin_request();
533
-            }
534
-        }
535
-    }
536
-
537
-
538
-
539
-    /**
540
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
-     *
542
-     * @access private
543
-     * @return void
544
-     */
545
-    private function _do_other_page_hooks()
546
-    {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
-        foreach ($registered_pages as $page) {
549
-            //now let's setup the file name and class that should be present
550
-            $classname = str_replace('.class.php', '', $page);
551
-            //autoloaders should take care of loading file
552
-            if ( ! class_exists($classname)) {
553
-                $error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
-                $error_msg[] = $error_msg[0]
555
-                               . "\r\n"
556
-                               . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
-                                'event_espresso'), $page, '<br />', $classname);
558
-                throw new EE_Error(implode('||', $error_msg));
559
-            }
560
-            $a = new ReflectionClass($classname);
561
-            //notice we are passing the instance of this class to the hook object.
562
-            $hookobj[] = $a->newInstance($this);
563
-        }
564
-    }
565
-
566
-
567
-
568
-    public function load_page_dependencies()
569
-    {
570
-        try {
571
-            $this->_load_page_dependencies();
572
-        } catch (EE_Error $e) {
573
-            $e->get_error();
574
-        }
575
-    }
576
-
577
-
578
-
579
-    /**
580
-     * load_page_dependencies
581
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
-     *
583
-     * @access public
584
-     * @return void
585
-     */
586
-    protected function _load_page_dependencies()
587
-    {
588
-        //let's set the current_screen and screen options to override what WP set
589
-        $this->_current_screen = get_current_screen();
590
-        //load admin_notices - global, page class, and view specific
591
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
-        }
596
-        //load network admin_notices - global, page class, and view specific
597
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
-        }
601
-        //this will save any per_page screen options if they are present
602
-        $this->_set_per_page_screen_options();
603
-        //setup list table properties
604
-        $this->_set_list_table();
605
-        // child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
606
-        $this->_add_registered_meta_boxes();
607
-        $this->_add_screen_columns();
608
-        //add screen options - global, page child class, and view specific
609
-        $this->_add_global_screen_options();
610
-        $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
-        }
614
-        //add help tab(s) and tours- set via page_config and qtips.
615
-        $this->_add_help_tour();
616
-        $this->_add_help_tabs();
617
-        $this->_add_qtips();
618
-        //add feature_pointers - global, page child class, and view specific
619
-        $this->_add_feature_pointers();
620
-        $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
-        }
624
-        //enqueue scripts/styles - global, page class, and view specific
625
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
-        }
630
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
-        //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
-        }
637
-        //admin footer scripts
638
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
-        }
643
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
-        //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
-    }
647
-
648
-
649
-
650
-    /**
651
-     * _set_defaults
652
-     * This sets some global defaults for class properties.
653
-     */
654
-    private function _set_defaults()
655
-    {
656
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
-        $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
-        $this->default_nav_tab_name = 'overview';
659
-        //init template args
660
-        $this->_template_args = array(
661
-                'admin_page_header'  => '',
662
-                'admin_page_content' => '',
663
-                'post_body_content'  => '',
664
-                'before_list_table'  => '',
665
-                'after_list_table'   => '',
666
-        );
667
-    }
668
-
669
-
670
-
671
-    /**
672
-     * route_admin_request
673
-     *
674
-     * @see    _route_admin_request()
675
-     * @access public
676
-     * @return void|exception error
677
-     */
678
-    public function route_admin_request()
679
-    {
680
-        try {
681
-            $this->_route_admin_request();
682
-        } catch (EE_Error $e) {
683
-            $e->get_error();
684
-        }
685
-    }
686
-
687
-
688
-
689
-    public function set_wp_page_slug($wp_page_slug)
690
-    {
691
-        $this->_wp_page_slug = $wp_page_slug;
692
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
-        if (is_network_admin()) {
694
-            $this->_wp_page_slug .= '-network';
695
-        }
696
-    }
697
-
698
-
699
-
700
-    /**
701
-     * _verify_routes
702
-     * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
-     *
704
-     * @access protected
705
-     * @return void
706
-     */
707
-    protected function _verify_routes()
708
-    {
709
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
-        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
-            return false;
712
-        }
713
-        $this->_route = false;
714
-        $func = false;
715
-        $args = array();
716
-        // check that the page_routes array is not empty
717
-        if (empty($this->_page_routes)) {
718
-            // user error msg
719
-            $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
-            // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
-            throw new EE_Error($error_msg);
723
-        }
724
-        // and that the requested page route exists
725
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
-            $this->_route = $this->_page_routes[$this->_req_action];
727
-            $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
-        } else {
729
-            // user error msg
730
-            $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
-            // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
-            throw new EE_Error($error_msg);
734
-        }
735
-        // and that a default route exists
736
-        if ( ! array_key_exists('default', $this->_page_routes)) {
737
-            // user error msg
738
-            $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
-            // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
-            throw new EE_Error($error_msg);
742
-        }
743
-        //first lets' catch if the UI request has EVER been set.
744
-        if ($this->_is_UI_request === null) {
745
-            //lets set if this is a UI request or not.
746
-            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
-            //wait a minute... we might have a noheader in the route array
748
-            $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
-        }
750
-        $this->_set_current_labels();
751
-    }
752
-
753
-
754
-
755
-    /**
756
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
-     *
758
-     * @param  string $route the route name we're verifying
759
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
-     */
761
-    protected function _verify_route($route)
762
-    {
763
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
-            return true;
765
-        } else {
766
-            // user error msg
767
-            $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
-            // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
-            throw new EE_Error($error_msg);
771
-        }
772
-    }
773
-
774
-
775
-
776
-    /**
777
-     * perform nonce verification
778
-     * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
-     *
780
-     * @param  string $nonce     The nonce sent
781
-     * @param  string $nonce_ref The nonce reference string (name0)
782
-     * @return mixed (bool|die)
783
-     */
784
-    protected function _verify_nonce($nonce, $nonce_ref)
785
-    {
786
-        // verify nonce against expected value
787
-        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
-            // these are not the droids you are looking for !!!
789
-            $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
-            if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
-            }
793
-            if ( ! defined('DOING_AJAX')) {
794
-                wp_die($msg);
795
-            } else {
796
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
-                $this->_return_json();
798
-            }
799
-        }
800
-    }
801
-
802
-
803
-
804
-    /**
805
-     * _route_admin_request()
806
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
-     * in the page routes and then will try to load the corresponding method.
809
-     *
810
-     * @access protected
811
-     * @return void
812
-     * @throws \EE_Error
813
-     */
814
-    protected function _route_admin_request()
815
-    {
816
-        if ( ! $this->_is_UI_request) {
817
-            $this->_verify_routes();
818
-        }
819
-        $nonce_check = isset($this->_route_config['require_nonce'])
820
-            ? $this->_route_config['require_nonce']
821
-            : true;
822
-        if ($this->_req_action !== 'default' && $nonce_check) {
823
-            // set nonce from post data
824
-            $nonce = isset($this->_req_data[$this->_req_nonce])
825
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
-                : '';
827
-            $this->_verify_nonce($nonce, $this->_req_nonce);
828
-        }
829
-        //set the nav_tabs array but ONLY if this is  UI_request
830
-        if ($this->_is_UI_request) {
831
-            $this->_set_nav_tabs();
832
-        }
833
-        // grab callback function
834
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
-        // check if callback has args
836
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
-        $error_msg = '';
838
-        // action right before calling route
839
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
-        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
-        }
843
-        // right before calling the route, let's remove _wp_http_referer from the
844
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
-        if ( ! empty($func)) {
847
-            if (is_array($func)) {
848
-                list($class, $method) = $func;
849
-            } else if (strpos($func, '::') !== false) {
850
-                list($class, $method) = explode('::', $func);
851
-            } else {
852
-                $class = $this;
853
-                $method = $func;
854
-            }
855
-            if ( ! (is_object($class) && $class === $this)) {
856
-                // send along this admin page object for access by addons.
857
-                $args['admin_page_object'] = $this;
858
-            }
859
-            if (
860
-                //is it a method on a class that doesn't work?
861
-                (
862
-                    method_exists($class, $method)
863
-                    && call_user_func_array(array($class, $method), $args) === false
864
-                )
865
-                || (
866
-                    //is it a standalone function that doesn't work?
867
-                    function_exists($method)
868
-                    && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
869
-                )
870
-                || (
871
-                    //is it neither a class method NOR a standalone function?
872
-                    ! method_exists($class, $method)
873
-                    && ! function_exists($method)
874
-                )
875
-            ) {
876
-                // user error msg
877
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
878
-                // developer error msg
879
-                $error_msg .= '||';
880
-                $error_msg .= sprintf(
881
-                    __(
882
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
883
-                        'event_espresso'
884
-                    ),
885
-                    $method
886
-                );
887
-            }
888
-            if ( ! empty($error_msg)) {
889
-                throw new EE_Error($error_msg);
890
-            }
891
-        }
892
-        //if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
893
-        //now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
894
-        if ($this->_is_UI_request === false
895
-            && is_array($this->_route)
896
-            && ! empty($this->_route['headers_sent_route'])
897
-        ) {
898
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
899
-        }
900
-    }
901
-
902
-
903
-
904
-    /**
905
-     * This method just allows the resetting of page properties in the case where a no headers
906
-     * route redirects to a headers route in its route config.
907
-     *
908
-     * @since   4.3.0
909
-     * @param  string $new_route New (non header) route to redirect to.
910
-     * @return   void
911
-     */
912
-    protected function _reset_routing_properties($new_route)
913
-    {
914
-        $this->_is_UI_request = true;
915
-        //now we set the current route to whatever the headers_sent_route is set at
916
-        $this->_req_data['action'] = $new_route;
917
-        //rerun page setup
918
-        $this->_page_setup();
919
-    }
920
-
921
-
922
-
923
-    /**
924
-     * _add_query_arg
925
-     * adds nonce to array of arguments then calls WP add_query_arg function
926
-     *(internally just uses EEH_URL's function with the same name)
927
-     *
928
-     * @access public
929
-     * @param array  $args
930
-     * @param string $url
931
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
932
-     *                                        url in an associative array indexed by the key 'wp_referer';
933
-     *                                        Example usage:
934
-     *                                        If the current page is:
935
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
936
-     *                                        &action=default&event_id=20&month_range=March%202015
937
-     *                                        &_wpnonce=5467821
938
-     *                                        and you call:
939
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
940
-     *                                        array(
941
-     *                                        'action' => 'resend_something',
942
-     *                                        'page=>espresso_registrations'
943
-     *                                        ),
944
-     *                                        $some_url,
945
-     *                                        true
946
-     *                                        );
947
-     *                                        It will produce a url in this structure:
948
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
949
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
950
-     *                                        month_range]=March%202015
951
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
952
-     * @return string
953
-     */
954
-    public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
955
-    {
956
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
957
-        if ($sticky) {
958
-            $request = $_REQUEST;
959
-            unset($request['_wp_http_referer']);
960
-            unset($request['wp_referer']);
961
-            foreach ($request as $key => $value) {
962
-                //do not add nonces
963
-                if (strpos($key, 'nonce') !== false) {
964
-                    continue;
965
-                }
966
-                $args['wp_referer[' . $key . ']'] = $value;
967
-            }
968
-        }
969
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
970
-    }
971
-
972
-
973
-
974
-    /**
975
-     * This returns a generated link that will load the related help tab.
976
-     *
977
-     * @param  string $help_tab_id the id for the connected help tab
978
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
979
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
980
-     * @uses EEH_Template::get_help_tab_link()
981
-     * @return string              generated link
982
-     */
983
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
984
-    {
985
-        return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
986
-    }
987
-
988
-
989
-
990
-    /**
991
-     * _add_help_tabs
992
-     * Note child classes define their help tabs within the page_config array.
993
-     *
994
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
995
-     * @access protected
996
-     * @return void
997
-     */
998
-    protected function _add_help_tabs()
999
-    {
1000
-        $tour_buttons = '';
1001
-        if (isset($this->_page_config[$this->_req_action])) {
1002
-            $config = $this->_page_config[$this->_req_action];
1003
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1004
-            if (isset($this->_help_tour[$this->_req_action])) {
1005
-                $tb = array();
1006
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1007
-                foreach ($this->_help_tour['tours'] as $tour) {
1008
-                    //if this is the end tour then we don't need to setup a button
1009
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1010
-                        continue;
1011
-                    }
1012
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1013
-                }
1014
-                $tour_buttons .= implode('<br />', $tb);
1015
-                $tour_buttons .= '</div></div>';
1016
-            }
1017
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1018
-            if (is_array($config) && isset($config['help_sidebar'])) {
1019
-                //check that the callback given is valid
1020
-                if ( ! method_exists($this, $config['help_sidebar'])) {
1021
-                    throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1022
-                            'event_espresso'), $config['help_sidebar'], get_class($this)));
1023
-                }
1024
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025
-                $content .= $tour_buttons; //add help tour buttons.
1026
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1027
-                $this->_current_screen->set_help_sidebar($content);
1028
-            }
1029
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1030
-            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1031
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1032
-            }
1033
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1034
-            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035
-                $_ht['id'] = $this->page_slug;
1036
-                $_ht['title'] = __('Help Tours', 'event_espresso');
1037
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1038
-                $this->_current_screen->add_help_tab($_ht);
1039
-            }/**/
1040
-            if ( ! isset($config['help_tabs'])) {
1041
-                return;
1042
-            } //no help tabs for this route
1043
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1044
-                //we're here so there ARE help tabs!
1045
-                //make sure we've got what we need
1046
-                if ( ! isset($cfg['title'])) {
1047
-                    throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1048
-                }
1049
-                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1050
-                    throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1051
-                            'event_espresso'));
1052
-                }
1053
-                //first priority goes to content.
1054
-                if ( ! empty($cfg['content'])) {
1055
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056
-                    //second priority goes to filename
1057
-                } else if ( ! empty($cfg['filename'])) {
1058
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1059
-                    //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1060
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1061
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062
-                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063
-                        EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1064
-                                'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1065
-                        return;
1066
-                    }
1067
-                    $template_args['admin_page_obj'] = $this;
1068
-                    $content = EEH_Template::display_template($file_path, $template_args, true);
1069
-                } else {
1070
-                    $content = '';
1071
-                }
1072
-                //check if callback is valid
1073
-                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1074
-                    EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1075
-                            'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1076
-                    return;
1077
-                }
1078
-                //setup config array for help tab method
1079
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1080
-                $_ht = array(
1081
-                        'id'       => $id,
1082
-                        'title'    => $cfg['title'],
1083
-                        'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1084
-                        'content'  => $content,
1085
-                );
1086
-                $this->_current_screen->add_help_tab($_ht);
1087
-            }
1088
-        }
1089
-    }
1090
-
1091
-
1092
-
1093
-    /**
1094
-     * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1095
-     *
1096
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1097
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1098
-     * @access protected
1099
-     * @return void
1100
-     */
1101
-    protected function _add_help_tour()
1102
-    {
1103
-        $tours = array();
1104
-        $this->_help_tour = array();
1105
-        //exit early if help tours are turned off globally
1106
-        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1107
-            return;
1108
-        }
1109
-        //loop through _page_config to find any help_tour defined
1110
-        foreach ($this->_page_config as $route => $config) {
1111
-            //we're only going to set things up for this route
1112
-            if ($route !== $this->_req_action) {
1113
-                continue;
1114
-            }
1115
-            if (isset($config['help_tour'])) {
1116
-                foreach ($config['help_tour'] as $tour) {
1117
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1118
-                    //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1119
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1120
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121
-                    if ( ! is_readable($file_path)) {
1122
-                        EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1123
-                                $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1124
-                        return;
1125
-                    }
1126
-                    require_once $file_path;
1127
-                    if ( ! class_exists($tour)) {
1128
-                        $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1130
-                                        'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131
-                        throw new EE_Error(implode('||', $error_msg));
1132
-                    }
1133
-                    $a = new ReflectionClass($tour);
1134
-                    $tour_obj = $a->newInstance($this->_is_caf);
1135
-                    $tours[] = $tour_obj;
1136
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1137
-                }
1138
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1139
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1140
-                $tours[] = $end_stop_tour;
1141
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1142
-            }
1143
-        }
1144
-        if ( ! empty($tours)) {
1145
-            $this->_help_tour['tours'] = $tours;
1146
-        }
1147
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1148
-    }
1149
-
1150
-
1151
-
1152
-    /**
1153
-     * This simply sets up any qtips that have been defined in the page config
1154
-     *
1155
-     * @access protected
1156
-     * @return void
1157
-     */
1158
-    protected function _add_qtips()
1159
-    {
1160
-        if (isset($this->_route_config['qtips'])) {
1161
-            $qtips = (array)$this->_route_config['qtips'];
1162
-            //load qtip loader
1163
-            $path = array(
1164
-                    $this->_get_dir() . '/qtips/',
1165
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1166
-            );
1167
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1168
-        }
1169
-    }
1170
-
1171
-
1172
-
1173
-    /**
1174
-     * _set_nav_tabs
1175
-     * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1176
-     *
1177
-     * @access protected
1178
-     * @return void
1179
-     */
1180
-    protected function _set_nav_tabs()
1181
-    {
1182
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1183
-        $i = 0;
1184
-        foreach ($this->_page_config as $slug => $config) {
1185
-            if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1186
-                continue;
1187
-            } //no nav tab for this config
1188
-            //check for persistent flag
1189
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1190
-                continue;
1191
-            } //nav tab is only to appear when route requested.
1192
-            if ( ! $this->check_user_access($slug, true)) {
1193
-                continue;
1194
-            } //no nav tab becasue current user does not have access.
1195
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1196
-            $this->_nav_tabs[$slug] = array(
1197
-                    'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198
-                    'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1200
-                    'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201
-            );
1202
-            $i++;
1203
-        }
1204
-        //if $this->_nav_tabs is empty then lets set the default
1205
-        if (empty($this->_nav_tabs)) {
1206
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1207
-                    'url'       => $this->admin_base_url,
1208
-                    'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1209
-                    'css_class' => 'nav-tab-active',
1210
-                    'order'     => 10,
1211
-            );
1212
-        }
1213
-        //now let's sort the tabs according to order
1214
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1215
-    }
1216
-
1217
-
1218
-
1219
-    /**
1220
-     * _set_current_labels
1221
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1222
-     *
1223
-     * @access private
1224
-     * @return void
1225
-     */
1226
-    private function _set_current_labels()
1227
-    {
1228
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1229
-            foreach ($this->_route_config['labels'] as $label => $text) {
1230
-                if (is_array($text)) {
1231
-                    foreach ($text as $sublabel => $subtext) {
1232
-                        $this->_labels[$label][$sublabel] = $subtext;
1233
-                    }
1234
-                } else {
1235
-                    $this->_labels[$label] = $text;
1236
-                }
1237
-            }
1238
-        }
1239
-    }
1240
-
1241
-
1242
-
1243
-    /**
1244
-     *        verifies user access for this admin page
1245
-     *
1246
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1247
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1248
-     * @return        BOOL|wp_die()
1249
-     */
1250
-    public function check_user_access($route_to_check = '', $verify_only = false)
1251
-    {
1252
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1253
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1254
-        $capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1255
-                ? $this->_page_routes[$route_to_check]['capability'] : null;
1256
-        if (empty($capability) && empty($route_to_check)) {
1257
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1258
-        } else {
1259
-            $capability = empty($capability) ? 'manage_options' : $capability;
1260
-        }
1261
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263
-            if ($verify_only) {
1264
-                return false;
1265
-            } else {
1266
-                wp_die(__('You do not have access to this route.', 'event_espresso'));
1267
-            }
1268
-        }
1269
-        return true;
1270
-    }
1271
-
1272
-
1273
-
1274
-    /**
1275
-     * admin_init_global
1276
-     * This runs all the code that we want executed within the WP admin_init hook.
1277
-     * This method executes for ALL EE Admin pages.
1278
-     *
1279
-     * @access public
1280
-     * @return void
1281
-     */
1282
-    public function admin_init_global()
1283
-    {
1284
-    }
1285
-
1286
-
1287
-
1288
-    /**
1289
-     * wp_loaded_global
1290
-     * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1291
-     *
1292
-     * @access public
1293
-     * @return void
1294
-     */
1295
-    public function wp_loaded()
1296
-    {
1297
-    }
1298
-
1299
-
1300
-
1301
-    /**
1302
-     * admin_notices
1303
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1304
-     *
1305
-     * @access public
1306
-     * @return void
1307
-     */
1308
-    public function admin_notices_global()
1309
-    {
1310
-        $this->_display_no_javascript_warning();
1311
-        $this->_display_espresso_notices();
1312
-    }
1313
-
1314
-
1315
-
1316
-    public function network_admin_notices_global()
1317
-    {
1318
-        $this->_display_no_javascript_warning();
1319
-        $this->_display_espresso_notices();
1320
-    }
1321
-
1322
-
1323
-
1324
-    /**
1325
-     * admin_footer_scripts_global
1326
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1327
-     *
1328
-     * @access public
1329
-     * @return void
1330
-     */
1331
-    public function admin_footer_scripts_global()
1332
-    {
1333
-        $this->_add_admin_page_ajax_loading_img();
1334
-        $this->_add_admin_page_overlay();
1335
-        //if metaboxes are present we need to add the nonce field
1336
-        if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1337
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1338
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1339
-        }
1340
-    }
1341
-
1342
-
1343
-
1344
-    /**
1345
-     * admin_footer_global
1346
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1347
-     *
1348
-     * @access  public
1349
-     * @return  void
1350
-     */
1351
-    public function admin_footer_global()
1352
-    {
1353
-        //dialog container for dialog helper
1354
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1355
-        $d_cont .= '<div class="ee-notices"></div>';
1356
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1357
-        $d_cont .= '</div>';
1358
-        echo $d_cont;
1359
-        //help tour stuff?
1360
-        if (isset($this->_help_tour[$this->_req_action])) {
1361
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1362
-        }
1363
-        //current set timezone for timezone js
1364
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1365
-    }
1366
-
1367
-
1368
-
1369
-    /**
1370
-     * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1371
-     * For child classes:
1372
-     * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1373
-     * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1374
-     * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1375
-     *    'help_trigger_id' => array(
1376
-     *        'title' => __('localized title for popup', 'event_espresso'),
1377
-     *        'content' => __('localized content for popup', 'event_espresso')
1378
-     *    )
1379
-     * );
1380
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1381
-     *
1382
-     * @access protected
1383
-     * @return string content
1384
-     */
1385
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1386
-    {
1387
-        $content = '';
1388
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1389
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1390
-        //loop through the array and setup content
1391
-        foreach ($help_array as $trigger => $help) {
1392
-            //make sure the array is setup properly
1393
-            if ( ! isset($help['title']) || ! isset($help['content'])) {
1394
-                throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1395
-                        'event_espresso'));
1396
-            }
1397
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1398
-            $template_args = array(
1399
-                    'help_popup_id'      => $trigger,
1400
-                    'help_popup_title'   => $help['title'],
1401
-                    'help_popup_content' => $help['content'],
1402
-            );
1403
-            $content .= EEH_Template::display_template($template_path, $template_args, true);
1404
-        }
1405
-        if ($display) {
1406
-            echo $content;
1407
-        } else {
1408
-            return $content;
1409
-        }
1410
-    }
1411
-
1412
-
1413
-
1414
-    /**
1415
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1416
-     *
1417
-     * @access private
1418
-     * @return array properly formatted array for help popup content
1419
-     */
1420
-    private function _get_help_content()
1421
-    {
1422
-        //what is the method we're looking for?
1423
-        $method_name = '_help_popup_content_' . $this->_req_action;
1424
-        //if method doesn't exist let's get out.
1425
-        if ( ! method_exists($this, $method_name)) {
1426
-            return array();
1427
-        }
1428
-        //k we're good to go let's retrieve the help array
1429
-        $help_array = call_user_func(array($this, $method_name));
1430
-        //make sure we've got an array!
1431
-        if ( ! is_array($help_array)) {
1432
-            throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1433
-        }
1434
-        return $help_array;
1435
-    }
1436
-
1437
-
1438
-
1439
-    /**
1440
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1441
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1442
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1443
-     *
1444
-     * @access protected
1445
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1446
-     * @param boolean $display    if false then we return the trigger string
1447
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1448
-     * @return string
1449
-     */
1450
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1451
-    {
1452
-        if (defined('DOING_AJAX')) {
1453
-            return;
1454
-        }
1455
-        //let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1456
-        $help_array = $this->_get_help_content();
1457
-        $help_content = '';
1458
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1459
-            $help_array[$trigger_id] = array(
1460
-                    'title'   => __('Missing Content', 'event_espresso'),
1461
-                    'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1462
-                            'event_espresso'),
1463
-            );
1464
-            $help_content = $this->_set_help_popup_content($help_array, false);
1465
-        }
1466
-        //let's setup the trigger
1467
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
-        $content = $content . $help_content;
1469
-        if ($display) {
1470
-            echo $content;
1471
-        } else {
1472
-            return $content;
1473
-        }
1474
-    }
1475
-
1476
-
1477
-
1478
-    /**
1479
-     * _add_global_screen_options
1480
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1481
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1482
-     *
1483
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1484
-     *         see also WP_Screen object documents...
1485
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1486
-     * @abstract
1487
-     * @access private
1488
-     * @return void
1489
-     */
1490
-    private function _add_global_screen_options()
1491
-    {
1492
-    }
1493
-
1494
-
1495
-
1496
-    /**
1497
-     * _add_global_feature_pointers
1498
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1499
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1500
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1501
-     *
1502
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1503
-     * @link   http://eamann.com/tech/wordpress-portland/
1504
-     * @abstract
1505
-     * @access protected
1506
-     * @return void
1507
-     */
1508
-    private function _add_global_feature_pointers()
1509
-    {
1510
-    }
1511
-
1512
-
1513
-
1514
-    /**
1515
-     * load_global_scripts_styles
1516
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1517
-     *
1518
-     * @return void
1519
-     */
1520
-    public function load_global_scripts_styles()
1521
-    {
1522
-        /** STYLES **/
1523
-        // add debugging styles
1524
-        if (WP_DEBUG) {
1525
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1526
-        }
1527
-        //register all styles
1528
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1530
-        //helpers styles
1531
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1532
-        //enqueue global styles
1533
-        wp_enqueue_style('ee-admin-css');
1534
-        /** SCRIPTS **/
1535
-        //register all scripts
1536
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540
-        // register jQuery Validate - see /includes/functions/wp_hooks.php
1541
-        add_filter('FHEE_load_jquery_validate', '__return_true');
1542
-        add_filter('FHEE_load_joyride', '__return_true');
1543
-        //script for sorting tables
1544
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1545
-        //script for parsing uri's
1546
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1547
-        //and parsing associative serialized form elements
1548
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1549
-        //helpers scripts
1550
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554
-        //google charts
1555
-        wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1556
-        //enqueue global scripts
1557
-        //taking care of metaboxes
1558
-        if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1559
-            wp_enqueue_script('dashboard');
1560
-        }
1561
-        //enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1562
-        if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1563
-            wp_enqueue_script('ee_admin_js');
1564
-            wp_enqueue_style('ee-admin-css');
1565
-        }
1566
-        //localize script for ajax lazy loading
1567
-        $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1568
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1569
-        /**
1570
-         * help tour stuff
1571
-         */
1572
-        if ( ! empty($this->_help_tour)) {
1573
-            //register the js for kicking things off
1574
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1575
-            //setup tours for the js tour object
1576
-            foreach ($this->_help_tour['tours'] as $tour) {
1577
-                $tours[] = array(
1578
-                        'id'      => $tour->get_slug(),
1579
-                        'options' => $tour->get_options(),
1580
-                );
1581
-            }
1582
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1583
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1584
-        }
1585
-    }
1586
-
1587
-
1588
-
1589
-    /**
1590
-     *        admin_footer_scripts_eei18n_js_strings
1591
-     *
1592
-     * @access        public
1593
-     * @return        void
1594
-     */
1595
-    public function admin_footer_scripts_eei18n_js_strings()
1596
-    {
1597
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1598
-        EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1599
-        EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1600
-        EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1601
-        EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1602
-        EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1603
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1604
-        EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1605
-        EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1606
-        EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1607
-        EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1608
-        EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1609
-        EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1610
-        EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1611
-        EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1612
-        EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1613
-        EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1614
-        EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1615
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1616
-        EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1617
-        EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1618
-        EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1619
-        EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1620
-        EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1621
-        EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1622
-        EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1623
-        EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1624
-        EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1625
-        EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1626
-        EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1627
-        EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1628
-        EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1629
-        EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1630
-        EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1631
-        EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1632
-        EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1633
-        EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1634
-        EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1635
-        EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1636
-        EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1637
-        //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1638
-        //admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1639
-        //espresso_core is listed as a dependency of ee_admin_js.
1640
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1641
-    }
1642
-
1643
-
1644
-
1645
-    /**
1646
-     *        load enhanced xdebug styles for ppl with failing eyesight
1647
-     *
1648
-     * @access        public
1649
-     * @return        void
1650
-     */
1651
-    public function add_xdebug_style()
1652
-    {
1653
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1654
-    }
1655
-
1656
-
1657
-    /************************/
1658
-    /** LIST TABLE METHODS **/
1659
-    /************************/
1660
-    /**
1661
-     * this sets up the list table if the current view requires it.
1662
-     *
1663
-     * @access protected
1664
-     * @return void
1665
-     */
1666
-    protected function _set_list_table()
1667
-    {
1668
-        //first is this a list_table view?
1669
-        if ( ! isset($this->_route_config['list_table'])) {
1670
-            return;
1671
-        } //not a list_table view so get out.
1672
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
1673
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1674
-            //user error msg
1675
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1676
-            //developer error msg
1677
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1678
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1679
-            throw new EE_Error($error_msg);
1680
-        }
1681
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1682
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1683
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1684
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1685
-        $this->_set_list_table_view();
1686
-        $this->_set_list_table_object();
1687
-    }
1688
-
1689
-
1690
-
1691
-    /**
1692
-     *        set current view for List Table
1693
-     *
1694
-     * @access public
1695
-     * @return array
1696
-     */
1697
-    protected function _set_list_table_view()
1698
-    {
1699
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1700
-        // looking at active items or dumpster diving ?
1701
-        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1702
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1703
-        } else {
1704
-            $this->_view = sanitize_key($this->_req_data['status']);
1705
-        }
1706
-    }
1707
-
1708
-
1709
-
1710
-    /**
1711
-     * _set_list_table_object
1712
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1713
-     *
1714
-     * @throws \EE_Error
1715
-     */
1716
-    protected function _set_list_table_object()
1717
-    {
1718
-        if (isset($this->_route_config['list_table'])) {
1719
-            if ( ! class_exists($this->_route_config['list_table'])) {
1720
-                throw new EE_Error(
1721
-                        sprintf(
1722
-                                __(
1723
-                                        'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1724
-                                        'event_espresso'
1725
-                                ),
1726
-                                $this->_route_config['list_table'],
1727
-                                get_class($this)
1728
-                        )
1729
-                );
1730
-            }
1731
-            $list_table = $this->_route_config['list_table'];
1732
-            $this->_list_table_object = new $list_table($this);
1733
-        }
1734
-    }
1735
-
1736
-
1737
-
1738
-    /**
1739
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1740
-     *
1741
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1742
-     *                                                    urls.  The array should be indexed by the view it is being
1743
-     *                                                    added to.
1744
-     * @return array
1745
-     */
1746
-    public function get_list_table_view_RLs($extra_query_args = array())
1747
-    {
1748
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1749
-        if (empty($this->_views)) {
1750
-            $this->_views = array();
1751
-        }
1752
-        // cycle thru views
1753
-        foreach ($this->_views as $key => $view) {
1754
-            $query_args = array();
1755
-            // check for current view
1756
-            $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1757
-            $query_args['action'] = $this->_req_action;
1758
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1759
-            $query_args['status'] = $view['slug'];
1760
-            //merge any other arguments sent in.
1761
-            if (isset($extra_query_args[$view['slug']])) {
1762
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1763
-            }
1764
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1765
-        }
1766
-        return $this->_views;
1767
-    }
1768
-
1769
-
1770
-
1771
-    /**
1772
-     * _entries_per_page_dropdown
1773
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
1774
-     *
1775
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1776
-     * @access protected
1777
-     * @param int $max_entries total number of rows in the table
1778
-     * @return string
1779
-     */
1780
-    protected function _entries_per_page_dropdown($max_entries = false)
1781
-    {
1782
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1783
-        $values = array(10, 25, 50, 100);
1784
-        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1785
-        if ($max_entries) {
1786
-            $values[] = $max_entries;
1787
-            sort($values);
1788
-        }
1789
-        $entries_per_page_dropdown = '
143
+	// yes / no array for admin form fields
144
+	protected $_yes_no_values = array();
145
+
146
+	//some default things shared by all child classes
147
+	protected $_default_espresso_metaboxes;
148
+
149
+	/**
150
+	 *    EE_Registry Object
151
+	 *
152
+	 * @var    EE_Registry
153
+	 * @access    protected
154
+	 */
155
+	protected $EE = null;
156
+
157
+
158
+
159
+	/**
160
+	 * This is just a property that flags whether the given route is a caffeinated route or not.
161
+	 *
162
+	 * @var boolean
163
+	 */
164
+	protected $_is_caf = false;
165
+
166
+
167
+
168
+	/**
169
+	 * @Constructor
170
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
171
+	 * @access public
172
+	 */
173
+	public function __construct($routing = true)
174
+	{
175
+		if (strpos($this->_get_dir(), 'caffeinated') !== false) {
176
+			$this->_is_caf = true;
177
+		}
178
+		$this->_yes_no_values = array(
179
+				array('id' => true, 'text' => __('Yes', 'event_espresso')),
180
+				array('id' => false, 'text' => __('No', 'event_espresso')),
181
+		);
182
+		//set the _req_data property.
183
+		$this->_req_data = array_merge($_GET, $_POST);
184
+		//routing enabled?
185
+		$this->_routing = $routing;
186
+		//set initial page props (child method)
187
+		$this->_init_page_props();
188
+		//set global defaults
189
+		$this->_set_defaults();
190
+		//set early because incoming requests could be ajax related and we need to register those hooks.
191
+		$this->_global_ajax_hooks();
192
+		$this->_ajax_hooks();
193
+		//other_page_hooks have to be early too.
194
+		$this->_do_other_page_hooks();
195
+		//This just allows us to have extending clases do something specific before the parent constructor runs _page_setup.
196
+		if (method_exists($this, '_before_page_setup')) {
197
+			$this->_before_page_setup();
198
+		}
199
+		//set up page dependencies
200
+		$this->_page_setup();
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * _init_page_props
207
+	 * Child classes use to set at least the following properties:
208
+	 * $page_slug.
209
+	 * $page_label.
210
+	 *
211
+	 * @abstract
212
+	 * @access protected
213
+	 * @return void
214
+	 */
215
+	abstract protected function _init_page_props();
216
+
217
+
218
+
219
+	/**
220
+	 * _ajax_hooks
221
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
222
+	 * Note: within the ajax callback methods.
223
+	 *
224
+	 * @abstract
225
+	 * @access protected
226
+	 * @return void
227
+	 */
228
+	abstract protected function _ajax_hooks();
229
+
230
+
231
+
232
+	/**
233
+	 * _define_page_props
234
+	 * child classes define page properties in here.  Must include at least:
235
+	 * $_admin_base_url = base_url for all admin pages
236
+	 * $_admin_page_title = default admin_page_title for admin pages
237
+	 * $_labels = array of default labels for various automatically generated elements:
238
+	 *    array(
239
+	 *        'buttons' => array(
240
+	 *            'add' => __('label for add new button'),
241
+	 *            'edit' => __('label for edit button'),
242
+	 *            'delete' => __('label for delete button')
243
+	 *            )
244
+	 *        )
245
+	 *
246
+	 * @abstract
247
+	 * @access protected
248
+	 * @return void
249
+	 */
250
+	abstract protected function _define_page_props();
251
+
252
+
253
+
254
+	/**
255
+	 * _set_page_routes
256
+	 * child classes use this to define the page routes for all subpages handled by the class.  Page routes are assigned to a action => method pairs in an array and to the $_page_routes property.  Each page route must also have a 'default'
257
+	 * route. Here's the format
258
+	 * $this->_page_routes = array(
259
+	 *        'default' => array(
260
+	 *            'func' => '_default_method_handling_route',
261
+	 *            'args' => array('array','of','args'),
262
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
263
+	 *            'headers_sent_route'=>'headers_route_reference', //add this if noheader=>true, and you want to load a headers route after.  The string you enter here should match the defined route reference for a headers sent route.
264
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
265
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
266
+	 *        ),
267
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
268
+	 *        )
269
+	 * )
270
+	 *
271
+	 * @abstract
272
+	 * @access protected
273
+	 * @return void
274
+	 */
275
+	abstract protected function _set_page_routes();
276
+
277
+
278
+
279
+	/**
280
+	 * _set_page_config
281
+	 * child classes use this to define the _page_config array for all subpages handled by the class. Each key in the array corresponds to the page_route for the loaded page.
282
+	 * Format:
283
+	 * $this->_page_config = array(
284
+	 *        'default' => array(
285
+	 *            'labels' => array(
286
+	 *                'buttons' => array(
287
+	 *                    'add' => __('label for adding item'),
288
+	 *                    'edit' => __('label for editing item'),
289
+	 *                    'delete' => __('label for deleting item')
290
+	 *                ),
291
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
292
+	 *            ), //optional an array of custom labels for various automatically generated elements to use on the page. If this isn't present then the defaults will be used as set for the $this->_labels in _define_page_props() method
293
+	 *            'nav' => array(
294
+	 *                'label' => __('Label for Tab', 'event_espresso').
295
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
296
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
297
+	 *                'order' => 10, //required to indicate tab position.
298
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
299
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
300
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
301
+	 *            'has_metaboxes' => true, //this boolean flag can simply be used to indicate if the route will have metaboxes.  Typically this is used if the 'metaboxes' index is not used because metaboxes are added later.  We just use
302
+	 *            this flag to make sure the necessary js gets enqueued on page load.
303
+	 *            'has_help_popups' => false //defaults(true) //this boolean flag can simply be used to indicate if the given route has help popups setup and if it does then we need to make sure thickbox is enqueued.
304
+	 *            'columns' => array(4, 2), //this key triggers the setup of a page that uses columns (metaboxes).  The array indicates the max number of columns (4) and the default number of columns on page load (2).  There is an option
305
+	 *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
306
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
307
+	 *                'tab_id' => array(
308
+	 *                    'title' => 'tab_title',
309
+	 *                    'filename' => 'name_of_file_containing_content', //this is the primary method for setting help tab content.  The fallback if it isn't present is to try a the callback.  Filename should match a file in the admin
310
+	 *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
311
+	 *                    'callback' => 'callback_method_for_content', //if 'filename' isn't present then system will attempt to use the callback which should match the name of a method in the class
312
+	 *                    ),
313
+	 *                'tab2_id' => array(
314
+	 *                    'title' => 'tab2 title',
315
+	 *                    'filename' => 'file_name_2'
316
+	 *                    'callback' => 'callback_method_for_content',
317
+	 *                 ),
318
+	 *            'help_sidebar' => 'callback_for_sidebar_content', //this is used for setting up the sidebar in the help tab area on an admin page. @link http://make.wordpress.org/core/2011/12/06/help-and-screen-api-changes-in-3-3/
319
+	 *            'help_tour' => array(
320
+	 *                'name_of_help_tour_class', //all help tours shoudl be a child class of EE_Help_Tour and located in a folder for this admin page named "help_tours", a file name matching the key given here
321
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
322
+	 *            ),
323
+	 *            'require_nonce' => TRUE //this is used if you want to set a route to NOT require a nonce (default is true if it isn't present).  To remove the requirement for a nonce check when this route is visited just set
324
+	 *            'require_nonce' to FALSE
325
+	 *            )
326
+	 * )
327
+	 *
328
+	 * @abstract
329
+	 * @access protected
330
+	 * @return void
331
+	 */
332
+	abstract protected function _set_page_config();
333
+
334
+
335
+
336
+
337
+
338
+	/** end sample help_tour methods **/
339
+	/**
340
+	 * _add_screen_options
341
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
342
+	 * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
343
+	 *
344
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
345
+	 *         see also WP_Screen object documents...
346
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
347
+	 * @abstract
348
+	 * @access protected
349
+	 * @return void
350
+	 */
351
+	abstract protected function _add_screen_options();
352
+
353
+
354
+
355
+	/**
356
+	 * _add_feature_pointers
357
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
358
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
359
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
360
+	 * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
361
+	 *
362
+	 * @link   http://eamann.com/tech/wordpress-portland/
363
+	 * @abstract
364
+	 * @access protected
365
+	 * @return void
366
+	 */
367
+	abstract protected function _add_feature_pointers();
368
+
369
+
370
+
371
+	/**
372
+	 * load_scripts_styles
373
+	 * child classes put their wp_enqueue_script and wp_enqueue_style hooks in here for anything they need loaded for their pages/subpages.  Note this is for all pages/subpages of the system.  You can also load only specific scripts/styles
374
+	 * per view by putting them in a dynamic function in this format (load_scripts_styles_{$this->_current_view}) which matches your page route (action request arg)
375
+	 *
376
+	 * @abstract
377
+	 * @access public
378
+	 * @return void
379
+	 */
380
+	abstract public function load_scripts_styles();
381
+
382
+
383
+
384
+	/**
385
+	 * admin_init
386
+	 * Anything that should be set/executed at 'admin_init' WP hook runtime should be put in here.  This will apply to all pages/views loaded by child class.
387
+	 *
388
+	 * @abstract
389
+	 * @access public
390
+	 * @return void
391
+	 */
392
+	abstract public function admin_init();
393
+
394
+
395
+
396
+	/**
397
+	 * admin_notices
398
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply to all pages/views loaded by child class.
399
+	 *
400
+	 * @abstract
401
+	 * @access public
402
+	 * @return void
403
+	 */
404
+	abstract public function admin_notices();
405
+
406
+
407
+
408
+	/**
409
+	 * admin_footer_scripts
410
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply to all pages/views loaded by child class.
411
+	 *
412
+	 * @access public
413
+	 * @return void
414
+	 */
415
+	abstract public function admin_footer_scripts();
416
+
417
+
418
+
419
+	/**
420
+	 * admin_footer
421
+	 * anything triggered by the 'admin_footer' WP action hook should be added to here. This particular method will apply to all pages/views loaded by child class.
422
+	 *
423
+	 * @access  public
424
+	 * @return void
425
+	 */
426
+	public function admin_footer()
427
+	{
428
+	}
429
+
430
+
431
+
432
+	/**
433
+	 * _global_ajax_hooks
434
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
435
+	 * Note: within the ajax callback methods.
436
+	 *
437
+	 * @abstract
438
+	 * @access protected
439
+	 * @return void
440
+	 */
441
+	protected function _global_ajax_hooks()
442
+	{
443
+		//for lazy loading of metabox content
444
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
445
+	}
446
+
447
+
448
+
449
+	public function ajax_metabox_content()
450
+	{
451
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
452
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
453
+		self::cached_rss_display($contentid, $url);
454
+		wp_die();
455
+	}
456
+
457
+
458
+
459
+	/**
460
+	 * _page_setup
461
+	 * Makes sure any things that need to be loaded early get handled.  We also escape early here if the page requested doesn't match the object.
462
+	 *
463
+	 * @final
464
+	 * @access protected
465
+	 * @return void
466
+	 */
467
+	final protected function _page_setup()
468
+	{
469
+		//requires?
470
+		//admin_init stuff - global - we're setting this REALLY early so if EE_Admin pages have to hook into other WP pages they can.  But keep in mind, not everything is available from the EE_Admin Page object at this point.
471
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
472
+		//next verify if we need to load anything...
473
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475
+		global $ee_menu_slugs;
476
+		$ee_menu_slugs = (array)$ee_menu_slugs;
477
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478
+			return false;
479
+		}
480
+		// becuz WP List tables have two duplicate select inputs for choosing bulk actions, we need to copy the action from the second to the first
481
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
482
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
483
+		}
484
+		// then set blank or -1 action values to 'default'
485
+		$this->_req_action = isset($this->_req_data['action']) && ! empty($this->_req_data['action']) && $this->_req_data['action'] != -1 ? sanitize_key($this->_req_data['action']) : 'default';
486
+		//if action is 'default' after the above BUT we have  'route' var set, then let's use the route as the action.  This covers cases where we're coming in from a list table that isn't on the default route.
487
+		$this->_req_action = $this->_req_action == 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
488
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490
+		$this->_current_view = $this->_req_action;
491
+		$this->_req_nonce = $this->_req_action . '_nonce';
492
+		$this->_define_page_props();
493
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494
+		//default things
495
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
496
+		//set page configs
497
+		$this->_set_page_routes();
498
+		$this->_set_page_config();
499
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
500
+		if (isset($this->_req_data['wp_referer'])) {
501
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
502
+		}
503
+		//for caffeinated and other extended functionality.  If there is a _extend_page_config method then let's run that to modify the all the various page configuration arrays
504
+		if (method_exists($this, '_extend_page_config')) {
505
+			$this->_extend_page_config();
506
+		}
507
+		//for CPT and other extended functionality. If there is an _extend_page_config_for_cpt then let's run that to modify all the various page configuration arrays.
508
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
509
+			$this->_extend_page_config_for_cpt();
510
+		}
511
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
512
+		$this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
+		$this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
514
+		//if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
517
+		}
518
+		//next route only if routing enabled
519
+		if ($this->_routing && ! defined('DOING_AJAX')) {
520
+			$this->_verify_routes();
521
+			//next let's just check user_access and kill if no access
522
+			$this->check_user_access();
523
+			if ($this->_is_UI_request) {
524
+				//admin_init stuff - global, all views for this page class, specific view
525
+				add_action('admin_init', array($this, 'admin_init'), 10);
526
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
528
+				}
529
+			} else {
530
+				//hijack regular WP loading and route admin request immediately
531
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
532
+				$this->route_admin_request();
533
+			}
534
+		}
535
+	}
536
+
537
+
538
+
539
+	/**
540
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
541
+	 *
542
+	 * @access private
543
+	 * @return void
544
+	 */
545
+	private function _do_other_page_hooks()
546
+	{
547
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
+		foreach ($registered_pages as $page) {
549
+			//now let's setup the file name and class that should be present
550
+			$classname = str_replace('.class.php', '', $page);
551
+			//autoloaders should take care of loading file
552
+			if ( ! class_exists($classname)) {
553
+				$error_msg[] = sprintf(__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
+				$error_msg[] = $error_msg[0]
555
+							   . "\r\n"
556
+							   . sprintf(__('There is no class in place for the %s admin hooks page.%sMake sure you have <strong>%s</strong> defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
557
+								'event_espresso'), $page, '<br />', $classname);
558
+				throw new EE_Error(implode('||', $error_msg));
559
+			}
560
+			$a = new ReflectionClass($classname);
561
+			//notice we are passing the instance of this class to the hook object.
562
+			$hookobj[] = $a->newInstance($this);
563
+		}
564
+	}
565
+
566
+
567
+
568
+	public function load_page_dependencies()
569
+	{
570
+		try {
571
+			$this->_load_page_dependencies();
572
+		} catch (EE_Error $e) {
573
+			$e->get_error();
574
+		}
575
+	}
576
+
577
+
578
+
579
+	/**
580
+	 * load_page_dependencies
581
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
582
+	 *
583
+	 * @access public
584
+	 * @return void
585
+	 */
586
+	protected function _load_page_dependencies()
587
+	{
588
+		//let's set the current_screen and screen options to override what WP set
589
+		$this->_current_screen = get_current_screen();
590
+		//load admin_notices - global, page class, and view specific
591
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
593
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
595
+		}
596
+		//load network admin_notices - global, page class, and view specific
597
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
600
+		}
601
+		//this will save any per_page screen options if they are present
602
+		$this->_set_per_page_screen_options();
603
+		//setup list table properties
604
+		$this->_set_list_table();
605
+		// child classes can "register" a metabox to be automatically handled via the _page_config array property.  However in some cases the metaboxes will need to be added within a route handling callback.
606
+		$this->_add_registered_meta_boxes();
607
+		$this->_add_screen_columns();
608
+		//add screen options - global, page child class, and view specific
609
+		$this->_add_global_screen_options();
610
+		$this->_add_screen_options();
611
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
613
+		}
614
+		//add help tab(s) and tours- set via page_config and qtips.
615
+		$this->_add_help_tour();
616
+		$this->_add_help_tabs();
617
+		$this->_add_qtips();
618
+		//add feature_pointers - global, page child class, and view specific
619
+		$this->_add_feature_pointers();
620
+		$this->_add_global_feature_pointers();
621
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
623
+		}
624
+		//enqueue scripts/styles - global, page class, and view specific
625
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
629
+		}
630
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631
+		//admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
636
+		}
637
+		//admin footer scripts
638
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
640
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
642
+		}
643
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644
+		//targeted hook
645
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
+	}
647
+
648
+
649
+
650
+	/**
651
+	 * _set_defaults
652
+	 * This sets some global defaults for class properties.
653
+	 */
654
+	private function _set_defaults()
655
+	{
656
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
657
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
658
+		$this->default_nav_tab_name = 'overview';
659
+		//init template args
660
+		$this->_template_args = array(
661
+				'admin_page_header'  => '',
662
+				'admin_page_content' => '',
663
+				'post_body_content'  => '',
664
+				'before_list_table'  => '',
665
+				'after_list_table'   => '',
666
+		);
667
+	}
668
+
669
+
670
+
671
+	/**
672
+	 * route_admin_request
673
+	 *
674
+	 * @see    _route_admin_request()
675
+	 * @access public
676
+	 * @return void|exception error
677
+	 */
678
+	public function route_admin_request()
679
+	{
680
+		try {
681
+			$this->_route_admin_request();
682
+		} catch (EE_Error $e) {
683
+			$e->get_error();
684
+		}
685
+	}
686
+
687
+
688
+
689
+	public function set_wp_page_slug($wp_page_slug)
690
+	{
691
+		$this->_wp_page_slug = $wp_page_slug;
692
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
693
+		if (is_network_admin()) {
694
+			$this->_wp_page_slug .= '-network';
695
+		}
696
+	}
697
+
698
+
699
+
700
+	/**
701
+	 * _verify_routes
702
+	 * All this method does is verify the incoming request and make sure that routes exist for it.  We do this early so we know if we need to drop out.
703
+	 *
704
+	 * @access protected
705
+	 * @return void
706
+	 */
707
+	protected function _verify_routes()
708
+	{
709
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
710
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
711
+			return false;
712
+		}
713
+		$this->_route = false;
714
+		$func = false;
715
+		$args = array();
716
+		// check that the page_routes array is not empty
717
+		if (empty($this->_page_routes)) {
718
+			// user error msg
719
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720
+			// developer error msg
721
+			$error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
+			throw new EE_Error($error_msg);
723
+		}
724
+		// and that the requested page route exists
725
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
726
+			$this->_route = $this->_page_routes[$this->_req_action];
727
+			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
728
+		} else {
729
+			// user error msg
730
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731
+			// developer error msg
732
+			$error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733
+			throw new EE_Error($error_msg);
734
+		}
735
+		// and that a default route exists
736
+		if ( ! array_key_exists('default', $this->_page_routes)) {
737
+			// user error msg
738
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739
+			// developer error msg
740
+			$error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741
+			throw new EE_Error($error_msg);
742
+		}
743
+		//first lets' catch if the UI request has EVER been set.
744
+		if ($this->_is_UI_request === null) {
745
+			//lets set if this is a UI request or not.
746
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
747
+			//wait a minute... we might have a noheader in the route array
748
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
749
+		}
750
+		$this->_set_current_labels();
751
+	}
752
+
753
+
754
+
755
+	/**
756
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
757
+	 *
758
+	 * @param  string $route the route name we're verifying
759
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
+	 */
761
+	protected function _verify_route($route)
762
+	{
763
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
764
+			return true;
765
+		} else {
766
+			// user error msg
767
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768
+			// developer error msg
769
+			$error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770
+			throw new EE_Error($error_msg);
771
+		}
772
+	}
773
+
774
+
775
+
776
+	/**
777
+	 * perform nonce verification
778
+	 * This method has be encapsulated here so that any ajax requests that bypass normal routes can verify their nonces using this method (and save retyping!)
779
+	 *
780
+	 * @param  string $nonce     The nonce sent
781
+	 * @param  string $nonce_ref The nonce reference string (name0)
782
+	 * @return mixed (bool|die)
783
+	 */
784
+	protected function _verify_nonce($nonce, $nonce_ref)
785
+	{
786
+		// verify nonce against expected value
787
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
788
+			// these are not the droids you are looking for !!!
789
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790
+			if (WP_DEBUG) {
791
+				$msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792
+			}
793
+			if ( ! defined('DOING_AJAX')) {
794
+				wp_die($msg);
795
+			} else {
796
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
797
+				$this->_return_json();
798
+			}
799
+		}
800
+	}
801
+
802
+
803
+
804
+	/**
805
+	 * _route_admin_request()
806
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
807
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
808
+	 * in the page routes and then will try to load the corresponding method.
809
+	 *
810
+	 * @access protected
811
+	 * @return void
812
+	 * @throws \EE_Error
813
+	 */
814
+	protected function _route_admin_request()
815
+	{
816
+		if ( ! $this->_is_UI_request) {
817
+			$this->_verify_routes();
818
+		}
819
+		$nonce_check = isset($this->_route_config['require_nonce'])
820
+			? $this->_route_config['require_nonce']
821
+			: true;
822
+		if ($this->_req_action !== 'default' && $nonce_check) {
823
+			// set nonce from post data
824
+			$nonce = isset($this->_req_data[$this->_req_nonce])
825
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
826
+				: '';
827
+			$this->_verify_nonce($nonce, $this->_req_nonce);
828
+		}
829
+		//set the nav_tabs array but ONLY if this is  UI_request
830
+		if ($this->_is_UI_request) {
831
+			$this->_set_nav_tabs();
832
+		}
833
+		// grab callback function
834
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
835
+		// check if callback has args
836
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
837
+		$error_msg = '';
838
+		// action right before calling route
839
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
840
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
841
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
842
+		}
843
+		// right before calling the route, let's remove _wp_http_referer from the
844
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
845
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
846
+		if ( ! empty($func)) {
847
+			if (is_array($func)) {
848
+				list($class, $method) = $func;
849
+			} else if (strpos($func, '::') !== false) {
850
+				list($class, $method) = explode('::', $func);
851
+			} else {
852
+				$class = $this;
853
+				$method = $func;
854
+			}
855
+			if ( ! (is_object($class) && $class === $this)) {
856
+				// send along this admin page object for access by addons.
857
+				$args['admin_page_object'] = $this;
858
+			}
859
+			if (
860
+				//is it a method on a class that doesn't work?
861
+				(
862
+					method_exists($class, $method)
863
+					&& call_user_func_array(array($class, $method), $args) === false
864
+				)
865
+				|| (
866
+					//is it a standalone function that doesn't work?
867
+					function_exists($method)
868
+					&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
869
+				)
870
+				|| (
871
+					//is it neither a class method NOR a standalone function?
872
+					! method_exists($class, $method)
873
+					&& ! function_exists($method)
874
+				)
875
+			) {
876
+				// user error msg
877
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
878
+				// developer error msg
879
+				$error_msg .= '||';
880
+				$error_msg .= sprintf(
881
+					__(
882
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
883
+						'event_espresso'
884
+					),
885
+					$method
886
+				);
887
+			}
888
+			if ( ! empty($error_msg)) {
889
+				throw new EE_Error($error_msg);
890
+			}
891
+		}
892
+		//if we've routed and this route has a no headers route AND a sent_headers_route, then we need to reset the routing properties to the new route.
893
+		//now if UI request is FALSE and noheader is true AND we have a headers_sent_route in the route array then let's set UI_request to true because the no header route has a second func after headers have been sent.
894
+		if ($this->_is_UI_request === false
895
+			&& is_array($this->_route)
896
+			&& ! empty($this->_route['headers_sent_route'])
897
+		) {
898
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
899
+		}
900
+	}
901
+
902
+
903
+
904
+	/**
905
+	 * This method just allows the resetting of page properties in the case where a no headers
906
+	 * route redirects to a headers route in its route config.
907
+	 *
908
+	 * @since   4.3.0
909
+	 * @param  string $new_route New (non header) route to redirect to.
910
+	 * @return   void
911
+	 */
912
+	protected function _reset_routing_properties($new_route)
913
+	{
914
+		$this->_is_UI_request = true;
915
+		//now we set the current route to whatever the headers_sent_route is set at
916
+		$this->_req_data['action'] = $new_route;
917
+		//rerun page setup
918
+		$this->_page_setup();
919
+	}
920
+
921
+
922
+
923
+	/**
924
+	 * _add_query_arg
925
+	 * adds nonce to array of arguments then calls WP add_query_arg function
926
+	 *(internally just uses EEH_URL's function with the same name)
927
+	 *
928
+	 * @access public
929
+	 * @param array  $args
930
+	 * @param string $url
931
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
932
+	 *                                        url in an associative array indexed by the key 'wp_referer';
933
+	 *                                        Example usage:
934
+	 *                                        If the current page is:
935
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
936
+	 *                                        &action=default&event_id=20&month_range=March%202015
937
+	 *                                        &_wpnonce=5467821
938
+	 *                                        and you call:
939
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
940
+	 *                                        array(
941
+	 *                                        'action' => 'resend_something',
942
+	 *                                        'page=>espresso_registrations'
943
+	 *                                        ),
944
+	 *                                        $some_url,
945
+	 *                                        true
946
+	 *                                        );
947
+	 *                                        It will produce a url in this structure:
948
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
949
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
950
+	 *                                        month_range]=March%202015
951
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
952
+	 * @return string
953
+	 */
954
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
955
+	{
956
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
957
+		if ($sticky) {
958
+			$request = $_REQUEST;
959
+			unset($request['_wp_http_referer']);
960
+			unset($request['wp_referer']);
961
+			foreach ($request as $key => $value) {
962
+				//do not add nonces
963
+				if (strpos($key, 'nonce') !== false) {
964
+					continue;
965
+				}
966
+				$args['wp_referer[' . $key . ']'] = $value;
967
+			}
968
+		}
969
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
970
+	}
971
+
972
+
973
+
974
+	/**
975
+	 * This returns a generated link that will load the related help tab.
976
+	 *
977
+	 * @param  string $help_tab_id the id for the connected help tab
978
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
979
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
980
+	 * @uses EEH_Template::get_help_tab_link()
981
+	 * @return string              generated link
982
+	 */
983
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
984
+	{
985
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
986
+	}
987
+
988
+
989
+
990
+	/**
991
+	 * _add_help_tabs
992
+	 * Note child classes define their help tabs within the page_config array.
993
+	 *
994
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
995
+	 * @access protected
996
+	 * @return void
997
+	 */
998
+	protected function _add_help_tabs()
999
+	{
1000
+		$tour_buttons = '';
1001
+		if (isset($this->_page_config[$this->_req_action])) {
1002
+			$config = $this->_page_config[$this->_req_action];
1003
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1004
+			if (isset($this->_help_tour[$this->_req_action])) {
1005
+				$tb = array();
1006
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1007
+				foreach ($this->_help_tour['tours'] as $tour) {
1008
+					//if this is the end tour then we don't need to setup a button
1009
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1010
+						continue;
1011
+					}
1012
+					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1013
+				}
1014
+				$tour_buttons .= implode('<br />', $tb);
1015
+				$tour_buttons .= '</div></div>';
1016
+			}
1017
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1018
+			if (is_array($config) && isset($config['help_sidebar'])) {
1019
+				//check that the callback given is valid
1020
+				if ( ! method_exists($this, $config['help_sidebar'])) {
1021
+					throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1022
+							'event_espresso'), $config['help_sidebar'], get_class($this)));
1023
+				}
1024
+				$content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025
+				$content .= $tour_buttons; //add help tour buttons.
1026
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1027
+				$this->_current_screen->set_help_sidebar($content);
1028
+			}
1029
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1030
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1031
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1032
+			}
1033
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1034
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035
+				$_ht['id'] = $this->page_slug;
1036
+				$_ht['title'] = __('Help Tours', 'event_espresso');
1037
+				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1038
+				$this->_current_screen->add_help_tab($_ht);
1039
+			}/**/
1040
+			if ( ! isset($config['help_tabs'])) {
1041
+				return;
1042
+			} //no help tabs for this route
1043
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1044
+				//we're here so there ARE help tabs!
1045
+				//make sure we've got what we need
1046
+				if ( ! isset($cfg['title'])) {
1047
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1048
+				}
1049
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1050
+					throw new EE_Error(__('The _page_config array is not setup properly for help tabs. It is missing a either a filename reference, or a callback reference or a content reference so there is no way to know the content for the help tab',
1051
+							'event_espresso'));
1052
+				}
1053
+				//first priority goes to content.
1054
+				if ( ! empty($cfg['content'])) {
1055
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056
+					//second priority goes to filename
1057
+				} else if ( ! empty($cfg['filename'])) {
1058
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1059
+					//it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1060
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1061
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063
+						EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
1064
+								'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1065
+						return;
1066
+					}
1067
+					$template_args['admin_page_obj'] = $this;
1068
+					$content = EEH_Template::display_template($file_path, $template_args, true);
1069
+				} else {
1070
+					$content = '';
1071
+				}
1072
+				//check if callback is valid
1073
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1074
+					EE_Error::add_error(sprintf(__('The callback given for a %s help tab on this page does not content OR a corresponding method for generating the content.  Check the spelling or make sure the method is present.',
1075
+							'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1076
+					return;
1077
+				}
1078
+				//setup config array for help tab method
1079
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1080
+				$_ht = array(
1081
+						'id'       => $id,
1082
+						'title'    => $cfg['title'],
1083
+						'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1084
+						'content'  => $content,
1085
+				);
1086
+				$this->_current_screen->add_help_tab($_ht);
1087
+			}
1088
+		}
1089
+	}
1090
+
1091
+
1092
+
1093
+	/**
1094
+	 * This basically checks loaded $_page_config property to see if there are any help_tours defined.  "help_tours" is an array with properties for setting up usage of the joyride plugin
1095
+	 *
1096
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1097
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1098
+	 * @access protected
1099
+	 * @return void
1100
+	 */
1101
+	protected function _add_help_tour()
1102
+	{
1103
+		$tours = array();
1104
+		$this->_help_tour = array();
1105
+		//exit early if help tours are turned off globally
1106
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1107
+			return;
1108
+		}
1109
+		//loop through _page_config to find any help_tour defined
1110
+		foreach ($this->_page_config as $route => $config) {
1111
+			//we're only going to set things up for this route
1112
+			if ($route !== $this->_req_action) {
1113
+				continue;
1114
+			}
1115
+			if (isset($config['help_tour'])) {
1116
+				foreach ($config['help_tour'] as $tour) {
1117
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1118
+					//let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1119
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1120
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121
+					if ( ! is_readable($file_path)) {
1122
+						EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
1123
+								$file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1124
+						return;
1125
+					}
1126
+					require_once $file_path;
1127
+					if ( ! class_exists($tour)) {
1128
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
+						$error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1130
+										'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131
+						throw new EE_Error(implode('||', $error_msg));
1132
+					}
1133
+					$a = new ReflectionClass($tour);
1134
+					$tour_obj = $a->newInstance($this->_is_caf);
1135
+					$tours[] = $tour_obj;
1136
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1137
+				}
1138
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1139
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1140
+				$tours[] = $end_stop_tour;
1141
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1142
+			}
1143
+		}
1144
+		if ( ! empty($tours)) {
1145
+			$this->_help_tour['tours'] = $tours;
1146
+		}
1147
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1148
+	}
1149
+
1150
+
1151
+
1152
+	/**
1153
+	 * This simply sets up any qtips that have been defined in the page config
1154
+	 *
1155
+	 * @access protected
1156
+	 * @return void
1157
+	 */
1158
+	protected function _add_qtips()
1159
+	{
1160
+		if (isset($this->_route_config['qtips'])) {
1161
+			$qtips = (array)$this->_route_config['qtips'];
1162
+			//load qtip loader
1163
+			$path = array(
1164
+					$this->_get_dir() . '/qtips/',
1165
+					EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1166
+			);
1167
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1168
+		}
1169
+	}
1170
+
1171
+
1172
+
1173
+	/**
1174
+	 * _set_nav_tabs
1175
+	 * This sets up the nav tabs from the page_routes array.  This method can be overwritten by child classes if you wish to add additional tabs or modify accordingly.
1176
+	 *
1177
+	 * @access protected
1178
+	 * @return void
1179
+	 */
1180
+	protected function _set_nav_tabs()
1181
+	{
1182
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1183
+		$i = 0;
1184
+		foreach ($this->_page_config as $slug => $config) {
1185
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1186
+				continue;
1187
+			} //no nav tab for this config
1188
+			//check for persistent flag
1189
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1190
+				continue;
1191
+			} //nav tab is only to appear when route requested.
1192
+			if ( ! $this->check_user_access($slug, true)) {
1193
+				continue;
1194
+			} //no nav tab becasue current user does not have access.
1195
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1196
+			$this->_nav_tabs[$slug] = array(
1197
+					'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198
+					'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
+					'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1200
+					'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201
+			);
1202
+			$i++;
1203
+		}
1204
+		//if $this->_nav_tabs is empty then lets set the default
1205
+		if (empty($this->_nav_tabs)) {
1206
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1207
+					'url'       => $this->admin_base_url,
1208
+					'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1209
+					'css_class' => 'nav-tab-active',
1210
+					'order'     => 10,
1211
+			);
1212
+		}
1213
+		//now let's sort the tabs according to order
1214
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1215
+	}
1216
+
1217
+
1218
+
1219
+	/**
1220
+	 * _set_current_labels
1221
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1222
+	 *
1223
+	 * @access private
1224
+	 * @return void
1225
+	 */
1226
+	private function _set_current_labels()
1227
+	{
1228
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1229
+			foreach ($this->_route_config['labels'] as $label => $text) {
1230
+				if (is_array($text)) {
1231
+					foreach ($text as $sublabel => $subtext) {
1232
+						$this->_labels[$label][$sublabel] = $subtext;
1233
+					}
1234
+				} else {
1235
+					$this->_labels[$label] = $text;
1236
+				}
1237
+			}
1238
+		}
1239
+	}
1240
+
1241
+
1242
+
1243
+	/**
1244
+	 *        verifies user access for this admin page
1245
+	 *
1246
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1247
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1248
+	 * @return        BOOL|wp_die()
1249
+	 */
1250
+	public function check_user_access($route_to_check = '', $verify_only = false)
1251
+	{
1252
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1253
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1254
+		$capability = ! empty($route_to_check) && isset($this->_page_routes[$route_to_check]) && is_array($this->_page_routes[$route_to_check]) && ! empty($this->_page_routes[$route_to_check]['capability'])
1255
+				? $this->_page_routes[$route_to_check]['capability'] : null;
1256
+		if (empty($capability) && empty($route_to_check)) {
1257
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1258
+		} else {
1259
+			$capability = empty($capability) ? 'manage_options' : $capability;
1260
+		}
1261
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263
+			if ($verify_only) {
1264
+				return false;
1265
+			} else {
1266
+				wp_die(__('You do not have access to this route.', 'event_espresso'));
1267
+			}
1268
+		}
1269
+		return true;
1270
+	}
1271
+
1272
+
1273
+
1274
+	/**
1275
+	 * admin_init_global
1276
+	 * This runs all the code that we want executed within the WP admin_init hook.
1277
+	 * This method executes for ALL EE Admin pages.
1278
+	 *
1279
+	 * @access public
1280
+	 * @return void
1281
+	 */
1282
+	public function admin_init_global()
1283
+	{
1284
+	}
1285
+
1286
+
1287
+
1288
+	/**
1289
+	 * wp_loaded_global
1290
+	 * This runs all the code that we want executed within the WP wp_loaded hook.  This method is optional for an EE_Admin page and will execute on every EE Admin Page load
1291
+	 *
1292
+	 * @access public
1293
+	 * @return void
1294
+	 */
1295
+	public function wp_loaded()
1296
+	{
1297
+	}
1298
+
1299
+
1300
+
1301
+	/**
1302
+	 * admin_notices
1303
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1304
+	 *
1305
+	 * @access public
1306
+	 * @return void
1307
+	 */
1308
+	public function admin_notices_global()
1309
+	{
1310
+		$this->_display_no_javascript_warning();
1311
+		$this->_display_espresso_notices();
1312
+	}
1313
+
1314
+
1315
+
1316
+	public function network_admin_notices_global()
1317
+	{
1318
+		$this->_display_no_javascript_warning();
1319
+		$this->_display_espresso_notices();
1320
+	}
1321
+
1322
+
1323
+
1324
+	/**
1325
+	 * admin_footer_scripts_global
1326
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method will apply on ALL EE_Admin pages.
1327
+	 *
1328
+	 * @access public
1329
+	 * @return void
1330
+	 */
1331
+	public function admin_footer_scripts_global()
1332
+	{
1333
+		$this->_add_admin_page_ajax_loading_img();
1334
+		$this->_add_admin_page_overlay();
1335
+		//if metaboxes are present we need to add the nonce field
1336
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1337
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1338
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1339
+		}
1340
+	}
1341
+
1342
+
1343
+
1344
+	/**
1345
+	 * admin_footer_global
1346
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1347
+	 *
1348
+	 * @access  public
1349
+	 * @return  void
1350
+	 */
1351
+	public function admin_footer_global()
1352
+	{
1353
+		//dialog container for dialog helper
1354
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1355
+		$d_cont .= '<div class="ee-notices"></div>';
1356
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1357
+		$d_cont .= '</div>';
1358
+		echo $d_cont;
1359
+		//help tour stuff?
1360
+		if (isset($this->_help_tour[$this->_req_action])) {
1361
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1362
+		}
1363
+		//current set timezone for timezone js
1364
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1365
+	}
1366
+
1367
+
1368
+
1369
+	/**
1370
+	 * This function sees if there is a method for help popup content existing for the given route.  If there is then we'll use the retrieved array to output the content using the template.
1371
+	 * For child classes:
1372
+	 * If you want to have help popups then in your templates or your content you set "triggers" for the content using the "_set_help_trigger('help_trigger_id')" where "help_trigger_id" is what you will use later in your custom method for
1373
+	 * the help popup content on that page. Then in your Child_Admin_Page class you need to define a help popup method for the content in the format "_help_popup_content_{route_name}()"  So if you are setting help content for the
1374
+	 * 'edit_event' route you should have a method named "_help_popup_content_edit_route". In your defined "help_popup_content_..." method.  You must prepare and return an array in the following format array(
1375
+	 *    'help_trigger_id' => array(
1376
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1377
+	 *        'content' => __('localized content for popup', 'event_espresso')
1378
+	 *    )
1379
+	 * );
1380
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1381
+	 *
1382
+	 * @access protected
1383
+	 * @return string content
1384
+	 */
1385
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1386
+	{
1387
+		$content = '';
1388
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1389
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1390
+		//loop through the array and setup content
1391
+		foreach ($help_array as $trigger => $help) {
1392
+			//make sure the array is setup properly
1393
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1394
+				throw new EE_Error(__('Does not look like the popup content array has been setup correctly.  Might want to double check that.  Read the comments for the _get_help_popup_content method found in "EE_Admin_Page" class',
1395
+						'event_espresso'));
1396
+			}
1397
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1398
+			$template_args = array(
1399
+					'help_popup_id'      => $trigger,
1400
+					'help_popup_title'   => $help['title'],
1401
+					'help_popup_content' => $help['content'],
1402
+			);
1403
+			$content .= EEH_Template::display_template($template_path, $template_args, true);
1404
+		}
1405
+		if ($display) {
1406
+			echo $content;
1407
+		} else {
1408
+			return $content;
1409
+		}
1410
+	}
1411
+
1412
+
1413
+
1414
+	/**
1415
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1416
+	 *
1417
+	 * @access private
1418
+	 * @return array properly formatted array for help popup content
1419
+	 */
1420
+	private function _get_help_content()
1421
+	{
1422
+		//what is the method we're looking for?
1423
+		$method_name = '_help_popup_content_' . $this->_req_action;
1424
+		//if method doesn't exist let's get out.
1425
+		if ( ! method_exists($this, $method_name)) {
1426
+			return array();
1427
+		}
1428
+		//k we're good to go let's retrieve the help array
1429
+		$help_array = call_user_func(array($this, $method_name));
1430
+		//make sure we've got an array!
1431
+		if ( ! is_array($help_array)) {
1432
+			throw new EE_Error(__('Something went wrong with help popup content generation. Expecting an array and well, this ain\'t no array bub.', 'event_espresso'));
1433
+		}
1434
+		return $help_array;
1435
+	}
1436
+
1437
+
1438
+
1439
+	/**
1440
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1441
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1442
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1443
+	 *
1444
+	 * @access protected
1445
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1446
+	 * @param boolean $display    if false then we return the trigger string
1447
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1448
+	 * @return string
1449
+	 */
1450
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1451
+	{
1452
+		if (defined('DOING_AJAX')) {
1453
+			return;
1454
+		}
1455
+		//let's check and see if there is any content set for this popup.  If there isn't then we'll include a default title and content so that developers know something needs to be corrected
1456
+		$help_array = $this->_get_help_content();
1457
+		$help_content = '';
1458
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1459
+			$help_array[$trigger_id] = array(
1460
+					'title'   => __('Missing Content', 'event_espresso'),
1461
+					'content' => __('A trigger has been set that doesn\'t have any corresponding content. Make sure you have set the help content. (see the "_set_help_popup_content" method in the EE_Admin_Page for instructions.)',
1462
+							'event_espresso'),
1463
+			);
1464
+			$help_content = $this->_set_help_popup_content($help_array, false);
1465
+		}
1466
+		//let's setup the trigger
1467
+		$content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
+		$content = $content . $help_content;
1469
+		if ($display) {
1470
+			echo $content;
1471
+		} else {
1472
+			return $content;
1473
+		}
1474
+	}
1475
+
1476
+
1477
+
1478
+	/**
1479
+	 * _add_global_screen_options
1480
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1481
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1482
+	 *
1483
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1484
+	 *         see also WP_Screen object documents...
1485
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1486
+	 * @abstract
1487
+	 * @access private
1488
+	 * @return void
1489
+	 */
1490
+	private function _add_global_screen_options()
1491
+	{
1492
+	}
1493
+
1494
+
1495
+
1496
+	/**
1497
+	 * _add_global_feature_pointers
1498
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1499
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1500
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1501
+	 *
1502
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1503
+	 * @link   http://eamann.com/tech/wordpress-portland/
1504
+	 * @abstract
1505
+	 * @access protected
1506
+	 * @return void
1507
+	 */
1508
+	private function _add_global_feature_pointers()
1509
+	{
1510
+	}
1511
+
1512
+
1513
+
1514
+	/**
1515
+	 * load_global_scripts_styles
1516
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1517
+	 *
1518
+	 * @return void
1519
+	 */
1520
+	public function load_global_scripts_styles()
1521
+	{
1522
+		/** STYLES **/
1523
+		// add debugging styles
1524
+		if (WP_DEBUG) {
1525
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1526
+		}
1527
+		//register all styles
1528
+		wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1530
+		//helpers styles
1531
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1532
+		//enqueue global styles
1533
+		wp_enqueue_style('ee-admin-css');
1534
+		/** SCRIPTS **/
1535
+		//register all scripts
1536
+		wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
+		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
+		wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
+		wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540
+		// register jQuery Validate - see /includes/functions/wp_hooks.php
1541
+		add_filter('FHEE_load_jquery_validate', '__return_true');
1542
+		add_filter('FHEE_load_joyride', '__return_true');
1543
+		//script for sorting tables
1544
+		wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1545
+		//script for parsing uri's
1546
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1547
+		//and parsing associative serialized form elements
1548
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1549
+		//helpers scripts
1550
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
+		wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554
+		//google charts
1555
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1556
+		//enqueue global scripts
1557
+		//taking care of metaboxes
1558
+		if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1559
+			wp_enqueue_script('dashboard');
1560
+		}
1561
+		//enqueue thickbox for ee help popups.  default is to enqueue unless its explicitly set to false since we're assuming all EE pages will have popups
1562
+		if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1563
+			wp_enqueue_script('ee_admin_js');
1564
+			wp_enqueue_style('ee-admin-css');
1565
+		}
1566
+		//localize script for ajax lazy loading
1567
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1568
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1569
+		/**
1570
+		 * help tour stuff
1571
+		 */
1572
+		if ( ! empty($this->_help_tour)) {
1573
+			//register the js for kicking things off
1574
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1575
+			//setup tours for the js tour object
1576
+			foreach ($this->_help_tour['tours'] as $tour) {
1577
+				$tours[] = array(
1578
+						'id'      => $tour->get_slug(),
1579
+						'options' => $tour->get_options(),
1580
+				);
1581
+			}
1582
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1583
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1584
+		}
1585
+	}
1586
+
1587
+
1588
+
1589
+	/**
1590
+	 *        admin_footer_scripts_eei18n_js_strings
1591
+	 *
1592
+	 * @access        public
1593
+	 * @return        void
1594
+	 */
1595
+	public function admin_footer_scripts_eei18n_js_strings()
1596
+	{
1597
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1598
+		EE_Registry::$i18n_js_strings['confirm_delete'] = __('Are you absolutely sure you want to delete this item?\nThis action will delete ALL DATA associated with this item!!!\nThis can NOT be undone!!!', 'event_espresso');
1599
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1600
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1601
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1602
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1603
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1604
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1605
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1606
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1607
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1608
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1609
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1610
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1611
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1612
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1613
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1614
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1615
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1616
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1617
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1618
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1619
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1620
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1621
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1622
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1623
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1624
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1625
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1626
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1627
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1628
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1629
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1630
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1631
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1632
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1633
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1634
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1635
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1636
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1637
+		//setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1638
+		//admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1639
+		//espresso_core is listed as a dependency of ee_admin_js.
1640
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1641
+	}
1642
+
1643
+
1644
+
1645
+	/**
1646
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1647
+	 *
1648
+	 * @access        public
1649
+	 * @return        void
1650
+	 */
1651
+	public function add_xdebug_style()
1652
+	{
1653
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1654
+	}
1655
+
1656
+
1657
+	/************************/
1658
+	/** LIST TABLE METHODS **/
1659
+	/************************/
1660
+	/**
1661
+	 * this sets up the list table if the current view requires it.
1662
+	 *
1663
+	 * @access protected
1664
+	 * @return void
1665
+	 */
1666
+	protected function _set_list_table()
1667
+	{
1668
+		//first is this a list_table view?
1669
+		if ( ! isset($this->_route_config['list_table'])) {
1670
+			return;
1671
+		} //not a list_table view so get out.
1672
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1673
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1674
+			//user error msg
1675
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1676
+			//developer error msg
1677
+			$error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1678
+							$this->_req_action, '_set_list_table_views_' . $this->_req_action);
1679
+			throw new EE_Error($error_msg);
1680
+		}
1681
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1682
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1683
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1684
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1685
+		$this->_set_list_table_view();
1686
+		$this->_set_list_table_object();
1687
+	}
1688
+
1689
+
1690
+
1691
+	/**
1692
+	 *        set current view for List Table
1693
+	 *
1694
+	 * @access public
1695
+	 * @return array
1696
+	 */
1697
+	protected function _set_list_table_view()
1698
+	{
1699
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1700
+		// looking at active items or dumpster diving ?
1701
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1702
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1703
+		} else {
1704
+			$this->_view = sanitize_key($this->_req_data['status']);
1705
+		}
1706
+	}
1707
+
1708
+
1709
+
1710
+	/**
1711
+	 * _set_list_table_object
1712
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1713
+	 *
1714
+	 * @throws \EE_Error
1715
+	 */
1716
+	protected function _set_list_table_object()
1717
+	{
1718
+		if (isset($this->_route_config['list_table'])) {
1719
+			if ( ! class_exists($this->_route_config['list_table'])) {
1720
+				throw new EE_Error(
1721
+						sprintf(
1722
+								__(
1723
+										'The %s class defined for the list table does not exist.  Please check the spelling of the class ref in the $_page_config property on %s.',
1724
+										'event_espresso'
1725
+								),
1726
+								$this->_route_config['list_table'],
1727
+								get_class($this)
1728
+						)
1729
+				);
1730
+			}
1731
+			$list_table = $this->_route_config['list_table'];
1732
+			$this->_list_table_object = new $list_table($this);
1733
+		}
1734
+	}
1735
+
1736
+
1737
+
1738
+	/**
1739
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1740
+	 *
1741
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1742
+	 *                                                    urls.  The array should be indexed by the view it is being
1743
+	 *                                                    added to.
1744
+	 * @return array
1745
+	 */
1746
+	public function get_list_table_view_RLs($extra_query_args = array())
1747
+	{
1748
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1749
+		if (empty($this->_views)) {
1750
+			$this->_views = array();
1751
+		}
1752
+		// cycle thru views
1753
+		foreach ($this->_views as $key => $view) {
1754
+			$query_args = array();
1755
+			// check for current view
1756
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1757
+			$query_args['action'] = $this->_req_action;
1758
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1759
+			$query_args['status'] = $view['slug'];
1760
+			//merge any other arguments sent in.
1761
+			if (isset($extra_query_args[$view['slug']])) {
1762
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1763
+			}
1764
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1765
+		}
1766
+		return $this->_views;
1767
+	}
1768
+
1769
+
1770
+
1771
+	/**
1772
+	 * _entries_per_page_dropdown
1773
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
1774
+	 *
1775
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1776
+	 * @access protected
1777
+	 * @param int $max_entries total number of rows in the table
1778
+	 * @return string
1779
+	 */
1780
+	protected function _entries_per_page_dropdown($max_entries = false)
1781
+	{
1782
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1783
+		$values = array(10, 25, 50, 100);
1784
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1785
+		if ($max_entries) {
1786
+			$values[] = $max_entries;
1787
+			sort($values);
1788
+		}
1789
+		$entries_per_page_dropdown = '
1790 1790
 			<div id="entries-per-page-dv" class="alignleft actions">
1791 1791
 				<label class="hide-if-no-js">
1792 1792
 					Show
1793 1793
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1794
-        foreach ($values as $value) {
1795
-            if ($value < $max_entries) {
1796
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1797
-                $entries_per_page_dropdown .= '
1794
+		foreach ($values as $value) {
1795
+			if ($value < $max_entries) {
1796
+				$selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1797
+				$entries_per_page_dropdown .= '
1798 1798
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1799
-            }
1800
-        }
1801
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1802
-        $entries_per_page_dropdown .= '
1799
+			}
1800
+		}
1801
+		$selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1802
+		$entries_per_page_dropdown .= '
1803 1803
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1804
-        $entries_per_page_dropdown .= '
1804
+		$entries_per_page_dropdown .= '
1805 1805
 					</select>
1806 1806
 					entries
1807 1807
 				</label>
1808 1808
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
1809 1809
 			</div>
1810 1810
 		';
1811
-        return $entries_per_page_dropdown;
1812
-    }
1813
-
1814
-
1815
-
1816
-    /**
1817
-     *        _set_search_attributes
1818
-     *
1819
-     * @access        protected
1820
-     * @return        void
1821
-     */
1822
-    public function _set_search_attributes()
1823
-    {
1824
-        $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1825
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1826
-    }
1827
-
1828
-    /*** END LIST TABLE METHODS **/
1829
-    /*****************************/
1830
-    /**
1831
-     *        _add_registered_metaboxes
1832
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1833
-     *
1834
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1835
-     * @access private
1836
-     * @return void
1837
-     */
1838
-    private function _add_registered_meta_boxes()
1839
-    {
1840
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1841
-        //we only add meta boxes if the page_route calls for it
1842
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1843
-            && is_array(
1844
-                    $this->_route_config['metaboxes']
1845
-            )
1846
-        ) {
1847
-            // this simply loops through the callbacks provided
1848
-            // and checks if there is a corresponding callback registered by the child
1849
-            // if there is then we go ahead and process the metabox loader.
1850
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1851
-                // first check for Closures
1852
-                if ($metabox_callback instanceof Closure) {
1853
-                    $result = $metabox_callback();
1854
-                } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1855
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1856
-                } else {
1857
-                    $result = call_user_func(array($this, &$metabox_callback));
1858
-                }
1859
-                if ($result === false) {
1860
-                    // user error msg
1861
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1862
-                    // developer error msg
1863
-                    $error_msg .= '||' . sprintf(
1864
-                                    __(
1865
-                                            'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1866
-                                            'event_espresso'
1867
-                                    ),
1868
-                                    $metabox_callback
1869
-                            );
1870
-                    throw new EE_Error($error_msg);
1871
-                }
1872
-            }
1873
-        }
1874
-    }
1875
-
1876
-
1877
-
1878
-    /**
1879
-     * _add_screen_columns
1880
-     * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1881
-     *
1882
-     * @access private
1883
-     * @return void
1884
-     */
1885
-    private function _add_screen_columns()
1886
-    {
1887
-        if (
1888
-                is_array($this->_route_config)
1889
-                && isset($this->_route_config['columns'])
1890
-                && is_array($this->_route_config['columns'])
1891
-                && count($this->_route_config['columns']) === 2
1892
-        ) {
1893
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1894
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1895
-            $screen_id = $this->_current_screen->id;
1896
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1897
-            $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1898
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1899
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
1900
-            $this->_template_args['screen'] = $this->_current_screen;
1901
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1902
-            //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1903
-            $this->_route_config['has_metaboxes'] = true;
1904
-        }
1905
-    }
1906
-
1907
-
1908
-
1909
-    /**********************************/
1910
-    /** GLOBALLY AVAILABLE METABOXES **/
1911
-    /**
1912
-     * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1913
-     * loaded on.
1914
-     */
1915
-    private function _espresso_news_post_box()
1916
-    {
1917
-        $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1918
-        add_meta_box('espresso_news_post_box', $news_box_title, array(
1919
-                $this,
1920
-                'espresso_news_post_box',
1921
-        ), $this->_wp_page_slug, 'side');
1922
-    }
1923
-
1924
-
1925
-
1926
-    /**
1927
-     * Code for setting up espresso ratings request metabox.
1928
-     */
1929
-    protected function _espresso_ratings_request()
1930
-    {
1931
-        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1932
-            return '';
1933
-        }
1934
-        $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1935
-        add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1936
-                $this,
1937
-                'espresso_ratings_request',
1938
-        ), $this->_wp_page_slug, 'side');
1939
-    }
1940
-
1941
-
1942
-
1943
-    /**
1944
-     * Code for setting up espresso ratings request metabox content.
1945
-     */
1946
-    public function espresso_ratings_request()
1947
-    {
1948
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1949
-        EEH_Template::display_template($template_path, array());
1950
-    }
1951
-
1952
-
1953
-
1954
-    public static function cached_rss_display($rss_id, $url)
1955
-    {
1956
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1957
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1958
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1959
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1960
-        $post = '</div>' . "\n";
1961
-        $cache_key = 'ee_rss_' . md5($rss_id);
1962
-        if (false != ($output = get_transient($cache_key))) {
1963
-            echo $pre . $output . $post;
1964
-            return true;
1965
-        }
1966
-        if ( ! $doing_ajax) {
1967
-            echo $pre . $loading . $post;
1968
-            return false;
1969
-        }
1970
-        ob_start();
1971
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1972
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1973
-        return true;
1974
-    }
1975
-
1976
-
1977
-
1978
-    public function espresso_news_post_box()
1979
-    {
1980
-        ?>
1811
+		return $entries_per_page_dropdown;
1812
+	}
1813
+
1814
+
1815
+
1816
+	/**
1817
+	 *        _set_search_attributes
1818
+	 *
1819
+	 * @access        protected
1820
+	 * @return        void
1821
+	 */
1822
+	public function _set_search_attributes()
1823
+	{
1824
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1825
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1826
+	}
1827
+
1828
+	/*** END LIST TABLE METHODS **/
1829
+	/*****************************/
1830
+	/**
1831
+	 *        _add_registered_metaboxes
1832
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1833
+	 *
1834
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1835
+	 * @access private
1836
+	 * @return void
1837
+	 */
1838
+	private function _add_registered_meta_boxes()
1839
+	{
1840
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1841
+		//we only add meta boxes if the page_route calls for it
1842
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1843
+			&& is_array(
1844
+					$this->_route_config['metaboxes']
1845
+			)
1846
+		) {
1847
+			// this simply loops through the callbacks provided
1848
+			// and checks if there is a corresponding callback registered by the child
1849
+			// if there is then we go ahead and process the metabox loader.
1850
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1851
+				// first check for Closures
1852
+				if ($metabox_callback instanceof Closure) {
1853
+					$result = $metabox_callback();
1854
+				} else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1855
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1856
+				} else {
1857
+					$result = call_user_func(array($this, &$metabox_callback));
1858
+				}
1859
+				if ($result === false) {
1860
+					// user error msg
1861
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1862
+					// developer error msg
1863
+					$error_msg .= '||' . sprintf(
1864
+									__(
1865
+											'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1866
+											'event_espresso'
1867
+									),
1868
+									$metabox_callback
1869
+							);
1870
+					throw new EE_Error($error_msg);
1871
+				}
1872
+			}
1873
+		}
1874
+	}
1875
+
1876
+
1877
+
1878
+	/**
1879
+	 * _add_screen_columns
1880
+	 * This will check the _page_config array and if there is "columns" key index indicated, we'll set the template as the dynamic column template and we'll setup the column options for the page.
1881
+	 *
1882
+	 * @access private
1883
+	 * @return void
1884
+	 */
1885
+	private function _add_screen_columns()
1886
+	{
1887
+		if (
1888
+				is_array($this->_route_config)
1889
+				&& isset($this->_route_config['columns'])
1890
+				&& is_array($this->_route_config['columns'])
1891
+				&& count($this->_route_config['columns']) === 2
1892
+		) {
1893
+			add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1894
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1895
+			$screen_id = $this->_current_screen->id;
1896
+			$screen_columns = (int)get_user_option("screen_layout_$screen_id");
1897
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1898
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1899
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
1900
+			$this->_template_args['screen'] = $this->_current_screen;
1901
+			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1902
+			//finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1903
+			$this->_route_config['has_metaboxes'] = true;
1904
+		}
1905
+	}
1906
+
1907
+
1908
+
1909
+	/**********************************/
1910
+	/** GLOBALLY AVAILABLE METABOXES **/
1911
+	/**
1912
+	 * In this section we put any globally available EE metaboxes for all EE Admin pages.  They are called by simply referencing the callback in the _page_config array property.  This way you can be very specific about what pages these get
1913
+	 * loaded on.
1914
+	 */
1915
+	private function _espresso_news_post_box()
1916
+	{
1917
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1918
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
1919
+				$this,
1920
+				'espresso_news_post_box',
1921
+		), $this->_wp_page_slug, 'side');
1922
+	}
1923
+
1924
+
1925
+
1926
+	/**
1927
+	 * Code for setting up espresso ratings request metabox.
1928
+	 */
1929
+	protected function _espresso_ratings_request()
1930
+	{
1931
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1932
+			return '';
1933
+		}
1934
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1935
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1936
+				$this,
1937
+				'espresso_ratings_request',
1938
+		), $this->_wp_page_slug, 'side');
1939
+	}
1940
+
1941
+
1942
+
1943
+	/**
1944
+	 * Code for setting up espresso ratings request metabox content.
1945
+	 */
1946
+	public function espresso_ratings_request()
1947
+	{
1948
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1949
+		EEH_Template::display_template($template_path, array());
1950
+	}
1951
+
1952
+
1953
+
1954
+	public static function cached_rss_display($rss_id, $url)
1955
+	{
1956
+		$loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1957
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1958
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
1959
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1960
+		$post = '</div>' . "\n";
1961
+		$cache_key = 'ee_rss_' . md5($rss_id);
1962
+		if (false != ($output = get_transient($cache_key))) {
1963
+			echo $pre . $output . $post;
1964
+			return true;
1965
+		}
1966
+		if ( ! $doing_ajax) {
1967
+			echo $pre . $loading . $post;
1968
+			return false;
1969
+		}
1970
+		ob_start();
1971
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1972
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1973
+		return true;
1974
+	}
1975
+
1976
+
1977
+
1978
+	public function espresso_news_post_box()
1979
+	{
1980
+		?>
1981 1981
         <div class="padding">
1982 1982
             <div id="espresso_news_post_box_content" class="infolinks">
1983 1983
                 <?php
1984
-                // Get RSS Feed(s)
1985
-                $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1986
-                $url = urlencode($feed_url);
1987
-                self::cached_rss_display('espresso_news_post_box_content', $url);
1988
-                ?>
1984
+				// Get RSS Feed(s)
1985
+				$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1986
+				$url = urlencode($feed_url);
1987
+				self::cached_rss_display('espresso_news_post_box_content', $url);
1988
+				?>
1989 1989
             </div>
1990 1990
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
1991 1991
         </div>
1992 1992
         <?php
1993
-    }
1994
-
1995
-
1996
-
1997
-    private function _espresso_links_post_box()
1998
-    {
1999
-        //Hiding until we actually have content to put in here...
2000
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2001
-    }
2002
-
2003
-
2004
-
2005
-    public function espresso_links_post_box()
2006
-    {
2007
-        //Hiding until we actually have content to put in here...
2008
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2009
-        //EEH_Template::display_template( $templatepath );
2010
-    }
2011
-
2012
-
2013
-
2014
-    protected function _espresso_sponsors_post_box()
2015
-    {
2016
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2017
-        if ($show_sponsors) {
2018
-            add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2019
-        }
2020
-    }
2021
-
2022
-
2023
-
2024
-    public function espresso_sponsors_post_box()
2025
-    {
2026
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2027
-        EEH_Template::display_template($templatepath);
2028
-    }
2029
-
2030
-
2031
-
2032
-    private function _publish_post_box()
2033
-    {
2034
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2035
-        //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2036
-        if ( ! empty($this->_labels['publishbox'])) {
2037
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2038
-        } else {
2039
-            $box_label = __('Publish', 'event_espresso');
2040
-        }
2041
-        $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2042
-        add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2043
-    }
2044
-
2045
-
2046
-
2047
-    public function editor_overview()
2048
-    {
2049
-        //if we have extra content set let's add it in if not make sure its empty
2050
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2051
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2052
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2053
-    }
2054
-
2055
-
2056
-    /** end of globally available metaboxes section **/
2057
-    /*************************************************/
2058
-    /**
2059
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2060
-     * protected method.
2061
-     *
2062
-     * @see   $this->_set_publish_post_box_vars for param details
2063
-     * @since 4.6.0
2064
-     */
2065
-    public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2066
-    {
2067
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2068
-    }
2069
-
2070
-
2071
-
2072
-    /**
2073
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2074
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2075
-     * save, and save and close buttons to work properly, then you will want to include a
2076
-     * values for the name and id arguments.
2077
-     *
2078
-     * @todo  Add in validation for name/id arguments.
2079
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2080
-     * @param    int     $id                      id attached to the item published
2081
-     * @param    string  $delete                  page route callback for the delete action
2082
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2083
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2084
-     * @throws \EE_Error
2085
-     */
2086
-    protected function _set_publish_post_box_vars(
2087
-            $name = '',
2088
-            $id = 0,
2089
-            $delete = '',
2090
-            $save_close_redirect_URL = '',
2091
-            $both_btns = true
2092
-    ) {
2093
-        // if Save & Close, use a custom redirect URL or default to the main page?
2094
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2095
-        // create the Save & Close and Save buttons
2096
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2097
-        //if we have extra content set let's add it in if not make sure its empty
2098
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2099
-        if ($delete && ! empty($id)) {
2100
-            //make sure we have a default if just true is sent.
2101
-            $delete = ! empty($delete) ? $delete : 'delete';
2102
-            $delete_link_args = array($name => $id);
2103
-            $delete = $this->get_action_link_or_button(
2104
-                    $delete,
2105
-                    $delete,
2106
-                    $delete_link_args,
2107
-                    'submitdelete deletion',
2108
-                    '',
2109
-                    false
2110
-            );
2111
-        }
2112
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2113
-        if ( ! empty($name) && ! empty($id)) {
2114
-            $hidden_field_arr[$name] = array(
2115
-                    'type'  => 'hidden',
2116
-                    'value' => $id,
2117
-            );
2118
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2119
-        } else {
2120
-            $hf = '';
2121
-        }
2122
-        // add hidden field
2123
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2124
-    }
2125
-
2126
-
2127
-
2128
-    /**
2129
-     *        displays an error message to ppl who have javascript disabled
2130
-     *
2131
-     * @access        private
2132
-     * @return        string
2133
-     */
2134
-    private function _display_no_javascript_warning()
2135
-    {
2136
-        ?>
1993
+	}
1994
+
1995
+
1996
+
1997
+	private function _espresso_links_post_box()
1998
+	{
1999
+		//Hiding until we actually have content to put in here...
2000
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2001
+	}
2002
+
2003
+
2004
+
2005
+	public function espresso_links_post_box()
2006
+	{
2007
+		//Hiding until we actually have content to put in here...
2008
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2009
+		//EEH_Template::display_template( $templatepath );
2010
+	}
2011
+
2012
+
2013
+
2014
+	protected function _espresso_sponsors_post_box()
2015
+	{
2016
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2017
+		if ($show_sponsors) {
2018
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2019
+		}
2020
+	}
2021
+
2022
+
2023
+
2024
+	public function espresso_sponsors_post_box()
2025
+	{
2026
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2027
+		EEH_Template::display_template($templatepath);
2028
+	}
2029
+
2030
+
2031
+
2032
+	private function _publish_post_box()
2033
+	{
2034
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2035
+		//if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2036
+		if ( ! empty($this->_labels['publishbox'])) {
2037
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2038
+		} else {
2039
+			$box_label = __('Publish', 'event_espresso');
2040
+		}
2041
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2042
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2043
+	}
2044
+
2045
+
2046
+
2047
+	public function editor_overview()
2048
+	{
2049
+		//if we have extra content set let's add it in if not make sure its empty
2050
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2051
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2052
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2053
+	}
2054
+
2055
+
2056
+	/** end of globally available metaboxes section **/
2057
+	/*************************************************/
2058
+	/**
2059
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2060
+	 * protected method.
2061
+	 *
2062
+	 * @see   $this->_set_publish_post_box_vars for param details
2063
+	 * @since 4.6.0
2064
+	 */
2065
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2066
+	{
2067
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2068
+	}
2069
+
2070
+
2071
+
2072
+	/**
2073
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2074
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2075
+	 * save, and save and close buttons to work properly, then you will want to include a
2076
+	 * values for the name and id arguments.
2077
+	 *
2078
+	 * @todo  Add in validation for name/id arguments.
2079
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2080
+	 * @param    int     $id                      id attached to the item published
2081
+	 * @param    string  $delete                  page route callback for the delete action
2082
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2083
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2084
+	 * @throws \EE_Error
2085
+	 */
2086
+	protected function _set_publish_post_box_vars(
2087
+			$name = '',
2088
+			$id = 0,
2089
+			$delete = '',
2090
+			$save_close_redirect_URL = '',
2091
+			$both_btns = true
2092
+	) {
2093
+		// if Save & Close, use a custom redirect URL or default to the main page?
2094
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2095
+		// create the Save & Close and Save buttons
2096
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2097
+		//if we have extra content set let's add it in if not make sure its empty
2098
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2099
+		if ($delete && ! empty($id)) {
2100
+			//make sure we have a default if just true is sent.
2101
+			$delete = ! empty($delete) ? $delete : 'delete';
2102
+			$delete_link_args = array($name => $id);
2103
+			$delete = $this->get_action_link_or_button(
2104
+					$delete,
2105
+					$delete,
2106
+					$delete_link_args,
2107
+					'submitdelete deletion',
2108
+					'',
2109
+					false
2110
+			);
2111
+		}
2112
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2113
+		if ( ! empty($name) && ! empty($id)) {
2114
+			$hidden_field_arr[$name] = array(
2115
+					'type'  => 'hidden',
2116
+					'value' => $id,
2117
+			);
2118
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2119
+		} else {
2120
+			$hf = '';
2121
+		}
2122
+		// add hidden field
2123
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2124
+	}
2125
+
2126
+
2127
+
2128
+	/**
2129
+	 *        displays an error message to ppl who have javascript disabled
2130
+	 *
2131
+	 * @access        private
2132
+	 * @return        string
2133
+	 */
2134
+	private function _display_no_javascript_warning()
2135
+	{
2136
+		?>
2137 2137
         <noscript>
2138 2138
             <div id="no-js-message" class="error">
2139 2139
                 <p style="font-size:1.3em;">
@@ -2143,1234 +2143,1234 @@  discard block
 block discarded – undo
2143 2143
             </div>
2144 2144
         </noscript>
2145 2145
         <?php
2146
-    }
2146
+	}
2147 2147
 
2148 2148
 
2149 2149
 
2150
-    /**
2151
-     *        displays espresso success and/or error notices
2152
-     *
2153
-     * @access        private
2154
-     * @return        string
2155
-     */
2156
-    private function _display_espresso_notices()
2157
-    {
2158
-        $notices = $this->_get_transient(true);
2159
-        echo stripslashes($notices);
2160
-    }
2150
+	/**
2151
+	 *        displays espresso success and/or error notices
2152
+	 *
2153
+	 * @access        private
2154
+	 * @return        string
2155
+	 */
2156
+	private function _display_espresso_notices()
2157
+	{
2158
+		$notices = $this->_get_transient(true);
2159
+		echo stripslashes($notices);
2160
+	}
2161 2161
 
2162 2162
 
2163 2163
 
2164
-    /**
2165
-     *        spinny things pacify the masses
2166
-     *
2167
-     * @access private
2168
-     * @return string
2169
-     */
2170
-    protected function _add_admin_page_ajax_loading_img()
2171
-    {
2172
-        ?>
2164
+	/**
2165
+	 *        spinny things pacify the masses
2166
+	 *
2167
+	 * @access private
2168
+	 * @return string
2169
+	 */
2170
+	protected function _add_admin_page_ajax_loading_img()
2171
+	{
2172
+		?>
2173 2173
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2174 2174
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php _e('loading...', 'event_espresso'); ?></span>
2175 2175
         </div>
2176 2176
         <?php
2177
-    }
2177
+	}
2178 2178
 
2179 2179
 
2180 2180
 
2181
-    /**
2182
-     *        add admin page overlay for modal boxes
2183
-     *
2184
-     * @access private
2185
-     * @return string
2186
-     */
2187
-    protected function _add_admin_page_overlay()
2188
-    {
2189
-        ?>
2181
+	/**
2182
+	 *        add admin page overlay for modal boxes
2183
+	 *
2184
+	 * @access private
2185
+	 * @return string
2186
+	 */
2187
+	protected function _add_admin_page_overlay()
2188
+	{
2189
+		?>
2190 2190
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2191 2191
         <?php
2192
-    }
2193
-
2194
-
2195
-
2196
-    /**
2197
-     * facade for add_meta_box
2198
-     *
2199
-     * @param string  $action        where the metabox get's displayed
2200
-     * @param string  $title         Title of Metabox (output in metabox header)
2201
-     * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2202
-     * @param array   $callback_args an array of args supplied for the metabox
2203
-     * @param string  $column        what metabox column
2204
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2205
-     * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2206
-     */
2207
-    public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2208
-    {
2209
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2210
-        //if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2211
-        if (empty($callback_args) && $create_func) {
2212
-            $callback_args = array(
2213
-                    'template_path' => $this->_template_path,
2214
-                    'template_args' => $this->_template_args,
2215
-            );
2216
-        }
2217
-        //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2218
-        $call_back_func = $create_func ? create_function('$post, $metabox',
2219
-                'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2220
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2221
-    }
2222
-
2223
-
2224
-
2225
-    /**
2226
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2227
-     *
2228
-     * @return [type] [description]
2229
-     */
2230
-    public function display_admin_page_with_metabox_columns()
2231
-    {
2232
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2233
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2234
-        //the final wrapper
2235
-        $this->admin_page_wrapper();
2236
-    }
2237
-
2238
-
2239
-
2240
-    /**
2241
-     *        generates  HTML wrapper for an admin details page
2242
-     *
2243
-     * @access public
2244
-     * @return void
2245
-     */
2246
-    public function display_admin_page_with_sidebar()
2247
-    {
2248
-        $this->_display_admin_page(true);
2249
-    }
2250
-
2251
-
2252
-
2253
-    /**
2254
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2255
-     *
2256
-     * @access public
2257
-     * @return void
2258
-     */
2259
-    public function display_admin_page_with_no_sidebar()
2260
-    {
2261
-        $this->_display_admin_page();
2262
-    }
2263
-
2264
-
2265
-
2266
-    /**
2267
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2268
-     *
2269
-     * @access public
2270
-     * @return void
2271
-     */
2272
-    public function display_about_admin_page()
2273
-    {
2274
-        $this->_display_admin_page(false, true);
2275
-    }
2276
-
2277
-
2278
-
2279
-    /**
2280
-     * display_admin_page
2281
-     * contains the code for actually displaying an admin page
2282
-     *
2283
-     * @access private
2284
-     * @param  boolean $sidebar true with sidebar, false without
2285
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2286
-     * @return void
2287
-     */
2288
-    private function _display_admin_page($sidebar = false, $about = false)
2289
-    {
2290
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2291
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2292
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2293
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2294
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2295
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2296
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2297
-                ? 'poststuff'
2298
-                : 'espresso-default-admin';
2299
-        $template_path = $sidebar
2300
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2301
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2302
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2303
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2304
-        }
2305
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2306
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2307
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2308
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2309
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2310
-        // the final template wrapper
2311
-        $this->admin_page_wrapper($about);
2312
-    }
2313
-
2314
-
2315
-
2316
-    /**
2317
-     * This is used to display caf preview pages.
2318
-     *
2319
-     * @since 4.3.2
2320
-     * @param string $utm_campaign_source what is the key used for google analytics link
2321
-     * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2322
-     * @return void
2323
-     * @throws \EE_Error
2324
-     */
2325
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2326
-    {
2327
-        //let's generate a default preview action button if there isn't one already present.
2328
-        $this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2329
-        $buy_now_url = add_query_arg(
2330
-                array(
2331
-                        'ee_ver'       => 'ee4',
2332
-                        'utm_source'   => 'ee4_plugin_admin',
2333
-                        'utm_medium'   => 'link',
2334
-                        'utm_campaign' => $utm_campaign_source,
2335
-                        'utm_content'  => 'buy_now_button',
2336
-                ),
2337
-                'http://eventespresso.com/pricing/'
2338
-        );
2339
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2340
-                ? $this->get_action_link_or_button(
2341
-                        '',
2342
-                        'buy_now',
2343
-                        array(),
2344
-                        'button-primary button-large',
2345
-                        $buy_now_url,
2346
-                        true
2347
-                )
2348
-                : $this->_template_args['preview_action_button'];
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2350
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2351
-                $template_path,
2352
-                $this->_template_args,
2353
-                true
2354
-        );
2355
-        $this->_display_admin_page($display_sidebar);
2356
-    }
2357
-
2358
-
2359
-
2360
-    /**
2361
-     * display_admin_list_table_page_with_sidebar
2362
-     * generates HTML wrapper for an admin_page with list_table
2363
-     *
2364
-     * @access public
2365
-     * @return void
2366
-     */
2367
-    public function display_admin_list_table_page_with_sidebar()
2368
-    {
2369
-        $this->_display_admin_list_table_page(true);
2370
-    }
2371
-
2372
-
2373
-
2374
-    /**
2375
-     * display_admin_list_table_page_with_no_sidebar
2376
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2377
-     *
2378
-     * @access public
2379
-     * @return void
2380
-     */
2381
-    public function display_admin_list_table_page_with_no_sidebar()
2382
-    {
2383
-        $this->_display_admin_list_table_page();
2384
-    }
2385
-
2386
-
2387
-
2388
-    /**
2389
-     * generates html wrapper for an admin_list_table page
2390
-     *
2391
-     * @access private
2392
-     * @param boolean $sidebar whether to display with sidebar or not.
2393
-     * @return void
2394
-     */
2395
-    private function _display_admin_list_table_page($sidebar = false)
2396
-    {
2397
-        //setup search attributes
2398
-        $this->_set_search_attributes();
2399
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2400
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2401
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2402
-                ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2403
-                : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2404
-        $this->_template_args['list_table'] = $this->_list_table_object;
2405
-        $this->_template_args['current_route'] = $this->_req_action;
2406
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2407
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2408
-        if ( ! empty($ajax_sorting_callback)) {
2409
-            $sortable_list_table_form_fields = wp_nonce_field(
2410
-                    $ajax_sorting_callback . '_nonce',
2411
-                    $ajax_sorting_callback . '_nonce',
2412
-                    false,
2413
-                    false
2414
-            );
2415
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2416
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2417
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2418
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2419
-        } else {
2420
-            $sortable_list_table_form_fields = '';
2421
-        }
2422
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2423
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2424
-        $nonce_ref = $this->_req_action . '_nonce';
2425
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2426
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2427
-        //display message about search results?
2428
-        $this->_template_args['before_list_table'] .= apply_filters(
2429
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2430
-                ! empty($this->_req_data['s'])
2431
-                        ? '<p class="ee-search-results">' . sprintf(
2432
-                                __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'),
2433
-                                trim($this->_req_data['s'], '%')
2434
-                        ) . '</p>'
2435
-                        : '',
2436
-                $this->page_slug,
2437
-                $this->_req_data,
2438
-                $this->_req_action
2439
-        );
2440
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2441
-                $template_path,
2442
-                $this->_template_args,
2443
-                true
2444
-        );
2445
-        // the final template wrapper
2446
-        if ($sidebar) {
2447
-            $this->display_admin_page_with_sidebar();
2448
-        } else {
2449
-            $this->display_admin_page_with_no_sidebar();
2450
-        }
2451
-    }
2452
-
2453
-
2454
-
2455
-    /**
2456
-     * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2457
-     * $items are expected in an array in the following format:
2458
-     * $legend_items = array(
2459
-     *        'item_id' => array(
2460
-     *            'icon' => 'http://url_to_icon_being_described.png',
2461
-     *            'desc' => __('localized description of item');
2462
-     *        )
2463
-     * );
2464
-     *
2465
-     * @param  array $items see above for format of array
2466
-     * @return string        html string of legend
2467
-     */
2468
-    protected function _display_legend($items)
2469
-    {
2470
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2471
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2472
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2473
-    }
2474
-
2475
-
2476
-
2477
-    /**
2478
-     * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2479
-     *
2480
-     * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2481
-     *                             The returned json object is created from an array in the following format:
2482
-     *                             array(
2483
-     *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2484
-     *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2485
-     *                             'notices' => '', // - contains any EE_Error formatted notices
2486
-     *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2487
-     *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2488
-     *                             specific template args that might be included in here)
2489
-     *                             )
2490
-     *                             The json object is populated by whatever is set in the $_template_args property.
2491
-     * @return void
2492
-     */
2493
-    protected function _return_json($sticky_notices = false)
2494
-    {
2495
-        //make sure any EE_Error notices have been handled.
2496
-        $this->_process_notices(array(), true, $sticky_notices);
2497
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2498
-        unset($this->_template_args['data']);
2499
-        $json = array(
2500
-                'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2501
-                'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2502
-                'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2503
-                'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2504
-                'notices'   => EE_Error::get_notices(),
2505
-                'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2506
-                'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2507
-                'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2508
-        );
2509
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2510
-        if (null === error_get_last() || ! headers_sent()) {
2511
-            header('Content-Type: application/json; charset=UTF-8');
2512
-        }
2513
-        if (function_exists('wp_json_encode')) {
2514
-            echo wp_json_encode($json);
2515
-        } else {
2516
-            echo json_encode($json);
2517
-        }
2518
-        exit();
2519
-    }
2520
-
2521
-
2522
-
2523
-    /**
2524
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2525
-     *
2526
-     * @return void
2527
-     * @throws EE_Error
2528
-     */
2529
-    public function return_json()
2530
-    {
2531
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2532
-            $this->_return_json();
2533
-        } else {
2534
-            throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2535
-        }
2536
-    }
2537
-
2538
-
2539
-
2540
-    /**
2541
-     * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2542
-     *
2543
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2544
-     * @access   public
2545
-     */
2546
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
2547
-    {
2548
-        $this->_hook_obj = $hook_obj;
2549
-    }
2550
-
2551
-
2552
-
2553
-    /**
2554
-     *        generates  HTML wrapper with Tabbed nav for an admin page
2555
-     *
2556
-     * @access public
2557
-     * @param  boolean $about whether to use the special about page wrapper or default.
2558
-     * @return void
2559
-     */
2560
-    public function admin_page_wrapper($about = false)
2561
-    {
2562
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2563
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
2564
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2565
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2566
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2567
-                isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2568
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2569
-                isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2570
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2571
-        // load settings page wrapper template
2572
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2573
-        //about page?
2574
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2575
-        if (defined('DOING_AJAX')) {
2576
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2577
-            $this->_return_json();
2578
-        } else {
2579
-            EEH_Template::display_template($template_path, $this->_template_args);
2580
-        }
2581
-    }
2582
-
2583
-
2584
-
2585
-    /**
2586
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2587
-     *
2588
-     * @return string html
2589
-     */
2590
-    protected function _get_main_nav_tabs()
2591
-    {
2592
-        //let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2593
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2594
-    }
2595
-
2596
-
2597
-
2598
-    /**
2599
-     *        sort nav tabs
2600
-     *
2601
-     * @access public
2602
-     * @param $a
2603
-     * @param $b
2604
-     * @return int
2605
-     */
2606
-    private function _sort_nav_tabs($a, $b)
2607
-    {
2608
-        if ($a['order'] == $b['order']) {
2609
-            return 0;
2610
-        }
2611
-        return ($a['order'] < $b['order']) ? -1 : 1;
2612
-    }
2613
-
2614
-
2615
-
2616
-    /**
2617
-     *    generates HTML for the forms used on admin pages
2618
-     *
2619
-     * @access protected
2620
-     * @param    array $input_vars - array of input field details
2621
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2622
-     * @return string
2623
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2624
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2625
-     */
2626
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2627
-    {
2628
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2629
-        return $content;
2630
-    }
2631
-
2632
-
2633
-
2634
-    /**
2635
-     * generates the "Save" and "Save & Close" buttons for edit forms
2636
-     *
2637
-     * @access protected
2638
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2639
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2640
-     * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2641
-     * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2642
-     */
2643
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2644
-    {
2645
-        //make sure $text and $actions are in an array
2646
-        $text = (array)$text;
2647
-        $actions = (array)$actions;
2648
-        $referrer_url = empty($referrer) ? '' : $referrer;
2649
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2650
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2651
-        $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2652
-        $default_names = array('save', 'save_and_close');
2653
-        //add in a hidden index for the current page (so save and close redirects properly)
2654
-        $this->_template_args['save_buttons'] = $referrer_url;
2655
-        foreach ($button_text as $key => $button) {
2656
-            $ref = $default_names[$key];
2657
-            $id = $this->_current_view . '_' . $ref;
2658
-            $name = ! empty($actions) ? $actions[$key] : $ref;
2659
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2660
-            if ( ! $both) {
2661
-                break;
2662
-            }
2663
-        }
2664
-    }
2665
-
2666
-
2667
-
2668
-    /**
2669
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2670
-     *
2671
-     * @see   $this->_set_add_edit_form_tags() for details on params
2672
-     * @since 4.6.0
2673
-     * @param string $route
2674
-     * @param array  $additional_hidden_fields
2675
-     */
2676
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2677
-    {
2678
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2679
-    }
2680
-
2681
-
2682
-
2683
-    /**
2684
-     * set form open and close tags on add/edit pages.
2685
-     *
2686
-     * @access protected
2687
-     * @param string $route                    the route you want the form to direct to
2688
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2689
-     * @return void
2690
-     */
2691
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2692
-    {
2693
-        if (empty($route)) {
2694
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2695
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2696
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2697
-        }
2698
-        // open form
2699
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2700
-        // add nonce
2701
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2702
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2703
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2704
-        // add REQUIRED form action
2705
-        $hidden_fields = array(
2706
-                'action' => array('type' => 'hidden', 'value' => $route),
2707
-        );
2708
-        // merge arrays
2709
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2710
-        // generate form fields
2711
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2712
-        // add fields to form
2713
-        foreach ((array)$form_fields as $field_name => $form_field) {
2714
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2715
-        }
2716
-        // close form
2717
-        $this->_template_args['after_admin_page_content'] = '</form>';
2718
-    }
2719
-
2720
-
2721
-
2722
-    /**
2723
-     * Public Wrapper for _redirect_after_action() method since its
2724
-     * discovered it would be useful for external code to have access.
2725
-     *
2726
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
2727
-     * @since 4.5.0
2728
-     */
2729
-    public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2730
-    {
2731
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2732
-    }
2733
-
2734
-
2735
-
2736
-    /**
2737
-     *    _redirect_after_action
2738
-     *
2739
-     * @param int    $success            - whether success was for two or more records, or just one, or none
2740
-     * @param string $what               - what the action was performed on
2741
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
2742
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2743
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2744
-     * @access protected
2745
-     * @return void
2746
-     */
2747
-    protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2748
-    {
2749
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2750
-        //class name for actions/filters.
2751
-        $classname = get_class($this);
2752
-        //set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2753
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2754
-        $notices = EE_Error::get_notices(false);
2755
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
2756
-        if ( ! $override_overwrite || ! empty($notices['errors'])) {
2757
-            EE_Error::overwrite_success();
2758
-        }
2759
-        if ( ! empty($what) && ! empty($action_desc)) {
2760
-            // how many records affected ? more than one record ? or just one ?
2761
-            if ($success > 1 && empty($notices['errors'])) {
2762
-                // set plural msg
2763
-                EE_Error::add_success(
2764
-                        sprintf(
2765
-                                __('The "%s" have been successfully %s.', 'event_espresso'),
2766
-                                $what,
2767
-                                $action_desc
2768
-                        ),
2769
-                        __FILE__, __FUNCTION__, __LINE__
2770
-                );
2771
-            } else if ($success == 1 && empty($notices['errors'])) {
2772
-                // set singular msg
2773
-                EE_Error::add_success(
2774
-                        sprintf(
2775
-                                __('The "%s" has been successfully %s.', 'event_espresso'),
2776
-                                $what,
2777
-                                $action_desc
2778
-                        ),
2779
-                        __FILE__, __FUNCTION__, __LINE__
2780
-                );
2781
-            }
2782
-        }
2783
-        // check that $query_args isn't something crazy
2784
-        if ( ! is_array($query_args)) {
2785
-            $query_args = array();
2786
-        }
2787
-        /**
2788
-         * Allow injecting actions before the query_args are modified for possible different
2789
-         * redirections on save and close actions
2790
-         *
2791
-         * @since 4.2.0
2792
-         * @param array $query_args       The original query_args array coming into the
2793
-         *                                method.
2794
-         */
2795
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2796
-        //calculate where we're going (if we have a "save and close" button pushed)
2797
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2798
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2799
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2800
-            // regenerate query args array from referrer URL
2801
-            parse_str($parsed_url['query'], $query_args);
2802
-            // correct page and action will be in the query args now
2803
-            $redirect_url = admin_url('admin.php');
2804
-        }
2805
-        //merge any default query_args set in _default_route_query_args property
2806
-        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2807
-            $args_to_merge = array();
2808
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
2809
-                //is there a wp_referer array in our _default_route_query_args property?
2810
-                if ($query_param == 'wp_referer') {
2811
-                    $query_value = (array)$query_value;
2812
-                    foreach ($query_value as $reference => $value) {
2813
-                        if (strpos($reference, 'nonce') !== false) {
2814
-                            continue;
2815
-                        }
2816
-                        //finally we will override any arguments in the referer with
2817
-                        //what might be set on the _default_route_query_args array.
2818
-                        if (isset($this->_default_route_query_args[$reference])) {
2819
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2820
-                        } else {
2821
-                            $args_to_merge[$reference] = urlencode($value);
2822
-                        }
2823
-                    }
2824
-                    continue;
2825
-                }
2826
-                $args_to_merge[$query_param] = $query_value;
2827
-            }
2828
-            //now let's merge these arguments but override with what was specifically sent in to the
2829
-            //redirect.
2830
-            $query_args = array_merge($args_to_merge, $query_args);
2831
-        }
2832
-        $this->_process_notices($query_args);
2833
-        // generate redirect url
2834
-        // if redirecting to anything other than the main page, add a nonce
2835
-        if (isset($query_args['action'])) {
2836
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2837
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2838
-        }
2839
-        //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2840
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2841
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2842
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2843
-        if (defined('DOING_AJAX')) {
2844
-            $default_data = array(
2845
-                    'close'        => true,
2846
-                    'redirect_url' => $redirect_url,
2847
-                    'where'        => 'main',
2848
-                    'what'         => 'append',
2849
-            );
2850
-            $this->_template_args['success'] = $success;
2851
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2852
-            $this->_return_json();
2853
-        }
2854
-        wp_safe_redirect($redirect_url);
2855
-        exit();
2856
-    }
2857
-
2858
-
2859
-
2860
-    /**
2861
-     * process any notices before redirecting (or returning ajax request)
2862
-     * This method sets the $this->_template_args['notices'] attribute;
2863
-     *
2864
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
2865
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2866
-     * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2867
-     * @return void
2868
-     */
2869
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2870
-    {
2871
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
2872
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2873
-            $notices = EE_Error::get_notices(false);
2874
-            if (empty($this->_template_args['success'])) {
2875
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2876
-            }
2877
-            if (empty($this->_template_args['errors'])) {
2878
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2879
-            }
2880
-            if (empty($this->_template_args['attention'])) {
2881
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2882
-            }
2883
-        }
2884
-        $this->_template_args['notices'] = EE_Error::get_notices();
2885
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2886
-        if ( ! defined('DOING_AJAX') || $sticky_notices) {
2887
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
2888
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2889
-        }
2890
-    }
2891
-
2892
-
2893
-
2894
-    /**
2895
-     * get_action_link_or_button
2896
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
2897
-     *
2898
-     * @param string $action        use this to indicate which action the url is generated with.
2899
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2900
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2901
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2902
-     * @param string $base_url      If this is not provided
2903
-     *                              the _admin_base_url will be used as the default for the button base_url.
2904
-     *                              Otherwise this value will be used.
2905
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2906
-     * @return string
2907
-     * @throws \EE_Error
2908
-     */
2909
-    public function get_action_link_or_button(
2910
-            $action,
2911
-            $type = 'add',
2912
-            $extra_request = array(),
2913
-            $class = 'button-primary',
2914
-            $base_url = '',
2915
-            $exclude_nonce = false
2916
-    ) {
2917
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2918
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2919
-            throw new EE_Error(
2920
-                    sprintf(
2921
-                            __(
2922
-                                    'There is no page route for given action for the button.  This action was given: %s',
2923
-                                    'event_espresso'
2924
-                            ),
2925
-                            $action
2926
-                    )
2927
-            );
2928
-        }
2929
-        if ( ! isset($this->_labels['buttons'][$type])) {
2930
-            throw new EE_Error(
2931
-                    sprintf(
2932
-                            __(
2933
-                                    'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2934
-                                    'event_espresso'
2935
-                            ),
2936
-                            $type
2937
-                    )
2938
-            );
2939
-        }
2940
-        //finally check user access for this button.
2941
-        $has_access = $this->check_user_access($action, true);
2942
-        if ( ! $has_access) {
2943
-            return '';
2944
-        }
2945
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2946
-        $query_args = array(
2947
-                'action' => $action,
2948
-        );
2949
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2950
-        if ( ! empty($extra_request)) {
2951
-            $query_args = array_merge($extra_request, $query_args);
2952
-        }
2953
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2954
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2955
-    }
2956
-
2957
-
2958
-
2959
-    /**
2960
-     * _per_page_screen_option
2961
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
2962
-     *
2963
-     * @return void
2964
-     */
2965
-    protected function _per_page_screen_option()
2966
-    {
2967
-        $option = 'per_page';
2968
-        $args = array(
2969
-                'label'   => $this->_admin_page_title,
2970
-                'default' => 10,
2971
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2972
-        );
2973
-        //ONLY add the screen option if the user has access to it.
2974
-        if ($this->check_user_access($this->_current_view, true)) {
2975
-            add_screen_option($option, $args);
2976
-        }
2977
-    }
2978
-
2979
-
2980
-
2981
-    /**
2982
-     * set_per_page_screen_option
2983
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
2984
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
2985
-     *
2986
-     * @access private
2987
-     * @return void
2988
-     */
2989
-    private function _set_per_page_screen_options()
2990
-    {
2991
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
2992
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
2993
-            if ( ! $user = wp_get_current_user()) {
2994
-                return;
2995
-            }
2996
-            $option = $_POST['wp_screen_options']['option'];
2997
-            $value = $_POST['wp_screen_options']['value'];
2998
-            if ($option != sanitize_key($option)) {
2999
-                return;
3000
-            }
3001
-            $map_option = $option;
3002
-            $option = str_replace('-', '_', $option);
3003
-            switch ($map_option) {
3004
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3005
-                    $value = (int)$value;
3006
-                    if ($value < 1 || $value > 999) {
3007
-                        return;
3008
-                    }
3009
-                    break;
3010
-                default:
3011
-                    $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3012
-                    if (false === $value) {
3013
-                        return;
3014
-                    }
3015
-                    break;
3016
-            }
3017
-            update_user_meta($user->ID, $option, $value);
3018
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3019
-            exit;
3020
-        }
3021
-    }
3022
-
3023
-
3024
-
3025
-    /**
3026
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3027
-     *
3028
-     * @param array $data array that will be assigned to template args.
3029
-     */
3030
-    public function set_template_args($data)
3031
-    {
3032
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3033
-    }
3034
-
3035
-
3036
-
3037
-    /**
3038
-     * This makes available the WP transient system for temporarily moving data between routes
3039
-     *
3040
-     * @access protected
3041
-     * @param string $route             the route that should receive the transient
3042
-     * @param array  $data              the data that gets sent
3043
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3044
-     * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3045
-     * @return void
3046
-     */
3047
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3048
-    {
3049
-        $user_id = get_current_user_id();
3050
-        if ( ! $skip_route_verify) {
3051
-            $this->_verify_route($route);
3052
-        }
3053
-        //now let's set the string for what kind of transient we're setting
3054
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3055
-        $data = $notices ? array('notices' => $data) : $data;
3056
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3057
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3058
-        if ($existing) {
3059
-            $data = array_merge((array)$data, (array)$existing);
3060
-        }
3061
-        if (is_multisite() && is_network_admin()) {
3062
-            set_site_transient($transient, $data, 8);
3063
-        } else {
3064
-            set_transient($transient, $data, 8);
3065
-        }
3066
-    }
3067
-
3068
-
3069
-
3070
-    /**
3071
-     * this retrieves the temporary transient that has been set for moving data between routes.
3072
-     *
3073
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3074
-     * @return mixed data
3075
-     */
3076
-    protected function _get_transient($notices = false, $route = false)
3077
-    {
3078
-        $user_id = get_current_user_id();
3079
-        $route = ! $route ? $this->_req_action : $route;
3080
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3081
-        $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3082
-        //delete transient after retrieval (just in case it hasn't expired);
3083
-        if (is_multisite() && is_network_admin()) {
3084
-            delete_site_transient($transient);
3085
-        } else {
3086
-            delete_transient($transient);
3087
-        }
3088
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3089
-    }
3090
-
3091
-
3092
-
3093
-    /**
3094
-     * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3095
-     * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3096
-     *
3097
-     * @return void
3098
-     */
3099
-    protected function _transient_garbage_collection()
3100
-    {
3101
-        global $wpdb;
3102
-        //retrieve all existing transients
3103
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3104
-        if ($results = $wpdb->get_results($query)) {
3105
-            foreach ($results as $result) {
3106
-                $transient = str_replace('_transient_', '', $result->option_name);
3107
-                get_transient($transient);
3108
-                if (is_multisite() && is_network_admin()) {
3109
-                    get_site_transient($transient);
3110
-                }
3111
-            }
3112
-        }
3113
-    }
3114
-
3115
-
3116
-
3117
-    /**
3118
-     * get_view
3119
-     *
3120
-     * @access public
3121
-     * @return string content of _view property
3122
-     */
3123
-    public function get_view()
3124
-    {
3125
-        return $this->_view;
3126
-    }
3127
-
3128
-
3129
-
3130
-    /**
3131
-     * getter for the protected $_views property
3132
-     *
3133
-     * @return array
3134
-     */
3135
-    public function get_views()
3136
-    {
3137
-        return $this->_views;
3138
-    }
3139
-
3140
-
3141
-
3142
-    /**
3143
-     * get_current_page
3144
-     *
3145
-     * @access public
3146
-     * @return string _current_page property value
3147
-     */
3148
-    public function get_current_page()
3149
-    {
3150
-        return $this->_current_page;
3151
-    }
3152
-
3153
-
3154
-
3155
-    /**
3156
-     * get_current_view
3157
-     *
3158
-     * @access public
3159
-     * @return string _current_view property value
3160
-     */
3161
-    public function get_current_view()
3162
-    {
3163
-        return $this->_current_view;
3164
-    }
3165
-
3166
-
3167
-
3168
-    /**
3169
-     * get_current_screen
3170
-     *
3171
-     * @access public
3172
-     * @return object The current WP_Screen object
3173
-     */
3174
-    public function get_current_screen()
3175
-    {
3176
-        return $this->_current_screen;
3177
-    }
3178
-
3179
-
3180
-
3181
-    /**
3182
-     * get_current_page_view_url
3183
-     *
3184
-     * @access public
3185
-     * @return string This returns the url for the current_page_view.
3186
-     */
3187
-    public function get_current_page_view_url()
3188
-    {
3189
-        return $this->_current_page_view_url;
3190
-    }
3191
-
3192
-
3193
-
3194
-    /**
3195
-     * just returns the _req_data property
3196
-     *
3197
-     * @return array
3198
-     */
3199
-    public function get_request_data()
3200
-    {
3201
-        return $this->_req_data;
3202
-    }
3203
-
3204
-
3205
-
3206
-    /**
3207
-     * returns the _req_data protected property
3208
-     *
3209
-     * @return string
3210
-     */
3211
-    public function get_req_action()
3212
-    {
3213
-        return $this->_req_action;
3214
-    }
3215
-
3216
-
3217
-
3218
-    /**
3219
-     * @return bool  value of $_is_caf property
3220
-     */
3221
-    public function is_caf()
3222
-    {
3223
-        return $this->_is_caf;
3224
-    }
3225
-
3226
-
3227
-
3228
-    /**
3229
-     * @return mixed
3230
-     */
3231
-    public function default_espresso_metaboxes()
3232
-    {
3233
-        return $this->_default_espresso_metaboxes;
3234
-    }
3235
-
3236
-
3237
-
3238
-    /**
3239
-     * @return mixed
3240
-     */
3241
-    public function admin_base_url()
3242
-    {
3243
-        return $this->_admin_base_url;
3244
-    }
3245
-
3246
-
3247
-
3248
-    /**
3249
-     * @return mixed
3250
-     */
3251
-    public function wp_page_slug()
3252
-    {
3253
-        return $this->_wp_page_slug;
3254
-    }
3255
-
3256
-
3257
-
3258
-    /**
3259
-     * updates  espresso configuration settings
3260
-     *
3261
-     * @access    protected
3262
-     * @param string                   $tab
3263
-     * @param EE_Config_Base|EE_Config $config
3264
-     * @param string                   $file file where error occurred
3265
-     * @param string                   $func function  where error occurred
3266
-     * @param string                   $line line no where error occurred
3267
-     * @return boolean
3268
-     */
3269
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3270
-    {
3271
-        //remove any options that are NOT going to be saved with the config settings.
3272
-        if (isset($config->core->ee_ueip_optin)) {
3273
-            $config->core->ee_ueip_has_notified = true;
3274
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3275
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3276
-            update_option('ee_ueip_has_notified', true);
3277
-        }
3278
-        // and save it (note we're also doing the network save here)
3279
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3280
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3281
-        if ($config_saved && $net_saved) {
3282
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3283
-            return true;
3284
-        } else {
3285
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3286
-            return false;
3287
-        }
3288
-    }
3289
-
3290
-
3291
-
3292
-    /**
3293
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3294
-     *
3295
-     * @return array
3296
-     */
3297
-    public function get_yes_no_values()
3298
-    {
3299
-        return $this->_yes_no_values;
3300
-    }
3301
-
3302
-
3303
-
3304
-    protected function _get_dir()
3305
-    {
3306
-        $reflector = new ReflectionClass(get_class($this));
3307
-        return dirname($reflector->getFileName());
3308
-    }
3309
-
3310
-
3311
-
3312
-    /**
3313
-     * A helper for getting a "next link".
3314
-     *
3315
-     * @param string $url   The url to link to
3316
-     * @param string $class The class to use.
3317
-     * @return string
3318
-     */
3319
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3320
-    {
3321
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3322
-    }
3323
-
3324
-
3325
-
3326
-    /**
3327
-     * A helper for getting a "previous link".
3328
-     *
3329
-     * @param string $url   The url to link to
3330
-     * @param string $class The class to use.
3331
-     * @return string
3332
-     */
3333
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3334
-    {
3335
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3336
-    }
3337
-
3338
-
3339
-
3340
-
3341
-
3342
-
3343
-
3344
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3345
-    /**
3346
-     * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3347
-     * array.
3348
-     *
3349
-     * @return bool success/fail
3350
-     */
3351
-    protected function _process_resend_registration()
3352
-    {
3353
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3354
-        do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3355
-        return $this->_template_args['success'];
3356
-    }
3357
-
3358
-
3359
-
3360
-    /**
3361
-     * This automatically processes any payment message notifications when manual payment has been applied.
3362
-     *
3363
-     * @access protected
3364
-     * @param \EE_Payment $payment
3365
-     * @return bool success/fail
3366
-     */
3367
-    protected function _process_payment_notification(EE_Payment $payment)
3368
-    {
3369
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3370
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3371
-        $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3372
-        return $this->_template_args['success'];
3373
-    }
2192
+	}
2193
+
2194
+
2195
+
2196
+	/**
2197
+	 * facade for add_meta_box
2198
+	 *
2199
+	 * @param string  $action        where the metabox get's displayed
2200
+	 * @param string  $title         Title of Metabox (output in metabox header)
2201
+	 * @param string  $callback      If not empty and $create_fun is set to false then we'll use a custom callback instead of the one created in here.
2202
+	 * @param array   $callback_args an array of args supplied for the metabox
2203
+	 * @param string  $column        what metabox column
2204
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2205
+	 * @param boolean $create_func   default is true.  Basically we can say we don't WANT to have the runtime function created but just set our own callback for wp's add_meta_box.
2206
+	 */
2207
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2208
+	{
2209
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2210
+		//if we have empty callback args and we want to automatically create the metabox callback then we need to make sure the callback args are generated.
2211
+		if (empty($callback_args) && $create_func) {
2212
+			$callback_args = array(
2213
+					'template_path' => $this->_template_path,
2214
+					'template_args' => $this->_template_args,
2215
+			);
2216
+		}
2217
+		//if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2218
+		$call_back_func = $create_func ? create_function('$post, $metabox',
2219
+				'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2220
+		add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2221
+	}
2222
+
2223
+
2224
+
2225
+	/**
2226
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2227
+	 *
2228
+	 * @return [type] [description]
2229
+	 */
2230
+	public function display_admin_page_with_metabox_columns()
2231
+	{
2232
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2233
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2234
+		//the final wrapper
2235
+		$this->admin_page_wrapper();
2236
+	}
2237
+
2238
+
2239
+
2240
+	/**
2241
+	 *        generates  HTML wrapper for an admin details page
2242
+	 *
2243
+	 * @access public
2244
+	 * @return void
2245
+	 */
2246
+	public function display_admin_page_with_sidebar()
2247
+	{
2248
+		$this->_display_admin_page(true);
2249
+	}
2250
+
2251
+
2252
+
2253
+	/**
2254
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2255
+	 *
2256
+	 * @access public
2257
+	 * @return void
2258
+	 */
2259
+	public function display_admin_page_with_no_sidebar()
2260
+	{
2261
+		$this->_display_admin_page();
2262
+	}
2263
+
2264
+
2265
+
2266
+	/**
2267
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2268
+	 *
2269
+	 * @access public
2270
+	 * @return void
2271
+	 */
2272
+	public function display_about_admin_page()
2273
+	{
2274
+		$this->_display_admin_page(false, true);
2275
+	}
2276
+
2277
+
2278
+
2279
+	/**
2280
+	 * display_admin_page
2281
+	 * contains the code for actually displaying an admin page
2282
+	 *
2283
+	 * @access private
2284
+	 * @param  boolean $sidebar true with sidebar, false without
2285
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2286
+	 * @return void
2287
+	 */
2288
+	private function _display_admin_page($sidebar = false, $about = false)
2289
+	{
2290
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2291
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2292
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2293
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2294
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2295
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2296
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2297
+				? 'poststuff'
2298
+				: 'espresso-default-admin';
2299
+		$template_path = $sidebar
2300
+				? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2301
+				: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2302
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2303
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2304
+		}
2305
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2306
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2307
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2308
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2309
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2310
+		// the final template wrapper
2311
+		$this->admin_page_wrapper($about);
2312
+	}
2313
+
2314
+
2315
+
2316
+	/**
2317
+	 * This is used to display caf preview pages.
2318
+	 *
2319
+	 * @since 4.3.2
2320
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2321
+	 * @param bool   $display_sidebar     whether to use the sidebar template or the full template for the page.  TRUE = SHOW sidebar, FALSE = no sidebar. Default no sidebar.
2322
+	 * @return void
2323
+	 * @throws \EE_Error
2324
+	 */
2325
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2326
+	{
2327
+		//let's generate a default preview action button if there isn't one already present.
2328
+		$this->_labels['buttons']['buy_now'] = __('Upgrade Now', 'event_espresso');
2329
+		$buy_now_url = add_query_arg(
2330
+				array(
2331
+						'ee_ver'       => 'ee4',
2332
+						'utm_source'   => 'ee4_plugin_admin',
2333
+						'utm_medium'   => 'link',
2334
+						'utm_campaign' => $utm_campaign_source,
2335
+						'utm_content'  => 'buy_now_button',
2336
+				),
2337
+				'http://eventespresso.com/pricing/'
2338
+		);
2339
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2340
+				? $this->get_action_link_or_button(
2341
+						'',
2342
+						'buy_now',
2343
+						array(),
2344
+						'button-primary button-large',
2345
+						$buy_now_url,
2346
+						true
2347
+				)
2348
+				: $this->_template_args['preview_action_button'];
2349
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2350
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2351
+				$template_path,
2352
+				$this->_template_args,
2353
+				true
2354
+		);
2355
+		$this->_display_admin_page($display_sidebar);
2356
+	}
2357
+
2358
+
2359
+
2360
+	/**
2361
+	 * display_admin_list_table_page_with_sidebar
2362
+	 * generates HTML wrapper for an admin_page with list_table
2363
+	 *
2364
+	 * @access public
2365
+	 * @return void
2366
+	 */
2367
+	public function display_admin_list_table_page_with_sidebar()
2368
+	{
2369
+		$this->_display_admin_list_table_page(true);
2370
+	}
2371
+
2372
+
2373
+
2374
+	/**
2375
+	 * display_admin_list_table_page_with_no_sidebar
2376
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2377
+	 *
2378
+	 * @access public
2379
+	 * @return void
2380
+	 */
2381
+	public function display_admin_list_table_page_with_no_sidebar()
2382
+	{
2383
+		$this->_display_admin_list_table_page();
2384
+	}
2385
+
2386
+
2387
+
2388
+	/**
2389
+	 * generates html wrapper for an admin_list_table page
2390
+	 *
2391
+	 * @access private
2392
+	 * @param boolean $sidebar whether to display with sidebar or not.
2393
+	 * @return void
2394
+	 */
2395
+	private function _display_admin_list_table_page($sidebar = false)
2396
+	{
2397
+		//setup search attributes
2398
+		$this->_set_search_attributes();
2399
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2400
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2401
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2402
+				? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2403
+				: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2404
+		$this->_template_args['list_table'] = $this->_list_table_object;
2405
+		$this->_template_args['current_route'] = $this->_req_action;
2406
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2407
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2408
+		if ( ! empty($ajax_sorting_callback)) {
2409
+			$sortable_list_table_form_fields = wp_nonce_field(
2410
+					$ajax_sorting_callback . '_nonce',
2411
+					$ajax_sorting_callback . '_nonce',
2412
+					false,
2413
+					false
2414
+			);
2415
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2416
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2417
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2418
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2419
+		} else {
2420
+			$sortable_list_table_form_fields = '';
2421
+		}
2422
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2423
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2424
+		$nonce_ref = $this->_req_action . '_nonce';
2425
+		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2426
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2427
+		//display message about search results?
2428
+		$this->_template_args['before_list_table'] .= apply_filters(
2429
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2430
+				! empty($this->_req_data['s'])
2431
+						? '<p class="ee-search-results">' . sprintf(
2432
+								__('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'),
2433
+								trim($this->_req_data['s'], '%')
2434
+						) . '</p>'
2435
+						: '',
2436
+				$this->page_slug,
2437
+				$this->_req_data,
2438
+				$this->_req_action
2439
+		);
2440
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2441
+				$template_path,
2442
+				$this->_template_args,
2443
+				true
2444
+		);
2445
+		// the final template wrapper
2446
+		if ($sidebar) {
2447
+			$this->display_admin_page_with_sidebar();
2448
+		} else {
2449
+			$this->display_admin_page_with_no_sidebar();
2450
+		}
2451
+	}
2452
+
2453
+
2454
+
2455
+	/**
2456
+	 * This just prepares a legend using the given items and the admin_details_legend.template.php file and returns the html string for the legend.
2457
+	 * $items are expected in an array in the following format:
2458
+	 * $legend_items = array(
2459
+	 *        'item_id' => array(
2460
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2461
+	 *            'desc' => __('localized description of item');
2462
+	 *        )
2463
+	 * );
2464
+	 *
2465
+	 * @param  array $items see above for format of array
2466
+	 * @return string        html string of legend
2467
+	 */
2468
+	protected function _display_legend($items)
2469
+	{
2470
+		$this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2471
+		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2472
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2473
+	}
2474
+
2475
+
2476
+
2477
+	/**
2478
+	 * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2479
+	 *
2480
+	 * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2481
+	 *                             The returned json object is created from an array in the following format:
2482
+	 *                             array(
2483
+	 *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2484
+	 *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2485
+	 *                             'notices' => '', // - contains any EE_Error formatted notices
2486
+	 *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2487
+	 *                             'data' => array() //this can be any key/value pairs that a method returns for later json parsing by the js. We're also going to include the template args with every package (so js can pick out any
2488
+	 *                             specific template args that might be included in here)
2489
+	 *                             )
2490
+	 *                             The json object is populated by whatever is set in the $_template_args property.
2491
+	 * @return void
2492
+	 */
2493
+	protected function _return_json($sticky_notices = false)
2494
+	{
2495
+		//make sure any EE_Error notices have been handled.
2496
+		$this->_process_notices(array(), true, $sticky_notices);
2497
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2498
+		unset($this->_template_args['data']);
2499
+		$json = array(
2500
+				'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2501
+				'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2502
+				'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2503
+				'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2504
+				'notices'   => EE_Error::get_notices(),
2505
+				'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2506
+				'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2507
+				'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2508
+		);
2509
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2510
+		if (null === error_get_last() || ! headers_sent()) {
2511
+			header('Content-Type: application/json; charset=UTF-8');
2512
+		}
2513
+		if (function_exists('wp_json_encode')) {
2514
+			echo wp_json_encode($json);
2515
+		} else {
2516
+			echo json_encode($json);
2517
+		}
2518
+		exit();
2519
+	}
2520
+
2521
+
2522
+
2523
+	/**
2524
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2525
+	 *
2526
+	 * @return void
2527
+	 * @throws EE_Error
2528
+	 */
2529
+	public function return_json()
2530
+	{
2531
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2532
+			$this->_return_json();
2533
+		} else {
2534
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2535
+		}
2536
+	}
2537
+
2538
+
2539
+
2540
+	/**
2541
+	 * This provides a way for child hook classes to send along themselves by reference so methods/properties within them can be accessed by EE_Admin_child pages. This is assigned to the $_hook_obj property.
2542
+	 *
2543
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2544
+	 * @access   public
2545
+	 */
2546
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
2547
+	{
2548
+		$this->_hook_obj = $hook_obj;
2549
+	}
2550
+
2551
+
2552
+
2553
+	/**
2554
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
2555
+	 *
2556
+	 * @access public
2557
+	 * @param  boolean $about whether to use the special about page wrapper or default.
2558
+	 * @return void
2559
+	 */
2560
+	public function admin_page_wrapper($about = false)
2561
+	{
2562
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2563
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
2564
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2565
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2566
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2567
+				isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2568
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2569
+				isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2570
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2571
+		// load settings page wrapper template
2572
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2573
+		//about page?
2574
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2575
+		if (defined('DOING_AJAX')) {
2576
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2577
+			$this->_return_json();
2578
+		} else {
2579
+			EEH_Template::display_template($template_path, $this->_template_args);
2580
+		}
2581
+	}
2582
+
2583
+
2584
+
2585
+	/**
2586
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2587
+	 *
2588
+	 * @return string html
2589
+	 */
2590
+	protected function _get_main_nav_tabs()
2591
+	{
2592
+		//let's generate the html using the EEH_Tabbed_Content helper.  We do this here so that it's possible for child classes to add in nav tabs dynamically at the last minute (rather than setting in the page_routes array)
2593
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2594
+	}
2595
+
2596
+
2597
+
2598
+	/**
2599
+	 *        sort nav tabs
2600
+	 *
2601
+	 * @access public
2602
+	 * @param $a
2603
+	 * @param $b
2604
+	 * @return int
2605
+	 */
2606
+	private function _sort_nav_tabs($a, $b)
2607
+	{
2608
+		if ($a['order'] == $b['order']) {
2609
+			return 0;
2610
+		}
2611
+		return ($a['order'] < $b['order']) ? -1 : 1;
2612
+	}
2613
+
2614
+
2615
+
2616
+	/**
2617
+	 *    generates HTML for the forms used on admin pages
2618
+	 *
2619
+	 * @access protected
2620
+	 * @param    array $input_vars - array of input field details
2621
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2622
+	 * @return string
2623
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2624
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2625
+	 */
2626
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2627
+	{
2628
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2629
+		return $content;
2630
+	}
2631
+
2632
+
2633
+
2634
+	/**
2635
+	 * generates the "Save" and "Save & Close" buttons for edit forms
2636
+	 *
2637
+	 * @access protected
2638
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2639
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2640
+	 * @param array            $actions  if included allows us to set the actions that each button will carry out (i.e. via the "name" value in the button).  We can also use this to just dump default actions by submitting some other value.
2641
+	 * @param bool|string|null $referrer if false then we just do the default action on save and close.  Other wise it will use the $referrer string. IF null, then we don't do ANYTHING on save and close (normal form handling).
2642
+	 */
2643
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2644
+	{
2645
+		//make sure $text and $actions are in an array
2646
+		$text = (array)$text;
2647
+		$actions = (array)$actions;
2648
+		$referrer_url = empty($referrer) ? '' : $referrer;
2649
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2650
+				: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2651
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2652
+		$default_names = array('save', 'save_and_close');
2653
+		//add in a hidden index for the current page (so save and close redirects properly)
2654
+		$this->_template_args['save_buttons'] = $referrer_url;
2655
+		foreach ($button_text as $key => $button) {
2656
+			$ref = $default_names[$key];
2657
+			$id = $this->_current_view . '_' . $ref;
2658
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2659
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2660
+			if ( ! $both) {
2661
+				break;
2662
+			}
2663
+		}
2664
+	}
2665
+
2666
+
2667
+
2668
+	/**
2669
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2670
+	 *
2671
+	 * @see   $this->_set_add_edit_form_tags() for details on params
2672
+	 * @since 4.6.0
2673
+	 * @param string $route
2674
+	 * @param array  $additional_hidden_fields
2675
+	 */
2676
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2677
+	{
2678
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2679
+	}
2680
+
2681
+
2682
+
2683
+	/**
2684
+	 * set form open and close tags on add/edit pages.
2685
+	 *
2686
+	 * @access protected
2687
+	 * @param string $route                    the route you want the form to direct to
2688
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2689
+	 * @return void
2690
+	 */
2691
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2692
+	{
2693
+		if (empty($route)) {
2694
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2695
+			$dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2696
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2697
+		}
2698
+		// open form
2699
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2700
+		// add nonce
2701
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2702
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2703
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2704
+		// add REQUIRED form action
2705
+		$hidden_fields = array(
2706
+				'action' => array('type' => 'hidden', 'value' => $route),
2707
+		);
2708
+		// merge arrays
2709
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2710
+		// generate form fields
2711
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2712
+		// add fields to form
2713
+		foreach ((array)$form_fields as $field_name => $form_field) {
2714
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2715
+		}
2716
+		// close form
2717
+		$this->_template_args['after_admin_page_content'] = '</form>';
2718
+	}
2719
+
2720
+
2721
+
2722
+	/**
2723
+	 * Public Wrapper for _redirect_after_action() method since its
2724
+	 * discovered it would be useful for external code to have access.
2725
+	 *
2726
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
2727
+	 * @since 4.5.0
2728
+	 */
2729
+	public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2730
+	{
2731
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2732
+	}
2733
+
2734
+
2735
+
2736
+	/**
2737
+	 *    _redirect_after_action
2738
+	 *
2739
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
2740
+	 * @param string $what               - what the action was performed on
2741
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
2742
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2743
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2744
+	 * @access protected
2745
+	 * @return void
2746
+	 */
2747
+	protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2748
+	{
2749
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2750
+		//class name for actions/filters.
2751
+		$classname = get_class($this);
2752
+		//set redirect url. Note if there is a "page" index in the $query_args then we go with vanilla admin.php route, otherwise we go with whatever is set as the _admin_base_url
2753
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2754
+		$notices = EE_Error::get_notices(false);
2755
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
2756
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2757
+			EE_Error::overwrite_success();
2758
+		}
2759
+		if ( ! empty($what) && ! empty($action_desc)) {
2760
+			// how many records affected ? more than one record ? or just one ?
2761
+			if ($success > 1 && empty($notices['errors'])) {
2762
+				// set plural msg
2763
+				EE_Error::add_success(
2764
+						sprintf(
2765
+								__('The "%s" have been successfully %s.', 'event_espresso'),
2766
+								$what,
2767
+								$action_desc
2768
+						),
2769
+						__FILE__, __FUNCTION__, __LINE__
2770
+				);
2771
+			} else if ($success == 1 && empty($notices['errors'])) {
2772
+				// set singular msg
2773
+				EE_Error::add_success(
2774
+						sprintf(
2775
+								__('The "%s" has been successfully %s.', 'event_espresso'),
2776
+								$what,
2777
+								$action_desc
2778
+						),
2779
+						__FILE__, __FUNCTION__, __LINE__
2780
+				);
2781
+			}
2782
+		}
2783
+		// check that $query_args isn't something crazy
2784
+		if ( ! is_array($query_args)) {
2785
+			$query_args = array();
2786
+		}
2787
+		/**
2788
+		 * Allow injecting actions before the query_args are modified for possible different
2789
+		 * redirections on save and close actions
2790
+		 *
2791
+		 * @since 4.2.0
2792
+		 * @param array $query_args       The original query_args array coming into the
2793
+		 *                                method.
2794
+		 */
2795
+		do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2796
+		//calculate where we're going (if we have a "save and close" button pushed)
2797
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2798
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2799
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2800
+			// regenerate query args array from referrer URL
2801
+			parse_str($parsed_url['query'], $query_args);
2802
+			// correct page and action will be in the query args now
2803
+			$redirect_url = admin_url('admin.php');
2804
+		}
2805
+		//merge any default query_args set in _default_route_query_args property
2806
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2807
+			$args_to_merge = array();
2808
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2809
+				//is there a wp_referer array in our _default_route_query_args property?
2810
+				if ($query_param == 'wp_referer') {
2811
+					$query_value = (array)$query_value;
2812
+					foreach ($query_value as $reference => $value) {
2813
+						if (strpos($reference, 'nonce') !== false) {
2814
+							continue;
2815
+						}
2816
+						//finally we will override any arguments in the referer with
2817
+						//what might be set on the _default_route_query_args array.
2818
+						if (isset($this->_default_route_query_args[$reference])) {
2819
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2820
+						} else {
2821
+							$args_to_merge[$reference] = urlencode($value);
2822
+						}
2823
+					}
2824
+					continue;
2825
+				}
2826
+				$args_to_merge[$query_param] = $query_value;
2827
+			}
2828
+			//now let's merge these arguments but override with what was specifically sent in to the
2829
+			//redirect.
2830
+			$query_args = array_merge($args_to_merge, $query_args);
2831
+		}
2832
+		$this->_process_notices($query_args);
2833
+		// generate redirect url
2834
+		// if redirecting to anything other than the main page, add a nonce
2835
+		if (isset($query_args['action'])) {
2836
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2837
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2838
+		}
2839
+		//we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2840
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2841
+		$redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2842
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2843
+		if (defined('DOING_AJAX')) {
2844
+			$default_data = array(
2845
+					'close'        => true,
2846
+					'redirect_url' => $redirect_url,
2847
+					'where'        => 'main',
2848
+					'what'         => 'append',
2849
+			);
2850
+			$this->_template_args['success'] = $success;
2851
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2852
+			$this->_return_json();
2853
+		}
2854
+		wp_safe_redirect($redirect_url);
2855
+		exit();
2856
+	}
2857
+
2858
+
2859
+
2860
+	/**
2861
+	 * process any notices before redirecting (or returning ajax request)
2862
+	 * This method sets the $this->_template_args['notices'] attribute;
2863
+	 *
2864
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
2865
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2866
+	 * @param bool   $sticky_notices    This is used to flag that regardless of whether this is doing_ajax or not, we still save a transient for the notice.
2867
+	 * @return void
2868
+	 */
2869
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2870
+	{
2871
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
2872
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2873
+			$notices = EE_Error::get_notices(false);
2874
+			if (empty($this->_template_args['success'])) {
2875
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2876
+			}
2877
+			if (empty($this->_template_args['errors'])) {
2878
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2879
+			}
2880
+			if (empty($this->_template_args['attention'])) {
2881
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2882
+			}
2883
+		}
2884
+		$this->_template_args['notices'] = EE_Error::get_notices();
2885
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2886
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2887
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2888
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2889
+		}
2890
+	}
2891
+
2892
+
2893
+
2894
+	/**
2895
+	 * get_action_link_or_button
2896
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
2897
+	 *
2898
+	 * @param string $action        use this to indicate which action the url is generated with.
2899
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2900
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2901
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2902
+	 * @param string $base_url      If this is not provided
2903
+	 *                              the _admin_base_url will be used as the default for the button base_url.
2904
+	 *                              Otherwise this value will be used.
2905
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2906
+	 * @return string
2907
+	 * @throws \EE_Error
2908
+	 */
2909
+	public function get_action_link_or_button(
2910
+			$action,
2911
+			$type = 'add',
2912
+			$extra_request = array(),
2913
+			$class = 'button-primary',
2914
+			$base_url = '',
2915
+			$exclude_nonce = false
2916
+	) {
2917
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2918
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2919
+			throw new EE_Error(
2920
+					sprintf(
2921
+							__(
2922
+									'There is no page route for given action for the button.  This action was given: %s',
2923
+									'event_espresso'
2924
+							),
2925
+							$action
2926
+					)
2927
+			);
2928
+		}
2929
+		if ( ! isset($this->_labels['buttons'][$type])) {
2930
+			throw new EE_Error(
2931
+					sprintf(
2932
+							__(
2933
+									'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2934
+									'event_espresso'
2935
+							),
2936
+							$type
2937
+					)
2938
+			);
2939
+		}
2940
+		//finally check user access for this button.
2941
+		$has_access = $this->check_user_access($action, true);
2942
+		if ( ! $has_access) {
2943
+			return '';
2944
+		}
2945
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2946
+		$query_args = array(
2947
+				'action' => $action,
2948
+		);
2949
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2950
+		if ( ! empty($extra_request)) {
2951
+			$query_args = array_merge($extra_request, $query_args);
2952
+		}
2953
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2954
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2955
+	}
2956
+
2957
+
2958
+
2959
+	/**
2960
+	 * _per_page_screen_option
2961
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
2962
+	 *
2963
+	 * @return void
2964
+	 */
2965
+	protected function _per_page_screen_option()
2966
+	{
2967
+		$option = 'per_page';
2968
+		$args = array(
2969
+				'label'   => $this->_admin_page_title,
2970
+				'default' => 10,
2971
+				'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2972
+		);
2973
+		//ONLY add the screen option if the user has access to it.
2974
+		if ($this->check_user_access($this->_current_view, true)) {
2975
+			add_screen_option($option, $args);
2976
+		}
2977
+	}
2978
+
2979
+
2980
+
2981
+	/**
2982
+	 * set_per_page_screen_option
2983
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
2984
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
2985
+	 *
2986
+	 * @access private
2987
+	 * @return void
2988
+	 */
2989
+	private function _set_per_page_screen_options()
2990
+	{
2991
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
2992
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
2993
+			if ( ! $user = wp_get_current_user()) {
2994
+				return;
2995
+			}
2996
+			$option = $_POST['wp_screen_options']['option'];
2997
+			$value = $_POST['wp_screen_options']['value'];
2998
+			if ($option != sanitize_key($option)) {
2999
+				return;
3000
+			}
3001
+			$map_option = $option;
3002
+			$option = str_replace('-', '_', $option);
3003
+			switch ($map_option) {
3004
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3005
+					$value = (int)$value;
3006
+					if ($value < 1 || $value > 999) {
3007
+						return;
3008
+					}
3009
+					break;
3010
+				default:
3011
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3012
+					if (false === $value) {
3013
+						return;
3014
+					}
3015
+					break;
3016
+			}
3017
+			update_user_meta($user->ID, $option, $value);
3018
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3019
+			exit;
3020
+		}
3021
+	}
3022
+
3023
+
3024
+
3025
+	/**
3026
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3027
+	 *
3028
+	 * @param array $data array that will be assigned to template args.
3029
+	 */
3030
+	public function set_template_args($data)
3031
+	{
3032
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3033
+	}
3034
+
3035
+
3036
+
3037
+	/**
3038
+	 * This makes available the WP transient system for temporarily moving data between routes
3039
+	 *
3040
+	 * @access protected
3041
+	 * @param string $route             the route that should receive the transient
3042
+	 * @param array  $data              the data that gets sent
3043
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3044
+	 * @param bool   $skip_route_verify Used to indicate we want to skip route verification.  This is usually ONLY used when we are adding a transient before page_routes have been defined.
3045
+	 * @return void
3046
+	 */
3047
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3048
+	{
3049
+		$user_id = get_current_user_id();
3050
+		if ( ! $skip_route_verify) {
3051
+			$this->_verify_route($route);
3052
+		}
3053
+		//now let's set the string for what kind of transient we're setting
3054
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3055
+		$data = $notices ? array('notices' => $data) : $data;
3056
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3057
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3058
+		if ($existing) {
3059
+			$data = array_merge((array)$data, (array)$existing);
3060
+		}
3061
+		if (is_multisite() && is_network_admin()) {
3062
+			set_site_transient($transient, $data, 8);
3063
+		} else {
3064
+			set_transient($transient, $data, 8);
3065
+		}
3066
+	}
3067
+
3068
+
3069
+
3070
+	/**
3071
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3072
+	 *
3073
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3074
+	 * @return mixed data
3075
+	 */
3076
+	protected function _get_transient($notices = false, $route = false)
3077
+	{
3078
+		$user_id = get_current_user_id();
3079
+		$route = ! $route ? $this->_req_action : $route;
3080
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3081
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3082
+		//delete transient after retrieval (just in case it hasn't expired);
3083
+		if (is_multisite() && is_network_admin()) {
3084
+			delete_site_transient($transient);
3085
+		} else {
3086
+			delete_transient($transient);
3087
+		}
3088
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3089
+	}
3090
+
3091
+
3092
+
3093
+	/**
3094
+	 * The purpose of this method is just to run garbage collection on any EE transients that might have expired but would not be called later.
3095
+	 * This will be assigned to run on a specific EE Admin page. (place the method in the default route callback on the EE_Admin page you want it run.)
3096
+	 *
3097
+	 * @return void
3098
+	 */
3099
+	protected function _transient_garbage_collection()
3100
+	{
3101
+		global $wpdb;
3102
+		//retrieve all existing transients
3103
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3104
+		if ($results = $wpdb->get_results($query)) {
3105
+			foreach ($results as $result) {
3106
+				$transient = str_replace('_transient_', '', $result->option_name);
3107
+				get_transient($transient);
3108
+				if (is_multisite() && is_network_admin()) {
3109
+					get_site_transient($transient);
3110
+				}
3111
+			}
3112
+		}
3113
+	}
3114
+
3115
+
3116
+
3117
+	/**
3118
+	 * get_view
3119
+	 *
3120
+	 * @access public
3121
+	 * @return string content of _view property
3122
+	 */
3123
+	public function get_view()
3124
+	{
3125
+		return $this->_view;
3126
+	}
3127
+
3128
+
3129
+
3130
+	/**
3131
+	 * getter for the protected $_views property
3132
+	 *
3133
+	 * @return array
3134
+	 */
3135
+	public function get_views()
3136
+	{
3137
+		return $this->_views;
3138
+	}
3139
+
3140
+
3141
+
3142
+	/**
3143
+	 * get_current_page
3144
+	 *
3145
+	 * @access public
3146
+	 * @return string _current_page property value
3147
+	 */
3148
+	public function get_current_page()
3149
+	{
3150
+		return $this->_current_page;
3151
+	}
3152
+
3153
+
3154
+
3155
+	/**
3156
+	 * get_current_view
3157
+	 *
3158
+	 * @access public
3159
+	 * @return string _current_view property value
3160
+	 */
3161
+	public function get_current_view()
3162
+	{
3163
+		return $this->_current_view;
3164
+	}
3165
+
3166
+
3167
+
3168
+	/**
3169
+	 * get_current_screen
3170
+	 *
3171
+	 * @access public
3172
+	 * @return object The current WP_Screen object
3173
+	 */
3174
+	public function get_current_screen()
3175
+	{
3176
+		return $this->_current_screen;
3177
+	}
3178
+
3179
+
3180
+
3181
+	/**
3182
+	 * get_current_page_view_url
3183
+	 *
3184
+	 * @access public
3185
+	 * @return string This returns the url for the current_page_view.
3186
+	 */
3187
+	public function get_current_page_view_url()
3188
+	{
3189
+		return $this->_current_page_view_url;
3190
+	}
3191
+
3192
+
3193
+
3194
+	/**
3195
+	 * just returns the _req_data property
3196
+	 *
3197
+	 * @return array
3198
+	 */
3199
+	public function get_request_data()
3200
+	{
3201
+		return $this->_req_data;
3202
+	}
3203
+
3204
+
3205
+
3206
+	/**
3207
+	 * returns the _req_data protected property
3208
+	 *
3209
+	 * @return string
3210
+	 */
3211
+	public function get_req_action()
3212
+	{
3213
+		return $this->_req_action;
3214
+	}
3215
+
3216
+
3217
+
3218
+	/**
3219
+	 * @return bool  value of $_is_caf property
3220
+	 */
3221
+	public function is_caf()
3222
+	{
3223
+		return $this->_is_caf;
3224
+	}
3225
+
3226
+
3227
+
3228
+	/**
3229
+	 * @return mixed
3230
+	 */
3231
+	public function default_espresso_metaboxes()
3232
+	{
3233
+		return $this->_default_espresso_metaboxes;
3234
+	}
3235
+
3236
+
3237
+
3238
+	/**
3239
+	 * @return mixed
3240
+	 */
3241
+	public function admin_base_url()
3242
+	{
3243
+		return $this->_admin_base_url;
3244
+	}
3245
+
3246
+
3247
+
3248
+	/**
3249
+	 * @return mixed
3250
+	 */
3251
+	public function wp_page_slug()
3252
+	{
3253
+		return $this->_wp_page_slug;
3254
+	}
3255
+
3256
+
3257
+
3258
+	/**
3259
+	 * updates  espresso configuration settings
3260
+	 *
3261
+	 * @access    protected
3262
+	 * @param string                   $tab
3263
+	 * @param EE_Config_Base|EE_Config $config
3264
+	 * @param string                   $file file where error occurred
3265
+	 * @param string                   $func function  where error occurred
3266
+	 * @param string                   $line line no where error occurred
3267
+	 * @return boolean
3268
+	 */
3269
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3270
+	{
3271
+		//remove any options that are NOT going to be saved with the config settings.
3272
+		if (isset($config->core->ee_ueip_optin)) {
3273
+			$config->core->ee_ueip_has_notified = true;
3274
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3275
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3276
+			update_option('ee_ueip_has_notified', true);
3277
+		}
3278
+		// and save it (note we're also doing the network save here)
3279
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3280
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3281
+		if ($config_saved && $net_saved) {
3282
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3283
+			return true;
3284
+		} else {
3285
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3286
+			return false;
3287
+		}
3288
+	}
3289
+
3290
+
3291
+
3292
+	/**
3293
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3294
+	 *
3295
+	 * @return array
3296
+	 */
3297
+	public function get_yes_no_values()
3298
+	{
3299
+		return $this->_yes_no_values;
3300
+	}
3301
+
3302
+
3303
+
3304
+	protected function _get_dir()
3305
+	{
3306
+		$reflector = new ReflectionClass(get_class($this));
3307
+		return dirname($reflector->getFileName());
3308
+	}
3309
+
3310
+
3311
+
3312
+	/**
3313
+	 * A helper for getting a "next link".
3314
+	 *
3315
+	 * @param string $url   The url to link to
3316
+	 * @param string $class The class to use.
3317
+	 * @return string
3318
+	 */
3319
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3320
+	{
3321
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3322
+	}
3323
+
3324
+
3325
+
3326
+	/**
3327
+	 * A helper for getting a "previous link".
3328
+	 *
3329
+	 * @param string $url   The url to link to
3330
+	 * @param string $class The class to use.
3331
+	 * @return string
3332
+	 */
3333
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3334
+	{
3335
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3336
+	}
3337
+
3338
+
3339
+
3340
+
3341
+
3342
+
3343
+
3344
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3345
+	/**
3346
+	 * This processes an request to resend a registration and assumes we have a _REG_ID for doing so. So if the caller knows that the _REG_ID isn't in the req_data array but CAN obtain it, the caller should ADD the _REG_ID to the _req_data
3347
+	 * array.
3348
+	 *
3349
+	 * @return bool success/fail
3350
+	 */
3351
+	protected function _process_resend_registration()
3352
+	{
3353
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3354
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3355
+		return $this->_template_args['success'];
3356
+	}
3357
+
3358
+
3359
+
3360
+	/**
3361
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3362
+	 *
3363
+	 * @access protected
3364
+	 * @param \EE_Payment $payment
3365
+	 * @return bool success/fail
3366
+	 */
3367
+	protected function _process_payment_notification(EE_Payment $payment)
3368
+	{
3369
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3370
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3371
+		$this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3372
+		return $this->_template_args['success'];
3373
+	}
3374 3374
 
3375 3375
 
3376 3376
 }
Please login to merge, or discard this patch.
Spacing   +141 added lines, -141 removed lines patch added patch discarded remove patch
@@ -473,7 +473,7 @@  discard block
 block discarded – undo
473 473
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
474 474
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
475 475
         global $ee_menu_slugs;
476
-        $ee_menu_slugs = (array)$ee_menu_slugs;
476
+        $ee_menu_slugs = (array) $ee_menu_slugs;
477 477
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
478 478
             return false;
479 479
         }
@@ -488,7 +488,7 @@  discard block
 block discarded – undo
488 488
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
489 489
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
490 490
         $this->_current_view = $this->_req_action;
491
-        $this->_req_nonce = $this->_req_action . '_nonce';
491
+        $this->_req_nonce = $this->_req_action.'_nonce';
492 492
         $this->_define_page_props();
493 493
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
494 494
         //default things
@@ -509,11 +509,11 @@  discard block
 block discarded – undo
509 509
             $this->_extend_page_config_for_cpt();
510 510
         }
511 511
         //filter routes and page_config so addons can add their stuff. Filtering done per class
512
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
513
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
512
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
513
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
514 514
         //if AHEE__EE_Admin_Page__route_admin_request_$this->_current_view method is present then we call it hooked into the AHEE__EE_Admin_Page__route_admin_request action
515
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
516
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
515
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
516
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
517 517
         }
518 518
         //next route only if routing enabled
519 519
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
             if ($this->_is_UI_request) {
524 524
                 //admin_init stuff - global, all views for this page class, specific view
525 525
                 add_action('admin_init', array($this, 'admin_init'), 10);
526
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
527
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
526
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
527
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
528 528
                 }
529 529
             } else {
530 530
                 //hijack regular WP loading and route admin request immediately
@@ -544,7 +544,7 @@  discard block
 block discarded – undo
544 544
      */
545 545
     private function _do_other_page_hooks()
546 546
     {
547
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
547
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
548 548
         foreach ($registered_pages as $page) {
549 549
             //now let's setup the file name and class that should be present
550 550
             $classname = str_replace('.class.php', '', $page);
@@ -590,13 +590,13 @@  discard block
 block discarded – undo
590 590
         //load admin_notices - global, page class, and view specific
591 591
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
592 592
         add_action('admin_notices', array($this, 'admin_notices'), 10);
593
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
594
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
593
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
594
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
595 595
         }
596 596
         //load network admin_notices - global, page class, and view specific
597 597
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
598
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
599
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
598
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
599
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
600 600
         }
601 601
         //this will save any per_page screen options if they are present
602 602
         $this->_set_per_page_screen_options();
@@ -608,8 +608,8 @@  discard block
 block discarded – undo
608 608
         //add screen options - global, page child class, and view specific
609 609
         $this->_add_global_screen_options();
610 610
         $this->_add_screen_options();
611
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
612
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
611
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
612
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
613 613
         }
614 614
         //add help tab(s) and tours- set via page_config and qtips.
615 615
         $this->_add_help_tour();
@@ -618,31 +618,31 @@  discard block
 block discarded – undo
618 618
         //add feature_pointers - global, page child class, and view specific
619 619
         $this->_add_feature_pointers();
620 620
         $this->_add_global_feature_pointers();
621
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
622
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
621
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
622
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
623 623
         }
624 624
         //enqueue scripts/styles - global, page class, and view specific
625 625
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
626 626
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
627
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
628
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
627
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
628
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
629 629
         }
630 630
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
631 631
         //admin_print_footer_scripts - global, page child class, and view specific.  NOTE, despite the name, whenever possible, scripts should NOT be loaded using this.  In most cases that's doing_it_wrong().  But adding hidden container elements etc. is a good use case. Notice the late priority we're giving these
632 632
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
633 633
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
634
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
635
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
634
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
635
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
636 636
         }
637 637
         //admin footer scripts
638 638
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
639 639
         add_action('admin_footer', array($this, 'admin_footer'), 100);
640
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
641
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
640
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
641
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
642 642
         }
643 643
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
644 644
         //targeted hook
645
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
645
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
646 646
     }
647 647
 
648 648
 
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
             // user error msg
719 719
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
720 720
             // developer error msg
721
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
721
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722 722
             throw new EE_Error($error_msg);
723 723
         }
724 724
         // and that the requested page route exists
@@ -729,7 +729,7 @@  discard block
 block discarded – undo
729 729
             // user error msg
730 730
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
731 731
             // developer error msg
732
-            $error_msg .= '||' . $error_msg . sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
732
+            $error_msg .= '||'.$error_msg.sprintf(__(' Create a key in the "_page_routes" array named "%s" and set its value to the appropriate method.', 'event_espresso'), $this->_req_action);
733 733
             throw new EE_Error($error_msg);
734 734
         }
735 735
         // and that a default route exists
@@ -737,7 +737,7 @@  discard block
 block discarded – undo
737 737
             // user error msg
738 738
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
739 739
             // developer error msg
740
-            $error_msg .= '||' . $error_msg . __(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
740
+            $error_msg .= '||'.$error_msg.__(' Create a key in the "_page_routes" array named "default" and set its value to your default page method.', 'event_espresso');
741 741
             throw new EE_Error($error_msg);
742 742
         }
743 743
         //first lets' catch if the UI request has EVER been set.
@@ -766,7 +766,7 @@  discard block
 block discarded – undo
766 766
             // user error msg
767 767
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
768 768
             // developer error msg
769
-            $error_msg .= '||' . $error_msg . sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
769
+            $error_msg .= '||'.$error_msg.sprintf(__(' Check the route you are using in your method (%s) and make sure it matches a route set in your "_page_routes" array property', 'event_espresso'), $route);
770 770
             throw new EE_Error($error_msg);
771 771
         }
772 772
     }
@@ -788,7 +788,7 @@  discard block
 block discarded – undo
788 788
             // these are not the droids you are looking for !!!
789 789
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
790 790
             if (WP_DEBUG) {
791
-                $msg .= "\n  " . sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
791
+                $msg .= "\n  ".sprintf(__('In order to dynamically generate nonces for your actions, use the %s::add_query_args_and_nonce() method. May the Nonce be with you!', 'event_espresso'), __CLASS__);
792 792
             }
793 793
             if ( ! defined('DOING_AJAX')) {
794 794
                 wp_die($msg);
@@ -963,7 +963,7 @@  discard block
 block discarded – undo
963 963
                 if (strpos($key, 'nonce') !== false) {
964 964
                     continue;
965 965
                 }
966
-                $args['wp_referer[' . $key . ']'] = $value;
966
+                $args['wp_referer['.$key.']'] = $value;
967 967
             }
968 968
         }
969 969
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1009,7 +1009,7 @@  discard block
 block discarded – undo
1009 1009
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1010 1010
                         continue;
1011 1011
                     }
1012
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1012
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1013 1013
                 }
1014 1014
                 $tour_buttons .= implode('<br />', $tb);
1015 1015
                 $tour_buttons .= '</div></div>';
@@ -1021,7 +1021,7 @@  discard block
 block discarded – undo
1021 1021
                     throw new EE_Error(sprintf(__('The _page_config array has a callback set for the "help_sidebar" option.  However the callback given (%s) is not a valid callback.  Doublecheck the spelling and make sure this method exists for the class %s',
1022 1022
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1023 1023
                 }
1024
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1024
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1025 1025
                 $content .= $tour_buttons; //add help tour buttons.
1026 1026
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1027 1027
                 $this->_current_screen->set_help_sidebar($content);
@@ -1034,13 +1034,13 @@  discard block
 block discarded – undo
1034 1034
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1035 1035
                 $_ht['id'] = $this->page_slug;
1036 1036
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1037
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1037
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1038 1038
                 $this->_current_screen->add_help_tab($_ht);
1039 1039
             }/**/
1040 1040
             if ( ! isset($config['help_tabs'])) {
1041 1041
                 return;
1042 1042
             } //no help tabs for this route
1043
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1043
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1044 1044
                 //we're here so there ARE help tabs!
1045 1045
                 //make sure we've got what we need
1046 1046
                 if ( ! isset($cfg['title'])) {
@@ -1055,9 +1055,9 @@  discard block
 block discarded – undo
1055 1055
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1056 1056
                     //second priority goes to filename
1057 1057
                 } else if ( ! empty($cfg['filename'])) {
1058
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1058
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1059 1059
                     //it's possible that the file is located on decaf route (and above sets up for caf route, if this is the case then lets check decaf route too)
1060
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1060
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1061 1061
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1062 1062
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1063 1063
                         EE_Error::add_error(sprintf(__('The filename given for the help tab %s is not a valid file and there is no other configuration for the tab content.  Please check that the string you set for the help tab on this route (%s) is the correct spelling.  The file should be in %s',
@@ -1076,7 +1076,7 @@  discard block
 block discarded – undo
1076 1076
                     return;
1077 1077
                 }
1078 1078
                 //setup config array for help tab method
1079
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1079
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1080 1080
                 $_ht = array(
1081 1081
                         'id'       => $id,
1082 1082
                         'title'    => $cfg['title'],
@@ -1114,9 +1114,9 @@  discard block
 block discarded – undo
1114 1114
             }
1115 1115
             if (isset($config['help_tour'])) {
1116 1116
                 foreach ($config['help_tour'] as $tour) {
1117
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1117
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1118 1118
                     //let's see if we can get that file... if not its possible this is a decaf route not set in caffienated so lets try and get the caffeinated equivalent
1119
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1119
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1120 1120
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1121 1121
                     if ( ! is_readable($file_path)) {
1122 1122
                         EE_Error::add_error(sprintf(__('The file path given for the help tour (%s) is not a valid path.  Please check that the string you set for the help tour on this route (%s) is the correct spelling', 'event_espresso'),
@@ -1126,7 +1126,7 @@  discard block
 block discarded – undo
1126 1126
                     require_once $file_path;
1127 1127
                     if ( ! class_exists($tour)) {
1128 1128
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1129
-                        $error_msg[] = $error_msg[0] . "\r\n" . sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1129
+                        $error_msg[] = $error_msg[0]."\r\n".sprintf(__('There is no class in place for the %s help tour.%s Make sure you have <strong>%s</strong> defined in the "help_tour" array for the %s route of the % admin page.',
1130 1130
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1131 1131
                         throw new EE_Error(implode('||', $error_msg));
1132 1132
                     }
@@ -1158,11 +1158,11 @@  discard block
 block discarded – undo
1158 1158
     protected function _add_qtips()
1159 1159
     {
1160 1160
         if (isset($this->_route_config['qtips'])) {
1161
-            $qtips = (array)$this->_route_config['qtips'];
1161
+            $qtips = (array) $this->_route_config['qtips'];
1162 1162
             //load qtip loader
1163 1163
             $path = array(
1164
-                    $this->_get_dir() . '/qtips/',
1165
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1164
+                    $this->_get_dir().'/qtips/',
1165
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1166 1166
             );
1167 1167
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1168 1168
         }
@@ -1192,11 +1192,11 @@  discard block
 block discarded – undo
1192 1192
             if ( ! $this->check_user_access($slug, true)) {
1193 1193
                 continue;
1194 1194
             } //no nav tab becasue current user does not have access.
1195
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1195
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1196 1196
             $this->_nav_tabs[$slug] = array(
1197 1197
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1198 1198
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1199
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1199
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1200 1200
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1201 1201
             );
1202 1202
             $i++;
@@ -1259,7 +1259,7 @@  discard block
 block discarded – undo
1259 1259
             $capability = empty($capability) ? 'manage_options' : $capability;
1260 1260
         }
1261 1261
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1262
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1262
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1263 1263
             if ($verify_only) {
1264 1264
                 return false;
1265 1265
             } else {
@@ -1351,7 +1351,7 @@  discard block
 block discarded – undo
1351 1351
     public function admin_footer_global()
1352 1352
     {
1353 1353
         //dialog container for dialog helper
1354
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1354
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1355 1355
         $d_cont .= '<div class="ee-notices"></div>';
1356 1356
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1357 1357
         $d_cont .= '</div>';
@@ -1361,7 +1361,7 @@  discard block
 block discarded – undo
1361 1361
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1362 1362
         }
1363 1363
         //current set timezone for timezone js
1364
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1364
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1365 1365
     }
1366 1366
 
1367 1367
 
@@ -1386,7 +1386,7 @@  discard block
 block discarded – undo
1386 1386
     {
1387 1387
         $content = '';
1388 1388
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1389
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1389
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1390 1390
         //loop through the array and setup content
1391 1391
         foreach ($help_array as $trigger => $help) {
1392 1392
             //make sure the array is setup properly
@@ -1420,7 +1420,7 @@  discard block
 block discarded – undo
1420 1420
     private function _get_help_content()
1421 1421
     {
1422 1422
         //what is the method we're looking for?
1423
-        $method_name = '_help_popup_content_' . $this->_req_action;
1423
+        $method_name = '_help_popup_content_'.$this->_req_action;
1424 1424
         //if method doesn't exist let's get out.
1425 1425
         if ( ! method_exists($this, $method_name)) {
1426 1426
             return array();
@@ -1464,8 +1464,8 @@  discard block
 block discarded – undo
1464 1464
             $help_content = $this->_set_help_popup_content($help_array, false);
1465 1465
         }
1466 1466
         //let's setup the trigger
1467
-        $content = '<a class="ee-dialog" href="?height=' . $dimensions[0] . '&width=' . $dimensions[1] . '&inlineId=' . $trigger_id . '" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
-        $content = $content . $help_content;
1467
+        $content = '<a class="ee-dialog" href="?height='.$dimensions[0].'&width='.$dimensions[1].'&inlineId='.$trigger_id.'" target="_blank"><span class="question ee-help-popup-question"></span></a>';
1468
+        $content = $content.$help_content;
1469 1469
         if ($display) {
1470 1470
             echo $content;
1471 1471
         } else {
@@ -1525,32 +1525,32 @@  discard block
 block discarded – undo
1525 1525
             add_action('admin_head', array($this, 'add_xdebug_style'));
1526 1526
         }
1527 1527
         //register all styles
1528
-        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL . 'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1528
+        wp_register_style('espresso-ui-theme', EE_GLOBAL_ASSETS_URL.'css/espresso-ui-theme/jquery-ui-1.10.3.custom.min.css', array(), EVENT_ESPRESSO_VERSION);
1529
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1530 1530
         //helpers styles
1531
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1531
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1532 1532
         //enqueue global styles
1533 1533
         wp_enqueue_style('ee-admin-css');
1534 1534
         /** SCRIPTS **/
1535 1535
         //register all scripts
1536
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
-        wp_register_script('ee_admin_js', EE_ADMIN_URL . 'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
-        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL . 'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1536
+        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1537
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1538
+        wp_register_script('ee_admin_js', EE_ADMIN_URL.'assets/ee-admin-page.js', array('espresso_core', 'ee-parse-uri', 'ee-dialog'), EVENT_ESPRESSO_VERSION, true);
1539
+        wp_register_script('jquery-ui-timepicker-addon', EE_GLOBAL_ASSETS_URL.'scripts/jquery-ui-timepicker-addon.js', array('jquery-ui-datepicker', 'jquery-ui-slider'), EVENT_ESPRESSO_VERSION, true);
1540 1540
         // register jQuery Validate - see /includes/functions/wp_hooks.php
1541 1541
         add_filter('FHEE_load_jquery_validate', '__return_true');
1542 1542
         add_filter('FHEE_load_joyride', '__return_true');
1543 1543
         //script for sorting tables
1544
-        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL . "assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1544
+        wp_register_script('espresso_ajax_table_sorting', EE_ADMIN_URL."assets/espresso_ajax_table_sorting.js", array('ee_admin_js', 'jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
1545 1545
         //script for parsing uri's
1546
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1546
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1547 1547
         //and parsing associative serialized form elements
1548
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1548
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1549 1549
         //helpers scripts
1550
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1550
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1551
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1552
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1553
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1554 1554
         //google charts
1555 1555
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1556 1556
         //enqueue global scripts
@@ -1571,7 +1571,7 @@  discard block
 block discarded – undo
1571 1571
          */
1572 1572
         if ( ! empty($this->_help_tour)) {
1573 1573
             //register the js for kicking things off
1574
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1574
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1575 1575
             //setup tours for the js tour object
1576 1576
             foreach ($this->_help_tour['tours'] as $tour) {
1577 1577
                 $tours[] = array(
@@ -1670,17 +1670,17 @@  discard block
 block discarded – undo
1670 1670
             return;
1671 1671
         } //not a list_table view so get out.
1672 1672
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1673
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1673
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1674 1674
             //user error msg
1675 1675
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1676 1676
             //developer error msg
1677
-            $error_msg .= '||' . sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1678
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1677
+            $error_msg .= '||'.sprintf(__('List table views for "%s" route could not be setup. Check that you have the corresponding method, "%s" set up for defining list_table_views for this route.', 'event_espresso'),
1678
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1679 1679
             throw new EE_Error($error_msg);
1680 1680
         }
1681 1681
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1682
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1683
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1682
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1683
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1684 1684
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1685 1685
         $this->_set_list_table_view();
1686 1686
         $this->_set_list_table_object();
@@ -1755,7 +1755,7 @@  discard block
 block discarded – undo
1755 1755
             // check for current view
1756 1756
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1757 1757
             $query_args['action'] = $this->_req_action;
1758
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1758
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1759 1759
             $query_args['status'] = $view['slug'];
1760 1760
             //merge any other arguments sent in.
1761 1761
             if (isset($extra_query_args[$view['slug']])) {
@@ -1793,14 +1793,14 @@  discard block
 block discarded – undo
1793 1793
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1794 1794
         foreach ($values as $value) {
1795 1795
             if ($value < $max_entries) {
1796
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1796
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1797 1797
                 $entries_per_page_dropdown .= '
1798
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1798
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1799 1799
             }
1800 1800
         }
1801
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1801
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1802 1802
         $entries_per_page_dropdown .= '
1803
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1803
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1804 1804
         $entries_per_page_dropdown .= '
1805 1805
 					</select>
1806 1806
 					entries
@@ -1822,7 +1822,7 @@  discard block
 block discarded – undo
1822 1822
     public function _set_search_attributes()
1823 1823
     {
1824 1824
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1825
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1825
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1826 1826
     }
1827 1827
 
1828 1828
     /*** END LIST TABLE METHODS **/
@@ -1860,7 +1860,7 @@  discard block
 block discarded – undo
1860 1860
                     // user error msg
1861 1861
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1862 1862
                     // developer error msg
1863
-                    $error_msg .= '||' . sprintf(
1863
+                    $error_msg .= '||'.sprintf(
1864 1864
                                     __(
1865 1865
                                             'The metabox with the string "%s" could not be called. Check that the spelling for method names and actions in the "_page_config[\'metaboxes\']" array are all correct.',
1866 1866
                                             'event_espresso'
@@ -1890,15 +1890,15 @@  discard block
 block discarded – undo
1890 1890
                 && is_array($this->_route_config['columns'])
1891 1891
                 && count($this->_route_config['columns']) === 2
1892 1892
         ) {
1893
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1893
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1894 1894
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1895 1895
             $screen_id = $this->_current_screen->id;
1896
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1896
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1897 1897
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1898
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1898
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1899 1899
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1900 1900
             $this->_template_args['screen'] = $this->_current_screen;
1901
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1901
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1902 1902
             //finally if we don't have has_metaboxes set in the route config let's make sure it IS set other wise the necessary hidden fields for this won't be loaded.
1903 1903
             $this->_route_config['has_metaboxes'] = true;
1904 1904
         }
@@ -1945,7 +1945,7 @@  discard block
 block discarded – undo
1945 1945
      */
1946 1946
     public function espresso_ratings_request()
1947 1947
     {
1948
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1948
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1949 1949
         EEH_Template::display_template($template_path, array());
1950 1950
     }
1951 1951
 
@@ -1953,18 +1953,18 @@  discard block
 block discarded – undo
1953 1953
 
1954 1954
     public static function cached_rss_display($rss_id, $url)
1955 1955
     {
1956
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1956
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1957 1957
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1958
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1959
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1960
-        $post = '</div>' . "\n";
1961
-        $cache_key = 'ee_rss_' . md5($rss_id);
1958
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1959
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1960
+        $post = '</div>'."\n";
1961
+        $cache_key = 'ee_rss_'.md5($rss_id);
1962 1962
         if (false != ($output = get_transient($cache_key))) {
1963
-            echo $pre . $output . $post;
1963
+            echo $pre.$output.$post;
1964 1964
             return true;
1965 1965
         }
1966 1966
         if ( ! $doing_ajax) {
1967
-            echo $pre . $loading . $post;
1967
+            echo $pre.$loading.$post;
1968 1968
             return false;
1969 1969
         }
1970 1970
         ob_start();
@@ -2023,7 +2023,7 @@  discard block
 block discarded – undo
2023 2023
 
2024 2024
     public function espresso_sponsors_post_box()
2025 2025
     {
2026
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2026
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2027 2027
         EEH_Template::display_template($templatepath);
2028 2028
     }
2029 2029
 
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
 
2032 2032
     private function _publish_post_box()
2033 2033
     {
2034
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2034
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2035 2035
         //if there is a array('label' => array('publishbox' => 'some title') ) present in the _page_config array then we'll use that for the metabox label.  Otherwise we'll just use publish (publishbox itself could be an array of labels indexed by routes)
2036 2036
         if ( ! empty($this->_labels['publishbox'])) {
2037 2037
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2048,7 +2048,7 @@  discard block
 block discarded – undo
2048 2048
     {
2049 2049
         //if we have extra content set let's add it in if not make sure its empty
2050 2050
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2051
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2051
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2052 2052
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2053 2053
     }
2054 2054
 
@@ -2217,7 +2217,7 @@  discard block
 block discarded – undo
2217 2217
         //if $create_func is true (default) then we automatically create the function for displaying the actual meta box.  If false then we take the $callback reference passed through and use it instead (so callers can define their own callback function/method if they wish)
2218 2218
         $call_back_func = $create_func ? create_function('$post, $metabox',
2219 2219
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2220
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2220
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2221 2221
     }
2222 2222
 
2223 2223
 
@@ -2297,10 +2297,10 @@  discard block
 block discarded – undo
2297 2297
                 ? 'poststuff'
2298 2298
                 : 'espresso-default-admin';
2299 2299
         $template_path = $sidebar
2300
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2301
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2300
+                ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php'
2301
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2302 2302
         if (defined('DOING_AJAX') && DOING_AJAX) {
2303
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2303
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2304 2304
         }
2305 2305
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2306 2306
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2346,7 +2346,7 @@  discard block
 block discarded – undo
2346 2346
                         true
2347 2347
                 )
2348 2348
                 : $this->_template_args['preview_action_button'];
2349
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2349
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2350 2350
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2351 2351
                 $template_path,
2352 2352
                 $this->_template_args,
@@ -2397,7 +2397,7 @@  discard block
 block discarded – undo
2397 2397
         //setup search attributes
2398 2398
         $this->_set_search_attributes();
2399 2399
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2400
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2400
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2401 2401
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2402 2402
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2403 2403
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2407,31 +2407,31 @@  discard block
 block discarded – undo
2407 2407
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2408 2408
         if ( ! empty($ajax_sorting_callback)) {
2409 2409
             $sortable_list_table_form_fields = wp_nonce_field(
2410
-                    $ajax_sorting_callback . '_nonce',
2411
-                    $ajax_sorting_callback . '_nonce',
2410
+                    $ajax_sorting_callback.'_nonce',
2411
+                    $ajax_sorting_callback.'_nonce',
2412 2412
                     false,
2413 2413
                     false
2414 2414
             );
2415 2415
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2416 2416
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2417
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2418
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2417
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2418
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2419 2419
         } else {
2420 2420
             $sortable_list_table_form_fields = '';
2421 2421
         }
2422 2422
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2423 2423
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2424
-        $nonce_ref = $this->_req_action . '_nonce';
2425
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2424
+        $nonce_ref = $this->_req_action.'_nonce';
2425
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2426 2426
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2427 2427
         //display message about search results?
2428 2428
         $this->_template_args['before_list_table'] .= apply_filters(
2429 2429
                 'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2430 2430
                 ! empty($this->_req_data['s'])
2431
-                        ? '<p class="ee-search-results">' . sprintf(
2431
+                        ? '<p class="ee-search-results">'.sprintf(
2432 2432
                                 __('Displaying search results for the search string: <strong><em>%s</em></strong>', 'event_espresso'),
2433 2433
                                 trim($this->_req_data['s'], '%')
2434
-                        ) . '</p>'
2434
+                        ).'</p>'
2435 2435
                         : '',
2436 2436
                 $this->page_slug,
2437 2437
                 $this->_req_data,
@@ -2467,8 +2467,8 @@  discard block
 block discarded – undo
2467 2467
      */
2468 2468
     protected function _display_legend($items)
2469 2469
     {
2470
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2471
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2470
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2471
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2472 2472
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2473 2473
     }
2474 2474
 
@@ -2563,15 +2563,15 @@  discard block
 block discarded – undo
2563 2563
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2564 2564
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2565 2565
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2566
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2566
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2567 2567
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2568
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2568
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2569 2569
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2570 2570
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2571 2571
         // load settings page wrapper template
2572
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2572
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2573 2573
         //about page?
2574
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2574
+        $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path;
2575 2575
         if (defined('DOING_AJAX')) {
2576 2576
             $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2577 2577
             $this->_return_json();
@@ -2643,20 +2643,20 @@  discard block
 block discarded – undo
2643 2643
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2644 2644
     {
2645 2645
         //make sure $text and $actions are in an array
2646
-        $text = (array)$text;
2647
-        $actions = (array)$actions;
2646
+        $text = (array) $text;
2647
+        $actions = (array) $actions;
2648 2648
         $referrer_url = empty($referrer) ? '' : $referrer;
2649
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2650
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2649
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2650
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2651 2651
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2652 2652
         $default_names = array('save', 'save_and_close');
2653 2653
         //add in a hidden index for the current page (so save and close redirects properly)
2654 2654
         $this->_template_args['save_buttons'] = $referrer_url;
2655 2655
         foreach ($button_text as $key => $button) {
2656 2656
             $ref = $default_names[$key];
2657
-            $id = $this->_current_view . '_' . $ref;
2657
+            $id = $this->_current_view.'_'.$ref;
2658 2658
             $name = ! empty($actions) ? $actions[$key] : $ref;
2659
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2659
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2660 2660
             if ( ! $both) {
2661 2661
                 break;
2662 2662
             }
@@ -2692,15 +2692,15 @@  discard block
 block discarded – undo
2692 2692
     {
2693 2693
         if (empty($route)) {
2694 2694
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2695
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2696
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2695
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2696
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2697 2697
         }
2698 2698
         // open form
2699
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2699
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2700 2700
         // add nonce
2701
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2701
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2702 2702
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2703
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2703
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2704 2704
         // add REQUIRED form action
2705 2705
         $hidden_fields = array(
2706 2706
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2710,8 +2710,8 @@  discard block
 block discarded – undo
2710 2710
         // generate form fields
2711 2711
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2712 2712
         // add fields to form
2713
-        foreach ((array)$form_fields as $field_name => $form_field) {
2714
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2713
+        foreach ((array) $form_fields as $field_name => $form_field) {
2714
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2715 2715
         }
2716 2716
         // close form
2717 2717
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2792,7 +2792,7 @@  discard block
 block discarded – undo
2792 2792
          * @param array $query_args       The original query_args array coming into the
2793 2793
          *                                method.
2794 2794
          */
2795
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2795
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2796 2796
         //calculate where we're going (if we have a "save and close" button pushed)
2797 2797
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2798 2798
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2808,7 +2808,7 @@  discard block
 block discarded – undo
2808 2808
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2809 2809
                 //is there a wp_referer array in our _default_route_query_args property?
2810 2810
                 if ($query_param == 'wp_referer') {
2811
-                    $query_value = (array)$query_value;
2811
+                    $query_value = (array) $query_value;
2812 2812
                     foreach ($query_value as $reference => $value) {
2813 2813
                         if (strpos($reference, 'nonce') !== false) {
2814 2814
                             continue;
@@ -2834,11 +2834,11 @@  discard block
 block discarded – undo
2834 2834
         // if redirecting to anything other than the main page, add a nonce
2835 2835
         if (isset($query_args['action'])) {
2836 2836
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2837
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2837
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2838 2838
         }
2839 2839
         //we're adding some hooks and filters in here for processing any things just before redirects (example: an admin page has done an insert or update and we want to run something after that).
2840
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2841
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2840
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2841
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2842 2842
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2843 2843
         if (defined('DOING_AJAX')) {
2844 2844
             $default_data = array(
@@ -2968,7 +2968,7 @@  discard block
 block discarded – undo
2968 2968
         $args = array(
2969 2969
                 'label'   => $this->_admin_page_title,
2970 2970
                 'default' => 10,
2971
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
2971
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
2972 2972
         );
2973 2973
         //ONLY add the screen option if the user has access to it.
2974 2974
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3001,8 +3001,8 @@  discard block
 block discarded – undo
3001 3001
             $map_option = $option;
3002 3002
             $option = str_replace('-', '_', $option);
3003 3003
             switch ($map_option) {
3004
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3005
-                    $value = (int)$value;
3004
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3005
+                    $value = (int) $value;
3006 3006
                     if ($value < 1 || $value > 999) {
3007 3007
                         return;
3008 3008
                     }
@@ -3029,7 +3029,7 @@  discard block
 block discarded – undo
3029 3029
      */
3030 3030
     public function set_template_args($data)
3031 3031
     {
3032
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3032
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3033 3033
     }
3034 3034
 
3035 3035
 
@@ -3051,12 +3051,12 @@  discard block
 block discarded – undo
3051 3051
             $this->_verify_route($route);
3052 3052
         }
3053 3053
         //now let's set the string for what kind of transient we're setting
3054
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3054
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3055 3055
         $data = $notices ? array('notices' => $data) : $data;
3056 3056
         //is there already a transient for this route?  If there is then let's ADD to that transient
3057 3057
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3058 3058
         if ($existing) {
3059
-            $data = array_merge((array)$data, (array)$existing);
3059
+            $data = array_merge((array) $data, (array) $existing);
3060 3060
         }
3061 3061
         if (is_multisite() && is_network_admin()) {
3062 3062
             set_site_transient($transient, $data, 8);
@@ -3077,7 +3077,7 @@  discard block
 block discarded – undo
3077 3077
     {
3078 3078
         $user_id = get_current_user_id();
3079 3079
         $route = ! $route ? $this->_req_action : $route;
3080
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3080
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3081 3081
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3082 3082
         //delete transient after retrieval (just in case it hasn't expired);
3083 3083
         if (is_multisite() && is_network_admin()) {
@@ -3318,7 +3318,7 @@  discard block
 block discarded – undo
3318 3318
      */
3319 3319
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3320 3320
     {
3321
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3321
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3322 3322
     }
3323 3323
 
3324 3324
 
@@ -3332,7 +3332,7 @@  discard block
 block discarded – undo
3332 3332
      */
3333 3333
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3334 3334
     {
3335
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3335
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3336 3336
     }
3337 3337
 
3338 3338
 
Please login to merge, or discard this patch.