Completed
Branch BUG-10381-asset-loading (189bf4)
by
unknown
13:54
created
admin/extend/registration_form/Extend_Registration_Form_Admin_Page.core.php 2 patches
Indentation   +1085 added lines, -1085 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 /**
@@ -25,1090 +25,1090 @@  discard block
 block discarded – undo
25 25
 {
26 26
 
27 27
 
28
-    /**
29
-     * @Constructor
30
-     * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
31
-     * @access public
32
-     */
33
-    public function __construct($routing = true)
34
-    {
35
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS);
36
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS);
37
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
38
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS);
39
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
40
-        parent::__construct($routing);
41
-    }
42
-
43
-
44
-    protected function _extend_page_config()
45
-    {
46
-        $this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
47
-        $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
48
-        $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
49
-
50
-        $new_page_routes    = array(
51
-            'question_groups'    => array(
52
-                'func'       => '_question_groups_overview_list_table',
53
-                'capability' => 'ee_read_question_groups',
54
-            ),
55
-            'add_question'       => array(
56
-                'func'       => '_edit_question',
57
-                'capability' => 'ee_edit_questions',
58
-            ),
59
-            'insert_question'    => array(
60
-                'func'       => '_insert_or_update_question',
61
-                'args'       => array('new_question' => true),
62
-                'capability' => 'ee_edit_questions',
63
-                'noheader'   => true,
64
-            ),
65
-            'duplicate_question' => array(
66
-                'func'       => '_duplicate_question',
67
-                'capability' => 'ee_edit_questions',
68
-                'noheader'   => true,
69
-            ),
70
-            'trash_question'     => array(
71
-                'func'       => '_trash_question',
72
-                'capability' => 'ee_delete_question',
73
-                'obj_id'     => $qst_id,
74
-                'noheader'   => true,
75
-            ),
76
-
77
-            'restore_question' => array(
78
-                'func'       => '_trash_or_restore_questions',
79
-                'capability' => 'ee_delete_question',
80
-                'obj_id'     => $qst_id,
81
-                'args'       => array('trash' => false),
82
-                'noheader'   => true,
83
-            ),
84
-
85
-            'delete_question' => array(
86
-                'func'       => '_delete_question',
87
-                'capability' => 'ee_delete_question',
88
-                'obj_id'     => $qst_id,
89
-                'noheader'   => true,
90
-            ),
91
-
92
-            'trash_questions' => array(
93
-                'func'       => '_trash_or_restore_questions',
94
-                'capability' => 'ee_delete_questions',
95
-                'args'       => array('trash' => true),
96
-                'noheader'   => true,
97
-            ),
98
-
99
-            'restore_questions' => array(
100
-                'func'       => '_trash_or_restore_questions',
101
-                'capability' => 'ee_delete_questions',
102
-                'args'       => array('trash' => false),
103
-                'noheader'   => true,
104
-            ),
105
-
106
-            'delete_questions' => array(
107
-                'func'       => '_delete_questions',
108
-                'args'       => array(),
109
-                'capability' => 'ee_delete_questions',
110
-                'noheader'   => true,
111
-            ),
112
-
113
-            'add_question_group' => array(
114
-                'func'       => '_edit_question_group',
115
-                'capability' => 'ee_edit_question_groups',
116
-            ),
117
-
118
-            'edit_question_group' => array(
119
-                'func'       => '_edit_question_group',
120
-                'capability' => 'ee_edit_question_group',
121
-                'obj_id'     => $qsg_id,
122
-                'args'       => array('edit'),
123
-            ),
124
-
125
-            'delete_question_groups' => array(
126
-                'func'       => '_delete_question_groups',
127
-                'capability' => 'ee_delete_question_groups',
128
-                'noheader'   => true,
129
-            ),
130
-
131
-            'delete_question_group' => array(
132
-                'func'       => '_delete_question_groups',
133
-                'capability' => 'ee_delete_question_group',
134
-                'obj_id'     => $qsg_id,
135
-                'noheader'   => true,
136
-            ),
137
-
138
-            'trash_question_group' => array(
139
-                'func'       => '_trash_or_restore_question_groups',
140
-                'args'       => array('trash' => true),
141
-                'capability' => 'ee_delete_question_group',
142
-                'obj_id'     => $qsg_id,
143
-                'noheader'   => true,
144
-            ),
145
-
146
-            'restore_question_group' => array(
147
-                'func'       => '_trash_or_restore_question_groups',
148
-                'args'       => array('trash' => false),
149
-                'capability' => 'ee_delete_question_group',
150
-                'obj_id'     => $qsg_id,
151
-                'noheader'   => true,
152
-            ),
153
-
154
-            'insert_question_group' => array(
155
-                'func'       => '_insert_or_update_question_group',
156
-                'args'       => array('new_question_group' => true),
157
-                'capability' => 'ee_edit_question_groups',
158
-                'noheader'   => true,
159
-            ),
160
-
161
-            'update_question_group' => array(
162
-                'func'       => '_insert_or_update_question_group',
163
-                'args'       => array('new_question_group' => false),
164
-                'capability' => 'ee_edit_question_group',
165
-                'obj_id'     => $qsg_id,
166
-                'noheader'   => true,
167
-            ),
168
-
169
-            'trash_question_groups' => array(
170
-                'func'       => '_trash_or_restore_question_groups',
171
-                'args'       => array('trash' => true),
172
-                'capability' => 'ee_delete_question_groups',
173
-                'noheader'   => array('trash' => false),
174
-            ),
175
-
176
-            'restore_question_groups' => array(
177
-                'func'       => '_trash_or_restore_question_groups',
178
-                'args'       => array('trash' => false),
179
-                'capability' => 'ee_delete_question_groups',
180
-                'noheader'   => true,
181
-            ),
182
-
183
-
184
-            'espresso_update_question_group_order' => array(
185
-                'func'       => 'update_question_group_order',
186
-                'capability' => 'ee_edit_question_groups',
187
-                'noheader'   => true,
188
-            ),
189
-
190
-            'view_reg_form_settings' => array(
191
-                'func'       => '_reg_form_settings',
192
-                'capability' => 'manage_options',
193
-            ),
194
-
195
-            'update_reg_form_settings' => array(
196
-                'func'       => '_update_reg_form_settings',
197
-                'capability' => 'manage_options',
198
-                'noheader'   => true,
199
-            ),
200
-        );
201
-        $this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
202
-
203
-        $new_page_config    = array(
204
-
205
-            'question_groups' => array(
206
-                'nav'           => array(
207
-                    'label' => esc_html__('Question Groups', 'event_espresso'),
208
-                    'order' => 20,
209
-                ),
210
-                'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
211
-                'help_tabs'     => array(
212
-                    'registration_form_question_groups_help_tab'                           => array(
213
-                        'title'    => esc_html__('Question Groups', 'event_espresso'),
214
-                        'filename' => 'registration_form_question_groups',
215
-                    ),
216
-                    'registration_form_question_groups_table_column_headings_help_tab'     => array(
217
-                        'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
218
-                        'filename' => 'registration_form_question_groups_table_column_headings',
219
-                    ),
220
-                    'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
221
-                        'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
222
-                        'filename' => 'registration_form_question_groups_views_bulk_actions_search',
223
-                    ),
224
-                ),
225
-                'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
226
-                'metaboxes'     => $this->_default_espresso_metaboxes,
227
-                'require_nonce' => false,
228
-                'qtips'         => array(
229
-                    'EE_Registration_Form_Tips',
230
-                ),
231
-            ),
232
-
233
-            'add_question' => array(
234
-                'nav'           => array(
235
-                    'label'      => esc_html__('Add Question', 'event_espresso'),
236
-                    'order'      => 5,
237
-                    'persistent' => false,
238
-                ),
239
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
240
-                'help_tabs'     => array(
241
-                    'registration_form_add_question_help_tab' => array(
242
-                        'title'    => esc_html__('Add Question', 'event_espresso'),
243
-                        'filename' => 'registration_form_add_question',
244
-                    ),
245
-                ),
246
-                'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
247
-                'require_nonce' => false,
248
-            ),
249
-
250
-            'add_question_group' => array(
251
-                'nav'           => array(
252
-                    'label'      => esc_html__('Add Question Group', 'event_espresso'),
253
-                    'order'      => 5,
254
-                    'persistent' => false,
255
-                ),
256
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
257
-                'help_tabs'     => array(
258
-                    'registration_form_add_question_group_help_tab' => array(
259
-                        'title'    => esc_html__('Add Question Group', 'event_espresso'),
260
-                        'filename' => 'registration_form_add_question_group',
261
-                    ),
262
-                ),
263
-                'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
264
-                'require_nonce' => false,
265
-            ),
266
-
267
-            'edit_question_group' => array(
268
-                'nav'           => array(
269
-                    'label'      => esc_html__('Edit Question Group', 'event_espresso'),
270
-                    'order'      => 5,
271
-                    'persistent' => false,
272
-                    'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']),
273
-                        $this->_current_page_view_url) : $this->_admin_base_url,
274
-                ),
275
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
276
-                'help_tabs'     => array(
277
-                    'registration_form_edit_question_group_help_tab' => array(
278
-                        'title'    => esc_html__('Edit Question Group', 'event_espresso'),
279
-                        'filename' => 'registration_form_edit_question_group',
280
-                    ),
281
-                ),
282
-                'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
283
-                'require_nonce' => false,
284
-            ),
285
-
286
-            'view_reg_form_settings' => array(
287
-                'nav'           => array(
288
-                    'label' => esc_html__('Reg Form Settings', 'event_espresso'),
289
-                    'order' => 40,
290
-                ),
291
-                'labels'        => array(
292
-                    'publishbox' => esc_html__('Update Settings', 'event_espresso'),
293
-                ),
294
-                'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
295
-                'help_tabs'     => array(
296
-                    'registration_form_reg_form_settings_help_tab' => array(
297
-                        'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
298
-                        'filename' => 'registration_form_reg_form_settings',
299
-                    ),
300
-                ),
301
-                'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
302
-                'require_nonce' => false,
303
-            ),
304
-
305
-        );
306
-        $this->_page_config = array_merge($this->_page_config, $new_page_config);
307
-
308
-        //change the list table we're going to use so it's the NEW list table!
309
-        $this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
310
-
311
-
312
-        //additional labels
313
-        $new_labels               = array(
314
-            'add_question'          => esc_html__('Add New Question', 'event_espresso'),
315
-            'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
316
-            'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
317
-            'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
318
-            'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
319
-        );
320
-        $this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
321
-
322
-    }
323
-
324
-
325
-    protected function _ajax_hooks()
326
-    {
327
-        add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
328
-    }
329
-
330
-
331
-    public function load_scripts_styles_question_groups()
332
-    {
333
-        wp_enqueue_script('espresso_ajax_table_sorting');
334
-    }
335
-
336
-
337
-    public function load_scripts_styles_add_question_group()
338
-    {
339
-        $this->load_scripts_styles_forms();
340
-        $this->load_sortable_question_script();
341
-    }
342
-
343
-    public function load_scripts_styles_edit_question_group()
344
-    {
345
-        $this->load_scripts_styles_forms();
346
-        $this->load_sortable_question_script();
347
-    }
348
-
349
-
350
-    /**
351
-     * registers and enqueues script for questions
352
-     *
353
-     * @return void
354
-     */
355
-    public function load_sortable_question_script()
356
-    {
357
-        wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
358
-            array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359
-        wp_enqueue_script('ee-question-sortable');
360
-    }
361
-
362
-
363
-    protected function _set_list_table_views_default()
364
-    {
365
-        $this->_views = array(
366
-            'all' => array(
367
-                'slug'        => 'all',
368
-                'label'       => esc_html__('View All Questions', 'event_espresso'),
369
-                'count'       => 0,
370
-                'bulk_action' => array(
371
-                    'trash_questions' => esc_html__('Trash', 'event_espresso'),
372
-                ),
373
-            ),
374
-        );
375
-
376
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions',
377
-            'espresso_registration_form_trash_questions')
378
-        ) {
379
-            $this->_views['trash'] = array(
380
-                'slug'        => 'trash',
381
-                'label'       => esc_html__('Trash', 'event_espresso'),
382
-                'count'       => 0,
383
-                'bulk_action' => array(
384
-                    'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
385
-                    'restore_questions' => esc_html__('Restore', 'event_espresso'),
386
-                ),
387
-            );
388
-        }
389
-    }
390
-
391
-
392
-    protected function _set_list_table_views_question_groups()
393
-    {
394
-        $this->_views = array(
395
-            'all' => array(
396
-                'slug'        => 'all',
397
-                'label'       => esc_html__('All', 'event_espresso'),
398
-                'count'       => 0,
399
-                'bulk_action' => array(
400
-                    'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
401
-                ),
402
-            ),
403
-        );
404
-
405
-        if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups',
406
-            'espresso_registration_form_trash_question_groups')
407
-        ) {
408
-            $this->_views['trash'] = array(
409
-                'slug'        => 'trash',
410
-                'label'       => esc_html__('Trash', 'event_espresso'),
411
-                'count'       => 0,
412
-                'bulk_action' => array(
413
-                    'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
414
-                    'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
415
-                ),
416
-            );
417
-        }
418
-    }
419
-
420
-
421
-    protected function _questions_overview_list_table()
422
-    {
423
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
424
-                'add_question',
425
-                'add_question',
426
-                array(),
427
-                'add-new-h2'
428
-            );
429
-        parent::_questions_overview_list_table();
430
-    }
431
-
432
-
433
-    protected function _question_groups_overview_list_table()
434
-    {
435
-        $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
436
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
437
-                'add_question_group',
438
-                'add_question_group',
439
-                array(),
440
-                'add-new-h2'
441
-            );
442
-        $this->display_admin_list_table_page_with_sidebar();
443
-    }
444
-
445
-
446
-    protected function _delete_question()
447
-    {
448
-        $success = $this->_delete_items($this->_question_model);
449
-        $this->_redirect_after_action(
450
-            $success,
451
-            $this->_question_model->item_name($success),
452
-            'deleted',
453
-            array('action' => 'default', 'status' => 'all')
454
-        );
455
-    }
456
-
457
-
458
-    protected function _delete_questions()
459
-    {
460
-        $success = $this->_delete_items($this->_question_model);
461
-        $this->_redirect_after_action(
462
-            $success,
463
-            $this->_question_model->item_name($success),
464
-            'deleted permanently',
465
-            array('action' => 'default', 'status' => 'trash')
466
-        );
467
-    }
468
-
469
-
470
-    /**
471
-     * Performs the deletion of a single or multiple questions or question groups.
472
-     *
473
-     * @param EEM_Soft_Delete_Base $model
474
-     * @return int number of items deleted permanently
475
-     */
476
-    private function _delete_items(EEM_Soft_Delete_Base $model)
477
-    {
478
-        $success = 0;
479
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481
-            // if array has more than one element than success message should be plural
482
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483
-            // cycle thru bulk action checkboxes
484
-            while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
-                if (! $this->_delete_item($ID, $model)) {
486
-                    $success = 0;
487
-                }
488
-            }
489
-
490
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
491
-            $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492
-
493
-        } elseif (! empty($this->_req_data['QST_ID'])) {
494
-            $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495
-        } else {
496
-            EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
497
-                "event_espresso")), __FILE__, __FUNCTION__, __LINE__);
498
-        }
499
-        return $success;
500
-    }
501
-
502
-    /**
503
-     * Deletes the specified question (and its associated question options) or question group
504
-     *
505
-     * @param int                  $id
506
-     * @param EEM_Soft_Delete_Base $model
507
-     * @return boolean
508
-     */
509
-    protected function _delete_item($id, $model)
510
-    {
511
-        if ($model instanceof EEM_Question) {
512
-            EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
513
-        }
514
-        return $model->delete_permanently_by_ID(absint($id));
515
-    }
516
-
517
-
518
-    /******************************    QUESTION GROUPS    ******************************/
519
-
520
-
521
-    protected function _edit_question_group($type = 'add')
522
-    {
523
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
524
-        $ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : false;
525
-
526
-        switch ($this->_req_action) {
527
-            case 'add_question_group' :
528
-                $this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
529
-                break;
530
-            case 'edit_question_group' :
531
-                $this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
532
-                break;
533
-            default :
534
-                $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
535
-        }
536
-        // add ID to title if editing
537
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
538
-        if ($ID) {
539
-            /** @var EE_Question_Group $questionGroup */
540
-            $questionGroup            = $this->_question_group_model->get_one_by_ID($ID);
541
-            $additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
542
-            $this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
543
-        } else {
544
-            /** @var EE_Question_Group $questionGroup */
545
-            $questionGroup = EEM_Question_Group::instance()->create_default_object();
546
-            $questionGroup->set_order_to_latest();
547
-            $this->_set_add_edit_form_tags('insert_question_group');
548
-        }
549
-        $this->_template_args['values']         = $this->_yes_no_values;
550
-        $this->_template_args['all_questions']  = $questionGroup->questions_in_and_not_in_group();
551
-        $this->_template_args['QSG_ID']         = $ID ? $ID : true;
552
-        $this->_template_args['question_group'] = $questionGroup;
553
-
554
-        $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
555
-        $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
556
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
557
-            $this->_template_args, true);
558
-
559
-        // the details template wrapper
560
-        $this->display_admin_page_with_sidebar();
561
-    }
562
-
563
-
564
-    protected function _delete_question_groups()
565
-    {
566
-        $success = $this->_delete_items($this->_question_group_model);
567
-        $this->_redirect_after_action($success, $this->_question_group_model->item_name($success),
568
-            'deleted permanently', array('action' => 'question_groups', 'status' => 'trash'));
569
-    }
570
-
571
-
572
-    /**
573
-     * @param bool $new_question_group
574
-     */
575
-    protected function _insert_or_update_question_group($new_question_group = true)
576
-    {
577
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
578
-        $set_column_values = $this->_set_column_values_for($this->_question_group_model);
579
-        if ($new_question_group) {
580
-            $QSG_ID  = $this->_question_group_model->insert($set_column_values);
581
-            $success = $QSG_ID ? 1 : 0;
582
-        } else {
583
-            $QSG_ID = absint($this->_req_data['QSG_ID']);
584
-            unset($set_column_values['QSG_ID']);
585
-            $success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
586
-        }
587
-        $phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
588
-        // update the existing related questions
589
-        // BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
590
-        if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
591
-            // delete where QST ID = system phone question ID and Question Group ID is NOT this group
592
-            EEM_Question_Group_Question::instance()->delete(array(
593
-                array(
594
-                    'QST_ID' => $phone_question_id,
595
-                    'QSG_ID' => array('!=', $QSG_ID),
596
-                ),
597
-            ));
598
-        }
599
-        /** @type EE_Question_Group $question_group */
600
-        $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
601
-        $questions      = $question_group->questions();
602
-        // make sure system phone question is added to list of questions for this group
603
-        if (! isset($questions[$phone_question_id])) {
604
-            $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
605
-        }
606
-
607
-        foreach ($questions as $question_ID => $question) {
608
-            // first we always check for order.
609
-            if (! empty($this->_req_data['question_orders'][$question_ID])) {
610
-                //update question order
611
-                $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
612
-            }
613
-
614
-            // then we always check if adding or removing.
615
-            if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
616
-                $question_group->add_question($question_ID);
617
-            } else {
618
-                // not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
619
-                if (
620
-                in_array(
621
-                    $question->system_ID(),
622
-                    EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
623
-                )
624
-                ) {
625
-                    continue;
626
-                } else {
627
-                    $question_group->remove_question($question_ID);
628
-                }
629
-            }
630
-        }
631
-        // save new related questions
632
-        if (isset($this->_req_data['questions'])) {
633
-            foreach ($this->_req_data['questions'] as $QST_ID) {
634
-                $question_group->add_question($QST_ID);
635
-                if (isset($this->_req_data['question_orders'][$QST_ID])) {
636
-                    $question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
637
-                }
638
-            }
639
-        }
640
-
641
-        if ($success !== false) {
642
-            $msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'),
643
-                $this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated',
644
-                'event_espresso'), $this->_question_group_model->item_name());
645
-            EE_Error::add_success($msg);
646
-        }
647
-        $this->_redirect_after_action(false, '', '', array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
648
-            true);
649
-
650
-    }
651
-
652
-    /**
653
-     * duplicates a question and all its question options and redirects to the new question.
654
-     */
655
-    public function _duplicate_question()
656
-    {
657
-        $question_ID = (int)$this->_req_data['QST_ID'];
658
-        $question    = EEM_Question::instance()->get_one_by_ID($question_ID);
659
-        if ($question instanceof EE_Question) {
660
-            $new_question = $question->duplicate();
661
-            if ($new_question instanceof EE_Question) {
662
-                $this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'),
663
-                    esc_html__('Duplicated', 'event_espresso'),
664
-                    array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), true);
665
-            } else {
666
-                global $wpdb;
667
-                EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s',
668
-                    'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
669
-                $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
670
-            }
671
-        } else {
672
-            EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!',
673
-                'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
674
-            $this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
675
-        }
676
-    }
677
-
678
-
679
-    /**
680
-     * @param bool $trash
681
-     */
682
-    protected function _trash_or_restore_question_groups($trash = true)
683
-    {
684
-        $this->_trash_or_restore_items($this->_question_group_model, $trash);
685
-    }
686
-
687
-
688
-    /**
689
-     *_trash_question
690
-     */
691
-    protected function _trash_question()
692
-    {
693
-        $success    = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']);
694
-        $query_args = array('action' => 'default', 'status' => 'all');
695
-        $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
696
-    }
697
-
698
-
699
-    /**
700
-     * @param bool $trash
701
-     */
702
-    protected function _trash_or_restore_questions($trash = true)
703
-    {
704
-        $this->_trash_or_restore_items($this->_question_model, $trash);
705
-    }
706
-
707
-
708
-    /**
709
-     * Internally used to delete or restore items, using the request data. Meant to be
710
-     * flexible between question or question groups
711
-     *
712
-     * @param EEM_Soft_Delete_Base $model
713
-     * @param boolean              $trash whether to trash or restore
714
-     */
715
-    private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
716
-    {
717
-
718
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
719
-
720
-        $success = 1;
721
-        //Checkboxes
722
-        //echo "trash $trash";
723
-        //var_dump($this->_req_data['checkbox']);die;
724
-        if (isset($this->_req_data['checkbox'])) {
725
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
726
-                // if array has more than one element than success message should be plural
727
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
728
-                // cycle thru bulk action checkboxes
729
-                while (list($ID, $value) = each($this->_req_data['checkbox'])) {
730
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
731
-                        $success = 0;
732
-                    }
733
-                }
734
-
735
-            } else {
736
-                // grab single id and delete
737
-                $ID = absint($this->_req_data['checkbox']);
738
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
739
-                    $success = 0;
740
-                }
741
-            }
742
-
743
-        } else {
744
-            // delete via trash link
745
-            // grab single id and delete
746
-            $ID = absint($this->_req_data[$model->primary_key_name()]);
747
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
748
-                $success = 0;
749
-            }
750
-
751
-        }
752
-
753
-
754
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
755
-        //echo "action :$action";
756
-        //$action = 'questions' ? 'default' : $action;
757
-        if ($trash) {
758
-            $action_desc = 'trashed';
759
-            $status      = 'trash';
760
-        } else {
761
-            $action_desc = 'restored';
762
-            $status      = 'all';
763
-        }
764
-        $this->_redirect_after_action($success, $model->item_name($success), $action_desc,
765
-            array('action' => $action, 'status' => $status));
766
-    }
767
-
768
-
769
-    /**
770
-     * @param            $per_page
771
-     * @param int        $current_page
772
-     * @param bool|false $count
773
-     * @return \EE_Soft_Delete_Base_Class[]|int
774
-     */
775
-    public function get_trashed_questions($per_page, $current_page = 1, $count = false)
776
-    {
777
-        $query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
778
-
779
-        if ($count) {
780
-            //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
781
-            $where   = isset($query_params[0]) ? array($query_params[0]) : array();
782
-            $results = $this->_question_model->count_deleted($where);
783
-        } else {
784
-            //note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
785
-            $results = $this->_question_model->get_all_deleted($query_params);
786
-        }
787
-        return $results;
788
-    }
789
-
790
-
791
-    /**
792
-     * @param            $per_page
793
-     * @param int        $current_page
794
-     * @param bool|false $count
795
-     * @return \EE_Soft_Delete_Base_Class[]
796
-     */
797
-    public function get_question_groups($per_page, $current_page = 1, $count = false)
798
-    {
799
-        $questionGroupModel = EEM_Question_Group::instance();
800
-        $query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
801
-        if ($count) {
802
-            $where   = isset($query_params[0]) ? array($query_params[0]) : array();
803
-            $results = $questionGroupModel->count($where);
804
-        } else {
805
-            $results = $questionGroupModel->get_all($query_params);
806
-        }
807
-        return $results;
808
-    }
809
-
810
-
811
-    /**
812
-     * @param      $per_page
813
-     * @param int  $current_page
814
-     * @param bool $count
815
-     * @return \EE_Soft_Delete_Base_Class[]|int
816
-     */
817
-    public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
818
-    {
819
-        $questionGroupModel = EEM_Question_Group::instance();
820
-        $query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
821
-        if ($count) {
822
-            $where                 = isset($query_params[0]) ? array($query_params[0]) : array();
823
-            $query_params['limit'] = null;
824
-            $results               = $questionGroupModel->count_deleted($where);
825
-        } else {
826
-            $results = $questionGroupModel->get_all_deleted($query_params);
827
-        }
828
-        return $results;
829
-    }
830
-
831
-
832
-    /**
833
-     * method for performing updates to question order
834
-     *
835
-     * @return array results array
836
-     */
837
-    public function update_question_group_order()
838
-    {
839
-
840
-        $success = esc_html__('Question group order was updated successfully.', 'event_espresso');
841
-
842
-        // grab our row IDs
843
-        $row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
844
-            ? explode(',', rtrim($this->_req_data['row_ids'], ','))
845
-            : array();
846
-
847
-        $perpage = ! empty($this->_req_data['perpage'])
848
-            ? (int)$this->_req_data['perpage']
849
-            : null;
850
-        $curpage = ! empty($this->_req_data['curpage'])
851
-            ? (int)$this->_req_data['curpage']
852
-            : null;
853
-
854
-        if (! empty($row_ids)) {
855
-            //figure out where we start the row_id count at for the current page.
856
-            $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
857
-
858
-            $row_count = count($row_ids);
859
-            for ($i = 0; $i < $row_count; $i++) {
860
-                //Update the questions when re-ordering
861
-                $updated = EEM_Question_Group::instance()->update(
862
-                    array('QSG_order' => $qsgcount),
863
-                    array(array('QSG_ID' => $row_ids[$i]))
864
-                );
865
-                if ($updated === false) {
866
-                    $success = false;
867
-                }
868
-                $qsgcount++;
869
-            }
870
-        } else {
871
-            $success = false;
872
-        }
873
-
874
-        $errors = ! $success
875
-            ? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
876
-            : false;
877
-
878
-        echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
879
-        die();
880
-
881
-    }
882
-
883
-
884
-
885
-    /***************************************        REGISTRATION SETTINGS        ***************************************/
886
-
887
-
888
-    /**
889
-     * _reg_form_settings
890
-     *
891
-     * @throws \EE_Error
892
-     */
893
-    protected function _reg_form_settings()
894
-    {
895
-        $this->_template_args['values'] = $this->_yes_no_values;
896
-        add_action(
897
-            'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
898
-            array($this, 'email_validation_settings_form'),
899
-            2
900
-        );
901
-        $this->_template_args = (array)apply_filters(
902
-            'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
903
-            $this->_template_args
904
-        );
905
-        $this->_set_add_edit_form_tags('update_reg_form_settings');
906
-        $this->_set_publish_post_box_vars(null, false, false, null, false);
907
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
909
-            $this->_template_args,
910
-            true
911
-        );
912
-        $this->display_admin_page_with_sidebar();
913
-    }
914
-
915
-
916
-    /**
917
-     * _update_reg_form_settings
918
-     */
919
-    protected function _update_reg_form_settings()
920
-    {
921
-        EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
922
-            EE_Registry::instance()->CFG->registration
923
-        );
924
-        EE_Registry::instance()->CFG->registration = apply_filters(
925
-            'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
926
-            EE_Registry::instance()->CFG->registration
927
-        );
928
-        $success                                   = $this->_update_espresso_configuration(
929
-            esc_html__('Registration Form Options', 'event_espresso'),
930
-            EE_Registry::instance()->CFG,
931
-            __FILE__, __FUNCTION__, __LINE__
932
-        );
933
-        $this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated',
934
-            array('action' => 'view_reg_form_settings'));
935
-    }
936
-
937
-
938
-    /**
939
-     * email_validation_settings_form
940
-     *
941
-     * @access    public
942
-     * @return    void
943
-     * @throws \EE_Error
944
-     */
945
-    public function email_validation_settings_form()
946
-    {
947
-        echo $this->_email_validation_settings_form()->get_html();
948
-    }
949
-
950
-
951
-    /**
952
-     * _email_validation_settings_form
953
-     *
954
-     * @access protected
955
-     * @return EE_Form_Section_Proper
956
-     * @throws \EE_Error
957
-     */
958
-    protected function _email_validation_settings_form()
959
-    {
960
-        return new EE_Form_Section_Proper(
961
-            array(
962
-                'name'            => 'email_validation_settings',
963
-                'html_id'         => 'email_validation_settings',
964
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
965
-                'subsections'     => array(
966
-                    'email_validation_hdr'   => new EE_Form_Section_HTML(
967
-                        EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
968
-                    ),
969
-                    'email_validation_level' => new EE_Select_Input(
970
-                        array(
971
-                            'basic'      => esc_html__('Basic', 'event_espresso'),
972
-                            'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
973
-                            'i18n'       => esc_html__('International', 'event_espresso'),
974
-                            'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
975
-                        ),
976
-                        array(
977
-                            'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
978
-                                                 . EEH_Template::get_help_tab_link('email_validation_info'),
979
-                            'html_help_text'  => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
980
-                                'event_espresso'),
981
-                            'default'         => isset(EE_Registry::instance()->CFG->registration->email_validation_level)
982
-                                ? EE_Registry::instance()->CFG->registration->email_validation_level
983
-                                : 'wp_default',
984
-                            'required'        => false,
985
-                        )
986
-                    ),
987
-                ),
988
-            )
989
-        );
990
-    }
991
-
992
-
993
-    /**
994
-     * update_email_validation_settings_form
995
-     *
996
-     * @access    public
997
-     * @param \EE_Registration_Config $EE_Registration_Config
998
-     * @return \EE_Registration_Config
999
-     */
1000
-    public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1001
-    {
1002
-        $prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1003
-        try {
1004
-            $email_validation_settings_form = $this->_email_validation_settings_form();
1005
-            // if not displaying a form, then check for form submission
1006
-            if ($email_validation_settings_form->was_submitted()) {
1007
-                // capture form data
1008
-                $email_validation_settings_form->receive_form_submission();
1009
-                // validate form data
1010
-                if ($email_validation_settings_form->is_valid()) {
1011
-                    // grab validated data from form
1012
-                    $valid_data = $email_validation_settings_form->valid_data();
1013
-                    if (isset($valid_data['email_validation_level'])) {
1014
-                        $email_validation_level = $valid_data['email_validation_level'];
1015
-                        // now if they want to use international email addresses
1016
-                        if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1017
-                            // in case we need to reset their email validation level,
1018
-                            // make sure that the previous value wasn't already set to one of the i18n options.
1019
-                            if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1020
-                                // if so, then reset it back to "basic" since that is the only other option that,
1021
-                                // despite offering poor validation, supports i18n email addresses
1022
-                                $prev_email_validation_level = 'basic';
1023
-                            }
1024
-                            // confirm our i18n email validation will work on the server
1025
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1026
-                                // or reset email validation level to previous value
1027
-                                $email_validation_level = $prev_email_validation_level;
1028
-                            }
1029
-                        }
1030
-                        $EE_Registration_Config->email_validation_level = $email_validation_level;
1031
-                    } else {
1032
-                        EE_Error::add_error(
1033
-                            esc_html__(
1034
-                                'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1035
-                                'event_espresso'
1036
-                            ),
1037
-                            __FILE__, __FUNCTION__, __LINE__
1038
-                        );
1039
-                    }
1040
-                } else {
1041
-                    if ($email_validation_settings_form->submission_error_message() !== '') {
1042
-                        EE_Error::add_error(
1043
-                            $email_validation_settings_form->submission_error_message(),
1044
-                            __FILE__, __FUNCTION__, __LINE__
1045
-                        );
1046
-                    }
1047
-                }
1048
-            }
1049
-        } catch (EE_Error $e) {
1050
-            $e->get_error();
1051
-        }
1052
-        return $EE_Registration_Config;
1053
-    }
1054
-
1055
-
1056
-    /**
1057
-     * confirms that the server's PHP version has the PCRE module enabled,
1058
-     * and that the PCRE version works with our i18n email validation
1059
-     *
1060
-     * @param \EE_Registration_Config $EE_Registration_Config
1061
-     * @param string                  $email_validation_level
1062
-     * @return bool
1063
-     */
1064
-    private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1065
-    {
1066
-        // first check that PCRE is enabled
1067
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1068
-            EE_Error::add_error(
1069
-                sprintf(
1070
-                    esc_html__(
1071
-                        'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1072
-                        'event_espresso'
1073
-                    ),
1074
-                    '<br />'
1075
-                ),
1076
-                __FILE__,
1077
-                __FUNCTION__,
1078
-                __LINE__
1079
-            );
1080
-            return false;
1081
-        } else {
1082
-            // PCRE support is enabled, but let's still
1083
-            // perform a test to see if the server will support it.
1084
-            // but first, save the updated validation level to the config,
1085
-            // so that the validation strategy picks it up.
1086
-            // this will get bumped back down if it doesn't work
1087
-            $EE_Registration_Config->email_validation_level = $email_validation_level;
1088
-            try {
1089
-                $email_validator    = new EE_Email_Validation_Strategy();
1090
-                $i18n_email_address = apply_filters(
1091
-                    'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1092
-                    'jägerjü[email protected]'
1093
-                );
1094
-                $email_validator->validate($i18n_email_address);
1095
-            } catch (Exception $e) {
1096
-                EE_Error::add_error(
1097
-                    sprintf(
1098
-                        esc_html__(
1099
-                            'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1100
-                            'event_espresso'
1101
-                        ),
1102
-                        '<br />',
1103
-                        '<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>'
1104
-                    ),
1105
-                    __FILE__, __FUNCTION__, __LINE__
1106
-                );
1107
-                return false;
1108
-            }
1109
-        }
1110
-        return true;
1111
-    }
28
+	/**
29
+	 * @Constructor
30
+	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
31
+	 * @access public
32
+	 */
33
+	public function __construct($routing = true)
34
+	{
35
+		define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS);
36
+		define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS);
37
+		define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
38
+		define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS);
39
+		define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
40
+		parent::__construct($routing);
41
+	}
42
+
43
+
44
+	protected function _extend_page_config()
45
+	{
46
+		$this->_admin_base_path = REGISTRATION_FORM_CAF_ADMIN;
47
+		$qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
48
+		$qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
49
+
50
+		$new_page_routes    = array(
51
+			'question_groups'    => array(
52
+				'func'       => '_question_groups_overview_list_table',
53
+				'capability' => 'ee_read_question_groups',
54
+			),
55
+			'add_question'       => array(
56
+				'func'       => '_edit_question',
57
+				'capability' => 'ee_edit_questions',
58
+			),
59
+			'insert_question'    => array(
60
+				'func'       => '_insert_or_update_question',
61
+				'args'       => array('new_question' => true),
62
+				'capability' => 'ee_edit_questions',
63
+				'noheader'   => true,
64
+			),
65
+			'duplicate_question' => array(
66
+				'func'       => '_duplicate_question',
67
+				'capability' => 'ee_edit_questions',
68
+				'noheader'   => true,
69
+			),
70
+			'trash_question'     => array(
71
+				'func'       => '_trash_question',
72
+				'capability' => 'ee_delete_question',
73
+				'obj_id'     => $qst_id,
74
+				'noheader'   => true,
75
+			),
76
+
77
+			'restore_question' => array(
78
+				'func'       => '_trash_or_restore_questions',
79
+				'capability' => 'ee_delete_question',
80
+				'obj_id'     => $qst_id,
81
+				'args'       => array('trash' => false),
82
+				'noheader'   => true,
83
+			),
84
+
85
+			'delete_question' => array(
86
+				'func'       => '_delete_question',
87
+				'capability' => 'ee_delete_question',
88
+				'obj_id'     => $qst_id,
89
+				'noheader'   => true,
90
+			),
91
+
92
+			'trash_questions' => array(
93
+				'func'       => '_trash_or_restore_questions',
94
+				'capability' => 'ee_delete_questions',
95
+				'args'       => array('trash' => true),
96
+				'noheader'   => true,
97
+			),
98
+
99
+			'restore_questions' => array(
100
+				'func'       => '_trash_or_restore_questions',
101
+				'capability' => 'ee_delete_questions',
102
+				'args'       => array('trash' => false),
103
+				'noheader'   => true,
104
+			),
105
+
106
+			'delete_questions' => array(
107
+				'func'       => '_delete_questions',
108
+				'args'       => array(),
109
+				'capability' => 'ee_delete_questions',
110
+				'noheader'   => true,
111
+			),
112
+
113
+			'add_question_group' => array(
114
+				'func'       => '_edit_question_group',
115
+				'capability' => 'ee_edit_question_groups',
116
+			),
117
+
118
+			'edit_question_group' => array(
119
+				'func'       => '_edit_question_group',
120
+				'capability' => 'ee_edit_question_group',
121
+				'obj_id'     => $qsg_id,
122
+				'args'       => array('edit'),
123
+			),
124
+
125
+			'delete_question_groups' => array(
126
+				'func'       => '_delete_question_groups',
127
+				'capability' => 'ee_delete_question_groups',
128
+				'noheader'   => true,
129
+			),
130
+
131
+			'delete_question_group' => array(
132
+				'func'       => '_delete_question_groups',
133
+				'capability' => 'ee_delete_question_group',
134
+				'obj_id'     => $qsg_id,
135
+				'noheader'   => true,
136
+			),
137
+
138
+			'trash_question_group' => array(
139
+				'func'       => '_trash_or_restore_question_groups',
140
+				'args'       => array('trash' => true),
141
+				'capability' => 'ee_delete_question_group',
142
+				'obj_id'     => $qsg_id,
143
+				'noheader'   => true,
144
+			),
145
+
146
+			'restore_question_group' => array(
147
+				'func'       => '_trash_or_restore_question_groups',
148
+				'args'       => array('trash' => false),
149
+				'capability' => 'ee_delete_question_group',
150
+				'obj_id'     => $qsg_id,
151
+				'noheader'   => true,
152
+			),
153
+
154
+			'insert_question_group' => array(
155
+				'func'       => '_insert_or_update_question_group',
156
+				'args'       => array('new_question_group' => true),
157
+				'capability' => 'ee_edit_question_groups',
158
+				'noheader'   => true,
159
+			),
160
+
161
+			'update_question_group' => array(
162
+				'func'       => '_insert_or_update_question_group',
163
+				'args'       => array('new_question_group' => false),
164
+				'capability' => 'ee_edit_question_group',
165
+				'obj_id'     => $qsg_id,
166
+				'noheader'   => true,
167
+			),
168
+
169
+			'trash_question_groups' => array(
170
+				'func'       => '_trash_or_restore_question_groups',
171
+				'args'       => array('trash' => true),
172
+				'capability' => 'ee_delete_question_groups',
173
+				'noheader'   => array('trash' => false),
174
+			),
175
+
176
+			'restore_question_groups' => array(
177
+				'func'       => '_trash_or_restore_question_groups',
178
+				'args'       => array('trash' => false),
179
+				'capability' => 'ee_delete_question_groups',
180
+				'noheader'   => true,
181
+			),
182
+
183
+
184
+			'espresso_update_question_group_order' => array(
185
+				'func'       => 'update_question_group_order',
186
+				'capability' => 'ee_edit_question_groups',
187
+				'noheader'   => true,
188
+			),
189
+
190
+			'view_reg_form_settings' => array(
191
+				'func'       => '_reg_form_settings',
192
+				'capability' => 'manage_options',
193
+			),
194
+
195
+			'update_reg_form_settings' => array(
196
+				'func'       => '_update_reg_form_settings',
197
+				'capability' => 'manage_options',
198
+				'noheader'   => true,
199
+			),
200
+		);
201
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
202
+
203
+		$new_page_config    = array(
204
+
205
+			'question_groups' => array(
206
+				'nav'           => array(
207
+					'label' => esc_html__('Question Groups', 'event_espresso'),
208
+					'order' => 20,
209
+				),
210
+				'list_table'    => 'Registration_Form_Question_Groups_Admin_List_Table',
211
+				'help_tabs'     => array(
212
+					'registration_form_question_groups_help_tab'                           => array(
213
+						'title'    => esc_html__('Question Groups', 'event_espresso'),
214
+						'filename' => 'registration_form_question_groups',
215
+					),
216
+					'registration_form_question_groups_table_column_headings_help_tab'     => array(
217
+						'title'    => esc_html__('Question Groups Table Column Headings', 'event_espresso'),
218
+						'filename' => 'registration_form_question_groups_table_column_headings',
219
+					),
220
+					'registration_form_question_groups_views_bulk_actions_search_help_tab' => array(
221
+						'title'    => esc_html__('Question Groups Views & Bulk Actions & Search', 'event_espresso'),
222
+						'filename' => 'registration_form_question_groups_views_bulk_actions_search',
223
+					),
224
+				),
225
+				'help_tour'     => array('Registration_Form_Question_Groups_Help_Tour'),
226
+				'metaboxes'     => $this->_default_espresso_metaboxes,
227
+				'require_nonce' => false,
228
+				'qtips'         => array(
229
+					'EE_Registration_Form_Tips',
230
+				),
231
+			),
232
+
233
+			'add_question' => array(
234
+				'nav'           => array(
235
+					'label'      => esc_html__('Add Question', 'event_espresso'),
236
+					'order'      => 5,
237
+					'persistent' => false,
238
+				),
239
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
240
+				'help_tabs'     => array(
241
+					'registration_form_add_question_help_tab' => array(
242
+						'title'    => esc_html__('Add Question', 'event_espresso'),
243
+						'filename' => 'registration_form_add_question',
244
+					),
245
+				),
246
+				'help_tour'     => array('Registration_Form_Add_Question_Help_Tour'),
247
+				'require_nonce' => false,
248
+			),
249
+
250
+			'add_question_group' => array(
251
+				'nav'           => array(
252
+					'label'      => esc_html__('Add Question Group', 'event_espresso'),
253
+					'order'      => 5,
254
+					'persistent' => false,
255
+				),
256
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
257
+				'help_tabs'     => array(
258
+					'registration_form_add_question_group_help_tab' => array(
259
+						'title'    => esc_html__('Add Question Group', 'event_espresso'),
260
+						'filename' => 'registration_form_add_question_group',
261
+					),
262
+				),
263
+				'help_tour'     => array('Registration_Form_Add_Question_Group_Help_Tour'),
264
+				'require_nonce' => false,
265
+			),
266
+
267
+			'edit_question_group' => array(
268
+				'nav'           => array(
269
+					'label'      => esc_html__('Edit Question Group', 'event_espresso'),
270
+					'order'      => 5,
271
+					'persistent' => false,
272
+					'url'        => isset($this->_req_data['question_group_id']) ? add_query_arg(array('question_group_id' => $this->_req_data['question_group_id']),
273
+						$this->_current_page_view_url) : $this->_admin_base_url,
274
+				),
275
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
276
+				'help_tabs'     => array(
277
+					'registration_form_edit_question_group_help_tab' => array(
278
+						'title'    => esc_html__('Edit Question Group', 'event_espresso'),
279
+						'filename' => 'registration_form_edit_question_group',
280
+					),
281
+				),
282
+				'help_tour'     => array('Registration_Form_Edit_Question_Group_Help_Tour'),
283
+				'require_nonce' => false,
284
+			),
285
+
286
+			'view_reg_form_settings' => array(
287
+				'nav'           => array(
288
+					'label' => esc_html__('Reg Form Settings', 'event_espresso'),
289
+					'order' => 40,
290
+				),
291
+				'labels'        => array(
292
+					'publishbox' => esc_html__('Update Settings', 'event_espresso'),
293
+				),
294
+				'metaboxes'     => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
295
+				'help_tabs'     => array(
296
+					'registration_form_reg_form_settings_help_tab' => array(
297
+						'title'    => esc_html__('Registration Form Settings', 'event_espresso'),
298
+						'filename' => 'registration_form_reg_form_settings',
299
+					),
300
+				),
301
+				'help_tour'     => array('Registration_Form_Settings_Help_Tour'),
302
+				'require_nonce' => false,
303
+			),
304
+
305
+		);
306
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
307
+
308
+		//change the list table we're going to use so it's the NEW list table!
309
+		$this->_page_config['default']['list_table'] = 'Extend_Registration_Form_Questions_Admin_List_Table';
310
+
311
+
312
+		//additional labels
313
+		$new_labels               = array(
314
+			'add_question'          => esc_html__('Add New Question', 'event_espresso'),
315
+			'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
316
+			'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
317
+			'edit_question_group'   => esc_html__('Edit Question Group', 'event_espresso'),
318
+			'delete_question_group' => esc_html__('Delete Question Group', 'event_espresso'),
319
+		);
320
+		$this->_labels['buttons'] = array_merge($this->_labels['buttons'], $new_labels);
321
+
322
+	}
323
+
324
+
325
+	protected function _ajax_hooks()
326
+	{
327
+		add_action('wp_ajax_espresso_update_question_group_order', array($this, 'update_question_group_order'));
328
+	}
329
+
330
+
331
+	public function load_scripts_styles_question_groups()
332
+	{
333
+		wp_enqueue_script('espresso_ajax_table_sorting');
334
+	}
335
+
336
+
337
+	public function load_scripts_styles_add_question_group()
338
+	{
339
+		$this->load_scripts_styles_forms();
340
+		$this->load_sortable_question_script();
341
+	}
342
+
343
+	public function load_scripts_styles_edit_question_group()
344
+	{
345
+		$this->load_scripts_styles_forms();
346
+		$this->load_sortable_question_script();
347
+	}
348
+
349
+
350
+	/**
351
+	 * registers and enqueues script for questions
352
+	 *
353
+	 * @return void
354
+	 */
355
+	public function load_sortable_question_script()
356
+	{
357
+		wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
358
+			array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359
+		wp_enqueue_script('ee-question-sortable');
360
+	}
361
+
362
+
363
+	protected function _set_list_table_views_default()
364
+	{
365
+		$this->_views = array(
366
+			'all' => array(
367
+				'slug'        => 'all',
368
+				'label'       => esc_html__('View All Questions', 'event_espresso'),
369
+				'count'       => 0,
370
+				'bulk_action' => array(
371
+					'trash_questions' => esc_html__('Trash', 'event_espresso'),
372
+				),
373
+			),
374
+		);
375
+
376
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_questions',
377
+			'espresso_registration_form_trash_questions')
378
+		) {
379
+			$this->_views['trash'] = array(
380
+				'slug'        => 'trash',
381
+				'label'       => esc_html__('Trash', 'event_espresso'),
382
+				'count'       => 0,
383
+				'bulk_action' => array(
384
+					'delete_questions'  => esc_html__('Delete Permanently', 'event_espresso'),
385
+					'restore_questions' => esc_html__('Restore', 'event_espresso'),
386
+				),
387
+			);
388
+		}
389
+	}
390
+
391
+
392
+	protected function _set_list_table_views_question_groups()
393
+	{
394
+		$this->_views = array(
395
+			'all' => array(
396
+				'slug'        => 'all',
397
+				'label'       => esc_html__('All', 'event_espresso'),
398
+				'count'       => 0,
399
+				'bulk_action' => array(
400
+					'trash_question_groups' => esc_html__('Trash', 'event_espresso'),
401
+				),
402
+			),
403
+		);
404
+
405
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_question_groups',
406
+			'espresso_registration_form_trash_question_groups')
407
+		) {
408
+			$this->_views['trash'] = array(
409
+				'slug'        => 'trash',
410
+				'label'       => esc_html__('Trash', 'event_espresso'),
411
+				'count'       => 0,
412
+				'bulk_action' => array(
413
+					'delete_question_groups'  => esc_html__('Delete Permanently', 'event_espresso'),
414
+					'restore_question_groups' => esc_html__('Restore', 'event_espresso'),
415
+				),
416
+			);
417
+		}
418
+	}
419
+
420
+
421
+	protected function _questions_overview_list_table()
422
+	{
423
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
424
+				'add_question',
425
+				'add_question',
426
+				array(),
427
+				'add-new-h2'
428
+			);
429
+		parent::_questions_overview_list_table();
430
+	}
431
+
432
+
433
+	protected function _question_groups_overview_list_table()
434
+	{
435
+		$this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
436
+		$this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
437
+				'add_question_group',
438
+				'add_question_group',
439
+				array(),
440
+				'add-new-h2'
441
+			);
442
+		$this->display_admin_list_table_page_with_sidebar();
443
+	}
444
+
445
+
446
+	protected function _delete_question()
447
+	{
448
+		$success = $this->_delete_items($this->_question_model);
449
+		$this->_redirect_after_action(
450
+			$success,
451
+			$this->_question_model->item_name($success),
452
+			'deleted',
453
+			array('action' => 'default', 'status' => 'all')
454
+		);
455
+	}
456
+
457
+
458
+	protected function _delete_questions()
459
+	{
460
+		$success = $this->_delete_items($this->_question_model);
461
+		$this->_redirect_after_action(
462
+			$success,
463
+			$this->_question_model->item_name($success),
464
+			'deleted permanently',
465
+			array('action' => 'default', 'status' => 'trash')
466
+		);
467
+	}
468
+
469
+
470
+	/**
471
+	 * Performs the deletion of a single or multiple questions or question groups.
472
+	 *
473
+	 * @param EEM_Soft_Delete_Base $model
474
+	 * @return int number of items deleted permanently
475
+	 */
476
+	private function _delete_items(EEM_Soft_Delete_Base $model)
477
+	{
478
+		$success = 0;
479
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
+		if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481
+			// if array has more than one element than success message should be plural
482
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483
+			// cycle thru bulk action checkboxes
484
+			while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
+				if (! $this->_delete_item($ID, $model)) {
486
+					$success = 0;
487
+				}
488
+			}
489
+
490
+		} elseif (! empty($this->_req_data['QSG_ID'])) {
491
+			$success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492
+
493
+		} elseif (! empty($this->_req_data['QST_ID'])) {
494
+			$success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495
+		} else {
496
+			EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
497
+				"event_espresso")), __FILE__, __FUNCTION__, __LINE__);
498
+		}
499
+		return $success;
500
+	}
501
+
502
+	/**
503
+	 * Deletes the specified question (and its associated question options) or question group
504
+	 *
505
+	 * @param int                  $id
506
+	 * @param EEM_Soft_Delete_Base $model
507
+	 * @return boolean
508
+	 */
509
+	protected function _delete_item($id, $model)
510
+	{
511
+		if ($model instanceof EEM_Question) {
512
+			EEM_Question_Option::instance()->delete_permanently(array(array('QST_ID' => absint($id))));
513
+		}
514
+		return $model->delete_permanently_by_ID(absint($id));
515
+	}
516
+
517
+
518
+	/******************************    QUESTION GROUPS    ******************************/
519
+
520
+
521
+	protected function _edit_question_group($type = 'add')
522
+	{
523
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
524
+		$ID = isset($this->_req_data['QSG_ID']) && ! empty($this->_req_data['QSG_ID']) ? absint($this->_req_data['QSG_ID']) : false;
525
+
526
+		switch ($this->_req_action) {
527
+			case 'add_question_group' :
528
+				$this->_admin_page_title = esc_html__('Add Question Group', 'event_espresso');
529
+				break;
530
+			case 'edit_question_group' :
531
+				$this->_admin_page_title = esc_html__('Edit Question Group', 'event_espresso');
532
+				break;
533
+			default :
534
+				$this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
535
+		}
536
+		// add ID to title if editing
537
+		$this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
538
+		if ($ID) {
539
+			/** @var EE_Question_Group $questionGroup */
540
+			$questionGroup            = $this->_question_group_model->get_one_by_ID($ID);
541
+			$additional_hidden_fields = array('QSG_ID' => array('type' => 'hidden', 'value' => $ID));
542
+			$this->_set_add_edit_form_tags('update_question_group', $additional_hidden_fields);
543
+		} else {
544
+			/** @var EE_Question_Group $questionGroup */
545
+			$questionGroup = EEM_Question_Group::instance()->create_default_object();
546
+			$questionGroup->set_order_to_latest();
547
+			$this->_set_add_edit_form_tags('insert_question_group');
548
+		}
549
+		$this->_template_args['values']         = $this->_yes_no_values;
550
+		$this->_template_args['all_questions']  = $questionGroup->questions_in_and_not_in_group();
551
+		$this->_template_args['QSG_ID']         = $ID ? $ID : true;
552
+		$this->_template_args['question_group'] = $questionGroup;
553
+
554
+		$redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
555
+		$this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
556
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
557
+			$this->_template_args, true);
558
+
559
+		// the details template wrapper
560
+		$this->display_admin_page_with_sidebar();
561
+	}
562
+
563
+
564
+	protected function _delete_question_groups()
565
+	{
566
+		$success = $this->_delete_items($this->_question_group_model);
567
+		$this->_redirect_after_action($success, $this->_question_group_model->item_name($success),
568
+			'deleted permanently', array('action' => 'question_groups', 'status' => 'trash'));
569
+	}
570
+
571
+
572
+	/**
573
+	 * @param bool $new_question_group
574
+	 */
575
+	protected function _insert_or_update_question_group($new_question_group = true)
576
+	{
577
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
578
+		$set_column_values = $this->_set_column_values_for($this->_question_group_model);
579
+		if ($new_question_group) {
580
+			$QSG_ID  = $this->_question_group_model->insert($set_column_values);
581
+			$success = $QSG_ID ? 1 : 0;
582
+		} else {
583
+			$QSG_ID = absint($this->_req_data['QSG_ID']);
584
+			unset($set_column_values['QSG_ID']);
585
+			$success = $this->_question_group_model->update($set_column_values, array(array('QSG_ID' => $QSG_ID)));
586
+		}
587
+		$phone_question_id = EEM_Question::instance()->get_Question_ID_from_system_string(EEM_Attendee::system_question_phone);
588
+		// update the existing related questions
589
+		// BUT FIRST...  delete the phone question from the Question_Group_Question if it is being added to this question group (therefore removed from the existing group)
590
+		if (isset($this->_req_data['questions'], $this->_req_data['questions'][$phone_question_id])) {
591
+			// delete where QST ID = system phone question ID and Question Group ID is NOT this group
592
+			EEM_Question_Group_Question::instance()->delete(array(
593
+				array(
594
+					'QST_ID' => $phone_question_id,
595
+					'QSG_ID' => array('!=', $QSG_ID),
596
+				),
597
+			));
598
+		}
599
+		/** @type EE_Question_Group $question_group */
600
+		$question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
601
+		$questions      = $question_group->questions();
602
+		// make sure system phone question is added to list of questions for this group
603
+		if (! isset($questions[$phone_question_id])) {
604
+			$questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
605
+		}
606
+
607
+		foreach ($questions as $question_ID => $question) {
608
+			// first we always check for order.
609
+			if (! empty($this->_req_data['question_orders'][$question_ID])) {
610
+				//update question order
611
+				$question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
612
+			}
613
+
614
+			// then we always check if adding or removing.
615
+			if (isset($this->_req_data['questions'], $this->_req_data['questions'][$question_ID])) {
616
+				$question_group->add_question($question_ID);
617
+			} else {
618
+				// not found, remove it (but only if not a system question for the personal group with the exception of lname system question - we allow removal of it)
619
+				if (
620
+				in_array(
621
+					$question->system_ID(),
622
+					EEM_Question::instance()->required_system_questions_in_system_question_group($question_group->system_group())
623
+				)
624
+				) {
625
+					continue;
626
+				} else {
627
+					$question_group->remove_question($question_ID);
628
+				}
629
+			}
630
+		}
631
+		// save new related questions
632
+		if (isset($this->_req_data['questions'])) {
633
+			foreach ($this->_req_data['questions'] as $QST_ID) {
634
+				$question_group->add_question($QST_ID);
635
+				if (isset($this->_req_data['question_orders'][$QST_ID])) {
636
+					$question_group->update_question_order($QST_ID, $this->_req_data['question_orders'][$QST_ID]);
637
+				}
638
+			}
639
+		}
640
+
641
+		if ($success !== false) {
642
+			$msg = $new_question_group ? sprintf(esc_html__('The %s has been created', 'event_espresso'),
643
+				$this->_question_group_model->item_name()) : sprintf(esc_html__('The %s has been updated',
644
+				'event_espresso'), $this->_question_group_model->item_name());
645
+			EE_Error::add_success($msg);
646
+		}
647
+		$this->_redirect_after_action(false, '', '', array('action' => 'edit_question_group', 'QSG_ID' => $QSG_ID),
648
+			true);
649
+
650
+	}
651
+
652
+	/**
653
+	 * duplicates a question and all its question options and redirects to the new question.
654
+	 */
655
+	public function _duplicate_question()
656
+	{
657
+		$question_ID = (int)$this->_req_data['QST_ID'];
658
+		$question    = EEM_Question::instance()->get_one_by_ID($question_ID);
659
+		if ($question instanceof EE_Question) {
660
+			$new_question = $question->duplicate();
661
+			if ($new_question instanceof EE_Question) {
662
+				$this->_redirect_after_action(true, esc_html__('Question', 'event_espresso'),
663
+					esc_html__('Duplicated', 'event_espresso'),
664
+					array('action' => 'edit_question', 'QST_ID' => $new_question->ID()), true);
665
+			} else {
666
+				global $wpdb;
667
+				EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %1$d because: %2$s',
668
+					'event_espresso'), $question_ID, $wpdb->last_error), __FILE__, __FUNCTION__, __LINE__);
669
+				$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
670
+			}
671
+		} else {
672
+			EE_Error::add_error(sprintf(esc_html__('Could not duplicate question with ID %d because it didn\'t exist!',
673
+				'event_espresso'), $question_ID), __FILE__, __FUNCTION__, __LINE__);
674
+			$this->_redirect_after_action(false, '', '', array('action' => 'default'), false);
675
+		}
676
+	}
677
+
678
+
679
+	/**
680
+	 * @param bool $trash
681
+	 */
682
+	protected function _trash_or_restore_question_groups($trash = true)
683
+	{
684
+		$this->_trash_or_restore_items($this->_question_group_model, $trash);
685
+	}
686
+
687
+
688
+	/**
689
+	 *_trash_question
690
+	 */
691
+	protected function _trash_question()
692
+	{
693
+		$success    = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']);
694
+		$query_args = array('action' => 'default', 'status' => 'all');
695
+		$this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
696
+	}
697
+
698
+
699
+	/**
700
+	 * @param bool $trash
701
+	 */
702
+	protected function _trash_or_restore_questions($trash = true)
703
+	{
704
+		$this->_trash_or_restore_items($this->_question_model, $trash);
705
+	}
706
+
707
+
708
+	/**
709
+	 * Internally used to delete or restore items, using the request data. Meant to be
710
+	 * flexible between question or question groups
711
+	 *
712
+	 * @param EEM_Soft_Delete_Base $model
713
+	 * @param boolean              $trash whether to trash or restore
714
+	 */
715
+	private function _trash_or_restore_items(EEM_Soft_Delete_Base $model, $trash = true)
716
+	{
717
+
718
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
719
+
720
+		$success = 1;
721
+		//Checkboxes
722
+		//echo "trash $trash";
723
+		//var_dump($this->_req_data['checkbox']);die;
724
+		if (isset($this->_req_data['checkbox'])) {
725
+			if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
726
+				// if array has more than one element than success message should be plural
727
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
728
+				// cycle thru bulk action checkboxes
729
+				while (list($ID, $value) = each($this->_req_data['checkbox'])) {
730
+					if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
731
+						$success = 0;
732
+					}
733
+				}
734
+
735
+			} else {
736
+				// grab single id and delete
737
+				$ID = absint($this->_req_data['checkbox']);
738
+				if (! $model->delete_or_restore_by_ID($trash, $ID)) {
739
+					$success = 0;
740
+				}
741
+			}
742
+
743
+		} else {
744
+			// delete via trash link
745
+			// grab single id and delete
746
+			$ID = absint($this->_req_data[$model->primary_key_name()]);
747
+			if (! $model->delete_or_restore_by_ID($trash, $ID)) {
748
+				$success = 0;
749
+			}
750
+
751
+		}
752
+
753
+
754
+		$action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
755
+		//echo "action :$action";
756
+		//$action = 'questions' ? 'default' : $action;
757
+		if ($trash) {
758
+			$action_desc = 'trashed';
759
+			$status      = 'trash';
760
+		} else {
761
+			$action_desc = 'restored';
762
+			$status      = 'all';
763
+		}
764
+		$this->_redirect_after_action($success, $model->item_name($success), $action_desc,
765
+			array('action' => $action, 'status' => $status));
766
+	}
767
+
768
+
769
+	/**
770
+	 * @param            $per_page
771
+	 * @param int        $current_page
772
+	 * @param bool|false $count
773
+	 * @return \EE_Soft_Delete_Base_Class[]|int
774
+	 */
775
+	public function get_trashed_questions($per_page, $current_page = 1, $count = false)
776
+	{
777
+		$query_params = $this->get_query_params(EEM_Question::instance(), $per_page, $current_page);
778
+
779
+		if ($count) {
780
+			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
781
+			$where   = isset($query_params[0]) ? array($query_params[0]) : array();
782
+			$results = $this->_question_model->count_deleted($where);
783
+		} else {
784
+			//note: this a subclass of EEM_Soft_Delete_Base, so this is actually only getting non-trashed items
785
+			$results = $this->_question_model->get_all_deleted($query_params);
786
+		}
787
+		return $results;
788
+	}
789
+
790
+
791
+	/**
792
+	 * @param            $per_page
793
+	 * @param int        $current_page
794
+	 * @param bool|false $count
795
+	 * @return \EE_Soft_Delete_Base_Class[]
796
+	 */
797
+	public function get_question_groups($per_page, $current_page = 1, $count = false)
798
+	{
799
+		$questionGroupModel = EEM_Question_Group::instance();
800
+		$query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
801
+		if ($count) {
802
+			$where   = isset($query_params[0]) ? array($query_params[0]) : array();
803
+			$results = $questionGroupModel->count($where);
804
+		} else {
805
+			$results = $questionGroupModel->get_all($query_params);
806
+		}
807
+		return $results;
808
+	}
809
+
810
+
811
+	/**
812
+	 * @param      $per_page
813
+	 * @param int  $current_page
814
+	 * @param bool $count
815
+	 * @return \EE_Soft_Delete_Base_Class[]|int
816
+	 */
817
+	public function get_trashed_question_groups($per_page, $current_page = 1, $count = false)
818
+	{
819
+		$questionGroupModel = EEM_Question_Group::instance();
820
+		$query_params       = $this->get_query_params($questionGroupModel, $per_page, $current_page);
821
+		if ($count) {
822
+			$where                 = isset($query_params[0]) ? array($query_params[0]) : array();
823
+			$query_params['limit'] = null;
824
+			$results               = $questionGroupModel->count_deleted($where);
825
+		} else {
826
+			$results = $questionGroupModel->get_all_deleted($query_params);
827
+		}
828
+		return $results;
829
+	}
830
+
831
+
832
+	/**
833
+	 * method for performing updates to question order
834
+	 *
835
+	 * @return array results array
836
+	 */
837
+	public function update_question_group_order()
838
+	{
839
+
840
+		$success = esc_html__('Question group order was updated successfully.', 'event_espresso');
841
+
842
+		// grab our row IDs
843
+		$row_ids = isset($this->_req_data['row_ids']) && ! empty($this->_req_data['row_ids'])
844
+			? explode(',', rtrim($this->_req_data['row_ids'], ','))
845
+			: array();
846
+
847
+		$perpage = ! empty($this->_req_data['perpage'])
848
+			? (int)$this->_req_data['perpage']
849
+			: null;
850
+		$curpage = ! empty($this->_req_data['curpage'])
851
+			? (int)$this->_req_data['curpage']
852
+			: null;
853
+
854
+		if (! empty($row_ids)) {
855
+			//figure out where we start the row_id count at for the current page.
856
+			$qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
857
+
858
+			$row_count = count($row_ids);
859
+			for ($i = 0; $i < $row_count; $i++) {
860
+				//Update the questions when re-ordering
861
+				$updated = EEM_Question_Group::instance()->update(
862
+					array('QSG_order' => $qsgcount),
863
+					array(array('QSG_ID' => $row_ids[$i]))
864
+				);
865
+				if ($updated === false) {
866
+					$success = false;
867
+				}
868
+				$qsgcount++;
869
+			}
870
+		} else {
871
+			$success = false;
872
+		}
873
+
874
+		$errors = ! $success
875
+			? esc_html__('An error occurred. The question group order was not updated.', 'event_espresso')
876
+			: false;
877
+
878
+		echo wp_json_encode(array('return_data' => false, 'success' => $success, 'errors' => $errors));
879
+		die();
880
+
881
+	}
882
+
883
+
884
+
885
+	/***************************************        REGISTRATION SETTINGS        ***************************************/
886
+
887
+
888
+	/**
889
+	 * _reg_form_settings
890
+	 *
891
+	 * @throws \EE_Error
892
+	 */
893
+	protected function _reg_form_settings()
894
+	{
895
+		$this->_template_args['values'] = $this->_yes_no_values;
896
+		add_action(
897
+			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
898
+			array($this, 'email_validation_settings_form'),
899
+			2
900
+		);
901
+		$this->_template_args = (array)apply_filters(
902
+			'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
903
+			$this->_template_args
904
+		);
905
+		$this->_set_add_edit_form_tags('update_reg_form_settings');
906
+		$this->_set_publish_post_box_vars(null, false, false, null, false);
907
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
+			REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
909
+			$this->_template_args,
910
+			true
911
+		);
912
+		$this->display_admin_page_with_sidebar();
913
+	}
914
+
915
+
916
+	/**
917
+	 * _update_reg_form_settings
918
+	 */
919
+	protected function _update_reg_form_settings()
920
+	{
921
+		EE_Registry::instance()->CFG->registration = $this->update_email_validation_settings_form(
922
+			EE_Registry::instance()->CFG->registration
923
+		);
924
+		EE_Registry::instance()->CFG->registration = apply_filters(
925
+			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
926
+			EE_Registry::instance()->CFG->registration
927
+		);
928
+		$success                                   = $this->_update_espresso_configuration(
929
+			esc_html__('Registration Form Options', 'event_espresso'),
930
+			EE_Registry::instance()->CFG,
931
+			__FILE__, __FUNCTION__, __LINE__
932
+		);
933
+		$this->_redirect_after_action($success, esc_html__('Registration Form Options', 'event_espresso'), 'updated',
934
+			array('action' => 'view_reg_form_settings'));
935
+	}
936
+
937
+
938
+	/**
939
+	 * email_validation_settings_form
940
+	 *
941
+	 * @access    public
942
+	 * @return    void
943
+	 * @throws \EE_Error
944
+	 */
945
+	public function email_validation_settings_form()
946
+	{
947
+		echo $this->_email_validation_settings_form()->get_html();
948
+	}
949
+
950
+
951
+	/**
952
+	 * _email_validation_settings_form
953
+	 *
954
+	 * @access protected
955
+	 * @return EE_Form_Section_Proper
956
+	 * @throws \EE_Error
957
+	 */
958
+	protected function _email_validation_settings_form()
959
+	{
960
+		return new EE_Form_Section_Proper(
961
+			array(
962
+				'name'            => 'email_validation_settings',
963
+				'html_id'         => 'email_validation_settings',
964
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
965
+				'subsections'     => array(
966
+					'email_validation_hdr'   => new EE_Form_Section_HTML(
967
+						EEH_HTML::h2(esc_html__('Email Validation Settings', 'event_espresso'))
968
+					),
969
+					'email_validation_level' => new EE_Select_Input(
970
+						array(
971
+							'basic'      => esc_html__('Basic', 'event_espresso'),
972
+							'wp_default' => esc_html__('WordPress Default', 'event_espresso'),
973
+							'i18n'       => esc_html__('International', 'event_espresso'),
974
+							'i18n_dns'   => esc_html__('International + DNS Check', 'event_espresso'),
975
+						),
976
+						array(
977
+							'html_label_text' => esc_html__('Email Validation Level', 'event_espresso')
978
+												 . EEH_Template::get_help_tab_link('email_validation_info'),
979
+							'html_help_text'  => esc_html__('These levels range from basic validation ( ie: [email protected] ) to more advanced checks against international email addresses (ie: üñîçøðé@example.com ) with additional MX and A record checks to confirm the domain actually exists. More information on on each level can be found within the help section.',
980
+								'event_espresso'),
981
+							'default'         => isset(EE_Registry::instance()->CFG->registration->email_validation_level)
982
+								? EE_Registry::instance()->CFG->registration->email_validation_level
983
+								: 'wp_default',
984
+							'required'        => false,
985
+						)
986
+					),
987
+				),
988
+			)
989
+		);
990
+	}
991
+
992
+
993
+	/**
994
+	 * update_email_validation_settings_form
995
+	 *
996
+	 * @access    public
997
+	 * @param \EE_Registration_Config $EE_Registration_Config
998
+	 * @return \EE_Registration_Config
999
+	 */
1000
+	public function update_email_validation_settings_form(EE_Registration_Config $EE_Registration_Config)
1001
+	{
1002
+		$prev_email_validation_level = $EE_Registration_Config->email_validation_level;
1003
+		try {
1004
+			$email_validation_settings_form = $this->_email_validation_settings_form();
1005
+			// if not displaying a form, then check for form submission
1006
+			if ($email_validation_settings_form->was_submitted()) {
1007
+				// capture form data
1008
+				$email_validation_settings_form->receive_form_submission();
1009
+				// validate form data
1010
+				if ($email_validation_settings_form->is_valid()) {
1011
+					// grab validated data from form
1012
+					$valid_data = $email_validation_settings_form->valid_data();
1013
+					if (isset($valid_data['email_validation_level'])) {
1014
+						$email_validation_level = $valid_data['email_validation_level'];
1015
+						// now if they want to use international email addresses
1016
+						if ($email_validation_level === 'i18n' || $email_validation_level === 'i18n_dns') {
1017
+							// in case we need to reset their email validation level,
1018
+							// make sure that the previous value wasn't already set to one of the i18n options.
1019
+							if ($prev_email_validation_level === 'i18n' || $prev_email_validation_level === 'i18n_dns') {
1020
+								// if so, then reset it back to "basic" since that is the only other option that,
1021
+								// despite offering poor validation, supports i18n email addresses
1022
+								$prev_email_validation_level = 'basic';
1023
+							}
1024
+							// confirm our i18n email validation will work on the server
1025
+							if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1026
+								// or reset email validation level to previous value
1027
+								$email_validation_level = $prev_email_validation_level;
1028
+							}
1029
+						}
1030
+						$EE_Registration_Config->email_validation_level = $email_validation_level;
1031
+					} else {
1032
+						EE_Error::add_error(
1033
+							esc_html__(
1034
+								'Invalid or missing Email Validation settings. Please refresh the form and try again.',
1035
+								'event_espresso'
1036
+							),
1037
+							__FILE__, __FUNCTION__, __LINE__
1038
+						);
1039
+					}
1040
+				} else {
1041
+					if ($email_validation_settings_form->submission_error_message() !== '') {
1042
+						EE_Error::add_error(
1043
+							$email_validation_settings_form->submission_error_message(),
1044
+							__FILE__, __FUNCTION__, __LINE__
1045
+						);
1046
+					}
1047
+				}
1048
+			}
1049
+		} catch (EE_Error $e) {
1050
+			$e->get_error();
1051
+		}
1052
+		return $EE_Registration_Config;
1053
+	}
1054
+
1055
+
1056
+	/**
1057
+	 * confirms that the server's PHP version has the PCRE module enabled,
1058
+	 * and that the PCRE version works with our i18n email validation
1059
+	 *
1060
+	 * @param \EE_Registration_Config $EE_Registration_Config
1061
+	 * @param string                  $email_validation_level
1062
+	 * @return bool
1063
+	 */
1064
+	private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1065
+	{
1066
+		// first check that PCRE is enabled
1067
+		if (! defined('PREG_BAD_UTF8_ERROR')) {
1068
+			EE_Error::add_error(
1069
+				sprintf(
1070
+					esc_html__(
1071
+						'We\'re sorry, but it appears that your server\'s version of PHP was not compiled with PCRE unicode support.%1$sPlease contact your hosting company and ask them whether the PCRE compiled with your version of PHP on your server can be been built with the "--enable-unicode-properties" and "--enable-utf8" configuration switches to enable more complex regex expressions.%1$sIf they are unable, or unwilling to do so, then your server will not support international email addresses using UTF-8 unicode characters. This means you will either have to lower your email validation level to "Basic" or "WordPress Default", or switch to a hosting company that has/can enable PCRE unicode support on the server.',
1072
+						'event_espresso'
1073
+					),
1074
+					'<br />'
1075
+				),
1076
+				__FILE__,
1077
+				__FUNCTION__,
1078
+				__LINE__
1079
+			);
1080
+			return false;
1081
+		} else {
1082
+			// PCRE support is enabled, but let's still
1083
+			// perform a test to see if the server will support it.
1084
+			// but first, save the updated validation level to the config,
1085
+			// so that the validation strategy picks it up.
1086
+			// this will get bumped back down if it doesn't work
1087
+			$EE_Registration_Config->email_validation_level = $email_validation_level;
1088
+			try {
1089
+				$email_validator    = new EE_Email_Validation_Strategy();
1090
+				$i18n_email_address = apply_filters(
1091
+					'FHEE__Extend_Registration_Form_Admin_Page__update_email_validation_settings_form__i18n_email_address',
1092
+					'jägerjü[email protected]'
1093
+				);
1094
+				$email_validator->validate($i18n_email_address);
1095
+			} catch (Exception $e) {
1096
+				EE_Error::add_error(
1097
+					sprintf(
1098
+						esc_html__(
1099
+							'We\'re sorry, but it appears that your server\'s configuration will not support the "International" or "International + DNS Check" email validation levels.%1$sTo correct this issue, please consult with your hosting company regarding your server\'s PCRE settings.%1$sIt is recommended that your PHP version be configured to use PCRE 8.10 or newer.%1$sMore information regarding PCRE versions and installation can be found here: %2$s',
1100
+							'event_espresso'
1101
+						),
1102
+						'<br />',
1103
+						'<a href="http://php.net/manual/en/pcre.installation.php" target="_blank">http://php.net/manual/en/pcre.installation.php</a>'
1104
+					),
1105
+					__FILE__, __FUNCTION__, __LINE__
1106
+				);
1107
+				return false;
1108
+			}
1109
+		}
1110
+		return true;
1111
+	}
1112 1112
 
1113 1113
 
1114 1114
 }
Please login to merge, or discard this patch.
Spacing   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (! defined('EVENT_ESPRESSO_VERSION')) {
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3 3
     exit('NO direct script access allowed');
4 4
 }
5 5
 
@@ -32,11 +32,11 @@  discard block
 block discarded – undo
32 32
      */
33 33
     public function __construct($routing = true)
34 34
     {
35
-        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND . 'registration_form' . DS);
36
-        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN . 'assets' . DS);
37
-        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/assets/');
38
-        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN . 'templates' . DS);
39
-        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'registration_form/templates/');
35
+        define('REGISTRATION_FORM_CAF_ADMIN', EE_CORE_CAF_ADMIN_EXTEND.'registration_form'.DS);
36
+        define('REGISTRATION_FORM_CAF_ASSETS_PATH', REGISTRATION_FORM_CAF_ADMIN.'assets'.DS);
37
+        define('REGISTRATION_FORM_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/assets/');
38
+        define('REGISTRATION_FORM_CAF_TEMPLATE_PATH', REGISTRATION_FORM_CAF_ADMIN.'templates'.DS);
39
+        define('REGISTRATION_FORM_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'registration_form/templates/');
40 40
         parent::__construct($routing);
41 41
     }
42 42
 
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
         $qst_id = ! empty($this->_req_data['QST_ID']) && ! is_array($this->_req_data['QST_ID']) ? $this->_req_data['QST_ID'] : 0;
48 48
         $qsg_id = ! empty($this->_req_data['QSG_ID']) && ! is_array($this->_req_data['QSG_ID']) ? $this->_req_data['QSG_ID'] : 0;
49 49
 
50
-        $new_page_routes    = array(
50
+        $new_page_routes = array(
51 51
             'question_groups'    => array(
52 52
                 'func'       => '_question_groups_overview_list_table',
53 53
                 'capability' => 'ee_read_question_groups',
@@ -310,7 +310,7 @@  discard block
 block discarded – undo
310 310
 
311 311
 
312 312
         //additional labels
313
-        $new_labels               = array(
313
+        $new_labels = array(
314 314
             'add_question'          => esc_html__('Add New Question', 'event_espresso'),
315 315
             'delete_question'       => esc_html__('Delete Question', 'event_espresso'),
316 316
             'add_question_group'    => esc_html__('Add New Question Group', 'event_espresso'),
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
      */
355 355
     public function load_sortable_question_script()
356 356
     {
357
-        wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL . 'ee_question_order.js',
357
+        wp_register_script('ee-question-sortable', REGISTRATION_FORM_CAF_ASSETS_URL.'ee_question_order.js',
358 358
             array('jquery-ui-sortable'), EVENT_ESPRESSO_VERSION, true);
359 359
         wp_enqueue_script('ee-question-sortable');
360 360
     }
@@ -420,7 +420,7 @@  discard block
 block discarded – undo
420 420
 
421 421
     protected function _questions_overview_list_table()
422 422
     {
423
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
423
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
424 424
                 'add_question',
425 425
                 'add_question',
426 426
                 array(),
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
     protected function _question_groups_overview_list_table()
434 434
     {
435 435
         $this->_search_btn_label = esc_html__('Question Groups', 'event_espresso');
436
-        $this->_admin_page_title .= ' ' . $this->get_action_link_or_button(
436
+        $this->_admin_page_title .= ' '.$this->get_action_link_or_button(
437 437
                 'add_question_group',
438 438
                 'add_question_group',
439 439
                 array(),
@@ -477,20 +477,20 @@  discard block
 block discarded – undo
477 477
     {
478 478
         $success = 0;
479 479
         do_action('AHEE_log', __FILE__, __FUNCTION__, '');
480
-        if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
480
+        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
481 481
             // if array has more than one element than success message should be plural
482 482
             $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
483 483
             // cycle thru bulk action checkboxes
484 484
             while (list($ID, $value) = each($this->_req_data['checkbox'])) {
485
-                if (! $this->_delete_item($ID, $model)) {
485
+                if ( ! $this->_delete_item($ID, $model)) {
486 486
                     $success = 0;
487 487
                 }
488 488
             }
489 489
 
490
-        } elseif (! empty($this->_req_data['QSG_ID'])) {
490
+        } elseif ( ! empty($this->_req_data['QSG_ID'])) {
491 491
             $success = $this->_delete_item($this->_req_data['QSG_ID'], $model);
492 492
 
493
-        } elseif (! empty($this->_req_data['QST_ID'])) {
493
+        } elseif ( ! empty($this->_req_data['QST_ID'])) {
494 494
             $success = $this->_delete_item($this->_req_data['QST_ID'], $model);
495 495
         } else {
496 496
             EE_Error::add_error(sprintf(esc_html__("No Questions or Question Groups were selected for deleting. This error usually shows when you've attempted to delete via bulk action but there were no selections.",
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
                 $this->_admin_page_title = ucwords(str_replace('_', ' ', $this->_req_action));
535 535
         }
536 536
         // add ID to title if editing
537
-        $this->_admin_page_title = $ID ? $this->_admin_page_title . ' # ' . $ID : $this->_admin_page_title;
537
+        $this->_admin_page_title = $ID ? $this->_admin_page_title.' # '.$ID : $this->_admin_page_title;
538 538
         if ($ID) {
539 539
             /** @var EE_Question_Group $questionGroup */
540 540
             $questionGroup            = $this->_question_group_model->get_one_by_ID($ID);
@@ -553,7 +553,7 @@  discard block
 block discarded – undo
553 553
 
554 554
         $redirect_URL = add_query_arg(array('action' => 'question_groups'), $this->_admin_base_url);
555 555
         $this->_set_publish_post_box_vars('id', $ID, false, $redirect_URL);
556
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'question_groups_main_meta_box.template.php',
556
+        $this->_template_args['admin_page_content'] = EEH_Template::display_template(REGISTRATION_FORM_CAF_TEMPLATE_PATH.'question_groups_main_meta_box.template.php',
557 557
             $this->_template_args, true);
558 558
 
559 559
         // the details template wrapper
@@ -600,13 +600,13 @@  discard block
 block discarded – undo
600 600
         $question_group = $this->_question_group_model->get_one_by_ID($QSG_ID);
601 601
         $questions      = $question_group->questions();
602 602
         // make sure system phone question is added to list of questions for this group
603
-        if (! isset($questions[$phone_question_id])) {
603
+        if ( ! isset($questions[$phone_question_id])) {
604 604
             $questions[$phone_question_id] = EEM_Question::instance()->get_one_by_ID($phone_question_id);
605 605
         }
606 606
 
607 607
         foreach ($questions as $question_ID => $question) {
608 608
             // first we always check for order.
609
-            if (! empty($this->_req_data['question_orders'][$question_ID])) {
609
+            if ( ! empty($this->_req_data['question_orders'][$question_ID])) {
610 610
                 //update question order
611 611
                 $question_group->update_question_order($question_ID, $this->_req_data['question_orders'][$question_ID]);
612 612
             }
@@ -654,7 +654,7 @@  discard block
 block discarded – undo
654 654
      */
655 655
     public function _duplicate_question()
656 656
     {
657
-        $question_ID = (int)$this->_req_data['QST_ID'];
657
+        $question_ID = (int) $this->_req_data['QST_ID'];
658 658
         $question    = EEM_Question::instance()->get_one_by_ID($question_ID);
659 659
         if ($question instanceof EE_Question) {
660 660
             $new_question = $question->duplicate();
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
      */
691 691
     protected function _trash_question()
692 692
     {
693
-        $success    = $this->_question_model->delete_by_ID((int)$this->_req_data['QST_ID']);
693
+        $success    = $this->_question_model->delete_by_ID((int) $this->_req_data['QST_ID']);
694 694
         $query_args = array('action' => 'default', 'status' => 'all');
695 695
         $this->_redirect_after_action($success, $this->_question_model->item_name($success), 'trashed', $query_args);
696 696
     }
@@ -722,12 +722,12 @@  discard block
 block discarded – undo
722 722
         //echo "trash $trash";
723 723
         //var_dump($this->_req_data['checkbox']);die;
724 724
         if (isset($this->_req_data['checkbox'])) {
725
-            if (! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
725
+            if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
726 726
                 // if array has more than one element than success message should be plural
727 727
                 $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
728 728
                 // cycle thru bulk action checkboxes
729 729
                 while (list($ID, $value) = each($this->_req_data['checkbox'])) {
730
-                    if (! $model->delete_or_restore_by_ID($trash, absint($ID))) {
730
+                    if ( ! $model->delete_or_restore_by_ID($trash, absint($ID))) {
731 731
                         $success = 0;
732 732
                     }
733 733
                 }
@@ -735,7 +735,7 @@  discard block
 block discarded – undo
735 735
             } else {
736 736
                 // grab single id and delete
737 737
                 $ID = absint($this->_req_data['checkbox']);
738
-                if (! $model->delete_or_restore_by_ID($trash, $ID)) {
738
+                if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
739 739
                     $success = 0;
740 740
                 }
741 741
             }
@@ -744,14 +744,14 @@  discard block
 block discarded – undo
744 744
             // delete via trash link
745 745
             // grab single id and delete
746 746
             $ID = absint($this->_req_data[$model->primary_key_name()]);
747
-            if (! $model->delete_or_restore_by_ID($trash, $ID)) {
747
+            if ( ! $model->delete_or_restore_by_ID($trash, $ID)) {
748 748
                 $success = 0;
749 749
             }
750 750
 
751 751
         }
752 752
 
753 753
 
754
-        $action = $model instanceof EEM_Question ? 'default' : 'question_groups';//strtolower( $model->item_name(2) );
754
+        $action = $model instanceof EEM_Question ? 'default' : 'question_groups'; //strtolower( $model->item_name(2) );
755 755
         //echo "action :$action";
756 756
         //$action = 'questions' ? 'default' : $action;
757 757
         if ($trash) {
@@ -845,13 +845,13 @@  discard block
 block discarded – undo
845 845
             : array();
846 846
 
847 847
         $perpage = ! empty($this->_req_data['perpage'])
848
-            ? (int)$this->_req_data['perpage']
848
+            ? (int) $this->_req_data['perpage']
849 849
             : null;
850 850
         $curpage = ! empty($this->_req_data['curpage'])
851
-            ? (int)$this->_req_data['curpage']
851
+            ? (int) $this->_req_data['curpage']
852 852
             : null;
853 853
 
854
-        if (! empty($row_ids)) {
854
+        if ( ! empty($row_ids)) {
855 855
             //figure out where we start the row_id count at for the current page.
856 856
             $qsgcount = empty($curpage) ? 0 : ($curpage - 1) * $perpage;
857 857
 
@@ -898,14 +898,14 @@  discard block
 block discarded – undo
898 898
             array($this, 'email_validation_settings_form'),
899 899
             2
900 900
         );
901
-        $this->_template_args = (array)apply_filters(
901
+        $this->_template_args = (array) apply_filters(
902 902
             'FHEE__Extend_Registration_Form_Admin_Page___reg_form_settings___template_args',
903 903
             $this->_template_args
904 904
         );
905 905
         $this->_set_add_edit_form_tags('update_reg_form_settings');
906 906
         $this->_set_publish_post_box_vars(null, false, false, null, false);
907 907
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
908
-            REGISTRATION_FORM_CAF_TEMPLATE_PATH . 'reg_form_settings.template.php',
908
+            REGISTRATION_FORM_CAF_TEMPLATE_PATH.'reg_form_settings.template.php',
909 909
             $this->_template_args,
910 910
             true
911 911
         );
@@ -925,7 +925,7 @@  discard block
 block discarded – undo
925 925
             'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
926 926
             EE_Registry::instance()->CFG->registration
927 927
         );
928
-        $success                                   = $this->_update_espresso_configuration(
928
+        $success = $this->_update_espresso_configuration(
929 929
             esc_html__('Registration Form Options', 'event_espresso'),
930 930
             EE_Registry::instance()->CFG,
931 931
             __FILE__, __FUNCTION__, __LINE__
@@ -1022,7 +1022,7 @@  discard block
 block discarded – undo
1022 1022
                                 $prev_email_validation_level = 'basic';
1023 1023
                             }
1024 1024
                             // confirm our i18n email validation will work on the server
1025
-                            if (! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1025
+                            if ( ! $this->_verify_pcre_support($EE_Registration_Config, $email_validation_level)) {
1026 1026
                                 // or reset email validation level to previous value
1027 1027
                                 $email_validation_level = $prev_email_validation_level;
1028 1028
                             }
@@ -1064,7 +1064,7 @@  discard block
 block discarded – undo
1064 1064
     private function _verify_pcre_support(EE_Registration_Config $EE_Registration_Config, $email_validation_level)
1065 1065
     {
1066 1066
         // first check that PCRE is enabled
1067
-        if (! defined('PREG_BAD_UTF8_ERROR')) {
1067
+        if ( ! defined('PREG_BAD_UTF8_ERROR')) {
1068 1068
             EE_Error::add_error(
1069 1069
                 sprintf(
1070 1070
                     esc_html__(
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Int_Normalization.strategy.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@
 block discarded – undo
11 11
 
12 12
 	/**
13 13
 	 * @param string $value_to_normalize
14
-	 * @return int|mixed|string
14
+	 * @return integer|null
15 15
 	 * @throws \EE_Validation_Error
16 16
 	 */
17 17
 	public function normalize($value_to_normalize) {
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -20,8 +20,8 @@  discard block
 block discarded – undo
20 20
 		}
21 21
 
22 22
 		if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) {
23
-		    return null;
24
-        }
23
+			return null;
24
+		}
25 25
 
26 26
 		if( ! is_string( $value_to_normalize )){
27 27
 			throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) );
@@ -56,9 +56,9 @@  discard block
 block discarded – undo
56 56
 	 * @return string
57 57
 	 */
58 58
 	public function unnormalize( $normalized_value ) {
59
-	    if ($normalized_value === null) {
60
-	        return '';
61
-        }elseif( empty( $normalized_value ) ){
59
+		if ($normalized_value === null) {
60
+			return '';
61
+		}elseif( empty( $normalized_value ) ){
62 62
 			return '0';
63 63
 		}else{
64 64
 			return "$normalized_value";
Please login to merge, or discard this patch.
Spacing   +16 added lines, -16 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * @subpackage
8 8
  * @author				Mike Nelson
9 9
  */
10
-class EE_Int_Normalization extends EE_Normalization_Strategy_Base{
10
+class EE_Int_Normalization extends EE_Normalization_Strategy_Base {
11 11
 
12 12
 	/**
13 13
 	 * @param string $value_to_normalize
@@ -15,38 +15,38 @@  discard block
 block discarded – undo
15 15
 	 * @throws \EE_Validation_Error
16 16
 	 */
17 17
 	public function normalize($value_to_normalize) {
18
-		if( is_int( $value_to_normalize ) ){
18
+		if (is_int($value_to_normalize)) {
19 19
 			return $value_to_normalize;
20 20
 		}
21 21
 
22
-		if ( is_null( $value_to_normalize ) || $value_to_normalize === '' ) {
22
+		if (is_null($value_to_normalize) || $value_to_normalize === '') {
23 23
 		    return null;
24 24
         }
25 25
 
26
-		if( ! is_string( $value_to_normalize )){
27
-			throw new EE_Validation_Error( sprintf( __( 'The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso' ), print_r( $value_to_normalize, TRUE), gettype( $value_to_normalize ) ) );
26
+		if ( ! is_string($value_to_normalize)) {
27
+			throw new EE_Validation_Error(sprintf(__('The value "%s" must be a string submitted for normalization, it was %s', 'event_espresso'), print_r($value_to_normalize, TRUE), gettype($value_to_normalize)));
28 28
 		}
29 29
 		$thousands_separator = EE_Config::instance()->currency->thsnds;
30
-		$value_to_normalize = str_replace( $thousands_separator, "", $value_to_normalize );
31
-		$value_to_normalize = str_replace( array(" ","\t"), '', $value_to_normalize );
32
-		if ( preg_match( '/^\d+$/', $value_to_normalize )) {
33
-			return intval( $value_to_normalize );
30
+		$value_to_normalize = str_replace($thousands_separator, "", $value_to_normalize);
31
+		$value_to_normalize = str_replace(array(" ", "\t"), '', $value_to_normalize);
32
+		if (preg_match('/^\d+$/', $value_to_normalize)) {
33
+			return intval($value_to_normalize);
34 34
 		} else {
35 35
 			//find if this input has a int validation strategy
36 36
 			//in which case, use its message
37 37
 			$validation_error_message = NULL;
38
-			foreach( $this->_input->get_validation_strategies() as $validation_strategy ){
39
-				if( $validation_strategy instanceof EE_Int_Validation_Strategy ){
38
+			foreach ($this->_input->get_validation_strategies() as $validation_strategy) {
39
+				if ($validation_strategy instanceof EE_Int_Validation_Strategy) {
40 40
 					$validation_error_message = $validation_strategy->get_validation_error_message();
41 41
 				}
42 42
 			}
43 43
 			//this really shouldn't ever happen because fields with a int normalization strategy
44 44
 			//should also have a int validation strategy, but in case it doesnt use the default
45
-			if( ! $validation_error_message ){
45
+			if ( ! $validation_error_message) {
46 46
 				$default_validation_strategy = new EE_Int_Validation_Strategy();
47 47
 				$validation_error_message = $default_validation_strategy->get_validation_error_message();
48 48
 			}
49
-			throw new EE_Validation_Error( $validation_error_message, 'numeric_only' );
49
+			throw new EE_Validation_Error($validation_error_message, 'numeric_only');
50 50
 		}
51 51
 	}
52 52
 
@@ -55,12 +55,12 @@  discard block
 block discarded – undo
55 55
 	 * @param int $normalized_value
56 56
 	 * @return string
57 57
 	 */
58
-	public function unnormalize( $normalized_value ) {
58
+	public function unnormalize($normalized_value) {
59 59
 	    if ($normalized_value === null) {
60 60
 	        return '';
61
-        }elseif( empty( $normalized_value ) ){
61
+        }elseif (empty($normalized_value)) {
62 62
 			return '0';
63
-		}else{
63
+		} else {
64 64
 			return "$normalized_value";
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -58,9 +58,9 @@
 block discarded – undo
58 58
 	public function unnormalize( $normalized_value ) {
59 59
 	    if ($normalized_value === null) {
60 60
 	        return '';
61
-        }elseif( empty( $normalized_value ) ){
61
+        } elseif( empty( $normalized_value ) ){
62 62
 			return '0';
63
-		}else{
63
+		} else{
64 64
 			return "$normalized_value";
65 65
 		}
66 66
 	}
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page_CPT.core.php 2 patches
Indentation   +1388 added lines, -1388 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
 /**
@@ -24,445 +24,445 @@  discard block
 block discarded – undo
24 24
 {
25 25
 
26 26
 
27
-    /**
28
-     * This gets set in _setup_cpt
29
-     * It will contain the object for the custom post type.
30
-     *
31
-     * @var object
32
-     */
33
-    protected $_cpt_object;
34
-
35
-
36
-
37
-    /**
38
-     * a boolean flag to set whether the current route is a cpt route or not.
39
-     *
40
-     * @var bool
41
-     */
42
-    protected $_cpt_route = false;
43
-
44
-
45
-
46
-    /**
47
-     * This property allows cpt classes to define multiple routes as cpt routes.
48
-     * //in this array we define what the custom post type for this route is.
49
-     * array(
50
-     * 'route_name' => 'custom_post_type_slug'
51
-     * )
52
-     *
53
-     * @var array
54
-     */
55
-    protected $_cpt_routes = array();
56
-
27
+	/**
28
+	 * This gets set in _setup_cpt
29
+	 * It will contain the object for the custom post type.
30
+	 *
31
+	 * @var object
32
+	 */
33
+	protected $_cpt_object;
34
+
35
+
36
+
37
+	/**
38
+	 * a boolean flag to set whether the current route is a cpt route or not.
39
+	 *
40
+	 * @var bool
41
+	 */
42
+	protected $_cpt_route = false;
43
+
44
+
45
+
46
+	/**
47
+	 * This property allows cpt classes to define multiple routes as cpt routes.
48
+	 * //in this array we define what the custom post type for this route is.
49
+	 * array(
50
+	 * 'route_name' => 'custom_post_type_slug'
51
+	 * )
52
+	 *
53
+	 * @var array
54
+	 */
55
+	protected $_cpt_routes = array();
56
+
57 57
 
58 58
 
59
-    /**
60
-     * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
61
-     * in this format:
62
-     * array(
63
-     * 'post_type_slug' => 'edit_route'
64
-     * )
65
-     *
66
-     * @var array
67
-     */
68
-    protected $_cpt_edit_routes = array();
69
-
70
-
71
-
72
-    /**
73
-     * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
-     * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
-     * _cpt_model_names property should be in the following format: array(
76
-     * 'route_defined_by_action_param' => 'Model_Name')
77
-     *
78
-     * @var array $_cpt_model_names
79
-     */
80
-    protected $_cpt_model_names = array();
81
-
82
-
83
-    /**
84
-     * @var EE_CPT_Base
85
-     */
86
-    protected $_cpt_model_obj = false;
87
-
88
-
89
-
90
-    /**
91
-     * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
92
-     * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
93
-     * the _register_autosave_containers() method so that we don't override any other containers already registered.
94
-     * Registration of containers should be done before load_page_dependencies() is run.
95
-     *
96
-     * @var array()
97
-     */
98
-    protected $_autosave_containers = array();
99
-    protected $_autosave_fields = array();
100
-
101
-    /**
102
-     * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
103
-     * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
104
-     *
105
-     * @var array
106
-     */
107
-    protected $_pagenow_map = null;
108
-
109
-
110
-
111
-    /**
112
-     * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
113
-     * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
114
-     * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
115
-     * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
116
-     * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
117
-     *
118
-     * @access protected
119
-     * @abstract
120
-     * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
121
-     * @param  object $post    The post object of the cpt that was saved.
122
-     * @return void
123
-     */
124
-    abstract protected function _insert_update_cpt_item($post_id, $post);
125
-
126
-
127
-
128
-    /**
129
-     * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
130
-     *
131
-     * @abstract
132
-     * @access public
133
-     * @param  string $post_id The ID of the cpt that was trashed
134
-     * @return void
135
-     */
136
-    abstract public function trash_cpt_item($post_id);
137
-
138
-
139
-
140
-    /**
141
-     * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
142
-     *
143
-     * @param  string $post_id theID of the cpt that was untrashed
144
-     * @return void
145
-     */
146
-    abstract public function restore_cpt_item($post_id);
147
-
148
-
149
-
150
-    /**
151
-     * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
152
-     * from the db
153
-     *
154
-     * @param  string $post_id the ID of the cpt that was deleted
155
-     * @return void
156
-     */
157
-    abstract public function delete_cpt_item($post_id);
158
-
159
-
160
-
161
-    /**
162
-     * Just utilizing the method EE_Admin exposes for doing things before page setup.
163
-     *
164
-     * @access protected
165
-     * @return void
166
-     */
167
-    protected function _before_page_setup()
168
-    {
169
-        $page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
170
-        $this->_cpt_routes = array_merge(array(
171
-            'create_new' => $this->page_slug,
172
-            'edit'       => $this->page_slug,
173
-            'trash'      => $this->page_slug,
174
-        ), $this->_cpt_routes);
175
-        //let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
176
-        $this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
177
-            ? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
178
-            : get_post_type_object($page);
179
-        //tweak pagenow for page loading.
180
-        if ( ! $this->_pagenow_map) {
181
-            $this->_pagenow_map = array(
182
-                'create_new' => 'post-new.php',
183
-                'edit'       => 'post.php',
184
-                'trash'      => 'post.php',
185
-            );
186
-        }
187
-        add_action('current_screen', array($this, 'modify_pagenow'));
188
-        //TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
189
-        //get current page from autosave
190
-        $current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
191
-            ? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
192
-            : null;
193
-        $this->_current_page = isset($this->_req_data['current_page'])
194
-            ? $this->_req_data['current_page']
195
-            : $current_page;
196
-        //autosave... make sure its only for the correct page
197
-        if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
198
-            //setup autosave ajax hook
199
-            //add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
200
-        }
201
-    }
202
-
203
-
204
-
205
-    /**
206
-     * Simply ensure that we simulate the correct post route for cpt screens
207
-     *
208
-     * @param WP_Screen $current_screen
209
-     * @return void
210
-     */
211
-    public function modify_pagenow($current_screen)
212
-    {
213
-        global $pagenow, $hook_suffix;
214
-        //possibly reset pagenow.
215
-        if ( ! empty($this->_req_data['page'])
216
-             && $this->_req_data['page'] == $this->page_slug
217
-             && ! empty($this->_req_data['action'])
218
-             && isset($this->_pagenow_map[$this->_req_data['action']])
219
-        ) {
220
-            $pagenow = $this->_pagenow_map[$this->_req_data['action']];
221
-            $hook_suffix = $pagenow;
222
-        }
223
-    }
224
-
225
-
226
-
227
-    /**
228
-     * This method is used to register additional autosave containers to the _autosave_containers property.
229
-     *
230
-     * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
231
-     *       automatically register the id for the post metabox as a container.
232
-     * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
233
-     *                    you would send along the id of a metabox container.
234
-     * @return void
235
-     */
236
-    protected function _register_autosave_containers($ids)
237
-    {
238
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids);
239
-    }
240
-
241
-
242
-
243
-    /**
244
-     * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
245
-     * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
246
-     */
247
-    protected function _set_autosave_containers()
248
-    {
249
-        global $wp_meta_boxes;
250
-        $containers = array();
251
-        if (empty($wp_meta_boxes)) {
252
-            return;
253
-        }
254
-        $current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
255
-        foreach ($current_metaboxes as $box_context) {
256
-            foreach ($box_context as $box_details) {
257
-                foreach ($box_details as $box) {
258
-                    if (is_array($box['callback'])
259
-                        && ($box['callback'][0] instanceof EE_Admin_Page
260
-                            || $box['callback'][0] instanceof EE_Admin_Hooks)
261
-                    ) {
262
-                        $containers[] = $box['id'];
263
-                    }
264
-                }
265
-            }
266
-        }
267
-        $this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
268
-        //add hidden inputs container
269
-        $this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
270
-    }
271
-
272
-
273
-
274
-    protected function _load_autosave_scripts_styles()
275
-    {
276
-        /*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
59
+	/**
60
+	 * This simply defines what the corresponding routes WP will be redirected to after completing a post save/update.
61
+	 * in this format:
62
+	 * array(
63
+	 * 'post_type_slug' => 'edit_route'
64
+	 * )
65
+	 *
66
+	 * @var array
67
+	 */
68
+	protected $_cpt_edit_routes = array();
69
+
70
+
71
+
72
+	/**
73
+	 * If child classes set the name of their main model via the $_cpt_obj_models property, EE_Admin_Page_CPT will
74
+	 * attempt to retrieve the related object model for the edit pages and assign it to _cpt_page_object. the
75
+	 * _cpt_model_names property should be in the following format: array(
76
+	 * 'route_defined_by_action_param' => 'Model_Name')
77
+	 *
78
+	 * @var array $_cpt_model_names
79
+	 */
80
+	protected $_cpt_model_names = array();
81
+
82
+
83
+	/**
84
+	 * @var EE_CPT_Base
85
+	 */
86
+	protected $_cpt_model_obj = false;
87
+
88
+
89
+
90
+	/**
91
+	 * This will hold an array of autosave containers that will be used to obtain input values and hook into the WP
92
+	 * autosave so we can save our inputs on the save_post hook!  Children classes should add to this array by using
93
+	 * the _register_autosave_containers() method so that we don't override any other containers already registered.
94
+	 * Registration of containers should be done before load_page_dependencies() is run.
95
+	 *
96
+	 * @var array()
97
+	 */
98
+	protected $_autosave_containers = array();
99
+	protected $_autosave_fields = array();
100
+
101
+	/**
102
+	 * Array mapping from admin actions to their equivalent wp core pages for custom post types. So when a user visits
103
+	 * a page for an action, it will appear as if they were visiting the wp core page for that custom post type
104
+	 *
105
+	 * @var array
106
+	 */
107
+	protected $_pagenow_map = null;
108
+
109
+
110
+
111
+	/**
112
+	 * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been
113
+	 * saved.  Child classes are required to declare this method.  Typically you would use this to save any additional
114
+	 * data. Keep in mind also that "save_post" runs on EVERY post update to the database. ALSO very important.  When a
115
+	 * post transitions from scheduled to published, the save_post action is fired but you will NOT have any _POST data
116
+	 * containing any extra info you may have from other meta saves.  So MAKE sure that you handle this accordingly.
117
+	 *
118
+	 * @access protected
119
+	 * @abstract
120
+	 * @param  string $post_id The ID of the cpt that was saved (so you can link relationally)
121
+	 * @param  object $post    The post object of the cpt that was saved.
122
+	 * @return void
123
+	 */
124
+	abstract protected function _insert_update_cpt_item($post_id, $post);
125
+
126
+
127
+
128
+	/**
129
+	 * This is hooked into the WordPress do_action('trashed_post') hook and runs after a cpt has been trashed.
130
+	 *
131
+	 * @abstract
132
+	 * @access public
133
+	 * @param  string $post_id The ID of the cpt that was trashed
134
+	 * @return void
135
+	 */
136
+	abstract public function trash_cpt_item($post_id);
137
+
138
+
139
+
140
+	/**
141
+	 * This is hooked into the WordPress do_action('untrashed_post') hook and runs after a cpt has been untrashed
142
+	 *
143
+	 * @param  string $post_id theID of the cpt that was untrashed
144
+	 * @return void
145
+	 */
146
+	abstract public function restore_cpt_item($post_id);
147
+
148
+
149
+
150
+	/**
151
+	 * This is hooked into the WordPress do_action('delete_cpt_item') hook and runs after a cpt has been fully deleted
152
+	 * from the db
153
+	 *
154
+	 * @param  string $post_id the ID of the cpt that was deleted
155
+	 * @return void
156
+	 */
157
+	abstract public function delete_cpt_item($post_id);
158
+
159
+
160
+
161
+	/**
162
+	 * Just utilizing the method EE_Admin exposes for doing things before page setup.
163
+	 *
164
+	 * @access protected
165
+	 * @return void
166
+	 */
167
+	protected function _before_page_setup()
168
+	{
169
+		$page = isset($this->_req_data['page']) ? $this->_req_data['page'] : $this->page_slug;
170
+		$this->_cpt_routes = array_merge(array(
171
+			'create_new' => $this->page_slug,
172
+			'edit'       => $this->page_slug,
173
+			'trash'      => $this->page_slug,
174
+		), $this->_cpt_routes);
175
+		//let's see if the current route has a value for cpt_object_slug if it does we use that instead of the page
176
+		$this->_cpt_object = isset($this->_req_data['action']) && isset($this->_cpt_routes[$this->_req_data['action']])
177
+			? get_post_type_object($this->_cpt_routes[$this->_req_data['action']])
178
+			: get_post_type_object($page);
179
+		//tweak pagenow for page loading.
180
+		if ( ! $this->_pagenow_map) {
181
+			$this->_pagenow_map = array(
182
+				'create_new' => 'post-new.php',
183
+				'edit'       => 'post.php',
184
+				'trash'      => 'post.php',
185
+			);
186
+		}
187
+		add_action('current_screen', array($this, 'modify_pagenow'));
188
+		//TODO the below will need to be reworked to account for the cpt routes that are NOT based off of page but action param.
189
+		//get current page from autosave
190
+		$current_page = isset($this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page'])
191
+			? $this->_req_data['ee_autosave_data']['ee-cpt-hidden-inputs']['current_page']
192
+			: null;
193
+		$this->_current_page = isset($this->_req_data['current_page'])
194
+			? $this->_req_data['current_page']
195
+			: $current_page;
196
+		//autosave... make sure its only for the correct page
197
+		if ( ! empty($this->_current_page) && $this->_current_page == $this->page_slug) {
198
+			//setup autosave ajax hook
199
+			//add_action('wp_ajax_ee-autosave', array( $this, 'do_extra_autosave_stuff' ), 10 ); //TODO reactivate when 4.2 autosave is implemented
200
+		}
201
+	}
202
+
203
+
204
+
205
+	/**
206
+	 * Simply ensure that we simulate the correct post route for cpt screens
207
+	 *
208
+	 * @param WP_Screen $current_screen
209
+	 * @return void
210
+	 */
211
+	public function modify_pagenow($current_screen)
212
+	{
213
+		global $pagenow, $hook_suffix;
214
+		//possibly reset pagenow.
215
+		if ( ! empty($this->_req_data['page'])
216
+			 && $this->_req_data['page'] == $this->page_slug
217
+			 && ! empty($this->_req_data['action'])
218
+			 && isset($this->_pagenow_map[$this->_req_data['action']])
219
+		) {
220
+			$pagenow = $this->_pagenow_map[$this->_req_data['action']];
221
+			$hook_suffix = $pagenow;
222
+		}
223
+	}
224
+
225
+
226
+
227
+	/**
228
+	 * This method is used to register additional autosave containers to the _autosave_containers property.
229
+	 *
230
+	 * @todo We should automate this at some point by creating a wrapper for add_post_metabox and in our wrapper we
231
+	 *       automatically register the id for the post metabox as a container.
232
+	 * @param  array $ids an array of ids for containers that hold form inputs we want autosave to pickup.  Typically
233
+	 *                    you would send along the id of a metabox container.
234
+	 * @return void
235
+	 */
236
+	protected function _register_autosave_containers($ids)
237
+	{
238
+		$this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids);
239
+	}
240
+
241
+
242
+
243
+	/**
244
+	 * Something nifty.  We're going to loop through all the registered metaboxes and if the CALLBACK is an instance of
245
+	 * EE_Admin_Page OR EE_Admin_Hooks, then we'll add the id to our _autosave_containers array.
246
+	 */
247
+	protected function _set_autosave_containers()
248
+	{
249
+		global $wp_meta_boxes;
250
+		$containers = array();
251
+		if (empty($wp_meta_boxes)) {
252
+			return;
253
+		}
254
+		$current_metaboxes = isset($wp_meta_boxes[$this->page_slug]) ? $wp_meta_boxes[$this->page_slug] : array();
255
+		foreach ($current_metaboxes as $box_context) {
256
+			foreach ($box_context as $box_details) {
257
+				foreach ($box_details as $box) {
258
+					if (is_array($box['callback'])
259
+						&& ($box['callback'][0] instanceof EE_Admin_Page
260
+							|| $box['callback'][0] instanceof EE_Admin_Hooks)
261
+					) {
262
+						$containers[] = $box['id'];
263
+					}
264
+				}
265
+			}
266
+		}
267
+		$this->_autosave_containers = array_merge($this->_autosave_containers, $containers);
268
+		//add hidden inputs container
269
+		$this->_autosave_containers[] = 'ee-cpt-hidden-inputs';
270
+	}
271
+
272
+
273
+
274
+	protected function _load_autosave_scripts_styles()
275
+	{
276
+		/*wp_register_script('cpt-autosave', EE_ADMIN_URL . 'assets/ee-cpt-autosave.js', array('ee-serialize-full-array', 'event_editor_js'), EVENT_ESPRESSO_VERSION, TRUE );
277 277
         wp_enqueue_script('cpt-autosave');/**/ //todo re-enable when we start doing autosave again in 4.2
278 278
 
279
-        //filter _autosave_containers
280
-        $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
281
-            $this->_autosave_containers, $this);
282
-        $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
283
-            $containers, $this);
284
-
285
-        wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS',
286
-            $containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
287
-
288
-        $unsaved_data_msg = array(
289
-            'eventmsg'     => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.",
290
-                'event_espresso'), $this->_cpt_object->labels->singular_name),
291
-            'inputChanged' => 0,
292
-        );
293
-        wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
294
-    }
295
-
296
-
297
-
298
-    public function load_page_dependencies()
299
-    {
300
-        try {
301
-            $this->_load_page_dependencies();
302
-        } catch (EE_Error $e) {
303
-            $e->get_error();
304
-        }
305
-    }
306
-
307
-
308
-
309
-    /**
310
-     * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
311
-     *
312
-     * @access protected
313
-     * @return void
314
-     */
315
-    protected function _load_page_dependencies()
316
-    {
317
-        //we only add stuff if this is a cpt_route!
318
-        if ( ! $this->_cpt_route) {
319
-            parent::_load_page_dependencies();
320
-            return;
321
-        }
322
-        //now let's do some automatic filters into the wp_system and we'll check to make sure the CHILD class automatically has the required methods in place.
323
-        //the following filters are for setting all the redirects on DEFAULT WP custom post type actions
324
-        //let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects!  Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
325
-        add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
326
-        //inject our Admin page nav tabs...
327
-        //let's make sure the nav tabs are set if they aren't already
328
-        //if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
329
-        add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
330
-        //modify the post_updated messages array
331
-        add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
332
-        //add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts!
333
-        add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
334
-        //This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
335
-        if ( ! empty($this->_labels['publishbox'])) {
336
-            $box_label = is_array($this->_labels['publishbox'])
337
-                         && isset($this->_labels['publishbox'][$this->_req_action])
338
-                ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
339
-            remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action],
340
-                'side', 'core');
341
-            add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action],
342
-                'side', 'core');
343
-        }
344
-        //let's add page_templates metabox if this cpt added support for it.
345
-        if ($this->_supports_page_templates($this->_cpt_object->name)) {
346
-            add_meta_box('page_templates', __('Page Template', 'event_espresso'),
347
-                array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default');
348
-        }
349
-        //this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
350
-        if (method_exists($this, 'extra_permalink_field_buttons')) {
351
-            add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
352
-        }
353
-        //add preview button
354
-        add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
355
-        //insert our own post_stati dropdown
356
-        add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
357
-        //This allows adding additional information to the publish post submitbox on the wp post edit form
358
-        if (method_exists($this, 'extra_misc_actions_publish_box')) {
359
-            add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
360
-        }
361
-        //This allows for adding additional stuff after the title field on the wp post edit form.  This is also before the wp_editor for post description field.
362
-        if (method_exists($this, 'edit_form_after_title')) {
363
-            add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
364
-        }
365
-        /**
366
-         * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
367
-         */
368
-        add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
369
-        parent::_load_page_dependencies();
370
-        //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes.
371
-        global $pagenow;
372
-        do_action('load-' . $pagenow);
373
-        $this->modify_current_screen();
374
-        add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
375
-        //we route REALLY early.
376
-        try {
377
-            $this->_route_admin_request();
378
-        } catch (EE_Error $e) {
379
-            $e->get_error();
380
-        }
381
-    }
382
-
383
-
384
-
385
-    /**
386
-     * Since we don't want users going to default core wp routes, this will check any wp urls run through the
387
-     * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
388
-     * route instead.
389
-     *
390
-     * @param string $good_protocol_url The escaped url.
391
-     * @param string $original_url      The original url.
392
-     * @param string $_context          The context sendt to the esc_url method.
393
-     * @return string possibly a new url for our route.
394
-     */
395
-    public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
396
-    {
397
-        $routes_to_match = array(
398
-            0 => array(
399
-                'edit.php?post_type=espresso_attendees',
400
-                'admin.php?page=espresso_registrations&action=contact_list',
401
-            ),
402
-            1 => array(
403
-                'edit.php?post_type=' . $this->_cpt_object->name,
404
-                'admin.php?page=' . $this->_cpt_object->name,
405
-            ),
406
-        );
407
-        foreach ($routes_to_match as $route_matches) {
408
-            if (strpos($good_protocol_url, $route_matches[0]) !== false) {
409
-                return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
410
-            }
411
-        }
412
-        return $good_protocol_url;
413
-    }
414
-
415
-
416
-
417
-    /**
418
-     * Determine whether the current cpt supports page templates or not.
419
-     *
420
-     * @since %VER%
421
-     * @param string $cpt_name The cpt slug we're checking on.
422
-     * @return bool True supported, false not.
423
-     */
424
-    private function _supports_page_templates($cpt_name)
425
-    {
426
-
427
-        $cpt_args = EE_Register_CPTs::get_CPTs();
428
-        $cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
429
-        $cpt_has_support = ! empty($cpt_args['page_templates']);
430
-
431
-        //if the installed version of WP is > 4.7 we do some additional checks.
432
-        if (EE_Recommended_Versions::check_wp_version('4.7','>=')) {
433
-            $post_templates = wp_get_theme()->get_post_templates();
434
-            //if there are $post_templates for this cpt, then we return false for this method because
435
-            //that means we aren't going to load our page template manager and leave that up to the native
436
-            //cpt template manager.
437
-            $cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
438
-        }
439
-
440
-        return $cpt_has_support;
441
-    }
442
-
443
-
444
-    /**
445
-     * Callback for the page_templates metabox selector.
446
-     *
447
-     * @since %VER%
448
-     * @return string html
449
-     */
450
-    public function page_template_meta_box()
451
-    {
452
-        global $post;
453
-        $template = '';
454
-
455
-        if (EE_Recommended_Versions::check_wp_version('4.7','>=')) {
456
-            $page_template_count = count(get_page_templates());
457
-        } else {
458
-            $page_template_count = count(get_page_templates($post));
459
-        };
460
-
461
-        if ($page_template_count) {
462
-            $page_template = get_post_meta($post->ID, '_wp_page_template', true);
463
-            $template      = ! empty($page_template) ? $page_template : '';
464
-        }
465
-        ?>
279
+		//filter _autosave_containers
280
+		$containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
281
+			$this->_autosave_containers, $this);
282
+		$containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
283
+			$containers, $this);
284
+
285
+		wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS',
286
+			$containers); //todo once we enable autosaves, this needs to be switched to localize with "cpt-autosave"
287
+
288
+		$unsaved_data_msg = array(
289
+			'eventmsg'     => sprintf(__("The changes you made to this %s will be lost if you navigate away from this page.",
290
+				'event_espresso'), $this->_cpt_object->labels->singular_name),
291
+			'inputChanged' => 0,
292
+		);
293
+		wp_localize_script('event_editor_js', 'UNSAVED_DATA_MSG', $unsaved_data_msg);
294
+	}
295
+
296
+
297
+
298
+	public function load_page_dependencies()
299
+	{
300
+		try {
301
+			$this->_load_page_dependencies();
302
+		} catch (EE_Error $e) {
303
+			$e->get_error();
304
+		}
305
+	}
306
+
307
+
308
+
309
+	/**
310
+	 * overloading the EE_Admin_Page parent load_page_dependencies so we can get the cpt stuff added in appropriately
311
+	 *
312
+	 * @access protected
313
+	 * @return void
314
+	 */
315
+	protected function _load_page_dependencies()
316
+	{
317
+		//we only add stuff if this is a cpt_route!
318
+		if ( ! $this->_cpt_route) {
319
+			parent::_load_page_dependencies();
320
+			return;
321
+		}
322
+		//now let's do some automatic filters into the wp_system and we'll check to make sure the CHILD class automatically has the required methods in place.
323
+		//the following filters are for setting all the redirects on DEFAULT WP custom post type actions
324
+		//let's add a hidden input to the post-edit form so we know when we have to trigger our custom redirects!  Otherwise the redirects will happen on ALL post saves which wouldn't be good of course!
325
+		add_action('edit_form_after_title', array($this, 'cpt_post_form_hidden_input'));
326
+		//inject our Admin page nav tabs...
327
+		//let's make sure the nav tabs are set if they aren't already
328
+		//if ( empty( $this->_nav_tabs ) ) $this->_set_nav_tabs();
329
+		add_action('post_edit_form_tag', array($this, 'inject_nav_tabs'));
330
+		//modify the post_updated messages array
331
+		add_action('post_updated_messages', array($this, 'post_update_messages'), 10);
332
+		//add shortlink button to cpt edit screens.  We can do this as a universal thing BECAUSE, cpts use the same format for shortlinks as posts!
333
+		add_filter('pre_get_shortlink', array($this, 'add_shortlink_button_to_editor'), 10, 4);
334
+		//This basically allows us to change the title of the "publish" metabox area on CPT pages by setting a 'publishbox' value in the $_labels property array in the child class.
335
+		if ( ! empty($this->_labels['publishbox'])) {
336
+			$box_label = is_array($this->_labels['publishbox'])
337
+						 && isset($this->_labels['publishbox'][$this->_req_action])
338
+				? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
339
+			remove_meta_box('submitdiv', __('Publish'), 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action],
340
+				'side', 'core');
341
+			add_meta_box('submitdiv', $box_label, 'post_submit_meta_box', $this->_cpt_routes[$this->_req_action],
342
+				'side', 'core');
343
+		}
344
+		//let's add page_templates metabox if this cpt added support for it.
345
+		if ($this->_supports_page_templates($this->_cpt_object->name)) {
346
+			add_meta_box('page_templates', __('Page Template', 'event_espresso'),
347
+				array($this, 'page_template_meta_box'), $this->_cpt_routes[$this->_req_action], 'side', 'default');
348
+		}
349
+		//this is a filter that allows the addition of extra html after the permalink field on the wp post edit-form
350
+		if (method_exists($this, 'extra_permalink_field_buttons')) {
351
+			add_filter('get_sample_permalink_html', array($this, 'extra_permalink_field_buttons'), 10, 4);
352
+		}
353
+		//add preview button
354
+		add_filter('get_sample_permalink_html', array($this, 'preview_button_html'), 5, 4);
355
+		//insert our own post_stati dropdown
356
+		add_action('post_submitbox_misc_actions', array($this, 'custom_post_stati_dropdown'), 10);
357
+		//This allows adding additional information to the publish post submitbox on the wp post edit form
358
+		if (method_exists($this, 'extra_misc_actions_publish_box')) {
359
+			add_action('post_submitbox_misc_actions', array($this, 'extra_misc_actions_publish_box'), 10);
360
+		}
361
+		//This allows for adding additional stuff after the title field on the wp post edit form.  This is also before the wp_editor for post description field.
362
+		if (method_exists($this, 'edit_form_after_title')) {
363
+			add_action('edit_form_after_title', array($this, 'edit_form_after_title'), 10);
364
+		}
365
+		/**
366
+		 * Filtering WP's esc_url to capture urls pointing to core wp routes so they point to our route.
367
+		 */
368
+		add_filter('clean_url', array($this, 'switch_core_wp_urls_with_ours'), 10, 3);
369
+		parent::_load_page_dependencies();
370
+		//notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes.
371
+		global $pagenow;
372
+		do_action('load-' . $pagenow);
373
+		$this->modify_current_screen();
374
+		add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
375
+		//we route REALLY early.
376
+		try {
377
+			$this->_route_admin_request();
378
+		} catch (EE_Error $e) {
379
+			$e->get_error();
380
+		}
381
+	}
382
+
383
+
384
+
385
+	/**
386
+	 * Since we don't want users going to default core wp routes, this will check any wp urls run through the
387
+	 * esc_url() method and if we see a url matching a pattern for our routes, we'll modify it to point to OUR
388
+	 * route instead.
389
+	 *
390
+	 * @param string $good_protocol_url The escaped url.
391
+	 * @param string $original_url      The original url.
392
+	 * @param string $_context          The context sendt to the esc_url method.
393
+	 * @return string possibly a new url for our route.
394
+	 */
395
+	public function switch_core_wp_urls_with_ours($good_protocol_url, $original_url, $_context)
396
+	{
397
+		$routes_to_match = array(
398
+			0 => array(
399
+				'edit.php?post_type=espresso_attendees',
400
+				'admin.php?page=espresso_registrations&action=contact_list',
401
+			),
402
+			1 => array(
403
+				'edit.php?post_type=' . $this->_cpt_object->name,
404
+				'admin.php?page=' . $this->_cpt_object->name,
405
+			),
406
+		);
407
+		foreach ($routes_to_match as $route_matches) {
408
+			if (strpos($good_protocol_url, $route_matches[0]) !== false) {
409
+				return str_replace($route_matches[0], $route_matches[1], $good_protocol_url);
410
+			}
411
+		}
412
+		return $good_protocol_url;
413
+	}
414
+
415
+
416
+
417
+	/**
418
+	 * Determine whether the current cpt supports page templates or not.
419
+	 *
420
+	 * @since %VER%
421
+	 * @param string $cpt_name The cpt slug we're checking on.
422
+	 * @return bool True supported, false not.
423
+	 */
424
+	private function _supports_page_templates($cpt_name)
425
+	{
426
+
427
+		$cpt_args = EE_Register_CPTs::get_CPTs();
428
+		$cpt_args = isset($cpt_args[$cpt_name]) ? $cpt_args[$cpt_name]['args'] : array();
429
+		$cpt_has_support = ! empty($cpt_args['page_templates']);
430
+
431
+		//if the installed version of WP is > 4.7 we do some additional checks.
432
+		if (EE_Recommended_Versions::check_wp_version('4.7','>=')) {
433
+			$post_templates = wp_get_theme()->get_post_templates();
434
+			//if there are $post_templates for this cpt, then we return false for this method because
435
+			//that means we aren't going to load our page template manager and leave that up to the native
436
+			//cpt template manager.
437
+			$cpt_has_support = ! isset($post_templates[$cpt_name]) ? $cpt_has_support : false;
438
+		}
439
+
440
+		return $cpt_has_support;
441
+	}
442
+
443
+
444
+	/**
445
+	 * Callback for the page_templates metabox selector.
446
+	 *
447
+	 * @since %VER%
448
+	 * @return string html
449
+	 */
450
+	public function page_template_meta_box()
451
+	{
452
+		global $post;
453
+		$template = '';
454
+
455
+		if (EE_Recommended_Versions::check_wp_version('4.7','>=')) {
456
+			$page_template_count = count(get_page_templates());
457
+		} else {
458
+			$page_template_count = count(get_page_templates($post));
459
+		};
460
+
461
+		if ($page_template_count) {
462
+			$page_template = get_post_meta($post->ID, '_wp_page_template', true);
463
+			$template      = ! empty($page_template) ? $page_template : '';
464
+		}
465
+		?>
466 466
         <p><strong><?php _e('Template') ?></strong></p>
467 467
         <label class="screen-reader-text" for="page_template"><?php _e('Page Template') ?></label><select
468 468
             name="page_template" id="page_template">
@@ -470,437 +470,437 @@  discard block
 block discarded – undo
470 470
         <?php page_template_dropdown($template); ?>
471 471
     </select>
472 472
         <?php
473
-    }
474
-
475
-
476
-
477
-    /**
478
-     * if this post is a draft or scheduled post then we provide a preview button for user to click
479
-     * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
480
-     *
481
-     * @param  string $return    the current html
482
-     * @param  int    $id        the post id for the page
483
-     * @param  string $new_title What the title is
484
-     * @param  string $new_slug  what the slug is
485
-     * @return string            The new html string for the permalink area
486
-     */
487
-    public function preview_button_html($return, $id, $new_title, $new_slug)
488
-    {
489
-        $post = get_post($id);
490
-        if ('publish' != get_post_status($post)) {
491
-            //include shims for the `get_preview_post_link` function
492
-            require_once( EE_CORE . 'wordpress-shims.php' );
493
-            $return .= '<span_id="view-post-btn"><a target="_blank" href="'
494
-                       . get_preview_post_link($id)
495
-                       . '" class="button button-small">'
496
-                       . __('Preview', 'event_espresso')
497
-                       . '</a></span>'
498
-                       . "\n";
499
-        }
500
-        return $return;
501
-    }
502
-
503
-
504
-
505
-    /**
506
-     * add our custom post stati dropdown on the wp post page for this cpt
507
-     *
508
-     * @return string html for dropdown
509
-     */
510
-    public function custom_post_stati_dropdown()
511
-    {
512
-
513
-        $statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
514
-        $cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
515
-            ? $statuses[$this->_cpt_model_obj->status()]
516
-            : '';
517
-        $template_args    = array(
518
-            'cur_status'            => $this->_cpt_model_obj->status(),
519
-            'statuses'              => $statuses,
520
-            'cur_status_label'      => $cur_status_label,
521
-            'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
522
-        );
523
-        //we'll add a trash post status (WP doesn't add one for some reason)
524
-        if ($this->_cpt_model_obj->status() == 'trash') {
525
-            $template_args['cur_status_label'] = __('Trashed', 'event_espresso');
526
-            $statuses['trash']                 = __('Trashed', 'event_espresso');
527
-            $template_args['statuses']         = $statuses;
528
-        }
529
-
530
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
531
-        EEH_Template::display_template($template, $template_args);
532
-    }
533
-
534
-
535
-
536
-    public function setup_autosave_hooks()
537
-    {
538
-        $this->_set_autosave_containers();
539
-        $this->_load_autosave_scripts_styles();
540
-    }
541
-
542
-
543
-
544
-    /**
545
-     * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
546
-     * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
547
-     * for the nonce in here, but then this method looks for two things:
548
-     * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
549
-     * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
550
-     * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
551
-     * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
552
-     * template args.
553
-     *    1. $template_args['error'] = IF there is an error you can add the message in here.
554
-     *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
555
-     *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
556
-     *    $this->_template_args['data']['items'] = array(
557
-     *        'event-datetime-ids' => '1,2,3';
558
-     *    );
559
-     *    Keep in mind the following things:
560
-     *    - "where" index is for the input with the id as that string.
561
-     *    - "what" index is what will be used for the value of that input.
562
-     *
563
-     * @return void
564
-     */
565
-    public function do_extra_autosave_stuff()
566
-    {
567
-        //next let's check for the autosave nonce (we'll use _verify_nonce )
568
-        $nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : null;
569
-        $this->_verify_nonce($nonce, 'autosave');
570
-        //make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
571
-        if ( ! defined('DOING_AUTOSAVE')) {
572
-            define('DOING_AUTOSAVE', true);
573
-        }
574
-        //if we made it here then the nonce checked out.  Let's run our methods and actions
575
-        if (method_exists($this, '_ee_autosave_' . $this->_current_view)) {
576
-            call_user_func(array($this, '_ee_autosave_' . $this->_current_view));
577
-        } else {
578
-            $this->_template_args['success'] = true;
579
-        }
580
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
581
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
582
-        //now let's return json
583
-        $this->_return_json();
584
-    }
585
-
586
-
587
-
588
-    /**
589
-     * This takes care of setting up default routes and pages that utilize the core WP admin pages.
590
-     * Child classes can override the defaults (in cases for adding metaboxes etc.)
591
-     * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
592
-     *
593
-     * @access protected
594
-     * @throws EE_Error
595
-     * @return void
596
-     */
597
-    protected function _extend_page_config_for_cpt()
598
-    {
599
-        //before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
600
-        if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) {
601
-            return;
602
-        }
603
-        //set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
604
-        if ( ! empty($this->_cpt_object)) {
605
-            $this->_page_routes = array_merge(array(
606
-                'create_new' => '_create_new_cpt_item',
607
-                'edit'       => '_edit_cpt_item',
608
-            ), $this->_page_routes);
609
-            $this->_page_config = array_merge(array(
610
-                'create_new' => array(
611
-                    'nav'           => array(
612
-                        'label' => $this->_cpt_object->labels->add_new_item,
613
-                        'order' => 5,
614
-                    ),
615
-                    'require_nonce' => false,
616
-                ),
617
-                'edit'       => array(
618
-                    'nav'           => array(
619
-                        'label'      => $this->_cpt_object->labels->edit_item,
620
-                        'order'      => 5,
621
-                        'persistent' => false,
622
-                        'url'        => '',
623
-                    ),
624
-                    'require_nonce' => false,
625
-                ),
626
-            ),
627
-                $this->_page_config
628
-            );
629
-        }
630
-        //load the next section only if this is a matching cpt route as set in the cpt routes array.
631
-        if ( ! isset($this->_cpt_routes[$this->_req_action])) {
632
-            return;
633
-        }
634
-        $this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
635
-        //add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
636
-        if (empty($this->_cpt_object)) {
637
-            $msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'),
638
-                $this->page_slug, $this->_req_action, get_class($this));
639
-            throw new EE_Error($msg);
640
-        }
641
-        if ($this->_cpt_route) {
642
-            $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
643
-            $this->_set_model_object($id);
644
-        }
645
-    }
646
-
647
-
648
-
649
-    /**
650
-     * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
651
-     *
652
-     * @access protected
653
-     * @param int  $id The id to retrieve the model object for. If empty we set a default object.
654
-     * @param bool $ignore_route_check
655
-     */
656
-    protected function _set_model_object($id = null, $ignore_route_check = false)
657
-    {
658
-        $model = null;
659
-        if (
660
-            empty($this->_cpt_model_names)
661
-            || (
662
-                ! $ignore_route_check
663
-                && ! isset($this->_cpt_routes[$this->_req_action])
664
-            ) || (
665
-                $this->_cpt_model_obj instanceof EE_CPT_Base
666
-                && $this->_cpt_model_obj->ID() === $id
667
-            )
668
-        ) {
669
-            //get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
670
-            return;
671
-        }
672
-        //if ignore_route_check is true, then get the model name via EE_Register_CPTs
673
-        if ($ignore_route_check) {
674
-            $model_names = EE_Register_CPTs::get_cpt_model_names();
675
-            $post_type   = get_post_type($id);
676
-            if (isset($model_names[$post_type])) {
677
-                $model = EE_Registry::instance()->load_model($model_names[$post_type]);
678
-            }
679
-        } else {
680
-            $model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
681
-        }
682
-        if ($model instanceof EEM_Base) {
683
-            $this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
684
-        }
685
-        do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object');
686
-    }
687
-
688
-
689
-
690
-    /**
691
-     * admin_init_global
692
-     * This runs all the code that we want executed within the WP admin_init hook.
693
-     * This method executes for ALL EE Admin pages.
694
-     *
695
-     * @access public
696
-     * @return void
697
-     */
698
-    public function admin_init_global()
699
-    {
700
-        $post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
701
-        //its possible this is a new save so let's catch that instead
702
-        $post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
703
-        $post_type = $post ? $post->post_type : false;
704
-        $current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route']
705
-            : 'shouldneverwork';
706
-        $route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route]
707
-            : '';
708
-        add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
709
-        add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
710
-        if ($post_type === $route_to_check) {
711
-            add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
712
-            //catch trashed wp redirect
713
-            add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2);
714
-        }
715
-        //now let's filter redirect if we're on a revision page and the revision is for an event CPT.
716
-        $revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
717
-        if ( ! empty($revision)) {
718
-            $action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
719
-            //doing a restore?
720
-            if ( ! empty($action) && $action == 'restore') {
721
-                //get post for revision
722
-                $rev_post = get_post($revision);
723
-                $rev_parent = get_post($rev_post->post_parent);
724
-                //only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
725
-                if ($rev_parent && $rev_parent->post_type == $this->page_slug) {
726
-                    add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
727
-                    //restores of revisions
728
-                    add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
729
-                }
730
-            }
731
-        }
732
-        //NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
733
-        if ($post_type && $post_type === $route_to_check) {
734
-            //$post_id, $post
735
-            add_action('save_post', array($this, 'insert_update'), 10, 3);
736
-            //$post_id
737
-            add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
738
-            add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
739
-            add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
740
-            add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
741
-        }
742
-    }
743
-
744
-
745
-
746
-    /**
747
-     * Callback for the WordPress trashed_post hook.
748
-     * Execute some basic checks before calling the trash_cpt_item declared in the child class.
749
-     *
750
-     * @param int $post_id
751
-     */
752
-    public function before_trash_cpt_item($post_id)
753
-    {
754
-        $this->_set_model_object($post_id, true);
755
-        //if our cpt object isn't existent then get out immediately.
756
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
757
-            return;
758
-        }
759
-        $this->trash_cpt_item($post_id);
760
-    }
761
-
762
-
763
-
764
-    /**
765
-     * Callback for the WordPress untrashed_post hook.
766
-     * Execute some basic checks before calling the restore_cpt_method in the child class.
767
-     *
768
-     * @param $post_id
769
-     */
770
-    public function before_restore_cpt_item($post_id)
771
-    {
772
-        $this->_set_model_object($post_id, true);
773
-        //if our cpt object isn't existent then get out immediately.
774
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
775
-            return;
776
-        }
777
-        $this->restore_cpt_item($post_id);
778
-    }
779
-
780
-
781
-
782
-    /**
783
-     * Callback for the WordPress after_delete_post hook.
784
-     * Execute some basic checks before calling the delete_cpt_item method in the child class.
785
-     *
786
-     * @param $post_id
787
-     */
788
-    public function before_delete_cpt_item($post_id)
789
-    {
790
-        $this->_set_model_object($post_id, true);
791
-        //if our cpt object isn't existent then get out immediately.
792
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
793
-            return;
794
-        }
795
-        $this->delete_cpt_item($post_id);
796
-    }
797
-
798
-
799
-
800
-    /**
801
-     * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
802
-     * accordingly.
803
-     *
804
-     * @access public
805
-     * @throws EE_Error
806
-     * @return void
807
-     */
808
-    public function verify_cpt_object()
809
-    {
810
-        $label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
811
-        // verify event object
812
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
813
-            throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
814
-                'event_espresso'), $label));
815
-        }
816
-        //if auto-draft then throw an error
817
-        if ($this->_cpt_model_obj->get('status') == 'auto-draft') {
818
-            EE_Error::overwrite_errors();
819
-            EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'),
820
-                $label), __FILE__, __FUNCTION__, __LINE__);
821
-        }
822
-    }
823
-
824
-
825
-
826
-    /**
827
-     * admin_footer_scripts_global
828
-     * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
829
-     * will apply on ALL EE_Admin pages.
830
-     *
831
-     * @access public
832
-     * @return void
833
-     */
834
-    public function admin_footer_scripts_global()
835
-    {
836
-        $this->_add_admin_page_ajax_loading_img();
837
-        $this->_add_admin_page_overlay();
838
-    }
839
-
840
-
841
-
842
-    /**
843
-     * add in any global scripts for cpt routes
844
-     *
845
-     * @return void
846
-     */
847
-    public function load_global_scripts_styles()
848
-    {
849
-        parent::load_global_scripts_styles();
850
-        if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
851
-            //setup custom post status object for localize script but only if we've got a cpt object
852
-            $statuses = $this->_cpt_model_obj->get_custom_post_statuses();
853
-            if ( ! empty($statuses)) {
854
-                //get ALL statuses!
855
-                $statuses = $this->_cpt_model_obj->get_all_post_statuses();
856
-                //setup object
857
-                $ee_cpt_statuses = array();
858
-                foreach ($statuses as $status => $label) {
859
-                    $ee_cpt_statuses[$status] = array(
860
-                        'label'      => $label,
861
-                        'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
862
-                    );
863
-                }
864
-                wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
865
-            }
866
-        }
867
-    }
868
-
869
-
870
-
871
-    /**
872
-     * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
873
-     * insert/updates
874
-     *
875
-     * @param  int     $post_id ID of post being updated
876
-     * @param  WP_Post $post    Post object from WP
877
-     * @param  bool    $update  Whether this is an update or a new save.
878
-     * @return void
879
-     */
880
-    public function insert_update($post_id, $post, $update)
881
-    {
882
-        //make sure that if this is a revision OR trash action that we don't do any updates!
883
-        if (
884
-            isset($this->_req_data['action'])
885
-            && (
886
-                $this->_req_data['action'] == 'restore'
887
-                || $this->_req_data['action'] == 'trash'
888
-            )
889
-        ) {
890
-            return;
891
-        }
892
-        $this->_set_model_object($post_id, true);
893
-        //if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
894
-        if ($update
895
-            && (
896
-                ! $this->_cpt_model_obj instanceof EE_CPT_Base
897
-                || $this->_cpt_model_obj->ID() !== $post_id
898
-            )
899
-        ) {
900
-            return;
901
-        }
902
-        //check for autosave and update our req_data property accordingly.
903
-        /*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
473
+	}
474
+
475
+
476
+
477
+	/**
478
+	 * if this post is a draft or scheduled post then we provide a preview button for user to click
479
+	 * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter.
480
+	 *
481
+	 * @param  string $return    the current html
482
+	 * @param  int    $id        the post id for the page
483
+	 * @param  string $new_title What the title is
484
+	 * @param  string $new_slug  what the slug is
485
+	 * @return string            The new html string for the permalink area
486
+	 */
487
+	public function preview_button_html($return, $id, $new_title, $new_slug)
488
+	{
489
+		$post = get_post($id);
490
+		if ('publish' != get_post_status($post)) {
491
+			//include shims for the `get_preview_post_link` function
492
+			require_once( EE_CORE . 'wordpress-shims.php' );
493
+			$return .= '<span_id="view-post-btn"><a target="_blank" href="'
494
+					   . get_preview_post_link($id)
495
+					   . '" class="button button-small">'
496
+					   . __('Preview', 'event_espresso')
497
+					   . '</a></span>'
498
+					   . "\n";
499
+		}
500
+		return $return;
501
+	}
502
+
503
+
504
+
505
+	/**
506
+	 * add our custom post stati dropdown on the wp post page for this cpt
507
+	 *
508
+	 * @return string html for dropdown
509
+	 */
510
+	public function custom_post_stati_dropdown()
511
+	{
512
+
513
+		$statuses         = $this->_cpt_model_obj->get_custom_post_statuses();
514
+		$cur_status_label = array_key_exists($this->_cpt_model_obj->status(), $statuses)
515
+			? $statuses[$this->_cpt_model_obj->status()]
516
+			: '';
517
+		$template_args    = array(
518
+			'cur_status'            => $this->_cpt_model_obj->status(),
519
+			'statuses'              => $statuses,
520
+			'cur_status_label'      => $cur_status_label,
521
+			'localized_status_save' => sprintf(__('Save %s', 'event_espresso'), $cur_status_label),
522
+		);
523
+		//we'll add a trash post status (WP doesn't add one for some reason)
524
+		if ($this->_cpt_model_obj->status() == 'trash') {
525
+			$template_args['cur_status_label'] = __('Trashed', 'event_espresso');
526
+			$statuses['trash']                 = __('Trashed', 'event_espresso');
527
+			$template_args['statuses']         = $statuses;
528
+		}
529
+
530
+		$template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
531
+		EEH_Template::display_template($template, $template_args);
532
+	}
533
+
534
+
535
+
536
+	public function setup_autosave_hooks()
537
+	{
538
+		$this->_set_autosave_containers();
539
+		$this->_load_autosave_scripts_styles();
540
+	}
541
+
542
+
543
+
544
+	/**
545
+	 * This is run on all WordPress autosaves AFTER the autosave is complete and sends along a $_POST object (available
546
+	 * in $this->_req_data) containing: post_ID of the saved post autosavenonce for the saved post We'll do the check
547
+	 * for the nonce in here, but then this method looks for two things:
548
+	 * 1. Execute a method (if exists) matching 'ee_autosave_' and appended with the given route. OR
549
+	 * 2. do_actions() for global or class specific actions that have been registered (for plugins/addons not in an
550
+	 * EE_Admin_Page class. PLEASE NOTE: Data will be returned using the _return_json() object and so the
551
+	 * $_template_args property should be used to hold the $data array.  We're expecting the following things set in
552
+	 * template args.
553
+	 *    1. $template_args['error'] = IF there is an error you can add the message in here.
554
+	 *    2. $template_args['data']['items'] = an array of items that are setup in key index pairs of 'where_values_go'
555
+	 *    => 'values_to_add'.  In other words, for the datetime metabox we'll have something like
556
+	 *    $this->_template_args['data']['items'] = array(
557
+	 *        'event-datetime-ids' => '1,2,3';
558
+	 *    );
559
+	 *    Keep in mind the following things:
560
+	 *    - "where" index is for the input with the id as that string.
561
+	 *    - "what" index is what will be used for the value of that input.
562
+	 *
563
+	 * @return void
564
+	 */
565
+	public function do_extra_autosave_stuff()
566
+	{
567
+		//next let's check for the autosave nonce (we'll use _verify_nonce )
568
+		$nonce = isset($this->_req_data['autosavenonce']) ? $this->_req_data['autosavenonce'] : null;
569
+		$this->_verify_nonce($nonce, 'autosave');
570
+		//make sure we define doing autosave (cause WP isn't triggering this we want to make sure we define it)
571
+		if ( ! defined('DOING_AUTOSAVE')) {
572
+			define('DOING_AUTOSAVE', true);
573
+		}
574
+		//if we made it here then the nonce checked out.  Let's run our methods and actions
575
+		if (method_exists($this, '_ee_autosave_' . $this->_current_view)) {
576
+			call_user_func(array($this, '_ee_autosave_' . $this->_current_view));
577
+		} else {
578
+			$this->_template_args['success'] = true;
579
+		}
580
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
581
+		do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
582
+		//now let's return json
583
+		$this->_return_json();
584
+	}
585
+
586
+
587
+
588
+	/**
589
+	 * This takes care of setting up default routes and pages that utilize the core WP admin pages.
590
+	 * Child classes can override the defaults (in cases for adding metaboxes etc.)
591
+	 * but take care that you include the defaults here otherwise your core WP admin pages for the cpt won't work!
592
+	 *
593
+	 * @access protected
594
+	 * @throws EE_Error
595
+	 * @return void
596
+	 */
597
+	protected function _extend_page_config_for_cpt()
598
+	{
599
+		//before doing anything we need to make sure this runs ONLY when the loaded page matches the set page_slug
600
+		if ((isset($this->_req_data['page']) && $this->_req_data['page'] != $this->page_slug)) {
601
+			return;
602
+		}
603
+		//set page routes and page config but ONLY if we're not viewing a custom setup cpt route as defined in _cpt_routes
604
+		if ( ! empty($this->_cpt_object)) {
605
+			$this->_page_routes = array_merge(array(
606
+				'create_new' => '_create_new_cpt_item',
607
+				'edit'       => '_edit_cpt_item',
608
+			), $this->_page_routes);
609
+			$this->_page_config = array_merge(array(
610
+				'create_new' => array(
611
+					'nav'           => array(
612
+						'label' => $this->_cpt_object->labels->add_new_item,
613
+						'order' => 5,
614
+					),
615
+					'require_nonce' => false,
616
+				),
617
+				'edit'       => array(
618
+					'nav'           => array(
619
+						'label'      => $this->_cpt_object->labels->edit_item,
620
+						'order'      => 5,
621
+						'persistent' => false,
622
+						'url'        => '',
623
+					),
624
+					'require_nonce' => false,
625
+				),
626
+			),
627
+				$this->_page_config
628
+			);
629
+		}
630
+		//load the next section only if this is a matching cpt route as set in the cpt routes array.
631
+		if ( ! isset($this->_cpt_routes[$this->_req_action])) {
632
+			return;
633
+		}
634
+		$this->_cpt_route = isset($this->_cpt_routes[$this->_req_action]) ? true : false;
635
+		//add_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', array( $this, 'modify_current_screen') );
636
+		if (empty($this->_cpt_object)) {
637
+			$msg = sprintf(__('This page has been set as being related to a registered custom post type, however, the custom post type object could not be retrieved. There are two possible reasons for this:  1. The "%s" does not match a registered post type. or 2. The custom post type is not registered for the "%s" action as indexed in the "$_cpt_routes" property on this class (%s).'),
638
+				$this->page_slug, $this->_req_action, get_class($this));
639
+			throw new EE_Error($msg);
640
+		}
641
+		if ($this->_cpt_route) {
642
+			$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
643
+			$this->_set_model_object($id);
644
+		}
645
+	}
646
+
647
+
648
+
649
+	/**
650
+	 * Sets the _cpt_model_object property using what has been set for the _cpt_model_name and a given id.
651
+	 *
652
+	 * @access protected
653
+	 * @param int  $id The id to retrieve the model object for. If empty we set a default object.
654
+	 * @param bool $ignore_route_check
655
+	 */
656
+	protected function _set_model_object($id = null, $ignore_route_check = false)
657
+	{
658
+		$model = null;
659
+		if (
660
+			empty($this->_cpt_model_names)
661
+			|| (
662
+				! $ignore_route_check
663
+				&& ! isset($this->_cpt_routes[$this->_req_action])
664
+			) || (
665
+				$this->_cpt_model_obj instanceof EE_CPT_Base
666
+				&& $this->_cpt_model_obj->ID() === $id
667
+			)
668
+		) {
669
+			//get out cuz we either don't have a model name OR the object has already been set and it has the same id as what has been sent.
670
+			return;
671
+		}
672
+		//if ignore_route_check is true, then get the model name via EE_Register_CPTs
673
+		if ($ignore_route_check) {
674
+			$model_names = EE_Register_CPTs::get_cpt_model_names();
675
+			$post_type   = get_post_type($id);
676
+			if (isset($model_names[$post_type])) {
677
+				$model = EE_Registry::instance()->load_model($model_names[$post_type]);
678
+			}
679
+		} else {
680
+			$model = EE_Registry::instance()->load_model($this->_cpt_model_names[$this->_req_action]);
681
+		}
682
+		if ($model instanceof EEM_Base) {
683
+			$this->_cpt_model_obj = ! empty($id) ? $model->get_one_by_ID($id) : $model->create_default_object();
684
+		}
685
+		do_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object');
686
+	}
687
+
688
+
689
+
690
+	/**
691
+	 * admin_init_global
692
+	 * This runs all the code that we want executed within the WP admin_init hook.
693
+	 * This method executes for ALL EE Admin pages.
694
+	 *
695
+	 * @access public
696
+	 * @return void
697
+	 */
698
+	public function admin_init_global()
699
+	{
700
+		$post = isset($this->_req_data['post']) ? get_post($this->_req_data['post']) : null;
701
+		//its possible this is a new save so let's catch that instead
702
+		$post = isset($this->_req_data['post_ID']) ? get_post($this->_req_data['post_ID']) : $post;
703
+		$post_type = $post ? $post->post_type : false;
704
+		$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route']
705
+			: 'shouldneverwork';
706
+		$route_to_check = $post_type && isset($this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route]
707
+			: '';
708
+		add_filter('get_delete_post_link', array($this, 'modify_delete_post_link'), 10, 3);
709
+		add_filter('get_edit_post_link', array($this, 'modify_edit_post_link'), 10, 3);
710
+		if ($post_type === $route_to_check) {
711
+			add_filter('redirect_post_location', array($this, 'cpt_post_location_redirect'), 10, 2);
712
+			//catch trashed wp redirect
713
+			add_filter('wp_redirect', array($this, 'cpt_trash_post_location_redirect'), 10, 2);
714
+		}
715
+		//now let's filter redirect if we're on a revision page and the revision is for an event CPT.
716
+		$revision = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
717
+		if ( ! empty($revision)) {
718
+			$action = isset($this->_req_data['action']) ? $this->_req_data['action'] : null;
719
+			//doing a restore?
720
+			if ( ! empty($action) && $action == 'restore') {
721
+				//get post for revision
722
+				$rev_post = get_post($revision);
723
+				$rev_parent = get_post($rev_post->post_parent);
724
+				//only do our redirect filter AND our restore revision action if the post_type for the parent is one of our cpts.
725
+				if ($rev_parent && $rev_parent->post_type == $this->page_slug) {
726
+					add_filter('wp_redirect', array($this, 'revision_redirect'), 10, 2);
727
+					//restores of revisions
728
+					add_action('wp_restore_post_revision', array($this, 'restore_revision'), 10, 2);
729
+				}
730
+			}
731
+		}
732
+		//NOTE we ONLY want to run these hooks if we're on the right class for the given post type.  Otherwise we could see some really freaky things happen!
733
+		if ($post_type && $post_type === $route_to_check) {
734
+			//$post_id, $post
735
+			add_action('save_post', array($this, 'insert_update'), 10, 3);
736
+			//$post_id
737
+			add_action('trashed_post', array($this, 'before_trash_cpt_item'), 10);
738
+			add_action('trashed_post', array($this, 'dont_permanently_delete_ee_cpts'), 10);
739
+			add_action('untrashed_post', array($this, 'before_restore_cpt_item'), 10);
740
+			add_action('after_delete_post', array($this, 'before_delete_cpt_item'), 10);
741
+		}
742
+	}
743
+
744
+
745
+
746
+	/**
747
+	 * Callback for the WordPress trashed_post hook.
748
+	 * Execute some basic checks before calling the trash_cpt_item declared in the child class.
749
+	 *
750
+	 * @param int $post_id
751
+	 */
752
+	public function before_trash_cpt_item($post_id)
753
+	{
754
+		$this->_set_model_object($post_id, true);
755
+		//if our cpt object isn't existent then get out immediately.
756
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
757
+			return;
758
+		}
759
+		$this->trash_cpt_item($post_id);
760
+	}
761
+
762
+
763
+
764
+	/**
765
+	 * Callback for the WordPress untrashed_post hook.
766
+	 * Execute some basic checks before calling the restore_cpt_method in the child class.
767
+	 *
768
+	 * @param $post_id
769
+	 */
770
+	public function before_restore_cpt_item($post_id)
771
+	{
772
+		$this->_set_model_object($post_id, true);
773
+		//if our cpt object isn't existent then get out immediately.
774
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
775
+			return;
776
+		}
777
+		$this->restore_cpt_item($post_id);
778
+	}
779
+
780
+
781
+
782
+	/**
783
+	 * Callback for the WordPress after_delete_post hook.
784
+	 * Execute some basic checks before calling the delete_cpt_item method in the child class.
785
+	 *
786
+	 * @param $post_id
787
+	 */
788
+	public function before_delete_cpt_item($post_id)
789
+	{
790
+		$this->_set_model_object($post_id, true);
791
+		//if our cpt object isn't existent then get out immediately.
792
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base || $this->_cpt_model_obj->ID() !== $post_id) {
793
+			return;
794
+		}
795
+		$this->delete_cpt_item($post_id);
796
+	}
797
+
798
+
799
+
800
+	/**
801
+	 * This simply verifies if the cpt_model_object is instantiated for the given page and throws an error message
802
+	 * accordingly.
803
+	 *
804
+	 * @access public
805
+	 * @throws EE_Error
806
+	 * @return void
807
+	 */
808
+	public function verify_cpt_object()
809
+	{
810
+		$label = ! empty($this->_cpt_object) ? $this->_cpt_object->labels->singular_name : $this->page_label;
811
+		// verify event object
812
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
813
+			throw new EE_Error(sprintf(__('Something has gone wrong with the page load because we are unable to set up the object for the %1$s.  This usually happens when the given id for the page route is NOT for the correct custom post type for this page',
814
+				'event_espresso'), $label));
815
+		}
816
+		//if auto-draft then throw an error
817
+		if ($this->_cpt_model_obj->get('status') == 'auto-draft') {
818
+			EE_Error::overwrite_errors();
819
+			EE_Error::add_error(sprintf(__('This %1$s was saved without a title, description, or excerpt which means that none of the extra details you added were saved properly.  All autodrafts will show up in the "draft" view of your event list table.  You can delete them from there. Please click the "Add %1$s" button to refresh and restart.'),
820
+				$label), __FILE__, __FUNCTION__, __LINE__);
821
+		}
822
+	}
823
+
824
+
825
+
826
+	/**
827
+	 * admin_footer_scripts_global
828
+	 * Anything triggered by the 'admin_print_footer_scripts' WP hook should be put in here. This particular method
829
+	 * will apply on ALL EE_Admin pages.
830
+	 *
831
+	 * @access public
832
+	 * @return void
833
+	 */
834
+	public function admin_footer_scripts_global()
835
+	{
836
+		$this->_add_admin_page_ajax_loading_img();
837
+		$this->_add_admin_page_overlay();
838
+	}
839
+
840
+
841
+
842
+	/**
843
+	 * add in any global scripts for cpt routes
844
+	 *
845
+	 * @return void
846
+	 */
847
+	public function load_global_scripts_styles()
848
+	{
849
+		parent::load_global_scripts_styles();
850
+		if ($this->_cpt_model_obj instanceof EE_CPT_Base) {
851
+			//setup custom post status object for localize script but only if we've got a cpt object
852
+			$statuses = $this->_cpt_model_obj->get_custom_post_statuses();
853
+			if ( ! empty($statuses)) {
854
+				//get ALL statuses!
855
+				$statuses = $this->_cpt_model_obj->get_all_post_statuses();
856
+				//setup object
857
+				$ee_cpt_statuses = array();
858
+				foreach ($statuses as $status => $label) {
859
+					$ee_cpt_statuses[$status] = array(
860
+						'label'      => $label,
861
+						'save_label' => sprintf(__('Save as %s', 'event_espresso'), $label),
862
+					);
863
+				}
864
+				wp_localize_script('ee_admin_js', 'eeCPTstatuses', $ee_cpt_statuses);
865
+			}
866
+		}
867
+	}
868
+
869
+
870
+
871
+	/**
872
+	 * This is a wrapper for the insert/update routes for cpt items so we can add things that are common to ALL
873
+	 * insert/updates
874
+	 *
875
+	 * @param  int     $post_id ID of post being updated
876
+	 * @param  WP_Post $post    Post object from WP
877
+	 * @param  bool    $update  Whether this is an update or a new save.
878
+	 * @return void
879
+	 */
880
+	public function insert_update($post_id, $post, $update)
881
+	{
882
+		//make sure that if this is a revision OR trash action that we don't do any updates!
883
+		if (
884
+			isset($this->_req_data['action'])
885
+			&& (
886
+				$this->_req_data['action'] == 'restore'
887
+				|| $this->_req_data['action'] == 'trash'
888
+			)
889
+		) {
890
+			return;
891
+		}
892
+		$this->_set_model_object($post_id, true);
893
+		//if our cpt object is not instantiated and its NOT the same post_id as what is triggering this callback, then exit.
894
+		if ($update
895
+			&& (
896
+				! $this->_cpt_model_obj instanceof EE_CPT_Base
897
+				|| $this->_cpt_model_obj->ID() !== $post_id
898
+			)
899
+		) {
900
+			return;
901
+		}
902
+		//check for autosave and update our req_data property accordingly.
903
+		/*if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE && isset( $this->_req_data['ee_autosave_data'] ) ) {
904 904
             foreach( (array) $this->_req_data['ee_autosave_data'] as $id => $values ) {
905 905
 
906 906
                 foreach ( (array) $values as $key => $value ) {
@@ -910,536 +910,536 @@  discard block
 block discarded – undo
910 910
 
911 911
         }/**/ //TODO reactivate after autosave is implemented in 4.2
912 912
 
913
-        //take care of updating any selected page_template IF this cpt supports it.
914
-        if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
915
-            //wp version aware.
916
-            if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) {
917
-                $page_templates = wp_get_theme()->get_page_templates();
918
-            } else {
919
-                $post->page_template = $this->_req_data['page_template'];
920
-                $page_templates      = wp_get_theme()->get_page_templates($post);
921
-            }
922
-            if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
923
-                EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
924
-            } else {
925
-                update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
926
-            }
927
-        }
928
-        if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
929
-            return;
930
-        } //TODO we'll remove this after reimplementing autosave in 4.2
931
-        $this->_insert_update_cpt_item($post_id, $post);
932
-    }
933
-
934
-
935
-
936
-    /**
937
-     * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
938
-     * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
939
-     * so we don't have to check for our CPT.
940
-     *
941
-     * @param  int $post_id ID of the post
942
-     * @return void
943
-     */
944
-    public function dont_permanently_delete_ee_cpts($post_id)
945
-    {
946
-        //only do this if we're actually processing one of our CPTs
947
-        //if our cpt object isn't existent then get out immediately.
948
-        if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
949
-            return;
950
-        }
951
-        delete_post_meta($post_id, '_wp_trash_meta_status');
952
-        delete_post_meta($post_id, '_wp_trash_meta_time');
953
-        //our cpts may have comments so let's take care of that too
954
-        delete_post_meta($post_id, '_wp_trash_meta_comments_status');
955
-    }
956
-
957
-
958
-
959
-    /**
960
-     * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
961
-     * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
962
-     * in them.  We also have our OWN action in here so addons can hook into the restore process easily.
963
-     *
964
-     * @param  int $post_id     ID of cpt item
965
-     * @param  int $revision_id ID of revision being restored
966
-     * @return void
967
-     */
968
-    public function restore_revision($post_id, $revision_id)
969
-    {
970
-        $this->_restore_cpt_item($post_id, $revision_id);
971
-        //global action
972
-        do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
973
-        //class specific action so you can limit hooking into a specific page.
974
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
975
-    }
976
-
977
-
978
-
979
-    /**
980
-     * @see restore_revision() for details
981
-     * @param  int $post_id     ID of cpt item
982
-     * @param  int $revision_id ID of revision for item
983
-     * @return void
984
-     */
985
-    abstract protected function _restore_cpt_item($post_id, $revision_id);
986
-
987
-
988
-
989
-    /**
990
-     * Execution of this method is added to the end of the load_page_dependencies method in the parent
991
-     * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
992
-     * To fix we have to reset the current_screen using the page_slug
993
-     * (which is identical - or should be - to our registered_post_type id.)
994
-     * Also, since the core WP file loads the admin_header.php for WP
995
-     * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
996
-     * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
997
-     *
998
-     * @return void
999
-     */
1000
-    public function modify_current_screen()
1001
-    {
1002
-        //ONLY do this if the current page_route IS a cpt route
1003
-        if ( ! $this->_cpt_route) {
1004
-            return;
1005
-        }
1006
-        //routing things REALLY early b/c this is a cpt admin page
1007
-        set_current_screen($this->_cpt_routes[$this->_req_action]);
1008
-        $this->_current_screen       = get_current_screen();
1009
-        $this->_current_screen->base = 'event-espresso';
1010
-        $this->_add_help_tabs(); //we make sure we add any help tabs back in!
1011
-        /*try {
913
+		//take care of updating any selected page_template IF this cpt supports it.
914
+		if ($this->_supports_page_templates($post->post_type) && ! empty($this->_req_data['page_template'])) {
915
+			//wp version aware.
916
+			if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) {
917
+				$page_templates = wp_get_theme()->get_page_templates();
918
+			} else {
919
+				$post->page_template = $this->_req_data['page_template'];
920
+				$page_templates      = wp_get_theme()->get_page_templates($post);
921
+			}
922
+			if ('default' != $this->_req_data['page_template'] && ! isset($page_templates[$this->_req_data['page_template']])) {
923
+				EE_Error::add_error(__('Invalid Page Template.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
924
+			} else {
925
+				update_post_meta($post_id, '_wp_page_template', $this->_req_data['page_template']);
926
+			}
927
+		}
928
+		if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
929
+			return;
930
+		} //TODO we'll remove this after reimplementing autosave in 4.2
931
+		$this->_insert_update_cpt_item($post_id, $post);
932
+	}
933
+
934
+
935
+
936
+	/**
937
+	 * This hooks into the wp_trash_post() function and removes the `_wp_trash_meta_status` and `_wp_trash_meta_time`
938
+	 * post meta IF the trashed post is one of our CPT's - note this method should only be called with our cpt routes
939
+	 * so we don't have to check for our CPT.
940
+	 *
941
+	 * @param  int $post_id ID of the post
942
+	 * @return void
943
+	 */
944
+	public function dont_permanently_delete_ee_cpts($post_id)
945
+	{
946
+		//only do this if we're actually processing one of our CPTs
947
+		//if our cpt object isn't existent then get out immediately.
948
+		if ( ! $this->_cpt_model_obj instanceof EE_CPT_Base) {
949
+			return;
950
+		}
951
+		delete_post_meta($post_id, '_wp_trash_meta_status');
952
+		delete_post_meta($post_id, '_wp_trash_meta_time');
953
+		//our cpts may have comments so let's take care of that too
954
+		delete_post_meta($post_id, '_wp_trash_meta_comments_status');
955
+	}
956
+
957
+
958
+
959
+	/**
960
+	 * This is a wrapper for the restore_cpt_revision route for cpt items so we can make sure that when a revision is
961
+	 * triggered that we restore related items.  In order to work cpt classes MUST have a restore_cpt_revision method
962
+	 * in them.  We also have our OWN action in here so addons can hook into the restore process easily.
963
+	 *
964
+	 * @param  int $post_id     ID of cpt item
965
+	 * @param  int $revision_id ID of revision being restored
966
+	 * @return void
967
+	 */
968
+	public function restore_revision($post_id, $revision_id)
969
+	{
970
+		$this->_restore_cpt_item($post_id, $revision_id);
971
+		//global action
972
+		do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
973
+		//class specific action so you can limit hooking into a specific page.
974
+		do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
975
+	}
976
+
977
+
978
+
979
+	/**
980
+	 * @see restore_revision() for details
981
+	 * @param  int $post_id     ID of cpt item
982
+	 * @param  int $revision_id ID of revision for item
983
+	 * @return void
984
+	 */
985
+	abstract protected function _restore_cpt_item($post_id, $revision_id);
986
+
987
+
988
+
989
+	/**
990
+	 * Execution of this method is added to the end of the load_page_dependencies method in the parent
991
+	 * so that we can fix a bug where default core metaboxes were not being called in the sidebar.
992
+	 * To fix we have to reset the current_screen using the page_slug
993
+	 * (which is identical - or should be - to our registered_post_type id.)
994
+	 * Also, since the core WP file loads the admin_header.php for WP
995
+	 * (and there are a bunch of other things edit-form-advanced.php loads that need to happen really early)
996
+	 * we need to load it NOW, hence our _route_admin_request in here. (Otherwise screen options won't be set).
997
+	 *
998
+	 * @return void
999
+	 */
1000
+	public function modify_current_screen()
1001
+	{
1002
+		//ONLY do this if the current page_route IS a cpt route
1003
+		if ( ! $this->_cpt_route) {
1004
+			return;
1005
+		}
1006
+		//routing things REALLY early b/c this is a cpt admin page
1007
+		set_current_screen($this->_cpt_routes[$this->_req_action]);
1008
+		$this->_current_screen       = get_current_screen();
1009
+		$this->_current_screen->base = 'event-espresso';
1010
+		$this->_add_help_tabs(); //we make sure we add any help tabs back in!
1011
+		/*try {
1012 1012
             $this->_route_admin_request();
1013 1013
         } catch ( EE_Error $e ) {
1014 1014
             $e->get_error();
1015 1015
         }/**/
1016
-    }
1017
-
1018
-
1019
-
1020
-    /**
1021
-     * This allows child classes to modify the default editor title that appears when people add a new or edit an
1022
-     * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1023
-     * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1024
-     * default to be.
1025
-     *
1026
-     * @param string $title The new title (or existing if there is no editor_title defined)
1027
-     * @return string
1028
-     */
1029
-    public function add_custom_editor_default_title($title)
1030
-    {
1031
-        return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1032
-            ? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1033
-            : $title;
1034
-    }
1035
-
1036
-
1037
-
1038
-    /**
1039
-     * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1040
-     *
1041
-     * @param string $shortlink   The already generated shortlink
1042
-     * @param int    $id          Post ID for this item
1043
-     * @param string $context     The context for the link
1044
-     * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1045
-     * @return string
1046
-     */
1047
-    public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1048
-    {
1049
-        if ( ! empty($id) && '' != get_option('permalink_structure')) {
1050
-            $post = get_post($id);
1051
-            if (isset($post->post_type) && $this->page_slug == $post->post_type) {
1052
-                $shortlink = home_url('?p=' . $post->ID);
1053
-            }
1054
-        }
1055
-        return $shortlink;
1056
-    }
1057
-
1058
-
1059
-
1060
-    /**
1061
-     * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1062
-     * already run in modify_current_screen())
1063
-     *
1064
-     * @return void
1065
-     */
1066
-    public function route_admin_request()
1067
-    {
1068
-        if ($this->_cpt_route) {
1069
-            return;
1070
-        }
1071
-        try {
1072
-            $this->_route_admin_request();
1073
-        } catch (EE_Error $e) {
1074
-            $e->get_error();
1075
-        }
1076
-    }
1077
-
1078
-
1079
-
1080
-    /**
1081
-     * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1082
-     *
1083
-     * @return string html
1084
-     */
1085
-    public function cpt_post_form_hidden_input()
1086
-    {
1087
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1088
-        //we're also going to add the route value and the current page so we can direct autosave parsing correctly
1089
-        echo '<div id="ee-cpt-hidden-inputs">';
1090
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1091
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1092
-        echo '</div>';
1093
-    }
1094
-
1095
-
1096
-
1097
-    /**
1098
-     * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1099
-     *
1100
-     * @param  string $location Original location url
1101
-     * @param  int    $status   Status for http header
1102
-     * @return string           new (or original) url to redirect to.
1103
-     */
1104
-    public function revision_redirect($location, $status)
1105
-    {
1106
-        //get revision
1107
-        $rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1108
-        //can't do anything without revision so let's get out if not present
1109
-        if (empty($rev_id)) {
1110
-            return $location;
1111
-        }
1112
-        //get rev_post_data
1113
-        $rev = get_post($rev_id);
1114
-        $admin_url = $this->_admin_base_url;
1115
-        $query_args = array(
1116
-            'action'   => 'edit',
1117
-            'post'     => $rev->post_parent,
1118
-            'revision' => $rev_id,
1119
-            'message'  => 5,
1120
-        );
1121
-        $this->_process_notices($query_args, true);
1122
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1123
-    }
1124
-
1125
-
1126
-
1127
-    /**
1128
-     * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1129
-     *
1130
-     * @param  string $link    the original generated link
1131
-     * @param  int    $id      post id
1132
-     * @param  string $context optional, defaults to display.  How to write the '&'
1133
-     * @return string          the link
1134
-     */
1135
-    public function modify_edit_post_link($link, $id, $context)
1136
-    {
1137
-        $post = get_post($id);
1138
-        if ( ! isset($this->_req_data['action'])
1139
-             || ! isset($this->_cpt_routes[$this->_req_data['action']])
1140
-             || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1141
-        ) {
1142
-            return $link;
1143
-        }
1144
-        $query_args = array(
1145
-            'action' => isset($this->_cpt_edit_routes[$post->post_type])
1146
-                ? $this->_cpt_edit_routes[$post->post_type]
1147
-                : 'edit',
1148
-            'post'   => $id,
1149
-        );
1150
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1151
-    }
1152
-
1153
-
1154
-
1155
-    /**
1156
-     * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1157
-     * our routes.
1158
-     *
1159
-     * @param  string $delete_link  original delete link
1160
-     * @param  int    $post_id      id of cpt object
1161
-     * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1162
-     * @return string               new delete link
1163
-     */
1164
-    public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1165
-    {
1166
-        $post = get_post($post_id);
1167
-        if ( ! isset($this->_req_data['action'])
1168
-             || (isset($this->_cpt_routes[$this->_req_data['action']])
1169
-                 && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])
1170
-        ) {
1171
-            return $delete_link;
1172
-        }
1173
-        return add_query_arg(array('current_route' => 'trash'), $delete_link);
1174
-    }
1175
-
1176
-
1177
-
1178
-    /**
1179
-     * This hooks into the wp_redirect filter and if trashed is detected, then we'll redirect to the appropriate EE
1180
-     * route
1181
-     *
1182
-     * @param  string $location url
1183
-     * @param  string $status   status
1184
-     * @return string           url to redirect to
1185
-     */
1186
-    public function cpt_trash_post_location_redirect($location, $status)
1187
-    {
1188
-        if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) {
1189
-            return $location;
1190
-        }
1191
-
1192
-        $post              = get_post($this->_req_data['post']);
1193
-        $query_args        = array('action' => 'default');
1194
-        $this->_cpt_object = get_post_type_object($post->post_type);
1195
-        EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name));
1196
-        $this->_process_notices($query_args, true);
1197
-        return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1198
-    }
1199
-
1200
-
1201
-
1202
-    /**
1203
-     * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1204
-     * so that we can hijack the default redirect locations for wp custom post types
1205
-     * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1206
-     *
1207
-     * @param  string $location This is the incoming currently set redirect location
1208
-     * @param  string $post_id  This is the 'ID' value of the wp_posts table
1209
-     * @return string           the new location to redirect to
1210
-     */
1211
-    public function cpt_post_location_redirect($location, $post_id)
1212
-    {
1213
-        //we DO have a match so let's setup the url
1214
-        //we have to get the post to determine our route
1215
-        $post       = get_post($post_id);
1216
-        $edit_route = $this->_cpt_edit_routes[$post->post_type];
1217
-        //shared query_args
1218
-        $query_args = array('action' => $edit_route, 'post' => $post_id);
1219
-        $admin_url  = $this->_admin_base_url;
1220
-        if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1221
-            $status = get_post_status($post_id);
1222
-            if (isset($this->_req_data['publish'])) {
1223
-                switch ($status) {
1224
-                    case 'pending':
1225
-                        $message = 8;
1226
-                        break;
1227
-                    case 'future':
1228
-                        $message = 9;
1229
-                        break;
1230
-                    default:
1231
-                        $message = 6;
1232
-                }
1233
-            } else {
1234
-                $message = 'draft' == $status ? 10 : 1;
1235
-            }
1236
-        } else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1237
-            $message = 2;
1238
-            //			$append = '#postcustom';
1239
-        } else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1240
-            $message = 3;
1241
-            //			$append = '#postcustom';
1242
-        } elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') {
1243
-            $message = 7;
1244
-        } else {
1245
-            $message = 4;
1246
-        }
1247
-        //change the message if the post type is not viewable on the frontend
1248
-        $this->_cpt_object = get_post_type_object($post->post_type);
1249
-        $message           = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1250
-        $query_args = array_merge(array('message' => $message), $query_args);
1251
-        $this->_process_notices($query_args, true);
1252
-        return self::add_query_args_and_nonce($query_args, $admin_url);
1253
-    }
1254
-
1255
-
1256
-
1257
-    /**
1258
-     * This method is called to inject nav tabs on core WP cpt pages
1259
-     *
1260
-     * @access public
1261
-     * @return string html
1262
-     */
1263
-    public function inject_nav_tabs()
1264
-    {
1265
-        //can we hijack and insert the nav_tabs?
1266
-        $nav_tabs = $this->_get_main_nav_tabs();
1267
-        //first close off existing form tag
1268
-        $html = '>';
1269
-        $html .= $nav_tabs;
1270
-        //now let's handle the remaining tag ( missing ">" is CORRECT )
1271
-        $html .= '<span></span';
1272
-        echo $html;
1273
-    }
1274
-
1275
-
1276
-
1277
-    /**
1278
-     * This just sets up the post update messages when an update form is loaded
1279
-     *
1280
-     * @access public
1281
-     * @param  array $messages the original messages array
1282
-     * @return array           the new messages array
1283
-     */
1284
-    public function post_update_messages($messages)
1285
-    {
1286
-        global $post;
1287
-        $id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1288
-        $id = empty($id) && is_object($post) ? $post->ID : null;
1289
-        //		$post_type = $post ? $post->post_type : false;
1290
-        /*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1016
+	}
1017
+
1018
+
1019
+
1020
+	/**
1021
+	 * This allows child classes to modify the default editor title that appears when people add a new or edit an
1022
+	 * existing CPT item.     * This uses the _labels property set by the child class via _define_page_props. Just make
1023
+	 * sure you have a key in _labels property that equals 'editor_title' and the value can be whatever you want the
1024
+	 * default to be.
1025
+	 *
1026
+	 * @param string $title The new title (or existing if there is no editor_title defined)
1027
+	 * @return string
1028
+	 */
1029
+	public function add_custom_editor_default_title($title)
1030
+	{
1031
+		return isset($this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]])
1032
+			? $this->_labels['editor_title'][$this->_cpt_routes[$this->_req_action]]
1033
+			: $title;
1034
+	}
1035
+
1036
+
1037
+
1038
+	/**
1039
+	 * hooks into the wp_get_shortlink button and makes sure that the shortlink gets generated
1040
+	 *
1041
+	 * @param string $shortlink   The already generated shortlink
1042
+	 * @param int    $id          Post ID for this item
1043
+	 * @param string $context     The context for the link
1044
+	 * @param bool   $allow_slugs Whether to allow post slugs in the shortlink.
1045
+	 * @return string
1046
+	 */
1047
+	public function add_shortlink_button_to_editor($shortlink, $id, $context, $allow_slugs)
1048
+	{
1049
+		if ( ! empty($id) && '' != get_option('permalink_structure')) {
1050
+			$post = get_post($id);
1051
+			if (isset($post->post_type) && $this->page_slug == $post->post_type) {
1052
+				$shortlink = home_url('?p=' . $post->ID);
1053
+			}
1054
+		}
1055
+		return $shortlink;
1056
+	}
1057
+
1058
+
1059
+
1060
+	/**
1061
+	 * overriding the parent route_admin_request method so we DON'T run the route twice on cpt core page loads (it's
1062
+	 * already run in modify_current_screen())
1063
+	 *
1064
+	 * @return void
1065
+	 */
1066
+	public function route_admin_request()
1067
+	{
1068
+		if ($this->_cpt_route) {
1069
+			return;
1070
+		}
1071
+		try {
1072
+			$this->_route_admin_request();
1073
+		} catch (EE_Error $e) {
1074
+			$e->get_error();
1075
+		}
1076
+	}
1077
+
1078
+
1079
+
1080
+	/**
1081
+	 * Add a hidden form input to cpt core pages so that we know to do redirects to our routes on saves
1082
+	 *
1083
+	 * @return string html
1084
+	 */
1085
+	public function cpt_post_form_hidden_input()
1086
+	{
1087
+		echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1088
+		//we're also going to add the route value and the current page so we can direct autosave parsing correctly
1089
+		echo '<div id="ee-cpt-hidden-inputs">';
1090
+		echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1091
+		echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1092
+		echo '</div>';
1093
+	}
1094
+
1095
+
1096
+
1097
+	/**
1098
+	 * This allows us to redirect the location of revision restores when they happen so it goes to our CPT routes.
1099
+	 *
1100
+	 * @param  string $location Original location url
1101
+	 * @param  int    $status   Status for http header
1102
+	 * @return string           new (or original) url to redirect to.
1103
+	 */
1104
+	public function revision_redirect($location, $status)
1105
+	{
1106
+		//get revision
1107
+		$rev_id = isset($this->_req_data['revision']) ? $this->_req_data['revision'] : null;
1108
+		//can't do anything without revision so let's get out if not present
1109
+		if (empty($rev_id)) {
1110
+			return $location;
1111
+		}
1112
+		//get rev_post_data
1113
+		$rev = get_post($rev_id);
1114
+		$admin_url = $this->_admin_base_url;
1115
+		$query_args = array(
1116
+			'action'   => 'edit',
1117
+			'post'     => $rev->post_parent,
1118
+			'revision' => $rev_id,
1119
+			'message'  => 5,
1120
+		);
1121
+		$this->_process_notices($query_args, true);
1122
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1123
+	}
1124
+
1125
+
1126
+
1127
+	/**
1128
+	 * Modify the edit post link generated by wp core function so that EE CPTs get setup differently.
1129
+	 *
1130
+	 * @param  string $link    the original generated link
1131
+	 * @param  int    $id      post id
1132
+	 * @param  string $context optional, defaults to display.  How to write the '&'
1133
+	 * @return string          the link
1134
+	 */
1135
+	public function modify_edit_post_link($link, $id, $context)
1136
+	{
1137
+		$post = get_post($id);
1138
+		if ( ! isset($this->_req_data['action'])
1139
+			 || ! isset($this->_cpt_routes[$this->_req_data['action']])
1140
+			 || $post->post_type !== $this->_cpt_routes[$this->_req_data['action']]
1141
+		) {
1142
+			return $link;
1143
+		}
1144
+		$query_args = array(
1145
+			'action' => isset($this->_cpt_edit_routes[$post->post_type])
1146
+				? $this->_cpt_edit_routes[$post->post_type]
1147
+				: 'edit',
1148
+			'post'   => $id,
1149
+		);
1150
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1151
+	}
1152
+
1153
+
1154
+
1155
+	/**
1156
+	 * Modify the trash link on our cpt edit pages so it has the required query var for triggering redirect properly on
1157
+	 * our routes.
1158
+	 *
1159
+	 * @param  string $delete_link  original delete link
1160
+	 * @param  int    $post_id      id of cpt object
1161
+	 * @param  bool   $force_delete whether this is forcing a hard delete instead of trash
1162
+	 * @return string               new delete link
1163
+	 */
1164
+	public function modify_delete_post_link($delete_link, $post_id, $force_delete)
1165
+	{
1166
+		$post = get_post($post_id);
1167
+		if ( ! isset($this->_req_data['action'])
1168
+			 || (isset($this->_cpt_routes[$this->_req_data['action']])
1169
+				 && $post->post_type !== $this->_cpt_routes[$this->_req_data['action']])
1170
+		) {
1171
+			return $delete_link;
1172
+		}
1173
+		return add_query_arg(array('current_route' => 'trash'), $delete_link);
1174
+	}
1175
+
1176
+
1177
+
1178
+	/**
1179
+	 * This hooks into the wp_redirect filter and if trashed is detected, then we'll redirect to the appropriate EE
1180
+	 * route
1181
+	 *
1182
+	 * @param  string $location url
1183
+	 * @param  string $status   status
1184
+	 * @return string           url to redirect to
1185
+	 */
1186
+	public function cpt_trash_post_location_redirect($location, $status)
1187
+	{
1188
+		if (isset($this->_req_data['action']) && $this->_req_data['action'] !== 'trash' && empty($this->_req_data['post'])) {
1189
+			return $location;
1190
+		}
1191
+
1192
+		$post              = get_post($this->_req_data['post']);
1193
+		$query_args        = array('action' => 'default');
1194
+		$this->_cpt_object = get_post_type_object($post->post_type);
1195
+		EE_Error::add_success(sprintf(__('%s trashed.', 'event_espresso'), $this->_cpt_object->labels->singular_name));
1196
+		$this->_process_notices($query_args, true);
1197
+		return self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1198
+	}
1199
+
1200
+
1201
+
1202
+	/**
1203
+	 * This is the callback for the 'redirect_post_location' filter in wp-admin/post.php
1204
+	 * so that we can hijack the default redirect locations for wp custom post types
1205
+	 * that WE'RE using and send back to OUR routes.  This should only be hooked in on the right route.
1206
+	 *
1207
+	 * @param  string $location This is the incoming currently set redirect location
1208
+	 * @param  string $post_id  This is the 'ID' value of the wp_posts table
1209
+	 * @return string           the new location to redirect to
1210
+	 */
1211
+	public function cpt_post_location_redirect($location, $post_id)
1212
+	{
1213
+		//we DO have a match so let's setup the url
1214
+		//we have to get the post to determine our route
1215
+		$post       = get_post($post_id);
1216
+		$edit_route = $this->_cpt_edit_routes[$post->post_type];
1217
+		//shared query_args
1218
+		$query_args = array('action' => $edit_route, 'post' => $post_id);
1219
+		$admin_url  = $this->_admin_base_url;
1220
+		if (isset($this->_req_data['save']) || isset($this->_req_data['publish'])) {
1221
+			$status = get_post_status($post_id);
1222
+			if (isset($this->_req_data['publish'])) {
1223
+				switch ($status) {
1224
+					case 'pending':
1225
+						$message = 8;
1226
+						break;
1227
+					case 'future':
1228
+						$message = 9;
1229
+						break;
1230
+					default:
1231
+						$message = 6;
1232
+				}
1233
+			} else {
1234
+				$message = 'draft' == $status ? 10 : 1;
1235
+			}
1236
+		} else if (isset($this->_req_data['addmeta']) && $this->_req_data['addmeta']) {
1237
+			$message = 2;
1238
+			//			$append = '#postcustom';
1239
+		} else if (isset($this->_req_data['deletemeta']) && $this->_req_data['deletemeta']) {
1240
+			$message = 3;
1241
+			//			$append = '#postcustom';
1242
+		} elseif ($this->_req_data['action'] == 'post-quickpress-save-cont') {
1243
+			$message = 7;
1244
+		} else {
1245
+			$message = 4;
1246
+		}
1247
+		//change the message if the post type is not viewable on the frontend
1248
+		$this->_cpt_object = get_post_type_object($post->post_type);
1249
+		$message           = $message === 1 && ! $this->_cpt_object->publicly_queryable ? 4 : $message;
1250
+		$query_args = array_merge(array('message' => $message), $query_args);
1251
+		$this->_process_notices($query_args, true);
1252
+		return self::add_query_args_and_nonce($query_args, $admin_url);
1253
+	}
1254
+
1255
+
1256
+
1257
+	/**
1258
+	 * This method is called to inject nav tabs on core WP cpt pages
1259
+	 *
1260
+	 * @access public
1261
+	 * @return string html
1262
+	 */
1263
+	public function inject_nav_tabs()
1264
+	{
1265
+		//can we hijack and insert the nav_tabs?
1266
+		$nav_tabs = $this->_get_main_nav_tabs();
1267
+		//first close off existing form tag
1268
+		$html = '>';
1269
+		$html .= $nav_tabs;
1270
+		//now let's handle the remaining tag ( missing ">" is CORRECT )
1271
+		$html .= '<span></span';
1272
+		echo $html;
1273
+	}
1274
+
1275
+
1276
+
1277
+	/**
1278
+	 * This just sets up the post update messages when an update form is loaded
1279
+	 *
1280
+	 * @access public
1281
+	 * @param  array $messages the original messages array
1282
+	 * @return array           the new messages array
1283
+	 */
1284
+	public function post_update_messages($messages)
1285
+	{
1286
+		global $post;
1287
+		$id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1288
+		$id = empty($id) && is_object($post) ? $post->ID : null;
1289
+		//		$post_type = $post ? $post->post_type : false;
1290
+		/*$current_route = isset($this->_req_data['current_route']) ? $this->_req_data['current_route'] : 'shouldneverwork';
1291 1291
 
1292 1292
         $route_to_check = $post_type && isset( $this->_cpt_routes[$current_route]) ? $this->_cpt_routes[$current_route] : '';/**/
1293
-        $messages[$post->post_type] = array(
1294
-            0 => '', //Unused. Messages start at index 1.
1295
-            1 => sprintf(
1296
-                __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1297
-                $this->_cpt_object->labels->singular_name,
1298
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1299
-                '</a>'
1300
-            ),
1301
-            2 => __('Custom field updated'),
1302
-            3 => __('Custom field deleted.'),
1303
-            4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1304
-            5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'),
1305
-                $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false))
1306
-                : false,
1307
-            6 => sprintf(
1308
-                __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1309
-                $this->_cpt_object->labels->singular_name,
1310
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1311
-                '</a>'
1312
-            ),
1313
-            7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1314
-            8 => sprintf(
1315
-                __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1316
-                $this->_cpt_object->labels->singular_name,
1317
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1318
-                '</a>'
1319
-            ),
1320
-            9 => sprintf(
1321
-                __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1322
-                $this->_cpt_object->labels->singular_name,
1323
-                '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>',
1324
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1325
-                '</a>'
1326
-            ),
1327
-            10 => sprintf(
1328
-                __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1329
-                $this->_cpt_object->labels->singular_name,
1330
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1331
-                '</a>'
1332
-            ),
1333
-        );
1334
-        return $messages;
1335
-    }
1336
-
1337
-
1338
-
1339
-    /**
1340
-     * default method for the 'create_new' route for cpt admin pages.
1341
-     * For reference what to include in here, see wp-admin/post-new.php
1342
-     *
1343
-     * @access  protected
1344
-     * @return string template for add new cpt form
1345
-     */
1346
-    protected function _create_new_cpt_item()
1347
-    {
1348
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1349
-        $post_type        = $this->_cpt_routes[$this->_req_action];
1350
-        $post_type_object = $this->_cpt_object;
1351
-        $title            = $post_type_object->labels->add_new_item;
1352
-        $editing          = true;
1353
-        wp_enqueue_script('autosave');
1354
-        $post    = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1355
-        $post_ID = $post->ID;
1356
-        $is_IE   = $is_IE;
1357
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1358
-        //modify the default editor title field with default title.
1359
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1360
-        include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1361
-    }
1362
-
1363
-
1364
-
1365
-    public function add_new_admin_page_global()
1366
-    {
1367
-        $admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1368
-        ?>
1293
+		$messages[$post->post_type] = array(
1294
+			0 => '', //Unused. Messages start at index 1.
1295
+			1 => sprintf(
1296
+				__('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1297
+				$this->_cpt_object->labels->singular_name,
1298
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1299
+				'</a>'
1300
+			),
1301
+			2 => __('Custom field updated'),
1302
+			3 => __('Custom field deleted.'),
1303
+			4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1304
+			5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'),
1305
+				$this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false))
1306
+				: false,
1307
+			6 => sprintf(
1308
+				__('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1309
+				$this->_cpt_object->labels->singular_name,
1310
+				'<a href="' . esc_url(get_permalink($id)) . '">',
1311
+				'</a>'
1312
+			),
1313
+			7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1314
+			8 => sprintf(
1315
+				__('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1316
+				$this->_cpt_object->labels->singular_name,
1317
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1318
+				'</a>'
1319
+			),
1320
+			9 => sprintf(
1321
+				__('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1322
+				$this->_cpt_object->labels->singular_name,
1323
+				'<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>',
1324
+				'<a target="_blank" href="' . esc_url(get_permalink($id)),
1325
+				'</a>'
1326
+			),
1327
+			10 => sprintf(
1328
+				__('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1329
+				$this->_cpt_object->labels->singular_name,
1330
+				'<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1331
+				'</a>'
1332
+			),
1333
+		);
1334
+		return $messages;
1335
+	}
1336
+
1337
+
1338
+
1339
+	/**
1340
+	 * default method for the 'create_new' route for cpt admin pages.
1341
+	 * For reference what to include in here, see wp-admin/post-new.php
1342
+	 *
1343
+	 * @access  protected
1344
+	 * @return string template for add new cpt form
1345
+	 */
1346
+	protected function _create_new_cpt_item()
1347
+	{
1348
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1349
+		$post_type        = $this->_cpt_routes[$this->_req_action];
1350
+		$post_type_object = $this->_cpt_object;
1351
+		$title            = $post_type_object->labels->add_new_item;
1352
+		$editing          = true;
1353
+		wp_enqueue_script('autosave');
1354
+		$post    = $post = get_default_post_to_edit($this->_cpt_routes[$this->_req_action], true);
1355
+		$post_ID = $post->ID;
1356
+		$is_IE   = $is_IE;
1357
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1358
+		//modify the default editor title field with default title.
1359
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1360
+		include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1361
+	}
1362
+
1363
+
1364
+
1365
+	public function add_new_admin_page_global()
1366
+	{
1367
+		$admin_page = ! empty($this->_req_data['post']) ? 'post-php' : 'post-new-php';
1368
+		?>
1369 1369
         <script type="text/javascript">
1370 1370
             adminpage = '<?php echo $admin_page; ?>';
1371 1371
         </script>
1372 1372
         <?php
1373
-    }
1374
-
1375
-
1376
-
1377
-    /**
1378
-     * default method for the 'edit' route for cpt admin pages
1379
-     * For reference on what to put in here, refer to wp-admin/post.php
1380
-     *
1381
-     * @access protected
1382
-     * @return string   template for edit cpt form
1383
-     */
1384
-    protected function _edit_cpt_item()
1385
-    {
1386
-        global $post, $title, $is_IE, $post_type, $post_type_object;
1387
-        $post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1388
-        $post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1389
-        if (empty ($post)) {
1390
-            wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'));
1391
-        }
1392
-        if ( ! empty($_GET['get-post-lock'])) {
1393
-            wp_set_post_lock($post_id);
1394
-            wp_redirect(get_edit_post_link($post_id, 'url'));
1395
-            exit();
1396
-        }
1397
-
1398
-        // template vars
1399
-        $editing          = true;
1400
-        $post_ID          = $post_id;
1401
-        $post_type        = $this->_cpt_routes[$this->_req_action];
1402
-        $post_type_object = $this->_cpt_object;
1403
-
1404
-        if ( ! wp_check_post_lock($post->ID)) {
1405
-            $active_post_lock = wp_set_post_lock($post->ID);
1406
-            //wp_enqueue_script('autosave');
1407
-        }
1408
-        $title = $this->_cpt_object->labels->edit_item;
1409
-        add_action('admin_footer', '_admin_notice_post_locked');
1410
-        if (isset($this->_cpt_routes[$this->_req_data['action']])
1411
-            && ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1412
-        ) {
1413
-            $create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1414
-                'create_new', $this);
1415
-            $post_new_file = EE_Admin_Page::add_query_args_and_nonce(array(
1416
-                'action' => $create_new_action,
1417
-                'page'   => $this->page_slug,
1418
-            ), 'admin.php');
1419
-        }
1420
-        if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1421
-            wp_enqueue_script('admin-comments');
1422
-            enqueue_comment_hotkeys_js();
1423
-        }
1424
-        add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1425
-        //modify the default editor title field with default title.
1426
-        add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1427
-        include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1428
-    }
1429
-
1430
-
1431
-
1432
-    /**
1433
-     * some getters
1434
-     */
1435
-    /**
1436
-     * This returns the protected _cpt_model_obj property
1437
-     *
1438
-     * @return EE_CPT_Base
1439
-     */
1440
-    public function get_cpt_model_obj()
1441
-    {
1442
-        return $this->_cpt_model_obj;
1443
-    }
1373
+	}
1374
+
1375
+
1376
+
1377
+	/**
1378
+	 * default method for the 'edit' route for cpt admin pages
1379
+	 * For reference on what to put in here, refer to wp-admin/post.php
1380
+	 *
1381
+	 * @access protected
1382
+	 * @return string   template for edit cpt form
1383
+	 */
1384
+	protected function _edit_cpt_item()
1385
+	{
1386
+		global $post, $title, $is_IE, $post_type, $post_type_object;
1387
+		$post_id = isset($this->_req_data['post']) ? $this->_req_data['post'] : null;
1388
+		$post = ! empty($post_id) ? get_post($post_id, OBJECT, 'edit') : null;
1389
+		if (empty ($post)) {
1390
+			wp_die(__('You attempted to edit an item that doesn&#8217;t exist. Perhaps it was deleted?'));
1391
+		}
1392
+		if ( ! empty($_GET['get-post-lock'])) {
1393
+			wp_set_post_lock($post_id);
1394
+			wp_redirect(get_edit_post_link($post_id, 'url'));
1395
+			exit();
1396
+		}
1397
+
1398
+		// template vars
1399
+		$editing          = true;
1400
+		$post_ID          = $post_id;
1401
+		$post_type        = $this->_cpt_routes[$this->_req_action];
1402
+		$post_type_object = $this->_cpt_object;
1403
+
1404
+		if ( ! wp_check_post_lock($post->ID)) {
1405
+			$active_post_lock = wp_set_post_lock($post->ID);
1406
+			//wp_enqueue_script('autosave');
1407
+		}
1408
+		$title = $this->_cpt_object->labels->edit_item;
1409
+		add_action('admin_footer', '_admin_notice_post_locked');
1410
+		if (isset($this->_cpt_routes[$this->_req_data['action']])
1411
+			&& ! isset($this->_labels['hide_add_button_on_cpt_route'][$this->_req_data['action']])
1412
+		) {
1413
+			$create_new_action = apply_filters('FHEE__EE_Admin_Page_CPT___edit_cpt_item__create_new_action',
1414
+				'create_new', $this);
1415
+			$post_new_file = EE_Admin_Page::add_query_args_and_nonce(array(
1416
+				'action' => $create_new_action,
1417
+				'page'   => $this->page_slug,
1418
+			), 'admin.php');
1419
+		}
1420
+		if (post_type_supports($this->_cpt_routes[$this->_req_action], 'comments')) {
1421
+			wp_enqueue_script('admin-comments');
1422
+			enqueue_comment_hotkeys_js();
1423
+		}
1424
+		add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1425
+		//modify the default editor title field with default title.
1426
+		add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1427
+		include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1428
+	}
1429
+
1430
+
1431
+
1432
+	/**
1433
+	 * some getters
1434
+	 */
1435
+	/**
1436
+	 * This returns the protected _cpt_model_obj property
1437
+	 *
1438
+	 * @return EE_CPT_Base
1439
+	 */
1440
+	public function get_cpt_model_obj()
1441
+	{
1442
+		return $this->_cpt_model_obj;
1443
+	}
1444 1444
 
1445 1445
 }
Please login to merge, or discard this patch.
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -235,7 +235,7 @@  discard block
 block discarded – undo
235 235
      */
236 236
     protected function _register_autosave_containers($ids)
237 237
     {
238
-        $this->_autosave_containers = array_merge($this->_autosave_fields, (array)$ids);
238
+        $this->_autosave_containers = array_merge($this->_autosave_fields, (array) $ids);
239 239
     }
240 240
 
241 241
 
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
         //filter _autosave_containers
280 280
         $containers = apply_filters('FHEE__EE_Admin_Page_CPT___load_autosave_scripts_styles__containers',
281 281
             $this->_autosave_containers, $this);
282
-        $containers = apply_filters('FHEE__EE_Admin_Page_CPT__' . get_class($this) . '___load_autosave_scripts_styles__containers',
282
+        $containers = apply_filters('FHEE__EE_Admin_Page_CPT__'.get_class($this).'___load_autosave_scripts_styles__containers',
283 283
             $containers, $this);
284 284
 
285 285
         wp_localize_script('event_editor_js', 'EE_AUTOSAVE_IDS',
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
         parent::_load_page_dependencies();
370 370
         //notice we are ALSO going to load the pagenow hook set for this route (see _before_page_setup for the reset of the pagenow global ). This is for any plugins that are doing things properly and hooking into the load page hook for core wp cpt routes.
371 371
         global $pagenow;
372
-        do_action('load-' . $pagenow);
372
+        do_action('load-'.$pagenow);
373 373
         $this->modify_current_screen();
374 374
         add_action('admin_enqueue_scripts', array($this, 'setup_autosave_hooks'), 30);
375 375
         //we route REALLY early.
@@ -400,8 +400,8 @@  discard block
 block discarded – undo
400 400
                 'admin.php?page=espresso_registrations&action=contact_list',
401 401
             ),
402 402
             1 => array(
403
-                'edit.php?post_type=' . $this->_cpt_object->name,
404
-                'admin.php?page=' . $this->_cpt_object->name,
403
+                'edit.php?post_type='.$this->_cpt_object->name,
404
+                'admin.php?page='.$this->_cpt_object->name,
405 405
             ),
406 406
         );
407 407
         foreach ($routes_to_match as $route_matches) {
@@ -429,7 +429,7 @@  discard block
 block discarded – undo
429 429
         $cpt_has_support = ! empty($cpt_args['page_templates']);
430 430
 
431 431
         //if the installed version of WP is > 4.7 we do some additional checks.
432
-        if (EE_Recommended_Versions::check_wp_version('4.7','>=')) {
432
+        if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) {
433 433
             $post_templates = wp_get_theme()->get_post_templates();
434 434
             //if there are $post_templates for this cpt, then we return false for this method because
435 435
             //that means we aren't going to load our page template manager and leave that up to the native
@@ -452,7 +452,7 @@  discard block
 block discarded – undo
452 452
         global $post;
453 453
         $template = '';
454 454
 
455
-        if (EE_Recommended_Versions::check_wp_version('4.7','>=')) {
455
+        if (EE_Recommended_Versions::check_wp_version('4.7', '>=')) {
456 456
             $page_template_count = count(get_page_templates());
457 457
         } else {
458 458
             $page_template_count = count(get_page_templates($post));
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         $post = get_post($id);
490 490
         if ('publish' != get_post_status($post)) {
491 491
             //include shims for the `get_preview_post_link` function
492
-            require_once( EE_CORE . 'wordpress-shims.php' );
492
+            require_once(EE_CORE.'wordpress-shims.php');
493 493
             $return .= '<span_id="view-post-btn"><a target="_blank" href="'
494 494
                        . get_preview_post_link($id)
495 495
                        . '" class="button button-small">'
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
             $template_args['statuses']         = $statuses;
528 528
         }
529 529
 
530
-        $template = EE_ADMIN_TEMPLATE . 'status_dropdown.template.php';
530
+        $template = EE_ADMIN_TEMPLATE.'status_dropdown.template.php';
531 531
         EEH_Template::display_template($template, $template_args);
532 532
     }
533 533
 
@@ -572,13 +572,13 @@  discard block
 block discarded – undo
572 572
             define('DOING_AUTOSAVE', true);
573 573
         }
574 574
         //if we made it here then the nonce checked out.  Let's run our methods and actions
575
-        if (method_exists($this, '_ee_autosave_' . $this->_current_view)) {
576
-            call_user_func(array($this, '_ee_autosave_' . $this->_current_view));
575
+        if (method_exists($this, '_ee_autosave_'.$this->_current_view)) {
576
+            call_user_func(array($this, '_ee_autosave_'.$this->_current_view));
577 577
         } else {
578 578
             $this->_template_args['success'] = true;
579 579
         }
580 580
         do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__global_after', $this);
581
-        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_' . get_class($this), $this);
581
+        do_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_'.get_class($this), $this);
582 582
         //now let's return json
583 583
         $this->_return_json();
584 584
     }
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
         //global action
972 972
         do_action('AHEE_EE_Admin_Page_CPT__restore_revision', $post_id, $revision_id);
973 973
         //class specific action so you can limit hooking into a specific page.
974
-        do_action('AHEE_EE_Admin_Page_CPT_' . get_class($this) . '__restore_revision', $post_id, $revision_id);
974
+        do_action('AHEE_EE_Admin_Page_CPT_'.get_class($this).'__restore_revision', $post_id, $revision_id);
975 975
     }
976 976
 
977 977
 
@@ -1049,7 +1049,7 @@  discard block
 block discarded – undo
1049 1049
         if ( ! empty($id) && '' != get_option('permalink_structure')) {
1050 1050
             $post = get_post($id);
1051 1051
             if (isset($post->post_type) && $this->page_slug == $post->post_type) {
1052
-                $shortlink = home_url('?p=' . $post->ID);
1052
+                $shortlink = home_url('?p='.$post->ID);
1053 1053
             }
1054 1054
         }
1055 1055
         return $shortlink;
@@ -1084,11 +1084,11 @@  discard block
 block discarded – undo
1084 1084
      */
1085 1085
     public function cpt_post_form_hidden_input()
1086 1086
     {
1087
-        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="' . $this->_admin_base_url . '" />';
1087
+        echo '<input type="hidden" name="ee_cpt_item_redirect_url" value="'.$this->_admin_base_url.'" />';
1088 1088
         //we're also going to add the route value and the current page so we can direct autosave parsing correctly
1089 1089
         echo '<div id="ee-cpt-hidden-inputs">';
1090
-        echo '<input type="hidden" id="current_route" name="current_route" value="' . $this->_current_view . '" />';
1091
-        echo '<input type="hidden" id="current_page" name="current_page" value="' . $this->page_slug . '" />';
1090
+        echo '<input type="hidden" id="current_route" name="current_route" value="'.$this->_current_view.'" />';
1091
+        echo '<input type="hidden" id="current_page" name="current_page" value="'.$this->page_slug.'" />';
1092 1092
         echo '</div>';
1093 1093
     }
1094 1094
 
@@ -1295,39 +1295,39 @@  discard block
 block discarded – undo
1295 1295
             1 => sprintf(
1296 1296
                 __('%1$s updated. %2$sView %1$s%3$s', 'event_espresso'),
1297 1297
                 $this->_cpt_object->labels->singular_name,
1298
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1298
+                '<a href="'.esc_url(get_permalink($id)).'">',
1299 1299
                 '</a>'
1300 1300
             ),
1301 1301
             2 => __('Custom field updated'),
1302 1302
             3 => __('Custom field deleted.'),
1303 1303
             4 => sprintf(__('%1$s updated.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1304 1304
             5 => isset($_GET['revision']) ? sprintf(__('%s restored to revision from %s', 'event_espresso'),
1305
-                $this->_cpt_object->labels->singular_name, wp_post_revision_title((int)$_GET['revision'], false))
1305
+                $this->_cpt_object->labels->singular_name, wp_post_revision_title((int) $_GET['revision'], false))
1306 1306
                 : false,
1307 1307
             6 => sprintf(
1308 1308
                 __('%1$s published. %2$sView %1$s%3$s', 'event_espresso'),
1309 1309
                 $this->_cpt_object->labels->singular_name,
1310
-                '<a href="' . esc_url(get_permalink($id)) . '">',
1310
+                '<a href="'.esc_url(get_permalink($id)).'">',
1311 1311
                 '</a>'
1312 1312
             ),
1313 1313
             7 => sprintf(__('%1$s saved.', 'event_espresso'), $this->_cpt_object->labels->singular_name),
1314 1314
             8 => sprintf(
1315 1315
                 __('%1$s submitted. %2$sPreview %1$s%3$s', 'event_espresso'),
1316 1316
                 $this->_cpt_object->labels->singular_name,
1317
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))) . '">',
1317
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))).'">',
1318 1318
                 '</a>'
1319 1319
             ),
1320 1320
             9 => sprintf(
1321 1321
                 __('%1$s scheduled for: %2$s. %3$s">Preview %1$s%3$s', 'event_espresso'),
1322 1322
                 $this->_cpt_object->labels->singular_name,
1323
-                '<strong>' . date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)) . '</strong>',
1324
-                '<a target="_blank" href="' . esc_url(get_permalink($id)),
1323
+                '<strong>'.date_i18n(__('M j, Y @ G:i'), strtotime($post->post_date)).'</strong>',
1324
+                '<a target="_blank" href="'.esc_url(get_permalink($id)),
1325 1325
                 '</a>'
1326 1326
             ),
1327 1327
             10 => sprintf(
1328 1328
                 __('%1$s draft updated. %2$s">Preview page%3$s', 'event_espresso'),
1329 1329
                 $this->_cpt_object->labels->singular_name,
1330
-                '<a target="_blank" href="' . esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1330
+                '<a target="_blank" href="'.esc_url(add_query_arg('preview', 'true', get_permalink($id))),
1331 1331
                 '</a>'
1332 1332
             ),
1333 1333
         );
@@ -1357,7 +1357,7 @@  discard block
 block discarded – undo
1357 1357
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1358 1358
         //modify the default editor title field with default title.
1359 1359
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1360
-        include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1360
+        include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1361 1361
     }
1362 1362
 
1363 1363
 
@@ -1424,7 +1424,7 @@  discard block
 block discarded – undo
1424 1424
         add_action('admin_print_styles', array($this, 'add_new_admin_page_global'));
1425 1425
         //modify the default editor title field with default title.
1426 1426
         add_filter('enter_title_here', array($this, 'add_custom_editor_default_title'), 10);
1427
-        include_once WP_ADMIN_PATH . 'edit-form-advanced.php';
1427
+        include_once WP_ADMIN_PATH.'edit-form-advanced.php';
1428 1428
     }
1429 1429
 
1430 1430
 
Please login to merge, or discard this patch.
form_sections/strategies/normalization/EE_Text_Normalization.strategy.php 3 patches
Indentation   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 	 */
16 16
 	public function normalize($value_to_normalize) {
17 17
 		if(is_array($value_to_normalize)) {
18
-            return array_shift($value_to_normalize);
19
-        //consider `"null"` values to be equivalent to null.
20
-        }elseif($value_to_normalize === '' || $value_to_normalize === null) {
21
-		    return null;
18
+			return array_shift($value_to_normalize);
19
+		//consider `"null"` values to be equivalent to null.
20
+		}elseif($value_to_normalize === '' || $value_to_normalize === null) {
21
+			return null;
22 22
 		}else{
23 23
 			return $value_to_normalize;
24 24
 		}
@@ -29,10 +29,10 @@  discard block
 block discarded – undo
29 29
 	 * @return string
30 30
 	 */
31 31
 	public function unnormalize( $normalized_value ){
32
-	    //account for default "select here" option values
33
-	    if ($normalized_value === null) {
34
-	        return '';
35
-        }
32
+		//account for default "select here" option values
33
+		if ($normalized_value === null) {
34
+			return '';
35
+		}
36 36
 		return $normalized_value;
37 37
 	}
38 38
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -7,19 +7,19 @@  discard block
 block discarded – undo
7 7
  * @subpackage
8 8
  * @author				Mike Nelson
9 9
  */
10
-class EE_Text_Normalization extends EE_Normalization_Strategy_Base{
10
+class EE_Text_Normalization extends EE_Normalization_Strategy_Base {
11 11
 
12 12
 	/**
13 13
 	 * @param string $value_to_normalize
14 14
 	 * @return array|mixed|string
15 15
 	 */
16 16
 	public function normalize($value_to_normalize) {
17
-		if(is_array($value_to_normalize)) {
17
+		if (is_array($value_to_normalize)) {
18 18
             return array_shift($value_to_normalize);
19 19
         //consider `"null"` values to be equivalent to null.
20
-        }elseif($value_to_normalize === '' || $value_to_normalize === null) {
20
+        }elseif ($value_to_normalize === '' || $value_to_normalize === null) {
21 21
 		    return null;
22
-		}else{
22
+		} else {
23 23
 			return $value_to_normalize;
24 24
 		}
25 25
 	}
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string $normalized_value
29 29
 	 * @return string
30 30
 	 */
31
-	public function unnormalize( $normalized_value ){
31
+	public function unnormalize($normalized_value) {
32 32
 	    //account for default "select here" option values
33 33
 	    if ($normalized_value === null) {
34 34
 	        return '';
Please login to merge, or discard this patch.
Braces   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -17,9 +17,9 @@
 block discarded – undo
17 17
 		if(is_array($value_to_normalize)) {
18 18
             return array_shift($value_to_normalize);
19 19
         //consider `"null"` values to be equivalent to null.
20
-        }elseif($value_to_normalize === '' || $value_to_normalize === null) {
20
+        } elseif($value_to_normalize === '' || $value_to_normalize === null) {
21 21
 		    return null;
22
-		}else{
22
+		} else{
23 23
 			return $value_to_normalize;
24 24
 		}
25 25
 	}
Please login to merge, or discard this patch.
core/db_classes/EE_Question.class.php 2 patches
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -445,8 +445,8 @@  discard block
 block discarded – undo
445 445
 		$new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) );
446 446
 		$new_question->set_system_ID( null );
447 447
 		$new_question->set_wp_user( get_current_user_id() );
448
-                //if we're duplicating a trashed question, assume we don't want the new one to be trashed
449
-                $new_question->set_deleted( false );
448
+				//if we're duplicating a trashed question, assume we don't want the new one to be trashed
449
+				$new_question->set_deleted( false );
450 450
 		$success = $new_question->save();
451 451
 		if( $success ) {
452 452
 			//we don't totally want to duplicate the question options, because we want them to be for the NEW question
@@ -501,8 +501,8 @@  discard block
 block discarded – undo
501 501
 		}
502 502
 		// has this question been answered ?
503 503
 		if ( $answer instanceof EE_Answer
504
-             && $answer->value() !== ''
505
-        ) {
504
+			 && $answer->value() !== ''
505
+		) {
506 506
 			//answer gets htmlspecialchars called on it, undo that please
507 507
 			//because the form input's display strategy may call esc_attr too
508 508
 			//which also does html special characters
Please login to merge, or discard this patch.
Spacing   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * Event Espresso
@@ -37,9 +37,9 @@  discard block
 block discarded – undo
37 37
 	 *                             		    date_format and the second value is the time format
38 38
 	 * @return EE_Question
39 39
 	 */
40
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
41
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats );
42
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
40
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
41
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats);
42
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
43 43
 	}
44 44
 
45 45
 
@@ -50,8 +50,8 @@  discard block
 block discarded – undo
50 50
 	 *                          		the website will be used.
51 51
 	 * @return EE_Question
52 52
 	 */
53
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
54
-		return new self( $props_n_values, TRUE, $timezone );
53
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
54
+		return new self($props_n_values, TRUE, $timezone);
55 55
 	}
56 56
 
57 57
 
@@ -62,8 +62,8 @@  discard block
 block discarded – undo
62 62
 	 * @access        public
63 63
 	 * @param string $QST_display_text
64 64
 	 */
65
-	public function set_display_text( $QST_display_text = '' ) {
66
-		$this->set( 'QST_display_text', $QST_display_text );
65
+	public function set_display_text($QST_display_text = '') {
66
+		$this->set('QST_display_text', $QST_display_text);
67 67
 	}
68 68
 
69 69
 
@@ -74,8 +74,8 @@  discard block
 block discarded – undo
74 74
 	 * @access        public
75 75
 	 * @param        string $QST_admin_label
76 76
 	 */
77
-	public function set_admin_label( $QST_admin_label = '' ) {
78
-		$this->set( 'QST_admin_label', $QST_admin_label );
77
+	public function set_admin_label($QST_admin_label = '') {
78
+		$this->set('QST_admin_label', $QST_admin_label);
79 79
 	}
80 80
 
81 81
 
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @access        public
87 87
 	 * @param        mixed $QST_system
88 88
 	 */
89
-	public function set_system_ID( $QST_system = '' ) {
90
-		$this->set( 'QST_system', $QST_system );
89
+	public function set_system_ID($QST_system = '') {
90
+		$this->set('QST_system', $QST_system);
91 91
 	}
92 92
 
93 93
 
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 	 * @access        public
99 99
 	 * @param        string $QST_type
100 100
 	 */
101
-	public function set_question_type( $QST_type = '' ) {
102
-		$this->set( 'QST_type', $QST_type );
101
+	public function set_question_type($QST_type = '') {
102
+		$this->set('QST_type', $QST_type);
103 103
 	}
104 104
 
105 105
 
@@ -110,8 +110,8 @@  discard block
 block discarded – undo
110 110
 	 * @access        public
111 111
 	 * @param        bool $QST_required
112 112
 	 */
113
-	public function set_required( $QST_required = FALSE ) {
114
-		$this->set( 'QST_required', $QST_required );
113
+	public function set_required($QST_required = FALSE) {
114
+		$this->set('QST_required', $QST_required);
115 115
 	}
116 116
 
117 117
 
@@ -122,8 +122,8 @@  discard block
 block discarded – undo
122 122
 	 * @access        public
123 123
 	 * @param        string $QST_required_text
124 124
 	 */
125
-	public function set_required_text( $QST_required_text = '' ) {
126
-		$this->set( 'QST_required_text', $QST_required_text );
125
+	public function set_required_text($QST_required_text = '') {
126
+		$this->set('QST_required_text', $QST_required_text);
127 127
 	}
128 128
 
129 129
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 * @access        public
135 135
 	 * @param        int $QST_order
136 136
 	 */
137
-	public function set_order( $QST_order = 0 ) {
138
-		$this->set( 'QST_order', $QST_order );
137
+	public function set_order($QST_order = 0) {
138
+		$this->set('QST_order', $QST_order);
139 139
 	}
140 140
 
141 141
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @access        public
147 147
 	 * @param        bool $QST_admin_only
148 148
 	 */
149
-	public function set_admin_only( $QST_admin_only = FALSE ) {
150
-		$this->set( 'QST_admin_only', $QST_admin_only );
149
+	public function set_admin_only($QST_admin_only = FALSE) {
150
+		$this->set('QST_admin_only', $QST_admin_only);
151 151
 	}
152 152
 
153 153
 
@@ -158,8 +158,8 @@  discard block
 block discarded – undo
158 158
 	 * @access        public
159 159
 	 * @param        int $QST_wp_user
160 160
 	 */
161
-	public function set_wp_user( $QST_wp_user = 1 ) {
162
-		$this->set( 'QST_wp_user', $QST_wp_user );
161
+	public function set_wp_user($QST_wp_user = 1) {
162
+		$this->set('QST_wp_user', $QST_wp_user);
163 163
 	}
164 164
 
165 165
 
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
 	 * @access        public
176 176
 	 * @param 	bool $QST_deleted
177 177
 	 */
178
-	public function set_deleted( $QST_deleted = FALSE ) {
179
-		$this->set( 'QST_deleted', $QST_deleted );
178
+	public function set_deleted($QST_deleted = FALSE) {
179
+		$this->set('QST_deleted', $QST_deleted);
180 180
 	}
181 181
 
182 182
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 	 * @return string
188 188
 	 */
189 189
 	public function display_text() {
190
-		return $this->get( 'QST_display_text' );
190
+		return $this->get('QST_display_text');
191 191
 	}
192 192
 
193 193
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
 	 * @return string
199 199
 	 */
200 200
 	public function admin_label() {
201
-		return $this->get( 'QST_admin_label' );
201
+		return $this->get('QST_admin_label');
202 202
 	}
203 203
 
204 204
 
@@ -209,7 +209,7 @@  discard block
 block discarded – undo
209 209
 	 * @return string
210 210
 	 */
211 211
 	public function system_ID() {
212
-		return $this->get( 'QST_system' );
212
+		return $this->get('QST_system');
213 213
 	}
214 214
 
215 215
 
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 	 * @return boolean
221 221
 	 */
222 222
 	public function required() {
223
-		return $this->get( 'QST_required' );
223
+		return $this->get('QST_required');
224 224
 	}
225 225
 
226 226
 
@@ -232,7 +232,7 @@  discard block
 block discarded – undo
232 232
 	 * @return string
233 233
 	 */
234 234
 	public function required_text() {
235
-		return $this->get( 'QST_required_text' );
235
+		return $this->get('QST_required_text');
236 236
 	}
237 237
 
238 238
 
@@ -243,7 +243,7 @@  discard block
 block discarded – undo
243 243
 	 * @return string
244 244
 	 */
245 245
 	public function type() {
246
-		return $this->get( 'QST_type' );
246
+		return $this->get('QST_type');
247 247
 	}
248 248
 
249 249
 
@@ -255,7 +255,7 @@  discard block
 block discarded – undo
255 255
 	 * @return int
256 256
 	 */
257 257
 	public function order() {
258
-		return $this->get( 'QST_order' );
258
+		return $this->get('QST_order');
259 259
 	}
260 260
 
261 261
 
@@ -267,7 +267,7 @@  discard block
 block discarded – undo
267 267
 	 * @return boolean
268 268
 	 */
269 269
 	public function admin_only() {
270
-		return $this->get( 'QST_admin_only' );
270
+		return $this->get('QST_admin_only');
271 271
 	}
272 272
 
273 273
 
@@ -278,7 +278,7 @@  discard block
 block discarded – undo
278 278
 	 * @return int
279 279
 	 */
280 280
 	public function wp_user() {
281
-		return $this->get( 'QST_wp_user' );
281
+		return $this->get('QST_wp_user');
282 282
 	}
283 283
 
284 284
 
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return boolean
290 290
 	 */
291 291
 	public function deleted() {
292
-		return $this->get( 'QST_deleted' );
292
+		return $this->get('QST_deleted');
293 293
 	}
294 294
 
295 295
 
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 	 * @return EE_Answer[]
300 300
 	 */
301 301
 	public function answers() {
302
-		return $this->get_many_related( 'Answer' );
302
+		return $this->get_many_related('Answer');
303 303
 	}
304 304
 
305 305
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * @return boolean true = has answers, false = no answers.
310 310
 	 */
311 311
 	public function has_answers() {
312
-		return $this->count_related( 'Answer' ) > 0 ? TRUE : FALSE;
312
+		return $this->count_related('Answer') > 0 ? TRUE : FALSE;
313 313
 	}
314 314
 
315 315
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return EE_Question_Group[]
320 320
 	 */
321 321
 	public function question_groups() {
322
-		return $this->get_many_related( 'Question_Group' );
322
+		return $this->get_many_related('Question_Group');
323 323
 	}
324 324
 
325 325
 
@@ -333,24 +333,24 @@  discard block
 block discarded – undo
333 333
 	 *                                                       whether it was trashed or not.
334 334
 	 * @return EE_Question_Option[]
335 335
 	 */
336
-	public function options( $notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL ) {
337
-		if ( ! $this->ID() ) {
336
+	public function options($notDeletedOptionsOnly = TRUE, $selected_value_to_always_include = NULL) {
337
+		if ( ! $this->ID()) {
338 338
 			return array();
339 339
 		}
340 340
 		$query_params = array();
341
-		if ( $selected_value_to_always_include ) {
342
-			if ( is_array( $selected_value_to_always_include ) ) {
343
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = array( 'IN', $selected_value_to_always_include );
341
+		if ($selected_value_to_always_include) {
342
+			if (is_array($selected_value_to_always_include)) {
343
+				$query_params[0]['OR*options-query']['QSO_value'] = array('IN', $selected_value_to_always_include);
344 344
 			} else {
345
-				$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_value' ] = $selected_value_to_always_include;
345
+				$query_params[0]['OR*options-query']['QSO_value'] = $selected_value_to_always_include;
346 346
 			}
347 347
 		}
348
-		if ( $notDeletedOptionsOnly ) {
349
-			$query_params[ 0 ][ 'OR*options-query' ][ 'QSO_deleted' ] = FALSE;
348
+		if ($notDeletedOptionsOnly) {
349
+			$query_params[0]['OR*options-query']['QSO_deleted'] = FALSE;
350 350
 		}
351 351
 		//order by QSO_order
352
-		$query_params[ 'order_by' ] = array( 'QSO_order' => 'ASC' );
353
-		return $this->get_many_related( 'Question_Option', $query_params );
352
+		$query_params['order_by'] = array('QSO_order' => 'ASC');
353
+		return $this->get_many_related('Question_Option', $query_params);
354 354
 	}
355 355
 
356 356
 
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
 	 * @return \EE_Question_Option[]
361 361
 	 */
362 362
 	public function temp_options() {
363
-		return $this->_model_relations[ 'Question_Option' ];
363
+		return $this->_model_relations['Question_Option'];
364 364
 	}
365 365
 
366 366
 
@@ -371,8 +371,8 @@  discard block
 block discarded – undo
371 371
 	 * @param EE_Question_Option $option
372 372
 	 * @return boolean success
373 373
 	 */
374
-	public function add_option( EE_Question_Option $option ) {
375
-		return $this->_add_relation_to( $option, 'Question_Option' );
374
+	public function add_option(EE_Question_Option $option) {
375
+		return $this->_add_relation_to($option, 'Question_Option');
376 376
 	}
377 377
 
378 378
 
@@ -382,8 +382,8 @@  discard block
 block discarded – undo
382 382
 	 * @param EE_Question_Option $option
383 383
 	 * @return boolean success
384 384
 	 */
385
-	public function add_temp_option( EE_Question_Option $option ) {
386
-		$this->_model_relations[ 'Question_Option' ][ ] = $option;
385
+	public function add_temp_option(EE_Question_Option $option) {
386
+		$this->_model_relations['Question_Option'][] = $option;
387 387
 		return TRUE;
388 388
 	}
389 389
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param EE_Question_Option $option
395 395
 	 * @return boolean success
396 396
 	 */
397
-	public function remove_option( EE_Question_Option $option ) {
398
-		return $this->_remove_relation_to( $option, 'Question_Option' );
397
+	public function remove_option(EE_Question_Option $option) {
398
+		return $this->_remove_relation_to($option, 'Question_Option');
399 399
 	}
400 400
 
401 401
 
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 * @return bool
405 405
 	 */
406 406
 	public function is_system_question() {
407
-		$system_ID = $this->get( 'QST_system' );
408
-		return ! empty( $system_ID ) ? TRUE : FALSE;
407
+		$system_ID = $this->get('QST_system');
408
+		return ! empty($system_ID) ? TRUE : FALSE;
409 409
 	}
410 410
 
411 411
 
@@ -418,8 +418,8 @@  discard block
 block discarded – undo
418 418
 	 */
419 419
 	public function set_order_to_latest() {
420 420
 		$latest_order = $this->get_model()->get_latest_question_order();
421
-		$latest_order ++;
422
-		$this->set( 'QST_order', $latest_order );
421
+		$latest_order++;
422
+		$this->set('QST_order', $latest_order);
423 423
 	}
424 424
 
425 425
 
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 	 * Duplicates this question and its question options
439 439
 	 * @return \EE_Question
440 440
 	 */
441
-	public function duplicate( $options = array() ) {
441
+	public function duplicate($options = array()) {
442 442
 		$new_question = clone $this;
443
-		$new_question->set( 'QST_ID', null );
444
-		$new_question->set_display_text( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->display_text() ) );
445
-		$new_question->set_admin_label( sprintf( __( '%s **Duplicate**', 'event_espresso' ), $this->admin_label() ) );
446
-		$new_question->set_system_ID( null );
447
-		$new_question->set_wp_user( get_current_user_id() );
443
+		$new_question->set('QST_ID', null);
444
+		$new_question->set_display_text(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->display_text()));
445
+		$new_question->set_admin_label(sprintf(__('%s **Duplicate**', 'event_espresso'), $this->admin_label()));
446
+		$new_question->set_system_ID(null);
447
+		$new_question->set_wp_user(get_current_user_id());
448 448
                 //if we're duplicating a trashed question, assume we don't want the new one to be trashed
449
-                $new_question->set_deleted( false );
449
+                $new_question->set_deleted(false);
450 450
 		$success = $new_question->save();
451
-		if( $success ) {
451
+		if ($success) {
452 452
 			//we don't totally want to duplicate the question options, because we want them to be for the NEW question
453
-			foreach( $this->options() as $question_option ) {
454
-				$question_option->duplicate( array( 'QST_ID' => $new_question->ID() ) );
453
+			foreach ($this->options() as $question_option) {
454
+				$question_option->duplicate(array('QST_ID' => $new_question->ID()));
455 455
 			}
456 456
 			return $new_question;
457 457
 		} else {
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
 	 * @return int|float
465 465
 	 */
466 466
 	public function max() {
467
-		return $this->get( 'QST_max' );
467
+		return $this->get('QST_max');
468 468
 	}
469 469
 
470 470
 	/**
@@ -472,8 +472,8 @@  discard block
 block discarded – undo
472 472
 	 * @param int|float $new_max
473 473
 	 * @return void
474 474
 	 */
475
-	public function set_max( $new_max ) {
476
-		$this->set( 'QST_max', $new_max );
475
+	public function set_max($new_max) {
476
+		$this->set('QST_max', $new_max);
477 477
 	}
478 478
 
479 479
 
@@ -485,7 +485,7 @@  discard block
 block discarded – undo
485 485
 	 * @param array $input_constructor_args
486 486
 	 * @return EE_Form_Input_Base
487 487
 	 */
488
-	public function generate_form_input( $registration = null, $answer = null, $input_constructor_args = array() ) {
488
+	public function generate_form_input($registration = null, $answer = null, $input_constructor_args = array()) {
489 489
 		$identifier = $this->is_system_question() ? $this->system_ID() : $this->ID();
490 490
 
491 491
 		$input_constructor_args = array_merge(
@@ -496,29 +496,29 @@  discard block
 block discarded – undo
496 496
 				),
497 497
 				$input_constructor_args
498 498
 			);
499
-		if( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration ) {
500
-			$answer = EEM_Answer::instance()->get_registration_question_answer_object( $registration, $this->ID() );
499
+		if ( ! $answer instanceof EE_Answer && $registration instanceof EE_Registration) {
500
+			$answer = EEM_Answer::instance()->get_registration_question_answer_object($registration, $this->ID());
501 501
 		}
502 502
 		// has this question been answered ?
503
-		if ( $answer instanceof EE_Answer
503
+		if ($answer instanceof EE_Answer
504 504
              && $answer->value() !== ''
505 505
         ) {
506 506
 			//answer gets htmlspecialchars called on it, undo that please
507 507
 			//because the form input's display strategy may call esc_attr too
508 508
 			//which also does html special characters
509 509
 			$values_with_html_special_chars = $answer->value();
510
-			if( is_array( $values_with_html_special_chars ) ) {
511
-				$default_value = array_map( 'htmlspecialchars_decode', $values_with_html_special_chars );
510
+			if (is_array($values_with_html_special_chars)) {
511
+				$default_value = array_map('htmlspecialchars_decode', $values_with_html_special_chars);
512 512
 			} else {
513
-				$default_value = htmlspecialchars_decode( $values_with_html_special_chars );
513
+				$default_value = htmlspecialchars_decode($values_with_html_special_chars);
514 514
 			}
515 515
 			$input_constructor_args['default'] = $default_value;
516 516
 		}
517
-		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question( $this->system_ID() );
518
-		if( EEM_Question::instance()->question_type_is_in_category(  $this->type(), 'text' ) ) {
519
-			$input_constructor_args[ 'validation_strategies' ][] = new EE_Max_Length_Validation_Strategy(
517
+		$max_max_for_question = EEM_Question::instance()->absolute_max_for_system_question($this->system_ID());
518
+		if (EEM_Question::instance()->question_type_is_in_category($this->type(), 'text')) {
519
+			$input_constructor_args['validation_strategies'][] = new EE_Max_Length_Validation_Strategy(
520 520
 				null,
521
-				min( $max_max_for_question, $this->max() )
521
+				min($max_max_for_question, $this->max())
522 522
 			);
523 523
 		}
524 524
 		$input_constructor_args = apply_filters(
@@ -530,22 +530,22 @@  discard block
 block discarded – undo
530 530
 		);
531 531
 
532 532
 		$result = null;
533
-		switch ( $this->type() ) {
533
+		switch ($this->type()) {
534 534
 			// Text
535 535
 			case EEM_Question::QST_type_text :
536
-				$result = new EE_Text_Input( $input_constructor_args );
536
+				$result = new EE_Text_Input($input_constructor_args);
537 537
 				break;
538 538
 			// Textarea
539 539
 			case EEM_Question::QST_type_textarea :
540
-				$result = new EE_Text_Area_Input( $input_constructor_args );
540
+				$result = new EE_Text_Area_Input($input_constructor_args);
541 541
 				break;
542 542
 			// Radio Buttons
543 543
 			case EEM_Question::QST_type_radio :
544
-				$result = new EE_Radio_Button_Input( $this->options(), $input_constructor_args );
544
+				$result = new EE_Radio_Button_Input($this->options(), $input_constructor_args);
545 545
 				break;
546 546
 			// Dropdown
547 547
 			case EEM_Question::QST_type_dropdown :
548
-				$result = new EE_Select_Input( $this->options(), $input_constructor_args );
548
+				$result = new EE_Select_Input($this->options(), $input_constructor_args);
549 549
 				break;
550 550
 			// State Dropdown
551 551
 			case EEM_Question::QST_type_state :
@@ -556,7 +556,7 @@  discard block
 block discarded – undo
556 556
 					$registration,
557 557
 					$answer
558 558
 				);				
559
-				$result = new EE_State_Select_Input( $state_options, $input_constructor_args );
559
+				$result = new EE_State_Select_Input($state_options, $input_constructor_args);
560 560
 				break;
561 561
 			// Country Dropdown
562 562
 			case EEM_Question::QST_type_country :
@@ -567,49 +567,49 @@  discard block
 block discarded – undo
567 567
 					$registration,
568 568
 					$answer
569 569
 				);
570
-				$result = new EE_Country_Select_Input( $country_options, $input_constructor_args );
570
+				$result = new EE_Country_Select_Input($country_options, $input_constructor_args);
571 571
 				break;
572 572
 			// Checkboxes
573 573
 			case EEM_Question::QST_type_checkbox :
574
-				$result = new EE_Checkbox_Multi_Input( $this->options(), $input_constructor_args );
574
+				$result = new EE_Checkbox_Multi_Input($this->options(), $input_constructor_args);
575 575
 				break;
576 576
 			// Date
577 577
 			case EEM_Question::QST_type_date :
578
-				$result = new EE_Datepicker_Input( $input_constructor_args );
578
+				$result = new EE_Datepicker_Input($input_constructor_args);
579 579
 				break;
580 580
 			case EEM_Question::QST_type_html_textarea :
581
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Simple_HTML_Validation_Strategy();
582
-				$result =  new EE_Text_Area_Input( $input_constructor_args );
583
-				$result->remove_validation_strategy( 'EE_Plaintext_Validation_Strategy' );
581
+				$input_constructor_args['validation_strategies'][] = new EE_Simple_HTML_Validation_Strategy();
582
+				$result = new EE_Text_Area_Input($input_constructor_args);
583
+				$result->remove_validation_strategy('EE_Plaintext_Validation_Strategy');
584 584
 				break;
585 585
 			case EEM_Question::QST_type_email :
586
-				$result = new EE_Email_Input( $input_constructor_args );
586
+				$result = new EE_Email_Input($input_constructor_args);
587 587
 				break;
588 588
 			case EEM_Question::QST_type_us_phone :
589
-				$result = new EE_Phone_Input( $input_constructor_args );
589
+				$result = new EE_Phone_Input($input_constructor_args);
590 590
 				break;
591 591
 			case EEM_Question::QST_type_int :
592
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Int_Validation_Strategy();
593
-				$result = new EE_Text_Input( $input_constructor_args );
592
+				$input_constructor_args['validation_strategies'][] = new EE_Int_Validation_Strategy();
593
+				$result = new EE_Text_Input($input_constructor_args);
594 594
 				break;
595 595
 			case EEM_Question::QST_type_decimal :
596
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_Float_Validation_Strategy();
597
-				$result = new EE_Text_Input( $input_constructor_args );
596
+				$input_constructor_args['validation_strategies'][] = new EE_Float_Validation_Strategy();
597
+				$result = new EE_Text_Input($input_constructor_args);
598 598
 				break;
599 599
 			case EEM_Question::QST_type_url :
600
-				$input_constructor_args[ 'validation_strategies' ][] = new EE_URL_Validation_Strategy();
601
-				$result = new EE_Text_Input( $input_constructor_args );
600
+				$input_constructor_args['validation_strategies'][] = new EE_URL_Validation_Strategy();
601
+				$result = new EE_Text_Input($input_constructor_args);
602 602
 				break;
603 603
 			case EEM_Question::QST_type_year :
604 604
 				$result = new EE_Year_Input(
605 605
 						$input_constructor_args,
606
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this ),
607
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this ),
608
-						apply_filters( 'FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this )
606
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__four_digit', true, $this),
607
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__early_range', 100, $this),
608
+						apply_filters('FHEE__EE_SPCO_Reg_Step_Attendee_Information___generate_question_input__year_question__end_range', 100, $this)
609 609
 						);
610 610
 				break;
611 611
 			case EEM_Question::QST_type_multi_select :
612
-				$result = new EE_Select_Multiple_Input( $this->options(), $input_constructor_args );
612
+				$result = new EE_Select_Multiple_Input($this->options(), $input_constructor_args);
613 613
 				break;
614 614
 			// fallback
615 615
 			default :
@@ -620,12 +620,12 @@  discard block
 block discarded – undo
620 620
 					$this,
621 621
 					$input_constructor_args
622 622
 				);
623
-				if( ! $default_input ){
624
-					$default_input = new EE_Text_Input( $input_constructor_args );
623
+				if ( ! $default_input) {
624
+					$default_input = new EE_Text_Input($input_constructor_args);
625 625
 				}
626 626
 				$result = $default_input;
627 627
 		}
628
-		return apply_filters( 'FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer );
628
+		return apply_filters('FHEE__EE_Question__generate_form_input__return', $result, $registration, $this, $answer);
629 629
 	}
630 630
 
631 631
 
Please login to merge, or discard this patch.
libraries/form_sections/inputs/EE_Form_Input_With_Options_Base.input.php 2 patches
Indentation   +309 added lines, -309 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
 
@@ -16,314 +16,314 @@  discard block
 block discarded – undo
16 16
 class EE_Form_Input_With_Options_Base extends EE_Form_Input_Base
17 17
 {
18 18
 
19
-    /**
20
-     * array of available options to choose as an answer
21
-     *
22
-     * @var array
23
-     */
24
-    protected $_options = array();
25
-
26
-    /**
27
-     * whether to display the html_label_text above the checkbox/radio button options
28
-     *
29
-     * @var boolean
30
-     */
31
-    protected $_display_html_label_text = true;
32
-
33
-    /**
34
-     * whether to display an question option description as part of the input label
35
-     *
36
-     * @var boolean
37
-     */
38
-    protected $_use_desc_in_label = true;
39
-
40
-    /**
41
-     * strlen() result for the longest input value (what gets displayed in the label)
42
-     * this is used to apply a css class to the input label
43
-     *
44
-     * @var int
45
-     */
46
-    protected $_label_size = 0;
47
-
48
-    /**
49
-     * whether to enforce the label size value passed in the constructor
50
-     *
51
-     * @var boolean
52
-     */
53
-    protected $_enforce_label_size = false;
54
-
55
-    /**
56
-     * whether to allow multiple selections (ie, the value of this input should be an array)
57
-     * or not (ie, the value should be a simple int, string, etc)
58
-     *
59
-     * @var boolean
60
-     */
61
-    protected $_multiple_selections = false;
62
-
63
-
64
-
65
-    /**
66
-     * @param array     $answer_options
67
-     * @param array     $input_settings {
68
-     * @type int|string $label_size
69
-     * @type boolean    $display_html_label_text
70
-     *                                  }
71
-     *                                  And all the options accepted by EE_Form_Input_Base
72
-     */
73
-    public function __construct($answer_options = array(), $input_settings = array())
74
-    {
75
-        if (isset($input_settings['label_size'])) {
76
-            $this->_set_label_size($input_settings['label_size']);
77
-            if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
78
-                $this->_enforce_label_size = true;
79
-            }
80
-        }
81
-        if (isset($input_settings['display_html_label_text'])) {
82
-            $this->set_display_html_label_text($input_settings['display_html_label_text']);
83
-        }
84
-        $this->set_select_options($answer_options);
85
-        parent::__construct($input_settings);
86
-    }
87
-
88
-
89
-
90
-    /**
91
-     * Sets the allowed options for this input. Also has the side-effect of
92
-     * updating the normalization strategy to match the keys provided in the array
93
-     *
94
-     * @param array $answer_options
95
-     * @return void  just has the side-effect of setting the options for this input
96
-     */
97
-    public function set_select_options($answer_options = array())
98
-    {
99
-        $answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
100
-        //get the first item in the select options and check it's type
101
-        $this->_options = reset($answer_options) instanceof EE_Question_Option
102
-            ? $this->_process_question_options($answer_options)
103
-            : $answer_options;
104
-        //d( $this->_options );
105
-        $select_option_keys = array_keys($this->_options);
106
-        // attempt to determine data type for values in order to set normalization type
107
-        if (
108
-            count($this->_options) === 2
109
-            && (
110
-                (in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
111
-                || (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
112
-            )
113
-        ) {
114
-            // values appear to be boolean, like TRUE, FALSE, 1, 0
115
-            $normalization = new EE_Boolean_Normalization();
116
-        } else {
117
-            //are ALL the options ints? If so use int validation
118
-            $all_ints = true;
119
-            foreach ($select_option_keys as $value) {
120
-                //allow for a default value which may be empty.
121
-                if ( ! is_int($value) && $value !== '' && $value !== null) {
122
-                    $all_ints = false;
123
-                    break;
124
-                }
125
-            }
126
-            if ($all_ints) {
127
-                $normalization = new EE_Int_Normalization();
128
-            } else {
129
-                $normalization = new EE_Text_Normalization();
130
-            }
131
-        }
132
-        // does input type have multiple options ?
133
-        if ($this->_multiple_selections) {
134
-            $this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
135
-        } else {
136
-            $this->_set_normalization_strategy($normalization);
137
-        }
138
-    }
139
-
140
-
141
-
142
-    /**
143
-     * @return array
144
-     */
145
-    public function options()
146
-    {
147
-        return $this->_options;
148
-    }
149
-
150
-
151
-
152
-    /**
153
-     * Returns an array which is guaranteed to not be multidimensional
154
-     *
155
-     * @return array
156
-     */
157
-    public function flat_options()
158
-    {
159
-        return $this->_flatten_select_options($this->options());
160
-    }
161
-
162
-
163
-
164
-    /**
165
-     * Makes sure $arr is a flat array, not a multidimensional one
166
-     *
167
-     * @param array $arr
168
-     * @return array
169
-     */
170
-    protected function _flatten_select_options($arr)
171
-    {
172
-        $flat_array = array();
173
-        if (EEH_Array::is_multi_dimensional_array($arr)) {
174
-            foreach ($arr as $sub_array) {
175
-                foreach ((array)$sub_array as $key => $value) {
176
-                    $flat_array[$key] = $value;
177
-                    $this->_set_label_size($value);
178
-                }
179
-            }
180
-        } else {
181
-            foreach ($arr as $key => $value) {
182
-                $flat_array[$key] = $value;
183
-                $this->_set_label_size($value);
184
-            }
185
-        }
186
-        return $flat_array;
187
-    }
188
-
189
-
190
-
191
-    /**
192
-     * @param EE_Question_Option[] $question_options_array
193
-     * @return array
194
-     */
195
-    protected function _process_question_options($question_options_array = array())
196
-    {
197
-        $flat_array = array();
198
-        foreach ($question_options_array as $question_option) {
199
-            if ($question_option instanceof EE_Question_Option) {
200
-                $desc = '';
201
-                if ($this->_use_desc_in_label) {
202
-                    $desc = $question_option->desc();
203
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
204
-                }
205
-                $value = $question_option->value();
206
-                // add value even if it's empty
207
-                $flat_array[$value] = $value;
208
-                // if both value and desc are not empty, then separate with a dash
209
-                if ( ! empty($value) && ! empty($desc)) {
210
-                    $flat_array[$value] .= ' - ' . $desc;
211
-                } else {
212
-                    // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
213
-                    $flat_array[$value] .= $desc;
214
-                }
215
-            } elseif (is_array($question_option)) {
216
-                $flat_array += $this->_flatten_select_options($question_option);
217
-            }
218
-        }
219
-        return $flat_array;
220
-    }
221
-
222
-
223
-
224
-    /**
225
-     *    set_label_sizes
226
-     *
227
-     * @return void
228
-     */
229
-    public function set_label_sizes()
230
-    {
231
-        // did the input settings specifically say to NOT set the label size dynamically ?
232
-        if ( ! $this->_enforce_label_size) {
233
-            foreach ($this->_options as $option) {
234
-                // calculate the strlen of the label
235
-                $this->_set_label_size($option);
236
-            }
237
-        }
238
-    }
239
-
240
-
241
-
242
-    /**
243
-     *    _set_label_size_class
244
-     *
245
-     * @param int|string $value
246
-     * @return void
247
-     */
248
-    private function _set_label_size($value = '')
249
-    {
250
-        // determine length of option value
251
-        $val_size = is_int($value) ? $value : strlen($value);
252
-        // use new value if bigger than existing
253
-        $this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
254
-    }
255
-
256
-
257
-
258
-    /**
259
-     *    get_label_size_class
260
-     *
261
-     * @return string
262
-     */
263
-    public function get_label_size_class()
264
-    {
265
-        $size = ' medium-lbl';
266
-        // use maximum option value length to determine label size
267
-        if ($this->_label_size < 3) {
268
-            $size = ' nano-lbl';
269
-        } else if ($this->_label_size < 6) {
270
-            $size = ' micro-lbl';
271
-        } else if ($this->_label_size < 12) {
272
-            $size = ' tiny-lbl';
273
-        } else if ($this->_label_size < 25) {
274
-            $size = ' small-lbl';
275
-        } else if ($this->_label_size < 50) {
276
-            $size = ' medium-lbl';
277
-        } else if ($this->_label_size >= 100) {
278
-            $size = ' big-lbl';
279
-        }
280
-        return $size;
281
-    }
282
-
283
-
284
-
285
-    /**
286
-     * Returns the pretty value for the normalized value
287
-     *
288
-     * @return string
289
-     */
290
-    public function pretty_value()
291
-    {
292
-        $options = $this->flat_options();
293
-        $unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
294
-        if ( ! $this->_multiple_selections) {
295
-            $unnormalized_value_choices = array($unnormalized_value_choices);
296
-        }
297
-        $pretty_strings = array();
298
-        foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
299
-            if (isset($options[$unnormalized_value_choice])) {
300
-                $pretty_strings[] = $options[$unnormalized_value_choice];
301
-            } else {
302
-                $pretty_strings[] = $this->normalized_value();
303
-            }
304
-        }
305
-        return implode(', ', $pretty_strings);
306
-    }
307
-
308
-
309
-
310
-    /**
311
-     * @return boolean
312
-     */
313
-    public function display_html_label_text()
314
-    {
315
-        return $this->_display_html_label_text;
316
-    }
317
-
318
-
319
-
320
-    /**
321
-     * @param boolean $display_html_label_text
322
-     */
323
-    public function set_display_html_label_text($display_html_label_text)
324
-    {
325
-        $this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
326
-    }
19
+	/**
20
+	 * array of available options to choose as an answer
21
+	 *
22
+	 * @var array
23
+	 */
24
+	protected $_options = array();
25
+
26
+	/**
27
+	 * whether to display the html_label_text above the checkbox/radio button options
28
+	 *
29
+	 * @var boolean
30
+	 */
31
+	protected $_display_html_label_text = true;
32
+
33
+	/**
34
+	 * whether to display an question option description as part of the input label
35
+	 *
36
+	 * @var boolean
37
+	 */
38
+	protected $_use_desc_in_label = true;
39
+
40
+	/**
41
+	 * strlen() result for the longest input value (what gets displayed in the label)
42
+	 * this is used to apply a css class to the input label
43
+	 *
44
+	 * @var int
45
+	 */
46
+	protected $_label_size = 0;
47
+
48
+	/**
49
+	 * whether to enforce the label size value passed in the constructor
50
+	 *
51
+	 * @var boolean
52
+	 */
53
+	protected $_enforce_label_size = false;
54
+
55
+	/**
56
+	 * whether to allow multiple selections (ie, the value of this input should be an array)
57
+	 * or not (ie, the value should be a simple int, string, etc)
58
+	 *
59
+	 * @var boolean
60
+	 */
61
+	protected $_multiple_selections = false;
62
+
63
+
64
+
65
+	/**
66
+	 * @param array     $answer_options
67
+	 * @param array     $input_settings {
68
+	 * @type int|string $label_size
69
+	 * @type boolean    $display_html_label_text
70
+	 *                                  }
71
+	 *                                  And all the options accepted by EE_Form_Input_Base
72
+	 */
73
+	public function __construct($answer_options = array(), $input_settings = array())
74
+	{
75
+		if (isset($input_settings['label_size'])) {
76
+			$this->_set_label_size($input_settings['label_size']);
77
+			if (isset($input_settings['enforce_label_size']) && $input_settings['enforce_label_size']) {
78
+				$this->_enforce_label_size = true;
79
+			}
80
+		}
81
+		if (isset($input_settings['display_html_label_text'])) {
82
+			$this->set_display_html_label_text($input_settings['display_html_label_text']);
83
+		}
84
+		$this->set_select_options($answer_options);
85
+		parent::__construct($input_settings);
86
+	}
87
+
88
+
89
+
90
+	/**
91
+	 * Sets the allowed options for this input. Also has the side-effect of
92
+	 * updating the normalization strategy to match the keys provided in the array
93
+	 *
94
+	 * @param array $answer_options
95
+	 * @return void  just has the side-effect of setting the options for this input
96
+	 */
97
+	public function set_select_options($answer_options = array())
98
+	{
99
+		$answer_options = is_array($answer_options) ? $answer_options : array($answer_options);
100
+		//get the first item in the select options and check it's type
101
+		$this->_options = reset($answer_options) instanceof EE_Question_Option
102
+			? $this->_process_question_options($answer_options)
103
+			: $answer_options;
104
+		//d( $this->_options );
105
+		$select_option_keys = array_keys($this->_options);
106
+		// attempt to determine data type for values in order to set normalization type
107
+		if (
108
+			count($this->_options) === 2
109
+			&& (
110
+				(in_array(true, $select_option_keys, true) && in_array(false, $select_option_keys, true))
111
+				|| (in_array(1, $select_option_keys, true) && in_array(0, $select_option_keys, true))
112
+			)
113
+		) {
114
+			// values appear to be boolean, like TRUE, FALSE, 1, 0
115
+			$normalization = new EE_Boolean_Normalization();
116
+		} else {
117
+			//are ALL the options ints? If so use int validation
118
+			$all_ints = true;
119
+			foreach ($select_option_keys as $value) {
120
+				//allow for a default value which may be empty.
121
+				if ( ! is_int($value) && $value !== '' && $value !== null) {
122
+					$all_ints = false;
123
+					break;
124
+				}
125
+			}
126
+			if ($all_ints) {
127
+				$normalization = new EE_Int_Normalization();
128
+			} else {
129
+				$normalization = new EE_Text_Normalization();
130
+			}
131
+		}
132
+		// does input type have multiple options ?
133
+		if ($this->_multiple_selections) {
134
+			$this->_set_normalization_strategy(new EE_Many_Valued_Normalization($normalization));
135
+		} else {
136
+			$this->_set_normalization_strategy($normalization);
137
+		}
138
+	}
139
+
140
+
141
+
142
+	/**
143
+	 * @return array
144
+	 */
145
+	public function options()
146
+	{
147
+		return $this->_options;
148
+	}
149
+
150
+
151
+
152
+	/**
153
+	 * Returns an array which is guaranteed to not be multidimensional
154
+	 *
155
+	 * @return array
156
+	 */
157
+	public function flat_options()
158
+	{
159
+		return $this->_flatten_select_options($this->options());
160
+	}
161
+
162
+
163
+
164
+	/**
165
+	 * Makes sure $arr is a flat array, not a multidimensional one
166
+	 *
167
+	 * @param array $arr
168
+	 * @return array
169
+	 */
170
+	protected function _flatten_select_options($arr)
171
+	{
172
+		$flat_array = array();
173
+		if (EEH_Array::is_multi_dimensional_array($arr)) {
174
+			foreach ($arr as $sub_array) {
175
+				foreach ((array)$sub_array as $key => $value) {
176
+					$flat_array[$key] = $value;
177
+					$this->_set_label_size($value);
178
+				}
179
+			}
180
+		} else {
181
+			foreach ($arr as $key => $value) {
182
+				$flat_array[$key] = $value;
183
+				$this->_set_label_size($value);
184
+			}
185
+		}
186
+		return $flat_array;
187
+	}
188
+
189
+
190
+
191
+	/**
192
+	 * @param EE_Question_Option[] $question_options_array
193
+	 * @return array
194
+	 */
195
+	protected function _process_question_options($question_options_array = array())
196
+	{
197
+		$flat_array = array();
198
+		foreach ($question_options_array as $question_option) {
199
+			if ($question_option instanceof EE_Question_Option) {
200
+				$desc = '';
201
+				if ($this->_use_desc_in_label) {
202
+					$desc = $question_option->desc();
203
+					$desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
204
+				}
205
+				$value = $question_option->value();
206
+				// add value even if it's empty
207
+				$flat_array[$value] = $value;
208
+				// if both value and desc are not empty, then separate with a dash
209
+				if ( ! empty($value) && ! empty($desc)) {
210
+					$flat_array[$value] .= ' - ' . $desc;
211
+				} else {
212
+					// otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
213
+					$flat_array[$value] .= $desc;
214
+				}
215
+			} elseif (is_array($question_option)) {
216
+				$flat_array += $this->_flatten_select_options($question_option);
217
+			}
218
+		}
219
+		return $flat_array;
220
+	}
221
+
222
+
223
+
224
+	/**
225
+	 *    set_label_sizes
226
+	 *
227
+	 * @return void
228
+	 */
229
+	public function set_label_sizes()
230
+	{
231
+		// did the input settings specifically say to NOT set the label size dynamically ?
232
+		if ( ! $this->_enforce_label_size) {
233
+			foreach ($this->_options as $option) {
234
+				// calculate the strlen of the label
235
+				$this->_set_label_size($option);
236
+			}
237
+		}
238
+	}
239
+
240
+
241
+
242
+	/**
243
+	 *    _set_label_size_class
244
+	 *
245
+	 * @param int|string $value
246
+	 * @return void
247
+	 */
248
+	private function _set_label_size($value = '')
249
+	{
250
+		// determine length of option value
251
+		$val_size = is_int($value) ? $value : strlen($value);
252
+		// use new value if bigger than existing
253
+		$this->_label_size = $val_size > $this->_label_size ? $val_size : $this->_label_size;
254
+	}
255
+
256
+
257
+
258
+	/**
259
+	 *    get_label_size_class
260
+	 *
261
+	 * @return string
262
+	 */
263
+	public function get_label_size_class()
264
+	{
265
+		$size = ' medium-lbl';
266
+		// use maximum option value length to determine label size
267
+		if ($this->_label_size < 3) {
268
+			$size = ' nano-lbl';
269
+		} else if ($this->_label_size < 6) {
270
+			$size = ' micro-lbl';
271
+		} else if ($this->_label_size < 12) {
272
+			$size = ' tiny-lbl';
273
+		} else if ($this->_label_size < 25) {
274
+			$size = ' small-lbl';
275
+		} else if ($this->_label_size < 50) {
276
+			$size = ' medium-lbl';
277
+		} else if ($this->_label_size >= 100) {
278
+			$size = ' big-lbl';
279
+		}
280
+		return $size;
281
+	}
282
+
283
+
284
+
285
+	/**
286
+	 * Returns the pretty value for the normalized value
287
+	 *
288
+	 * @return string
289
+	 */
290
+	public function pretty_value()
291
+	{
292
+		$options = $this->flat_options();
293
+		$unnormalized_value_choices = $this->get_normalization_strategy()->unnormalize($this->_normalized_value);
294
+		if ( ! $this->_multiple_selections) {
295
+			$unnormalized_value_choices = array($unnormalized_value_choices);
296
+		}
297
+		$pretty_strings = array();
298
+		foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
299
+			if (isset($options[$unnormalized_value_choice])) {
300
+				$pretty_strings[] = $options[$unnormalized_value_choice];
301
+			} else {
302
+				$pretty_strings[] = $this->normalized_value();
303
+			}
304
+		}
305
+		return implode(', ', $pretty_strings);
306
+	}
307
+
308
+
309
+
310
+	/**
311
+	 * @return boolean
312
+	 */
313
+	public function display_html_label_text()
314
+	{
315
+		return $this->_display_html_label_text;
316
+	}
317
+
318
+
319
+
320
+	/**
321
+	 * @param boolean $display_html_label_text
322
+	 */
323
+	public function set_display_html_label_text($display_html_label_text)
324
+	{
325
+		$this->_display_html_label_text = filter_var($display_html_label_text, FILTER_VALIDATE_BOOLEAN);
326
+	}
327 327
 
328 328
 
329 329
 
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
         $flat_array = array();
173 173
         if (EEH_Array::is_multi_dimensional_array($arr)) {
174 174
             foreach ($arr as $sub_array) {
175
-                foreach ((array)$sub_array as $key => $value) {
175
+                foreach ((array) $sub_array as $key => $value) {
176 176
                     $flat_array[$key] = $value;
177 177
                     $this->_set_label_size($value);
178 178
                 }
@@ -200,14 +200,14 @@  discard block
 block discarded – undo
200 200
                 $desc = '';
201 201
                 if ($this->_use_desc_in_label) {
202 202
                     $desc = $question_option->desc();
203
-                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">' . $desc . '</span>' : '';
203
+                    $desc = ! empty($desc) ? '<span class="ee-question-option-desc">'.$desc.'</span>' : '';
204 204
                 }
205 205
                 $value = $question_option->value();
206 206
                 // add value even if it's empty
207 207
                 $flat_array[$value] = $value;
208 208
                 // if both value and desc are not empty, then separate with a dash
209 209
                 if ( ! empty($value) && ! empty($desc)) {
210
-                    $flat_array[$value] .= ' - ' . $desc;
210
+                    $flat_array[$value] .= ' - '.$desc;
211 211
                 } else {
212 212
                     // otherwise, just add desc, since either or both of the vars is empty, and no dash is necessary
213 213
                     $flat_array[$value] .= $desc;
@@ -295,7 +295,7 @@  discard block
 block discarded – undo
295 295
             $unnormalized_value_choices = array($unnormalized_value_choices);
296 296
         }
297 297
         $pretty_strings = array();
298
-        foreach ((array)$unnormalized_value_choices as $unnormalized_value_choice) {
298
+        foreach ((array) $unnormalized_value_choices as $unnormalized_value_choice) {
299 299
             if (isset($options[$unnormalized_value_choice])) {
300 300
                 $pretty_strings[] = $options[$unnormalized_value_choice];
301 301
             } else {
Please login to merge, or discard this patch.
core/interfaces/EEI_Interfaces.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -190,7 +190,7 @@  discard block
 block discarded – undo
190 190
 interface EEI_Attendee {
191 191
 	public function fname();
192 192
 	public function lname();
193
-    public function full_name();
193
+	public function full_name();
194 194
 	public function email();
195 195
 	public function phone();
196 196
 	public function address();
@@ -311,23 +311,23 @@  discard block
 block discarded – undo
311 311
 	 * @param float $amount
312 312
 	 * @param string $name
313 313
 	 * @param string $description
314
-         * @param string $code
315
-         * @param boolean $add_to_existing_line_item if true and a duplicate line item with
316
-         *  the same code is found, $amount will be added onto it; otherwise will simply
317
-         *  set the taxes to match $amount
314
+	 * @param string $code
315
+	 * @param boolean $add_to_existing_line_item if true and a duplicate line item with
316
+	 *  the same code is found, $amount will be added onto it; otherwise will simply
317
+	 *  set the taxes to match $amount
318 318
 	 * @return EE_Line_Item the new tax created
319 319
 	 */
320 320
 	public function set_total_tax_to( EE_Line_Item $total_line_item, $amount, $name  = NULL, $description = NULL, $code = NULL, $add_to_existing_line_item = false );
321 321
 
322
-         /**
323
-         * Makes all the line items which are children of $line_item taxable (or not).
324
-         * Does NOT save the line items
325
-         * @param EE_Line_Item $line_item
326
-         * @param boolean $taxable
327
-         * @param string $code_substring_for_whitelist if this string is part of the line item's code
328
-         *  it will be whitelisted (ie, except from becoming taxable)
329
-         */
330
-        public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
322
+		 /**
323
+		  * Makes all the line items which are children of $line_item taxable (or not).
324
+		  * Does NOT save the line items
325
+		  * @param EE_Line_Item $line_item
326
+		  * @param boolean $taxable
327
+		  * @param string $code_substring_for_whitelist if this string is part of the line item's code
328
+		  *  it will be whitelisted (ie, except from becoming taxable)
329
+		  */
330
+		public static function set_line_items_taxable( EE_Line_Item $line_item, $taxable = true, $code_substring_for_whitelist = null );
331 331
 
332 332
 	/**
333 333
 	 * Adds a simple item ( unrelated to any other model object) to the total line item,
@@ -357,15 +357,15 @@  discard block
 block discarded – undo
357 357
  */
358 358
 interface EEHI_Money{
359 359
 		/**
360
-	 * For comparing floats. Default operator is '=', but see the $operator below for all options.
361
-	 * This should be used to compare floats instead of normal '==' because floats
362
-	 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
363
-	 * but actually differ by 0.00000001.
364
-	 * @param float $float1
365
-	 * @param float $float2
366
-	 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
367
-	 * @return boolean whether the equation is true or false
368
-	 */
360
+		 * For comparing floats. Default operator is '=', but see the $operator below for all options.
361
+		 * This should be used to compare floats instead of normal '==' because floats
362
+		 * are inherently imprecise, and so you can sometimes have two floats that appear to be identical
363
+		 * but actually differ by 0.00000001.
364
+		 * @param float $float1
365
+		 * @param float $float2
366
+		 * @param string $operator  The operator. Valid options are =, <=, <, >=, >, <>, eq, lt, lte, gt, gte, ne
367
+		 * @return boolean whether the equation is true or false
368
+		 */
369 369
 	public function compare_floats( $float1, $float2, $operator='=' );
370 370
 }
371 371
 
Please login to merge, or discard this patch.
caffeinated/payment_methods/Paypal_Pro/EEG_Paypal_Pro.gateway.php 2 patches
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -90,19 +90,19 @@  discard block
 block discarded – undo
90 90
 	 */
91 91
 	public function do_direct_payment($payment,$billing_info = null){
92 92
 		$transaction = $payment->transaction();
93
-        if (! $transaction instanceof EEI_Transaction) {
94
-            throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso'));
95
-        }
96
-        $primary_registrant = $transaction->primary_registration();
97
-        if (! $primary_registrant instanceof EEI_Registration) {
98
-            throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.',
99
-                'event_espresso'));
100
-        }
101
-        $attendee = $primary_registrant->attendee();
102
-        if (! $attendee instanceof EEI_Attendee) {
103
-            throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.',
104
-                'event_espresso'));
105
-        }
93
+		if (! $transaction instanceof EEI_Transaction) {
94
+			throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso'));
95
+		}
96
+		$primary_registrant = $transaction->primary_registration();
97
+		if (! $primary_registrant instanceof EEI_Registration) {
98
+			throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.',
99
+				'event_espresso'));
100
+		}
101
+		$attendee = $primary_registrant->attendee();
102
+		if (! $attendee instanceof EEI_Attendee) {
103
+			throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.',
104
+				'event_espresso'));
105
+		}
106 106
 		$order_description  = $this->_format_order_description( $payment );
107 107
 		//charge for the full amount. Show itemized list
108 108
 		if( $this->_can_easily_itemize_transaction_for( $payment ) ){
@@ -232,23 +232,23 @@  discard block
 block discarded – undo
232 232
 			'zip' => $billing_info['zip'],
233 233
 		);
234 234
 
235
-        //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
236
-        if($attendee->address() && $attendee->city() && $attendee->country_ID()){
237
-            $use_registration_address_info = true;
238
-        } else {
239
-            $use_registration_address_info = false;
240
-        }
241
-        //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again
242
-        $ShippingAddress = array(
243
-            'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
244
-            'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100),
245
-            'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'],0,100),
246
-            'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'],0,40),
247
-            'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'],0,40),
248
-            'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'],
249
-            'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'],0,20),
250
-            'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'],0,20),
251
-        );
235
+		//check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
236
+		if($attendee->address() && $attendee->city() && $attendee->country_ID()){
237
+			$use_registration_address_info = true;
238
+		} else {
239
+			$use_registration_address_info = false;
240
+		}
241
+		//so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again
242
+		$ShippingAddress = array(
243
+			'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
244
+			'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100),
245
+			'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'],0,100),
246
+			'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'],0,40),
247
+			'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'],0,40),
248
+			'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'],
249
+			'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'],0,20),
250
+			'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'],0,20),
251
+		);
252 252
 
253 253
 		$PaymentDetails = array(
254 254
 			// Required.  Total amount of order, including shipping, handling, and tax.
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 				'PayerInfo' => $PayerInfo,
281 281
 				'PayerName' => $PayerName,
282 282
 				'BillingAddress' => $BillingAddress,
283
-                'ShippingAddress' => $ShippingAddress,
283
+				'ShippingAddress' => $ShippingAddress,
284 284
 				'PaymentDetails' => $PaymentDetails,
285 285
 				'OrderItems' => $order_items,
286 286
 		);
Please login to merge, or discard this patch.
Spacing   +61 added lines, -61 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
 /**
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
  *
26 26
  * ------------------------------------------------------------------------
27 27
  */
28
-class EEG_Paypal_Pro extends EE_Onsite_Gateway{
28
+class EEG_Paypal_Pro extends EE_Onsite_Gateway {
29 29
 	/**
30 30
 	 *
31 31
 	 * @var $_paypal_api_username string
@@ -88,42 +88,42 @@  discard block
 block discarded – undo
88 88
 	 * } @see parent::do_direct_payment for more info
89 89
 	 * @return \EE_Payment|\EEI_Payment
90 90
 	 */
91
-	public function do_direct_payment($payment,$billing_info = null){
91
+	public function do_direct_payment($payment, $billing_info = null) {
92 92
 		$transaction = $payment->transaction();
93
-        if (! $transaction instanceof EEI_Transaction) {
93
+        if ( ! $transaction instanceof EEI_Transaction) {
94 94
             throw new EE_Error(esc_html__('No transaction for payment while paying with PayPal Pro.', 'event_espresso'));
95 95
         }
96 96
         $primary_registrant = $transaction->primary_registration();
97
-        if (! $primary_registrant instanceof EEI_Registration) {
97
+        if ( ! $primary_registrant instanceof EEI_Registration) {
98 98
             throw new EE_Error(esc_html__('No primary registration on transaction while paying with PayPal Pro.',
99 99
                 'event_espresso'));
100 100
         }
101 101
         $attendee = $primary_registrant->attendee();
102
-        if (! $attendee instanceof EEI_Attendee) {
102
+        if ( ! $attendee instanceof EEI_Attendee) {
103 103
             throw new EE_Error(esc_html__('No attendee on primary registration while paying with PayPal Pro.',
104 104
                 'event_espresso'));
105 105
         }
106
-		$order_description  = $this->_format_order_description( $payment );
106
+		$order_description = $this->_format_order_description($payment);
107 107
 		//charge for the full amount. Show itemized list
108
-		if( $this->_can_easily_itemize_transaction_for( $payment ) ){
108
+		if ($this->_can_easily_itemize_transaction_for($payment)) {
109 109
 			$item_num = 1;
110 110
 			$total_line_item = $transaction->total_line_item();
111 111
 			$order_items = array();
112 112
 			foreach ($total_line_item->get_items() as $line_item) {
113 113
 				//ignore line items with a quantity of 0
114
-				if( $line_item->quantity() == 0 ) {
114
+				if ($line_item->quantity() == 0) {
115 115
 					continue;
116 116
 				}
117 117
 				$item = array(
118 118
 						// Item Name.  127 char max.
119 119
 						'l_name' => substr(
120
-							$this->_format_line_item_name( $line_item, $payment ),
120
+							$this->_format_line_item_name($line_item, $payment),
121 121
 							0,
122 122
 							127
123 123
 						),
124 124
 						// Item description.  127 char max.
125 125
 						'l_desc' => substr( 
126
-							$this->_format_line_item_desc( $line_item, $payment ),
126
+							$this->_format_line_item_desc($line_item, $payment),
127 127
 							0,
128 128
 							127
129 129
 						),
@@ -147,20 +147,20 @@  discard block
 block discarded – undo
147 147
 			}
148 148
 			$item_amount = $total_line_item->get_items_total();
149 149
 			$tax_amount = $total_line_item->get_total_tax();
150
-		}else{
150
+		} else {
151 151
 			$order_items = array();
152 152
 			$item_amount = $payment->amount();
153 153
 			$tax_amount = 0;
154
-			array_push($order_items,array(
154
+			array_push($order_items, array(
155 155
 				// Item Name.  127 char max.
156 156
 				'l_name' => substr(
157
-					$this->_format_partial_payment_line_item_name( $payment ),
157
+					$this->_format_partial_payment_line_item_name($payment),
158 158
 					0,
159 159
 					127
160 160
 				),
161 161
 				// Item description.  127 char max.
162 162
 				'l_desc' => substr( 
163
-					$this->_format_partial_payment_line_item_desc( $payment ),
163
+					$this->_format_partial_payment_line_item_desc($payment),
164 164
 					0,
165 165
 					127
166 166
 				),
@@ -208,11 +208,11 @@  discard block
 block discarded – undo
208 208
 			// Payer's salutation.  20 char max.
209 209
 			'salutation' => '',
210 210
 			// Payer's first name.  25 char max.
211
-			'firstname' => substr($billing_info['first_name'],0,25),
211
+			'firstname' => substr($billing_info['first_name'], 0, 25),
212 212
 			// Payer's middle name.  25 char max.
213 213
 			'middlename' => '',
214 214
 			// Payer's last name.  25 char max.
215
-			'lastname' => substr($billing_info['last_name'],0,25),
215
+			'lastname' => substr($billing_info['last_name'], 0, 25),
216 216
 			// Payer's suffix.  12 char max.
217 217
 			'suffix' => ''
218 218
 		);
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 			// Required.  Name of City.
226 226
 			'city' => $billing_info['city'],
227 227
 			// Required. Name of State or Province.
228
-			'state' => substr( $billing_info['state'], 0, 40 ),
228
+			'state' => substr($billing_info['state'], 0, 40),
229 229
 			// Required.  Country code.
230 230
 			'countrycode' => $billing_info['country'],
231 231
 			// Required.  Postal code of payer.
@@ -233,21 +233,21 @@  discard block
 block discarded – undo
233 233
 		);
234 234
 
235 235
         //check if the registration info contains the needed fields for paypal pro (see https://developer.paypal.com/docs/classic/api/merchant/DoDirectPayment_API_Operation_NVP/)
236
-        if($attendee->address() && $attendee->city() && $attendee->country_ID()){
236
+        if ($attendee->address() && $attendee->city() && $attendee->country_ID()) {
237 237
             $use_registration_address_info = true;
238 238
         } else {
239 239
             $use_registration_address_info = false;
240 240
         }
241 241
         //so if the attendee has enough data to fill out PayPal Pro's shipping info, use it. If not, use the billing info again
242 242
         $ShippingAddress = array(
243
-            'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'] . ' ' . $billing_info['last_name'], 0, 32),
243
+            'shiptoname' => substr($use_registration_address_info ? $attendee->full_name() : $billing_info['first_name'].' '.$billing_info['last_name'], 0, 32),
244 244
             'shiptostreet' => substr($use_registration_address_info ? $attendee->address() : $billing_info['address'], 0, 100),
245
-            'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'],0,100),
246
-            'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'],0,40),
247
-            'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'],0,40),
245
+            'shiptostreet2' => substr($use_registration_address_info ? $attendee->address2() : $billing_info['address2'], 0, 100),
246
+            'shiptocity' => substr($use_registration_address_info ? $attendee->city() : $billing_info['city'], 0, 40),
247
+            'state' => substr($use_registration_address_info ? $attendee->state_name() : $billing_info['state'], 0, 40),
248 248
             'shiptocountry' => $use_registration_address_info ? $attendee->country_ID() : $billing_info['country'],
249
-            'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'],0,20),
250
-            'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'],0,20),
249
+            'shiptozip' => substr($use_registration_address_info ? $attendee->zip() : $billing_info['zip'], 0, 20),
250
+            'shiptophonenum' => substr($use_registration_address_info ? $attendee->phone() : $billing_info['phone'], 0, 20),
251 251
         );
252 252
 
253 253
 		$PaymentDetails = array(
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
 			// Required.  Three-letter currency code.  Default is USD.
257 257
 			'currencycode' => $payment->currency_code(),
258 258
 			// Required if you include itemized cart details. (L_AMTn, etc.)  Subtotal of items not including S&H, or tax.
259
-			'itemamt' => $this->format_currency($item_amount),//
259
+			'itemamt' => $this->format_currency($item_amount), //
260 260
 			// Total shipping costs for the order.  If you specify shippingamt, you must also specify itemamt.
261 261
 			'shippingamt' => '',
262 262
 			// Total handling costs for the order.  If you specify handlingamt, you must also specify itemamt.
@@ -268,10 +268,10 @@  discard block
 block discarded – undo
268 268
 			// Free-form field for your own use.  256 char max.
269 269
 			'custom' => $primary_registrant ? $primary_registrant->ID() : '',
270 270
 			// Your own invoice or tracking number
271
-			'invnum' => wp_generate_password(12,false),//$transaction->ID(),
271
+			'invnum' => wp_generate_password(12, false), //$transaction->ID(),
272 272
 			// URL for receiving Instant Payment Notifications.  This overrides what your profile is set to use.
273 273
 			'notifyurl' => '',
274
-			'buttonsource' => 'EventEspresso_SP',//EE will blow up if you change this
274
+			'buttonsource' => 'EventEspresso_SP', //EE will blow up if you change this
275 275
 		);
276 276
 		// Wrap all data arrays into a single, "master" array which will be passed into the class function.
277 277
 		$PayPalRequestData = array(
@@ -285,32 +285,32 @@  discard block
 block discarded – undo
285 285
 				'OrderItems' => $order_items,
286 286
 		);
287 287
 		$this->_log_clean_request($PayPalRequestData, $payment);
288
-		try{
288
+		try {
289 289
 			$PayPalResult = $this->prep_and_curl_request($PayPalRequestData);
290 290
 			//remove PCI-sensitive data so it doesn't get stored
291
-			$PayPalResult = $this->_log_clean_response($PayPalResult,$payment);
291
+			$PayPalResult = $this->_log_clean_response($PayPalResult, $payment);
292 292
 
293 293
 			$message = isset($PayPalResult['L_LONGMESSAGE0']) ? $PayPalResult['L_LONGMESSAGE0'] : $PayPalResult['ACK'];
294
-			if( empty($PayPalResult[ 'RAWRESPONSE' ] ) ) {
295
-				$payment->set_status( $this->_pay_model->failed_status() ) ;
296
-				$payment->set_gateway_response( __( 'No response received from Paypal Pro', 'event_espresso' ) );
294
+			if (empty($PayPalResult['RAWRESPONSE'])) {
295
+				$payment->set_status($this->_pay_model->failed_status());
296
+				$payment->set_gateway_response(__('No response received from Paypal Pro', 'event_espresso'));
297 297
 				$payment->set_details($PayPalResult);
298
-			}else{
299
-				if($this->_APICallSuccessful($PayPalResult)){
298
+			} else {
299
+				if ($this->_APICallSuccessful($PayPalResult)) {
300 300
 					$payment->set_status($this->_pay_model->approved_status());
301
-				}else{
301
+				} else {
302 302
 					$payment->set_status($this->_pay_model->declined_status());
303 303
 				}
304 304
 				//make sure we interpret the AMT as a float, not an international string (where periods are thousand separators)
305
-				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval( $PayPalResult['AMT'] ) : 0);
305
+				$payment->set_amount(isset($PayPalResult['AMT']) ? floatval($PayPalResult['AMT']) : 0);
306 306
 				$payment->set_gateway_response($message);
307
-				$payment->set_txn_id_chq_nmbr(isset( $PayPalResult['TRANSACTIONID'] )? $PayPalResult['TRANSACTIONID'] : null);
307
+				$payment->set_txn_id_chq_nmbr(isset($PayPalResult['TRANSACTIONID']) ? $PayPalResult['TRANSACTIONID'] : null);
308 308
 
309 309
 				$primary_registration_code = $primary_registrant instanceof EE_Registration ? $primary_registrant->reg_code() : '';
310 310
 				$payment->set_extra_accntng($primary_registration_code);
311 311
 				$payment->set_details($PayPalResult);
312 312
 			}
313
-		}catch(Exception $e){
313
+		} catch (Exception $e) {
314 314
 			$payment->set_status($this->_pay_model->failed_status());
315 315
 			$payment->set_gateway_response($e->getMessage());
316 316
 		}
@@ -327,7 +327,7 @@  discard block
 block discarded – undo
327 327
 	 * @param EEI_Payment $payment
328 328
 	 * @return array
329 329
 	 */
330
-	private function _log_clean_request($request,$payment){
330
+	private function _log_clean_request($request, $payment) {
331 331
 		$cleaned_request_data = $request;
332 332
 		unset($cleaned_request_data['CCDetails']['acct']);
333 333
 		unset($cleaned_request_data['CCDetails']['cvv2']);
@@ -343,13 +343,13 @@  discard block
 block discarded – undo
343 343
 	 * @param EEI_Payment $payment
344 344
 	 * @return array cleaned
345 345
 	 */
346
-	private function _log_clean_response($response,$payment){
346
+	private function _log_clean_response($response, $payment) {
347 347
 		unset($response['REQUESTDATA']['CREDITCARDTYPE']);
348 348
 		unset($response['REQUESTDATA']['ACCT']);
349 349
 		unset($response['REQUESTDATA']['EXPDATE']);
350 350
 		unset($response['REQUESTDATA']['CVV2']);
351 351
 		unset($response['RAWREQUEST']);
352
-		$this->log(array('Paypal Response'=>$response),$payment);
352
+		$this->log(array('Paypal Response'=>$response), $payment);
353 353
 		return $response;
354 354
 	}
355 355
 
@@ -374,32 +374,32 @@  discard block
 block discarded – undo
374 374
 		// DP Fields
375 375
 		$DPFields = isset($DataArray['DPFields']) ? $DataArray['DPFields'] : array();
376 376
 		foreach ($DPFields as $DPFieldsVar => $DPFieldsVal)
377
-			$DPFieldsNVP .= '&' . strtoupper($DPFieldsVar) . '=' . urlencode($DPFieldsVal);
377
+			$DPFieldsNVP .= '&'.strtoupper($DPFieldsVar).'='.urlencode($DPFieldsVal);
378 378
 
379 379
 		// CC Details Fields
380 380
 		$CCDetails = isset($DataArray['CCDetails']) ? $DataArray['CCDetails'] : array();
381 381
 		foreach ($CCDetails as $CCDetailsVar => $CCDetailsVal)
382
-			$CCDetailsNVP .= '&' . strtoupper($CCDetailsVar) . '=' . urlencode($CCDetailsVal);
382
+			$CCDetailsNVP .= '&'.strtoupper($CCDetailsVar).'='.urlencode($CCDetailsVal);
383 383
 
384 384
 		// PayerInfo Type Fields
385 385
 		$PayerInfo = isset($DataArray['PayerInfo']) ? $DataArray['PayerInfo'] : array();
386 386
 		foreach ($PayerInfo as $PayerInfoVar => $PayerInfoVal)
387
-			$PayerInfoNVP .= '&' . strtoupper($PayerInfoVar) . '=' . urlencode($PayerInfoVal);
387
+			$PayerInfoNVP .= '&'.strtoupper($PayerInfoVar).'='.urlencode($PayerInfoVal);
388 388
 
389 389
 		// Payer Name Fields
390 390
 		$PayerName = isset($DataArray['PayerName']) ? $DataArray['PayerName'] : array();
391 391
 		foreach ($PayerName as $PayerNameVar => $PayerNameVal)
392
-			$PayerNameNVP .= '&' . strtoupper($PayerNameVar) . '=' . urlencode($PayerNameVal);
392
+			$PayerNameNVP .= '&'.strtoupper($PayerNameVar).'='.urlencode($PayerNameVal);
393 393
 
394 394
 		// Address Fields (Billing)
395 395
 		$BillingAddress = isset($DataArray['BillingAddress']) ? $DataArray['BillingAddress'] : array();
396 396
 		foreach ($BillingAddress as $BillingAddressVar => $BillingAddressVal)
397
-			$BillingAddressNVP .= '&' . strtoupper($BillingAddressVar) . '=' . urlencode($BillingAddressVal);
397
+			$BillingAddressNVP .= '&'.strtoupper($BillingAddressVar).'='.urlencode($BillingAddressVal);
398 398
 
399 399
 		// Payment Details Type Fields
400 400
 		$PaymentDetails = isset($DataArray['PaymentDetails']) ? $DataArray['PaymentDetails'] : array();
401 401
 		foreach ($PaymentDetails as $PaymentDetailsVar => $PaymentDetailsVal)
402
-			$PaymentDetailsNVP .= '&' . strtoupper($PaymentDetailsVar) . '=' . urlencode($PaymentDetailsVal);
402
+			$PaymentDetailsNVP .= '&'.strtoupper($PaymentDetailsVar).'='.urlencode($PaymentDetailsVal);
403 403
 
404 404
 		// Payment Details Item Type Fields
405 405
 		$OrderItems = isset($DataArray['OrderItems']) ? $DataArray['OrderItems'] : array();
@@ -407,22 +407,22 @@  discard block
 block discarded – undo
407 407
 		foreach ($OrderItems as $OrderItemsVar => $OrderItemsVal) {
408 408
 			$CurrentItem = $OrderItems[$OrderItemsVar];
409 409
 			foreach ($CurrentItem as $CurrentItemVar => $CurrentItemVal)
410
-				$OrderItemsNVP .= '&' . strtoupper($CurrentItemVar) . $n . '=' . urlencode($CurrentItemVal);
410
+				$OrderItemsNVP .= '&'.strtoupper($CurrentItemVar).$n.'='.urlencode($CurrentItemVal);
411 411
 			$n++;
412 412
 		}
413 413
 
414 414
 		// Ship To Address Fields
415 415
 		$ShippingAddress = isset($DataArray['ShippingAddress']) ? $DataArray['ShippingAddress'] : array();
416 416
 		foreach ($ShippingAddress as $ShippingAddressVar => $ShippingAddressVal)
417
-			$ShippingAddressNVP .= '&' . strtoupper($ShippingAddressVar) . '=' . urlencode($ShippingAddressVal);
417
+			$ShippingAddressNVP .= '&'.strtoupper($ShippingAddressVar).'='.urlencode($ShippingAddressVal);
418 418
 
419 419
 		// 3D Secure Fields
420 420
 		$Secure3D = isset($DataArray['Secure3D']) ? $DataArray['Secure3D'] : array();
421 421
 		foreach ($Secure3D as $Secure3DVar => $Secure3DVal)
422
-			$Secure3DNVP .= '&' . strtoupper($Secure3DVar) . '=' . urlencode($Secure3DVal);
422
+			$Secure3DNVP .= '&'.strtoupper($Secure3DVar).'='.urlencode($Secure3DVal);
423 423
 
424 424
 		// Now that we have each chunk we need to go ahead and append them all together for our entire NVP string
425
-		$NVPRequest = 'USER=' . $this->_username . '&PWD=' . $this->_password . '&VERSION=64.0' . '&SIGNATURE=' . $this->_signature . $DPFieldsNVP . $CCDetailsNVP . $PayerInfoNVP . $PayerNameNVP . $BillingAddressNVP . $PaymentDetailsNVP . $OrderItemsNVP . $ShippingAddressNVP . $Secure3DNVP;
425
+		$NVPRequest = 'USER='.$this->_username.'&PWD='.$this->_password.'&VERSION=64.0'.'&SIGNATURE='.$this->_signature.$DPFieldsNVP.$CCDetailsNVP.$PayerInfoNVP.$PayerNameNVP.$BillingAddressNVP.$PaymentDetailsNVP.$OrderItemsNVP.$ShippingAddressNVP.$Secure3DNVP;
426 426
 		$NVPResponse = $this->_CURLRequest($NVPRequest);
427 427
 		$NVPRequestArray = $this->_NVPToArray($NVPRequest);
428 428
 		$NVPResponseArray = $this->_NVPToArray($NVPResponse);
@@ -446,7 +446,7 @@  discard block
 block discarded – undo
446 446
 	private function _CURLRequest($Request) {
447 447
 		$EndPointURL = $this->_debug_mode ? 'https://api-3t.sandbox.paypal.com/nvp' : 'https://api-3t.paypal.com/nvp';
448 448
 		$curl = curl_init();
449
-		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE ) );
449
+		curl_setopt($curl, CURLOPT_VERBOSE, apply_filters('FHEE__EEG_Paypal_Pro__CurlRequest__CURLOPT_VERBOSE', TRUE));
450 450
 		curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, FALSE);
451 451
 		curl_setopt($curl, CURLOPT_TIMEOUT, 60);
452 452
 		curl_setopt($curl, CURLOPT_URL, $EndPointURL);
@@ -496,9 +496,9 @@  discard block
 block discarded – undo
496 496
 	private function _APICallSuccessful($PayPalResult) {
497 497
 		$approved = false;
498 498
 		// check main response message from PayPal
499
-		if (isset($PayPalResult['ACK']) && !empty($PayPalResult['ACK'])) {
499
+		if (isset($PayPalResult['ACK']) && ! empty($PayPalResult['ACK'])) {
500 500
 			$ack = strtoupper($PayPalResult['ACK']);
501
-			$approved = ( $ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS' ) ? true : false;
501
+			$approved = ($ack == 'SUCCESS' || $ack == 'SUCCESSWITHWARNING' || $ack == 'PARTIALSUCCESS') ? true : false;
502 502
 		}
503 503
 
504 504
 		return $approved;
@@ -514,11 +514,11 @@  discard block
 block discarded – undo
514 514
 
515 515
 		$Errors = array();
516 516
 		$n = 0;
517
-		while (isset($DataArray['L_ERRORCODE' . $n . ''])) {
518
-			$LErrorCode = isset($DataArray['L_ERRORCODE' . $n . '']) ? $DataArray['L_ERRORCODE' . $n . ''] : '';
519
-			$LShortMessage = isset($DataArray['L_SHORTMESSAGE' . $n . '']) ? $DataArray['L_SHORTMESSAGE' . $n . ''] : '';
520
-			$LLongMessage = isset($DataArray['L_LONGMESSAGE' . $n . '']) ? $DataArray['L_LONGMESSAGE' . $n . ''] : '';
521
-			$LSeverityCode = isset($DataArray['L_SEVERITYCODE' . $n . '']) ? $DataArray['L_SEVERITYCODE' . $n . ''] : '';
517
+		while (isset($DataArray['L_ERRORCODE'.$n.''])) {
518
+			$LErrorCode = isset($DataArray['L_ERRORCODE'.$n.'']) ? $DataArray['L_ERRORCODE'.$n.''] : '';
519
+			$LShortMessage = isset($DataArray['L_SHORTMESSAGE'.$n.'']) ? $DataArray['L_SHORTMESSAGE'.$n.''] : '';
520
+			$LLongMessage = isset($DataArray['L_LONGMESSAGE'.$n.'']) ? $DataArray['L_LONGMESSAGE'.$n.''] : '';
521
+			$LSeverityCode = isset($DataArray['L_SEVERITYCODE'.$n.'']) ? $DataArray['L_SEVERITYCODE'.$n.''] : '';
522 522
 
523 523
 			$CurrentItem = array(
524 524
 					'L_ERRORCODE' => $LErrorCode,
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 				elseif ($CurrentErrorVar == 'L_SEVERITYCODE')
559 559
 					$CurrentVarName = 'Severity Code';
560 560
 
561
-				$error .= '<br />' . $CurrentVarName . ': ' . $CurrentErrorVal;
561
+				$error .= '<br />'.$CurrentVarName.': '.$CurrentErrorVal;
562 562
 			}
563 563
 		}
564 564
 		return $error;
Please login to merge, or discard this patch.
core/admin/EE_Admin_Page.core.php 3 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
      * 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.
704 704
      *
705 705
      * @access protected
706
-     * @return void
706
+     * @return false|null
707 707
      */
708 708
     protected function _verify_routes()
709 709
     {
@@ -757,7 +757,7 @@  discard block
 block discarded – undo
757 757
      * this method simply verifies a given route and makes sure its an actual route available for the loaded page
758 758
      *
759 759
      * @param  string $route the route name we're verifying
760
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
760
+     * @return boolean  (bool|Exception)      we'll throw an exception if this isn't a valid route.
761 761
      */
762 762
     protected function _verify_route($route)
763 763
     {
@@ -3247,7 +3247,7 @@  discard block
 block discarded – undo
3247 3247
 
3248 3248
 
3249 3249
     /**
3250
-     * @return mixed
3250
+     * @return string[]
3251 3251
      */
3252 3252
     public function default_espresso_metaboxes()
3253 3253
     {
@@ -3267,7 +3267,7 @@  discard block
 block discarded – undo
3267 3267
 
3268 3268
 
3269 3269
     /**
3270
-     * @return mixed
3270
+     * @return string
3271 3271
      */
3272 3272
     public function wp_page_slug()
3273 3273
     {
Please login to merge, or discard this patch.
Indentation   +3305 added lines, -3305 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,2120 +28,2120 @@  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 classes do something specific
196
-        // before the parent constructor runs _page_setup().
197
-        if (method_exists($this, '_before_page_setup')) {
198
-            $this->_before_page_setup();
199
-        }
200
-        //set up page dependencies
201
-        $this->_page_setup();
202
-    }
203
-
204
-
205
-
206
-    /**
207
-     * _init_page_props
208
-     * Child classes use to set at least the following properties:
209
-     * $page_slug.
210
-     * $page_label.
211
-     *
212
-     * @abstract
213
-     * @access protected
214
-     * @return void
215
-     */
216
-    abstract protected function _init_page_props();
217
-
218
-
219
-
220
-    /**
221
-     * _ajax_hooks
222
-     * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
223
-     * Note: within the ajax callback methods.
224
-     *
225
-     * @abstract
226
-     * @access protected
227
-     * @return void
228
-     */
229
-    abstract protected function _ajax_hooks();
230
-
231
-
232
-
233
-    /**
234
-     * _define_page_props
235
-     * child classes define page properties in here.  Must include at least:
236
-     * $_admin_base_url = base_url for all admin pages
237
-     * $_admin_page_title = default admin_page_title for admin pages
238
-     * $_labels = array of default labels for various automatically generated elements:
239
-     *    array(
240
-     *        'buttons' => array(
241
-     *            'add' => __('label for add new button'),
242
-     *            'edit' => __('label for edit button'),
243
-     *            'delete' => __('label for delete button')
244
-     *            )
245
-     *        )
246
-     *
247
-     * @abstract
248
-     * @access protected
249
-     * @return void
250
-     */
251
-    abstract protected function _define_page_props();
252
-
253
-
254
-
255
-    /**
256
-     * _set_page_routes
257
-     * 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'
258
-     * route. Here's the format
259
-     * $this->_page_routes = array(
260
-     *        'default' => array(
261
-     *            'func' => '_default_method_handling_route',
262
-     *            'args' => array('array','of','args'),
263
-     *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
264
-     *            '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.
265
-     *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
266
-     *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
267
-     *        ),
268
-     *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
269
-     *        )
270
-     * )
271
-     *
272
-     * @abstract
273
-     * @access protected
274
-     * @return void
275
-     */
276
-    abstract protected function _set_page_routes();
277
-
278
-
279
-
280
-    /**
281
-     * _set_page_config
282
-     * 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.
283
-     * Format:
284
-     * $this->_page_config = array(
285
-     *        'default' => array(
286
-     *            'labels' => array(
287
-     *                'buttons' => array(
288
-     *                    'add' => __('label for adding item'),
289
-     *                    'edit' => __('label for editing item'),
290
-     *                    'delete' => __('label for deleting item')
291
-     *                ),
292
-     *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
293
-     *            ), //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
294
-     *            'nav' => array(
295
-     *                'label' => __('Label for Tab', 'event_espresso').
296
-     *                'url' => 'http://someurl', //automatically generated UNLESS you define
297
-     *                'css_class' => 'css-class', //automatically generated UNLESS you define
298
-     *                'order' => 10, //required to indicate tab position.
299
-     *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
300
-     *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
301
-     *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
302
-     *            '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
303
-     *            this flag to make sure the necessary js gets enqueued on page load.
304
-     *            '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.
305
-     *            '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
306
-     *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
307
-     *            'help_tabs' => array( //this is used for adding help tabs to a page
308
-     *                'tab_id' => array(
309
-     *                    'title' => 'tab_title',
310
-     *                    '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
311
-     *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
312
-     *                    '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
313
-     *                    ),
314
-     *                'tab2_id' => array(
315
-     *                    'title' => 'tab2 title',
316
-     *                    'filename' => 'file_name_2'
317
-     *                    'callback' => 'callback_method_for_content',
318
-     *                 ),
319
-     *            '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/
320
-     *            'help_tour' => array(
321
-     *                '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
322
-     *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
323
-     *            ),
324
-     *            '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
325
-     *            'require_nonce' to FALSE
326
-     *            )
327
-     * )
328
-     *
329
-     * @abstract
330
-     * @access protected
331
-     * @return void
332
-     */
333
-    abstract protected function _set_page_config();
334
-
335
-
336
-
337
-
338
-
339
-    /** end sample help_tour methods **/
340
-    /**
341
-     * _add_screen_options
342
-     * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
343
-     * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
344
-     *
345
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
346
-     *         see also WP_Screen object documents...
347
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
348
-     * @abstract
349
-     * @access protected
350
-     * @return void
351
-     */
352
-    abstract protected function _add_screen_options();
353
-
354
-
355
-
356
-    /**
357
-     * _add_feature_pointers
358
-     * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
359
-     * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
360
-     * Note: this is just a placeholder for now.  Implementation will come down the road
361
-     * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
362
-     *
363
-     * @link   http://eamann.com/tech/wordpress-portland/
364
-     * @abstract
365
-     * @access protected
366
-     * @return void
367
-     */
368
-    abstract protected function _add_feature_pointers();
369
-
370
-
371
-
372
-    /**
373
-     * load_scripts_styles
374
-     * 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
375
-     * 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)
376
-     *
377
-     * @abstract
378
-     * @access public
379
-     * @return void
380
-     */
381
-    abstract public function load_scripts_styles();
382
-
383
-
384
-
385
-    /**
386
-     * admin_init
387
-     * 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.
388
-     *
389
-     * @abstract
390
-     * @access public
391
-     * @return void
392
-     */
393
-    abstract public function admin_init();
394
-
395
-
396
-
397
-    /**
398
-     * admin_notices
399
-     * 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.
400
-     *
401
-     * @abstract
402
-     * @access public
403
-     * @return void
404
-     */
405
-    abstract public function admin_notices();
406
-
407
-
408
-
409
-    /**
410
-     * admin_footer_scripts
411
-     * 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.
412
-     *
413
-     * @access public
414
-     * @return void
415
-     */
416
-    abstract public function admin_footer_scripts();
417
-
418
-
419
-
420
-    /**
421
-     * admin_footer
422
-     * 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.
423
-     *
424
-     * @access  public
425
-     * @return void
426
-     */
427
-    public function admin_footer()
428
-    {
429
-    }
430
-
431
-
432
-
433
-    /**
434
-     * _global_ajax_hooks
435
-     * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
436
-     * Note: within the ajax callback methods.
437
-     *
438
-     * @abstract
439
-     * @access protected
440
-     * @return void
441
-     */
442
-    protected function _global_ajax_hooks()
443
-    {
444
-        //for lazy loading of metabox content
445
-        add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
446
-    }
447
-
448
-
449
-
450
-    public function ajax_metabox_content()
451
-    {
452
-        $contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
453
-        $url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
454
-        self::cached_rss_display($contentid, $url);
455
-        wp_die();
456
-    }
457
-
458
-
459
-
460
-    /**
461
-     * _page_setup
462
-     * 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.
463
-     *
464
-     * @final
465
-     * @access protected
466
-     * @return void
467
-     */
468
-    final protected function _page_setup()
469
-    {
470
-        //requires?
471
-        //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.
472
-        add_action('admin_init', array($this, 'admin_init_global'), 5);
473
-        //next verify if we need to load anything...
474
-        $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
475
-        $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
476
-        global $ee_menu_slugs;
477
-        $ee_menu_slugs = (array)$ee_menu_slugs;
478
-        if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
479
-            return;
480
-        }
481
-        // 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
482
-        if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
483
-            $this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
484
-        }
485
-        // then set blank or -1 action values to 'default'
486
-        $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';
487
-        //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.
488
-        $this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
489
-        //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
490
-        $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
491
-        $this->_current_view = $this->_req_action;
492
-        $this->_req_nonce = $this->_req_action . '_nonce';
493
-        $this->_define_page_props();
494
-        $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
495
-        //default things
496
-        $this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
497
-        //set page configs
498
-        $this->_set_page_routes();
499
-        $this->_set_page_config();
500
-        //let's include any referrer data in our default_query_args for this route for "stickiness".
501
-        if (isset($this->_req_data['wp_referer'])) {
502
-            $this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
503
-        }
504
-        //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
505
-        if (method_exists($this, '_extend_page_config')) {
506
-            $this->_extend_page_config();
507
-        }
508
-        //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.
509
-        if (method_exists($this, '_extend_page_config_for_cpt')) {
510
-            $this->_extend_page_config_for_cpt();
511
-        }
512
-        //filter routes and page_config so addons can add their stuff. Filtering done per class
513
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
514
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
515
-        //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
516
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
517
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
518
-        }
519
-        //next route only if routing enabled
520
-        if ($this->_routing && ! defined('DOING_AJAX')) {
521
-            $this->_verify_routes();
522
-            //next let's just check user_access and kill if no access
523
-            $this->check_user_access();
524
-            if ($this->_is_UI_request) {
525
-                //admin_init stuff - global, all views for this page class, specific view
526
-                add_action('admin_init', array($this, 'admin_init'), 10);
527
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
528
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
529
-                }
530
-            } else {
531
-                //hijack regular WP loading and route admin request immediately
532
-                @ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
533
-                $this->route_admin_request();
534
-            }
535
-        }
536
-    }
537
-
538
-
539
-
540
-    /**
541
-     * Provides a way for related child admin pages to load stuff on the loaded admin page.
542
-     *
543
-     * @access private
544
-     * @return void
545
-     */
546
-    private function _do_other_page_hooks()
547
-    {
548
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
549
-        foreach ($registered_pages as $page) {
550
-            //now let's setup the file name and class that should be present
551
-            $classname = str_replace('.class.php', '', $page);
552
-            //autoloaders should take care of loading file
553
-            if ( ! class_exists($classname)) {
554
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
555
-                $error_msg[] = $error_msg[0]
556
-                               . "\r\n"
557
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
558
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
559
-                throw new EE_Error(implode('||', $error_msg));
560
-            }
561
-            $a = new ReflectionClass($classname);
562
-            //notice we are passing the instance of this class to the hook object.
563
-            $hookobj[] = $a->newInstance($this);
564
-        }
565
-    }
566
-
567
-
568
-
569
-    public function load_page_dependencies()
570
-    {
571
-        try {
572
-            $this->_load_page_dependencies();
573
-        } catch (EE_Error $e) {
574
-            $e->get_error();
575
-        }
576
-    }
577
-
578
-
579
-
580
-    /**
581
-     * load_page_dependencies
582
-     * loads things specific to this page class when its loaded.  Really helps with efficiency.
583
-     *
584
-     * @access public
585
-     * @return void
586
-     */
587
-    protected function _load_page_dependencies()
588
-    {
589
-        //let's set the current_screen and screen options to override what WP set
590
-        $this->_current_screen = get_current_screen();
591
-        //load admin_notices - global, page class, and view specific
592
-        add_action('admin_notices', array($this, 'admin_notices_global'), 5);
593
-        add_action('admin_notices', array($this, 'admin_notices'), 10);
594
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
595
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
596
-        }
597
-        //load network admin_notices - global, page class, and view specific
598
-        add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
599
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
600
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
601
-        }
602
-        //this will save any per_page screen options if they are present
603
-        $this->_set_per_page_screen_options();
604
-        //setup list table properties
605
-        $this->_set_list_table();
606
-        // 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.
607
-        $this->_add_registered_meta_boxes();
608
-        $this->_add_screen_columns();
609
-        //add screen options - global, page child class, and view specific
610
-        $this->_add_global_screen_options();
611
-        $this->_add_screen_options();
612
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
613
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
614
-        }
615
-        //add help tab(s) and tours- set via page_config and qtips.
616
-        $this->_add_help_tour();
617
-        $this->_add_help_tabs();
618
-        $this->_add_qtips();
619
-        //add feature_pointers - global, page child class, and view specific
620
-        $this->_add_feature_pointers();
621
-        $this->_add_global_feature_pointers();
622
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
623
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
624
-        }
625
-        //enqueue scripts/styles - global, page class, and view specific
626
-        add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
627
-        add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
628
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
629
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
630
-        }
631
-        add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
632
-        //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
633
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
634
-        add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
635
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
636
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
637
-        }
638
-        //admin footer scripts
639
-        add_action('admin_footer', array($this, 'admin_footer_global'), 99);
640
-        add_action('admin_footer', array($this, 'admin_footer'), 100);
641
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
642
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
643
-        }
644
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
645
-        //targeted hook
646
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
647
-    }
648
-
649
-
650
-
651
-    /**
652
-     * _set_defaults
653
-     * This sets some global defaults for class properties.
654
-     */
655
-    private function _set_defaults()
656
-    {
657
-        $this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
658
-        $this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
659
-        $this->default_nav_tab_name = 'overview';
660
-        //init template args
661
-        $this->_template_args = array(
662
-                'admin_page_header'  => '',
663
-                'admin_page_content' => '',
664
-                'post_body_content'  => '',
665
-                'before_list_table'  => '',
666
-                'after_list_table'   => '',
667
-        );
668
-    }
669
-
670
-
671
-
672
-    /**
673
-     * route_admin_request
674
-     *
675
-     * @see    _route_admin_request()
676
-     * @access public
677
-     * @return void|exception error
678
-     */
679
-    public function route_admin_request()
680
-    {
681
-        try {
682
-            $this->_route_admin_request();
683
-        } catch (EE_Error $e) {
684
-            $e->get_error();
685
-        }
686
-    }
687
-
688
-
689
-
690
-    public function set_wp_page_slug($wp_page_slug)
691
-    {
692
-        $this->_wp_page_slug = $wp_page_slug;
693
-        //if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
694
-        if (is_network_admin()) {
695
-            $this->_wp_page_slug .= '-network';
696
-        }
697
-    }
698
-
699
-
700
-
701
-    /**
702
-     * _verify_routes
703
-     * 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.
704
-     *
705
-     * @access protected
706
-     * @return void
707
-     */
708
-    protected function _verify_routes()
709
-    {
710
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
711
-        if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
712
-            return false;
713
-        }
714
-        $this->_route = false;
715
-        $func = false;
716
-        $args = array();
717
-        // check that the page_routes array is not empty
718
-        if (empty($this->_page_routes)) {
719
-            // user error msg
720
-            $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
721
-            // developer error msg
722
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
723
-            throw new EE_Error($error_msg);
724
-        }
725
-        // and that the requested page route exists
726
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
727
-            $this->_route = $this->_page_routes[$this->_req_action];
728
-            $this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
729
-        } else {
730
-            // user error msg
731
-            $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
732
-            // developer error msg
733
-            $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);
734
-            throw new EE_Error($error_msg);
735
-        }
736
-        // and that a default route exists
737
-        if ( ! array_key_exists('default', $this->_page_routes)) {
738
-            // user error msg
739
-            $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
740
-            // developer error msg
741
-            $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');
742
-            throw new EE_Error($error_msg);
743
-        }
744
-        //first lets' catch if the UI request has EVER been set.
745
-        if ($this->_is_UI_request === null) {
746
-            //lets set if this is a UI request or not.
747
-            $this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
748
-            //wait a minute... we might have a noheader in the route array
749
-            $this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
750
-        }
751
-        $this->_set_current_labels();
752
-    }
753
-
754
-
755
-
756
-    /**
757
-     * this method simply verifies a given route and makes sure its an actual route available for the loaded page
758
-     *
759
-     * @param  string $route the route name we're verifying
760
-     * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
761
-     */
762
-    protected function _verify_route($route)
763
-    {
764
-        if (array_key_exists($this->_req_action, $this->_page_routes)) {
765
-            return true;
766
-        } else {
767
-            // user error msg
768
-            $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
769
-            // developer error msg
770
-            $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);
771
-            throw new EE_Error($error_msg);
772
-        }
773
-    }
774
-
775
-
776
-
777
-    /**
778
-     * perform nonce verification
779
-     * 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!)
780
-     *
781
-     * @param  string $nonce     The nonce sent
782
-     * @param  string $nonce_ref The nonce reference string (name0)
783
-     * @return mixed (bool|die)
784
-     */
785
-    protected function _verify_nonce($nonce, $nonce_ref)
786
-    {
787
-        // verify nonce against expected value
788
-        if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
789
-            // these are not the droids you are looking for !!!
790
-            $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
791
-            if (WP_DEBUG) {
792
-                $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__);
793
-            }
794
-            if ( ! defined('DOING_AJAX')) {
795
-                wp_die($msg);
796
-            } else {
797
-                EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
798
-                $this->_return_json();
799
-            }
800
-        }
801
-    }
802
-
803
-
804
-
805
-    /**
806
-     * _route_admin_request()
807
-     * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
808
-     * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
809
-     * in the page routes and then will try to load the corresponding method.
810
-     *
811
-     * @access protected
812
-     * @return void
813
-     * @throws \EE_Error
814
-     */
815
-    protected function _route_admin_request()
816
-    {
817
-        if ( ! $this->_is_UI_request) {
818
-            $this->_verify_routes();
819
-        }
820
-        $nonce_check = isset($this->_route_config['require_nonce'])
821
-            ? $this->_route_config['require_nonce']
822
-            : true;
823
-        if ($this->_req_action !== 'default' && $nonce_check) {
824
-            // set nonce from post data
825
-            $nonce = isset($this->_req_data[$this->_req_nonce])
826
-                ? sanitize_text_field($this->_req_data[$this->_req_nonce])
827
-                : '';
828
-            $this->_verify_nonce($nonce, $this->_req_nonce);
829
-        }
830
-        //set the nav_tabs array but ONLY if this is  UI_request
831
-        if ($this->_is_UI_request) {
832
-            $this->_set_nav_tabs();
833
-        }
834
-        // grab callback function
835
-        $func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
836
-        // check if callback has args
837
-        $args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
838
-        $error_msg = '';
839
-        // action right before calling route
840
-        // (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
841
-        if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
842
-            do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
843
-        }
844
-        // right before calling the route, let's remove _wp_http_referer from the
845
-        // $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
846
-        $_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
847
-        if ( ! empty($func)) {
848
-            if (is_array($func)) {
849
-                list($class, $method) = $func;
850
-            } else if (strpos($func, '::') !== false) {
851
-                list($class, $method) = explode('::', $func);
852
-            } else {
853
-                $class = $this;
854
-                $method = $func;
855
-            }
856
-            if ( ! (is_object($class) && $class === $this)) {
857
-                // send along this admin page object for access by addons.
858
-                $args['admin_page_object'] = $this;
859
-            }
860
-
861
-            if (
862
-                //is it a method on a class that doesn't work?
863
-                (
864
-                    (
865
-                        method_exists($class, $method)
866
-                        && call_user_func_array(array($class, $method), $args) === false
867
-                    )
868
-                    && (
869
-                        //is it a standalone function that doesn't work?
870
-                        function_exists($method)
871
-                        && call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
872
-                    )
873
-                )
874
-                || (
875
-                    //is it neither a class method NOR a standalone function?
876
-                    ! method_exists($class, $method)
877
-                    && ! function_exists($method)
878
-                )
879
-            ) {
880
-                // user error msg
881
-                $error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
882
-                // developer error msg
883
-                $error_msg .= '||';
884
-                $error_msg .= sprintf(
885
-                    __(
886
-                        'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
887
-                        'event_espresso'
888
-                    ),
889
-                    $method
890
-                );
891
-            }
892
-            if ( ! empty($error_msg)) {
893
-                throw new EE_Error($error_msg);
894
-            }
895
-        }
896
-        //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.
897
-        //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.
898
-        if ($this->_is_UI_request === false
899
-            && is_array($this->_route)
900
-            && ! empty($this->_route['headers_sent_route'])
901
-        ) {
902
-            $this->_reset_routing_properties($this->_route['headers_sent_route']);
903
-        }
904
-    }
905
-
906
-
907
-
908
-    /**
909
-     * This method just allows the resetting of page properties in the case where a no headers
910
-     * route redirects to a headers route in its route config.
911
-     *
912
-     * @since   4.3.0
913
-     * @param  string $new_route New (non header) route to redirect to.
914
-     * @return   void
915
-     */
916
-    protected function _reset_routing_properties($new_route)
917
-    {
918
-        $this->_is_UI_request = true;
919
-        //now we set the current route to whatever the headers_sent_route is set at
920
-        $this->_req_data['action'] = $new_route;
921
-        //rerun page setup
922
-        $this->_page_setup();
923
-    }
924
-
925
-
926
-
927
-    /**
928
-     * _add_query_arg
929
-     * adds nonce to array of arguments then calls WP add_query_arg function
930
-     *(internally just uses EEH_URL's function with the same name)
931
-     *
932
-     * @access public
933
-     * @param array  $args
934
-     * @param string $url
935
-     * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
936
-     *                                        url in an associative array indexed by the key 'wp_referer';
937
-     *                                        Example usage:
938
-     *                                        If the current page is:
939
-     *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
940
-     *                                        &action=default&event_id=20&month_range=March%202015
941
-     *                                        &_wpnonce=5467821
942
-     *                                        and you call:
943
-     *                                        EE_Admin_Page::add_query_args_and_nonce(
944
-     *                                        array(
945
-     *                                        'action' => 'resend_something',
946
-     *                                        'page=>espresso_registrations'
947
-     *                                        ),
948
-     *                                        $some_url,
949
-     *                                        true
950
-     *                                        );
951
-     *                                        It will produce a url in this structure:
952
-     *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
953
-     *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
954
-     *                                        month_range]=March%202015
955
-     * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
956
-     * @return string
957
-     */
958
-    public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
959
-    {
960
-        //if there is a _wp_http_referer include the values from the request but only if sticky = true
961
-        if ($sticky) {
962
-            $request = $_REQUEST;
963
-            unset($request['_wp_http_referer']);
964
-            unset($request['wp_referer']);
965
-            foreach ($request as $key => $value) {
966
-                //do not add nonces
967
-                if (strpos($key, 'nonce') !== false) {
968
-                    continue;
969
-                }
970
-                $args['wp_referer[' . $key . ']'] = $value;
971
-            }
972
-        }
973
-        return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
974
-    }
975
-
976
-
977
-
978
-    /**
979
-     * This returns a generated link that will load the related help tab.
980
-     *
981
-     * @param  string $help_tab_id the id for the connected help tab
982
-     * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
983
-     * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
984
-     * @uses EEH_Template::get_help_tab_link()
985
-     * @return string              generated link
986
-     */
987
-    protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
988
-    {
989
-        return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
990
-    }
991
-
992
-
993
-
994
-    /**
995
-     * _add_help_tabs
996
-     * Note child classes define their help tabs within the page_config array.
997
-     *
998
-     * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
999
-     * @access protected
1000
-     * @return void
1001
-     */
1002
-    protected function _add_help_tabs()
1003
-    {
1004
-        $tour_buttons = '';
1005
-        if (isset($this->_page_config[$this->_req_action])) {
1006
-            $config = $this->_page_config[$this->_req_action];
1007
-            //is there a help tour for the current route?  if there is let's setup the tour buttons
1008
-            if (isset($this->_help_tour[$this->_req_action])) {
1009
-                $tb = array();
1010
-                $tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1011
-                foreach ($this->_help_tour['tours'] as $tour) {
1012
-                    //if this is the end tour then we don't need to setup a button
1013
-                    if ($tour instanceof EE_Help_Tour_final_stop) {
1014
-                        continue;
1015
-                    }
1016
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1017
-                }
1018
-                $tour_buttons .= implode('<br />', $tb);
1019
-                $tour_buttons .= '</div></div>';
1020
-            }
1021
-            // let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1022
-            if (is_array($config) && isset($config['help_sidebar'])) {
1023
-                //check that the callback given is valid
1024
-                if ( ! method_exists($this, $config['help_sidebar'])) {
1025
-                    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',
1026
-                            'event_espresso'), $config['help_sidebar'], get_class($this)));
1027
-                }
1028
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1029
-                $content .= $tour_buttons; //add help tour buttons.
1030
-                //do we have any help tours setup?  Cause if we do we want to add the buttons
1031
-                $this->_current_screen->set_help_sidebar($content);
1032
-            }
1033
-            //if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1034
-            if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1035
-                $this->_current_screen->set_help_sidebar($tour_buttons);
1036
-            }
1037
-            //handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1038
-            if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1039
-                $_ht['id'] = $this->page_slug;
1040
-                $_ht['title'] = __('Help Tours', 'event_espresso');
1041
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1042
-                $this->_current_screen->add_help_tab($_ht);
1043
-            }/**/
1044
-            if ( ! isset($config['help_tabs'])) {
1045
-                return;
1046
-            } //no help tabs for this route
1047
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1048
-                //we're here so there ARE help tabs!
1049
-                //make sure we've got what we need
1050
-                if ( ! isset($cfg['title'])) {
1051
-                    throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1052
-                }
1053
-                if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1054
-                    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',
1055
-                            'event_espresso'));
1056
-                }
1057
-                //first priority goes to content.
1058
-                if ( ! empty($cfg['content'])) {
1059
-                    $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1060
-                    //second priority goes to filename
1061
-                } else if ( ! empty($cfg['filename'])) {
1062
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1063
-                    //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)
1064
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1065
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1066
-                    if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1067
-                        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',
1068
-                                'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1069
-                        return;
1070
-                    }
1071
-                    $template_args['admin_page_obj'] = $this;
1072
-                    $content = EEH_Template::display_template($file_path, $template_args, true);
1073
-                } else {
1074
-                    $content = '';
1075
-                }
1076
-                //check if callback is valid
1077
-                if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1078
-                    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.',
1079
-                            'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1080
-                    return;
1081
-                }
1082
-                //setup config array for help tab method
1083
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1084
-                $_ht = array(
1085
-                        'id'       => $id,
1086
-                        'title'    => $cfg['title'],
1087
-                        'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1088
-                        'content'  => $content,
1089
-                );
1090
-                $this->_current_screen->add_help_tab($_ht);
1091
-            }
1092
-        }
1093
-    }
1094
-
1095
-
1096
-
1097
-    /**
1098
-     * 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
1099
-     *
1100
-     * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1101
-     * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1102
-     * @access protected
1103
-     * @return void
1104
-     */
1105
-    protected function _add_help_tour()
1106
-    {
1107
-        $tours = array();
1108
-        $this->_help_tour = array();
1109
-        //exit early if help tours are turned off globally
1110
-        if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1111
-            return;
1112
-        }
1113
-        //loop through _page_config to find any help_tour defined
1114
-        foreach ($this->_page_config as $route => $config) {
1115
-            //we're only going to set things up for this route
1116
-            if ($route !== $this->_req_action) {
1117
-                continue;
1118
-            }
1119
-            if (isset($config['help_tour'])) {
1120
-                foreach ($config['help_tour'] as $tour) {
1121
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1122
-                    //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
1123
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1124
-                    //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1125
-                    if ( ! is_readable($file_path)) {
1126
-                        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'),
1127
-                                $file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1128
-                        return;
1129
-                    }
1130
-                    require_once $file_path;
1131
-                    if ( ! class_exists($tour)) {
1132
-                        $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1133
-                        $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.',
1134
-                                        'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1135
-                        throw new EE_Error(implode('||', $error_msg));
1136
-                    }
1137
-                    $a = new ReflectionClass($tour);
1138
-                    $tour_obj = $a->newInstance($this->_is_caf);
1139
-                    $tours[] = $tour_obj;
1140
-                    $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1141
-                }
1142
-                //let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1143
-                $end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1144
-                $tours[] = $end_stop_tour;
1145
-                $this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1146
-            }
1147
-        }
1148
-        if ( ! empty($tours)) {
1149
-            $this->_help_tour['tours'] = $tours;
1150
-        }
1151
-        //thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1152
-    }
1153
-
1154
-
1155
-
1156
-    /**
1157
-     * This simply sets up any qtips that have been defined in the page config
1158
-     *
1159
-     * @access protected
1160
-     * @return void
1161
-     */
1162
-    protected function _add_qtips()
1163
-    {
1164
-        if (isset($this->_route_config['qtips'])) {
1165
-            $qtips = (array)$this->_route_config['qtips'];
1166
-            //load qtip loader
1167
-            $path = array(
1168
-                    $this->_get_dir() . '/qtips/',
1169
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1170
-            );
1171
-            EEH_Qtip_Loader::instance()->register($qtips, $path);
1172
-        }
1173
-    }
1174
-
1175
-
1176
-
1177
-    /**
1178
-     * _set_nav_tabs
1179
-     * 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.
1180
-     *
1181
-     * @access protected
1182
-     * @return void
1183
-     */
1184
-    protected function _set_nav_tabs()
1185
-    {
1186
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1187
-        $i = 0;
1188
-        foreach ($this->_page_config as $slug => $config) {
1189
-            if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1190
-                continue;
1191
-            } //no nav tab for this config
1192
-            //check for persistent flag
1193
-            if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1194
-                continue;
1195
-            } //nav tab is only to appear when route requested.
1196
-            if ( ! $this->check_user_access($slug, true)) {
1197
-                continue;
1198
-            } //no nav tab becasue current user does not have access.
1199
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1200
-            $this->_nav_tabs[$slug] = array(
1201
-                    'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1202
-                    'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1203
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1204
-                    'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1205
-            );
1206
-            $i++;
1207
-        }
1208
-        //if $this->_nav_tabs is empty then lets set the default
1209
-        if (empty($this->_nav_tabs)) {
1210
-            $this->_nav_tabs[$this->default_nav_tab_name] = array(
1211
-                    'url'       => $this->admin_base_url,
1212
-                    'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1213
-                    'css_class' => 'nav-tab-active',
1214
-                    'order'     => 10,
1215
-            );
1216
-        }
1217
-        //now let's sort the tabs according to order
1218
-        usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1219
-    }
1220
-
1221
-
1222
-
1223
-    /**
1224
-     * _set_current_labels
1225
-     * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1226
-     *
1227
-     * @access private
1228
-     * @return void
1229
-     */
1230
-    private function _set_current_labels()
1231
-    {
1232
-        if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1233
-            foreach ($this->_route_config['labels'] as $label => $text) {
1234
-                if (is_array($text)) {
1235
-                    foreach ($text as $sublabel => $subtext) {
1236
-                        $this->_labels[$label][$sublabel] = $subtext;
1237
-                    }
1238
-                } else {
1239
-                    $this->_labels[$label] = $text;
1240
-                }
1241
-            }
1242
-        }
1243
-    }
1244
-
1245
-
1246
-
1247
-    /**
1248
-     *        verifies user access for this admin page
1249
-     *
1250
-     * @param string $route_to_check if present then the capability for the route matching this string is checked.
1251
-     * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1252
-     * @return        BOOL|wp_die()
1253
-     */
1254
-    public function check_user_access($route_to_check = '', $verify_only = false)
1255
-    {
1256
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1257
-        $route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1258
-        $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'])
1259
-                ? $this->_page_routes[$route_to_check]['capability'] : null;
1260
-        if (empty($capability) && empty($route_to_check)) {
1261
-            $capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1262
-        } else {
1263
-            $capability = empty($capability) ? 'manage_options' : $capability;
1264
-        }
1265
-        $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1266
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1267
-            if ($verify_only) {
1268
-                return false;
1269
-            } else {
1270
-                if ( is_user_logged_in() ) {
1271
-                    wp_die(__('You do not have access to this route.', 'event_espresso'));
1272
-                } else {
1273
-                    return false;
1274
-                }
1275
-            }
1276
-        }
1277
-        return true;
1278
-    }
1279
-
1280
-
1281
-
1282
-    /**
1283
-     * admin_init_global
1284
-     * This runs all the code that we want executed within the WP admin_init hook.
1285
-     * This method executes for ALL EE Admin pages.
1286
-     *
1287
-     * @access public
1288
-     * @return void
1289
-     */
1290
-    public function admin_init_global()
1291
-    {
1292
-    }
1293
-
1294
-
1295
-
1296
-    /**
1297
-     * wp_loaded_global
1298
-     * 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
1299
-     *
1300
-     * @access public
1301
-     * @return void
1302
-     */
1303
-    public function wp_loaded()
1304
-    {
1305
-    }
1306
-
1307
-
1308
-
1309
-    /**
1310
-     * admin_notices
1311
-     * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1312
-     *
1313
-     * @access public
1314
-     * @return void
1315
-     */
1316
-    public function admin_notices_global()
1317
-    {
1318
-        $this->_display_no_javascript_warning();
1319
-        $this->_display_espresso_notices();
1320
-    }
1321
-
1322
-
1323
-
1324
-    public function network_admin_notices_global()
1325
-    {
1326
-        $this->_display_no_javascript_warning();
1327
-        $this->_display_espresso_notices();
1328
-    }
1329
-
1330
-
1331
-
1332
-    /**
1333
-     * admin_footer_scripts_global
1334
-     * 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.
1335
-     *
1336
-     * @access public
1337
-     * @return void
1338
-     */
1339
-    public function admin_footer_scripts_global()
1340
-    {
1341
-        $this->_add_admin_page_ajax_loading_img();
1342
-        $this->_add_admin_page_overlay();
1343
-        //if metaboxes are present we need to add the nonce field
1344
-        if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1345
-            wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1346
-            wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1347
-        }
1348
-    }
1349
-
1350
-
1351
-
1352
-    /**
1353
-     * admin_footer_global
1354
-     * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1355
-     *
1356
-     * @access  public
1357
-     * @return  void
1358
-     */
1359
-    public function admin_footer_global()
1360
-    {
1361
-        //dialog container for dialog helper
1362
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1363
-        $d_cont .= '<div class="ee-notices"></div>';
1364
-        $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1365
-        $d_cont .= '</div>';
1366
-        echo $d_cont;
1367
-        //help tour stuff?
1368
-        if (isset($this->_help_tour[$this->_req_action])) {
1369
-            echo implode('<br />', $this->_help_tour[$this->_req_action]);
1370
-        }
1371
-        //current set timezone for timezone js
1372
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1373
-    }
1374
-
1375
-
1376
-
1377
-    /**
1378
-     * 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.
1379
-     * For child classes:
1380
-     * 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
1381
-     * 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
1382
-     * '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(
1383
-     *    'help_trigger_id' => array(
1384
-     *        'title' => __('localized title for popup', 'event_espresso'),
1385
-     *        'content' => __('localized content for popup', 'event_espresso')
1386
-     *    )
1387
-     * );
1388
-     * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1389
-     *
1390
-     * @access protected
1391
-     * @return string content
1392
-     */
1393
-    protected function _set_help_popup_content($help_array = array(), $display = false)
1394
-    {
1395
-        $content = '';
1396
-        $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1397
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1398
-        //loop through the array and setup content
1399
-        foreach ($help_array as $trigger => $help) {
1400
-            //make sure the array is setup properly
1401
-            if ( ! isset($help['title']) || ! isset($help['content'])) {
1402
-                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',
1403
-                        'event_espresso'));
1404
-            }
1405
-            //we're good so let'd setup the template vars and then assign parsed template content to our content.
1406
-            $template_args = array(
1407
-                    'help_popup_id'      => $trigger,
1408
-                    'help_popup_title'   => $help['title'],
1409
-                    'help_popup_content' => $help['content'],
1410
-            );
1411
-            $content .= EEH_Template::display_template($template_path, $template_args, true);
1412
-        }
1413
-        if ($display) {
1414
-            echo $content;
1415
-        } else {
1416
-            return $content;
1417
-        }
1418
-    }
1419
-
1420
-
1421
-
1422
-    /**
1423
-     * All this does is retrive the help content array if set by the EE_Admin_Page child
1424
-     *
1425
-     * @access private
1426
-     * @return array properly formatted array for help popup content
1427
-     */
1428
-    private function _get_help_content()
1429
-    {
1430
-        //what is the method we're looking for?
1431
-        $method_name = '_help_popup_content_' . $this->_req_action;
1432
-        //if method doesn't exist let's get out.
1433
-        if ( ! method_exists($this, $method_name)) {
1434
-            return array();
1435
-        }
1436
-        //k we're good to go let's retrieve the help array
1437
-        $help_array = call_user_func(array($this, $method_name));
1438
-        //make sure we've got an array!
1439
-        if ( ! is_array($help_array)) {
1440
-            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'));
1441
-        }
1442
-        return $help_array;
1443
-    }
1444
-
1445
-
1446
-
1447
-    /**
1448
-     * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1449
-     * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1450
-     * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1451
-     *
1452
-     * @access protected
1453
-     * @param string  $trigger_id reference for retrieving the trigger content for the popup
1454
-     * @param boolean $display    if false then we return the trigger string
1455
-     * @param array   $dimensions an array of dimensions for the box (array(h,w))
1456
-     * @return string
1457
-     */
1458
-    protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1459
-    {
1460
-        if (defined('DOING_AJAX')) {
1461
-            return;
1462
-        }
1463
-        //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
1464
-        $help_array = $this->_get_help_content();
1465
-        $help_content = '';
1466
-        if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1467
-            $help_array[$trigger_id] = array(
1468
-                    'title'   => __('Missing Content', 'event_espresso'),
1469
-                    '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.)',
1470
-                            'event_espresso'),
1471
-            );
1472
-            $help_content = $this->_set_help_popup_content($help_array, false);
1473
-        }
1474
-        //let's setup the trigger
1475
-        $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>';
1476
-        $content = $content . $help_content;
1477
-        if ($display) {
1478
-            echo $content;
1479
-        } else {
1480
-            return $content;
1481
-        }
1482
-    }
1483
-
1484
-
1485
-
1486
-    /**
1487
-     * _add_global_screen_options
1488
-     * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1489
-     * This particular method will add_screen_options on ALL EE_Admin Pages
1490
-     *
1491
-     * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1492
-     *         see also WP_Screen object documents...
1493
-     * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1494
-     * @abstract
1495
-     * @access private
1496
-     * @return void
1497
-     */
1498
-    private function _add_global_screen_options()
1499
-    {
1500
-    }
1501
-
1502
-
1503
-
1504
-    /**
1505
-     * _add_global_feature_pointers
1506
-     * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1507
-     * This particular method will implement feature pointers for ALL EE_Admin pages.
1508
-     * Note: this is just a placeholder for now.  Implementation will come down the road
1509
-     *
1510
-     * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1511
-     * @link   http://eamann.com/tech/wordpress-portland/
1512
-     * @abstract
1513
-     * @access protected
1514
-     * @return void
1515
-     */
1516
-    private function _add_global_feature_pointers()
1517
-    {
1518
-    }
1519
-
1520
-
1521
-
1522
-    /**
1523
-     * load_global_scripts_styles
1524
-     * The scripts and styles enqueued in here will be loaded on every EE Admin page
1525
-     *
1526
-     * @return void
1527
-     */
1528
-    public function load_global_scripts_styles()
1529
-    {
1530
-        /** STYLES **/
1531
-        // add debugging styles
1532
-        if (WP_DEBUG) {
1533
-            add_action('admin_head', array($this, 'add_xdebug_style'));
1534
-        }
1535
-        //register all styles
1536
-        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);
1537
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1538
-        //helpers styles
1539
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1540
-        //enqueue global styles
1541
-        wp_enqueue_style('ee-admin-css');
1542
-        /** SCRIPTS **/
1543
-        //register all scripts
1544
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1545
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1546
-        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);
1547
-        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);
1548
-        // register jQuery Validate - see /includes/functions/wp_hooks.php
1549
-        add_filter('FHEE_load_jquery_validate', '__return_true');
1550
-        add_filter('FHEE_load_joyride', '__return_true');
1551
-        //script for sorting tables
1552
-        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);
1553
-        //script for parsing uri's
1554
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1555
-        //and parsing associative serialized form elements
1556
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1557
-        //helpers scripts
1558
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1559
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1560
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1561
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1562
-        //google charts
1563
-        wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1564
-        //enqueue global scripts
1565
-        //taking care of metaboxes
1566
-        if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1567
-            wp_enqueue_script('dashboard');
1568
-        }
1569
-        //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
1570
-        if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1571
-            wp_enqueue_script('ee_admin_js');
1572
-            wp_enqueue_style('ee-admin-css');
1573
-        }
1574
-        //localize script for ajax lazy loading
1575
-        $lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1576
-        wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1577
-        /**
1578
-         * help tour stuff
1579
-         */
1580
-        if ( ! empty($this->_help_tour)) {
1581
-            //register the js for kicking things off
1582
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1583
-            //setup tours for the js tour object
1584
-            foreach ($this->_help_tour['tours'] as $tour) {
1585
-                $tours[] = array(
1586
-                        'id'      => $tour->get_slug(),
1587
-                        'options' => $tour->get_options(),
1588
-                );
1589
-            }
1590
-            wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1591
-            //admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1592
-        }
1593
-    }
1594
-
1595
-
1596
-
1597
-    /**
1598
-     *        admin_footer_scripts_eei18n_js_strings
1599
-     *
1600
-     * @access        public
1601
-     * @return        void
1602
-     */
1603
-    public function admin_footer_scripts_eei18n_js_strings()
1604
-    {
1605
-        EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1606
-        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');
1607
-        EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1608
-        EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1609
-        EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1610
-        EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1611
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1612
-        EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1613
-        EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1614
-        EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1615
-        EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1616
-        EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1617
-        EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1618
-        EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1619
-        EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1620
-        EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1621
-        EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1622
-        EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1623
-        EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1624
-        EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1625
-        EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1626
-        EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1627
-        EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1628
-        EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1629
-        EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1630
-        EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1631
-        EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1632
-        EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1633
-        EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1634
-        EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1635
-        EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1636
-        EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1637
-        EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1638
-        EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1639
-        EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1640
-        EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1641
-        EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1642
-        EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1643
-        EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1644
-        EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1645
-        //setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1646
-        //admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1647
-        //espresso_core is listed as a dependency of ee_admin_js.
1648
-        wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1649
-    }
1650
-
1651
-
1652
-
1653
-    /**
1654
-     *        load enhanced xdebug styles for ppl with failing eyesight
1655
-     *
1656
-     * @access        public
1657
-     * @return        void
1658
-     */
1659
-    public function add_xdebug_style()
1660
-    {
1661
-        echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1662
-    }
1663
-
1664
-
1665
-    /************************/
1666
-    /** LIST TABLE METHODS **/
1667
-    /************************/
1668
-    /**
1669
-     * this sets up the list table if the current view requires it.
1670
-     *
1671
-     * @access protected
1672
-     * @return void
1673
-     */
1674
-    protected function _set_list_table()
1675
-    {
1676
-        //first is this a list_table view?
1677
-        if ( ! isset($this->_route_config['list_table'])) {
1678
-            return;
1679
-        } //not a list_table view so get out.
1680
-        //list table functions are per view specific (because some admin pages might have more than one listtable!)
1681
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1682
-            //user error msg
1683
-            $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1684
-            //developer error msg
1685
-            $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'),
1686
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1687
-            throw new EE_Error($error_msg);
1688
-        }
1689
-        //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1690
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1691
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1692
-        $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1693
-        $this->_set_list_table_view();
1694
-        $this->_set_list_table_object();
1695
-    }
1696
-
1697
-
1698
-
1699
-    /**
1700
-     *        set current view for List Table
1701
-     *
1702
-     * @access public
1703
-     * @return array
1704
-     */
1705
-    protected function _set_list_table_view()
1706
-    {
1707
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1708
-        // looking at active items or dumpster diving ?
1709
-        if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1710
-            $this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1711
-        } else {
1712
-            $this->_view = sanitize_key($this->_req_data['status']);
1713
-        }
1714
-    }
1715
-
1716
-
1717
-
1718
-    /**
1719
-     * _set_list_table_object
1720
-     * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1721
-     *
1722
-     * @throws \EE_Error
1723
-     */
1724
-    protected function _set_list_table_object()
1725
-    {
1726
-        if (isset($this->_route_config['list_table'])) {
1727
-            if ( ! class_exists($this->_route_config['list_table'])) {
1728
-                throw new EE_Error(
1729
-                        sprintf(
1730
-                                __(
1731
-                                        '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.',
1732
-                                        'event_espresso'
1733
-                                ),
1734
-                                $this->_route_config['list_table'],
1735
-                                get_class($this)
1736
-                        )
1737
-                );
1738
-            }
1739
-            $list_table = $this->_route_config['list_table'];
1740
-            $this->_list_table_object = new $list_table($this);
1741
-        }
1742
-    }
1743
-
1744
-
1745
-
1746
-    /**
1747
-     * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1748
-     *
1749
-     * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1750
-     *                                                    urls.  The array should be indexed by the view it is being
1751
-     *                                                    added to.
1752
-     * @return array
1753
-     */
1754
-    public function get_list_table_view_RLs($extra_query_args = array())
1755
-    {
1756
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1757
-        if (empty($this->_views)) {
1758
-            $this->_views = array();
1759
-        }
1760
-        // cycle thru views
1761
-        foreach ($this->_views as $key => $view) {
1762
-            $query_args = array();
1763
-            // check for current view
1764
-            $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1765
-            $query_args['action'] = $this->_req_action;
1766
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1767
-            $query_args['status'] = $view['slug'];
1768
-            //merge any other arguments sent in.
1769
-            if (isset($extra_query_args[$view['slug']])) {
1770
-                $query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1771
-            }
1772
-            $this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1773
-        }
1774
-        return $this->_views;
1775
-    }
1776
-
1777
-
1778
-
1779
-    /**
1780
-     * _entries_per_page_dropdown
1781
-     * generates a drop down box for selecting the number of visiable rows in an admin page list table
1782
-     *
1783
-     * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1784
-     * @access protected
1785
-     * @param int $max_entries total number of rows in the table
1786
-     * @return string
1787
-     */
1788
-    protected function _entries_per_page_dropdown($max_entries = false)
1789
-    {
1790
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1791
-        $values = array(10, 25, 50, 100);
1792
-        $per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1793
-        if ($max_entries) {
1794
-            $values[] = $max_entries;
1795
-            sort($values);
1796
-        }
1797
-        $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 classes do something specific
196
+		// before the parent constructor runs _page_setup().
197
+		if (method_exists($this, '_before_page_setup')) {
198
+			$this->_before_page_setup();
199
+		}
200
+		//set up page dependencies
201
+		$this->_page_setup();
202
+	}
203
+
204
+
205
+
206
+	/**
207
+	 * _init_page_props
208
+	 * Child classes use to set at least the following properties:
209
+	 * $page_slug.
210
+	 * $page_label.
211
+	 *
212
+	 * @abstract
213
+	 * @access protected
214
+	 * @return void
215
+	 */
216
+	abstract protected function _init_page_props();
217
+
218
+
219
+
220
+	/**
221
+	 * _ajax_hooks
222
+	 * child classes put all their add_action('wp_ajax_{name_of_hook}') hooks in here.
223
+	 * Note: within the ajax callback methods.
224
+	 *
225
+	 * @abstract
226
+	 * @access protected
227
+	 * @return void
228
+	 */
229
+	abstract protected function _ajax_hooks();
230
+
231
+
232
+
233
+	/**
234
+	 * _define_page_props
235
+	 * child classes define page properties in here.  Must include at least:
236
+	 * $_admin_base_url = base_url for all admin pages
237
+	 * $_admin_page_title = default admin_page_title for admin pages
238
+	 * $_labels = array of default labels for various automatically generated elements:
239
+	 *    array(
240
+	 *        'buttons' => array(
241
+	 *            'add' => __('label for add new button'),
242
+	 *            'edit' => __('label for edit button'),
243
+	 *            'delete' => __('label for delete button')
244
+	 *            )
245
+	 *        )
246
+	 *
247
+	 * @abstract
248
+	 * @access protected
249
+	 * @return void
250
+	 */
251
+	abstract protected function _define_page_props();
252
+
253
+
254
+
255
+	/**
256
+	 * _set_page_routes
257
+	 * 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'
258
+	 * route. Here's the format
259
+	 * $this->_page_routes = array(
260
+	 *        'default' => array(
261
+	 *            'func' => '_default_method_handling_route',
262
+	 *            'args' => array('array','of','args'),
263
+	 *            'noheader' => true, //add this in if this page route is processed before any headers are loaded (i.e. ajax request, backend processing)
264
+	 *            '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.
265
+	 *            'capability' => 'route_capability', //indicate a string for minimum capability required to access this route.
266
+	 *            'obj_id' => 10 // if this route has an object id, then this can include it (used for capability checks).
267
+	 *        ),
268
+	 *        'insert_item' => '_method_for_handling_insert_item' //this can be used if all we need to have is a handling method.
269
+	 *        )
270
+	 * )
271
+	 *
272
+	 * @abstract
273
+	 * @access protected
274
+	 * @return void
275
+	 */
276
+	abstract protected function _set_page_routes();
277
+
278
+
279
+
280
+	/**
281
+	 * _set_page_config
282
+	 * 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.
283
+	 * Format:
284
+	 * $this->_page_config = array(
285
+	 *        'default' => array(
286
+	 *            'labels' => array(
287
+	 *                'buttons' => array(
288
+	 *                    'add' => __('label for adding item'),
289
+	 *                    'edit' => __('label for editing item'),
290
+	 *                    'delete' => __('label for deleting item')
291
+	 *                ),
292
+	 *                'publishbox' => __('Localized Title for Publish metabox', 'event_espresso')
293
+	 *            ), //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
294
+	 *            'nav' => array(
295
+	 *                'label' => __('Label for Tab', 'event_espresso').
296
+	 *                'url' => 'http://someurl', //automatically generated UNLESS you define
297
+	 *                'css_class' => 'css-class', //automatically generated UNLESS you define
298
+	 *                'order' => 10, //required to indicate tab position.
299
+	 *                'persistent' => false //if you want the nav tab to ONLY display when the specific route is displayed then add this parameter.
300
+	 *            'list_table' => 'name_of_list_table' //string for list table class to be loaded for this admin_page.
301
+	 *            'metaboxes' => array('metabox1', 'metabox2'), //if present this key indicates we want to load metaboxes set for eventespresso admin pages.
302
+	 *            '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
303
+	 *            this flag to make sure the necessary js gets enqueued on page load.
304
+	 *            '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.
305
+	 *            '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
306
+	 *            in the "screen_options" dropdown that is setup so users can pick what columns they want to display.
307
+	 *            'help_tabs' => array( //this is used for adding help tabs to a page
308
+	 *                'tab_id' => array(
309
+	 *                    'title' => 'tab_title',
310
+	 *                    '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
311
+	 *                    folder's "help_tabs" dir (ie.. events/help_tabs/name_of_file_containing_content.help_tab.php)
312
+	 *                    '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
313
+	 *                    ),
314
+	 *                'tab2_id' => array(
315
+	 *                    'title' => 'tab2 title',
316
+	 *                    'filename' => 'file_name_2'
317
+	 *                    'callback' => 'callback_method_for_content',
318
+	 *                 ),
319
+	 *            '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/
320
+	 *            'help_tour' => array(
321
+	 *                '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
322
+	 *                (name_of_help_tour_class.class.php), and class matching key given here (name_of_help_tour_class)
323
+	 *            ),
324
+	 *            '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
325
+	 *            'require_nonce' to FALSE
326
+	 *            )
327
+	 * )
328
+	 *
329
+	 * @abstract
330
+	 * @access protected
331
+	 * @return void
332
+	 */
333
+	abstract protected function _set_page_config();
334
+
335
+
336
+
337
+
338
+
339
+	/** end sample help_tour methods **/
340
+	/**
341
+	 * _add_screen_options
342
+	 * Child classes can add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
343
+	 * Note child classes can also define _add_screen_options_($this->_current_view) to limit screen options to a particular view.
344
+	 *
345
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
346
+	 *         see also WP_Screen object documents...
347
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
348
+	 * @abstract
349
+	 * @access protected
350
+	 * @return void
351
+	 */
352
+	abstract protected function _add_screen_options();
353
+
354
+
355
+
356
+	/**
357
+	 * _add_feature_pointers
358
+	 * Child classes should use this method for implementing any "feature pointers" (using built-in WP styling js).
359
+	 * Note child classes can also define _add_feature_pointers_($this->_current_view) to limit screen options to a particular view.
360
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
361
+	 * See: WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
362
+	 *
363
+	 * @link   http://eamann.com/tech/wordpress-portland/
364
+	 * @abstract
365
+	 * @access protected
366
+	 * @return void
367
+	 */
368
+	abstract protected function _add_feature_pointers();
369
+
370
+
371
+
372
+	/**
373
+	 * load_scripts_styles
374
+	 * 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
375
+	 * 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)
376
+	 *
377
+	 * @abstract
378
+	 * @access public
379
+	 * @return void
380
+	 */
381
+	abstract public function load_scripts_styles();
382
+
383
+
384
+
385
+	/**
386
+	 * admin_init
387
+	 * 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.
388
+	 *
389
+	 * @abstract
390
+	 * @access public
391
+	 * @return void
392
+	 */
393
+	abstract public function admin_init();
394
+
395
+
396
+
397
+	/**
398
+	 * admin_notices
399
+	 * 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.
400
+	 *
401
+	 * @abstract
402
+	 * @access public
403
+	 * @return void
404
+	 */
405
+	abstract public function admin_notices();
406
+
407
+
408
+
409
+	/**
410
+	 * admin_footer_scripts
411
+	 * 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.
412
+	 *
413
+	 * @access public
414
+	 * @return void
415
+	 */
416
+	abstract public function admin_footer_scripts();
417
+
418
+
419
+
420
+	/**
421
+	 * admin_footer
422
+	 * 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.
423
+	 *
424
+	 * @access  public
425
+	 * @return void
426
+	 */
427
+	public function admin_footer()
428
+	{
429
+	}
430
+
431
+
432
+
433
+	/**
434
+	 * _global_ajax_hooks
435
+	 * all global add_action('wp_ajax_{name_of_hook}') hooks in here.
436
+	 * Note: within the ajax callback methods.
437
+	 *
438
+	 * @abstract
439
+	 * @access protected
440
+	 * @return void
441
+	 */
442
+	protected function _global_ajax_hooks()
443
+	{
444
+		//for lazy loading of metabox content
445
+		add_action('wp_ajax_espresso-ajax-content', array($this, 'ajax_metabox_content'), 10);
446
+	}
447
+
448
+
449
+
450
+	public function ajax_metabox_content()
451
+	{
452
+		$contentid = isset($this->_req_data['contentid']) ? $this->_req_data['contentid'] : '';
453
+		$url = isset($this->_req_data['contenturl']) ? $this->_req_data['contenturl'] : '';
454
+		self::cached_rss_display($contentid, $url);
455
+		wp_die();
456
+	}
457
+
458
+
459
+
460
+	/**
461
+	 * _page_setup
462
+	 * 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.
463
+	 *
464
+	 * @final
465
+	 * @access protected
466
+	 * @return void
467
+	 */
468
+	final protected function _page_setup()
469
+	{
470
+		//requires?
471
+		//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.
472
+		add_action('admin_init', array($this, 'admin_init_global'), 5);
473
+		//next verify if we need to load anything...
474
+		$this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
475
+		$this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
476
+		global $ee_menu_slugs;
477
+		$ee_menu_slugs = (array)$ee_menu_slugs;
478
+		if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
479
+			return;
480
+		}
481
+		// 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
482
+		if (isset($this->_req_data['action2']) && $this->_req_data['action'] == -1) {
483
+			$this->_req_data['action'] = ! empty($this->_req_data['action2']) && $this->_req_data['action2'] != -1 ? $this->_req_data['action2'] : $this->_req_data['action'];
484
+		}
485
+		// then set blank or -1 action values to 'default'
486
+		$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';
487
+		//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.
488
+		$this->_req_action = $this->_req_action === 'default' && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
489
+		//however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
490
+		$this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
491
+		$this->_current_view = $this->_req_action;
492
+		$this->_req_nonce = $this->_req_action . '_nonce';
493
+		$this->_define_page_props();
494
+		$this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
495
+		//default things
496
+		$this->_default_espresso_metaboxes = array('_espresso_news_post_box', '_espresso_links_post_box', '_espresso_ratings_request', '_espresso_sponsors_post_box');
497
+		//set page configs
498
+		$this->_set_page_routes();
499
+		$this->_set_page_config();
500
+		//let's include any referrer data in our default_query_args for this route for "stickiness".
501
+		if (isset($this->_req_data['wp_referer'])) {
502
+			$this->_default_route_query_args['wp_referer'] = $this->_req_data['wp_referer'];
503
+		}
504
+		//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
505
+		if (method_exists($this, '_extend_page_config')) {
506
+			$this->_extend_page_config();
507
+		}
508
+		//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.
509
+		if (method_exists($this, '_extend_page_config_for_cpt')) {
510
+			$this->_extend_page_config_for_cpt();
511
+		}
512
+		//filter routes and page_config so addons can add their stuff. Filtering done per class
513
+		$this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
514
+		$this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
515
+		//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
516
+		if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
517
+			add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
518
+		}
519
+		//next route only if routing enabled
520
+		if ($this->_routing && ! defined('DOING_AJAX')) {
521
+			$this->_verify_routes();
522
+			//next let's just check user_access and kill if no access
523
+			$this->check_user_access();
524
+			if ($this->_is_UI_request) {
525
+				//admin_init stuff - global, all views for this page class, specific view
526
+				add_action('admin_init', array($this, 'admin_init'), 10);
527
+				if (method_exists($this, 'admin_init_' . $this->_current_view)) {
528
+					add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
529
+				}
530
+			} else {
531
+				//hijack regular WP loading and route admin request immediately
532
+				@ini_set('memory_limit', apply_filters('admin_memory_limit', WP_MAX_MEMORY_LIMIT));
533
+				$this->route_admin_request();
534
+			}
535
+		}
536
+	}
537
+
538
+
539
+
540
+	/**
541
+	 * Provides a way for related child admin pages to load stuff on the loaded admin page.
542
+	 *
543
+	 * @access private
544
+	 * @return void
545
+	 */
546
+	private function _do_other_page_hooks()
547
+	{
548
+		$registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
549
+		foreach ($registered_pages as $page) {
550
+			//now let's setup the file name and class that should be present
551
+			$classname = str_replace('.class.php', '', $page);
552
+			//autoloaders should take care of loading file
553
+			if ( ! class_exists($classname)) {
554
+				$error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
555
+				$error_msg[] = $error_msg[0]
556
+							   . "\r\n"
557
+							   . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
558
+								'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
559
+				throw new EE_Error(implode('||', $error_msg));
560
+			}
561
+			$a = new ReflectionClass($classname);
562
+			//notice we are passing the instance of this class to the hook object.
563
+			$hookobj[] = $a->newInstance($this);
564
+		}
565
+	}
566
+
567
+
568
+
569
+	public function load_page_dependencies()
570
+	{
571
+		try {
572
+			$this->_load_page_dependencies();
573
+		} catch (EE_Error $e) {
574
+			$e->get_error();
575
+		}
576
+	}
577
+
578
+
579
+
580
+	/**
581
+	 * load_page_dependencies
582
+	 * loads things specific to this page class when its loaded.  Really helps with efficiency.
583
+	 *
584
+	 * @access public
585
+	 * @return void
586
+	 */
587
+	protected function _load_page_dependencies()
588
+	{
589
+		//let's set the current_screen and screen options to override what WP set
590
+		$this->_current_screen = get_current_screen();
591
+		//load admin_notices - global, page class, and view specific
592
+		add_action('admin_notices', array($this, 'admin_notices_global'), 5);
593
+		add_action('admin_notices', array($this, 'admin_notices'), 10);
594
+		if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
595
+			add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
596
+		}
597
+		//load network admin_notices - global, page class, and view specific
598
+		add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
599
+		if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
600
+			add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
601
+		}
602
+		//this will save any per_page screen options if they are present
603
+		$this->_set_per_page_screen_options();
604
+		//setup list table properties
605
+		$this->_set_list_table();
606
+		// 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.
607
+		$this->_add_registered_meta_boxes();
608
+		$this->_add_screen_columns();
609
+		//add screen options - global, page child class, and view specific
610
+		$this->_add_global_screen_options();
611
+		$this->_add_screen_options();
612
+		if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
613
+			call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
614
+		}
615
+		//add help tab(s) and tours- set via page_config and qtips.
616
+		$this->_add_help_tour();
617
+		$this->_add_help_tabs();
618
+		$this->_add_qtips();
619
+		//add feature_pointers - global, page child class, and view specific
620
+		$this->_add_feature_pointers();
621
+		$this->_add_global_feature_pointers();
622
+		if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
623
+			call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
624
+		}
625
+		//enqueue scripts/styles - global, page class, and view specific
626
+		add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
627
+		add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
628
+		if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
629
+			add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
630
+		}
631
+		add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
632
+		//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
633
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
634
+		add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
635
+		if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
636
+			add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
637
+		}
638
+		//admin footer scripts
639
+		add_action('admin_footer', array($this, 'admin_footer_global'), 99);
640
+		add_action('admin_footer', array($this, 'admin_footer'), 100);
641
+		if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
642
+			add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
643
+		}
644
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
645
+		//targeted hook
646
+		do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
647
+	}
648
+
649
+
650
+
651
+	/**
652
+	 * _set_defaults
653
+	 * This sets some global defaults for class properties.
654
+	 */
655
+	private function _set_defaults()
656
+	{
657
+		$this->_current_screen = $this->_admin_page_title = $this->_req_action = $this->_req_nonce = $this->_event = $this->_template_path = $this->_column_template_path = null;
658
+		$this->_nav_tabs = $this_views = $this->_page_routes = $this->_page_config = $this->_default_route_query_args = array();
659
+		$this->default_nav_tab_name = 'overview';
660
+		//init template args
661
+		$this->_template_args = array(
662
+				'admin_page_header'  => '',
663
+				'admin_page_content' => '',
664
+				'post_body_content'  => '',
665
+				'before_list_table'  => '',
666
+				'after_list_table'   => '',
667
+		);
668
+	}
669
+
670
+
671
+
672
+	/**
673
+	 * route_admin_request
674
+	 *
675
+	 * @see    _route_admin_request()
676
+	 * @access public
677
+	 * @return void|exception error
678
+	 */
679
+	public function route_admin_request()
680
+	{
681
+		try {
682
+			$this->_route_admin_request();
683
+		} catch (EE_Error $e) {
684
+			$e->get_error();
685
+		}
686
+	}
687
+
688
+
689
+
690
+	public function set_wp_page_slug($wp_page_slug)
691
+	{
692
+		$this->_wp_page_slug = $wp_page_slug;
693
+		//if in network admin then we need to append "-network" to the page slug. Why? Because that's how WP rolls...
694
+		if (is_network_admin()) {
695
+			$this->_wp_page_slug .= '-network';
696
+		}
697
+	}
698
+
699
+
700
+
701
+	/**
702
+	 * _verify_routes
703
+	 * 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.
704
+	 *
705
+	 * @access protected
706
+	 * @return void
707
+	 */
708
+	protected function _verify_routes()
709
+	{
710
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
711
+		if ( ! $this->_current_page && ! defined('DOING_AJAX')) {
712
+			return false;
713
+		}
714
+		$this->_route = false;
715
+		$func = false;
716
+		$args = array();
717
+		// check that the page_routes array is not empty
718
+		if (empty($this->_page_routes)) {
719
+			// user error msg
720
+			$error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
721
+			// developer error msg
722
+			$error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
723
+			throw new EE_Error($error_msg);
724
+		}
725
+		// and that the requested page route exists
726
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
727
+			$this->_route = $this->_page_routes[$this->_req_action];
728
+			$this->_route_config = isset($this->_page_config[$this->_req_action]) ? $this->_page_config[$this->_req_action] : array();
729
+		} else {
730
+			// user error msg
731
+			$error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
732
+			// developer error msg
733
+			$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);
734
+			throw new EE_Error($error_msg);
735
+		}
736
+		// and that a default route exists
737
+		if ( ! array_key_exists('default', $this->_page_routes)) {
738
+			// user error msg
739
+			$error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
740
+			// developer error msg
741
+			$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');
742
+			throw new EE_Error($error_msg);
743
+		}
744
+		//first lets' catch if the UI request has EVER been set.
745
+		if ($this->_is_UI_request === null) {
746
+			//lets set if this is a UI request or not.
747
+			$this->_is_UI_request = ( ! isset($this->_req_data['noheader']) || $this->_req_data['noheader'] !== true) ? true : false;
748
+			//wait a minute... we might have a noheader in the route array
749
+			$this->_is_UI_request = is_array($this->_route) && isset($this->_route['noheader']) && $this->_route['noheader'] ? false : $this->_is_UI_request;
750
+		}
751
+		$this->_set_current_labels();
752
+	}
753
+
754
+
755
+
756
+	/**
757
+	 * this method simply verifies a given route and makes sure its an actual route available for the loaded page
758
+	 *
759
+	 * @param  string $route the route name we're verifying
760
+	 * @return mixed  (bool|Exception)      we'll throw an exception if this isn't a valid route.
761
+	 */
762
+	protected function _verify_route($route)
763
+	{
764
+		if (array_key_exists($this->_req_action, $this->_page_routes)) {
765
+			return true;
766
+		} else {
767
+			// user error msg
768
+			$error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
769
+			// developer error msg
770
+			$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);
771
+			throw new EE_Error($error_msg);
772
+		}
773
+	}
774
+
775
+
776
+
777
+	/**
778
+	 * perform nonce verification
779
+	 * 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!)
780
+	 *
781
+	 * @param  string $nonce     The nonce sent
782
+	 * @param  string $nonce_ref The nonce reference string (name0)
783
+	 * @return mixed (bool|die)
784
+	 */
785
+	protected function _verify_nonce($nonce, $nonce_ref)
786
+	{
787
+		// verify nonce against expected value
788
+		if ( ! wp_verify_nonce($nonce, $nonce_ref)) {
789
+			// these are not the droids you are looking for !!!
790
+			$msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
791
+			if (WP_DEBUG) {
792
+				$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__);
793
+			}
794
+			if ( ! defined('DOING_AJAX')) {
795
+				wp_die($msg);
796
+			} else {
797
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
798
+				$this->_return_json();
799
+			}
800
+		}
801
+	}
802
+
803
+
804
+
805
+	/**
806
+	 * _route_admin_request()
807
+	 * Meat and potatoes of the class.  Basically, this dude checks out what's being requested and sees if theres are
808
+	 * some doodads to work the magic and handle the flingjangy. Translation:  Checks if the requested action is listed
809
+	 * in the page routes and then will try to load the corresponding method.
810
+	 *
811
+	 * @access protected
812
+	 * @return void
813
+	 * @throws \EE_Error
814
+	 */
815
+	protected function _route_admin_request()
816
+	{
817
+		if ( ! $this->_is_UI_request) {
818
+			$this->_verify_routes();
819
+		}
820
+		$nonce_check = isset($this->_route_config['require_nonce'])
821
+			? $this->_route_config['require_nonce']
822
+			: true;
823
+		if ($this->_req_action !== 'default' && $nonce_check) {
824
+			// set nonce from post data
825
+			$nonce = isset($this->_req_data[$this->_req_nonce])
826
+				? sanitize_text_field($this->_req_data[$this->_req_nonce])
827
+				: '';
828
+			$this->_verify_nonce($nonce, $this->_req_nonce);
829
+		}
830
+		//set the nav_tabs array but ONLY if this is  UI_request
831
+		if ($this->_is_UI_request) {
832
+			$this->_set_nav_tabs();
833
+		}
834
+		// grab callback function
835
+		$func = is_array($this->_route) ? $this->_route['func'] : $this->_route;
836
+		// check if callback has args
837
+		$args = is_array($this->_route) && isset($this->_route['args']) ? $this->_route['args'] : array();
838
+		$error_msg = '';
839
+		// action right before calling route
840
+		// (hook is something like 'AHEE__Registrations_Admin_Page__route_admin_request')
841
+		if ( ! did_action('AHEE__EE_Admin_Page__route_admin_request')) {
842
+			do_action('AHEE__EE_Admin_Page__route_admin_request', $this->_current_view, $this);
843
+		}
844
+		// right before calling the route, let's remove _wp_http_referer from the
845
+		// $_SERVER[REQUEST_URI] global (its now in _req_data for route processing).
846
+		$_SERVER['REQUEST_URI'] = remove_query_arg('_wp_http_referer', wp_unslash($_SERVER['REQUEST_URI']));
847
+		if ( ! empty($func)) {
848
+			if (is_array($func)) {
849
+				list($class, $method) = $func;
850
+			} else if (strpos($func, '::') !== false) {
851
+				list($class, $method) = explode('::', $func);
852
+			} else {
853
+				$class = $this;
854
+				$method = $func;
855
+			}
856
+			if ( ! (is_object($class) && $class === $this)) {
857
+				// send along this admin page object for access by addons.
858
+				$args['admin_page_object'] = $this;
859
+			}
860
+
861
+			if (
862
+				//is it a method on a class that doesn't work?
863
+				(
864
+					(
865
+						method_exists($class, $method)
866
+						&& call_user_func_array(array($class, $method), $args) === false
867
+					)
868
+					&& (
869
+						//is it a standalone function that doesn't work?
870
+						function_exists($method)
871
+						&& call_user_func_array($func, array_merge(array('admin_page_object' => $this), $args)) === false
872
+					)
873
+				)
874
+				|| (
875
+					//is it neither a class method NOR a standalone function?
876
+					! method_exists($class, $method)
877
+					&& ! function_exists($method)
878
+				)
879
+			) {
880
+				// user error msg
881
+				$error_msg = __('An error occurred. The  requested page route could not be found.', 'event_espresso');
882
+				// developer error msg
883
+				$error_msg .= '||';
884
+				$error_msg .= sprintf(
885
+					__(
886
+						'Page route "%s" could not be called. Check that the spelling for method names and actions in the "_page_routes" array are all correct.',
887
+						'event_espresso'
888
+					),
889
+					$method
890
+				);
891
+			}
892
+			if ( ! empty($error_msg)) {
893
+				throw new EE_Error($error_msg);
894
+			}
895
+		}
896
+		//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.
897
+		//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.
898
+		if ($this->_is_UI_request === false
899
+			&& is_array($this->_route)
900
+			&& ! empty($this->_route['headers_sent_route'])
901
+		) {
902
+			$this->_reset_routing_properties($this->_route['headers_sent_route']);
903
+		}
904
+	}
905
+
906
+
907
+
908
+	/**
909
+	 * This method just allows the resetting of page properties in the case where a no headers
910
+	 * route redirects to a headers route in its route config.
911
+	 *
912
+	 * @since   4.3.0
913
+	 * @param  string $new_route New (non header) route to redirect to.
914
+	 * @return   void
915
+	 */
916
+	protected function _reset_routing_properties($new_route)
917
+	{
918
+		$this->_is_UI_request = true;
919
+		//now we set the current route to whatever the headers_sent_route is set at
920
+		$this->_req_data['action'] = $new_route;
921
+		//rerun page setup
922
+		$this->_page_setup();
923
+	}
924
+
925
+
926
+
927
+	/**
928
+	 * _add_query_arg
929
+	 * adds nonce to array of arguments then calls WP add_query_arg function
930
+	 *(internally just uses EEH_URL's function with the same name)
931
+	 *
932
+	 * @access public
933
+	 * @param array  $args
934
+	 * @param string $url
935
+	 * @param bool   $sticky                  if true, then the existing Request params will be appended to the generated
936
+	 *                                        url in an associative array indexed by the key 'wp_referer';
937
+	 *                                        Example usage:
938
+	 *                                        If the current page is:
939
+	 *                                        http://mydomain.com/wp-admin/admin.php?page=espresso_registrations
940
+	 *                                        &action=default&event_id=20&month_range=March%202015
941
+	 *                                        &_wpnonce=5467821
942
+	 *                                        and you call:
943
+	 *                                        EE_Admin_Page::add_query_args_and_nonce(
944
+	 *                                        array(
945
+	 *                                        'action' => 'resend_something',
946
+	 *                                        'page=>espresso_registrations'
947
+	 *                                        ),
948
+	 *                                        $some_url,
949
+	 *                                        true
950
+	 *                                        );
951
+	 *                                        It will produce a url in this structure:
952
+	 *                                        http://{$some_url}/?page=espresso_registrations&action=resend_something
953
+	 *                                        &wp_referer[action]=default&wp_referer[event_id]=20&wpreferer[
954
+	 *                                        month_range]=March%202015
955
+	 * @param   bool $exclude_nonce           If true, the the nonce will be excluded from the generated nonce.
956
+	 * @return string
957
+	 */
958
+	public static function add_query_args_and_nonce($args = array(), $url = false, $sticky = false, $exclude_nonce = false)
959
+	{
960
+		//if there is a _wp_http_referer include the values from the request but only if sticky = true
961
+		if ($sticky) {
962
+			$request = $_REQUEST;
963
+			unset($request['_wp_http_referer']);
964
+			unset($request['wp_referer']);
965
+			foreach ($request as $key => $value) {
966
+				//do not add nonces
967
+				if (strpos($key, 'nonce') !== false) {
968
+					continue;
969
+				}
970
+				$args['wp_referer[' . $key . ']'] = $value;
971
+			}
972
+		}
973
+		return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
974
+	}
975
+
976
+
977
+
978
+	/**
979
+	 * This returns a generated link that will load the related help tab.
980
+	 *
981
+	 * @param  string $help_tab_id the id for the connected help tab
982
+	 * @param  string $icon_style  (optional) include css class for the style you want to use for the help icon.
983
+	 * @param  string $help_text   (optional) send help text you want to use for the link if default not to be used
984
+	 * @uses EEH_Template::get_help_tab_link()
985
+	 * @return string              generated link
986
+	 */
987
+	protected function _get_help_tab_link($help_tab_id, $icon_style = false, $help_text = false)
988
+	{
989
+		return EEH_Template::get_help_tab_link($help_tab_id, $this->page_slug, $this->_req_action, $icon_style, $help_text);
990
+	}
991
+
992
+
993
+
994
+	/**
995
+	 * _add_help_tabs
996
+	 * Note child classes define their help tabs within the page_config array.
997
+	 *
998
+	 * @link   http://codex.wordpress.org/Function_Reference/add_help_tab
999
+	 * @access protected
1000
+	 * @return void
1001
+	 */
1002
+	protected function _add_help_tabs()
1003
+	{
1004
+		$tour_buttons = '';
1005
+		if (isset($this->_page_config[$this->_req_action])) {
1006
+			$config = $this->_page_config[$this->_req_action];
1007
+			//is there a help tour for the current route?  if there is let's setup the tour buttons
1008
+			if (isset($this->_help_tour[$this->_req_action])) {
1009
+				$tb = array();
1010
+				$tour_buttons = '<div class="ee-abs-container"><div class="ee-help-tour-restart-buttons">';
1011
+				foreach ($this->_help_tour['tours'] as $tour) {
1012
+					//if this is the end tour then we don't need to setup a button
1013
+					if ($tour instanceof EE_Help_Tour_final_stop) {
1014
+						continue;
1015
+					}
1016
+					$tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1017
+				}
1018
+				$tour_buttons .= implode('<br />', $tb);
1019
+				$tour_buttons .= '</div></div>';
1020
+			}
1021
+			// let's see if there is a help_sidebar set for the current route and we'll set that up for usage as well.
1022
+			if (is_array($config) && isset($config['help_sidebar'])) {
1023
+				//check that the callback given is valid
1024
+				if ( ! method_exists($this, $config['help_sidebar'])) {
1025
+					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',
1026
+							'event_espresso'), $config['help_sidebar'], get_class($this)));
1027
+				}
1028
+				$content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1029
+				$content .= $tour_buttons; //add help tour buttons.
1030
+				//do we have any help tours setup?  Cause if we do we want to add the buttons
1031
+				$this->_current_screen->set_help_sidebar($content);
1032
+			}
1033
+			//if we DON'T have config help sidebar and there ARE toure buttons then we'll just add the tour buttons to the sidebar.
1034
+			if ( ! isset($config['help_sidebar']) && ! empty($tour_buttons)) {
1035
+				$this->_current_screen->set_help_sidebar($tour_buttons);
1036
+			}
1037
+			//handle if no help_tabs are set so the sidebar will still show for the help tour buttons
1038
+			if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1039
+				$_ht['id'] = $this->page_slug;
1040
+				$_ht['title'] = __('Help Tours', 'event_espresso');
1041
+				$_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1042
+				$this->_current_screen->add_help_tab($_ht);
1043
+			}/**/
1044
+			if ( ! isset($config['help_tabs'])) {
1045
+				return;
1046
+			} //no help tabs for this route
1047
+			foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1048
+				//we're here so there ARE help tabs!
1049
+				//make sure we've got what we need
1050
+				if ( ! isset($cfg['title'])) {
1051
+					throw new EE_Error(__('The _page_config array is not set up properly for help tabs.  It is missing a title', 'event_espresso'));
1052
+				}
1053
+				if ( ! isset($cfg['filename']) && ! isset($cfg['callback']) && ! isset($cfg['content'])) {
1054
+					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',
1055
+							'event_espresso'));
1056
+				}
1057
+				//first priority goes to content.
1058
+				if ( ! empty($cfg['content'])) {
1059
+					$content = ! empty($cfg['content']) ? $cfg['content'] : null;
1060
+					//second priority goes to filename
1061
+				} else if ( ! empty($cfg['filename'])) {
1062
+					$file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1063
+					//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)
1064
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1065
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1066
+					if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1067
+						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',
1068
+								'event_espresso'), $tab_id, key($config), $file_path), __FILE__, __FUNCTION__, __LINE__);
1069
+						return;
1070
+					}
1071
+					$template_args['admin_page_obj'] = $this;
1072
+					$content = EEH_Template::display_template($file_path, $template_args, true);
1073
+				} else {
1074
+					$content = '';
1075
+				}
1076
+				//check if callback is valid
1077
+				if (empty($content) && ( ! isset($cfg['callback']) || ! method_exists($this, $cfg['callback']))) {
1078
+					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.',
1079
+							'event_espresso'), $cfg['title']), __FILE__, __FUNCTION__, __LINE__);
1080
+					return;
1081
+				}
1082
+				//setup config array for help tab method
1083
+				$id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1084
+				$_ht = array(
1085
+						'id'       => $id,
1086
+						'title'    => $cfg['title'],
1087
+						'callback' => isset($cfg['callback']) && empty($content) ? array($this, $cfg['callback']) : null,
1088
+						'content'  => $content,
1089
+				);
1090
+				$this->_current_screen->add_help_tab($_ht);
1091
+			}
1092
+		}
1093
+	}
1094
+
1095
+
1096
+
1097
+	/**
1098
+	 * 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
1099
+	 *
1100
+	 * @link   http://zurb.com/playground/jquery-joyride-feature-tour-plugin
1101
+	 * @see    instructions regarding the format and construction of the "help_tour" array element is found in the _set_page_config() comments
1102
+	 * @access protected
1103
+	 * @return void
1104
+	 */
1105
+	protected function _add_help_tour()
1106
+	{
1107
+		$tours = array();
1108
+		$this->_help_tour = array();
1109
+		//exit early if help tours are turned off globally
1110
+		if ( ! EE_Registry::instance()->CFG->admin->help_tour_activation || (defined('EE_DISABLE_HELP_TOURS') && EE_DISABLE_HELP_TOURS)) {
1111
+			return;
1112
+		}
1113
+		//loop through _page_config to find any help_tour defined
1114
+		foreach ($this->_page_config as $route => $config) {
1115
+			//we're only going to set things up for this route
1116
+			if ($route !== $this->_req_action) {
1117
+				continue;
1118
+			}
1119
+			if (isset($config['help_tour'])) {
1120
+				foreach ($config['help_tour'] as $tour) {
1121
+					$file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1122
+					//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
1123
+					$file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1124
+					//if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1125
+					if ( ! is_readable($file_path)) {
1126
+						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'),
1127
+								$file_path, $tour), __FILE__, __FUNCTION__, __LINE__);
1128
+						return;
1129
+					}
1130
+					require_once $file_path;
1131
+					if ( ! class_exists($tour)) {
1132
+						$error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1133
+						$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.',
1134
+										'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1135
+						throw new EE_Error(implode('||', $error_msg));
1136
+					}
1137
+					$a = new ReflectionClass($tour);
1138
+					$tour_obj = $a->newInstance($this->_is_caf);
1139
+					$tours[] = $tour_obj;
1140
+					$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($tour_obj);
1141
+				}
1142
+				//let's inject the end tour stop element common to all pages... this will only get seen once per machine.
1143
+				$end_stop_tour = new EE_Help_Tour_final_stop($this->_is_caf);
1144
+				$tours[] = $end_stop_tour;
1145
+				$this->_help_tour[$route][] = EEH_Template::help_tour_stops_generator($end_stop_tour);
1146
+			}
1147
+		}
1148
+		if ( ! empty($tours)) {
1149
+			$this->_help_tour['tours'] = $tours;
1150
+		}
1151
+		//thats it!  Now that the $_help_tours property is set (or not) the scripts and html should be taken care of automatically.
1152
+	}
1153
+
1154
+
1155
+
1156
+	/**
1157
+	 * This simply sets up any qtips that have been defined in the page config
1158
+	 *
1159
+	 * @access protected
1160
+	 * @return void
1161
+	 */
1162
+	protected function _add_qtips()
1163
+	{
1164
+		if (isset($this->_route_config['qtips'])) {
1165
+			$qtips = (array)$this->_route_config['qtips'];
1166
+			//load qtip loader
1167
+			$path = array(
1168
+					$this->_get_dir() . '/qtips/',
1169
+					EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1170
+			);
1171
+			EEH_Qtip_Loader::instance()->register($qtips, $path);
1172
+		}
1173
+	}
1174
+
1175
+
1176
+
1177
+	/**
1178
+	 * _set_nav_tabs
1179
+	 * 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.
1180
+	 *
1181
+	 * @access protected
1182
+	 * @return void
1183
+	 */
1184
+	protected function _set_nav_tabs()
1185
+	{
1186
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1187
+		$i = 0;
1188
+		foreach ($this->_page_config as $slug => $config) {
1189
+			if ( ! is_array($config) || (is_array($config) && (isset($config['nav']) && ! $config['nav']) || ! isset($config['nav']))) {
1190
+				continue;
1191
+			} //no nav tab for this config
1192
+			//check for persistent flag
1193
+			if (isset($config['nav']['persistent']) && ! $config['nav']['persistent'] && $slug !== $this->_req_action) {
1194
+				continue;
1195
+			} //nav tab is only to appear when route requested.
1196
+			if ( ! $this->check_user_access($slug, true)) {
1197
+				continue;
1198
+			} //no nav tab becasue current user does not have access.
1199
+			$css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1200
+			$this->_nav_tabs[$slug] = array(
1201
+					'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1202
+					'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1203
+					'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1204
+					'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1205
+			);
1206
+			$i++;
1207
+		}
1208
+		//if $this->_nav_tabs is empty then lets set the default
1209
+		if (empty($this->_nav_tabs)) {
1210
+			$this->_nav_tabs[$this->default_nav_tab_name] = array(
1211
+					'url'       => $this->admin_base_url,
1212
+					'link_text' => ucwords(str_replace('_', ' ', $this->default_nav_tab_name)),
1213
+					'css_class' => 'nav-tab-active',
1214
+					'order'     => 10,
1215
+			);
1216
+		}
1217
+		//now let's sort the tabs according to order
1218
+		usort($this->_nav_tabs, array($this, '_sort_nav_tabs'));
1219
+	}
1220
+
1221
+
1222
+
1223
+	/**
1224
+	 * _set_current_labels
1225
+	 * This method modifies the _labels property with any optional specific labels indicated in the _page_routes property array
1226
+	 *
1227
+	 * @access private
1228
+	 * @return void
1229
+	 */
1230
+	private function _set_current_labels()
1231
+	{
1232
+		if (is_array($this->_route_config) && isset($this->_route_config['labels'])) {
1233
+			foreach ($this->_route_config['labels'] as $label => $text) {
1234
+				if (is_array($text)) {
1235
+					foreach ($text as $sublabel => $subtext) {
1236
+						$this->_labels[$label][$sublabel] = $subtext;
1237
+					}
1238
+				} else {
1239
+					$this->_labels[$label] = $text;
1240
+				}
1241
+			}
1242
+		}
1243
+	}
1244
+
1245
+
1246
+
1247
+	/**
1248
+	 *        verifies user access for this admin page
1249
+	 *
1250
+	 * @param string $route_to_check if present then the capability for the route matching this string is checked.
1251
+	 * @param bool   $verify_only    Default is FALSE which means if user check fails then wp_die().  Otherwise just return false if verify fail.
1252
+	 * @return        BOOL|wp_die()
1253
+	 */
1254
+	public function check_user_access($route_to_check = '', $verify_only = false)
1255
+	{
1256
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1257
+		$route_to_check = empty($route_to_check) ? $this->_req_action : $route_to_check;
1258
+		$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'])
1259
+				? $this->_page_routes[$route_to_check]['capability'] : null;
1260
+		if (empty($capability) && empty($route_to_check)) {
1261
+			$capability = is_array($this->_route) && empty($this->_route['capability']) ? 'manage_options' : $this->_route['capability'];
1262
+		} else {
1263
+			$capability = empty($capability) ? 'manage_options' : $capability;
1264
+		}
1265
+		$id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1266
+		if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1267
+			if ($verify_only) {
1268
+				return false;
1269
+			} else {
1270
+				if ( is_user_logged_in() ) {
1271
+					wp_die(__('You do not have access to this route.', 'event_espresso'));
1272
+				} else {
1273
+					return false;
1274
+				}
1275
+			}
1276
+		}
1277
+		return true;
1278
+	}
1279
+
1280
+
1281
+
1282
+	/**
1283
+	 * admin_init_global
1284
+	 * This runs all the code that we want executed within the WP admin_init hook.
1285
+	 * This method executes for ALL EE Admin pages.
1286
+	 *
1287
+	 * @access public
1288
+	 * @return void
1289
+	 */
1290
+	public function admin_init_global()
1291
+	{
1292
+	}
1293
+
1294
+
1295
+
1296
+	/**
1297
+	 * wp_loaded_global
1298
+	 * 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
1299
+	 *
1300
+	 * @access public
1301
+	 * @return void
1302
+	 */
1303
+	public function wp_loaded()
1304
+	{
1305
+	}
1306
+
1307
+
1308
+
1309
+	/**
1310
+	 * admin_notices
1311
+	 * Anything triggered by the 'admin_notices' WP hook should be put in here.  This particular method will apply on ALL EE_Admin pages.
1312
+	 *
1313
+	 * @access public
1314
+	 * @return void
1315
+	 */
1316
+	public function admin_notices_global()
1317
+	{
1318
+		$this->_display_no_javascript_warning();
1319
+		$this->_display_espresso_notices();
1320
+	}
1321
+
1322
+
1323
+
1324
+	public function network_admin_notices_global()
1325
+	{
1326
+		$this->_display_no_javascript_warning();
1327
+		$this->_display_espresso_notices();
1328
+	}
1329
+
1330
+
1331
+
1332
+	/**
1333
+	 * admin_footer_scripts_global
1334
+	 * 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.
1335
+	 *
1336
+	 * @access public
1337
+	 * @return void
1338
+	 */
1339
+	public function admin_footer_scripts_global()
1340
+	{
1341
+		$this->_add_admin_page_ajax_loading_img();
1342
+		$this->_add_admin_page_overlay();
1343
+		//if metaboxes are present we need to add the nonce field
1344
+		if ((isset($this->_route_config['metaboxes']) || (isset($this->_route_config['has_metaboxes']) && $this->_route_config['has_metaboxes']) || isset($this->_route_config['list_table']))) {
1345
+			wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
1346
+			wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
1347
+		}
1348
+	}
1349
+
1350
+
1351
+
1352
+	/**
1353
+	 * admin_footer_global
1354
+	 * Anything triggered by the wp 'admin_footer' wp hook should be put in here. This particluar method will apply on ALL EE_Admin Pages.
1355
+	 *
1356
+	 * @access  public
1357
+	 * @return  void
1358
+	 */
1359
+	public function admin_footer_global()
1360
+	{
1361
+		//dialog container for dialog helper
1362
+		$d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1363
+		$d_cont .= '<div class="ee-notices"></div>';
1364
+		$d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1365
+		$d_cont .= '</div>';
1366
+		echo $d_cont;
1367
+		//help tour stuff?
1368
+		if (isset($this->_help_tour[$this->_req_action])) {
1369
+			echo implode('<br />', $this->_help_tour[$this->_req_action]);
1370
+		}
1371
+		//current set timezone for timezone js
1372
+		echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1373
+	}
1374
+
1375
+
1376
+
1377
+	/**
1378
+	 * 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.
1379
+	 * For child classes:
1380
+	 * 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
1381
+	 * 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
1382
+	 * '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(
1383
+	 *    'help_trigger_id' => array(
1384
+	 *        'title' => __('localized title for popup', 'event_espresso'),
1385
+	 *        'content' => __('localized content for popup', 'event_espresso')
1386
+	 *    )
1387
+	 * );
1388
+	 * Then the EE_Admin_Parent will take care of making sure that is setup properly on the correct route.
1389
+	 *
1390
+	 * @access protected
1391
+	 * @return string content
1392
+	 */
1393
+	protected function _set_help_popup_content($help_array = array(), $display = false)
1394
+	{
1395
+		$content = '';
1396
+		$help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1397
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1398
+		//loop through the array and setup content
1399
+		foreach ($help_array as $trigger => $help) {
1400
+			//make sure the array is setup properly
1401
+			if ( ! isset($help['title']) || ! isset($help['content'])) {
1402
+				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',
1403
+						'event_espresso'));
1404
+			}
1405
+			//we're good so let'd setup the template vars and then assign parsed template content to our content.
1406
+			$template_args = array(
1407
+					'help_popup_id'      => $trigger,
1408
+					'help_popup_title'   => $help['title'],
1409
+					'help_popup_content' => $help['content'],
1410
+			);
1411
+			$content .= EEH_Template::display_template($template_path, $template_args, true);
1412
+		}
1413
+		if ($display) {
1414
+			echo $content;
1415
+		} else {
1416
+			return $content;
1417
+		}
1418
+	}
1419
+
1420
+
1421
+
1422
+	/**
1423
+	 * All this does is retrive the help content array if set by the EE_Admin_Page child
1424
+	 *
1425
+	 * @access private
1426
+	 * @return array properly formatted array for help popup content
1427
+	 */
1428
+	private function _get_help_content()
1429
+	{
1430
+		//what is the method we're looking for?
1431
+		$method_name = '_help_popup_content_' . $this->_req_action;
1432
+		//if method doesn't exist let's get out.
1433
+		if ( ! method_exists($this, $method_name)) {
1434
+			return array();
1435
+		}
1436
+		//k we're good to go let's retrieve the help array
1437
+		$help_array = call_user_func(array($this, $method_name));
1438
+		//make sure we've got an array!
1439
+		if ( ! is_array($help_array)) {
1440
+			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'));
1441
+		}
1442
+		return $help_array;
1443
+	}
1444
+
1445
+
1446
+
1447
+	/**
1448
+	 * EE Admin Pages can use this to set a properly formatted trigger for a help popup.
1449
+	 * By default the trigger html is printed.  Otherwise it can be returned if the $display flag is set "false"
1450
+	 * See comments made on the _set_help_content method for understanding other parts to the help popup tool.
1451
+	 *
1452
+	 * @access protected
1453
+	 * @param string  $trigger_id reference for retrieving the trigger content for the popup
1454
+	 * @param boolean $display    if false then we return the trigger string
1455
+	 * @param array   $dimensions an array of dimensions for the box (array(h,w))
1456
+	 * @return string
1457
+	 */
1458
+	protected function _set_help_trigger($trigger_id, $display = true, $dimensions = array('400', '640'))
1459
+	{
1460
+		if (defined('DOING_AJAX')) {
1461
+			return;
1462
+		}
1463
+		//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
1464
+		$help_array = $this->_get_help_content();
1465
+		$help_content = '';
1466
+		if (empty($help_array) || ! isset($help_array[$trigger_id])) {
1467
+			$help_array[$trigger_id] = array(
1468
+					'title'   => __('Missing Content', 'event_espresso'),
1469
+					'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.)',
1470
+							'event_espresso'),
1471
+			);
1472
+			$help_content = $this->_set_help_popup_content($help_array, false);
1473
+		}
1474
+		//let's setup the trigger
1475
+		$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>';
1476
+		$content = $content . $help_content;
1477
+		if ($display) {
1478
+			echo $content;
1479
+		} else {
1480
+			return $content;
1481
+		}
1482
+	}
1483
+
1484
+
1485
+
1486
+	/**
1487
+	 * _add_global_screen_options
1488
+	 * Add any extra wp_screen_options within this method using built-in WP functions/methods for doing so.
1489
+	 * This particular method will add_screen_options on ALL EE_Admin Pages
1490
+	 *
1491
+	 * @link   http://chrismarslender.com/wp-tutorials/wordpress-screen-options-tutorial/
1492
+	 *         see also WP_Screen object documents...
1493
+	 * @link   http://codex.wordpress.org/Class_Reference/WP_Screen
1494
+	 * @abstract
1495
+	 * @access private
1496
+	 * @return void
1497
+	 */
1498
+	private function _add_global_screen_options()
1499
+	{
1500
+	}
1501
+
1502
+
1503
+
1504
+	/**
1505
+	 * _add_global_feature_pointers
1506
+	 * This method is used for implementing any "feature pointers" (using built-in WP styling js).
1507
+	 * This particular method will implement feature pointers for ALL EE_Admin pages.
1508
+	 * Note: this is just a placeholder for now.  Implementation will come down the road
1509
+	 *
1510
+	 * @see    WP_Internal_Pointers class in wp-admin/includes/template.php for example (its a final class so can't be extended) also see:
1511
+	 * @link   http://eamann.com/tech/wordpress-portland/
1512
+	 * @abstract
1513
+	 * @access protected
1514
+	 * @return void
1515
+	 */
1516
+	private function _add_global_feature_pointers()
1517
+	{
1518
+	}
1519
+
1520
+
1521
+
1522
+	/**
1523
+	 * load_global_scripts_styles
1524
+	 * The scripts and styles enqueued in here will be loaded on every EE Admin page
1525
+	 *
1526
+	 * @return void
1527
+	 */
1528
+	public function load_global_scripts_styles()
1529
+	{
1530
+		/** STYLES **/
1531
+		// add debugging styles
1532
+		if (WP_DEBUG) {
1533
+			add_action('admin_head', array($this, 'add_xdebug_style'));
1534
+		}
1535
+		//register all styles
1536
+		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);
1537
+		wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1538
+		//helpers styles
1539
+		wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1540
+		//enqueue global styles
1541
+		wp_enqueue_style('ee-admin-css');
1542
+		/** SCRIPTS **/
1543
+		//register all scripts
1544
+		wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1545
+		wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1546
+		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);
1547
+		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);
1548
+		// register jQuery Validate - see /includes/functions/wp_hooks.php
1549
+		add_filter('FHEE_load_jquery_validate', '__return_true');
1550
+		add_filter('FHEE_load_joyride', '__return_true');
1551
+		//script for sorting tables
1552
+		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);
1553
+		//script for parsing uri's
1554
+		wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1555
+		//and parsing associative serialized form elements
1556
+		wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1557
+		//helpers scripts
1558
+		wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1559
+		wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1560
+		wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1561
+		wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1562
+		//google charts
1563
+		wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1564
+		//enqueue global scripts
1565
+		//taking care of metaboxes
1566
+		if ((isset($this->_route_config['metaboxes']) || isset($this->_route_config['has_metaboxes'])) && empty($this->_cpt_route)) {
1567
+			wp_enqueue_script('dashboard');
1568
+		}
1569
+		//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
1570
+		if ( ! isset($this->_route_config['has_help_popups']) || (isset($this->_route_config['has_help_popups']) && $this->_route_config['has_help_popups'])) {
1571
+			wp_enqueue_script('ee_admin_js');
1572
+			wp_enqueue_style('ee-admin-css');
1573
+		}
1574
+		//localize script for ajax lazy loading
1575
+		$lazy_loader_container_ids = apply_filters('FHEE__EE_Admin_Page_Core__load_global_scripts_styles__loader_containers', array('espresso_news_post_box_content'));
1576
+		wp_localize_script('ee_admin_js', 'eeLazyLoadingContainers', $lazy_loader_container_ids);
1577
+		/**
1578
+		 * help tour stuff
1579
+		 */
1580
+		if ( ! empty($this->_help_tour)) {
1581
+			//register the js for kicking things off
1582
+			wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1583
+			//setup tours for the js tour object
1584
+			foreach ($this->_help_tour['tours'] as $tour) {
1585
+				$tours[] = array(
1586
+						'id'      => $tour->get_slug(),
1587
+						'options' => $tour->get_options(),
1588
+				);
1589
+			}
1590
+			wp_localize_script('ee-help-tour', 'EE_HELP_TOUR', array('tours' => $tours));
1591
+			//admin_footer_global will take care of making sure our help_tour skeleton gets printed via the info stored in $this->_help_tour
1592
+		}
1593
+	}
1594
+
1595
+
1596
+
1597
+	/**
1598
+	 *        admin_footer_scripts_eei18n_js_strings
1599
+	 *
1600
+	 * @access        public
1601
+	 * @return        void
1602
+	 */
1603
+	public function admin_footer_scripts_eei18n_js_strings()
1604
+	{
1605
+		EE_Registry::$i18n_js_strings['ajax_url'] = WP_AJAX_URL;
1606
+		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');
1607
+		EE_Registry::$i18n_js_strings['January'] = __('January', 'event_espresso');
1608
+		EE_Registry::$i18n_js_strings['February'] = __('February', 'event_espresso');
1609
+		EE_Registry::$i18n_js_strings['March'] = __('March', 'event_espresso');
1610
+		EE_Registry::$i18n_js_strings['April'] = __('April', 'event_espresso');
1611
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1612
+		EE_Registry::$i18n_js_strings['June'] = __('June', 'event_espresso');
1613
+		EE_Registry::$i18n_js_strings['July'] = __('July', 'event_espresso');
1614
+		EE_Registry::$i18n_js_strings['August'] = __('August', 'event_espresso');
1615
+		EE_Registry::$i18n_js_strings['September'] = __('September', 'event_espresso');
1616
+		EE_Registry::$i18n_js_strings['October'] = __('October', 'event_espresso');
1617
+		EE_Registry::$i18n_js_strings['November'] = __('November', 'event_espresso');
1618
+		EE_Registry::$i18n_js_strings['December'] = __('December', 'event_espresso');
1619
+		EE_Registry::$i18n_js_strings['Jan'] = __('Jan', 'event_espresso');
1620
+		EE_Registry::$i18n_js_strings['Feb'] = __('Feb', 'event_espresso');
1621
+		EE_Registry::$i18n_js_strings['Mar'] = __('Mar', 'event_espresso');
1622
+		EE_Registry::$i18n_js_strings['Apr'] = __('Apr', 'event_espresso');
1623
+		EE_Registry::$i18n_js_strings['May'] = __('May', 'event_espresso');
1624
+		EE_Registry::$i18n_js_strings['Jun'] = __('Jun', 'event_espresso');
1625
+		EE_Registry::$i18n_js_strings['Jul'] = __('Jul', 'event_espresso');
1626
+		EE_Registry::$i18n_js_strings['Aug'] = __('Aug', 'event_espresso');
1627
+		EE_Registry::$i18n_js_strings['Sep'] = __('Sep', 'event_espresso');
1628
+		EE_Registry::$i18n_js_strings['Oct'] = __('Oct', 'event_espresso');
1629
+		EE_Registry::$i18n_js_strings['Nov'] = __('Nov', 'event_espresso');
1630
+		EE_Registry::$i18n_js_strings['Dec'] = __('Dec', 'event_espresso');
1631
+		EE_Registry::$i18n_js_strings['Sunday'] = __('Sunday', 'event_espresso');
1632
+		EE_Registry::$i18n_js_strings['Monday'] = __('Monday', 'event_espresso');
1633
+		EE_Registry::$i18n_js_strings['Tuesday'] = __('Tuesday', 'event_espresso');
1634
+		EE_Registry::$i18n_js_strings['Wednesday'] = __('Wednesday', 'event_espresso');
1635
+		EE_Registry::$i18n_js_strings['Thursday'] = __('Thursday', 'event_espresso');
1636
+		EE_Registry::$i18n_js_strings['Friday'] = __('Friday', 'event_espresso');
1637
+		EE_Registry::$i18n_js_strings['Saturday'] = __('Saturday', 'event_espresso');
1638
+		EE_Registry::$i18n_js_strings['Sun'] = __('Sun', 'event_espresso');
1639
+		EE_Registry::$i18n_js_strings['Mon'] = __('Mon', 'event_espresso');
1640
+		EE_Registry::$i18n_js_strings['Tue'] = __('Tue', 'event_espresso');
1641
+		EE_Registry::$i18n_js_strings['Wed'] = __('Wed', 'event_espresso');
1642
+		EE_Registry::$i18n_js_strings['Thu'] = __('Thu', 'event_espresso');
1643
+		EE_Registry::$i18n_js_strings['Fri'] = __('Fri', 'event_espresso');
1644
+		EE_Registry::$i18n_js_strings['Sat'] = __('Sat', 'event_espresso');
1645
+		//setting on espresso_core instead of ee_admin_js because espresso_core is enqueued by the maintenance
1646
+		//admin page when in maintenance mode and ee_admin_js is not loaded then.  This works everywhere else because
1647
+		//espresso_core is listed as a dependency of ee_admin_js.
1648
+		wp_localize_script('espresso_core', 'eei18n', EE_Registry::$i18n_js_strings);
1649
+	}
1650
+
1651
+
1652
+
1653
+	/**
1654
+	 *        load enhanced xdebug styles for ppl with failing eyesight
1655
+	 *
1656
+	 * @access        public
1657
+	 * @return        void
1658
+	 */
1659
+	public function add_xdebug_style()
1660
+	{
1661
+		echo '<style>.xdebug-error { font-size:1.5em; }</style>';
1662
+	}
1663
+
1664
+
1665
+	/************************/
1666
+	/** LIST TABLE METHODS **/
1667
+	/************************/
1668
+	/**
1669
+	 * this sets up the list table if the current view requires it.
1670
+	 *
1671
+	 * @access protected
1672
+	 * @return void
1673
+	 */
1674
+	protected function _set_list_table()
1675
+	{
1676
+		//first is this a list_table view?
1677
+		if ( ! isset($this->_route_config['list_table'])) {
1678
+			return;
1679
+		} //not a list_table view so get out.
1680
+		//list table functions are per view specific (because some admin pages might have more than one listtable!)
1681
+		if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1682
+			//user error msg
1683
+			$error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1684
+			//developer error msg
1685
+			$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'),
1686
+							$this->_req_action, '_set_list_table_views_' . $this->_req_action);
1687
+			throw new EE_Error($error_msg);
1688
+		}
1689
+		//let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1690
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1691
+		$this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1692
+		$this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1693
+		$this->_set_list_table_view();
1694
+		$this->_set_list_table_object();
1695
+	}
1696
+
1697
+
1698
+
1699
+	/**
1700
+	 *        set current view for List Table
1701
+	 *
1702
+	 * @access public
1703
+	 * @return array
1704
+	 */
1705
+	protected function _set_list_table_view()
1706
+	{
1707
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1708
+		// looking at active items or dumpster diving ?
1709
+		if ( ! isset($this->_req_data['status']) || ! array_key_exists($this->_req_data['status'], $this->_views)) {
1710
+			$this->_view = isset($this->_views['in_use']) ? 'in_use' : 'all';
1711
+		} else {
1712
+			$this->_view = sanitize_key($this->_req_data['status']);
1713
+		}
1714
+	}
1715
+
1716
+
1717
+
1718
+	/**
1719
+	 * _set_list_table_object
1720
+	 * WP_List_Table objects need to be loaded fairly early so automatic stuff WP does is taken care of.
1721
+	 *
1722
+	 * @throws \EE_Error
1723
+	 */
1724
+	protected function _set_list_table_object()
1725
+	{
1726
+		if (isset($this->_route_config['list_table'])) {
1727
+			if ( ! class_exists($this->_route_config['list_table'])) {
1728
+				throw new EE_Error(
1729
+						sprintf(
1730
+								__(
1731
+										'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.',
1732
+										'event_espresso'
1733
+								),
1734
+								$this->_route_config['list_table'],
1735
+								get_class($this)
1736
+						)
1737
+				);
1738
+			}
1739
+			$list_table = $this->_route_config['list_table'];
1740
+			$this->_list_table_object = new $list_table($this);
1741
+		}
1742
+	}
1743
+
1744
+
1745
+
1746
+	/**
1747
+	 * get_list_table_view_RLs - get it? View RL ?? VU-RL???  URL ??
1748
+	 *
1749
+	 * @param array $extra_query_args                     Optional. An array of extra query args to add to the generated
1750
+	 *                                                    urls.  The array should be indexed by the view it is being
1751
+	 *                                                    added to.
1752
+	 * @return array
1753
+	 */
1754
+	public function get_list_table_view_RLs($extra_query_args = array())
1755
+	{
1756
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1757
+		if (empty($this->_views)) {
1758
+			$this->_views = array();
1759
+		}
1760
+		// cycle thru views
1761
+		foreach ($this->_views as $key => $view) {
1762
+			$query_args = array();
1763
+			// check for current view
1764
+			$this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1765
+			$query_args['action'] = $this->_req_action;
1766
+			$query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1767
+			$query_args['status'] = $view['slug'];
1768
+			//merge any other arguments sent in.
1769
+			if (isset($extra_query_args[$view['slug']])) {
1770
+				$query_args = array_merge($query_args, $extra_query_args[$view['slug']]);
1771
+			}
1772
+			$this->_views[$key]['url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1773
+		}
1774
+		return $this->_views;
1775
+	}
1776
+
1777
+
1778
+
1779
+	/**
1780
+	 * _entries_per_page_dropdown
1781
+	 * generates a drop down box for selecting the number of visiable rows in an admin page list table
1782
+	 *
1783
+	 * @todo   : Note: ideally this should be added to the screen options dropdown as that would be consistent with how WP does it.
1784
+	 * @access protected
1785
+	 * @param int $max_entries total number of rows in the table
1786
+	 * @return string
1787
+	 */
1788
+	protected function _entries_per_page_dropdown($max_entries = false)
1789
+	{
1790
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1791
+		$values = array(10, 25, 50, 100);
1792
+		$per_page = ( ! empty($this->_req_data['per_page'])) ? absint($this->_req_data['per_page']) : 10;
1793
+		if ($max_entries) {
1794
+			$values[] = $max_entries;
1795
+			sort($values);
1796
+		}
1797
+		$entries_per_page_dropdown = '
1798 1798
 			<div id="entries-per-page-dv" class="alignleft actions">
1799 1799
 				<label class="hide-if-no-js">
1800 1800
 					Show
1801 1801
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1802
-        foreach ($values as $value) {
1803
-            if ($value < $max_entries) {
1804
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1805
-                $entries_per_page_dropdown .= '
1802
+		foreach ($values as $value) {
1803
+			if ($value < $max_entries) {
1804
+				$selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1805
+				$entries_per_page_dropdown .= '
1806 1806
 						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1807
-            }
1808
-        }
1809
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1810
-        $entries_per_page_dropdown .= '
1807
+			}
1808
+		}
1809
+		$selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1810
+		$entries_per_page_dropdown .= '
1811 1811
 						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1812
-        $entries_per_page_dropdown .= '
1812
+		$entries_per_page_dropdown .= '
1813 1813
 					</select>
1814 1814
 					entries
1815 1815
 				</label>
1816 1816
 				<input id="entries-per-page-btn" class="button-secondary" type="submit" value="Go" >
1817 1817
 			</div>
1818 1818
 		';
1819
-        return $entries_per_page_dropdown;
1820
-    }
1821
-
1822
-
1823
-
1824
-    /**
1825
-     *        _set_search_attributes
1826
-     *
1827
-     * @access        protected
1828
-     * @return        void
1829
-     */
1830
-    public function _set_search_attributes()
1831
-    {
1832
-        $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1833
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1834
-    }
1835
-
1836
-    /*** END LIST TABLE METHODS **/
1837
-    /*****************************/
1838
-    /**
1839
-     *        _add_registered_metaboxes
1840
-     *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1841
-     *
1842
-     * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1843
-     * @access private
1844
-     * @return void
1845
-     */
1846
-    private function _add_registered_meta_boxes()
1847
-    {
1848
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1849
-        //we only add meta boxes if the page_route calls for it
1850
-        if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1851
-            && is_array(
1852
-                    $this->_route_config['metaboxes']
1853
-            )
1854
-        ) {
1855
-            // this simply loops through the callbacks provided
1856
-            // and checks if there is a corresponding callback registered by the child
1857
-            // if there is then we go ahead and process the metabox loader.
1858
-            foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1859
-                // first check for Closures
1860
-                if ($metabox_callback instanceof Closure) {
1861
-                    $result = $metabox_callback();
1862
-                } else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1863
-                    $result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1864
-                } else {
1865
-                    $result = call_user_func(array($this, &$metabox_callback));
1866
-                }
1867
-                if ($result === false) {
1868
-                    // user error msg
1869
-                    $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1870
-                    // developer error msg
1871
-                    $error_msg .= '||' . sprintf(
1872
-                                    __(
1873
-                                            '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.',
1874
-                                            'event_espresso'
1875
-                                    ),
1876
-                                    $metabox_callback
1877
-                            );
1878
-                    throw new EE_Error($error_msg);
1879
-                }
1880
-            }
1881
-        }
1882
-    }
1883
-
1884
-
1885
-
1886
-    /**
1887
-     * _add_screen_columns
1888
-     * 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.
1889
-     *
1890
-     * @access private
1891
-     * @return void
1892
-     */
1893
-    private function _add_screen_columns()
1894
-    {
1895
-        if (
1896
-                is_array($this->_route_config)
1897
-                && isset($this->_route_config['columns'])
1898
-                && is_array($this->_route_config['columns'])
1899
-                && count($this->_route_config['columns']) === 2
1900
-        ) {
1901
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1902
-            $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1903
-            $screen_id = $this->_current_screen->id;
1904
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1905
-            $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1906
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1907
-            $this->_template_args['current_page'] = $this->_wp_page_slug;
1908
-            $this->_template_args['screen'] = $this->_current_screen;
1909
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1910
-            //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.
1911
-            $this->_route_config['has_metaboxes'] = true;
1912
-        }
1913
-    }
1914
-
1915
-
1916
-
1917
-    /**********************************/
1918
-    /** GLOBALLY AVAILABLE METABOXES **/
1919
-    /**
1920
-     * 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
1921
-     * loaded on.
1922
-     */
1923
-    private function _espresso_news_post_box()
1924
-    {
1925
-        $news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1926
-        add_meta_box('espresso_news_post_box', $news_box_title, array(
1927
-                $this,
1928
-                'espresso_news_post_box',
1929
-        ), $this->_wp_page_slug, 'side');
1930
-    }
1931
-
1932
-
1933
-
1934
-    /**
1935
-     * Code for setting up espresso ratings request metabox.
1936
-     */
1937
-    protected function _espresso_ratings_request()
1938
-    {
1939
-        if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1940
-            return '';
1941
-        }
1942
-        $ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1943
-        add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1944
-                $this,
1945
-                'espresso_ratings_request',
1946
-        ), $this->_wp_page_slug, 'side');
1947
-    }
1948
-
1949
-
1950
-
1951
-    /**
1952
-     * Code for setting up espresso ratings request metabox content.
1953
-     */
1954
-    public function espresso_ratings_request()
1955
-    {
1956
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1957
-        EEH_Template::display_template($template_path, array());
1958
-    }
1959
-
1960
-
1961
-
1962
-    public static function cached_rss_display($rss_id, $url)
1963
-    {
1964
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1965
-        $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1966
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1967
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1968
-        $post = '</div>' . "\n";
1969
-        $cache_key = 'ee_rss_' . md5($rss_id);
1970
-        if (false != ($output = get_transient($cache_key))) {
1971
-            echo $pre . $output . $post;
1972
-            return true;
1973
-        }
1974
-        if ( ! $doing_ajax) {
1975
-            echo $pre . $loading . $post;
1976
-            return false;
1977
-        }
1978
-        ob_start();
1979
-        wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1980
-        set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1981
-        return true;
1982
-    }
1983
-
1984
-
1985
-
1986
-    public function espresso_news_post_box()
1987
-    {
1988
-        ?>
1819
+		return $entries_per_page_dropdown;
1820
+	}
1821
+
1822
+
1823
+
1824
+	/**
1825
+	 *        _set_search_attributes
1826
+	 *
1827
+	 * @access        protected
1828
+	 * @return        void
1829
+	 */
1830
+	public function _set_search_attributes()
1831
+	{
1832
+		$this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1833
+		$this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1834
+	}
1835
+
1836
+	/*** END LIST TABLE METHODS **/
1837
+	/*****************************/
1838
+	/**
1839
+	 *        _add_registered_metaboxes
1840
+	 *        this loads any registered metaboxes via the 'metaboxes' index in the _page_config property array.
1841
+	 *
1842
+	 * @link   http://codex.wordpress.org/Function_Reference/add_meta_box
1843
+	 * @access private
1844
+	 * @return void
1845
+	 */
1846
+	private function _add_registered_meta_boxes()
1847
+	{
1848
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1849
+		//we only add meta boxes if the page_route calls for it
1850
+		if (is_array($this->_route_config) && isset($this->_route_config['metaboxes'])
1851
+			&& is_array(
1852
+					$this->_route_config['metaboxes']
1853
+			)
1854
+		) {
1855
+			// this simply loops through the callbacks provided
1856
+			// and checks if there is a corresponding callback registered by the child
1857
+			// if there is then we go ahead and process the metabox loader.
1858
+			foreach ($this->_route_config['metaboxes'] as $metabox_callback) {
1859
+				// first check for Closures
1860
+				if ($metabox_callback instanceof Closure) {
1861
+					$result = $metabox_callback();
1862
+				} else if (is_array($metabox_callback) && isset($metabox_callback[0], $metabox_callback[1])) {
1863
+					$result = call_user_func(array($metabox_callback[0], $metabox_callback[1]));
1864
+				} else {
1865
+					$result = call_user_func(array($this, &$metabox_callback));
1866
+				}
1867
+				if ($result === false) {
1868
+					// user error msg
1869
+					$error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1870
+					// developer error msg
1871
+					$error_msg .= '||' . sprintf(
1872
+									__(
1873
+											'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.',
1874
+											'event_espresso'
1875
+									),
1876
+									$metabox_callback
1877
+							);
1878
+					throw new EE_Error($error_msg);
1879
+				}
1880
+			}
1881
+		}
1882
+	}
1883
+
1884
+
1885
+
1886
+	/**
1887
+	 * _add_screen_columns
1888
+	 * 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.
1889
+	 *
1890
+	 * @access private
1891
+	 * @return void
1892
+	 */
1893
+	private function _add_screen_columns()
1894
+	{
1895
+		if (
1896
+				is_array($this->_route_config)
1897
+				&& isset($this->_route_config['columns'])
1898
+				&& is_array($this->_route_config['columns'])
1899
+				&& count($this->_route_config['columns']) === 2
1900
+		) {
1901
+			add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1902
+			$this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1903
+			$screen_id = $this->_current_screen->id;
1904
+			$screen_columns = (int)get_user_option("screen_layout_$screen_id");
1905
+			$total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1906
+			$this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1907
+			$this->_template_args['current_page'] = $this->_wp_page_slug;
1908
+			$this->_template_args['screen'] = $this->_current_screen;
1909
+			$this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1910
+			//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.
1911
+			$this->_route_config['has_metaboxes'] = true;
1912
+		}
1913
+	}
1914
+
1915
+
1916
+
1917
+	/**********************************/
1918
+	/** GLOBALLY AVAILABLE METABOXES **/
1919
+	/**
1920
+	 * 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
1921
+	 * loaded on.
1922
+	 */
1923
+	private function _espresso_news_post_box()
1924
+	{
1925
+		$news_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('New @ Event Espresso', 'event_espresso'));
1926
+		add_meta_box('espresso_news_post_box', $news_box_title, array(
1927
+				$this,
1928
+				'espresso_news_post_box',
1929
+		), $this->_wp_page_slug, 'side');
1930
+	}
1931
+
1932
+
1933
+
1934
+	/**
1935
+	 * Code for setting up espresso ratings request metabox.
1936
+	 */
1937
+	protected function _espresso_ratings_request()
1938
+	{
1939
+		if ( ! apply_filters('FHEE_show_ratings_request_meta_box', true)) {
1940
+			return '';
1941
+		}
1942
+		$ratings_box_title = apply_filters('FHEE__EE_Admin_Page___espresso_news_post_box__news_box_title', __('Keep Event Espresso Decaf Free', 'event_espresso'));
1943
+		add_meta_box('espresso_ratings_request', $ratings_box_title, array(
1944
+				$this,
1945
+				'espresso_ratings_request',
1946
+		), $this->_wp_page_slug, 'side');
1947
+	}
1948
+
1949
+
1950
+
1951
+	/**
1952
+	 * Code for setting up espresso ratings request metabox content.
1953
+	 */
1954
+	public function espresso_ratings_request()
1955
+	{
1956
+		$template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1957
+		EEH_Template::display_template($template_path, array());
1958
+	}
1959
+
1960
+
1961
+
1962
+	public static function cached_rss_display($rss_id, $url)
1963
+	{
1964
+		$loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1965
+		$doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1966
+		$pre = '<div class="espresso-rss-display">' . "\n\t";
1967
+		$pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1968
+		$post = '</div>' . "\n";
1969
+		$cache_key = 'ee_rss_' . md5($rss_id);
1970
+		if (false != ($output = get_transient($cache_key))) {
1971
+			echo $pre . $output . $post;
1972
+			return true;
1973
+		}
1974
+		if ( ! $doing_ajax) {
1975
+			echo $pre . $loading . $post;
1976
+			return false;
1977
+		}
1978
+		ob_start();
1979
+		wp_widget_rss_output($url, array('show_date' => 0, 'items' => 5));
1980
+		set_transient($cache_key, ob_get_flush(), 12 * HOUR_IN_SECONDS);
1981
+		return true;
1982
+	}
1983
+
1984
+
1985
+
1986
+	public function espresso_news_post_box()
1987
+	{
1988
+		?>
1989 1989
         <div class="padding">
1990 1990
             <div id="espresso_news_post_box_content" class="infolinks">
1991 1991
                 <?php
1992
-                // Get RSS Feed(s)
1993
-                $feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1994
-                $url = urlencode($feed_url);
1995
-                self::cached_rss_display('espresso_news_post_box_content', $url);
1996
-                ?>
1992
+				// Get RSS Feed(s)
1993
+				$feed_url = apply_filters('FHEE__EE_Admin_Page__espresso_news_post_box__feed_url', 'http://eventespresso.com/feed/');
1994
+				$url = urlencode($feed_url);
1995
+				self::cached_rss_display('espresso_news_post_box_content', $url);
1996
+				?>
1997 1997
             </div>
1998 1998
             <?php do_action('AHEE__EE_Admin_Page__espresso_news_post_box__after_content'); ?>
1999 1999
         </div>
2000 2000
         <?php
2001
-    }
2002
-
2003
-
2004
-
2005
-    private function _espresso_links_post_box()
2006
-    {
2007
-        //Hiding until we actually have content to put in here...
2008
-        //add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2009
-    }
2010
-
2011
-
2012
-
2013
-    public function espresso_links_post_box()
2014
-    {
2015
-        //Hiding until we actually have content to put in here...
2016
-        //$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2017
-        //EEH_Template::display_template( $templatepath );
2018
-    }
2019
-
2020
-
2021
-
2022
-    protected function _espresso_sponsors_post_box()
2023
-    {
2024
-        $show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2025
-        if ($show_sponsors) {
2026
-            add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2027
-        }
2028
-    }
2029
-
2030
-
2031
-
2032
-    public function espresso_sponsors_post_box()
2033
-    {
2034
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2035
-        EEH_Template::display_template($templatepath);
2036
-    }
2037
-
2038
-
2039
-
2040
-    private function _publish_post_box()
2041
-    {
2042
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2043
-        //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)
2044
-        if ( ! empty($this->_labels['publishbox'])) {
2045
-            $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2046
-        } else {
2047
-            $box_label = __('Publish', 'event_espresso');
2048
-        }
2049
-        $box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2050
-        add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2051
-    }
2052
-
2053
-
2054
-
2055
-    public function editor_overview()
2056
-    {
2057
-        //if we have extra content set let's add it in if not make sure its empty
2058
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2059
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2060
-        echo EEH_Template::display_template($template_path, $this->_template_args, true);
2061
-    }
2062
-
2063
-
2064
-    /** end of globally available metaboxes section **/
2065
-    /*************************************************/
2066
-    /**
2067
-     * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2068
-     * protected method.
2069
-     *
2070
-     * @see   $this->_set_publish_post_box_vars for param details
2071
-     * @since 4.6.0
2072
-     */
2073
-    public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2074
-    {
2075
-        $this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2076
-    }
2077
-
2078
-
2079
-
2080
-    /**
2081
-     * Sets the _template_args arguments used by the _publish_post_box shortcut
2082
-     * Note: currently there is no validation for this.  However if you want the delete button, the
2083
-     * save, and save and close buttons to work properly, then you will want to include a
2084
-     * values for the name and id arguments.
2085
-     *
2086
-     * @todo  Add in validation for name/id arguments.
2087
-     * @param    string  $name                    key used for the action ID (i.e. event_id)
2088
-     * @param    int     $id                      id attached to the item published
2089
-     * @param    string  $delete                  page route callback for the delete action
2090
-     * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2091
-     * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2092
-     * @throws \EE_Error
2093
-     */
2094
-    protected function _set_publish_post_box_vars(
2095
-            $name = '',
2096
-            $id = 0,
2097
-            $delete = '',
2098
-            $save_close_redirect_URL = '',
2099
-            $both_btns = true
2100
-    ) {
2101
-        // if Save & Close, use a custom redirect URL or default to the main page?
2102
-        $save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2103
-        // create the Save & Close and Save buttons
2104
-        $this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2105
-        //if we have extra content set let's add it in if not make sure its empty
2106
-        $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2107
-        if ($delete && ! empty($id)) {
2108
-            //make sure we have a default if just true is sent.
2109
-            $delete = ! empty($delete) ? $delete : 'delete';
2110
-            $delete_link_args = array($name => $id);
2111
-            $delete = $this->get_action_link_or_button(
2112
-                    $delete,
2113
-                    $delete,
2114
-                    $delete_link_args,
2115
-                    'submitdelete deletion',
2116
-                    '',
2117
-                    false
2118
-            );
2119
-        }
2120
-        $this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2121
-        if ( ! empty($name) && ! empty($id)) {
2122
-            $hidden_field_arr[$name] = array(
2123
-                    'type'  => 'hidden',
2124
-                    'value' => $id,
2125
-            );
2126
-            $hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2127
-        } else {
2128
-            $hf = '';
2129
-        }
2130
-        // add hidden field
2131
-        $this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2132
-    }
2133
-
2134
-
2135
-
2136
-    /**
2137
-     *        displays an error message to ppl who have javascript disabled
2138
-     *
2139
-     * @access        private
2140
-     * @return        string
2141
-     */
2142
-    private function _display_no_javascript_warning()
2143
-    {
2144
-        ?>
2001
+	}
2002
+
2003
+
2004
+
2005
+	private function _espresso_links_post_box()
2006
+	{
2007
+		//Hiding until we actually have content to put in here...
2008
+		//add_meta_box('espresso_links_post_box', __('Helpful Plugin Links', 'event_espresso'), array( $this, 'espresso_links_post_box'), $this->_wp_page_slug, 'side');
2009
+	}
2010
+
2011
+
2012
+
2013
+	public function espresso_links_post_box()
2014
+	{
2015
+		//Hiding until we actually have content to put in here...
2016
+		//$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_links.template.php';
2017
+		//EEH_Template::display_template( $templatepath );
2018
+	}
2019
+
2020
+
2021
+
2022
+	protected function _espresso_sponsors_post_box()
2023
+	{
2024
+		$show_sponsors = apply_filters('FHEE_show_sponsors_meta_box', true);
2025
+		if ($show_sponsors) {
2026
+			add_meta_box('espresso_sponsors_post_box', __('Event Espresso Highlights', 'event_espresso'), array($this, 'espresso_sponsors_post_box'), $this->_wp_page_slug, 'side');
2027
+		}
2028
+	}
2029
+
2030
+
2031
+
2032
+	public function espresso_sponsors_post_box()
2033
+	{
2034
+		$templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2035
+		EEH_Template::display_template($templatepath);
2036
+	}
2037
+
2038
+
2039
+
2040
+	private function _publish_post_box()
2041
+	{
2042
+		$meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2043
+		//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)
2044
+		if ( ! empty($this->_labels['publishbox'])) {
2045
+			$box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
2046
+		} else {
2047
+			$box_label = __('Publish', 'event_espresso');
2048
+		}
2049
+		$box_label = apply_filters('FHEE__EE_Admin_Page___publish_post_box__box_label', $box_label, $this->_req_action, $this);
2050
+		add_meta_box($meta_box_ref, $box_label, array($this, 'editor_overview'), $this->_current_screen->id, 'side', 'high');
2051
+	}
2052
+
2053
+
2054
+
2055
+	public function editor_overview()
2056
+	{
2057
+		//if we have extra content set let's add it in if not make sure its empty
2058
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2059
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2060
+		echo EEH_Template::display_template($template_path, $this->_template_args, true);
2061
+	}
2062
+
2063
+
2064
+	/** end of globally available metaboxes section **/
2065
+	/*************************************************/
2066
+	/**
2067
+	 * Public wrapper for the protected method.  Allows plugins/addons to externally call the
2068
+	 * protected method.
2069
+	 *
2070
+	 * @see   $this->_set_publish_post_box_vars for param details
2071
+	 * @since 4.6.0
2072
+	 */
2073
+	public function set_publish_post_box_vars($name = null, $id = false, $delete = false, $save_close_redirect_URL = null, $both_btns = true)
2074
+	{
2075
+		$this->_set_publish_post_box_vars($name, $id, $delete, $save_close_redirect_URL, $both_btns);
2076
+	}
2077
+
2078
+
2079
+
2080
+	/**
2081
+	 * Sets the _template_args arguments used by the _publish_post_box shortcut
2082
+	 * Note: currently there is no validation for this.  However if you want the delete button, the
2083
+	 * save, and save and close buttons to work properly, then you will want to include a
2084
+	 * values for the name and id arguments.
2085
+	 *
2086
+	 * @todo  Add in validation for name/id arguments.
2087
+	 * @param    string  $name                    key used for the action ID (i.e. event_id)
2088
+	 * @param    int     $id                      id attached to the item published
2089
+	 * @param    string  $delete                  page route callback for the delete action
2090
+	 * @param    string  $save_close_redirect_URL custom URL to redirect to after Save & Close has been completed
2091
+	 * @param    boolean $both_btns               whether to display BOTH the "Save & Close" and "Save" buttons or just the Save button
2092
+	 * @throws \EE_Error
2093
+	 */
2094
+	protected function _set_publish_post_box_vars(
2095
+			$name = '',
2096
+			$id = 0,
2097
+			$delete = '',
2098
+			$save_close_redirect_URL = '',
2099
+			$both_btns = true
2100
+	) {
2101
+		// if Save & Close, use a custom redirect URL or default to the main page?
2102
+		$save_close_redirect_URL = ! empty($save_close_redirect_URL) ? $save_close_redirect_URL : $this->_admin_base_url;
2103
+		// create the Save & Close and Save buttons
2104
+		$this->_set_save_buttons($both_btns, array(), array(), $save_close_redirect_URL);
2105
+		//if we have extra content set let's add it in if not make sure its empty
2106
+		$this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2107
+		if ($delete && ! empty($id)) {
2108
+			//make sure we have a default if just true is sent.
2109
+			$delete = ! empty($delete) ? $delete : 'delete';
2110
+			$delete_link_args = array($name => $id);
2111
+			$delete = $this->get_action_link_or_button(
2112
+					$delete,
2113
+					$delete,
2114
+					$delete_link_args,
2115
+					'submitdelete deletion',
2116
+					'',
2117
+					false
2118
+			);
2119
+		}
2120
+		$this->_template_args['publish_delete_link'] = ! empty($id) ? $delete : '';
2121
+		if ( ! empty($name) && ! empty($id)) {
2122
+			$hidden_field_arr[$name] = array(
2123
+					'type'  => 'hidden',
2124
+					'value' => $id,
2125
+			);
2126
+			$hf = $this->_generate_admin_form_fields($hidden_field_arr, 'array');
2127
+		} else {
2128
+			$hf = '';
2129
+		}
2130
+		// add hidden field
2131
+		$this->_template_args['publish_hidden_fields'] = ! empty($hf) ? $hf[$name]['field'] : $hf;
2132
+	}
2133
+
2134
+
2135
+
2136
+	/**
2137
+	 *        displays an error message to ppl who have javascript disabled
2138
+	 *
2139
+	 * @access        private
2140
+	 * @return        string
2141
+	 */
2142
+	private function _display_no_javascript_warning()
2143
+	{
2144
+		?>
2145 2145
         <noscript>
2146 2146
             <div id="no-js-message" class="error">
2147 2147
                 <p style="font-size:1.3em;">
@@ -2151,1267 +2151,1267 @@  discard block
 block discarded – undo
2151 2151
             </div>
2152 2152
         </noscript>
2153 2153
         <?php
2154
-    }
2154
+	}
2155 2155
 
2156 2156
 
2157 2157
 
2158
-    /**
2159
-     *        displays espresso success and/or error notices
2160
-     *
2161
-     * @access        private
2162
-     * @return        string
2163
-     */
2164
-    private function _display_espresso_notices()
2165
-    {
2166
-        $notices = $this->_get_transient(true);
2167
-        echo stripslashes($notices);
2168
-    }
2158
+	/**
2159
+	 *        displays espresso success and/or error notices
2160
+	 *
2161
+	 * @access        private
2162
+	 * @return        string
2163
+	 */
2164
+	private function _display_espresso_notices()
2165
+	{
2166
+		$notices = $this->_get_transient(true);
2167
+		echo stripslashes($notices);
2168
+	}
2169 2169
 
2170 2170
 
2171 2171
 
2172
-    /**
2173
-     *        spinny things pacify the masses
2174
-     *
2175
-     * @access private
2176
-     * @return string
2177
-     */
2178
-    protected function _add_admin_page_ajax_loading_img()
2179
-    {
2180
-        ?>
2172
+	/**
2173
+	 *        spinny things pacify the masses
2174
+	 *
2175
+	 * @access private
2176
+	 * @return string
2177
+	 */
2178
+	protected function _add_admin_page_ajax_loading_img()
2179
+	{
2180
+		?>
2181 2181
         <div id="espresso-ajax-loading" class="ajax-loading-grey">
2182 2182
             <span class="ee-spinner ee-spin"></span><span class="hidden"><?php esc_html_e('loading...', 'event_espresso'); ?></span>
2183 2183
         </div>
2184 2184
         <?php
2185
-    }
2185
+	}
2186 2186
 
2187 2187
 
2188 2188
 
2189
-    /**
2190
-     *        add admin page overlay for modal boxes
2191
-     *
2192
-     * @access private
2193
-     * @return string
2194
-     */
2195
-    protected function _add_admin_page_overlay()
2196
-    {
2197
-        ?>
2189
+	/**
2190
+	 *        add admin page overlay for modal boxes
2191
+	 *
2192
+	 * @access private
2193
+	 * @return string
2194
+	 */
2195
+	protected function _add_admin_page_overlay()
2196
+	{
2197
+		?>
2198 2198
         <div id="espresso-admin-page-overlay-dv" class=""></div>
2199 2199
         <?php
2200
-    }
2201
-
2202
-
2203
-
2204
-    /**
2205
-     * facade for add_meta_box
2206
-     *
2207
-     * @param string  $action        where the metabox get's displayed
2208
-     * @param string  $title         Title of Metabox (output in metabox header)
2209
-     * @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.
2210
-     * @param array   $callback_args an array of args supplied for the metabox
2211
-     * @param string  $column        what metabox column
2212
-     * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2213
-     * @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.
2214
-     */
2215
-    public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2216
-    {
2217
-        do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2218
-        //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.
2219
-        if (empty($callback_args) && $create_func) {
2220
-            $callback_args = array(
2221
-                    'template_path' => $this->_template_path,
2222
-                    'template_args' => $this->_template_args,
2223
-            );
2224
-        }
2225
-        //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)
2226
-        $call_back_func = $create_func ? create_function('$post, $metabox',
2227
-                'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2228
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2229
-    }
2230
-
2231
-
2232
-
2233
-    /**
2234
-     * generates HTML wrapper for and admin details page that contains metaboxes in columns
2235
-     *
2236
-     * @return [type] [description]
2237
-     */
2238
-    public function display_admin_page_with_metabox_columns()
2239
-    {
2240
-        $this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2241
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2242
-        //the final wrapper
2243
-        $this->admin_page_wrapper();
2244
-    }
2245
-
2246
-
2247
-
2248
-    /**
2249
-     *        generates  HTML wrapper for an admin details page
2250
-     *
2251
-     * @access public
2252
-     * @return void
2253
-     */
2254
-    public function display_admin_page_with_sidebar()
2255
-    {
2256
-        $this->_display_admin_page(true);
2257
-    }
2258
-
2259
-
2260
-
2261
-    /**
2262
-     *        generates  HTML wrapper for an admin details page (except no sidebar)
2263
-     *
2264
-     * @access public
2265
-     * @return void
2266
-     */
2267
-    public function display_admin_page_with_no_sidebar()
2268
-    {
2269
-        $this->_display_admin_page();
2270
-    }
2271
-
2272
-
2273
-
2274
-    /**
2275
-     * generates HTML wrapper for an EE about admin page (no sidebar)
2276
-     *
2277
-     * @access public
2278
-     * @return void
2279
-     */
2280
-    public function display_about_admin_page()
2281
-    {
2282
-        $this->_display_admin_page(false, true);
2283
-    }
2284
-
2285
-
2286
-
2287
-    /**
2288
-     * display_admin_page
2289
-     * contains the code for actually displaying an admin page
2290
-     *
2291
-     * @access private
2292
-     * @param  boolean $sidebar true with sidebar, false without
2293
-     * @param  boolean $about   use the about admin wrapper instead of the default.
2294
-     * @return void
2295
-     */
2296
-    private function _display_admin_page($sidebar = false, $about = false)
2297
-    {
2298
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2299
-        //custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2300
-        do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2301
-        // set current wp page slug - looks like: event-espresso_page_event_categories
2302
-        // keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2303
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2304
-        $this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2305
-                ? 'poststuff'
2306
-                : 'espresso-default-admin';
2307
-        $template_path = $sidebar
2308
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2309
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2310
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2311
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2312
-        }
2313
-        $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2314
-        $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2315
-        $this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2316
-        $this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2317
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2318
-        // the final template wrapper
2319
-        $this->admin_page_wrapper($about);
2320
-    }
2321
-
2322
-
2323
-
2324
-    /**
2325
-     * This is used to display caf preview pages.
2326
-     *
2327
-     * @since 4.3.2
2328
-     * @param string $utm_campaign_source what is the key used for google analytics link
2329
-     * @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.
2330
-     * @return void
2331
-     * @throws \EE_Error
2332
-     */
2333
-    public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2334
-    {
2335
-        //let's generate a default preview action button if there isn't one already present.
2336
-        $this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2337
-        $buy_now_url = add_query_arg(
2338
-                array(
2339
-                        'ee_ver'       => 'ee4',
2340
-                        'utm_source'   => 'ee4_plugin_admin',
2341
-                        'utm_medium'   => 'link',
2342
-                        'utm_campaign' => $utm_campaign_source,
2343
-                        'utm_content'  => 'buy_now_button',
2344
-                ),
2345
-                'http://eventespresso.com/pricing/'
2346
-        );
2347
-        $this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2348
-                ? $this->get_action_link_or_button(
2349
-                        '',
2350
-                        'buy_now',
2351
-                        array(),
2352
-                        'button-primary button-large',
2353
-                        $buy_now_url,
2354
-                        true
2355
-                )
2356
-                : $this->_template_args['preview_action_button'];
2357
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2358
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2359
-                $template_path,
2360
-                $this->_template_args,
2361
-                true
2362
-        );
2363
-        $this->_display_admin_page($display_sidebar);
2364
-    }
2365
-
2366
-
2367
-
2368
-    /**
2369
-     * display_admin_list_table_page_with_sidebar
2370
-     * generates HTML wrapper for an admin_page with list_table
2371
-     *
2372
-     * @access public
2373
-     * @return void
2374
-     */
2375
-    public function display_admin_list_table_page_with_sidebar()
2376
-    {
2377
-        $this->_display_admin_list_table_page(true);
2378
-    }
2379
-
2380
-
2381
-
2382
-    /**
2383
-     * display_admin_list_table_page_with_no_sidebar
2384
-     * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2385
-     *
2386
-     * @access public
2387
-     * @return void
2388
-     */
2389
-    public function display_admin_list_table_page_with_no_sidebar()
2390
-    {
2391
-        $this->_display_admin_list_table_page();
2392
-    }
2393
-
2394
-
2395
-
2396
-    /**
2397
-     * generates html wrapper for an admin_list_table page
2398
-     *
2399
-     * @access private
2400
-     * @param boolean $sidebar whether to display with sidebar or not.
2401
-     * @return void
2402
-     */
2403
-    private function _display_admin_list_table_page($sidebar = false)
2404
-    {
2405
-        //setup search attributes
2406
-        $this->_set_search_attributes();
2407
-        $this->_template_args['current_page'] = $this->_wp_page_slug;
2408
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2409
-        $this->_template_args['table_url'] = defined('DOING_AJAX')
2410
-                ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2411
-                : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2412
-        $this->_template_args['list_table'] = $this->_list_table_object;
2413
-        $this->_template_args['current_route'] = $this->_req_action;
2414
-        $this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2415
-        $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2416
-        if ( ! empty($ajax_sorting_callback)) {
2417
-            $sortable_list_table_form_fields = wp_nonce_field(
2418
-                    $ajax_sorting_callback . '_nonce',
2419
-                    $ajax_sorting_callback . '_nonce',
2420
-                    false,
2421
-                    false
2422
-            );
2423
-            //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2424
-            //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2425
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2426
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2427
-        } else {
2428
-            $sortable_list_table_form_fields = '';
2429
-        }
2430
-        $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2431
-        $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2432
-        $nonce_ref = $this->_req_action . '_nonce';
2433
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2434
-        $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2435
-        //display message about search results?
2436
-        $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2437
-                ? '<p class="ee-search-results">' . sprintf(
2438
-                        esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2439
-                        trim($this->_req_data['s'], '%')
2440
-                ) . '</p>'
2441
-                : '';
2442
-        // filter before_list_table template arg
2443
-        $this->_template_args['before_list_table'] = apply_filters(
2444
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2445
-            $this->_template_args['before_list_table'],
2446
-            $this->page_slug,
2447
-            $this->_req_data,
2448
-            $this->_req_action
2449
-        );
2450
-        // convert to array and filter again
2451
-        // arrays are easier to inject new items in a specific location,
2452
-        // but would not be backwards compatible, so we have to add a new filter
2453
-        $this->_template_args['before_list_table'] = implode(
2454
-            " \n",
2455
-            (array) apply_filters(
2456
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2457
-                (array) $this->_template_args['before_list_table'],
2458
-                $this->page_slug,
2459
-                $this->_req_data,
2460
-                $this->_req_action
2461
-            )
2462
-        );
2463
-        // filter after_list_table template arg
2464
-        $this->_template_args['after_list_table'] = apply_filters(
2465
-            'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2466
-            $this->_template_args['after_list_table'],
2467
-            $this->page_slug,
2468
-            $this->_req_data,
2469
-            $this->_req_action
2470
-        );
2471
-        // convert to array and filter again
2472
-        // arrays are easier to inject new items in a specific location,
2473
-        // but would not be backwards compatible, so we have to add a new filter
2474
-        $this->_template_args['after_list_table'] = implode(
2475
-            " \n",
2476
-            (array) apply_filters(
2477
-                'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2478
-                (array) $this->_template_args['after_list_table'],
2479
-                $this->page_slug,
2480
-                $this->_req_data,
2481
-                $this->_req_action
2482
-            )
2483
-        );
2484
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2485
-                $template_path,
2486
-                $this->_template_args,
2487
-                true
2488
-        );
2489
-        // the final template wrapper
2490
-        if ($sidebar) {
2491
-            $this->display_admin_page_with_sidebar();
2492
-        } else {
2493
-            $this->display_admin_page_with_no_sidebar();
2494
-        }
2495
-    }
2496
-
2497
-
2498
-
2499
-    /**
2500
-     * 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.
2501
-     * $items are expected in an array in the following format:
2502
-     * $legend_items = array(
2503
-     *        'item_id' => array(
2504
-     *            'icon' => 'http://url_to_icon_being_described.png',
2505
-     *            'desc' => __('localized description of item');
2506
-     *        )
2507
-     * );
2508
-     *
2509
-     * @param  array $items see above for format of array
2510
-     * @return string        html string of legend
2511
-     */
2512
-    protected function _display_legend($items)
2513
-    {
2514
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2515
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2516
-        return EEH_Template::display_template($legend_template, $this->_template_args, true);
2517
-    }
2518
-
2519
-
2520
-
2521
-    /**
2522
-     * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2523
-     *
2524
-     * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2525
-     *                             The returned json object is created from an array in the following format:
2526
-     *                             array(
2527
-     *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2528
-     *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2529
-     *                             'notices' => '', // - contains any EE_Error formatted notices
2530
-     *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2531
-     *                             '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
2532
-     *                             specific template args that might be included in here)
2533
-     *                             )
2534
-     *                             The json object is populated by whatever is set in the $_template_args property.
2535
-     * @return void
2536
-     */
2537
-    protected function _return_json($sticky_notices = false)
2538
-    {
2539
-        //make sure any EE_Error notices have been handled.
2540
-        $this->_process_notices(array(), true, $sticky_notices);
2541
-        $data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2542
-        unset($this->_template_args['data']);
2543
-        $json = array(
2544
-                'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2545
-                'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2546
-                'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2547
-                'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2548
-                'notices'   => EE_Error::get_notices(),
2549
-                'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2550
-                'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2551
-                'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2552
-        );
2553
-        // make sure there are no php errors or headers_sent.  Then we can set correct json header.
2554
-        if (null === error_get_last() || ! headers_sent()) {
2555
-            header('Content-Type: application/json; charset=UTF-8');
2556
-        }
2557
-        echo wp_json_encode($json);
2558
-
2559
-        exit();
2560
-    }
2561
-
2562
-
2563
-
2564
-    /**
2565
-     * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2566
-     *
2567
-     * @return void
2568
-     * @throws EE_Error
2569
-     */
2570
-    public function return_json()
2571
-    {
2572
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2573
-            $this->_return_json();
2574
-        } else {
2575
-            throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2576
-        }
2577
-    }
2578
-
2579
-
2580
-
2581
-    /**
2582
-     * 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.
2583
-     *
2584
-     * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2585
-     * @access   public
2586
-     */
2587
-    public function set_hook_object(EE_Admin_Hooks $hook_obj)
2588
-    {
2589
-        $this->_hook_obj = $hook_obj;
2590
-    }
2591
-
2592
-
2593
-
2594
-    /**
2595
-     *        generates  HTML wrapper with Tabbed nav for an admin page
2596
-     *
2597
-     * @access public
2598
-     * @param  boolean $about whether to use the special about page wrapper or default.
2599
-     * @return void
2600
-     */
2601
-    public function admin_page_wrapper($about = false)
2602
-    {
2603
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604
-        $this->_nav_tabs = $this->_get_main_nav_tabs();
2605
-        $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2606
-        $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2607
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2608
-                isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2609
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2610
-                isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2611
-        $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2612
-        // load settings page wrapper template
2613
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2614
-        //about page?
2615
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2616
-        if (defined('DOING_AJAX')) {
2617
-            $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2618
-            $this->_return_json();
2619
-        } else {
2620
-            EEH_Template::display_template($template_path, $this->_template_args);
2621
-        }
2622
-    }
2623
-
2624
-
2625
-
2626
-    /**
2627
-     * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2628
-     *
2629
-     * @return string html
2630
-     */
2631
-    protected function _get_main_nav_tabs()
2632
-    {
2633
-        //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)
2634
-        return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2635
-    }
2636
-
2637
-
2638
-
2639
-    /**
2640
-     *        sort nav tabs
2641
-     *
2642
-     * @access public
2643
-     * @param $a
2644
-     * @param $b
2645
-     * @return int
2646
-     */
2647
-    private function _sort_nav_tabs($a, $b)
2648
-    {
2649
-        if ($a['order'] == $b['order']) {
2650
-            return 0;
2651
-        }
2652
-        return ($a['order'] < $b['order']) ? -1 : 1;
2653
-    }
2654
-
2655
-
2656
-
2657
-    /**
2658
-     *    generates HTML for the forms used on admin pages
2659
-     *
2660
-     * @access protected
2661
-     * @param    array $input_vars - array of input field details
2662
-     * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2663
-     * @return string
2664
-     * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2665
-     * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2666
-     */
2667
-    protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2668
-    {
2669
-        $content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2670
-        return $content;
2671
-    }
2672
-
2673
-
2674
-
2675
-    /**
2676
-     * generates the "Save" and "Save & Close" buttons for edit forms
2677
-     *
2678
-     * @access protected
2679
-     * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2680
-     * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2681
-     * @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.
2682
-     * @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).
2683
-     */
2684
-    protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2685
-    {
2686
-        //make sure $text and $actions are in an array
2687
-        $text = (array)$text;
2688
-        $actions = (array)$actions;
2689
-        $referrer_url = empty($referrer) ? '' : $referrer;
2690
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2691
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2692
-        $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2693
-        $default_names = array('save', 'save_and_close');
2694
-        //add in a hidden index for the current page (so save and close redirects properly)
2695
-        $this->_template_args['save_buttons'] = $referrer_url;
2696
-        foreach ($button_text as $key => $button) {
2697
-            $ref = $default_names[$key];
2698
-            $id = $this->_current_view . '_' . $ref;
2699
-            $name = ! empty($actions) ? $actions[$key] : $ref;
2700
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2701
-            if ( ! $both) {
2702
-                break;
2703
-            }
2704
-        }
2705
-    }
2706
-
2707
-
2708
-
2709
-    /**
2710
-     * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2711
-     *
2712
-     * @see   $this->_set_add_edit_form_tags() for details on params
2713
-     * @since 4.6.0
2714
-     * @param string $route
2715
-     * @param array  $additional_hidden_fields
2716
-     */
2717
-    public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2718
-    {
2719
-        $this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2720
-    }
2721
-
2722
-
2723
-
2724
-    /**
2725
-     * set form open and close tags on add/edit pages.
2726
-     *
2727
-     * @access protected
2728
-     * @param string $route                    the route you want the form to direct to
2729
-     * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2730
-     * @return void
2731
-     */
2732
-    protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2733
-    {
2734
-        if (empty($route)) {
2735
-            $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2736
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2737
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2738
-        }
2739
-        // open form
2740
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2741
-        // add nonce
2742
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2743
-        //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2744
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2745
-        // add REQUIRED form action
2746
-        $hidden_fields = array(
2747
-                'action' => array('type' => 'hidden', 'value' => $route),
2748
-        );
2749
-        // merge arrays
2750
-        $hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2751
-        // generate form fields
2752
-        $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2753
-        // add fields to form
2754
-        foreach ((array)$form_fields as $field_name => $form_field) {
2755
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2756
-        }
2757
-        // close form
2758
-        $this->_template_args['after_admin_page_content'] = '</form>';
2759
-    }
2760
-
2761
-
2762
-
2763
-    /**
2764
-     * Public Wrapper for _redirect_after_action() method since its
2765
-     * discovered it would be useful for external code to have access.
2766
-     *
2767
-     * @see   EE_Admin_Page::_redirect_after_action() for params.
2768
-     * @since 4.5.0
2769
-     */
2770
-    public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2771
-    {
2772
-        $this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2773
-    }
2774
-
2775
-
2776
-
2777
-    /**
2778
-     *    _redirect_after_action
2779
-     *
2780
-     * @param int    $success            - whether success was for two or more records, or just one, or none
2781
-     * @param string $what               - what the action was performed on
2782
-     * @param string $action_desc        - what was done ie: updated, deleted, etc
2783
-     * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2784
-     * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2785
-     * @access protected
2786
-     * @return void
2787
-     */
2788
-    protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2789
-    {
2790
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2791
-        //class name for actions/filters.
2792
-        $classname = get_class($this);
2793
-        //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
2794
-        $redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2795
-        $notices = EE_Error::get_notices(false);
2796
-        // overwrite default success messages //BUT ONLY if overwrite not overridden
2797
-        if ( ! $override_overwrite || ! empty($notices['errors'])) {
2798
-            EE_Error::overwrite_success();
2799
-        }
2800
-        if ( ! empty($what) && ! empty($action_desc)) {
2801
-            // how many records affected ? more than one record ? or just one ?
2802
-            if ($success > 1 && empty($notices['errors'])) {
2803
-                // set plural msg
2804
-                EE_Error::add_success(
2805
-                        sprintf(
2806
-                                __('The "%s" have been successfully %s.', 'event_espresso'),
2807
-                                $what,
2808
-                                $action_desc
2809
-                        ),
2810
-                        __FILE__, __FUNCTION__, __LINE__
2811
-                );
2812
-            } else if ($success == 1 && empty($notices['errors'])) {
2813
-                // set singular msg
2814
-                EE_Error::add_success(
2815
-                        sprintf(
2816
-                                __('The "%s" has been successfully %s.', 'event_espresso'),
2817
-                                $what,
2818
-                                $action_desc
2819
-                        ),
2820
-                        __FILE__, __FUNCTION__, __LINE__
2821
-                );
2822
-            }
2823
-        }
2824
-        // check that $query_args isn't something crazy
2825
-        if ( ! is_array($query_args)) {
2826
-            $query_args = array();
2827
-        }
2828
-        /**
2829
-         * Allow injecting actions before the query_args are modified for possible different
2830
-         * redirections on save and close actions
2831
-         *
2832
-         * @since 4.2.0
2833
-         * @param array $query_args       The original query_args array coming into the
2834
-         *                                method.
2835
-         */
2836
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2837
-        //calculate where we're going (if we have a "save and close" button pushed)
2838
-        if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2839
-            // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2840
-            $parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2841
-            // regenerate query args array from referrer URL
2842
-            parse_str($parsed_url['query'], $query_args);
2843
-            // correct page and action will be in the query args now
2844
-            $redirect_url = admin_url('admin.php');
2845
-        }
2846
-        //merge any default query_args set in _default_route_query_args property
2847
-        if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2848
-            $args_to_merge = array();
2849
-            foreach ($this->_default_route_query_args as $query_param => $query_value) {
2850
-                //is there a wp_referer array in our _default_route_query_args property?
2851
-                if ($query_param == 'wp_referer') {
2852
-                    $query_value = (array)$query_value;
2853
-                    foreach ($query_value as $reference => $value) {
2854
-                        if (strpos($reference, 'nonce') !== false) {
2855
-                            continue;
2856
-                        }
2857
-                        //finally we will override any arguments in the referer with
2858
-                        //what might be set on the _default_route_query_args array.
2859
-                        if (isset($this->_default_route_query_args[$reference])) {
2860
-                            $args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2861
-                        } else {
2862
-                            $args_to_merge[$reference] = urlencode($value);
2863
-                        }
2864
-                    }
2865
-                    continue;
2866
-                }
2867
-                $args_to_merge[$query_param] = $query_value;
2868
-            }
2869
-            //now let's merge these arguments but override with what was specifically sent in to the
2870
-            //redirect.
2871
-            $query_args = array_merge($args_to_merge, $query_args);
2872
-        }
2873
-        $this->_process_notices($query_args);
2874
-        // generate redirect url
2875
-        // if redirecting to anything other than the main page, add a nonce
2876
-        if (isset($query_args['action'])) {
2877
-            // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2878
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2879
-        }
2880
-        //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).
2881
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2882
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2883
-        // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2884
-        if (defined('DOING_AJAX')) {
2885
-            $default_data = array(
2886
-                    'close'        => true,
2887
-                    'redirect_url' => $redirect_url,
2888
-                    'where'        => 'main',
2889
-                    'what'         => 'append',
2890
-            );
2891
-            $this->_template_args['success'] = $success;
2892
-            $this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2893
-            $this->_return_json();
2894
-        }
2895
-        wp_safe_redirect($redirect_url);
2896
-        exit();
2897
-    }
2898
-
2899
-
2900
-
2901
-    /**
2902
-     * process any notices before redirecting (or returning ajax request)
2903
-     * This method sets the $this->_template_args['notices'] attribute;
2904
-     *
2905
-     * @param  array $query_args        any query args that need to be used for notice transient ('action')
2906
-     * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2907
-     * @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.
2908
-     * @return void
2909
-     */
2910
-    protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2911
-    {
2912
-        //first let's set individual error properties if doing_ajax and the properties aren't already set.
2913
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2914
-            $notices = EE_Error::get_notices(false);
2915
-            if (empty($this->_template_args['success'])) {
2916
-                $this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2917
-            }
2918
-            if (empty($this->_template_args['errors'])) {
2919
-                $this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2920
-            }
2921
-            if (empty($this->_template_args['attention'])) {
2922
-                $this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2923
-            }
2924
-        }
2925
-        $this->_template_args['notices'] = EE_Error::get_notices();
2926
-        //IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2927
-        if ( ! defined('DOING_AJAX') || $sticky_notices) {
2928
-            $route = isset($query_args['action']) ? $query_args['action'] : 'default';
2929
-            $this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2930
-        }
2931
-    }
2932
-
2933
-
2934
-
2935
-    /**
2936
-     * get_action_link_or_button
2937
-     * returns the button html for adding, editing, or deleting an item (depending on given type)
2938
-     *
2939
-     * @param string $action        use this to indicate which action the url is generated with.
2940
-     * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2941
-     * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2942
-     * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2943
-     * @param string $base_url      If this is not provided
2944
-     *                              the _admin_base_url will be used as the default for the button base_url.
2945
-     *                              Otherwise this value will be used.
2946
-     * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2947
-     * @return string
2948
-     * @throws \EE_Error
2949
-     */
2950
-    public function get_action_link_or_button(
2951
-            $action,
2952
-            $type = 'add',
2953
-            $extra_request = array(),
2954
-            $class = 'button-primary',
2955
-            $base_url = '',
2956
-            $exclude_nonce = false
2957
-    ) {
2958
-        //first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2959
-        if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2960
-            throw new EE_Error(
2961
-                    sprintf(
2962
-                            __(
2963
-                                    'There is no page route for given action for the button.  This action was given: %s',
2964
-                                    'event_espresso'
2965
-                            ),
2966
-                            $action
2967
-                    )
2968
-            );
2969
-        }
2970
-        if ( ! isset($this->_labels['buttons'][$type])) {
2971
-            throw new EE_Error(
2972
-                    sprintf(
2973
-                            __(
2974
-                                    'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2975
-                                    'event_espresso'
2976
-                            ),
2977
-                            $type
2978
-                    )
2979
-            );
2980
-        }
2981
-        //finally check user access for this button.
2982
-        $has_access = $this->check_user_access($action, true);
2983
-        if ( ! $has_access) {
2984
-            return '';
2985
-        }
2986
-        $_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2987
-        $query_args = array(
2988
-                'action' => $action,
2989
-        );
2990
-        //merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2991
-        if ( ! empty($extra_request)) {
2992
-            $query_args = array_merge($extra_request, $query_args);
2993
-        }
2994
-        $url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2995
-        return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2996
-    }
2997
-
2998
-
2999
-
3000
-    /**
3001
-     * _per_page_screen_option
3002
-     * Utility function for adding in a per_page_option in the screen_options_dropdown.
3003
-     *
3004
-     * @return void
3005
-     */
3006
-    protected function _per_page_screen_option()
3007
-    {
3008
-        $option = 'per_page';
3009
-        $args = array(
3010
-                'label'   => $this->_admin_page_title,
3011
-                'default' => 10,
3012
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3013
-        );
3014
-        //ONLY add the screen option if the user has access to it.
3015
-        if ($this->check_user_access($this->_current_view, true)) {
3016
-            add_screen_option($option, $args);
3017
-        }
3018
-    }
3019
-
3020
-
3021
-
3022
-    /**
3023
-     * set_per_page_screen_option
3024
-     * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3025
-     * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
3026
-     *
3027
-     * @access private
3028
-     * @return void
3029
-     */
3030
-    private function _set_per_page_screen_options()
3031
-    {
3032
-        if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3033
-            check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3034
-            if ( ! $user = wp_get_current_user()) {
3035
-                return;
3036
-            }
3037
-            $option = $_POST['wp_screen_options']['option'];
3038
-            $value = $_POST['wp_screen_options']['value'];
3039
-            if ($option != sanitize_key($option)) {
3040
-                return;
3041
-            }
3042
-            $map_option = $option;
3043
-            $option = str_replace('-', '_', $option);
3044
-            switch ($map_option) {
3045
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3046
-                    $value = (int)$value;
3047
-                    if ($value < 1 || $value > 999) {
3048
-                        return;
3049
-                    }
3050
-                    break;
3051
-                default:
3052
-                    $value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3053
-                    if (false === $value) {
3054
-                        return;
3055
-                    }
3056
-                    break;
3057
-            }
3058
-            update_user_meta($user->ID, $option, $value);
3059
-            wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3060
-            exit;
3061
-        }
3062
-    }
3063
-
3064
-
3065
-
3066
-    /**
3067
-     * This just allows for setting the $_template_args property if it needs to be set outside the object
3068
-     *
3069
-     * @param array $data array that will be assigned to template args.
3070
-     */
3071
-    public function set_template_args($data)
3072
-    {
3073
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3074
-    }
3075
-
3076
-
3077
-
3078
-    /**
3079
-     * This makes available the WP transient system for temporarily moving data between routes
3080
-     *
3081
-     * @access protected
3082
-     * @param string $route             the route that should receive the transient
3083
-     * @param array  $data              the data that gets sent
3084
-     * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3085
-     * @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.
3086
-     * @return void
3087
-     */
3088
-    protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3089
-    {
3090
-        $user_id = get_current_user_id();
3091
-        if ( ! $skip_route_verify) {
3092
-            $this->_verify_route($route);
3093
-        }
3094
-        //now let's set the string for what kind of transient we're setting
3095
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3096
-        $data = $notices ? array('notices' => $data) : $data;
3097
-        //is there already a transient for this route?  If there is then let's ADD to that transient
3098
-        $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3099
-        if ($existing) {
3100
-            $data = array_merge((array)$data, (array)$existing);
3101
-        }
3102
-        if (is_multisite() && is_network_admin()) {
3103
-            set_site_transient($transient, $data, 8);
3104
-        } else {
3105
-            set_transient($transient, $data, 8);
3106
-        }
3107
-    }
3108
-
3109
-
3110
-
3111
-    /**
3112
-     * this retrieves the temporary transient that has been set for moving data between routes.
3113
-     *
3114
-     * @param bool $notices true we get notices transient. False we just return normal route transient
3115
-     * @return mixed data
3116
-     */
3117
-    protected function _get_transient($notices = false, $route = false)
3118
-    {
3119
-        $user_id = get_current_user_id();
3120
-        $route = ! $route ? $this->_req_action : $route;
3121
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3122
-        $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3123
-        //delete transient after retrieval (just in case it hasn't expired);
3124
-        if (is_multisite() && is_network_admin()) {
3125
-            delete_site_transient($transient);
3126
-        } else {
3127
-            delete_transient($transient);
3128
-        }
3129
-        return $notices && isset($data['notices']) ? $data['notices'] : $data;
3130
-    }
3131
-
3132
-
3133
-
3134
-    /**
3135
-     * 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.
3136
-     * 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.)
3137
-     *
3138
-     * @return void
3139
-     */
3140
-    protected function _transient_garbage_collection()
3141
-    {
3142
-        global $wpdb;
3143
-        //retrieve all existing transients
3144
-        $query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3145
-        if ($results = $wpdb->get_results($query)) {
3146
-            foreach ($results as $result) {
3147
-                $transient = str_replace('_transient_', '', $result->option_name);
3148
-                get_transient($transient);
3149
-                if (is_multisite() && is_network_admin()) {
3150
-                    get_site_transient($transient);
3151
-                }
3152
-            }
3153
-        }
3154
-    }
3155
-
3156
-
3157
-
3158
-    /**
3159
-     * get_view
3160
-     *
3161
-     * @access public
3162
-     * @return string content of _view property
3163
-     */
3164
-    public function get_view()
3165
-    {
3166
-        return $this->_view;
3167
-    }
3168
-
3169
-
3170
-
3171
-    /**
3172
-     * getter for the protected $_views property
3173
-     *
3174
-     * @return array
3175
-     */
3176
-    public function get_views()
3177
-    {
3178
-        return $this->_views;
3179
-    }
3180
-
3181
-
3182
-
3183
-    /**
3184
-     * get_current_page
3185
-     *
3186
-     * @access public
3187
-     * @return string _current_page property value
3188
-     */
3189
-    public function get_current_page()
3190
-    {
3191
-        return $this->_current_page;
3192
-    }
3193
-
3194
-
3195
-
3196
-    /**
3197
-     * get_current_view
3198
-     *
3199
-     * @access public
3200
-     * @return string _current_view property value
3201
-     */
3202
-    public function get_current_view()
3203
-    {
3204
-        return $this->_current_view;
3205
-    }
3206
-
3207
-
3208
-
3209
-    /**
3210
-     * get_current_screen
3211
-     *
3212
-     * @access public
3213
-     * @return object The current WP_Screen object
3214
-     */
3215
-    public function get_current_screen()
3216
-    {
3217
-        return $this->_current_screen;
3218
-    }
3219
-
3220
-
3221
-
3222
-    /**
3223
-     * get_current_page_view_url
3224
-     *
3225
-     * @access public
3226
-     * @return string This returns the url for the current_page_view.
3227
-     */
3228
-    public function get_current_page_view_url()
3229
-    {
3230
-        return $this->_current_page_view_url;
3231
-    }
3232
-
3233
-
3234
-
3235
-    /**
3236
-     * just returns the _req_data property
3237
-     *
3238
-     * @return array
3239
-     */
3240
-    public function get_request_data()
3241
-    {
3242
-        return $this->_req_data;
3243
-    }
3244
-
3245
-
3246
-
3247
-    /**
3248
-     * returns the _req_data protected property
3249
-     *
3250
-     * @return string
3251
-     */
3252
-    public function get_req_action()
3253
-    {
3254
-        return $this->_req_action;
3255
-    }
3256
-
3257
-
3258
-
3259
-    /**
3260
-     * @return bool  value of $_is_caf property
3261
-     */
3262
-    public function is_caf()
3263
-    {
3264
-        return $this->_is_caf;
3265
-    }
3266
-
3267
-
3268
-
3269
-    /**
3270
-     * @return mixed
3271
-     */
3272
-    public function default_espresso_metaboxes()
3273
-    {
3274
-        return $this->_default_espresso_metaboxes;
3275
-    }
3276
-
3277
-
3278
-
3279
-    /**
3280
-     * @return mixed
3281
-     */
3282
-    public function admin_base_url()
3283
-    {
3284
-        return $this->_admin_base_url;
3285
-    }
3286
-
3287
-
3288
-
3289
-    /**
3290
-     * @return mixed
3291
-     */
3292
-    public function wp_page_slug()
3293
-    {
3294
-        return $this->_wp_page_slug;
3295
-    }
3296
-
3297
-
3298
-
3299
-    /**
3300
-     * updates  espresso configuration settings
3301
-     *
3302
-     * @access    protected
3303
-     * @param string                   $tab
3304
-     * @param EE_Config_Base|EE_Config $config
3305
-     * @param string                   $file file where error occurred
3306
-     * @param string                   $func function  where error occurred
3307
-     * @param string                   $line line no where error occurred
3308
-     * @return boolean
3309
-     */
3310
-    protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3311
-    {
3312
-        //remove any options that are NOT going to be saved with the config settings.
3313
-        if (isset($config->core->ee_ueip_optin)) {
3314
-            $config->core->ee_ueip_has_notified = true;
3315
-            // TODO: remove the following two lines and make sure values are migrated from 3.1
3316
-            update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3317
-            update_option('ee_ueip_has_notified', true);
3318
-        }
3319
-        // and save it (note we're also doing the network save here)
3320
-        $net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3321
-        $config_saved = EE_Config::instance()->update_espresso_config(false, false);
3322
-        if ($config_saved && $net_saved) {
3323
-            EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3324
-            return true;
3325
-        } else {
3326
-            EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3327
-            return false;
3328
-        }
3329
-    }
3330
-
3331
-
3332
-
3333
-    /**
3334
-     * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3335
-     *
3336
-     * @return array
3337
-     */
3338
-    public function get_yes_no_values()
3339
-    {
3340
-        return $this->_yes_no_values;
3341
-    }
3342
-
3343
-
3344
-
3345
-    protected function _get_dir()
3346
-    {
3347
-        $reflector = new ReflectionClass(get_class($this));
3348
-        return dirname($reflector->getFileName());
3349
-    }
3350
-
3351
-
3352
-
3353
-    /**
3354
-     * A helper for getting a "next link".
3355
-     *
3356
-     * @param string $url   The url to link to
3357
-     * @param string $class The class to use.
3358
-     * @return string
3359
-     */
3360
-    protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3361
-    {
3362
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3363
-    }
3364
-
3365
-
3366
-
3367
-    /**
3368
-     * A helper for getting a "previous link".
3369
-     *
3370
-     * @param string $url   The url to link to
3371
-     * @param string $class The class to use.
3372
-     * @return string
3373
-     */
3374
-    protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3375
-    {
3376
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3377
-    }
3378
-
3379
-
3380
-
3381
-
3382
-
3383
-
3384
-
3385
-    //below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3386
-    /**
3387
-     * 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
3388
-     * array.
3389
-     *
3390
-     * @return bool success/fail
3391
-     */
3392
-    protected function _process_resend_registration()
3393
-    {
3394
-        $this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3395
-        do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3396
-        return $this->_template_args['success'];
3397
-    }
3398
-
3399
-
3400
-
3401
-    /**
3402
-     * This automatically processes any payment message notifications when manual payment has been applied.
3403
-     *
3404
-     * @access protected
3405
-     * @param \EE_Payment $payment
3406
-     * @return bool success/fail
3407
-     */
3408
-    protected function _process_payment_notification(EE_Payment $payment)
3409
-    {
3410
-        add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3411
-        do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3412
-        $this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3413
-        return $this->_template_args['success'];
3414
-    }
2200
+	}
2201
+
2202
+
2203
+
2204
+	/**
2205
+	 * facade for add_meta_box
2206
+	 *
2207
+	 * @param string  $action        where the metabox get's displayed
2208
+	 * @param string  $title         Title of Metabox (output in metabox header)
2209
+	 * @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.
2210
+	 * @param array   $callback_args an array of args supplied for the metabox
2211
+	 * @param string  $column        what metabox column
2212
+	 * @param string  $priority      give this metabox a priority (using accepted priorities for wp meta boxes)
2213
+	 * @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.
2214
+	 */
2215
+	public function _add_admin_page_meta_box($action, $title, $callback, $callback_args, $column = 'normal', $priority = 'high', $create_func = true)
2216
+	{
2217
+		do_action('AHEE_log', __FILE__, __FUNCTION__, $callback);
2218
+		//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.
2219
+		if (empty($callback_args) && $create_func) {
2220
+			$callback_args = array(
2221
+					'template_path' => $this->_template_path,
2222
+					'template_args' => $this->_template_args,
2223
+			);
2224
+		}
2225
+		//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)
2226
+		$call_back_func = $create_func ? create_function('$post, $metabox',
2227
+				'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2228
+		add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2229
+	}
2230
+
2231
+
2232
+
2233
+	/**
2234
+	 * generates HTML wrapper for and admin details page that contains metaboxes in columns
2235
+	 *
2236
+	 * @return [type] [description]
2237
+	 */
2238
+	public function display_admin_page_with_metabox_columns()
2239
+	{
2240
+		$this->_template_args['post_body_content'] = $this->_template_args['admin_page_content'];
2241
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_column_template_path, $this->_template_args, true);
2242
+		//the final wrapper
2243
+		$this->admin_page_wrapper();
2244
+	}
2245
+
2246
+
2247
+
2248
+	/**
2249
+	 *        generates  HTML wrapper for an admin details page
2250
+	 *
2251
+	 * @access public
2252
+	 * @return void
2253
+	 */
2254
+	public function display_admin_page_with_sidebar()
2255
+	{
2256
+		$this->_display_admin_page(true);
2257
+	}
2258
+
2259
+
2260
+
2261
+	/**
2262
+	 *        generates  HTML wrapper for an admin details page (except no sidebar)
2263
+	 *
2264
+	 * @access public
2265
+	 * @return void
2266
+	 */
2267
+	public function display_admin_page_with_no_sidebar()
2268
+	{
2269
+		$this->_display_admin_page();
2270
+	}
2271
+
2272
+
2273
+
2274
+	/**
2275
+	 * generates HTML wrapper for an EE about admin page (no sidebar)
2276
+	 *
2277
+	 * @access public
2278
+	 * @return void
2279
+	 */
2280
+	public function display_about_admin_page()
2281
+	{
2282
+		$this->_display_admin_page(false, true);
2283
+	}
2284
+
2285
+
2286
+
2287
+	/**
2288
+	 * display_admin_page
2289
+	 * contains the code for actually displaying an admin page
2290
+	 *
2291
+	 * @access private
2292
+	 * @param  boolean $sidebar true with sidebar, false without
2293
+	 * @param  boolean $about   use the about admin wrapper instead of the default.
2294
+	 * @return void
2295
+	 */
2296
+	private function _display_admin_page($sidebar = false, $about = false)
2297
+	{
2298
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2299
+		//custom remove metaboxes hook to add or remove any metaboxes to/from Admin pages.
2300
+		do_action('AHEE__EE_Admin_Page___display_admin_page__modify_metaboxes');
2301
+		// set current wp page slug - looks like: event-espresso_page_event_categories
2302
+		// keep in mind "event-espresso" COULD be something else if the top level menu label has been translated.
2303
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2304
+		$this->_template_args['admin_page_wrapper_div_id'] = $this->_cpt_route
2305
+				? 'poststuff'
2306
+				: 'espresso-default-admin';
2307
+		$template_path = $sidebar
2308
+				? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2309
+				: EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2310
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2311
+			$template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2312
+		}
2313
+		$template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2314
+		$this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
2315
+		$this->_template_args['before_admin_page_content'] = isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '';
2316
+		$this->_template_args['after_admin_page_content'] = isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '';
2317
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2318
+		// the final template wrapper
2319
+		$this->admin_page_wrapper($about);
2320
+	}
2321
+
2322
+
2323
+
2324
+	/**
2325
+	 * This is used to display caf preview pages.
2326
+	 *
2327
+	 * @since 4.3.2
2328
+	 * @param string $utm_campaign_source what is the key used for google analytics link
2329
+	 * @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.
2330
+	 * @return void
2331
+	 * @throws \EE_Error
2332
+	 */
2333
+	public function display_admin_caf_preview_page($utm_campaign_source = '', $display_sidebar = true)
2334
+	{
2335
+		//let's generate a default preview action button if there isn't one already present.
2336
+		$this->_labels['buttons']['buy_now'] = __('Upgrade to Event Espresso 4 Right Now', 'event_espresso');
2337
+		$buy_now_url = add_query_arg(
2338
+				array(
2339
+						'ee_ver'       => 'ee4',
2340
+						'utm_source'   => 'ee4_plugin_admin',
2341
+						'utm_medium'   => 'link',
2342
+						'utm_campaign' => $utm_campaign_source,
2343
+						'utm_content'  => 'buy_now_button',
2344
+				),
2345
+				'http://eventespresso.com/pricing/'
2346
+		);
2347
+		$this->_template_args['preview_action_button'] = ! isset($this->_template_args['preview_action_button'])
2348
+				? $this->get_action_link_or_button(
2349
+						'',
2350
+						'buy_now',
2351
+						array(),
2352
+						'button-primary button-large',
2353
+						$buy_now_url,
2354
+						true
2355
+				)
2356
+				: $this->_template_args['preview_action_button'];
2357
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2358
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2359
+				$template_path,
2360
+				$this->_template_args,
2361
+				true
2362
+		);
2363
+		$this->_display_admin_page($display_sidebar);
2364
+	}
2365
+
2366
+
2367
+
2368
+	/**
2369
+	 * display_admin_list_table_page_with_sidebar
2370
+	 * generates HTML wrapper for an admin_page with list_table
2371
+	 *
2372
+	 * @access public
2373
+	 * @return void
2374
+	 */
2375
+	public function display_admin_list_table_page_with_sidebar()
2376
+	{
2377
+		$this->_display_admin_list_table_page(true);
2378
+	}
2379
+
2380
+
2381
+
2382
+	/**
2383
+	 * display_admin_list_table_page_with_no_sidebar
2384
+	 * generates HTML wrapper for an admin_page with list_table (but with no sidebar)
2385
+	 *
2386
+	 * @access public
2387
+	 * @return void
2388
+	 */
2389
+	public function display_admin_list_table_page_with_no_sidebar()
2390
+	{
2391
+		$this->_display_admin_list_table_page();
2392
+	}
2393
+
2394
+
2395
+
2396
+	/**
2397
+	 * generates html wrapper for an admin_list_table page
2398
+	 *
2399
+	 * @access private
2400
+	 * @param boolean $sidebar whether to display with sidebar or not.
2401
+	 * @return void
2402
+	 */
2403
+	private function _display_admin_list_table_page($sidebar = false)
2404
+	{
2405
+		//setup search attributes
2406
+		$this->_set_search_attributes();
2407
+		$this->_template_args['current_page'] = $this->_wp_page_slug;
2408
+		$template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2409
+		$this->_template_args['table_url'] = defined('DOING_AJAX')
2410
+				? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2411
+				: add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
2412
+		$this->_template_args['list_table'] = $this->_list_table_object;
2413
+		$this->_template_args['current_route'] = $this->_req_action;
2414
+		$this->_template_args['list_table_class'] = get_class($this->_list_table_object);
2415
+		$ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2416
+		if ( ! empty($ajax_sorting_callback)) {
2417
+			$sortable_list_table_form_fields = wp_nonce_field(
2418
+					$ajax_sorting_callback . '_nonce',
2419
+					$ajax_sorting_callback . '_nonce',
2420
+					false,
2421
+					false
2422
+			);
2423
+			//			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2424
+			//			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2425
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2426
+			$sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2427
+		} else {
2428
+			$sortable_list_table_form_fields = '';
2429
+		}
2430
+		$this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2431
+		$hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2432
+		$nonce_ref = $this->_req_action . '_nonce';
2433
+		$hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2434
+		$this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2435
+		//display message about search results?
2436
+		$this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2437
+				? '<p class="ee-search-results">' . sprintf(
2438
+						esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2439
+						trim($this->_req_data['s'], '%')
2440
+				) . '</p>'
2441
+				: '';
2442
+		// filter before_list_table template arg
2443
+		$this->_template_args['before_list_table'] = apply_filters(
2444
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_arg',
2445
+			$this->_template_args['before_list_table'],
2446
+			$this->page_slug,
2447
+			$this->_req_data,
2448
+			$this->_req_action
2449
+		);
2450
+		// convert to array and filter again
2451
+		// arrays are easier to inject new items in a specific location,
2452
+		// but would not be backwards compatible, so we have to add a new filter
2453
+		$this->_template_args['before_list_table'] = implode(
2454
+			" \n",
2455
+			(array) apply_filters(
2456
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__before_list_table__template_args_array',
2457
+				(array) $this->_template_args['before_list_table'],
2458
+				$this->page_slug,
2459
+				$this->_req_data,
2460
+				$this->_req_action
2461
+			)
2462
+		);
2463
+		// filter after_list_table template arg
2464
+		$this->_template_args['after_list_table'] = apply_filters(
2465
+			'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_arg',
2466
+			$this->_template_args['after_list_table'],
2467
+			$this->page_slug,
2468
+			$this->_req_data,
2469
+			$this->_req_action
2470
+		);
2471
+		// convert to array and filter again
2472
+		// arrays are easier to inject new items in a specific location,
2473
+		// but would not be backwards compatible, so we have to add a new filter
2474
+		$this->_template_args['after_list_table'] = implode(
2475
+			" \n",
2476
+			(array) apply_filters(
2477
+				'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array',
2478
+				(array) $this->_template_args['after_list_table'],
2479
+				$this->page_slug,
2480
+				$this->_req_data,
2481
+				$this->_req_action
2482
+			)
2483
+		);
2484
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
2485
+				$template_path,
2486
+				$this->_template_args,
2487
+				true
2488
+		);
2489
+		// the final template wrapper
2490
+		if ($sidebar) {
2491
+			$this->display_admin_page_with_sidebar();
2492
+		} else {
2493
+			$this->display_admin_page_with_no_sidebar();
2494
+		}
2495
+	}
2496
+
2497
+
2498
+
2499
+	/**
2500
+	 * 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.
2501
+	 * $items are expected in an array in the following format:
2502
+	 * $legend_items = array(
2503
+	 *        'item_id' => array(
2504
+	 *            'icon' => 'http://url_to_icon_being_described.png',
2505
+	 *            'desc' => __('localized description of item');
2506
+	 *        )
2507
+	 * );
2508
+	 *
2509
+	 * @param  array $items see above for format of array
2510
+	 * @return string        html string of legend
2511
+	 */
2512
+	protected function _display_legend($items)
2513
+	{
2514
+		$this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2515
+		$legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2516
+		return EEH_Template::display_template($legend_template, $this->_template_args, true);
2517
+	}
2518
+
2519
+
2520
+
2521
+	/**
2522
+	 * this is used whenever we're DOING_AJAX to return a formatted json array that our calling javascript can expect
2523
+	 *
2524
+	 * @param bool $sticky_notices Used to indicate whether you want to ensure notices are added to a transient instead of displayed.
2525
+	 *                             The returned json object is created from an array in the following format:
2526
+	 *                             array(
2527
+	 *                             'error' => FALSE, //(default FALSE), contains any errors and/or exceptions (exceptions return json early),
2528
+	 *                             'success' => FALSE, //(default FALSE) - contains any special success message.
2529
+	 *                             'notices' => '', // - contains any EE_Error formatted notices
2530
+	 *                             'content' => 'string can be html', //this is a string of formatted content (can be html)
2531
+	 *                             '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
2532
+	 *                             specific template args that might be included in here)
2533
+	 *                             )
2534
+	 *                             The json object is populated by whatever is set in the $_template_args property.
2535
+	 * @return void
2536
+	 */
2537
+	protected function _return_json($sticky_notices = false)
2538
+	{
2539
+		//make sure any EE_Error notices have been handled.
2540
+		$this->_process_notices(array(), true, $sticky_notices);
2541
+		$data = isset($this->_template_args['data']) ? $this->_template_args['data'] : array();
2542
+		unset($this->_template_args['data']);
2543
+		$json = array(
2544
+				'error'     => isset($this->_template_args['error']) ? $this->_template_args['error'] : false,
2545
+				'success'   => isset($this->_template_args['success']) ? $this->_template_args['success'] : false,
2546
+				'errors'    => isset($this->_template_args['errors']) ? $this->_template_args['errors'] : false,
2547
+				'attention' => isset($this->_template_args['attention']) ? $this->_template_args['attention'] : false,
2548
+				'notices'   => EE_Error::get_notices(),
2549
+				'content'   => isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '',
2550
+				'data'      => array_merge($data, array('template_args' => $this->_template_args)),
2551
+				'isEEajax'  => true //special flag so any ajax.Success methods in js can identify this return package as a EEajax package.
2552
+		);
2553
+		// make sure there are no php errors or headers_sent.  Then we can set correct json header.
2554
+		if (null === error_get_last() || ! headers_sent()) {
2555
+			header('Content-Type: application/json; charset=UTF-8');
2556
+		}
2557
+		echo wp_json_encode($json);
2558
+
2559
+		exit();
2560
+	}
2561
+
2562
+
2563
+
2564
+	/**
2565
+	 * Simply a wrapper for the protected method so we can call this outside the class (ONLY when doing ajax)
2566
+	 *
2567
+	 * @return void
2568
+	 * @throws EE_Error
2569
+	 */
2570
+	public function return_json()
2571
+	{
2572
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2573
+			$this->_return_json();
2574
+		} else {
2575
+			throw new EE_Error(sprintf(__('The public %s method can only be called when DOING_AJAX = TRUE', 'event_espresso'), __FUNCTION__));
2576
+		}
2577
+	}
2578
+
2579
+
2580
+
2581
+	/**
2582
+	 * 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.
2583
+	 *
2584
+	 * @param EE_Admin_Hooks $hook_obj This will be the object for the EE_Admin_Hooks child
2585
+	 * @access   public
2586
+	 */
2587
+	public function set_hook_object(EE_Admin_Hooks $hook_obj)
2588
+	{
2589
+		$this->_hook_obj = $hook_obj;
2590
+	}
2591
+
2592
+
2593
+
2594
+	/**
2595
+	 *        generates  HTML wrapper with Tabbed nav for an admin page
2596
+	 *
2597
+	 * @access public
2598
+	 * @param  boolean $about whether to use the special about page wrapper or default.
2599
+	 * @return void
2600
+	 */
2601
+	public function admin_page_wrapper($about = false)
2602
+	{
2603
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2604
+		$this->_nav_tabs = $this->_get_main_nav_tabs();
2605
+		$this->_template_args['nav_tabs'] = $this->_nav_tabs;
2606
+		$this->_template_args['admin_page_title'] = $this->_admin_page_title;
2607
+		$this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2608
+				isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2609
+		$this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2610
+				isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2611
+		$this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2612
+		// load settings page wrapper template
2613
+		$template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2614
+		//about page?
2615
+		$template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2616
+		if (defined('DOING_AJAX')) {
2617
+			$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2618
+			$this->_return_json();
2619
+		} else {
2620
+			EEH_Template::display_template($template_path, $this->_template_args);
2621
+		}
2622
+	}
2623
+
2624
+
2625
+
2626
+	/**
2627
+	 * This returns the admin_nav tabs html using the configuration in the _nav_tabs property
2628
+	 *
2629
+	 * @return string html
2630
+	 */
2631
+	protected function _get_main_nav_tabs()
2632
+	{
2633
+		//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)
2634
+		return EEH_Tabbed_Content::display_admin_nav_tabs($this->_nav_tabs);
2635
+	}
2636
+
2637
+
2638
+
2639
+	/**
2640
+	 *        sort nav tabs
2641
+	 *
2642
+	 * @access public
2643
+	 * @param $a
2644
+	 * @param $b
2645
+	 * @return int
2646
+	 */
2647
+	private function _sort_nav_tabs($a, $b)
2648
+	{
2649
+		if ($a['order'] == $b['order']) {
2650
+			return 0;
2651
+		}
2652
+		return ($a['order'] < $b['order']) ? -1 : 1;
2653
+	}
2654
+
2655
+
2656
+
2657
+	/**
2658
+	 *    generates HTML for the forms used on admin pages
2659
+	 *
2660
+	 * @access protected
2661
+	 * @param    array $input_vars - array of input field details
2662
+	 * @param string   $generator  (options are 'string' or 'array', basically use this to indicate which generator to use)
2663
+	 * @return string
2664
+	 * @uses   EEH_Form_Fields::get_form_fields (/helper/EEH_Form_Fields.helper.php)
2665
+	 * @uses   EEH_Form_Fields::get_form_fields_array (/helper/EEH_Form_Fields.helper.php)
2666
+	 */
2667
+	protected function _generate_admin_form_fields($input_vars = array(), $generator = 'string', $id = false)
2668
+	{
2669
+		$content = $generator == 'string' ? EEH_Form_Fields::get_form_fields($input_vars, $id) : EEH_Form_Fields::get_form_fields_array($input_vars);
2670
+		return $content;
2671
+	}
2672
+
2673
+
2674
+
2675
+	/**
2676
+	 * generates the "Save" and "Save & Close" buttons for edit forms
2677
+	 *
2678
+	 * @access protected
2679
+	 * @param bool             $both     if true then both buttons will be generated.  If false then just the "Save & Close" button.
2680
+	 * @param array            $text     if included, generator will use the given text for the buttons ( array([0] => 'Save', [1] => 'save & close')
2681
+	 * @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.
2682
+	 * @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).
2683
+	 */
2684
+	protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2685
+	{
2686
+		//make sure $text and $actions are in an array
2687
+		$text = (array)$text;
2688
+		$actions = (array)$actions;
2689
+		$referrer_url = empty($referrer) ? '' : $referrer;
2690
+		$referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2691
+				: '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2692
+		$button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2693
+		$default_names = array('save', 'save_and_close');
2694
+		//add in a hidden index for the current page (so save and close redirects properly)
2695
+		$this->_template_args['save_buttons'] = $referrer_url;
2696
+		foreach ($button_text as $key => $button) {
2697
+			$ref = $default_names[$key];
2698
+			$id = $this->_current_view . '_' . $ref;
2699
+			$name = ! empty($actions) ? $actions[$key] : $ref;
2700
+			$this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2701
+			if ( ! $both) {
2702
+				break;
2703
+			}
2704
+		}
2705
+	}
2706
+
2707
+
2708
+
2709
+	/**
2710
+	 * Wrapper for the protected function.  Allows plugins/addons to call this to set the form tags.
2711
+	 *
2712
+	 * @see   $this->_set_add_edit_form_tags() for details on params
2713
+	 * @since 4.6.0
2714
+	 * @param string $route
2715
+	 * @param array  $additional_hidden_fields
2716
+	 */
2717
+	public function set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2718
+	{
2719
+		$this->_set_add_edit_form_tags($route, $additional_hidden_fields);
2720
+	}
2721
+
2722
+
2723
+
2724
+	/**
2725
+	 * set form open and close tags on add/edit pages.
2726
+	 *
2727
+	 * @access protected
2728
+	 * @param string $route                    the route you want the form to direct to
2729
+	 * @param array  $additional_hidden_fields any additional hidden fields required in the form header
2730
+	 * @return void
2731
+	 */
2732
+	protected function _set_add_edit_form_tags($route = '', $additional_hidden_fields = array())
2733
+	{
2734
+		if (empty($route)) {
2735
+			$user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2736
+			$dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2737
+			EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2738
+		}
2739
+		// open form
2740
+		$this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2741
+		// add nonce
2742
+		$nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2743
+		//		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2744
+		$this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2745
+		// add REQUIRED form action
2746
+		$hidden_fields = array(
2747
+				'action' => array('type' => 'hidden', 'value' => $route),
2748
+		);
2749
+		// merge arrays
2750
+		$hidden_fields = is_array($additional_hidden_fields) ? array_merge($hidden_fields, $additional_hidden_fields) : $hidden_fields;
2751
+		// generate form fields
2752
+		$form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2753
+		// add fields to form
2754
+		foreach ((array)$form_fields as $field_name => $form_field) {
2755
+			$this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2756
+		}
2757
+		// close form
2758
+		$this->_template_args['after_admin_page_content'] = '</form>';
2759
+	}
2760
+
2761
+
2762
+
2763
+	/**
2764
+	 * Public Wrapper for _redirect_after_action() method since its
2765
+	 * discovered it would be useful for external code to have access.
2766
+	 *
2767
+	 * @see   EE_Admin_Page::_redirect_after_action() for params.
2768
+	 * @since 4.5.0
2769
+	 */
2770
+	public function redirect_after_action($success = false, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2771
+	{
2772
+		$this->_redirect_after_action($success, $what, $action_desc, $query_args, $override_overwrite);
2773
+	}
2774
+
2775
+
2776
+
2777
+	/**
2778
+	 *    _redirect_after_action
2779
+	 *
2780
+	 * @param int    $success            - whether success was for two or more records, or just one, or none
2781
+	 * @param string $what               - what the action was performed on
2782
+	 * @param string $action_desc        - what was done ie: updated, deleted, etc
2783
+	 * @param array  $query_args         - an array of query_args to be added to the URL to redirect to after the admin action is completed
2784
+	 * @param BOOL   $override_overwrite by default all EE_Error::success messages are overwritten, this allows you to override this so that they show.
2785
+	 * @access protected
2786
+	 * @return void
2787
+	 */
2788
+	protected function _redirect_after_action($success = 0, $what = 'item', $action_desc = 'processed', $query_args = array(), $override_overwrite = false)
2789
+	{
2790
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2791
+		//class name for actions/filters.
2792
+		$classname = get_class($this);
2793
+		//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
2794
+		$redirect_url = isset($query_args['page']) ? admin_url('admin.php') : $this->_admin_base_url;
2795
+		$notices = EE_Error::get_notices(false);
2796
+		// overwrite default success messages //BUT ONLY if overwrite not overridden
2797
+		if ( ! $override_overwrite || ! empty($notices['errors'])) {
2798
+			EE_Error::overwrite_success();
2799
+		}
2800
+		if ( ! empty($what) && ! empty($action_desc)) {
2801
+			// how many records affected ? more than one record ? or just one ?
2802
+			if ($success > 1 && empty($notices['errors'])) {
2803
+				// set plural msg
2804
+				EE_Error::add_success(
2805
+						sprintf(
2806
+								__('The "%s" have been successfully %s.', 'event_espresso'),
2807
+								$what,
2808
+								$action_desc
2809
+						),
2810
+						__FILE__, __FUNCTION__, __LINE__
2811
+				);
2812
+			} else if ($success == 1 && empty($notices['errors'])) {
2813
+				// set singular msg
2814
+				EE_Error::add_success(
2815
+						sprintf(
2816
+								__('The "%s" has been successfully %s.', 'event_espresso'),
2817
+								$what,
2818
+								$action_desc
2819
+						),
2820
+						__FILE__, __FUNCTION__, __LINE__
2821
+				);
2822
+			}
2823
+		}
2824
+		// check that $query_args isn't something crazy
2825
+		if ( ! is_array($query_args)) {
2826
+			$query_args = array();
2827
+		}
2828
+		/**
2829
+		 * Allow injecting actions before the query_args are modified for possible different
2830
+		 * redirections on save and close actions
2831
+		 *
2832
+		 * @since 4.2.0
2833
+		 * @param array $query_args       The original query_args array coming into the
2834
+		 *                                method.
2835
+		 */
2836
+		do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2837
+		//calculate where we're going (if we have a "save and close" button pushed)
2838
+		if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2839
+			// even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
2840
+			$parsed_url = parse_url($this->_req_data['save_and_close_referrer']);
2841
+			// regenerate query args array from referrer URL
2842
+			parse_str($parsed_url['query'], $query_args);
2843
+			// correct page and action will be in the query args now
2844
+			$redirect_url = admin_url('admin.php');
2845
+		}
2846
+		//merge any default query_args set in _default_route_query_args property
2847
+		if ( ! empty($this->_default_route_query_args) && ! $this->_is_UI_request) {
2848
+			$args_to_merge = array();
2849
+			foreach ($this->_default_route_query_args as $query_param => $query_value) {
2850
+				//is there a wp_referer array in our _default_route_query_args property?
2851
+				if ($query_param == 'wp_referer') {
2852
+					$query_value = (array)$query_value;
2853
+					foreach ($query_value as $reference => $value) {
2854
+						if (strpos($reference, 'nonce') !== false) {
2855
+							continue;
2856
+						}
2857
+						//finally we will override any arguments in the referer with
2858
+						//what might be set on the _default_route_query_args array.
2859
+						if (isset($this->_default_route_query_args[$reference])) {
2860
+							$args_to_merge[$reference] = urlencode($this->_default_route_query_args[$reference]);
2861
+						} else {
2862
+							$args_to_merge[$reference] = urlencode($value);
2863
+						}
2864
+					}
2865
+					continue;
2866
+				}
2867
+				$args_to_merge[$query_param] = $query_value;
2868
+			}
2869
+			//now let's merge these arguments but override with what was specifically sent in to the
2870
+			//redirect.
2871
+			$query_args = array_merge($args_to_merge, $query_args);
2872
+		}
2873
+		$this->_process_notices($query_args);
2874
+		// generate redirect url
2875
+		// if redirecting to anything other than the main page, add a nonce
2876
+		if (isset($query_args['action'])) {
2877
+			// manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2878
+			$query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2879
+		}
2880
+		//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).
2881
+		do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2882
+		$redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2883
+		// check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2884
+		if (defined('DOING_AJAX')) {
2885
+			$default_data = array(
2886
+					'close'        => true,
2887
+					'redirect_url' => $redirect_url,
2888
+					'where'        => 'main',
2889
+					'what'         => 'append',
2890
+			);
2891
+			$this->_template_args['success'] = $success;
2892
+			$this->_template_args['data'] = ! empty($this->_template_args['data']) ? array_merge($default_data, $this->_template_args['data']) : $default_data;
2893
+			$this->_return_json();
2894
+		}
2895
+		wp_safe_redirect($redirect_url);
2896
+		exit();
2897
+	}
2898
+
2899
+
2900
+
2901
+	/**
2902
+	 * process any notices before redirecting (or returning ajax request)
2903
+	 * This method sets the $this->_template_args['notices'] attribute;
2904
+	 *
2905
+	 * @param  array $query_args        any query args that need to be used for notice transient ('action')
2906
+	 * @param bool   $skip_route_verify This is typically used when we are processing notices REALLY early and page_routes haven't been defined yet.
2907
+	 * @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.
2908
+	 * @return void
2909
+	 */
2910
+	protected function _process_notices($query_args = array(), $skip_route_verify = false, $sticky_notices = true)
2911
+	{
2912
+		//first let's set individual error properties if doing_ajax and the properties aren't already set.
2913
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2914
+			$notices = EE_Error::get_notices(false);
2915
+			if (empty($this->_template_args['success'])) {
2916
+				$this->_template_args['success'] = isset($notices['success']) ? $notices['success'] : false;
2917
+			}
2918
+			if (empty($this->_template_args['errors'])) {
2919
+				$this->_template_args['errors'] = isset($notices['errors']) ? $notices['errors'] : false;
2920
+			}
2921
+			if (empty($this->_template_args['attention'])) {
2922
+				$this->_template_args['attention'] = isset($notices['attention']) ? $notices['attention'] : false;
2923
+			}
2924
+		}
2925
+		$this->_template_args['notices'] = EE_Error::get_notices();
2926
+		//IF this isn't ajax we need to create a transient for the notices using the route (however, overridden if $sticky_notices == true)
2927
+		if ( ! defined('DOING_AJAX') || $sticky_notices) {
2928
+			$route = isset($query_args['action']) ? $query_args['action'] : 'default';
2929
+			$this->_add_transient($route, $this->_template_args['notices'], true, $skip_route_verify);
2930
+		}
2931
+	}
2932
+
2933
+
2934
+
2935
+	/**
2936
+	 * get_action_link_or_button
2937
+	 * returns the button html for adding, editing, or deleting an item (depending on given type)
2938
+	 *
2939
+	 * @param string $action        use this to indicate which action the url is generated with.
2940
+	 * @param string $type          accepted strings must be defined in the $_labels['button'] array(as the key) property.
2941
+	 * @param array  $extra_request if the button requires extra params you can include them in $key=>$value pairs.
2942
+	 * @param string $class         Use this to give the class for the button. Defaults to 'button-primary'
2943
+	 * @param string $base_url      If this is not provided
2944
+	 *                              the _admin_base_url will be used as the default for the button base_url.
2945
+	 *                              Otherwise this value will be used.
2946
+	 * @param bool   $exclude_nonce If true then no nonce will be in the generated button link.
2947
+	 * @return string
2948
+	 * @throws \EE_Error
2949
+	 */
2950
+	public function get_action_link_or_button(
2951
+			$action,
2952
+			$type = 'add',
2953
+			$extra_request = array(),
2954
+			$class = 'button-primary',
2955
+			$base_url = '',
2956
+			$exclude_nonce = false
2957
+	) {
2958
+		//first let's validate the action (if $base_url is FALSE otherwise validation will happen further along)
2959
+		if (empty($base_url) && ! isset($this->_page_routes[$action])) {
2960
+			throw new EE_Error(
2961
+					sprintf(
2962
+							__(
2963
+									'There is no page route for given action for the button.  This action was given: %s',
2964
+									'event_espresso'
2965
+							),
2966
+							$action
2967
+					)
2968
+			);
2969
+		}
2970
+		if ( ! isset($this->_labels['buttons'][$type])) {
2971
+			throw new EE_Error(
2972
+					sprintf(
2973
+							__(
2974
+									'There is no label for the given button type (%s). Labels are set in the <code>_page_config</code> property.',
2975
+									'event_espresso'
2976
+							),
2977
+							$type
2978
+					)
2979
+			);
2980
+		}
2981
+		//finally check user access for this button.
2982
+		$has_access = $this->check_user_access($action, true);
2983
+		if ( ! $has_access) {
2984
+			return '';
2985
+		}
2986
+		$_base_url = ! $base_url ? $this->_admin_base_url : $base_url;
2987
+		$query_args = array(
2988
+				'action' => $action,
2989
+		);
2990
+		//merge extra_request args but make sure our original action takes precedence and doesn't get overwritten.
2991
+		if ( ! empty($extra_request)) {
2992
+			$query_args = array_merge($extra_request, $query_args);
2993
+		}
2994
+		$url = self::add_query_args_and_nonce($query_args, $_base_url, false, $exclude_nonce);
2995
+		return EEH_Template::get_button_or_link($url, $this->_labels['buttons'][$type], $class);
2996
+	}
2997
+
2998
+
2999
+
3000
+	/**
3001
+	 * _per_page_screen_option
3002
+	 * Utility function for adding in a per_page_option in the screen_options_dropdown.
3003
+	 *
3004
+	 * @return void
3005
+	 */
3006
+	protected function _per_page_screen_option()
3007
+	{
3008
+		$option = 'per_page';
3009
+		$args = array(
3010
+				'label'   => $this->_admin_page_title,
3011
+				'default' => 10,
3012
+				'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3013
+		);
3014
+		//ONLY add the screen option if the user has access to it.
3015
+		if ($this->check_user_access($this->_current_view, true)) {
3016
+			add_screen_option($option, $args);
3017
+		}
3018
+	}
3019
+
3020
+
3021
+
3022
+	/**
3023
+	 * set_per_page_screen_option
3024
+	 * All this does is make sure that WordPress saves any per_page screen options (if set) for the current page.
3025
+	 * we have to do this rather than running inside the 'set-screen-options' hook because it runs earlier than admin_menu.
3026
+	 *
3027
+	 * @access private
3028
+	 * @return void
3029
+	 */
3030
+	private function _set_per_page_screen_options()
3031
+	{
3032
+		if (isset($_POST['wp_screen_options']) && is_array($_POST['wp_screen_options'])) {
3033
+			check_admin_referer('screen-options-nonce', 'screenoptionnonce');
3034
+			if ( ! $user = wp_get_current_user()) {
3035
+				return;
3036
+			}
3037
+			$option = $_POST['wp_screen_options']['option'];
3038
+			$value = $_POST['wp_screen_options']['value'];
3039
+			if ($option != sanitize_key($option)) {
3040
+				return;
3041
+			}
3042
+			$map_option = $option;
3043
+			$option = str_replace('-', '_', $option);
3044
+			switch ($map_option) {
3045
+				case $this->_current_page . '_' . $this->_current_view . '_per_page':
3046
+					$value = (int)$value;
3047
+					if ($value < 1 || $value > 999) {
3048
+						return;
3049
+					}
3050
+					break;
3051
+				default:
3052
+					$value = apply_filters('FHEE__EE_Admin_Page___set_per_page_screen_options__value', false, $option, $value);
3053
+					if (false === $value) {
3054
+						return;
3055
+					}
3056
+					break;
3057
+			}
3058
+			update_user_meta($user->ID, $option, $value);
3059
+			wp_safe_redirect(remove_query_arg(array('pagenum', 'apage', 'paged'), wp_get_referer()));
3060
+			exit;
3061
+		}
3062
+	}
3063
+
3064
+
3065
+
3066
+	/**
3067
+	 * This just allows for setting the $_template_args property if it needs to be set outside the object
3068
+	 *
3069
+	 * @param array $data array that will be assigned to template args.
3070
+	 */
3071
+	public function set_template_args($data)
3072
+	{
3073
+		$this->_template_args = array_merge($this->_template_args, (array)$data);
3074
+	}
3075
+
3076
+
3077
+
3078
+	/**
3079
+	 * This makes available the WP transient system for temporarily moving data between routes
3080
+	 *
3081
+	 * @access protected
3082
+	 * @param string $route             the route that should receive the transient
3083
+	 * @param array  $data              the data that gets sent
3084
+	 * @param bool   $notices           If this is for notices then we use this to indicate so, otherwise its just a normal route transient.
3085
+	 * @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.
3086
+	 * @return void
3087
+	 */
3088
+	protected function _add_transient($route, $data, $notices = false, $skip_route_verify = false)
3089
+	{
3090
+		$user_id = get_current_user_id();
3091
+		if ( ! $skip_route_verify) {
3092
+			$this->_verify_route($route);
3093
+		}
3094
+		//now let's set the string for what kind of transient we're setting
3095
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3096
+		$data = $notices ? array('notices' => $data) : $data;
3097
+		//is there already a transient for this route?  If there is then let's ADD to that transient
3098
+		$existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3099
+		if ($existing) {
3100
+			$data = array_merge((array)$data, (array)$existing);
3101
+		}
3102
+		if (is_multisite() && is_network_admin()) {
3103
+			set_site_transient($transient, $data, 8);
3104
+		} else {
3105
+			set_transient($transient, $data, 8);
3106
+		}
3107
+	}
3108
+
3109
+
3110
+
3111
+	/**
3112
+	 * this retrieves the temporary transient that has been set for moving data between routes.
3113
+	 *
3114
+	 * @param bool $notices true we get notices transient. False we just return normal route transient
3115
+	 * @return mixed data
3116
+	 */
3117
+	protected function _get_transient($notices = false, $route = false)
3118
+	{
3119
+		$user_id = get_current_user_id();
3120
+		$route = ! $route ? $this->_req_action : $route;
3121
+		$transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3122
+		$data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3123
+		//delete transient after retrieval (just in case it hasn't expired);
3124
+		if (is_multisite() && is_network_admin()) {
3125
+			delete_site_transient($transient);
3126
+		} else {
3127
+			delete_transient($transient);
3128
+		}
3129
+		return $notices && isset($data['notices']) ? $data['notices'] : $data;
3130
+	}
3131
+
3132
+
3133
+
3134
+	/**
3135
+	 * 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.
3136
+	 * 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.)
3137
+	 *
3138
+	 * @return void
3139
+	 */
3140
+	protected function _transient_garbage_collection()
3141
+	{
3142
+		global $wpdb;
3143
+		//retrieve all existing transients
3144
+		$query = "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%rte_tx_%' OR option_name LIKE '%rte_n_tx_%'";
3145
+		if ($results = $wpdb->get_results($query)) {
3146
+			foreach ($results as $result) {
3147
+				$transient = str_replace('_transient_', '', $result->option_name);
3148
+				get_transient($transient);
3149
+				if (is_multisite() && is_network_admin()) {
3150
+					get_site_transient($transient);
3151
+				}
3152
+			}
3153
+		}
3154
+	}
3155
+
3156
+
3157
+
3158
+	/**
3159
+	 * get_view
3160
+	 *
3161
+	 * @access public
3162
+	 * @return string content of _view property
3163
+	 */
3164
+	public function get_view()
3165
+	{
3166
+		return $this->_view;
3167
+	}
3168
+
3169
+
3170
+
3171
+	/**
3172
+	 * getter for the protected $_views property
3173
+	 *
3174
+	 * @return array
3175
+	 */
3176
+	public function get_views()
3177
+	{
3178
+		return $this->_views;
3179
+	}
3180
+
3181
+
3182
+
3183
+	/**
3184
+	 * get_current_page
3185
+	 *
3186
+	 * @access public
3187
+	 * @return string _current_page property value
3188
+	 */
3189
+	public function get_current_page()
3190
+	{
3191
+		return $this->_current_page;
3192
+	}
3193
+
3194
+
3195
+
3196
+	/**
3197
+	 * get_current_view
3198
+	 *
3199
+	 * @access public
3200
+	 * @return string _current_view property value
3201
+	 */
3202
+	public function get_current_view()
3203
+	{
3204
+		return $this->_current_view;
3205
+	}
3206
+
3207
+
3208
+
3209
+	/**
3210
+	 * get_current_screen
3211
+	 *
3212
+	 * @access public
3213
+	 * @return object The current WP_Screen object
3214
+	 */
3215
+	public function get_current_screen()
3216
+	{
3217
+		return $this->_current_screen;
3218
+	}
3219
+
3220
+
3221
+
3222
+	/**
3223
+	 * get_current_page_view_url
3224
+	 *
3225
+	 * @access public
3226
+	 * @return string This returns the url for the current_page_view.
3227
+	 */
3228
+	public function get_current_page_view_url()
3229
+	{
3230
+		return $this->_current_page_view_url;
3231
+	}
3232
+
3233
+
3234
+
3235
+	/**
3236
+	 * just returns the _req_data property
3237
+	 *
3238
+	 * @return array
3239
+	 */
3240
+	public function get_request_data()
3241
+	{
3242
+		return $this->_req_data;
3243
+	}
3244
+
3245
+
3246
+
3247
+	/**
3248
+	 * returns the _req_data protected property
3249
+	 *
3250
+	 * @return string
3251
+	 */
3252
+	public function get_req_action()
3253
+	{
3254
+		return $this->_req_action;
3255
+	}
3256
+
3257
+
3258
+
3259
+	/**
3260
+	 * @return bool  value of $_is_caf property
3261
+	 */
3262
+	public function is_caf()
3263
+	{
3264
+		return $this->_is_caf;
3265
+	}
3266
+
3267
+
3268
+
3269
+	/**
3270
+	 * @return mixed
3271
+	 */
3272
+	public function default_espresso_metaboxes()
3273
+	{
3274
+		return $this->_default_espresso_metaboxes;
3275
+	}
3276
+
3277
+
3278
+
3279
+	/**
3280
+	 * @return mixed
3281
+	 */
3282
+	public function admin_base_url()
3283
+	{
3284
+		return $this->_admin_base_url;
3285
+	}
3286
+
3287
+
3288
+
3289
+	/**
3290
+	 * @return mixed
3291
+	 */
3292
+	public function wp_page_slug()
3293
+	{
3294
+		return $this->_wp_page_slug;
3295
+	}
3296
+
3297
+
3298
+
3299
+	/**
3300
+	 * updates  espresso configuration settings
3301
+	 *
3302
+	 * @access    protected
3303
+	 * @param string                   $tab
3304
+	 * @param EE_Config_Base|EE_Config $config
3305
+	 * @param string                   $file file where error occurred
3306
+	 * @param string                   $func function  where error occurred
3307
+	 * @param string                   $line line no where error occurred
3308
+	 * @return boolean
3309
+	 */
3310
+	protected function _update_espresso_configuration($tab, $config, $file = '', $func = '', $line = '')
3311
+	{
3312
+		//remove any options that are NOT going to be saved with the config settings.
3313
+		if (isset($config->core->ee_ueip_optin)) {
3314
+			$config->core->ee_ueip_has_notified = true;
3315
+			// TODO: remove the following two lines and make sure values are migrated from 3.1
3316
+			update_option('ee_ueip_optin', $config->core->ee_ueip_optin);
3317
+			update_option('ee_ueip_has_notified', true);
3318
+		}
3319
+		// and save it (note we're also doing the network save here)
3320
+		$net_saved = is_main_site() ? EE_Network_Config::instance()->update_config(false, false) : true;
3321
+		$config_saved = EE_Config::instance()->update_espresso_config(false, false);
3322
+		if ($config_saved && $net_saved) {
3323
+			EE_Error::add_success(sprintf(__('"%s" have been successfully updated.', 'event_espresso'), $tab));
3324
+			return true;
3325
+		} else {
3326
+			EE_Error::add_error(sprintf(__('The "%s" were not updated.', 'event_espresso'), $tab), $file, $func, $line);
3327
+			return false;
3328
+		}
3329
+	}
3330
+
3331
+
3332
+
3333
+	/**
3334
+	 * Returns an array to be used for EE_FOrm_Fields.helper.php's select_input as the $values argument.
3335
+	 *
3336
+	 * @return array
3337
+	 */
3338
+	public function get_yes_no_values()
3339
+	{
3340
+		return $this->_yes_no_values;
3341
+	}
3342
+
3343
+
3344
+
3345
+	protected function _get_dir()
3346
+	{
3347
+		$reflector = new ReflectionClass(get_class($this));
3348
+		return dirname($reflector->getFileName());
3349
+	}
3350
+
3351
+
3352
+
3353
+	/**
3354
+	 * A helper for getting a "next link".
3355
+	 *
3356
+	 * @param string $url   The url to link to
3357
+	 * @param string $class The class to use.
3358
+	 * @return string
3359
+	 */
3360
+	protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3361
+	{
3362
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3363
+	}
3364
+
3365
+
3366
+
3367
+	/**
3368
+	 * A helper for getting a "previous link".
3369
+	 *
3370
+	 * @param string $url   The url to link to
3371
+	 * @param string $class The class to use.
3372
+	 * @return string
3373
+	 */
3374
+	protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3375
+	{
3376
+		return '<a class="' . $class . '" href="' . $url . '"></a>';
3377
+	}
3378
+
3379
+
3380
+
3381
+
3382
+
3383
+
3384
+
3385
+	//below are some messages related methods that should be available across the EE_Admin system.  Note, these methods are NOT page specific
3386
+	/**
3387
+	 * 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
3388
+	 * array.
3389
+	 *
3390
+	 * @return bool success/fail
3391
+	 */
3392
+	protected function _process_resend_registration()
3393
+	{
3394
+		$this->_template_args['success'] = EED_Messages::process_resend($this->_req_data);
3395
+		do_action('AHEE__EE_Admin_Page___process_resend_registration', $this->_template_args['success'], $this->_req_data);
3396
+		return $this->_template_args['success'];
3397
+	}
3398
+
3399
+
3400
+
3401
+	/**
3402
+	 * This automatically processes any payment message notifications when manual payment has been applied.
3403
+	 *
3404
+	 * @access protected
3405
+	 * @param \EE_Payment $payment
3406
+	 * @return bool success/fail
3407
+	 */
3408
+	protected function _process_payment_notification(EE_Payment $payment)
3409
+	{
3410
+		add_filter('FHEE__EE_Payment_Processor__process_registration_payments__display_notifications', '__return_true');
3411
+		do_action('AHEE__EE_Admin_Page___process_admin_payment_notification', $payment);
3412
+		$this->_template_args['success'] = apply_filters('FHEE__EE_Admin_Page___process_admin_payment_notification__success', false, $payment);
3413
+		return $this->_template_args['success'];
3414
+	}
3415 3415
 
3416 3416
 
3417 3417
 }
Please login to merge, or discard this patch.
Spacing   +145 added lines, -145 removed lines patch added patch discarded remove patch
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
         $this->_current_page = ! empty($_GET['page']) ? sanitize_key($_GET['page']) : '';
475 475
         $this->page_folder = strtolower(str_replace('_Admin_Page', '', str_replace('Extend_', '', get_class($this))));
476 476
         global $ee_menu_slugs;
477
-        $ee_menu_slugs = (array)$ee_menu_slugs;
477
+        $ee_menu_slugs = (array) $ee_menu_slugs;
478 478
         if (( ! $this->_current_page || ! isset($ee_menu_slugs[$this->_current_page])) && ! defined('DOING_AJAX')) {
479 479
             return;
480 480
         }
@@ -489,7 +489,7 @@  discard block
 block discarded – undo
489 489
         //however if we are doing_ajax and we've got a 'route' set then that's what the req_action will be
490 490
         $this->_req_action = defined('DOING_AJAX') && isset($this->_req_data['route']) ? $this->_req_data['route'] : $this->_req_action;
491 491
         $this->_current_view = $this->_req_action;
492
-        $this->_req_nonce = $this->_req_action . '_nonce';
492
+        $this->_req_nonce = $this->_req_action.'_nonce';
493 493
         $this->_define_page_props();
494 494
         $this->_current_page_view_url = add_query_arg(array('page' => $this->_current_page, 'action' => $this->_current_view), $this->_admin_base_url);
495 495
         //default things
@@ -510,11 +510,11 @@  discard block
 block discarded – undo
510 510
             $this->_extend_page_config_for_cpt();
511 511
         }
512 512
         //filter routes and page_config so addons can add their stuff. Filtering done per class
513
-        $this->_page_routes = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_routes', $this->_page_routes, $this);
514
-        $this->_page_config = apply_filters('FHEE__' . get_class($this) . '__page_setup__page_config', $this->_page_config, $this);
513
+        $this->_page_routes = apply_filters('FHEE__'.get_class($this).'__page_setup__page_routes', $this->_page_routes, $this);
514
+        $this->_page_config = apply_filters('FHEE__'.get_class($this).'__page_setup__page_config', $this->_page_config, $this);
515 515
         //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
516
-        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view)) {
517
-            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_' . $this->_current_view), 10, 2);
516
+        if (method_exists($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view)) {
517
+            add_action('AHEE__EE_Admin_Page__route_admin_request', array($this, 'AHEE__EE_Admin_Page__route_admin_request_'.$this->_current_view), 10, 2);
518 518
         }
519 519
         //next route only if routing enabled
520 520
         if ($this->_routing && ! defined('DOING_AJAX')) {
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
             if ($this->_is_UI_request) {
525 525
                 //admin_init stuff - global, all views for this page class, specific view
526 526
                 add_action('admin_init', array($this, 'admin_init'), 10);
527
-                if (method_exists($this, 'admin_init_' . $this->_current_view)) {
528
-                    add_action('admin_init', array($this, 'admin_init_' . $this->_current_view), 15);
527
+                if (method_exists($this, 'admin_init_'.$this->_current_view)) {
528
+                    add_action('admin_init', array($this, 'admin_init_'.$this->_current_view), 15);
529 529
                 }
530 530
             } else {
531 531
                 //hijack regular WP loading and route admin request immediately
@@ -545,17 +545,17 @@  discard block
 block discarded – undo
545 545
      */
546 546
     private function _do_other_page_hooks()
547 547
     {
548
-        $registered_pages = apply_filters('FHEE_do_other_page_hooks_' . $this->page_slug, array());
548
+        $registered_pages = apply_filters('FHEE_do_other_page_hooks_'.$this->page_slug, array());
549 549
         foreach ($registered_pages as $page) {
550 550
             //now let's setup the file name and class that should be present
551 551
             $classname = str_replace('.class.php', '', $page);
552 552
             //autoloaders should take care of loading file
553 553
             if ( ! class_exists($classname)) {
554
-                $error_msg[] = sprintf( esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
554
+                $error_msg[] = sprintf(esc_html__('Something went wrong with loading the %s admin hooks page.', 'event_espresso'), $page);
555 555
                 $error_msg[] = $error_msg[0]
556 556
                                . "\r\n"
557
-                               . sprintf( esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
558
-                                'event_espresso'), $page, '<br />', '<strong>' . $classname . '</strong>');
557
+                               . sprintf(esc_html__('There is no class in place for the %1$s admin hooks page.%2$sMake sure you have %3$s defined. If this is a non-EE-core admin page then you also must have an autoloader in place for your class',
558
+                                'event_espresso'), $page, '<br />', '<strong>'.$classname.'</strong>');
559 559
                 throw new EE_Error(implode('||', $error_msg));
560 560
             }
561 561
             $a = new ReflectionClass($classname);
@@ -591,13 +591,13 @@  discard block
 block discarded – undo
591 591
         //load admin_notices - global, page class, and view specific
592 592
         add_action('admin_notices', array($this, 'admin_notices_global'), 5);
593 593
         add_action('admin_notices', array($this, 'admin_notices'), 10);
594
-        if (method_exists($this, 'admin_notices_' . $this->_current_view)) {
595
-            add_action('admin_notices', array($this, 'admin_notices_' . $this->_current_view), 15);
594
+        if (method_exists($this, 'admin_notices_'.$this->_current_view)) {
595
+            add_action('admin_notices', array($this, 'admin_notices_'.$this->_current_view), 15);
596 596
         }
597 597
         //load network admin_notices - global, page class, and view specific
598 598
         add_action('network_admin_notices', array($this, 'network_admin_notices_global'), 5);
599
-        if (method_exists($this, 'network_admin_notices_' . $this->_current_view)) {
600
-            add_action('network_admin_notices', array($this, 'network_admin_notices_' . $this->_current_view));
599
+        if (method_exists($this, 'network_admin_notices_'.$this->_current_view)) {
600
+            add_action('network_admin_notices', array($this, 'network_admin_notices_'.$this->_current_view));
601 601
         }
602 602
         //this will save any per_page screen options if they are present
603 603
         $this->_set_per_page_screen_options();
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
         //add screen options - global, page child class, and view specific
610 610
         $this->_add_global_screen_options();
611 611
         $this->_add_screen_options();
612
-        if (method_exists($this, '_add_screen_options_' . $this->_current_view)) {
613
-            call_user_func(array($this, '_add_screen_options_' . $this->_current_view));
612
+        if (method_exists($this, '_add_screen_options_'.$this->_current_view)) {
613
+            call_user_func(array($this, '_add_screen_options_'.$this->_current_view));
614 614
         }
615 615
         //add help tab(s) and tours- set via page_config and qtips.
616 616
         $this->_add_help_tour();
@@ -619,31 +619,31 @@  discard block
 block discarded – undo
619 619
         //add feature_pointers - global, page child class, and view specific
620 620
         $this->_add_feature_pointers();
621 621
         $this->_add_global_feature_pointers();
622
-        if (method_exists($this, '_add_feature_pointer_' . $this->_current_view)) {
623
-            call_user_func(array($this, '_add_feature_pointer_' . $this->_current_view));
622
+        if (method_exists($this, '_add_feature_pointer_'.$this->_current_view)) {
623
+            call_user_func(array($this, '_add_feature_pointer_'.$this->_current_view));
624 624
         }
625 625
         //enqueue scripts/styles - global, page class, and view specific
626 626
         add_action('admin_enqueue_scripts', array($this, 'load_global_scripts_styles'), 5);
627 627
         add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles'), 10);
628
-        if (method_exists($this, 'load_scripts_styles_' . $this->_current_view)) {
629
-            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_' . $this->_current_view), 15);
628
+        if (method_exists($this, 'load_scripts_styles_'.$this->_current_view)) {
629
+            add_action('admin_enqueue_scripts', array($this, 'load_scripts_styles_'.$this->_current_view), 15);
630 630
         }
631 631
         add_action('admin_enqueue_scripts', array($this, 'admin_footer_scripts_eei18n_js_strings'), 100);
632 632
         //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
633 633
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_global'), 99);
634 634
         add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts'), 100);
635
-        if (method_exists($this, 'admin_footer_scripts_' . $this->_current_view)) {
636
-            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_' . $this->_current_view), 101);
635
+        if (method_exists($this, 'admin_footer_scripts_'.$this->_current_view)) {
636
+            add_action('admin_print_footer_scripts', array($this, 'admin_footer_scripts_'.$this->_current_view), 101);
637 637
         }
638 638
         //admin footer scripts
639 639
         add_action('admin_footer', array($this, 'admin_footer_global'), 99);
640 640
         add_action('admin_footer', array($this, 'admin_footer'), 100);
641
-        if (method_exists($this, 'admin_footer_' . $this->_current_view)) {
642
-            add_action('admin_footer', array($this, 'admin_footer_' . $this->_current_view), 101);
641
+        if (method_exists($this, 'admin_footer_'.$this->_current_view)) {
642
+            add_action('admin_footer', array($this, 'admin_footer_'.$this->_current_view), 101);
643 643
         }
644 644
         do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load', $this->page_slug);
645 645
         //targeted hook
646
-        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__' . $this->page_slug . '__' . $this->_req_action);
646
+        do_action('FHEE__EE_Admin_Page___load_page_dependencies__after_load__'.$this->page_slug.'__'.$this->_req_action);
647 647
     }
648 648
 
649 649
 
@@ -719,7 +719,7 @@  discard block
 block discarded – undo
719 719
             // user error msg
720 720
             $error_msg = sprintf(__('No page routes have been set for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
721 721
             // developer error msg
722
-            $error_msg .= '||' . $error_msg . __(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
722
+            $error_msg .= '||'.$error_msg.__(' Make sure the "set_page_routes()" method exists, and is setting the "_page_routes" array properly.', 'event_espresso');
723 723
             throw new EE_Error($error_msg);
724 724
         }
725 725
         // and that the requested page route exists
@@ -730,7 +730,7 @@  discard block
 block discarded – undo
730 730
             // user error msg
731 731
             $error_msg = sprintf(__('The requested page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
732 732
             // developer error msg
733
-            $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
+            $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);
734 734
             throw new EE_Error($error_msg);
735 735
         }
736 736
         // and that a default route exists
@@ -738,7 +738,7 @@  discard block
 block discarded – undo
738 738
             // user error msg
739 739
             $error_msg = sprintf(__('A default page route has not been set for the % admin page.', 'event_espresso'), $this->_admin_page_title);
740 740
             // developer error msg
741
-            $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
+            $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');
742 742
             throw new EE_Error($error_msg);
743 743
         }
744 744
         //first lets' catch if the UI request has EVER been set.
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
             // user error msg
768 768
             $error_msg = sprintf(__('The given page route does not exist for the %s admin page.', 'event_espresso'), $this->_admin_page_title);
769 769
             // developer error msg
770
-            $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
+            $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);
771 771
             throw new EE_Error($error_msg);
772 772
         }
773 773
     }
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
             // these are not the droids you are looking for !!!
790 790
             $msg = sprintf(__('%sNonce Fail.%s', 'event_espresso'), '<a href="http://www.youtube.com/watch?v=56_S0WeTkzs">', '</a>');
791 791
             if (WP_DEBUG) {
792
-                $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
+                $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__);
793 793
             }
794 794
             if ( ! defined('DOING_AJAX')) {
795 795
                 wp_die($msg);
@@ -967,7 +967,7 @@  discard block
 block discarded – undo
967 967
                 if (strpos($key, 'nonce') !== false) {
968 968
                     continue;
969 969
                 }
970
-                $args['wp_referer[' . $key . ']'] = $value;
970
+                $args['wp_referer['.$key.']'] = $value;
971 971
             }
972 972
         }
973 973
         return EEH_URL::add_query_args_and_nonce($args, $url, $exclude_nonce);
@@ -1013,7 +1013,7 @@  discard block
 block discarded – undo
1013 1013
                     if ($tour instanceof EE_Help_Tour_final_stop) {
1014 1014
                         continue;
1015 1015
                     }
1016
-                    $tb[] = '<button id="trigger-tour-' . $tour->get_slug() . '" class="button-primary trigger-ee-help-tour">' . $tour->get_label() . '</button>';
1016
+                    $tb[] = '<button id="trigger-tour-'.$tour->get_slug().'" class="button-primary trigger-ee-help-tour">'.$tour->get_label().'</button>';
1017 1017
                 }
1018 1018
                 $tour_buttons .= implode('<br />', $tb);
1019 1019
                 $tour_buttons .= '</div></div>';
@@ -1025,7 +1025,7 @@  discard block
 block discarded – undo
1025 1025
                     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',
1026 1026
                             'event_espresso'), $config['help_sidebar'], get_class($this)));
1027 1027
                 }
1028
-                $content = apply_filters('FHEE__' . get_class($this) . '__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1028
+                $content = apply_filters('FHEE__'.get_class($this).'__add_help_tabs__help_sidebar', call_user_func(array($this, $config['help_sidebar'])));
1029 1029
                 $content .= $tour_buttons; //add help tour buttons.
1030 1030
                 //do we have any help tours setup?  Cause if we do we want to add the buttons
1031 1031
                 $this->_current_screen->set_help_sidebar($content);
@@ -1038,13 +1038,13 @@  discard block
 block discarded – undo
1038 1038
             if ( ! isset($config['help_tabs']) && ! empty($tour_buttons)) {
1039 1039
                 $_ht['id'] = $this->page_slug;
1040 1040
                 $_ht['title'] = __('Help Tours', 'event_espresso');
1041
-                $_ht['content'] = '<p>' . __('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso') . '</p>';
1041
+                $_ht['content'] = '<p>'.__('The buttons to the right allow you to start/restart any help tours available for this page', 'event_espresso').'</p>';
1042 1042
                 $this->_current_screen->add_help_tab($_ht);
1043 1043
             }/**/
1044 1044
             if ( ! isset($config['help_tabs'])) {
1045 1045
                 return;
1046 1046
             } //no help tabs for this route
1047
-            foreach ((array)$config['help_tabs'] as $tab_id => $cfg) {
1047
+            foreach ((array) $config['help_tabs'] as $tab_id => $cfg) {
1048 1048
                 //we're here so there ARE help tabs!
1049 1049
                 //make sure we've got what we need
1050 1050
                 if ( ! isset($cfg['title'])) {
@@ -1059,9 +1059,9 @@  discard block
 block discarded – undo
1059 1059
                     $content = ! empty($cfg['content']) ? $cfg['content'] : null;
1060 1060
                     //second priority goes to filename
1061 1061
                 } else if ( ! empty($cfg['filename'])) {
1062
-                    $file_path = $this->_get_dir() . '/help_tabs/' . $cfg['filename'] . '.help_tab.php';
1062
+                    $file_path = $this->_get_dir().'/help_tabs/'.$cfg['filename'].'.help_tab.php';
1063 1063
                     //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)
1064
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tabs/' . $cfg['filename'] . '.help_tab.php' : $file_path;
1064
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tabs/'.$cfg['filename'].'.help_tab.php' : $file_path;
1065 1065
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1066 1066
                     if ( ! is_readable($file_path) && ! isset($cfg['callback'])) {
1067 1067
                         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',
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
                     return;
1081 1081
                 }
1082 1082
                 //setup config array for help tab method
1083
-                $id = $this->page_slug . '-' . $this->_req_action . '-' . $tab_id;
1083
+                $id = $this->page_slug.'-'.$this->_req_action.'-'.$tab_id;
1084 1084
                 $_ht = array(
1085 1085
                         'id'       => $id,
1086 1086
                         'title'    => $cfg['title'],
@@ -1118,9 +1118,9 @@  discard block
 block discarded – undo
1118 1118
             }
1119 1119
             if (isset($config['help_tour'])) {
1120 1120
                 foreach ($config['help_tour'] as $tour) {
1121
-                    $file_path = $this->_get_dir() . '/help_tours/' . $tour . '.class.php';
1121
+                    $file_path = $this->_get_dir().'/help_tours/'.$tour.'.class.php';
1122 1122
                     //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
1123
-                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES . basename($this->_get_dir()) . '/help_tours/' . $tour . '.class.php' : $file_path;
1123
+                    $file_path = ! is_readable($file_path) ? EE_ADMIN_PAGES.basename($this->_get_dir()).'/help_tours/'.$tour.'.class.php' : $file_path;
1124 1124
                     //if file is STILL not readable then let's do a EE_Error so its more graceful than a fatal error.
1125 1125
                     if ( ! is_readable($file_path)) {
1126 1126
                         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'),
@@ -1130,7 +1130,7 @@  discard block
 block discarded – undo
1130 1130
                     require_once $file_path;
1131 1131
                     if ( ! class_exists($tour)) {
1132 1132
                         $error_msg[] = sprintf(__('Something went wrong with loading the %s Help Tour Class.', 'event_espresso'), $tour);
1133
-                        $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.',
1133
+                        $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.',
1134 1134
                                         'event_espresso'), $tour, '<br />', $tour, $this->_req_action, get_class($this));
1135 1135
                         throw new EE_Error(implode('||', $error_msg));
1136 1136
                     }
@@ -1162,11 +1162,11 @@  discard block
 block discarded – undo
1162 1162
     protected function _add_qtips()
1163 1163
     {
1164 1164
         if (isset($this->_route_config['qtips'])) {
1165
-            $qtips = (array)$this->_route_config['qtips'];
1165
+            $qtips = (array) $this->_route_config['qtips'];
1166 1166
             //load qtip loader
1167 1167
             $path = array(
1168
-                    $this->_get_dir() . '/qtips/',
1169
-                    EE_ADMIN_PAGES . basename($this->_get_dir()) . '/qtips/',
1168
+                    $this->_get_dir().'/qtips/',
1169
+                    EE_ADMIN_PAGES.basename($this->_get_dir()).'/qtips/',
1170 1170
             );
1171 1171
             EEH_Qtip_Loader::instance()->register($qtips, $path);
1172 1172
         }
@@ -1196,11 +1196,11 @@  discard block
 block discarded – undo
1196 1196
             if ( ! $this->check_user_access($slug, true)) {
1197 1197
                 continue;
1198 1198
             } //no nav tab becasue current user does not have access.
1199
-            $css_class = isset($config['css_class']) ? $config['css_class'] . ' ' : '';
1199
+            $css_class = isset($config['css_class']) ? $config['css_class'].' ' : '';
1200 1200
             $this->_nav_tabs[$slug] = array(
1201 1201
                     'url'       => isset($config['nav']['url']) ? $config['nav']['url'] : self::add_query_args_and_nonce(array('action' => $slug), $this->_admin_base_url),
1202 1202
                     'link_text' => isset($config['nav']['label']) ? $config['nav']['label'] : ucwords(str_replace('_', ' ', $slug)),
1203
-                    'css_class' => $this->_req_action == $slug ? $css_class . 'nav-tab-active' : $css_class,
1203
+                    'css_class' => $this->_req_action == $slug ? $css_class.'nav-tab-active' : $css_class,
1204 1204
                     'order'     => isset($config['nav']['order']) ? $config['nav']['order'] : $i,
1205 1205
             );
1206 1206
             $i++;
@@ -1263,11 +1263,11 @@  discard block
 block discarded – undo
1263 1263
             $capability = empty($capability) ? 'manage_options' : $capability;
1264 1264
         }
1265 1265
         $id = is_array($this->_route) && ! empty($this->_route['obj_id']) ? $this->_route['obj_id'] : 0;
1266
-        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug . '_' . $route_to_check, $id)) && ! defined('DOING_AJAX')) {
1266
+        if (( ! function_exists('is_admin') || ! EE_Registry::instance()->CAP->current_user_can($capability, $this->page_slug.'_'.$route_to_check, $id)) && ! defined('DOING_AJAX')) {
1267 1267
             if ($verify_only) {
1268 1268
                 return false;
1269 1269
             } else {
1270
-                if ( is_user_logged_in() ) {
1270
+                if (is_user_logged_in()) {
1271 1271
                     wp_die(__('You do not have access to this route.', 'event_espresso'));
1272 1272
                 } else {
1273 1273
                     return false;
@@ -1359,7 +1359,7 @@  discard block
 block discarded – undo
1359 1359
     public function admin_footer_global()
1360 1360
     {
1361 1361
         //dialog container for dialog helper
1362
-        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">' . "\n";
1362
+        $d_cont = '<div class="ee-admin-dialog-container auto-hide hidden">'."\n";
1363 1363
         $d_cont .= '<div class="ee-notices"></div>';
1364 1364
         $d_cont .= '<div class="ee-admin-dialog-container-inner-content"></div>';
1365 1365
         $d_cont .= '</div>';
@@ -1369,7 +1369,7 @@  discard block
 block discarded – undo
1369 1369
             echo implode('<br />', $this->_help_tour[$this->_req_action]);
1370 1370
         }
1371 1371
         //current set timezone for timezone js
1372
-        echo '<span id="current_timezone" class="hidden">' . EEH_DTT_Helper::get_timezone() . '</span>';
1372
+        echo '<span id="current_timezone" class="hidden">'.EEH_DTT_Helper::get_timezone().'</span>';
1373 1373
     }
1374 1374
 
1375 1375
 
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
     {
1395 1395
         $content = '';
1396 1396
         $help_array = empty($help_array) ? $this->_get_help_content() : $help_array;
1397
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_help_popup.template.php';
1397
+        $template_path = EE_ADMIN_TEMPLATE.'admin_help_popup.template.php';
1398 1398
         //loop through the array and setup content
1399 1399
         foreach ($help_array as $trigger => $help) {
1400 1400
             //make sure the array is setup properly
@@ -1428,7 +1428,7 @@  discard block
 block discarded – undo
1428 1428
     private function _get_help_content()
1429 1429
     {
1430 1430
         //what is the method we're looking for?
1431
-        $method_name = '_help_popup_content_' . $this->_req_action;
1431
+        $method_name = '_help_popup_content_'.$this->_req_action;
1432 1432
         //if method doesn't exist let's get out.
1433 1433
         if ( ! method_exists($this, $method_name)) {
1434 1434
             return array();
@@ -1472,8 +1472,8 @@  discard block
 block discarded – undo
1472 1472
             $help_content = $this->_set_help_popup_content($help_array, false);
1473 1473
         }
1474 1474
         //let's setup the trigger
1475
-        $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>';
1476
-        $content = $content . $help_content;
1475
+        $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>';
1476
+        $content = $content.$help_content;
1477 1477
         if ($display) {
1478 1478
             echo $content;
1479 1479
         } else {
@@ -1533,32 +1533,32 @@  discard block
 block discarded – undo
1533 1533
             add_action('admin_head', array($this, 'add_xdebug_style'));
1534 1534
         }
1535 1535
         //register all styles
1536
-        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);
1537
-        wp_register_style('ee-admin-css', EE_ADMIN_URL . 'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1536
+        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);
1537
+        wp_register_style('ee-admin-css', EE_ADMIN_URL.'assets/ee-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
1538 1538
         //helpers styles
1539
-        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1539
+        wp_register_style('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.css', array(), EVENT_ESPRESSO_VERSION);
1540 1540
         //enqueue global styles
1541 1541
         wp_enqueue_style('ee-admin-css');
1542 1542
         /** SCRIPTS **/
1543 1543
         //register all scripts
1544
-        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL . 'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1545
-        wp_register_script('ee-dialog', EE_ADMIN_URL . 'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1546
-        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);
1547
-        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);
1544
+        wp_register_script('espresso_core', EE_GLOBAL_ASSETS_URL.'scripts/espresso_core.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1545
+        wp_register_script('ee-dialog', EE_ADMIN_URL.'assets/ee-dialog-helper.js', array('jquery', 'jquery-ui-draggable'), EVENT_ESPRESSO_VERSION, true);
1546
+        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);
1547
+        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);
1548 1548
         // register jQuery Validate - see /includes/functions/wp_hooks.php
1549 1549
         add_filter('FHEE_load_jquery_validate', '__return_true');
1550 1550
         add_filter('FHEE_load_joyride', '__return_true');
1551 1551
         //script for sorting tables
1552
-        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);
1552
+        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);
1553 1553
         //script for parsing uri's
1554
-        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL . 'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1554
+        wp_register_script('ee-parse-uri', EE_GLOBAL_ASSETS_URL.'scripts/parseuri.js', array(), EVENT_ESPRESSO_VERSION, true);
1555 1555
         //and parsing associative serialized form elements
1556
-        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL . 'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1556
+        wp_register_script('ee-serialize-full-array', EE_GLOBAL_ASSETS_URL.'scripts/jquery.serializefullarray.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1557 1557
         //helpers scripts
1558
-        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL . 'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1559
-        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL . 'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1560
-        wp_register_script('ee-moment', EE_THIRD_PARTY_URL . 'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1561
-        wp_register_script('ee-datepicker', EE_ADMIN_URL . 'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1558
+        wp_register_script('ee-text-links', EE_PLUGIN_DIR_URL.'core/helpers/assets/ee_text_list_helper.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
1559
+        wp_register_script('ee-moment-core', EE_THIRD_PARTY_URL.'moment/moment-with-locales.min.js', array(), EVENT_ESPRESSO_VERSION, true);
1560
+        wp_register_script('ee-moment', EE_THIRD_PARTY_URL.'moment/moment-timezone-with-data.min.js', array('ee-moment-core'), EVENT_ESPRESSO_VERSION, true);
1561
+        wp_register_script('ee-datepicker', EE_ADMIN_URL.'assets/ee-datepicker.js', array('jquery-ui-timepicker-addon', 'ee-moment'), EVENT_ESPRESSO_VERSION, true);
1562 1562
         //google charts
1563 1563
         wp_register_script('google-charts', 'https://www.gstatic.com/charts/loader.js', array(), EVENT_ESPRESSO_VERSION, false);
1564 1564
         //enqueue global scripts
@@ -1579,7 +1579,7 @@  discard block
 block discarded – undo
1579 1579
          */
1580 1580
         if ( ! empty($this->_help_tour)) {
1581 1581
             //register the js for kicking things off
1582
-            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL . 'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1582
+            wp_enqueue_script('ee-help-tour', EE_ADMIN_URL.'assets/ee-help-tour.js', array('jquery-joyride'), EVENT_ESPRESSO_VERSION, true);
1583 1583
             //setup tours for the js tour object
1584 1584
             foreach ($this->_help_tour['tours'] as $tour) {
1585 1585
                 $tours[] = array(
@@ -1678,17 +1678,17 @@  discard block
 block discarded – undo
1678 1678
             return;
1679 1679
         } //not a list_table view so get out.
1680 1680
         //list table functions are per view specific (because some admin pages might have more than one listtable!)
1681
-        if (call_user_func(array($this, '_set_list_table_views_' . $this->_req_action)) === false) {
1681
+        if (call_user_func(array($this, '_set_list_table_views_'.$this->_req_action)) === false) {
1682 1682
             //user error msg
1683 1683
             $error_msg = __('An error occurred. The requested list table views could not be found.', 'event_espresso');
1684 1684
             //developer error msg
1685
-            $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'),
1686
-                            $this->_req_action, '_set_list_table_views_' . $this->_req_action);
1685
+            $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'),
1686
+                            $this->_req_action, '_set_list_table_views_'.$this->_req_action);
1687 1687
             throw new EE_Error($error_msg);
1688 1688
         }
1689 1689
         //let's provide the ability to filter the views per PAGE AND ROUTE, per PAGE, and globally
1690
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug . '_' . $this->_req_action, $this->_views);
1691
-        $this->_views = apply_filters('FHEE_list_table_views_' . $this->page_slug, $this->_views);
1690
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug.'_'.$this->_req_action, $this->_views);
1691
+        $this->_views = apply_filters('FHEE_list_table_views_'.$this->page_slug, $this->_views);
1692 1692
         $this->_views = apply_filters('FHEE_list_table_views', $this->_views);
1693 1693
         $this->_set_list_table_view();
1694 1694
         $this->_set_list_table_object();
@@ -1763,7 +1763,7 @@  discard block
 block discarded – undo
1763 1763
             // check for current view
1764 1764
             $this->_views[$key]['class'] = $this->_view == $view['slug'] ? 'current' : '';
1765 1765
             $query_args['action'] = $this->_req_action;
1766
-            $query_args[$this->_req_action . '_nonce'] = wp_create_nonce($query_args['action'] . '_nonce');
1766
+            $query_args[$this->_req_action.'_nonce'] = wp_create_nonce($query_args['action'].'_nonce');
1767 1767
             $query_args['status'] = $view['slug'];
1768 1768
             //merge any other arguments sent in.
1769 1769
             if (isset($extra_query_args[$view['slug']])) {
@@ -1801,14 +1801,14 @@  discard block
 block discarded – undo
1801 1801
 					<select id="entries-per-page-slct" name="entries-per-page-slct">';
1802 1802
         foreach ($values as $value) {
1803 1803
             if ($value < $max_entries) {
1804
-                $selected = $value == $per_page ? ' selected="' . $per_page . '"' : '';
1804
+                $selected = $value == $per_page ? ' selected="'.$per_page.'"' : '';
1805 1805
                 $entries_per_page_dropdown .= '
1806
-						<option value="' . $value . '"' . $selected . '>' . $value . '&nbsp;&nbsp;</option>';
1806
+						<option value="' . $value.'"'.$selected.'>'.$value.'&nbsp;&nbsp;</option>';
1807 1807
             }
1808 1808
         }
1809
-        $selected = $max_entries == $per_page ? ' selected="' . $per_page . '"' : '';
1809
+        $selected = $max_entries == $per_page ? ' selected="'.$per_page.'"' : '';
1810 1810
         $entries_per_page_dropdown .= '
1811
-						<option value="' . $max_entries . '"' . $selected . '>All&nbsp;&nbsp;</option>';
1811
+						<option value="' . $max_entries.'"'.$selected.'>All&nbsp;&nbsp;</option>';
1812 1812
         $entries_per_page_dropdown .= '
1813 1813
 					</select>
1814 1814
 					entries
@@ -1830,7 +1830,7 @@  discard block
 block discarded – undo
1830 1830
     public function _set_search_attributes()
1831 1831
     {
1832 1832
         $this->_template_args['search']['btn_label'] = sprintf(__('Search %s', 'event_espresso'), empty($this->_search_btn_label) ? $this->page_label : $this->_search_btn_label);
1833
-        $this->_template_args['search']['callback'] = 'search_' . $this->page_slug;
1833
+        $this->_template_args['search']['callback'] = 'search_'.$this->page_slug;
1834 1834
     }
1835 1835
 
1836 1836
     /*** END LIST TABLE METHODS **/
@@ -1868,7 +1868,7 @@  discard block
 block discarded – undo
1868 1868
                     // user error msg
1869 1869
                     $error_msg = __('An error occurred. The  requested metabox could not be found.', 'event_espresso');
1870 1870
                     // developer error msg
1871
-                    $error_msg .= '||' . sprintf(
1871
+                    $error_msg .= '||'.sprintf(
1872 1872
                                     __(
1873 1873
                                             '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.',
1874 1874
                                             'event_espresso'
@@ -1898,15 +1898,15 @@  discard block
 block discarded – undo
1898 1898
                 && is_array($this->_route_config['columns'])
1899 1899
                 && count($this->_route_config['columns']) === 2
1900 1900
         ) {
1901
-            add_screen_option('layout_columns', array('max' => (int)$this->_route_config['columns'][0], 'default' => (int)$this->_route_config['columns'][1]));
1901
+            add_screen_option('layout_columns', array('max' => (int) $this->_route_config['columns'][0], 'default' => (int) $this->_route_config['columns'][1]));
1902 1902
             $this->_template_args['num_columns'] = $this->_route_config['columns'][0];
1903 1903
             $screen_id = $this->_current_screen->id;
1904
-            $screen_columns = (int)get_user_option("screen_layout_$screen_id");
1904
+            $screen_columns = (int) get_user_option("screen_layout_$screen_id");
1905 1905
             $total_columns = ! empty($screen_columns) ? $screen_columns : $this->_route_config['columns'][1];
1906
-            $this->_template_args['current_screen_widget_class'] = 'columns-' . $total_columns;
1906
+            $this->_template_args['current_screen_widget_class'] = 'columns-'.$total_columns;
1907 1907
             $this->_template_args['current_page'] = $this->_wp_page_slug;
1908 1908
             $this->_template_args['screen'] = $this->_current_screen;
1909
-            $this->_column_template_path = EE_ADMIN_TEMPLATE . 'admin_details_metabox_column_wrapper.template.php';
1909
+            $this->_column_template_path = EE_ADMIN_TEMPLATE.'admin_details_metabox_column_wrapper.template.php';
1910 1910
             //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.
1911 1911
             $this->_route_config['has_metaboxes'] = true;
1912 1912
         }
@@ -1953,7 +1953,7 @@  discard block
 block discarded – undo
1953 1953
      */
1954 1954
     public function espresso_ratings_request()
1955 1955
     {
1956
-        $template_path = EE_ADMIN_TEMPLATE . 'espresso_ratings_request_content.template.php';
1956
+        $template_path = EE_ADMIN_TEMPLATE.'espresso_ratings_request_content.template.php';
1957 1957
         EEH_Template::display_template($template_path, array());
1958 1958
     }
1959 1959
 
@@ -1961,18 +1961,18 @@  discard block
 block discarded – undo
1961 1961
 
1962 1962
     public static function cached_rss_display($rss_id, $url)
1963 1963
     {
1964
-        $loading = '<p class="widget-loading hide-if-no-js">' . __('Loading&#8230;') . '</p><p class="hide-if-js">' . __('This widget requires JavaScript.') . '</p>';
1964
+        $loading = '<p class="widget-loading hide-if-no-js">'.__('Loading&#8230;').'</p><p class="hide-if-js">'.__('This widget requires JavaScript.').'</p>';
1965 1965
         $doing_ajax = (defined('DOING_AJAX') && DOING_AJAX);
1966
-        $pre = '<div class="espresso-rss-display">' . "\n\t";
1967
-        $pre .= '<span id="' . $rss_id . '_url" class="hidden">' . $url . '</span>';
1968
-        $post = '</div>' . "\n";
1969
-        $cache_key = 'ee_rss_' . md5($rss_id);
1966
+        $pre = '<div class="espresso-rss-display">'."\n\t";
1967
+        $pre .= '<span id="'.$rss_id.'_url" class="hidden">'.$url.'</span>';
1968
+        $post = '</div>'."\n";
1969
+        $cache_key = 'ee_rss_'.md5($rss_id);
1970 1970
         if (false != ($output = get_transient($cache_key))) {
1971
-            echo $pre . $output . $post;
1971
+            echo $pre.$output.$post;
1972 1972
             return true;
1973 1973
         }
1974 1974
         if ( ! $doing_ajax) {
1975
-            echo $pre . $loading . $post;
1975
+            echo $pre.$loading.$post;
1976 1976
             return false;
1977 1977
         }
1978 1978
         ob_start();
@@ -2031,7 +2031,7 @@  discard block
 block discarded – undo
2031 2031
 
2032 2032
     public function espresso_sponsors_post_box()
2033 2033
     {
2034
-        $templatepath = EE_ADMIN_TEMPLATE . 'admin_general_metabox_contents_espresso_sponsors.template.php';
2034
+        $templatepath = EE_ADMIN_TEMPLATE.'admin_general_metabox_contents_espresso_sponsors.template.php';
2035 2035
         EEH_Template::display_template($templatepath);
2036 2036
     }
2037 2037
 
@@ -2039,7 +2039,7 @@  discard block
 block discarded – undo
2039 2039
 
2040 2040
     private function _publish_post_box()
2041 2041
     {
2042
-        $meta_box_ref = 'espresso_' . $this->page_slug . '_editor_overview';
2042
+        $meta_box_ref = 'espresso_'.$this->page_slug.'_editor_overview';
2043 2043
         //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)
2044 2044
         if ( ! empty($this->_labels['publishbox'])) {
2045 2045
             $box_label = is_array($this->_labels['publishbox']) ? $this->_labels['publishbox'][$this->_req_action] : $this->_labels['publishbox'];
@@ -2056,7 +2056,7 @@  discard block
 block discarded – undo
2056 2056
     {
2057 2057
         //if we have extra content set let's add it in if not make sure its empty
2058 2058
         $this->_template_args['publish_box_extra_content'] = isset($this->_template_args['publish_box_extra_content']) ? $this->_template_args['publish_box_extra_content'] : '';
2059
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_details_publish_metabox.template.php';
2059
+        $template_path = EE_ADMIN_TEMPLATE.'admin_details_publish_metabox.template.php';
2060 2060
         echo EEH_Template::display_template($template_path, $this->_template_args, true);
2061 2061
     }
2062 2062
 
@@ -2225,7 +2225,7 @@  discard block
 block discarded – undo
2225 2225
         //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)
2226 2226
         $call_back_func = $create_func ? create_function('$post, $metabox',
2227 2227
                 'do_action( "AHEE_log", __FILE__, __FUNCTION__, ""); echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );') : $callback;
2228
-        add_meta_box(str_replace('_', '-', $action) . '-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2228
+        add_meta_box(str_replace('_', '-', $action).'-mbox', $title, $call_back_func, $this->_wp_page_slug, $column, $priority, $callback_args);
2229 2229
     }
2230 2230
 
2231 2231
 
@@ -2305,10 +2305,10 @@  discard block
 block discarded – undo
2305 2305
                 ? 'poststuff'
2306 2306
                 : 'espresso-default-admin';
2307 2307
         $template_path = $sidebar
2308
-                ? EE_ADMIN_TEMPLATE . 'admin_details_wrapper.template.php'
2309
-                : EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar.template.php';
2308
+                ? EE_ADMIN_TEMPLATE.'admin_details_wrapper.template.php'
2309
+                : EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar.template.php';
2310 2310
         if (defined('DOING_AJAX') && DOING_AJAX) {
2311
-            $template_path = EE_ADMIN_TEMPLATE . 'admin_details_wrapper_no_sidebar_ajax.template.php';
2311
+            $template_path = EE_ADMIN_TEMPLATE.'admin_details_wrapper_no_sidebar_ajax.template.php';
2312 2312
         }
2313 2313
         $template_path = ! empty($this->_column_template_path) ? $this->_column_template_path : $template_path;
2314 2314
         $this->_template_args['post_body_content'] = isset($this->_template_args['admin_page_content']) ? $this->_template_args['admin_page_content'] : '';
@@ -2354,7 +2354,7 @@  discard block
 block discarded – undo
2354 2354
                         true
2355 2355
                 )
2356 2356
                 : $this->_template_args['preview_action_button'];
2357
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_caf_full_page_preview.template.php';
2357
+        $template_path = EE_ADMIN_TEMPLATE.'admin_caf_full_page_preview.template.php';
2358 2358
         $this->_template_args['admin_page_content'] = EEH_Template::display_template(
2359 2359
                 $template_path,
2360 2360
                 $this->_template_args,
@@ -2405,7 +2405,7 @@  discard block
 block discarded – undo
2405 2405
         //setup search attributes
2406 2406
         $this->_set_search_attributes();
2407 2407
         $this->_template_args['current_page'] = $this->_wp_page_slug;
2408
-        $template_path = EE_ADMIN_TEMPLATE . 'admin_list_wrapper.template.php';
2408
+        $template_path = EE_ADMIN_TEMPLATE.'admin_list_wrapper.template.php';
2409 2409
         $this->_template_args['table_url'] = defined('DOING_AJAX')
2410 2410
                 ? add_query_arg(array('noheader' => 'true', 'route' => $this->_req_action), $this->_admin_base_url)
2411 2411
                 : add_query_arg(array('route' => $this->_req_action), $this->_admin_base_url);
@@ -2415,29 +2415,29 @@  discard block
 block discarded – undo
2415 2415
         $ajax_sorting_callback = $this->_list_table_object->get_ajax_sorting_callback();
2416 2416
         if ( ! empty($ajax_sorting_callback)) {
2417 2417
             $sortable_list_table_form_fields = wp_nonce_field(
2418
-                    $ajax_sorting_callback . '_nonce',
2419
-                    $ajax_sorting_callback . '_nonce',
2418
+                    $ajax_sorting_callback.'_nonce',
2419
+                    $ajax_sorting_callback.'_nonce',
2420 2420
                     false,
2421 2421
                     false
2422 2422
             );
2423 2423
             //			$reorder_action = 'espresso_' . $ajax_sorting_callback . '_nonce';
2424 2424
             //			$sortable_list_table_form_fields = wp_nonce_field( $reorder_action, 'ajax_table_sort_nonce', FALSE, FALSE );
2425
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="' . $this->page_slug . '" />';
2426
-            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="' . $ajax_sorting_callback . '" />';
2425
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_page" name="ajax_table_sort_page" value="'.$this->page_slug.'" />';
2426
+            $sortable_list_table_form_fields .= '<input type="hidden" id="ajax_table_sort_action" name="ajax_table_sort_action" value="'.$ajax_sorting_callback.'" />';
2427 2427
         } else {
2428 2428
             $sortable_list_table_form_fields = '';
2429 2429
         }
2430 2430
         $this->_template_args['sortable_list_table_form_fields'] = $sortable_list_table_form_fields;
2431 2431
         $hidden_form_fields = isset($this->_template_args['list_table_hidden_fields']) ? $this->_template_args['list_table_hidden_fields'] : '';
2432
-        $nonce_ref = $this->_req_action . '_nonce';
2433
-        $hidden_form_fields .= '<input type="hidden" name="' . $nonce_ref . '" value="' . wp_create_nonce($nonce_ref) . '">';
2432
+        $nonce_ref = $this->_req_action.'_nonce';
2433
+        $hidden_form_fields .= '<input type="hidden" name="'.$nonce_ref.'" value="'.wp_create_nonce($nonce_ref).'">';
2434 2434
         $this->_template_args['list_table_hidden_fields'] = $hidden_form_fields;
2435 2435
         //display message about search results?
2436 2436
         $this->_template_args['before_list_table'] .= ! empty($this->_req_data['s'])
2437
-                ? '<p class="ee-search-results">' . sprintf(
2437
+                ? '<p class="ee-search-results">'.sprintf(
2438 2438
                         esc_html__('Displaying search results for the search string: %1$s', 'event_espresso'),
2439 2439
                         trim($this->_req_data['s'], '%')
2440
-                ) . '</p>'
2440
+                ).'</p>'
2441 2441
                 : '';
2442 2442
         // filter before_list_table template arg
2443 2443
         $this->_template_args['before_list_table'] = apply_filters(
@@ -2511,8 +2511,8 @@  discard block
 block discarded – undo
2511 2511
      */
2512 2512
     protected function _display_legend($items)
2513 2513
     {
2514
-        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array)$items, $this);
2515
-        $legend_template = EE_ADMIN_TEMPLATE . 'admin_details_legend.template.php';
2514
+        $this->_template_args['items'] = apply_filters('FHEE__EE_Admin_Page___display_legend__items', (array) $items, $this);
2515
+        $legend_template = EE_ADMIN_TEMPLATE.'admin_details_legend.template.php';
2516 2516
         return EEH_Template::display_template($legend_template, $this->_template_args, true);
2517 2517
     }
2518 2518
 
@@ -2604,15 +2604,15 @@  discard block
 block discarded – undo
2604 2604
         $this->_nav_tabs = $this->_get_main_nav_tabs();
2605 2605
         $this->_template_args['nav_tabs'] = $this->_nav_tabs;
2606 2606
         $this->_template_args['admin_page_title'] = $this->_admin_page_title;
2607
-        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content' . $this->_current_page . $this->_current_view,
2607
+        $this->_template_args['before_admin_page_content'] = apply_filters('FHEE_before_admin_page_content'.$this->_current_page.$this->_current_view,
2608 2608
                 isset($this->_template_args['before_admin_page_content']) ? $this->_template_args['before_admin_page_content'] : '');
2609
-        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content' . $this->_current_page . $this->_current_view,
2609
+        $this->_template_args['after_admin_page_content'] = apply_filters('FHEE_after_admin_page_content'.$this->_current_page.$this->_current_view,
2610 2610
                 isset($this->_template_args['after_admin_page_content']) ? $this->_template_args['after_admin_page_content'] : '');
2611 2611
         $this->_template_args['after_admin_page_content'] .= $this->_set_help_popup_content();
2612 2612
         // load settings page wrapper template
2613
-        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE . 'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE . 'admin_wrapper_ajax.template.php';
2613
+        $template_path = ! defined('DOING_AJAX') ? EE_ADMIN_TEMPLATE.'admin_wrapper.template.php' : EE_ADMIN_TEMPLATE.'admin_wrapper_ajax.template.php';
2614 2614
         //about page?
2615
-        $template_path = $about ? EE_ADMIN_TEMPLATE . 'about_admin_wrapper.template.php' : $template_path;
2615
+        $template_path = $about ? EE_ADMIN_TEMPLATE.'about_admin_wrapper.template.php' : $template_path;
2616 2616
         if (defined('DOING_AJAX')) {
2617 2617
             $this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, true);
2618 2618
             $this->_return_json();
@@ -2684,20 +2684,20 @@  discard block
 block discarded – undo
2684 2684
     protected function _set_save_buttons($both = true, $text = array(), $actions = array(), $referrer = null)
2685 2685
     {
2686 2686
         //make sure $text and $actions are in an array
2687
-        $text = (array)$text;
2688
-        $actions = (array)$actions;
2687
+        $text = (array) $text;
2688
+        $actions = (array) $actions;
2689 2689
         $referrer_url = empty($referrer) ? '' : $referrer;
2690
-        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $_SERVER['REQUEST_URI'] . '" />'
2691
-                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="' . $referrer . '" />';
2690
+        $referrer_url = ! $referrer ? '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$_SERVER['REQUEST_URI'].'" />'
2691
+                : '<input type="hidden" id="save_and_close_referrer" name="save_and_close_referrer" value="'.$referrer.'" />';
2692 2692
         $button_text = ! empty($text) ? $text : array(__('Save', 'event_espresso'), __('Save and Close', 'event_espresso'));
2693 2693
         $default_names = array('save', 'save_and_close');
2694 2694
         //add in a hidden index for the current page (so save and close redirects properly)
2695 2695
         $this->_template_args['save_buttons'] = $referrer_url;
2696 2696
         foreach ($button_text as $key => $button) {
2697 2697
             $ref = $default_names[$key];
2698
-            $id = $this->_current_view . '_' . $ref;
2698
+            $id = $this->_current_view.'_'.$ref;
2699 2699
             $name = ! empty($actions) ? $actions[$key] : $ref;
2700
-            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary ' . $ref . '" value="' . $button . '" name="' . $name . '" id="' . $id . '" />';
2700
+            $this->_template_args['save_buttons'] .= '<input type="submit" class="button-primary '.$ref.'" value="'.$button.'" name="'.$name.'" id="'.$id.'" />';
2701 2701
             if ( ! $both) {
2702 2702
                 break;
2703 2703
             }
@@ -2733,15 +2733,15 @@  discard block
 block discarded – undo
2733 2733
     {
2734 2734
         if (empty($route)) {
2735 2735
             $user_msg = __('An error occurred. No action was set for this page\'s form.', 'event_espresso');
2736
-            $dev_msg = $user_msg . "\n" . sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2737
-            EE_Error::add_error($user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__);
2736
+            $dev_msg = $user_msg."\n".sprintf(__('The $route argument is required for the %s->%s method.', 'event_espresso'), __FUNCTION__, __CLASS__);
2737
+            EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__);
2738 2738
         }
2739 2739
         // open form
2740
-        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="' . $this->_admin_base_url . '" id="' . $route . '_event_form" >';
2740
+        $this->_template_args['before_admin_page_content'] = '<form name="form" method="post" action="'.$this->_admin_base_url.'" id="'.$route.'_event_form" >';
2741 2741
         // add nonce
2742
-        $nonce = wp_nonce_field($route . '_nonce', $route . '_nonce', false, false);
2742
+        $nonce = wp_nonce_field($route.'_nonce', $route.'_nonce', false, false);
2743 2743
         //		$nonce = wp_nonce_field( $route . '_nonce', '_wpnonce', FALSE, FALSE );
2744
-        $this->_template_args['before_admin_page_content'] .= "\n\t" . $nonce;
2744
+        $this->_template_args['before_admin_page_content'] .= "\n\t".$nonce;
2745 2745
         // add REQUIRED form action
2746 2746
         $hidden_fields = array(
2747 2747
                 'action' => array('type' => 'hidden', 'value' => $route),
@@ -2751,8 +2751,8 @@  discard block
 block discarded – undo
2751 2751
         // generate form fields
2752 2752
         $form_fields = $this->_generate_admin_form_fields($hidden_fields, 'array');
2753 2753
         // add fields to form
2754
-        foreach ((array)$form_fields as $field_name => $form_field) {
2755
-            $this->_template_args['before_admin_page_content'] .= "\n\t" . $form_field['field'];
2754
+        foreach ((array) $form_fields as $field_name => $form_field) {
2755
+            $this->_template_args['before_admin_page_content'] .= "\n\t".$form_field['field'];
2756 2756
         }
2757 2757
         // close form
2758 2758
         $this->_template_args['after_admin_page_content'] = '</form>';
@@ -2833,7 +2833,7 @@  discard block
 block discarded – undo
2833 2833
          * @param array $query_args       The original query_args array coming into the
2834 2834
          *                                method.
2835 2835
          */
2836
-        do_action('AHEE__' . $classname . '___redirect_after_action__before_redirect_modification_' . $this->_req_action, $query_args);
2836
+        do_action('AHEE__'.$classname.'___redirect_after_action__before_redirect_modification_'.$this->_req_action, $query_args);
2837 2837
         //calculate where we're going (if we have a "save and close" button pushed)
2838 2838
         if (isset($this->_req_data['save_and_close']) && isset($this->_req_data['save_and_close_referrer'])) {
2839 2839
             // even though we have the save_and_close referrer, we need to parse the url for the action in order to generate a nonce
@@ -2849,7 +2849,7 @@  discard block
 block discarded – undo
2849 2849
             foreach ($this->_default_route_query_args as $query_param => $query_value) {
2850 2850
                 //is there a wp_referer array in our _default_route_query_args property?
2851 2851
                 if ($query_param == 'wp_referer') {
2852
-                    $query_value = (array)$query_value;
2852
+                    $query_value = (array) $query_value;
2853 2853
                     foreach ($query_value as $reference => $value) {
2854 2854
                         if (strpos($reference, 'nonce') !== false) {
2855 2855
                             continue;
@@ -2875,11 +2875,11 @@  discard block
 block discarded – undo
2875 2875
         // if redirecting to anything other than the main page, add a nonce
2876 2876
         if (isset($query_args['action'])) {
2877 2877
             // manually generate wp_nonce and merge that with the query vars becuz the wp_nonce_url function wrecks havoc on some vars
2878
-            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'] . '_nonce');
2878
+            $query_args['_wpnonce'] = wp_create_nonce($query_args['action'].'_nonce');
2879 2879
         }
2880 2880
         //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).
2881
-        do_action('AHEE_redirect_' . $classname . $this->_req_action, $query_args);
2882
-        $redirect_url = apply_filters('FHEE_redirect_' . $classname . $this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2881
+        do_action('AHEE_redirect_'.$classname.$this->_req_action, $query_args);
2882
+        $redirect_url = apply_filters('FHEE_redirect_'.$classname.$this->_req_action, self::add_query_args_and_nonce($query_args, $redirect_url), $query_args);
2883 2883
         // check if we're doing ajax.  If we are then lets just return the results and js can handle how it wants.
2884 2884
         if (defined('DOING_AJAX')) {
2885 2885
             $default_data = array(
@@ -3009,7 +3009,7 @@  discard block
 block discarded – undo
3009 3009
         $args = array(
3010 3010
                 'label'   => $this->_admin_page_title,
3011 3011
                 'default' => 10,
3012
-                'option'  => $this->_current_page . '_' . $this->_current_view . '_per_page',
3012
+                'option'  => $this->_current_page.'_'.$this->_current_view.'_per_page',
3013 3013
         );
3014 3014
         //ONLY add the screen option if the user has access to it.
3015 3015
         if ($this->check_user_access($this->_current_view, true)) {
@@ -3042,8 +3042,8 @@  discard block
 block discarded – undo
3042 3042
             $map_option = $option;
3043 3043
             $option = str_replace('-', '_', $option);
3044 3044
             switch ($map_option) {
3045
-                case $this->_current_page . '_' . $this->_current_view . '_per_page':
3046
-                    $value = (int)$value;
3045
+                case $this->_current_page.'_'.$this->_current_view.'_per_page':
3046
+                    $value = (int) $value;
3047 3047
                     if ($value < 1 || $value > 999) {
3048 3048
                         return;
3049 3049
                     }
@@ -3070,7 +3070,7 @@  discard block
 block discarded – undo
3070 3070
      */
3071 3071
     public function set_template_args($data)
3072 3072
     {
3073
-        $this->_template_args = array_merge($this->_template_args, (array)$data);
3073
+        $this->_template_args = array_merge($this->_template_args, (array) $data);
3074 3074
     }
3075 3075
 
3076 3076
 
@@ -3092,12 +3092,12 @@  discard block
 block discarded – undo
3092 3092
             $this->_verify_route($route);
3093 3093
         }
3094 3094
         //now let's set the string for what kind of transient we're setting
3095
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3095
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3096 3096
         $data = $notices ? array('notices' => $data) : $data;
3097 3097
         //is there already a transient for this route?  If there is then let's ADD to that transient
3098 3098
         $existing = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3099 3099
         if ($existing) {
3100
-            $data = array_merge((array)$data, (array)$existing);
3100
+            $data = array_merge((array) $data, (array) $existing);
3101 3101
         }
3102 3102
         if (is_multisite() && is_network_admin()) {
3103 3103
             set_site_transient($transient, $data, 8);
@@ -3118,7 +3118,7 @@  discard block
 block discarded – undo
3118 3118
     {
3119 3119
         $user_id = get_current_user_id();
3120 3120
         $route = ! $route ? $this->_req_action : $route;
3121
-        $transient = $notices ? 'ee_rte_n_tx_' . $route . '_' . $user_id : 'rte_tx_' . $route . '_' . $user_id;
3121
+        $transient = $notices ? 'ee_rte_n_tx_'.$route.'_'.$user_id : 'rte_tx_'.$route.'_'.$user_id;
3122 3122
         $data = is_multisite() && is_network_admin() ? get_site_transient($transient) : get_transient($transient);
3123 3123
         //delete transient after retrieval (just in case it hasn't expired);
3124 3124
         if (is_multisite() && is_network_admin()) {
@@ -3359,7 +3359,7 @@  discard block
 block discarded – undo
3359 3359
      */
3360 3360
     protected function _next_link($url, $class = 'dashicons dashicons-arrow-right')
3361 3361
     {
3362
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3362
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3363 3363
     }
3364 3364
 
3365 3365
 
@@ -3373,7 +3373,7 @@  discard block
 block discarded – undo
3373 3373
      */
3374 3374
     protected function _previous_link($url, $class = 'dashicons dashicons-arrow-left')
3375 3375
     {
3376
-        return '<a class="' . $class . '" href="' . $url . '"></a>';
3376
+        return '<a class="'.$class.'" href="'.$url.'"></a>';
3377 3377
     }
3378 3378
 
3379 3379
 
Please login to merge, or discard this patch.